-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.html
132 lines (99 loc) · 4.87 KB
/
example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE html>
<html>
<body>
<p>Vendor HTML page</p>
<script type="module">
import {Heimdall, TidePromise, FieldData} from './src/heimdall.js';
const config = {
vendorPublic: "+g/dDdxLqJMOLpJMZ3WIiJ1PEe/12bNhDoIBFmAvgR8=",
vendorLocationSignature: "0dYi2k4V8Qa5BfKkNSkqcCGQ4d1BIJm6+A5Pwl8DNbZcxQljPnbNk0KG5FTkWjDTbckKHSG7xi1xuzb38uy3Bg==",
homeORKUrl: "http://localhost:1001",
vendorReturnAuthUrl: "http://localhost:6001?jwt=",
enclaveRequest: {
refreshToken: true, // I want a TideJWT returned
customModel: undefined // I do not want to provide a customModel
}
}
const heimdall = new Heimdall(config);
const tidePromise = new TidePromise();
const tideButtonAction = async (promise) => {
return heimdall.GetUserInfo(promise);
}
const tideButton = heimdall.AddTideButton(tideButtonAction, tidePromise);
const resolvedData = await tidePromise.promise;
console.log(resolvedData.UID)
// i need the uid
const enc = new TextEncoder();
const dec = new TextDecoder();
// time to encrypt some data
// create fieldData
const encryptPromise = new TidePromise();
const idList = ["password", "username"]
const fieldData = new FieldData(idList);
fieldData.add(enc.encode("test to encrypt"), ["password"]);
const ac2 = async(params) => {
return await heimdall.EncryptUserData(params);
}
const params = [resolvedData.UID, fieldData, encryptPromise];
const tBtn2 = heimdall.AddTideButton(ac2, params);
tBtn2.style.background = "blue";
const serializedFields = await encryptPromise.promise;
console.log(serializedFields);
const decryptPromise = new TidePromise();
const ac3 = async(params) => {
return await heimdall.DecryptUserData(params);
}
const params2 = [resolvedData.UID, serializedFields, decryptPromise];
const tBtn3 = heimdall.AddTideButton(ac3, params2);
tBtn3.style.background = "purple";
const decrypted = await decryptPromise.promise;
const fieldData2 = new FieldData(idList);
fieldData2.addManyWithTag(decrypted);
const fdIds = fieldData2.getAllWithIds();
console.log(fdIds);
console.log(dec.decode(fdIds[0].Data));
</script>
<!--script type="module">
import {Heimdall, TidePromise, FieldData} from './heimdall.js';
const config = {
vendorPublic: "+g/dDdxLqJMOLpJMZ3WIiJ1PEe/12bNhDoIBFmAvgR8=",
vendorUrlSignature: "0dYi2k4V8Qa5BfKkNSkqcCGQ4d1BIJm6+A5Pwl8DNbZcxQljPnbNk0KG5FTkWjDTbckKHSG7xi1xuzb38uy3Bg==",
homeORKUrl: "https://prod-ork1.azurewebsites.net",
vendorReturnAuthUrl: "http://localhost:6001?jwt=",
enclaveRequest: {
refreshToken: true, // I want a TideJWT returned
customModel: undefined // I do not want to provide a customModel
}
}
const heimdall = new Heimdall(config);
const jwt = "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiJjZGMxOTJhOGFmNzc5NjQwMmQzYjNlYzg4YzkzMWYxZmQzODc1YjQwMGRhOGFkZjg4MGI3Y2QzMDNhODFmODA1IiwiZXhwIjoxNzAxNjU2ODE5LCJnU2Vzc0tleVB1YiI6Ik95ZForZmROdWxCMHhwYm9jWGNLY3BHSS9kUGh5YTkwKzBwWmpKalhHanM9IiwiZ1ZWSyI6IjRnT3B0NElXeDRpckx6L3BLQ3dzM1BPa2RqOG9HSDBBb0pVTXpWdXQ4VTA9In0.4XLEzkJRklN0ZQt-GBGOtHOx-esomCIP0VXioaG-8Eu1eVdGFWJg-o22i4uiOIAnImcus5w1OIs2ze9gjJwHAw";
const tidePromise = new TidePromise();
const fieldData = new FieldData(["password", "username"]);
fieldData.add("test to encrypt", ["password"]);
fieldData.add("test2", ["username"]);
fieldData.add("test3", ["username", "password"])
const params = [jwt, fieldData, tidePromise];
const tideButtonAction = async (params) => {
return heimdall.TESTencryptUserDataTEST(params);
}
const tideButtonAction2 = async (params) => {
return heimdall.TESTdecryptUserDataTEST(params);
}
const tideButton = heimdall.AddTideButton(tideButtonAction, params);
const encrypted = await tidePromise.promise;
console.log(encrypted)
tideButton.remove();
const tidePromise2 = new TidePromise();
const params2 = [jwt, encrypted, tidePromise2];
const tideButton2 = heimdall.AddTideButton(tideButtonAction2, params2);
//console.log(resolvedData.ModelSig)
const decrypted = await tidePromise2.promise;
tideButton2.remove()
const fieldData2 = new FieldData(["password", "username"]);
fieldData2.addManyWithTag(decrypted);
console.log(fieldData2.getAllWithIds());
</script-->
<script>
</script>
</body>
</html>