smoothly 0.1.114 → 0.1.115
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{Notice-9c2b52b7.js → Notice-839702d8.js} +34 -26
- package/dist/cjs/{Trigger-74bd1ee8.js → Trigger-cf376531.js} +55 -146
- package/dist/cjs/{index-41a36ce2.js → index-1c61bdd3.js} +27 -1
- package/dist/cjs/index.cjs.js +20 -8
- package/dist/cjs/loader.cjs.js +3 -19
- package/dist/cjs/{smoothly-accordion_50.cjs.entry.js → smoothly-accordion_51.cjs.entry.js} +7689 -1483
- package/dist/cjs/smoothly-google-font.cjs.entry.js +2 -2
- package/dist/cjs/smoothly-radio-group.cjs.entry.js +2 -2
- package/dist/cjs/smoothly-reorder.cjs.entry.js +2 -2
- package/dist/cjs/smoothly-trigger-sink.cjs.entry.js +5 -5
- package/dist/cjs/smoothly-trigger-source.cjs.entry.js +5 -5
- package/dist/cjs/smoothly.cjs.js +5 -113
- package/dist/collection/collection-manifest.json +3 -2
- package/dist/collection/components/app-demo/index.js +6 -1
- package/dist/collection/components/button/index.js +168 -0
- package/dist/collection/components/button/style.css +49 -0
- package/dist/collection/components/picker/index.js +10 -6
- package/dist/collection/components/trigger/style.css +3 -3
- package/dist/custom-elements/index.d.ts +6 -0
- package/dist/custom-elements/index.js +7776 -2966
- package/dist/esm/{Notice-4131b4e0.js → Notice-608b552c.js} +34 -26
- package/dist/esm/{Trigger-d7b181ec.js → Trigger-365408f0.js} +55 -146
- package/dist/esm/{index-dcb2b612.js → index-a3737440.js} +27 -1
- package/dist/esm/index.js +17 -4
- package/dist/esm/loader.js +3 -19
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/{smoothly-accordion_50.entry.js → smoothly-accordion_51.entry.js} +7689 -1484
- package/dist/esm/smoothly-google-font.entry.js +2 -2
- package/dist/esm/smoothly-radio-group.entry.js +2 -2
- package/dist/esm/smoothly-reorder.entry.js +2 -2
- package/dist/esm/smoothly-trigger-sink.entry.js +3 -3
- package/dist/esm/smoothly-trigger-source.entry.js +3 -3
- package/dist/esm/smoothly.js +5 -113
- package/dist/smoothly/index.esm.js +1 -376
- package/dist/smoothly/p-0215b4da.entry.js +1 -0
- package/dist/smoothly/{p-074a0448.js → p-0cba3e3d.js} +1 -1
- package/dist/smoothly/p-18a1063c.entry.js +1 -0
- package/dist/smoothly/p-6ca0d36c.js +1 -0
- package/dist/smoothly/p-6f009ac9.entry.js +1 -0
- package/dist/smoothly/p-7a30d9b8.js +1 -0
- package/dist/smoothly/p-8ae38136.entry.js +1 -0
- package/dist/smoothly/p-993534fa.entry.js +1 -0
- package/dist/smoothly/p-eec1c703.entry.js +1 -0
- package/dist/smoothly/smoothly.esm.js +1 -125
- package/dist/types/components/button/index.d.ts +11 -0
- package/dist/types/components.d.ts +27 -0
- package/dist/types/stencil-public-runtime.d.ts +6 -4
- package/package.json +17 -17
- package/dist/cjs/App-339acc9b.js +0 -647
- package/dist/cjs/_commonjsHelpers-10109b76.js +0 -48
- package/dist/cjs/app-globals-3a1e7e63.js +0 -5
- package/dist/cjs/css-shim-88cc6900.js +0 -6
- package/dist/cjs/dom-95afd968.js +0 -75
- package/dist/cjs/generate-f9a36f25.js +0 -66
- package/dist/cjs/index-138c41c2.js +0 -3066
- package/dist/cjs/index-36da3c23.js +0 -1673
- package/dist/cjs/index-40d009d5.js +0 -1354
- package/dist/cjs/index-ac32385c.js +0 -18850
- package/dist/cjs/shadow-css-71d0f821.js +0 -391
- package/dist/cjs/smoothly-accordion-item.cjs.entry.js +0 -54
- package/dist/cjs/smoothly-accordion.cjs.entry.js +0 -55
- package/dist/cjs/smoothly-app-demo.cjs.entry.js +0 -29
- package/dist/cjs/smoothly-app.cjs.entry.js +0 -19
- package/dist/cjs/smoothly-backtotop.cjs.entry.js +0 -37
- package/dist/cjs/smoothly-calendar.cjs.entry.js +0 -95
- package/dist/cjs/smoothly-checkbox.cjs.entry.js +0 -18671
- package/dist/cjs/smoothly-dialog-demo.cjs.entry.js +0 -16
- package/dist/cjs/smoothly-dialog.cjs.entry.js +0 -38
- package/dist/cjs/smoothly-display-amount.cjs.entry.js +0 -59
- package/dist/cjs/smoothly-display-date-time.cjs.entry.js +0 -20
- package/dist/cjs/smoothly-display-demo.cjs.entry.js +0 -25
- package/dist/cjs/smoothly-display.cjs.entry.js +0 -41
- package/dist/cjs/smoothly-frame.cjs.entry.js +0 -50
- package/dist/cjs/smoothly-icon-demo.cjs.entry.js +0 -491
- package/dist/cjs/smoothly-icon.cjs.entry.js +0 -52
- package/dist/cjs/smoothly-input-date-range.cjs.entry.js +0 -50
- package/dist/cjs/smoothly-input-date.cjs.entry.js +0 -44
- package/dist/cjs/smoothly-input-demo.cjs.entry.js +0 -19
- package/dist/cjs/smoothly-input-month.cjs.entry.js +0 -41
- package/dist/cjs/smoothly-input.cjs.entry.js +0 -202
- package/dist/cjs/smoothly-item.cjs.entry.js +0 -43
- package/dist/cjs/smoothly-menu-options.cjs.entry.js +0 -108
- package/dist/cjs/smoothly-notification.cjs.entry.js +0 -67
- package/dist/cjs/smoothly-notifier.cjs.entry.js +0 -29
- package/dist/cjs/smoothly-option.cjs.entry.js +0 -33
- package/dist/cjs/smoothly-picker.cjs.entry.js +0 -151
- package/dist/cjs/smoothly-popup.cjs.entry.js +0 -38
- package/dist/cjs/smoothly-quiet.cjs.entry.js +0 -19
- package/dist/cjs/smoothly-radio.cjs.entry.js +0 -28
- package/dist/cjs/smoothly-room.cjs.entry.js +0 -16
- package/dist/cjs/smoothly-select-demo.cjs.entry.js +0 -86
- package/dist/cjs/smoothly-select.cjs.entry.js +0 -31
- package/dist/cjs/smoothly-selector.cjs.entry.js +0 -119
- package/dist/cjs/smoothly-skeleton.cjs.entry.js +0 -27
- package/dist/cjs/smoothly-spinner.cjs.entry.js +0 -24
- package/dist/cjs/smoothly-submit.cjs.entry.js +0 -60
- package/dist/cjs/smoothly-svg.cjs.entry.js +0 -41
- package/dist/cjs/smoothly-tab-switch.cjs.entry.js +0 -32
- package/dist/cjs/smoothly-tab.cjs.entry.js +0 -37
- package/dist/cjs/smoothly-table-cell.cjs.entry.js +0 -19
- package/dist/cjs/smoothly-table-demo.cjs.entry.js +0 -22
- package/dist/cjs/smoothly-table-expandable-cell.cjs.entry.js +0 -45
- package/dist/cjs/smoothly-table-expandable-row.cjs.entry.js +0 -32
- package/dist/cjs/smoothly-table-header.cjs.entry.js +0 -41
- package/dist/cjs/smoothly-table-row.cjs.entry.js +0 -38
- package/dist/cjs/smoothly-table.cjs.entry.js +0 -26
- package/dist/cjs/smoothly-trigger.cjs.entry.js +0 -36
- package/dist/cjs/smoothly-tuple.cjs.entry.js +0 -16
- package/dist/cjs/smoothly-urlencoded.cjs.entry.js +0 -19
- package/dist/esm/App-22187759.js +0 -645
- package/dist/esm/_commonjsHelpers-8fe71198.js +0 -44
- package/dist/esm/app-globals-0f993ce5.js +0 -3
- package/dist/esm/css-shim-c64026cd.js +0 -4
- package/dist/esm/dom-a712b575.js +0 -73
- package/dist/esm/generate-50b98474.js +0 -61
- package/dist/esm/index-02a70ac1.js +0 -3027
- package/dist/esm/index-a5a08f46.js +0 -18848
- package/dist/esm/index-c8b5d468.js +0 -1349
- package/dist/esm/index-d1360bcf.js +0 -1671
- package/dist/esm/shadow-css-1e16431b.js +0 -389
- package/dist/esm/smoothly-accordion-item.entry.js +0 -50
- package/dist/esm/smoothly-accordion.entry.js +0 -51
- package/dist/esm/smoothly-app-demo.entry.js +0 -25
- package/dist/esm/smoothly-app.entry.js +0 -15
- package/dist/esm/smoothly-backtotop.entry.js +0 -33
- package/dist/esm/smoothly-calendar.entry.js +0 -91
- package/dist/esm/smoothly-checkbox.entry.js +0 -18667
- package/dist/esm/smoothly-dialog-demo.entry.js +0 -12
- package/dist/esm/smoothly-dialog.entry.js +0 -34
- package/dist/esm/smoothly-display-amount.entry.js +0 -55
- package/dist/esm/smoothly-display-date-time.entry.js +0 -16
- package/dist/esm/smoothly-display-demo.entry.js +0 -21
- package/dist/esm/smoothly-display.entry.js +0 -37
- package/dist/esm/smoothly-frame.entry.js +0 -46
- package/dist/esm/smoothly-icon-demo.entry.js +0 -487
- package/dist/esm/smoothly-icon.entry.js +0 -48
- package/dist/esm/smoothly-input-date-range.entry.js +0 -46
- package/dist/esm/smoothly-input-date.entry.js +0 -40
- package/dist/esm/smoothly-input-demo.entry.js +0 -15
- package/dist/esm/smoothly-input-month.entry.js +0 -37
- package/dist/esm/smoothly-input.entry.js +0 -198
- package/dist/esm/smoothly-item.entry.js +0 -39
- package/dist/esm/smoothly-menu-options.entry.js +0 -104
- package/dist/esm/smoothly-notification.entry.js +0 -63
- package/dist/esm/smoothly-notifier.entry.js +0 -25
- package/dist/esm/smoothly-option.entry.js +0 -29
- package/dist/esm/smoothly-picker.entry.js +0 -147
- package/dist/esm/smoothly-popup.entry.js +0 -34
- package/dist/esm/smoothly-quiet.entry.js +0 -15
- package/dist/esm/smoothly-radio.entry.js +0 -24
- package/dist/esm/smoothly-room.entry.js +0 -12
- package/dist/esm/smoothly-select-demo.entry.js +0 -82
- package/dist/esm/smoothly-select.entry.js +0 -27
- package/dist/esm/smoothly-selector.entry.js +0 -115
- package/dist/esm/smoothly-skeleton.entry.js +0 -23
- package/dist/esm/smoothly-spinner.entry.js +0 -20
- package/dist/esm/smoothly-submit.entry.js +0 -56
- package/dist/esm/smoothly-svg.entry.js +0 -37
- package/dist/esm/smoothly-tab-switch.entry.js +0 -28
- package/dist/esm/smoothly-tab.entry.js +0 -33
- package/dist/esm/smoothly-table-cell.entry.js +0 -15
- package/dist/esm/smoothly-table-demo.entry.js +0 -18
- package/dist/esm/smoothly-table-expandable-cell.entry.js +0 -41
- package/dist/esm/smoothly-table-expandable-row.entry.js +0 -28
- package/dist/esm/smoothly-table-header.entry.js +0 -37
- package/dist/esm/smoothly-table-row.entry.js +0 -34
- package/dist/esm/smoothly-table.entry.js +0 -22
- package/dist/esm/smoothly-trigger.entry.js +0 -32
- package/dist/esm/smoothly-tuple.entry.js +0 -12
- package/dist/esm/smoothly-urlencoded.entry.js +0 -15
- package/dist/smoothly/App-22187759.js +0 -645
- package/dist/smoothly/GoogleFont-8474516b.js +0 -21
- package/dist/smoothly/_commonjsHelpers-8fe71198.js +0 -44
- package/dist/smoothly/app-globals-0f993ce5.js +0 -3
- package/dist/smoothly/css-shim-c64026cd.js +0 -4
- package/dist/smoothly/dom-a712b575.js +0 -73
- package/dist/smoothly/generate-50b98474.js +0 -61
- package/dist/smoothly/index-02a70ac1.js +0 -3027
- package/dist/smoothly/index-a5a08f46.js +0 -18848
- package/dist/smoothly/index-c8b5d468.js +0 -1349
- package/dist/smoothly/index-d1360bcf.js +0 -1671
- package/dist/smoothly/p-0bad2c46.entry.js +0 -1
- package/dist/smoothly/p-0c1e9588.entry.js +0 -1
- package/dist/smoothly/p-14232157.entry.js +0 -1
- package/dist/smoothly/p-19518931.js +0 -1
- package/dist/smoothly/p-22d4d5a7.entry.js +0 -1
- package/dist/smoothly/p-2cda1784.js +0 -1
- package/dist/smoothly/p-9fa3ab06.entry.js +0 -1
- package/dist/smoothly/p-b8a3e273.entry.js +0 -1
- package/dist/smoothly/shadow-css-1e16431b.js +0 -389
- package/dist/smoothly/smoothly-accordion-item.entry.js +0 -50
- package/dist/smoothly/smoothly-accordion.entry.js +0 -51
- package/dist/smoothly/smoothly-app-demo.entry.js +0 -25
- package/dist/smoothly/smoothly-app.entry.js +0 -15
- package/dist/smoothly/smoothly-backtotop.entry.js +0 -33
- package/dist/smoothly/smoothly-calendar.entry.js +0 -91
- package/dist/smoothly/smoothly-checkbox.entry.js +0 -18667
- package/dist/smoothly/smoothly-dialog-demo.entry.js +0 -12
- package/dist/smoothly/smoothly-dialog.entry.js +0 -34
- package/dist/smoothly/smoothly-display-amount.entry.js +0 -55
- package/dist/smoothly/smoothly-display-date-time.entry.js +0 -16
- package/dist/smoothly/smoothly-display-demo.entry.js +0 -21
- package/dist/smoothly/smoothly-display.entry.js +0 -37
- package/dist/smoothly/smoothly-frame.entry.js +0 -46
- package/dist/smoothly/smoothly-google-font.entry.js +0 -13
- package/dist/smoothly/smoothly-icon-demo.entry.js +0 -487
- package/dist/smoothly/smoothly-icon.entry.js +0 -48
- package/dist/smoothly/smoothly-input-date-range.entry.js +0 -46
- package/dist/smoothly/smoothly-input-date.entry.js +0 -40
- package/dist/smoothly/smoothly-input-demo.entry.js +0 -15
- package/dist/smoothly/smoothly-input-month.entry.js +0 -37
- package/dist/smoothly/smoothly-input.entry.js +0 -198
- package/dist/smoothly/smoothly-item.entry.js +0 -39
- package/dist/smoothly/smoothly-menu-options.entry.js +0 -104
- package/dist/smoothly/smoothly-notification.entry.js +0 -63
- package/dist/smoothly/smoothly-notifier.entry.js +0 -25
- package/dist/smoothly/smoothly-option.entry.js +0 -29
- package/dist/smoothly/smoothly-picker.entry.js +0 -147
- package/dist/smoothly/smoothly-popup.entry.js +0 -34
- package/dist/smoothly/smoothly-quiet.entry.js +0 -15
- package/dist/smoothly/smoothly-radio-group.entry.js +0 -16
- package/dist/smoothly/smoothly-radio.entry.js +0 -24
- package/dist/smoothly/smoothly-reorder.entry.js +0 -99
- package/dist/smoothly/smoothly-room.entry.js +0 -12
- package/dist/smoothly/smoothly-select-demo.entry.js +0 -82
- package/dist/smoothly/smoothly-select.entry.js +0 -27
- package/dist/smoothly/smoothly-selector.entry.js +0 -115
- package/dist/smoothly/smoothly-skeleton.entry.js +0 -23
- package/dist/smoothly/smoothly-spinner.entry.js +0 -20
- package/dist/smoothly/smoothly-submit.entry.js +0 -56
- package/dist/smoothly/smoothly-svg.entry.js +0 -37
- package/dist/smoothly/smoothly-tab-switch.entry.js +0 -28
- package/dist/smoothly/smoothly-tab.entry.js +0 -33
- package/dist/smoothly/smoothly-table-cell.entry.js +0 -15
- package/dist/smoothly/smoothly-table-demo.entry.js +0 -18
- package/dist/smoothly/smoothly-table-expandable-cell.entry.js +0 -41
- package/dist/smoothly/smoothly-table-expandable-row.entry.js +0 -28
- package/dist/smoothly/smoothly-table-header.entry.js +0 -37
- package/dist/smoothly/smoothly-table-row.entry.js +0 -34
- package/dist/smoothly/smoothly-table.entry.js +0 -22
- package/dist/smoothly/smoothly-trigger-sink.entry.js +0 -29
- package/dist/smoothly/smoothly-trigger-source.entry.js +0 -28
- package/dist/smoothly/smoothly-trigger.entry.js +0 -32
- package/dist/smoothly/smoothly-tuple.entry.js +0 -12
- package/dist/smoothly/smoothly-urlencoded.entry.js +0 -15
|
@@ -1,1349 +0,0 @@
|
|
|
1
|
-
import './GoogleFont-8474516b.js';
|
|
2
|
-
|
|
3
|
-
class TextEncoder {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.encoding = "utf-8";
|
|
6
|
-
}
|
|
7
|
-
encode(data) {
|
|
8
|
-
return Uint8Array.from(unescape(encodeURIComponent(data)).split(""), c => c.charCodeAt(0));
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const tables = {
|
|
13
|
-
standard: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
|
|
14
|
-
url: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",
|
|
15
|
-
};
|
|
16
|
-
function encode$1(value, standard = "standard", padding = "") {
|
|
17
|
-
if (typeof value == "string")
|
|
18
|
-
value = new TextEncoder().encode(value);
|
|
19
|
-
const table = tables[standard];
|
|
20
|
-
const result = [];
|
|
21
|
-
for (let c = 0; c < value.length; c += 3) {
|
|
22
|
-
const c0 = value[c];
|
|
23
|
-
const c1 = c + 1 < value.length ? value[c + 1] : 0;
|
|
24
|
-
const c2 = c + 2 < value.length ? value[c + 2] : 0;
|
|
25
|
-
result.push(table[c0 >>> 2]);
|
|
26
|
-
result.push(table[((c0 & 3) << 4) | (c1 >>> 4)]);
|
|
27
|
-
result.push(table[((c1 & 15) << 2) | (c2 >>> 6)]);
|
|
28
|
-
result.push(table[c2 & 63]);
|
|
29
|
-
}
|
|
30
|
-
const length = Math.ceil((value.length / 3) * 4);
|
|
31
|
-
return result.join("").substr(0, length) + padding.repeat(result.length - length);
|
|
32
|
-
}
|
|
33
|
-
function decode$1(value, standard = "standard") {
|
|
34
|
-
while (value.endsWith("=") && value.length > 0)
|
|
35
|
-
value = value.substr(0, value.length - 1);
|
|
36
|
-
const table = tables[standard];
|
|
37
|
-
const data = value.split("").map(c => table.indexOf(c));
|
|
38
|
-
const result = new Uint8Array(Math.floor((data.length / 4) * 3));
|
|
39
|
-
for (let c = 0; c < result.length; c += 3) {
|
|
40
|
-
const d0 = data.shift() || 0;
|
|
41
|
-
const d1 = data.shift() || 0;
|
|
42
|
-
const d2 = data.shift() || 0;
|
|
43
|
-
const d3 = data.shift() || 0;
|
|
44
|
-
result[c] = (d0 << 2) | (d1 >>> 4);
|
|
45
|
-
result[c + 1] = ((d1 & 15) << 4) | (d2 >>> 2);
|
|
46
|
-
result[c + 2] = ((d2 & 3) << 6) | d3;
|
|
47
|
-
}
|
|
48
|
-
return result;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const crypto = typeof window != "undefined"
|
|
52
|
-
? window.crypto || window.msCrypto
|
|
53
|
-
: self.crypto || self.msCrypto;
|
|
54
|
-
|
|
55
|
-
class TextDecoder {
|
|
56
|
-
constructor() {
|
|
57
|
-
this.encoding = "utf-8";
|
|
58
|
-
}
|
|
59
|
-
decode(view, options) {
|
|
60
|
-
return !view
|
|
61
|
-
? ""
|
|
62
|
-
: decodeURIComponent(escape(Array.from(new Uint8Array(view.buffer, view.byteOffset, view.byteLength), c => String.fromCharCode(c)).join("")));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
var __awaiter$d = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
67
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
68
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
69
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
70
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
71
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
72
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
class Algorithm$2 {
|
|
76
|
-
constructor(key) {
|
|
77
|
-
this.key = key;
|
|
78
|
-
}
|
|
79
|
-
encrypt(data, salt) {
|
|
80
|
-
return __awaiter$d(this, void 0, void 0, function* () {
|
|
81
|
-
const iv = salt ? decode$1(salt, "url") : crypto.getRandomValues(new Uint8Array(16));
|
|
82
|
-
return {
|
|
83
|
-
key: this.name,
|
|
84
|
-
salt: salt || encode$1(iv, "url"),
|
|
85
|
-
value: encode$1(new Uint8Array(yield crypto.subtle.encrypt({ name: (yield this.key).algorithm.name, iv }, yield this.key, new TextEncoder().encode(data))), "url"),
|
|
86
|
-
};
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
decrypt(encrypted, salt) {
|
|
90
|
-
return __awaiter$d(this, void 0, void 0, function* () {
|
|
91
|
-
if (typeof encrypted == "string")
|
|
92
|
-
encrypted = { value: encrypted, salt: salt !== null && salt !== void 0 ? salt : "" };
|
|
93
|
-
return new TextDecoder().decode(new Uint8Array(yield crypto.subtle.decrypt({ name: (yield this.key).algorithm.name, iv: decode$1(encrypted.salt, "url") }, yield this.key, decode$1(encrypted.value, "url"))));
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
export(parts = 1) {
|
|
97
|
-
return __awaiter$d(this, void 0, void 0, function* () {
|
|
98
|
-
const key = new Uint8Array(yield crypto.subtle.exportKey("raw", yield this.key));
|
|
99
|
-
let result = Algorithm$2.generateRandomKeys(key.length, parts - 1);
|
|
100
|
-
result = [Algorithm$2.reduceKeys([key, ...result]), ...result];
|
|
101
|
-
return result.length == 1 ? encode$1(result[0], "url") : result.map(r => encode$1(r, "url"));
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
static aesCbc(key) {
|
|
105
|
-
return Algorithm$2.generate("AES-CBC", key);
|
|
106
|
-
}
|
|
107
|
-
static aesGcm(key) {
|
|
108
|
-
return Algorithm$2.generate("AES-GCM", key);
|
|
109
|
-
}
|
|
110
|
-
static generate(algorithm, key) {
|
|
111
|
-
return new Algorithm$2(typeof key == "number"
|
|
112
|
-
? crypto.subtle.generateKey({ name: algorithm, length: key }, true, ["encrypt", "decrypt"])
|
|
113
|
-
: crypto.subtle.importKey("raw", Array.isArray(key)
|
|
114
|
-
? Algorithm$2.reduceKeys(key.map(k => decode$1(k, "url")))
|
|
115
|
-
: decode$1(key, "url"), algorithm, true, ["encrypt", "decrypt"]));
|
|
116
|
-
}
|
|
117
|
-
static generateRandomKeys(length, parts) {
|
|
118
|
-
return parts > 0
|
|
119
|
-
? [crypto.getRandomValues(new Uint8Array(length)), ...this.generateRandomKeys(length, parts - 1)]
|
|
120
|
-
: [];
|
|
121
|
-
}
|
|
122
|
-
static reduceKeys(keys) {
|
|
123
|
-
const result = new Uint8Array(keys[0].length);
|
|
124
|
-
for (let index = 0; index < keys[0].length; index++)
|
|
125
|
-
result[index] = keys.reduce((p, c) => p ^ c[index], 0);
|
|
126
|
-
return result;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function encode(value, length) {
|
|
131
|
-
const data = typeof value == "string" ? new TextEncoder().encode(value) : value;
|
|
132
|
-
let result = [];
|
|
133
|
-
for (const d of data)
|
|
134
|
-
result.push(Math.floor(d / 16).toString(16), (d % 16).toString(16));
|
|
135
|
-
if (length)
|
|
136
|
-
result = result.slice(0, length);
|
|
137
|
-
return result.join("");
|
|
138
|
-
}
|
|
139
|
-
function decode(value) {
|
|
140
|
-
if (value.length % 2 == 1)
|
|
141
|
-
value += "0";
|
|
142
|
-
const result = new Uint8Array(value.length / 2);
|
|
143
|
-
for (let index = 0; index < result.length; index++)
|
|
144
|
-
result[index] = Number.parseInt(value[index * 2], 16) * 16 + Number.parseInt(value[index * 2 + 1], 16);
|
|
145
|
-
return result;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
var __awaiter$c = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
149
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
150
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
151
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
152
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
153
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
154
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
155
|
-
});
|
|
156
|
-
};
|
|
157
|
-
class Digest {
|
|
158
|
-
constructor(algorithm) {
|
|
159
|
-
this.algorithm = algorithm;
|
|
160
|
-
}
|
|
161
|
-
get length() {
|
|
162
|
-
return Digest.lengths[this.algorithm];
|
|
163
|
-
}
|
|
164
|
-
digest(data, base = "standard") {
|
|
165
|
-
return __awaiter$c(this, void 0, void 0, function* () {
|
|
166
|
-
let result;
|
|
167
|
-
if (typeof data == "string") {
|
|
168
|
-
const digest = yield this.digest(new TextEncoder().encode(data));
|
|
169
|
-
result = base == 16 ? encode(digest) : encode$1(digest, base);
|
|
170
|
-
}
|
|
171
|
-
else
|
|
172
|
-
result = new Uint8Array(yield crypto.subtle.digest(this.algorithm, data));
|
|
173
|
-
return result;
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
Digest.lengths = {
|
|
178
|
-
"SHA-1": 128,
|
|
179
|
-
"SHA-256": 256,
|
|
180
|
-
"SHA-384": 384,
|
|
181
|
-
"SHA-512": 512,
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
var Encrypted;
|
|
185
|
-
(function (Encrypted) {
|
|
186
|
-
function is(value) {
|
|
187
|
-
return (typeof value == "object" &&
|
|
188
|
-
(value.key == undefined || typeof value.key == "string") &&
|
|
189
|
-
typeof value.value == "string" &&
|
|
190
|
-
typeof value.salt == "string");
|
|
191
|
-
}
|
|
192
|
-
Encrypted.is = is;
|
|
193
|
-
function stringify(encrypted) {
|
|
194
|
-
encrypted.key = encrypted.key && encrypted.key.length != 4 ? encrypted.key.slice(-2) : encrypted.key;
|
|
195
|
-
return [encrypted.key, encrypted.salt, encrypted.value].join(".");
|
|
196
|
-
}
|
|
197
|
-
Encrypted.stringify = stringify;
|
|
198
|
-
function parse(encryptedString) {
|
|
199
|
-
const splitted = encryptedString.split(".");
|
|
200
|
-
const encrypted = { key: splitted[0], salt: splitted[1], value: splitted[2] };
|
|
201
|
-
return Encrypted.is(encrypted) ? encrypted : undefined;
|
|
202
|
-
}
|
|
203
|
-
Encrypted.parse = parse;
|
|
204
|
-
})(Encrypted || (Encrypted = {}));
|
|
205
|
-
|
|
206
|
-
var Identifier;
|
|
207
|
-
(function (Identifier) {
|
|
208
|
-
function is(value, length) {
|
|
209
|
-
return (typeof value == "string" &&
|
|
210
|
-
(length == undefined || value.length == length) &&
|
|
211
|
-
Array.from(value).every(c => (c >= "0" && c <= "9") || (c >= "A" && c <= "Z") || (c >= "a" && c <= "z") || c == "-" || c == "_"));
|
|
212
|
-
}
|
|
213
|
-
Identifier.is = is;
|
|
214
|
-
function fromUint24(value) {
|
|
215
|
-
return fromHexadecimal(value.toString(16).padStart(6, "0"));
|
|
216
|
-
}
|
|
217
|
-
Identifier.fromUint24 = fromUint24;
|
|
218
|
-
function toUint24(identifier) {
|
|
219
|
-
return Number.parseInt(toHexadecimal(identifier, 6), 16);
|
|
220
|
-
}
|
|
221
|
-
Identifier.toUint24 = toUint24;
|
|
222
|
-
function fromUint48(value) {
|
|
223
|
-
return fromHexadecimal(value.toString(16).padStart(12, "0"));
|
|
224
|
-
}
|
|
225
|
-
Identifier.fromUint48 = fromUint48;
|
|
226
|
-
function toUint48(identifier) {
|
|
227
|
-
return Number.parseInt(toHexadecimal(identifier, 12), 16);
|
|
228
|
-
}
|
|
229
|
-
Identifier.toUint48 = toUint48;
|
|
230
|
-
function fromBinary(identifier) {
|
|
231
|
-
return encode$1(identifier, "url");
|
|
232
|
-
}
|
|
233
|
-
Identifier.fromBinary = fromBinary;
|
|
234
|
-
function toBinary(identifier) {
|
|
235
|
-
return decode$1(identifier, "url");
|
|
236
|
-
}
|
|
237
|
-
Identifier.toBinary = toBinary;
|
|
238
|
-
function generate(length) {
|
|
239
|
-
return fromBinary(crypto.getRandomValues(new Uint8Array((length / 4) * 3)));
|
|
240
|
-
}
|
|
241
|
-
Identifier.generate = generate;
|
|
242
|
-
function fromHexadecimal(identifier) {
|
|
243
|
-
if (identifier.length % 2 == 1)
|
|
244
|
-
identifier += "0";
|
|
245
|
-
const result = new Uint8Array(identifier.length / 2);
|
|
246
|
-
for (let index = 0; index < result.length; index++)
|
|
247
|
-
result[index] = Number.parseInt(identifier[index * 2], 16) * 16 + Number.parseInt(identifier[index * 2 + 1], 16);
|
|
248
|
-
return fromBinary(result);
|
|
249
|
-
}
|
|
250
|
-
Identifier.fromHexadecimal = fromHexadecimal;
|
|
251
|
-
function toHexadecimal(identifier, length) {
|
|
252
|
-
const data = decode$1(identifier, "url");
|
|
253
|
-
let result = [];
|
|
254
|
-
for (const d of data)
|
|
255
|
-
result.push(Math.floor(d / 16).toString(16), (d % 16).toString(16));
|
|
256
|
-
if (length)
|
|
257
|
-
result = result.slice(0, length);
|
|
258
|
-
return result.join("");
|
|
259
|
-
}
|
|
260
|
-
Identifier.toHexadecimal = toHexadecimal;
|
|
261
|
-
Identifier.length = [
|
|
262
|
-
4,
|
|
263
|
-
8,
|
|
264
|
-
12,
|
|
265
|
-
16,
|
|
266
|
-
20,
|
|
267
|
-
24,
|
|
268
|
-
28,
|
|
269
|
-
32,
|
|
270
|
-
36,
|
|
271
|
-
40,
|
|
272
|
-
44,
|
|
273
|
-
48,
|
|
274
|
-
52,
|
|
275
|
-
56,
|
|
276
|
-
60,
|
|
277
|
-
64,
|
|
278
|
-
68,
|
|
279
|
-
72,
|
|
280
|
-
76,
|
|
281
|
-
80,
|
|
282
|
-
84,
|
|
283
|
-
88,
|
|
284
|
-
92,
|
|
285
|
-
96,
|
|
286
|
-
100,
|
|
287
|
-
104,
|
|
288
|
-
108,
|
|
289
|
-
112,
|
|
290
|
-
116,
|
|
291
|
-
120,
|
|
292
|
-
124,
|
|
293
|
-
128,
|
|
294
|
-
];
|
|
295
|
-
let Length;
|
|
296
|
-
(function (Length) {
|
|
297
|
-
function is(value) {
|
|
298
|
-
return typeof value == "number" && value >= 4 && value <= 128 && (value & 252) == value;
|
|
299
|
-
}
|
|
300
|
-
Length.is = is;
|
|
301
|
-
})(Length = Identifier.Length || (Identifier.Length = {}));
|
|
302
|
-
})(Identifier || (Identifier = {}));
|
|
303
|
-
|
|
304
|
-
var __awaiter$b = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
305
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
306
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
307
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
308
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
309
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
310
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
311
|
-
});
|
|
312
|
-
};
|
|
313
|
-
var Password;
|
|
314
|
-
(function (Password) {
|
|
315
|
-
function is(value) {
|
|
316
|
-
return (typeof value == "string" ||
|
|
317
|
-
(typeof value == "object" && typeof value.hash == "string" && typeof value.salt == "string"));
|
|
318
|
-
}
|
|
319
|
-
Password.is = is;
|
|
320
|
-
function hash(algorithm, password, salt) {
|
|
321
|
-
return __awaiter$b(this, void 0, void 0, function* () {
|
|
322
|
-
if (!salt)
|
|
323
|
-
salt = encode$1(crypto.getRandomValues(new Uint8Array(64)));
|
|
324
|
-
return {
|
|
325
|
-
hash: yield algorithm.sign(salt + password),
|
|
326
|
-
salt,
|
|
327
|
-
};
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
Password.hash = hash;
|
|
331
|
-
function verify(algorithm, hash, password) {
|
|
332
|
-
return __awaiter$b(this, void 0, void 0, function* () {
|
|
333
|
-
return (yield Password.hash(algorithm, password, hash.salt)).hash == hash.hash;
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
Password.verify = verify;
|
|
337
|
-
let Hashed;
|
|
338
|
-
(function (Hashed) {
|
|
339
|
-
function is(value) {
|
|
340
|
-
return typeof value == "object" && typeof value.hash == "string" && typeof value.salt == "string";
|
|
341
|
-
}
|
|
342
|
-
Hashed.is = is;
|
|
343
|
-
})(Hashed = Password.Hashed || (Password.Hashed = {}));
|
|
344
|
-
})(Password || (Password = {}));
|
|
345
|
-
|
|
346
|
-
var RandomValue;
|
|
347
|
-
(function (RandomValue) {
|
|
348
|
-
function generate(array) {
|
|
349
|
-
return crypto.getRandomValues(array);
|
|
350
|
-
}
|
|
351
|
-
RandomValue.generate = generate;
|
|
352
|
-
})(RandomValue || (RandomValue = {}));
|
|
353
|
-
|
|
354
|
-
var Algorithm$1;
|
|
355
|
-
(function (Algorithm) {
|
|
356
|
-
function is(value) {
|
|
357
|
-
return value == "HMAC" || value == "RSA" || value == "ECDSA" || value == "RSA-PSS";
|
|
358
|
-
}
|
|
359
|
-
Algorithm.is = is;
|
|
360
|
-
})(Algorithm$1 || (Algorithm$1 = {}));
|
|
361
|
-
|
|
362
|
-
var __awaiter$a = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
363
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
364
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
365
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
366
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
367
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
368
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
369
|
-
});
|
|
370
|
-
};
|
|
371
|
-
class Base {
|
|
372
|
-
sign(data) {
|
|
373
|
-
return __awaiter$a(this, void 0, void 0, function* () {
|
|
374
|
-
return typeof data == "string"
|
|
375
|
-
? encode$1(yield this.signBinary(new TextEncoder().encode(data)), "url")
|
|
376
|
-
: this.signBinary(data);
|
|
377
|
-
});
|
|
378
|
-
}
|
|
379
|
-
verify(data, signature) {
|
|
380
|
-
if (typeof signature == "string")
|
|
381
|
-
signature = decode$1(signature, "url");
|
|
382
|
-
return typeof data == "string"
|
|
383
|
-
? this.verifyBinary(new TextEncoder().encode(data), signature)
|
|
384
|
-
: this.verifyBinary(data, signature);
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
var __awaiter$9 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
389
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
390
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
391
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
392
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
393
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
394
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
395
|
-
});
|
|
396
|
-
};
|
|
397
|
-
class ECDSA extends Base {
|
|
398
|
-
constructor(hash, publicKey, privateKey) {
|
|
399
|
-
super();
|
|
400
|
-
this.hash = hash;
|
|
401
|
-
if (publicKey) {
|
|
402
|
-
if (typeof publicKey == "string")
|
|
403
|
-
publicKey = decode$1(publicKey);
|
|
404
|
-
this.publicKey = crypto.subtle.importKey("spki", publicKey, { name: "ECDSA", namedCurve: hash.replace("SHA", "P") == "P-512" ? "P-521" : hash.replace("SHA", "P") }, false, ["verify"]);
|
|
405
|
-
}
|
|
406
|
-
if (privateKey) {
|
|
407
|
-
if (typeof privateKey == "string")
|
|
408
|
-
privateKey = decode$1(privateKey);
|
|
409
|
-
this.privateKey = crypto.subtle.importKey("pkcs8", privateKey, { name: "ECDSA", namedCurve: hash.replace("SHA", "P") == "P-512" ? "P-521" : hash.replace("SHA", "P") }, true, ["sign", "verify"]);
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
signBinary(data) {
|
|
413
|
-
return __awaiter$9(this, void 0, void 0, function* () {
|
|
414
|
-
return new Uint8Array(yield crypto.subtle.sign({ name: "ECDSA", hash: { name: this.hash } }, yield this.privateKey, data));
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
verifyBinary(data, signature) {
|
|
418
|
-
return __awaiter$9(this, void 0, void 0, function* () {
|
|
419
|
-
return crypto.subtle.verify({ name: "ECDSA", hash: { name: this.hash } }, yield this.publicKey, signature, data);
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
var Hash;
|
|
425
|
-
(function (Hash) {
|
|
426
|
-
function is(value) {
|
|
427
|
-
return value == "SHA-1" || value == "SHA-256" || value == "SHA-384" || value == "SHA-512";
|
|
428
|
-
}
|
|
429
|
-
Hash.is = is;
|
|
430
|
-
})(Hash || (Hash = {}));
|
|
431
|
-
|
|
432
|
-
var __awaiter$8 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
433
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
434
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
435
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
436
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
437
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
438
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
439
|
-
});
|
|
440
|
-
};
|
|
441
|
-
class Symmetric$1 extends Base {
|
|
442
|
-
verifyBinary(data, signature) {
|
|
443
|
-
return __awaiter$8(this, void 0, void 0, function* () {
|
|
444
|
-
return encode$1(yield this.signBinary(data), "url") == encode$1(signature, "url");
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
var __awaiter$7 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
450
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
451
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
452
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
453
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
454
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
455
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
456
|
-
});
|
|
457
|
-
};
|
|
458
|
-
class HMAC extends Symmetric$1 {
|
|
459
|
-
constructor(hash, key) {
|
|
460
|
-
super();
|
|
461
|
-
this.hash = hash;
|
|
462
|
-
if (typeof key == "string")
|
|
463
|
-
key = decode$1(key, "url");
|
|
464
|
-
this.key = crypto.subtle.importKey("raw", key, { name: "HMAC", hash: { name: hash } }, false, ["sign", "verify"]);
|
|
465
|
-
}
|
|
466
|
-
signBinary(data) {
|
|
467
|
-
return __awaiter$7(this, void 0, void 0, function* () {
|
|
468
|
-
return new Uint8Array(yield crypto.subtle.sign("HMAC", yield this.key, data));
|
|
469
|
-
});
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
class None extends Symmetric$1 {
|
|
474
|
-
signBinary(_) {
|
|
475
|
-
return Promise.resolve(new Uint8Array(0));
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
var __awaiter$6 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
480
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
481
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
482
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
483
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
484
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
485
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
486
|
-
});
|
|
487
|
-
};
|
|
488
|
-
class RSA extends Base {
|
|
489
|
-
constructor(hash, publicKey, privateKey) {
|
|
490
|
-
super();
|
|
491
|
-
this.hash = hash;
|
|
492
|
-
if (publicKey) {
|
|
493
|
-
if (typeof publicKey == "string")
|
|
494
|
-
publicKey = decode$1(publicKey);
|
|
495
|
-
this.publicKey = crypto.subtle.importKey("spki", publicKey, { name: "RSASSA-PKCS1-v1_5", hash: { name: hash } }, false, ["verify"]);
|
|
496
|
-
}
|
|
497
|
-
if (privateKey) {
|
|
498
|
-
if (typeof privateKey == "string")
|
|
499
|
-
privateKey = decode$1(privateKey);
|
|
500
|
-
this.privateKey = crypto.subtle.importKey("pkcs8", privateKey, { name: "RSASSA-PKCS1-v1_5", hash: { name: hash } }, true, ["sign"]);
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
signBinary(data) {
|
|
504
|
-
return __awaiter$6(this, void 0, void 0, function* () {
|
|
505
|
-
return new Uint8Array(yield crypto.subtle.sign("RSASSA-PKCS1-v1_5", yield this.privateKey, data));
|
|
506
|
-
});
|
|
507
|
-
}
|
|
508
|
-
verifyBinary(data, signature) {
|
|
509
|
-
return __awaiter$6(this, void 0, void 0, function* () {
|
|
510
|
-
return crypto.subtle.verify("RSASSA-PKCS1-v1_5", yield this.publicKey, signature, data);
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
var __awaiter$5 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
516
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
517
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
518
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
519
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
520
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
521
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
522
|
-
});
|
|
523
|
-
};
|
|
524
|
-
class RSAPSS extends Base {
|
|
525
|
-
constructor(hash, publicKey, privateKey) {
|
|
526
|
-
super();
|
|
527
|
-
this.hash = hash;
|
|
528
|
-
if (publicKey) {
|
|
529
|
-
if (typeof publicKey == "string")
|
|
530
|
-
publicKey = decode$1(publicKey);
|
|
531
|
-
this.publicKey = crypto.subtle.importKey("spki", publicKey, { name: "RSA-PSS", hash: { name: hash } }, false, [
|
|
532
|
-
"verify",
|
|
533
|
-
]);
|
|
534
|
-
}
|
|
535
|
-
if (privateKey) {
|
|
536
|
-
if (typeof privateKey == "string")
|
|
537
|
-
privateKey = decode$1(privateKey);
|
|
538
|
-
this.privateKey = crypto.subtle.importKey("pkcs8", privateKey, { name: "RSA-PSS", hash: { name: hash } }, true, [
|
|
539
|
-
"sign",
|
|
540
|
-
"verify",
|
|
541
|
-
]);
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
signBinary(data) {
|
|
545
|
-
return __awaiter$5(this, void 0, void 0, function* () {
|
|
546
|
-
return new Uint8Array(yield crypto.subtle.sign({ name: "RSA-PSS", saltLength: 128 }, yield this.privateKey, data));
|
|
547
|
-
});
|
|
548
|
-
}
|
|
549
|
-
verifyBinary(data, signature) {
|
|
550
|
-
return __awaiter$5(this, void 0, void 0, function* () {
|
|
551
|
-
return crypto.subtle.verify({ name: "RSA-PSS", saltLength: 128 }, yield this.publicKey, signature, data);
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
var Signer;
|
|
557
|
-
(function (Signer) {
|
|
558
|
-
let Algorithm;
|
|
559
|
-
(function (Algorithm) {
|
|
560
|
-
Algorithm.is = Algorithm$1.is;
|
|
561
|
-
})(Algorithm = Signer.Algorithm || (Signer.Algorithm = {}));
|
|
562
|
-
let Hash$1;
|
|
563
|
-
(function (Hash$1) {
|
|
564
|
-
Hash$1.is = Hash.is;
|
|
565
|
-
})(Hash$1 = Signer.Hash || (Signer.Hash = {}));
|
|
566
|
-
function create(algorithm, hash, ...keys) {
|
|
567
|
-
let result;
|
|
568
|
-
switch (algorithm) {
|
|
569
|
-
case "HMAC":
|
|
570
|
-
if (hash != undefined)
|
|
571
|
-
result = new HMAC(hash, keys[0]);
|
|
572
|
-
break;
|
|
573
|
-
case "RSA":
|
|
574
|
-
if (hash != undefined)
|
|
575
|
-
result = new RSA(hash, keys[0], keys[1]);
|
|
576
|
-
break;
|
|
577
|
-
case "RSA-PSS":
|
|
578
|
-
if (hash != undefined)
|
|
579
|
-
result = new RSAPSS(hash, keys[0], keys[1]);
|
|
580
|
-
break;
|
|
581
|
-
case "ECDSA":
|
|
582
|
-
if (hash != undefined)
|
|
583
|
-
result = new ECDSA(hash, keys[0], keys[1]);
|
|
584
|
-
break;
|
|
585
|
-
case "None":
|
|
586
|
-
result = new None();
|
|
587
|
-
}
|
|
588
|
-
return result;
|
|
589
|
-
}
|
|
590
|
-
Signer.create = create;
|
|
591
|
-
})(Signer || (Signer = {}));
|
|
592
|
-
|
|
593
|
-
if (!Uint8Array.__proto__.from) {
|
|
594
|
-
;
|
|
595
|
-
(() => {
|
|
596
|
-
Uint8Array.__proto__.from = function (object, theFunction, thisObject) {
|
|
597
|
-
const typedArrayClass = Uint8Array.__proto__;
|
|
598
|
-
if (typeof this !== "function") {
|
|
599
|
-
throw new TypeError("# is not a constructor");
|
|
600
|
-
}
|
|
601
|
-
if (this.__proto__ !== typedArrayClass) {
|
|
602
|
-
throw new TypeError("this is not a typed array.");
|
|
603
|
-
}
|
|
604
|
-
theFunction = theFunction || (element => element);
|
|
605
|
-
if (typeof theFunction !== "function") {
|
|
606
|
-
throw new TypeError("specified argument is not a function");
|
|
607
|
-
}
|
|
608
|
-
object = Object(object);
|
|
609
|
-
if (!object.length) {
|
|
610
|
-
return new this(0);
|
|
611
|
-
}
|
|
612
|
-
let copyData = [];
|
|
613
|
-
for (const data of copyData) {
|
|
614
|
-
copyData.push(data);
|
|
615
|
-
}
|
|
616
|
-
copyData = copyData.map(theFunction, thisObject);
|
|
617
|
-
const typedArray = new this(copyData.length);
|
|
618
|
-
for (let i = 0; i < typedArray.length; i++) {
|
|
619
|
-
typedArray[i] = copyData[i];
|
|
620
|
-
}
|
|
621
|
-
return typedArray;
|
|
622
|
-
};
|
|
623
|
-
})();
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
var __awaiter$4 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
627
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
628
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
629
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
630
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
631
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
632
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
633
|
-
});
|
|
634
|
-
};
|
|
635
|
-
class Converter$1 {
|
|
636
|
-
constructor(conversionMap) {
|
|
637
|
-
this.conversionMap = conversionMap;
|
|
638
|
-
}
|
|
639
|
-
apply(payload) {
|
|
640
|
-
return __awaiter$4(this, void 0, void 0, function* () {
|
|
641
|
-
return payload && this.convert(payload, true);
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
reverse(payload) {
|
|
645
|
-
return __awaiter$4(this, void 0, void 0, function* () {
|
|
646
|
-
return payload && this.convert(payload, false);
|
|
647
|
-
});
|
|
648
|
-
}
|
|
649
|
-
convert(payload, forward) {
|
|
650
|
-
return __awaiter$4(this, void 0, void 0, function* () {
|
|
651
|
-
for (const key in this.conversionMap) {
|
|
652
|
-
const fnction = forward ? this.conversionMap[key].forward : this.conversionMap[key].backward;
|
|
653
|
-
const property = key.split(".");
|
|
654
|
-
payload = yield this.convertProperty(payload, property, fnction);
|
|
655
|
-
}
|
|
656
|
-
return payload;
|
|
657
|
-
});
|
|
658
|
-
}
|
|
659
|
-
convertProperty(payload, property, fnction) {
|
|
660
|
-
return __awaiter$4(this, void 0, void 0, function* () {
|
|
661
|
-
const result = Object.assign({}, payload);
|
|
662
|
-
if (result[property[0]])
|
|
663
|
-
result[property[0]] =
|
|
664
|
-
property.length == 1
|
|
665
|
-
? yield fnction(result[property[0]])
|
|
666
|
-
: yield this.convertProperty(result[property[0]], property.slice(1), fnction);
|
|
667
|
-
return result;
|
|
668
|
-
});
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
var Converter;
|
|
673
|
-
(function (Converter) {
|
|
674
|
-
function is(value) {
|
|
675
|
-
return typeof value == "object" && Object.entries(value).every(v => typeof v == "function");
|
|
676
|
-
}
|
|
677
|
-
Converter.is = is;
|
|
678
|
-
})(Converter || (Converter = {}));
|
|
679
|
-
|
|
680
|
-
var Crypto$1;
|
|
681
|
-
(function (Crypto) {
|
|
682
|
-
function is(value) {
|
|
683
|
-
return Array.isArray(value) && value.every(v => typeof v == "string");
|
|
684
|
-
}
|
|
685
|
-
Crypto.is = is;
|
|
686
|
-
})(Crypto$1 || (Crypto$1 = {}));
|
|
687
|
-
|
|
688
|
-
var Renamer$1;
|
|
689
|
-
(function (Renamer) {
|
|
690
|
-
function is(value) {
|
|
691
|
-
return typeof value == "object" && Object.entries(value).every(thing => typeof thing[1] == "string");
|
|
692
|
-
}
|
|
693
|
-
Renamer.is = is;
|
|
694
|
-
})(Renamer$1 || (Renamer$1 = {}));
|
|
695
|
-
|
|
696
|
-
var Creatable;
|
|
697
|
-
(function (Creatable) {
|
|
698
|
-
function is(value) {
|
|
699
|
-
return Crypto$1.is(value) || Converter.is(value) || Renamer$1.is(value);
|
|
700
|
-
}
|
|
701
|
-
Creatable.is = is;
|
|
702
|
-
let Converter$1;
|
|
703
|
-
(function (Converter$1) {
|
|
704
|
-
Converter$1.is = Converter.is;
|
|
705
|
-
})(Converter$1 = Creatable.Converter || (Creatable.Converter = {}));
|
|
706
|
-
let Crypto;
|
|
707
|
-
(function (Crypto) {
|
|
708
|
-
Crypto.is = Crypto$1.is;
|
|
709
|
-
})(Crypto = Creatable.Crypto || (Creatable.Crypto = {}));
|
|
710
|
-
let Renamer;
|
|
711
|
-
(function (Renamer) {
|
|
712
|
-
Renamer.is = Renamer$1.is;
|
|
713
|
-
})(Renamer = Creatable.Renamer || (Creatable.Renamer = {}));
|
|
714
|
-
})(Creatable || (Creatable = {}));
|
|
715
|
-
|
|
716
|
-
class Remover {
|
|
717
|
-
constructor(toRemove) {
|
|
718
|
-
this.toRemove = toRemove;
|
|
719
|
-
}
|
|
720
|
-
apply(payload) {
|
|
721
|
-
return payload && this.removeFrom(payload);
|
|
722
|
-
}
|
|
723
|
-
reverse(payload) {
|
|
724
|
-
return payload && this.removeFrom(payload);
|
|
725
|
-
}
|
|
726
|
-
removeFrom(payload) {
|
|
727
|
-
let result = Object.assign({}, payload);
|
|
728
|
-
this.toRemove.forEach(str => {
|
|
729
|
-
const property = str.split(".");
|
|
730
|
-
result = this.removeProperty(result, property);
|
|
731
|
-
});
|
|
732
|
-
return result;
|
|
733
|
-
}
|
|
734
|
-
removeProperty(payload, property) {
|
|
735
|
-
const result = Object.assign({}, payload);
|
|
736
|
-
if (result[property[0]])
|
|
737
|
-
if (property.length == 1)
|
|
738
|
-
delete result[property[0]];
|
|
739
|
-
else
|
|
740
|
-
result[property[0]] = this.removeProperty(result[property[0]], property.slice(1));
|
|
741
|
-
return result;
|
|
742
|
-
}
|
|
743
|
-
static create(toRemove) {
|
|
744
|
-
return toRemove.length == 0 ? undefined : new Remover(toRemove);
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
var __awaiter$3 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
749
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
750
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
751
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
752
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
753
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
754
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
755
|
-
});
|
|
756
|
-
};
|
|
757
|
-
class Crypto {
|
|
758
|
-
constructor(secret, ...properties) {
|
|
759
|
-
this.secret = secret;
|
|
760
|
-
this.encoder = new TextEncoder();
|
|
761
|
-
this.decoder = new TextDecoder();
|
|
762
|
-
this.properties = properties.map(p => p.split("."));
|
|
763
|
-
}
|
|
764
|
-
apply(payload) {
|
|
765
|
-
return __awaiter$3(this, void 0, void 0, function* () {
|
|
766
|
-
return (payload &&
|
|
767
|
-
this.process(payload, value => this.encoder.encode(JSON.stringify(value)), value => encode$1(value, "url")));
|
|
768
|
-
});
|
|
769
|
-
}
|
|
770
|
-
reverse(payload) {
|
|
771
|
-
return __awaiter$3(this, void 0, void 0, function* () {
|
|
772
|
-
return (payload &&
|
|
773
|
-
this.process(payload, value => (typeof value == "string" ? decode$1(value, "url") : new Uint8Array()), value => JSON.parse(this.decoder.decode(value))));
|
|
774
|
-
});
|
|
775
|
-
}
|
|
776
|
-
process(payload, preprocess, postprocess) {
|
|
777
|
-
return __awaiter$3(this, void 0, void 0, function* () {
|
|
778
|
-
const secret = this.secret + payload.sub + payload.iat;
|
|
779
|
-
for (const property of this.properties)
|
|
780
|
-
payload = yield this.processProperty(payload, property, secret + property.join("."), preprocess, postprocess);
|
|
781
|
-
return payload;
|
|
782
|
-
});
|
|
783
|
-
}
|
|
784
|
-
processProperty(payload, property, secret, preprocess, postprocess) {
|
|
785
|
-
return __awaiter$3(this, void 0, void 0, function* () {
|
|
786
|
-
const result = Object.assign({}, payload);
|
|
787
|
-
if (result[property[0]])
|
|
788
|
-
if (property.length == 1) {
|
|
789
|
-
const data = preprocess(payload[property[0]]);
|
|
790
|
-
const key = yield new Digest("SHA-512").digest(this.encoder.encode(secret));
|
|
791
|
-
const processed = new Uint8Array(data.length);
|
|
792
|
-
for (let index = 0; index < data.length; index++)
|
|
793
|
-
processed[index] = data[index] ^ key[index];
|
|
794
|
-
result[property[0]] = postprocess(processed);
|
|
795
|
-
}
|
|
796
|
-
else
|
|
797
|
-
result[property[0]] = yield this.processProperty(result[property[0]], property.slice(1), secret, preprocess, postprocess);
|
|
798
|
-
return result;
|
|
799
|
-
});
|
|
800
|
-
}
|
|
801
|
-
static create(secret, ...properties) {
|
|
802
|
-
return secret ? new Crypto(secret, ...properties) : Remover.create(properties);
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
class Renamer {
|
|
807
|
-
constructor(forwardTransformMap) {
|
|
808
|
-
this.forwardTransformMap = forwardTransformMap;
|
|
809
|
-
this.createBackwardTransformMap();
|
|
810
|
-
}
|
|
811
|
-
createBackwardTransformMap() {
|
|
812
|
-
const result = {};
|
|
813
|
-
for (const key in this.forwardTransformMap) {
|
|
814
|
-
result[this.forwardTransformMap[key]] = key;
|
|
815
|
-
}
|
|
816
|
-
this.backwardTransformMap = result ? result : {};
|
|
817
|
-
}
|
|
818
|
-
apply(payload) {
|
|
819
|
-
return payload && this.remap(payload, true);
|
|
820
|
-
}
|
|
821
|
-
reverse(payload) {
|
|
822
|
-
return payload && this.remap(payload, false);
|
|
823
|
-
}
|
|
824
|
-
remap(payload, forward) {
|
|
825
|
-
const transformMap = forward ? this.forwardTransformMap : this.backwardTransformMap;
|
|
826
|
-
const result = {};
|
|
827
|
-
for (const key in payload)
|
|
828
|
-
if (key in transformMap)
|
|
829
|
-
result[transformMap[key]] = this.resolve(payload[key], forward);
|
|
830
|
-
else
|
|
831
|
-
result[key] = this.resolve(payload[key], forward);
|
|
832
|
-
return result;
|
|
833
|
-
}
|
|
834
|
-
resolve(payload, forward) {
|
|
835
|
-
let result;
|
|
836
|
-
if (Array.isArray(payload)) {
|
|
837
|
-
result = [];
|
|
838
|
-
payload.forEach(value => result.push(this.resolve(value, forward)));
|
|
839
|
-
}
|
|
840
|
-
else
|
|
841
|
-
result = typeof payload == "object" ? this.remap(payload, forward) : payload;
|
|
842
|
-
return result;
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
var Transformer;
|
|
847
|
-
(function (Transformer) {
|
|
848
|
-
function is(value) {
|
|
849
|
-
return typeof value == "object" && typeof value.apply == "function" && typeof value.reverse == "function";
|
|
850
|
-
}
|
|
851
|
-
Transformer.is = is;
|
|
852
|
-
function create(transformer) {
|
|
853
|
-
return {
|
|
854
|
-
apply: transformer.apply ? transformer.apply : (v) => v,
|
|
855
|
-
reverse: transformer.reverse ? transformer.reverse : (v) => v,
|
|
856
|
-
};
|
|
857
|
-
}
|
|
858
|
-
Transformer.create = create;
|
|
859
|
-
})(Transformer || (Transformer = {}));
|
|
860
|
-
|
|
861
|
-
class Typeguard {
|
|
862
|
-
constructor(...is) {
|
|
863
|
-
this.is = is;
|
|
864
|
-
}
|
|
865
|
-
apply(payload) {
|
|
866
|
-
return this.is.some(f => f(payload)) ? payload : undefined;
|
|
867
|
-
}
|
|
868
|
-
reverse(payload) {
|
|
869
|
-
return this.is.some(f => f(payload)) ? payload : undefined;
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
class Actor {
|
|
874
|
-
constructor(id) {
|
|
875
|
-
this.id = id;
|
|
876
|
-
this.transformers = [];
|
|
877
|
-
}
|
|
878
|
-
add(...argument) {
|
|
879
|
-
argument.forEach(value => value && this.transformers.push(Creatable.is(value) ? this.creatableToTransformer(value) : value));
|
|
880
|
-
return this;
|
|
881
|
-
}
|
|
882
|
-
creatableToTransformer(creatable) {
|
|
883
|
-
return Creatable.Converter.is(creatable)
|
|
884
|
-
? new Converter$1(creatable)
|
|
885
|
-
: Creatable.Crypto.is(creatable)
|
|
886
|
-
? Crypto.create(creatable[0], ...creatable.slice(1))
|
|
887
|
-
: new Renamer(creatable);
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
var Asymmetric;
|
|
892
|
-
(function (Asymmetric) {
|
|
893
|
-
function is(value) {
|
|
894
|
-
return (value == "RS256" ||
|
|
895
|
-
value == "RS384" ||
|
|
896
|
-
value == "RS512" ||
|
|
897
|
-
value == "ES256" ||
|
|
898
|
-
value == "ES384" ||
|
|
899
|
-
value == "ES512" ||
|
|
900
|
-
value == "PS256" ||
|
|
901
|
-
value == "PS384" ||
|
|
902
|
-
value == "PS512");
|
|
903
|
-
}
|
|
904
|
-
Asymmetric.is = is;
|
|
905
|
-
})(Asymmetric || (Asymmetric = {}));
|
|
906
|
-
|
|
907
|
-
var Symmetric;
|
|
908
|
-
(function (Symmetric) {
|
|
909
|
-
function is(value) {
|
|
910
|
-
return value == "HS256" || value == "HS384" || value == "HS512";
|
|
911
|
-
}
|
|
912
|
-
Symmetric.is = is;
|
|
913
|
-
})(Symmetric || (Symmetric = {}));
|
|
914
|
-
|
|
915
|
-
var Name;
|
|
916
|
-
(function (Name) {
|
|
917
|
-
function is(value) {
|
|
918
|
-
return value == "none" || Symmetric.is(value) || Asymmetric.is(value);
|
|
919
|
-
}
|
|
920
|
-
Name.is = is;
|
|
921
|
-
let Symmetric$1;
|
|
922
|
-
(function (Symmetric$1) {
|
|
923
|
-
Symmetric$1.is = Symmetric.is;
|
|
924
|
-
})(Symmetric$1 = Name.Symmetric || (Name.Symmetric = {}));
|
|
925
|
-
let Asymmetric$1;
|
|
926
|
-
(function (Asymmetric$1) {
|
|
927
|
-
Asymmetric$1.is = Asymmetric.is;
|
|
928
|
-
})(Asymmetric$1 = Name.Asymmetric || (Name.Asymmetric = {}));
|
|
929
|
-
})(Name || (Name = {}));
|
|
930
|
-
|
|
931
|
-
var __awaiter$2 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
932
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
933
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
934
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
935
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
936
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
937
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
938
|
-
});
|
|
939
|
-
};
|
|
940
|
-
class Algorithm {
|
|
941
|
-
constructor(name, signer) {
|
|
942
|
-
this.name = name;
|
|
943
|
-
this.signer = signer;
|
|
944
|
-
}
|
|
945
|
-
sign(data) {
|
|
946
|
-
return __awaiter$2(this, void 0, void 0, function* () {
|
|
947
|
-
return typeof data == "string" ? this.signer.sign(data) : this.signer.sign(data);
|
|
948
|
-
});
|
|
949
|
-
}
|
|
950
|
-
verify(data, signature) {
|
|
951
|
-
return this.signer.verify(data, signature);
|
|
952
|
-
}
|
|
953
|
-
static create(name, ...keys) {
|
|
954
|
-
let result;
|
|
955
|
-
switch (name) {
|
|
956
|
-
case "ES256":
|
|
957
|
-
result = Signer.create("ECDSA", "SHA-256", keys[0], keys[1]);
|
|
958
|
-
break;
|
|
959
|
-
case "ES384":
|
|
960
|
-
result = Signer.create("ECDSA", "SHA-384", keys[0], keys[1]);
|
|
961
|
-
break;
|
|
962
|
-
case "ES512":
|
|
963
|
-
result = Signer.create("ECDSA", "SHA-512", keys[0], keys[1]);
|
|
964
|
-
break;
|
|
965
|
-
case "PS256":
|
|
966
|
-
result = Signer.create("RSA-PSS", "SHA-256", keys[0], keys[1]);
|
|
967
|
-
break;
|
|
968
|
-
case "PS384":
|
|
969
|
-
result = Signer.create("RSA-PSS", "SHA-384", keys[0], keys[1]);
|
|
970
|
-
break;
|
|
971
|
-
case "PS512":
|
|
972
|
-
result = Signer.create("RSA-PSS", "SHA-512", keys[0], keys[1]);
|
|
973
|
-
break;
|
|
974
|
-
case "HS256":
|
|
975
|
-
result = Signer.create("HMAC", "SHA-256", keys[0]);
|
|
976
|
-
break;
|
|
977
|
-
case "HS384":
|
|
978
|
-
result = Signer.create("HMAC", "SHA-384", keys[0]);
|
|
979
|
-
break;
|
|
980
|
-
case "HS512":
|
|
981
|
-
result = Signer.create("HMAC", "SHA-512", keys[0]);
|
|
982
|
-
break;
|
|
983
|
-
case "RS256":
|
|
984
|
-
result = Signer.create("RSA", "SHA-256", keys[0], keys[1]);
|
|
985
|
-
break;
|
|
986
|
-
case "RS384":
|
|
987
|
-
result = Signer.create("RSA", "SHA-384", keys[0], keys[1]);
|
|
988
|
-
break;
|
|
989
|
-
case "RS512":
|
|
990
|
-
result = Signer.create("RSA", "SHA-512", keys[0], keys[1]);
|
|
991
|
-
break;
|
|
992
|
-
case "none":
|
|
993
|
-
result = Signer.create("None");
|
|
994
|
-
break;
|
|
995
|
-
}
|
|
996
|
-
return result && new Algorithm(name, result);
|
|
997
|
-
}
|
|
998
|
-
static none() {
|
|
999
|
-
return Algorithm.create("none");
|
|
1000
|
-
}
|
|
1001
|
-
static HS256(key) {
|
|
1002
|
-
return Algorithm.create("HS256", key);
|
|
1003
|
-
}
|
|
1004
|
-
static HS384(key) {
|
|
1005
|
-
return Algorithm.create("HS384", key);
|
|
1006
|
-
}
|
|
1007
|
-
static HS512(key) {
|
|
1008
|
-
return Algorithm.create("HS512", key);
|
|
1009
|
-
}
|
|
1010
|
-
static RS256(publicKey, privateKey) {
|
|
1011
|
-
return Algorithm.create("RS256", publicKey, privateKey);
|
|
1012
|
-
}
|
|
1013
|
-
static RS384(publicKey, privateKey) {
|
|
1014
|
-
return Algorithm.create("RS384", publicKey, privateKey);
|
|
1015
|
-
}
|
|
1016
|
-
static RS512(publicKey, privateKey) {
|
|
1017
|
-
return Algorithm.create("RS512", publicKey, privateKey);
|
|
1018
|
-
}
|
|
1019
|
-
static ES256(publicKey, privateKey) {
|
|
1020
|
-
return Algorithm.create("ES256", publicKey, privateKey);
|
|
1021
|
-
}
|
|
1022
|
-
static ES384(publicKey, privateKey) {
|
|
1023
|
-
return Algorithm.create("ES384", publicKey, privateKey);
|
|
1024
|
-
}
|
|
1025
|
-
static ES512(publicKey, privateKey) {
|
|
1026
|
-
return Algorithm.create("ES512", publicKey, privateKey);
|
|
1027
|
-
}
|
|
1028
|
-
static PS256(publicKey, privateKey) {
|
|
1029
|
-
return Algorithm.create("PS256", publicKey, privateKey);
|
|
1030
|
-
}
|
|
1031
|
-
static PS384(publicKey, privateKey) {
|
|
1032
|
-
return Algorithm.create("PS384", publicKey, privateKey);
|
|
1033
|
-
}
|
|
1034
|
-
static PS512(publicKey, privateKey) {
|
|
1035
|
-
return Algorithm.create("PS512", publicKey, privateKey);
|
|
1036
|
-
}
|
|
1037
|
-
}
|
|
1038
|
-
(function (Algorithm) {
|
|
1039
|
-
let Name$1;
|
|
1040
|
-
(function (Name$1) {
|
|
1041
|
-
Name$1.is = Name.is;
|
|
1042
|
-
let Symmetric;
|
|
1043
|
-
(function (Symmetric) {
|
|
1044
|
-
Symmetric.is = Name.Symmetric.is;
|
|
1045
|
-
})(Symmetric = Name$1.Symmetric || (Name$1.Symmetric = {}));
|
|
1046
|
-
let Asymmetric;
|
|
1047
|
-
(function (Asymmetric) {
|
|
1048
|
-
Asymmetric.is = Name.Asymmetric.is;
|
|
1049
|
-
})(Asymmetric = Name$1.Asymmetric || (Name$1.Asymmetric = {}));
|
|
1050
|
-
})(Name$1 = Algorithm.Name || (Algorithm.Name = {}));
|
|
1051
|
-
})(Algorithm || (Algorithm = {}));
|
|
1052
|
-
|
|
1053
|
-
var __awaiter$1 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1054
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1055
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1056
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
1057
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
1058
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
1059
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1060
|
-
});
|
|
1061
|
-
};
|
|
1062
|
-
class Issuer extends Actor {
|
|
1063
|
-
constructor(issuer, algorithm) {
|
|
1064
|
-
super(issuer);
|
|
1065
|
-
this.algorithm = algorithm;
|
|
1066
|
-
}
|
|
1067
|
-
get header() {
|
|
1068
|
-
return {
|
|
1069
|
-
alg: this.algorithm.name,
|
|
1070
|
-
typ: "JWT",
|
|
1071
|
-
};
|
|
1072
|
-
}
|
|
1073
|
-
get payload() {
|
|
1074
|
-
const result = { iss: this.id, iat: Issuer.issuedAt };
|
|
1075
|
-
if (this.audience)
|
|
1076
|
-
result.aud = this.audience;
|
|
1077
|
-
if (this.duration && result.iat)
|
|
1078
|
-
result.exp = result.iat + this.duration;
|
|
1079
|
-
return result;
|
|
1080
|
-
}
|
|
1081
|
-
sign(payload, issuedAt) {
|
|
1082
|
-
return __awaiter$1(this, void 0, void 0, function* () {
|
|
1083
|
-
payload = Object.assign(Object.assign({}, this.payload), payload);
|
|
1084
|
-
if (issuedAt)
|
|
1085
|
-
payload.iat = typeof issuedAt == "number" ? issuedAt : issuedAt.getTime() / 1000;
|
|
1086
|
-
const transformed = yield this.transformers.reduce((p, c) => __awaiter$1(this, void 0, void 0, function* () { return c.apply(yield p); }), Promise.resolve(payload));
|
|
1087
|
-
const data = transformed &&
|
|
1088
|
-
`${encode$1(new TextEncoder().encode(JSON.stringify(this.header)), "url")}.${encode$1(new TextEncoder().encode(JSON.stringify(transformed)), "url")}`;
|
|
1089
|
-
return data && `${data}.${yield this.algorithm.sign(data)}`;
|
|
1090
|
-
});
|
|
1091
|
-
}
|
|
1092
|
-
static get issuedAt() {
|
|
1093
|
-
return Issuer.defaultIssuedAt == undefined
|
|
1094
|
-
? Math.floor(Date.now() / 1000)
|
|
1095
|
-
: typeof Issuer.defaultIssuedAt == "number"
|
|
1096
|
-
? Issuer.defaultIssuedAt
|
|
1097
|
-
: Math.floor(Issuer.defaultIssuedAt.getTime() / 1000);
|
|
1098
|
-
}
|
|
1099
|
-
static create(issuer, algorithm) {
|
|
1100
|
-
return (algorithm && new Issuer(issuer, algorithm)) || undefined;
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
|
-
var Token;
|
|
1105
|
-
(function (Token) {
|
|
1106
|
-
function is(value) {
|
|
1107
|
-
return typeof value == "string" && /^[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+/=]*$/.test(value);
|
|
1108
|
-
}
|
|
1109
|
-
Token.is = is;
|
|
1110
|
-
})(Token || (Token = {}));
|
|
1111
|
-
|
|
1112
|
-
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1113
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1114
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1115
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
1116
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
1117
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
1118
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1119
|
-
});
|
|
1120
|
-
};
|
|
1121
|
-
class Verifier extends Actor {
|
|
1122
|
-
constructor(...algorithms) {
|
|
1123
|
-
super();
|
|
1124
|
-
if (algorithms.length > 0) {
|
|
1125
|
-
this.algorithms = {};
|
|
1126
|
-
for (const algorithm of algorithms)
|
|
1127
|
-
if (this.algorithms[algorithm.name])
|
|
1128
|
-
this.algorithms[algorithm.name].push(algorithm);
|
|
1129
|
-
else
|
|
1130
|
-
this.algorithms[algorithm.name] = [algorithm];
|
|
1131
|
-
}
|
|
1132
|
-
else
|
|
1133
|
-
this.algorithms = undefined;
|
|
1134
|
-
}
|
|
1135
|
-
verify(token, ...audience) {
|
|
1136
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1137
|
-
let result;
|
|
1138
|
-
if (token) {
|
|
1139
|
-
const splitted = token.split(".", 3);
|
|
1140
|
-
if (splitted.length < 2)
|
|
1141
|
-
result = undefined;
|
|
1142
|
-
else {
|
|
1143
|
-
try {
|
|
1144
|
-
const oldDecoder = token.includes("/") || token.includes("+");
|
|
1145
|
-
const header = JSON.parse(new TextDecoder().decode(decode$1(splitted[0], oldDecoder ? "standard" : "url")));
|
|
1146
|
-
result = JSON.parse(new TextDecoder().decode(decode$1(splitted[1], oldDecoder ? "standard" : "url")));
|
|
1147
|
-
if (this.algorithms) {
|
|
1148
|
-
const algorithm = this.algorithms[header.alg];
|
|
1149
|
-
result =
|
|
1150
|
-
splitted.length == 3 &&
|
|
1151
|
-
algorithm &&
|
|
1152
|
-
algorithm.some((a) => __awaiter(this, void 0, void 0, function* () { return yield a.verify(`${splitted[0]}.${splitted[1]}`, splitted[2]); }))
|
|
1153
|
-
? result
|
|
1154
|
-
: undefined;
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
1157
|
-
catch (_a) {
|
|
1158
|
-
result = undefined;
|
|
1159
|
-
}
|
|
1160
|
-
result = result && this.verifyAudience(result.aud, audience) ? result : undefined;
|
|
1161
|
-
if (result) {
|
|
1162
|
-
const now = Math.floor(Date.now() / 1000);
|
|
1163
|
-
if ((result === null || result === void 0 ? void 0 : result.iat) && result.iat > 1000000000000)
|
|
1164
|
-
result.iat = Math.floor(result.iat / 1000);
|
|
1165
|
-
if ((result === null || result === void 0 ? void 0 : result.exp) && result.exp > 1000000000000)
|
|
1166
|
-
result.exp = Math.floor(result.exp / 1000);
|
|
1167
|
-
result =
|
|
1168
|
-
(result.exp == undefined || result.exp > now) && (result.iat == undefined || result.iat <= now)
|
|
1169
|
-
? result
|
|
1170
|
-
: undefined;
|
|
1171
|
-
}
|
|
1172
|
-
if (result) {
|
|
1173
|
-
result.token = token;
|
|
1174
|
-
result = yield this.transformers.reduceRight((p, c) => __awaiter(this, void 0, void 0, function* () { return c.reverse(yield p); }), Promise.resolve(result));
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
return result;
|
|
1179
|
-
});
|
|
1180
|
-
}
|
|
1181
|
-
verifyAudience(audience, allowed) {
|
|
1182
|
-
return (audience == undefined ||
|
|
1183
|
-
allowed.length == 0 ||
|
|
1184
|
-
(typeof audience == "string" && allowed.some(a => a == audience)) ||
|
|
1185
|
-
(Array.isArray(audience) && audience.some(a => allowed.some(ta => ta == a))));
|
|
1186
|
-
}
|
|
1187
|
-
authenticate(authorization, ...audience) {
|
|
1188
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1189
|
-
return authorization && authorization.startsWith("Bearer ")
|
|
1190
|
-
? this.verify(authorization.substr(7), ...audience)
|
|
1191
|
-
: undefined;
|
|
1192
|
-
});
|
|
1193
|
-
}
|
|
1194
|
-
static create(...algorithms) {
|
|
1195
|
-
return (((algorithms.length == 0 || algorithms.some(a => !!a)) &&
|
|
1196
|
-
new Verifier(...algorithms.filter(a => !!a))) ||
|
|
1197
|
-
undefined);
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
|
-
|
|
1201
|
-
class ClientIdentifier {
|
|
1202
|
-
constructor() { }
|
|
1203
|
-
static get value() {
|
|
1204
|
-
ClientIdentifier.valueCache = localStorage.getItem("clientIdentifier") || undefined;
|
|
1205
|
-
if (!ClientIdentifier.valueCache) {
|
|
1206
|
-
ClientIdentifier.valueCache = Identifier.generate(12);
|
|
1207
|
-
localStorage.setItem("clientIdentifier", ClientIdentifier.valueCache);
|
|
1208
|
-
}
|
|
1209
|
-
return ClientIdentifier.valueCache;
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
|
-
class Message {
|
|
1214
|
-
static is(value) {
|
|
1215
|
-
return typeof value == "object" && typeof value.destination == "string" && value.content != undefined;
|
|
1216
|
-
}
|
|
1217
|
-
static send(message, content, context) {
|
|
1218
|
-
if (Message.is(message) && context == undefined) {
|
|
1219
|
-
context = content;
|
|
1220
|
-
if (!context)
|
|
1221
|
-
context = window;
|
|
1222
|
-
const destination = message.destination.split("#", 2);
|
|
1223
|
-
message = { destination: destination[1], content: message.content };
|
|
1224
|
-
context.postMessage(message, destination[0]);
|
|
1225
|
-
}
|
|
1226
|
-
else if (typeof context != "string") {
|
|
1227
|
-
if (!context)
|
|
1228
|
-
context = window;
|
|
1229
|
-
if (typeof message == "string")
|
|
1230
|
-
Message.send({ destination: message, content }, context);
|
|
1231
|
-
}
|
|
1232
|
-
}
|
|
1233
|
-
static listen(origin, handle, context) {
|
|
1234
|
-
const splitted = origin.split("#", 2);
|
|
1235
|
-
let destination = "";
|
|
1236
|
-
if (splitted.length == 2) {
|
|
1237
|
-
origin = splitted[0];
|
|
1238
|
-
destination = splitted[1];
|
|
1239
|
-
}
|
|
1240
|
-
;
|
|
1241
|
-
(context || window).addEventListener("message", (e) => {
|
|
1242
|
-
const message = e.data;
|
|
1243
|
-
if (Message.is(message) &&
|
|
1244
|
-
(origin == "*" || e.origin == origin) &&
|
|
1245
|
-
(destination == "" || message.destination == destination))
|
|
1246
|
-
handle(message.destination, message.content);
|
|
1247
|
-
});
|
|
1248
|
-
}
|
|
1249
|
-
}
|
|
1250
|
-
|
|
1251
|
-
class Notice {
|
|
1252
|
-
constructor(stateValue, messageValue, task) {
|
|
1253
|
-
this.stateValue = stateValue;
|
|
1254
|
-
this.messageValue = messageValue;
|
|
1255
|
-
this.task = task;
|
|
1256
|
-
this.listeners = [];
|
|
1257
|
-
switch (stateValue) {
|
|
1258
|
-
case "delayed":
|
|
1259
|
-
this.timer = window.setTimeout(() => this.execute(), 5000);
|
|
1260
|
-
break;
|
|
1261
|
-
case "executing":
|
|
1262
|
-
this.execute();
|
|
1263
|
-
break;
|
|
1264
|
-
case "success":
|
|
1265
|
-
case "warning":
|
|
1266
|
-
case "failed":
|
|
1267
|
-
this.startCloseTimer();
|
|
1268
|
-
break;
|
|
1269
|
-
default:
|
|
1270
|
-
break;
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
get state() {
|
|
1274
|
-
return this.stateValue;
|
|
1275
|
-
}
|
|
1276
|
-
set state(value) {
|
|
1277
|
-
if (this.stateValue != value) {
|
|
1278
|
-
this.stateValue = value;
|
|
1279
|
-
this.emit();
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
get message() {
|
|
1283
|
-
return this.messageValue;
|
|
1284
|
-
}
|
|
1285
|
-
set message(value) {
|
|
1286
|
-
if (this.messageValue != value) {
|
|
1287
|
-
this.messageValue = value;
|
|
1288
|
-
this.emit();
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
listen(listener) {
|
|
1292
|
-
this.listeners.push(listener);
|
|
1293
|
-
}
|
|
1294
|
-
unlisten(listener) {
|
|
1295
|
-
this.listeners.filter(l => l != listener);
|
|
1296
|
-
}
|
|
1297
|
-
emit() {
|
|
1298
|
-
this.listeners.forEach(l => l(this));
|
|
1299
|
-
}
|
|
1300
|
-
execute() {
|
|
1301
|
-
this.clearTimer();
|
|
1302
|
-
if (this.task) {
|
|
1303
|
-
this.state = "executing";
|
|
1304
|
-
this.task(this).then(r => {
|
|
1305
|
-
this.messageValue = r[1];
|
|
1306
|
-
this.state = r[0] ? "success" : "failed";
|
|
1307
|
-
this.startCloseTimer();
|
|
1308
|
-
});
|
|
1309
|
-
}
|
|
1310
|
-
else
|
|
1311
|
-
this.state = "failed";
|
|
1312
|
-
}
|
|
1313
|
-
startCloseTimer() {
|
|
1314
|
-
this.timer = window.setTimeout(() => this.close(), 15000);
|
|
1315
|
-
}
|
|
1316
|
-
close() {
|
|
1317
|
-
this.clearTimer();
|
|
1318
|
-
this.state = "closed";
|
|
1319
|
-
}
|
|
1320
|
-
clearTimer() {
|
|
1321
|
-
if (this.timer) {
|
|
1322
|
-
window.clearTimeout(this.timer);
|
|
1323
|
-
this.timer = undefined;
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1326
|
-
static delay(message, task) {
|
|
1327
|
-
return new Notice("delayed", message, task);
|
|
1328
|
-
}
|
|
1329
|
-
static execute(message, task) {
|
|
1330
|
-
return new Notice("executing", message, task);
|
|
1331
|
-
}
|
|
1332
|
-
static succeded(message) {
|
|
1333
|
-
return new Notice("success", message);
|
|
1334
|
-
}
|
|
1335
|
-
static failed(message) {
|
|
1336
|
-
return new Notice("failed", message);
|
|
1337
|
-
}
|
|
1338
|
-
static warn(message) {
|
|
1339
|
-
return new Notice("warning", message);
|
|
1340
|
-
}
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
class Trigger {
|
|
1344
|
-
static is(value) {
|
|
1345
|
-
return typeof value == "object" && typeof value.name == "string";
|
|
1346
|
-
}
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
|
-
export { ClientIdentifier as C, Message as M, Notice as N, Trigger as T };
|