one 2.6.20 → 2.6.22
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/android/src/main/java/dev/onejs/onenative/OneNativeCameraManager.kt +24 -0
- package/android/src/main/java/dev/onejs/onenative/OneNativeCameraView.kt +197 -2
- package/cpp/HybridOneCrypto.cpp +327 -1
- package/cpp/HybridOneCrypto.hpp +8 -0
- package/dist/cjs/index.cjs +25 -22
- package/dist/cjs/index.native.cjs +25 -22
- package/dist/cjs/index.native.js +25 -22
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/one.cjs +1 -0
- package/dist/cjs/one.native.cjs +1 -0
- package/dist/cjs/one.native.js +1 -0
- package/dist/cjs/one.native.js.map +1 -1
- package/dist/cjs/platform/camera/index.cjs +3 -2
- package/dist/cjs/platform/camera/index.native.cjs +89 -3
- package/dist/cjs/platform/camera/index.native.js +89 -3
- package/dist/cjs/platform/camera/index.native.js.map +1 -1
- package/dist/cjs/platform/crypto/aes.cjs +259 -0
- package/dist/cjs/platform/crypto/aes.native.cjs +343 -0
- package/dist/cjs/platform/crypto/aes.native.js +345 -0
- package/dist/cjs/platform/crypto/aes.native.js.map +1 -0
- package/dist/cjs/platform/crypto/bytes.cjs +132 -0
- package/dist/cjs/platform/crypto/bytes.native.cjs +175 -0
- package/dist/cjs/platform/crypto/bytes.native.js +177 -0
- package/dist/cjs/platform/crypto/bytes.native.js.map +1 -0
- package/dist/cjs/platform/crypto/digest-api.cjs +65 -0
- package/dist/cjs/platform/crypto/digest-api.native.cjs +69 -0
- package/dist/cjs/platform/crypto/digest-api.native.js +71 -0
- package/dist/cjs/platform/crypto/digest-api.native.js.map +1 -0
- package/dist/cjs/platform/crypto/digest.cjs +26 -15
- package/dist/cjs/platform/crypto/digest.native.cjs +26 -15
- package/dist/cjs/platform/crypto/digest.native.js +26 -15
- package/dist/cjs/platform/crypto/digest.native.js.map +1 -1
- package/dist/cjs/platform/crypto/index.cjs +19 -1
- package/dist/cjs/platform/crypto/index.native.cjs +39 -1
- package/dist/cjs/platform/crypto/index.native.js +39 -1
- package/dist/cjs/platform/crypto/index.native.js.map +1 -1
- package/dist/cjs/platform/crypto/types.cjs +16 -0
- package/dist/cjs/platform/crypto/types.native.cjs +18 -0
- package/dist/cjs/platform/crypto/types.native.js +20 -0
- package/dist/cjs/platform/crypto/types.native.js.map +1 -0
- package/dist/cjs/platform/crypto/web.cjs +73 -0
- package/dist/cjs/platform/extras.cjs +4 -0
- package/dist/cjs/platform/extras.native.cjs +4 -0
- package/dist/cjs/platform/extras.native.js +4 -0
- package/dist/cjs/platform/extras.native.js.map +1 -1
- package/dist/cjs/platform/specs/OneNativeCameraNativeComponent.cjs +37 -21
- package/dist/cjs/platform/specs/OneNativeCameraNativeComponent.native.cjs +37 -21
- package/dist/cjs/platform/specs/OneNativeCameraNativeComponent.native.js +37 -21
- package/dist/cjs/platform/specs/OneNativeCameraNativeComponent.native.js.map +3 -3
- package/dist/cjs/router/router.cjs +4 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/index.native.js +2 -2
- package/dist/esm/one.mjs +2 -1
- package/dist/esm/one.mjs.map +1 -1
- package/dist/esm/one.native.js +2 -1
- package/dist/esm/one.native.js.map +1 -1
- package/dist/esm/platform/camera/index.mjs +4 -2
- package/dist/esm/platform/camera/index.mjs.map +1 -1
- package/dist/esm/platform/camera/index.native.js +90 -4
- package/dist/esm/platform/camera/index.native.js.map +1 -1
- package/dist/esm/platform/crypto/aes.mjs +236 -0
- package/dist/esm/platform/crypto/aes.mjs.map +1 -0
- package/dist/esm/platform/crypto/aes.native.js +318 -0
- package/dist/esm/platform/crypto/aes.native.js.map +1 -0
- package/dist/esm/platform/crypto/bytes.mjs +104 -0
- package/dist/esm/platform/crypto/bytes.mjs.map +1 -0
- package/dist/esm/platform/crypto/bytes.native.js +145 -0
- package/dist/esm/platform/crypto/bytes.native.js.map +1 -0
- package/dist/esm/platform/crypto/digest-api.mjs +42 -0
- package/dist/esm/platform/crypto/digest-api.mjs.map +1 -0
- package/dist/esm/platform/crypto/digest-api.native.js +44 -0
- package/dist/esm/platform/crypto/digest-api.native.js.map +1 -0
- package/dist/esm/platform/crypto/digest.mjs +23 -15
- package/dist/esm/platform/crypto/digest.mjs.map +1 -1
- package/dist/esm/platform/crypto/digest.native.js +23 -15
- package/dist/esm/platform/crypto/digest.native.js.map +1 -1
- package/dist/esm/platform/crypto/index.mjs +14 -1
- package/dist/esm/platform/crypto/index.mjs.map +1 -1
- package/dist/esm/platform/crypto/index.native.js +34 -1
- package/dist/esm/platform/crypto/index.native.js.map +1 -1
- package/dist/esm/platform/crypto/types.mjs +0 -0
- package/dist/esm/platform/crypto/types.native.js +0 -0
- package/dist/esm/platform/crypto/web.mjs +50 -0
- package/dist/esm/platform/crypto/web.mjs.map +1 -0
- package/dist/esm/platform/extras.mjs +2 -1
- package/dist/esm/platform/extras.native.js +2 -1
- package/dist/esm/platform/specs/OneNativeCameraNativeComponent.mjs +25 -9
- package/dist/esm/platform/specs/OneNativeCameraNativeComponent.mjs.map +3 -3
- package/dist/esm/platform/specs/OneNativeCameraNativeComponent.native.js +25 -9
- package/dist/esm/platform/specs/OneNativeCameraNativeComponent.native.js.map +3 -3
- package/dist/esm/router/router.mjs +5 -2
- package/dist/esm/router/router.mjs.map +1 -1
- package/ios/OneNativeCameraComponentView.mm +28 -0
- package/ios/OneNativeCameraView.swift +163 -0
- package/nitrogen/generated/shared/c++/HybridOneCryptoSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridOneCryptoSpec.hpp +4 -1
- package/package.json +12 -12
- package/src/index.ts +4 -0
- package/src/one.ts +3 -0
- package/src/platform/camera/index.native.tsx +116 -12
- package/src/platform/camera/index.tsx +15 -4
- package/src/platform/camera/types.ts +22 -0
- package/src/platform/crypto/aes.ts +345 -0
- package/src/platform/crypto/bytes.ts +120 -0
- package/src/platform/crypto/digest-api.ts +50 -0
- package/src/platform/crypto/digest.ts +24 -15
- package/src/platform/crypto/index.native.ts +68 -0
- package/src/platform/crypto/index.ts +31 -0
- package/src/platform/crypto/types.ts +64 -0
- package/src/platform/crypto/web.ts +69 -0
- package/src/platform/extras.ts +15 -0
- package/src/platform/index.native.ts +4 -0
- package/src/platform/index.ts +4 -0
- package/src/platform/specs/OneCrypto.nitro.ts +19 -0
- package/src/platform/specs/OneNativeCameraNativeComponent.ts +35 -2
- package/src/router/router.ts +7 -4
- package/types/index.d.ts +2 -1
- package/types/index.d.ts.map +1 -1
- package/types/one.d.ts +2 -1
- package/types/one.d.ts.map +1 -1
- package/types/platform/camera/index.d.ts +3 -3
- package/types/platform/camera/index.d.ts.map +1 -1
- package/types/platform/camera/index.native.d.ts +3 -3
- package/types/platform/camera/index.native.d.ts.map +1 -1
- package/types/platform/camera/types.d.ts +18 -0
- package/types/platform/camera/types.d.ts.map +1 -1
- package/types/platform/crypto/aes.d.ts +211 -0
- package/types/platform/crypto/aes.d.ts.map +1 -0
- package/types/platform/crypto/bytes.d.ts +8 -0
- package/types/platform/crypto/bytes.d.ts.map +1 -0
- package/types/platform/crypto/digest-api.d.ts +9 -0
- package/types/platform/crypto/digest-api.d.ts.map +1 -0
- package/types/platform/crypto/digest.d.ts +5 -0
- package/types/platform/crypto/digest.d.ts.map +1 -1
- package/types/platform/crypto/index.d.ts +127 -0
- package/types/platform/crypto/index.d.ts.map +1 -1
- package/types/platform/crypto/index.native.d.ts +127 -0
- package/types/platform/crypto/index.native.d.ts.map +1 -1
- package/types/platform/crypto/types.d.ts +43 -0
- package/types/platform/crypto/types.d.ts.map +1 -0
- package/types/platform/crypto/web.d.ts +5 -0
- package/types/platform/crypto/web.d.ts.map +1 -0
- package/types/platform/extras.d.ts +2 -0
- package/types/platform/extras.d.ts.map +1 -1
- package/types/platform/index.d.ts +1 -1
- package/types/platform/index.d.ts.map +1 -1
- package/types/platform/index.native.d.ts +1 -1
- package/types/platform/index.native.d.ts.map +1 -1
- package/types/platform/specs/OneCrypto.nitro.d.ts +2 -0
- package/types/platform/specs/OneCrypto.nitro.d.ts.map +1 -1
- package/types/platform/specs/OneNativeCameraNativeComponent.d.ts +18 -2
- package/types/platform/specs/OneNativeCameraNativeComponent.d.ts.map +1 -1
- package/types/router/router.d.ts.map +1 -1
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
const HEX_DIGITS = "0123456789abcdef";
|
|
2
|
+
function bytesToHex(bytes) {
|
|
3
|
+
let out = "";
|
|
4
|
+
for (const byte of bytes) out += HEX_DIGITS[byte >> 4] + HEX_DIGITS[byte & 15];
|
|
5
|
+
return out;
|
|
6
|
+
}
|
|
7
|
+
function hexToBytes(hex, verb) {
|
|
8
|
+
if (hex.length % 2 !== 0 || /[^0-9a-fA-F]/.test(hex)) {
|
|
9
|
+
throw new Error(`${verb}: expected an even-length hex string`);
|
|
10
|
+
}
|
|
11
|
+
const out = new Uint8Array(hex.length / 2);
|
|
12
|
+
for (let index = 0; index < out.length; index++) {
|
|
13
|
+
out[index] = parseInt(hex.slice(index * 2, index * 2 + 2), 16);
|
|
14
|
+
}
|
|
15
|
+
return out;
|
|
16
|
+
}
|
|
17
|
+
const BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
18
|
+
const BASE64_VALUES = new Int16Array(128).fill(-1);
|
|
19
|
+
for (let index = 0; index < BASE64_ALPHABET.length; index++) {
|
|
20
|
+
BASE64_VALUES[BASE64_ALPHABET.charCodeAt(index)] = index;
|
|
21
|
+
}
|
|
22
|
+
function bytesToBase64(bytes) {
|
|
23
|
+
let out = "";
|
|
24
|
+
for (let index = 0; index < bytes.length; index += 3) {
|
|
25
|
+
const first = bytes[index];
|
|
26
|
+
const second = bytes[index + 1];
|
|
27
|
+
const third = bytes[index + 2];
|
|
28
|
+
out += BASE64_ALPHABET[first >> 2];
|
|
29
|
+
out += BASE64_ALPHABET[(first & 3) << 4 | (second ?? 0) >> 4];
|
|
30
|
+
out += second === void 0 ? "=" : BASE64_ALPHABET[(second & 15) << 2 | (third ?? 0) >> 6];
|
|
31
|
+
out += third === void 0 ? "=" : BASE64_ALPHABET[third & 63];
|
|
32
|
+
}
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
function base64ToBytes(base64, verb) {
|
|
36
|
+
if (base64.length % 4 !== 0 || /[^A-Za-z0-9+/=]/.test(base64)) {
|
|
37
|
+
throw new Error(`${verb}: expected a base64 string`);
|
|
38
|
+
}
|
|
39
|
+
const padding = base64.endsWith("==") ? 2 : base64.endsWith("=") ? 1 : 0;
|
|
40
|
+
if (base64.slice(0, base64.length - padding).includes("=")) {
|
|
41
|
+
throw new Error(`${verb}: expected a base64 string`);
|
|
42
|
+
}
|
|
43
|
+
const out = new Uint8Array(base64.length / 4 * 3 - padding);
|
|
44
|
+
let at = 0;
|
|
45
|
+
for (let index = 0; index < base64.length; index += 4) {
|
|
46
|
+
const values = [
|
|
47
|
+
0,
|
|
48
|
+
1,
|
|
49
|
+
2,
|
|
50
|
+
3
|
|
51
|
+
].map((offset) => {
|
|
52
|
+
const code = base64.charCodeAt(index + offset);
|
|
53
|
+
return code === 61 ? 0 : BASE64_VALUES[code];
|
|
54
|
+
});
|
|
55
|
+
if (values.some((value) => value < 0)) throw new Error(`${verb}: expected a base64 string`);
|
|
56
|
+
if (at < out.length) out[at++] = values[0] << 2 | values[1] >> 4;
|
|
57
|
+
if (at < out.length) out[at++] = (values[1] & 15) << 4 | values[2] >> 2;
|
|
58
|
+
if (at < out.length) out[at++] = (values[2] & 3) << 6 | values[3];
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
function utf8Encode(text) {
|
|
63
|
+
const bytes = [];
|
|
64
|
+
for (let index = 0; index < text.length; index++) {
|
|
65
|
+
let code = text.charCodeAt(index);
|
|
66
|
+
if (code >= 55296 && code <= 56319) {
|
|
67
|
+
const next = text.charCodeAt(index + 1);
|
|
68
|
+
if (next >= 56320 && next <= 57343) {
|
|
69
|
+
code = 65536 + (code - 55296 << 10) + (next - 56320);
|
|
70
|
+
index++;
|
|
71
|
+
} else {
|
|
72
|
+
code = 65533;
|
|
73
|
+
}
|
|
74
|
+
} else if (code >= 56320 && code <= 57343) {
|
|
75
|
+
code = 65533;
|
|
76
|
+
}
|
|
77
|
+
if (code < 128) {
|
|
78
|
+
bytes.push(code);
|
|
79
|
+
} else if (code < 2048) {
|
|
80
|
+
bytes.push(192 | code >> 6, 128 | code & 63);
|
|
81
|
+
} else if (code < 65536) {
|
|
82
|
+
bytes.push(224 | code >> 12, 128 | code >> 6 & 63, 128 | code & 63);
|
|
83
|
+
} else {
|
|
84
|
+
bytes.push(240 | code >> 18, 128 | code >> 12 & 63, 128 | code >> 6 & 63, 128 | code & 63);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return new Uint8Array(bytes);
|
|
88
|
+
}
|
|
89
|
+
function exactBytes(view) {
|
|
90
|
+
return new Uint8Array(view);
|
|
91
|
+
}
|
|
92
|
+
function concatBytes(parts) {
|
|
93
|
+
const length = parts.reduce((sum, part) => sum + part.length, 0);
|
|
94
|
+
const out = new Uint8Array(length);
|
|
95
|
+
let at = 0;
|
|
96
|
+
for (const part of parts) {
|
|
97
|
+
out.set(part, at);
|
|
98
|
+
at += part.length;
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export { base64ToBytes, bytesToBase64, bytesToHex, concatBytes, exactBytes, hexToBytes, utf8Encode };
|
|
104
|
+
//# sourceMappingURL=bytes.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes.js","names":[],"sources":["esm/platform/crypto/bytes.js"],"sourcesContent":["const HEX_DIGITS = \"0123456789abcdef\";\nfunction bytesToHex(bytes) {\n let out = \"\";\n for (const byte of bytes) out += HEX_DIGITS[byte >> 4] + HEX_DIGITS[byte & 15];\n return out;\n}\nfunction hexToBytes(hex, verb) {\n if (hex.length % 2 !== 0 || /[^0-9a-fA-F]/.test(hex)) {\n throw new Error(`${verb}: expected an even-length hex string`);\n }\n const out = new Uint8Array(hex.length / 2);\n for (let index = 0; index < out.length; index++) {\n out[index] = parseInt(hex.slice(index * 2, index * 2 + 2), 16);\n }\n return out;\n}\nconst BASE64_ALPHABET = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\nconst BASE64_VALUES = new Int16Array(128).fill(-1);\nfor (let index = 0; index < BASE64_ALPHABET.length; index++) {\n BASE64_VALUES[BASE64_ALPHABET.charCodeAt(index)] = index;\n}\nfunction bytesToBase64(bytes) {\n let out = \"\";\n for (let index = 0; index < bytes.length; index += 3) {\n const first = bytes[index];\n const second = bytes[index + 1];\n const third = bytes[index + 2];\n out += BASE64_ALPHABET[first >> 2];\n out += BASE64_ALPHABET[(first & 3) << 4 | (second ?? 0) >> 4];\n out += second === void 0 ? \"=\" : BASE64_ALPHABET[(second & 15) << 2 | (third ?? 0) >> 6];\n out += third === void 0 ? \"=\" : BASE64_ALPHABET[third & 63];\n }\n return out;\n}\nfunction base64ToBytes(base64, verb) {\n if (base64.length % 4 !== 0 || /[^A-Za-z0-9+/=]/.test(base64)) {\n throw new Error(`${verb}: expected a base64 string`);\n }\n const padding = base64.endsWith(\"==\") ? 2 : base64.endsWith(\"=\") ? 1 : 0;\n if (base64.slice(0, base64.length - padding).includes(\"=\")) {\n throw new Error(`${verb}: expected a base64 string`);\n }\n const out = new Uint8Array(base64.length / 4 * 3 - padding);\n let at = 0;\n for (let index = 0; index < base64.length; index += 4) {\n const values = [0, 1, 2, 3].map((offset) => {\n const code = base64.charCodeAt(index + offset);\n return code === 61 ? 0 : BASE64_VALUES[code];\n });\n if (values.some((value) => value < 0)) throw new Error(`${verb}: expected a base64 string`);\n if (at < out.length) out[at++] = values[0] << 2 | values[1] >> 4;\n if (at < out.length) out[at++] = (values[1] & 15) << 4 | values[2] >> 2;\n if (at < out.length) out[at++] = (values[2] & 3) << 6 | values[3];\n }\n return out;\n}\nfunction utf8Encode(text) {\n const bytes = [];\n for (let index = 0; index < text.length; index++) {\n let code = text.charCodeAt(index);\n if (code >= 55296 && code <= 56319) {\n const next = text.charCodeAt(index + 1);\n if (next >= 56320 && next <= 57343) {\n code = 65536 + (code - 55296 << 10) + (next - 56320);\n index++;\n } else {\n code = 65533;\n }\n } else if (code >= 56320 && code <= 57343) {\n code = 65533;\n }\n if (code < 128) {\n bytes.push(code);\n } else if (code < 2048) {\n bytes.push(192 | code >> 6, 128 | code & 63);\n } else if (code < 65536) {\n bytes.push(224 | code >> 12, 128 | code >> 6 & 63, 128 | code & 63);\n } else {\n bytes.push(\n 240 | code >> 18,\n 128 | code >> 12 & 63,\n 128 | code >> 6 & 63,\n 128 | code & 63\n );\n }\n }\n return new Uint8Array(bytes);\n}\nfunction exactBytes(view) {\n return new Uint8Array(view);\n}\nfunction concatBytes(parts) {\n const length = parts.reduce((sum, part) => sum + part.length, 0);\n const out = new Uint8Array(length);\n let at = 0;\n for (const part of parts) {\n out.set(part, at);\n at += part.length;\n }\n return out;\n}\nexport {\n base64ToBytes,\n bytesToBase64,\n bytesToHex,\n concatBytes,\n exactBytes,\n hexToBytes,\n utf8Encode\n};\n//# sourceMappingURL=bytes.js.map\n"],"mappings":";AAAA,MAAM,aAAa;AACnB,SAAS,WAAW,OAAO;CACzB,IAAI,MAAM;CACV,KAAK,MAAM,QAAQ,OAAO,OAAO,WAAW,QAAQ,KAAK,WAAW,OAAO;CAC3E,OAAO;AACT;AACA,SAAS,WAAW,KAAK,MAAM;CAC7B,IAAI,IAAI,SAAS,MAAM,KAAK,eAAe,KAAK,GAAG,GAAG;EACpD,MAAM,IAAI,MAAM,GAAG,KAAK,qCAAqC;CAC/D;CACA,MAAM,MAAM,IAAI,WAAW,IAAI,SAAS,CAAC;CACzC,KAAK,IAAI,QAAQ,GAAG,QAAQ,IAAI,QAAQ,SAAS;EAC/C,IAAI,SAAS,SAAS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OAAO,IAAI,WAAW,KAAK;AAC7B;AACA,SAAS,WAAW,MAAM;CACxB,OAAO,IAAI,WAAW,IAAI;AAC5B;AACA,SAAS,YAAY,OAAO;CAC1B,MAAM,SAAS,MAAM,QAAQ,KAAK,SAAS,MAAM,KAAK,QAAQ,CAAC;CAC/D,MAAM,MAAM,IAAI,WAAW,MAAM;CACjC,IAAI,KAAK;CACT,KAAK,MAAM,QAAQ,OAAO;EACxB,IAAI,IAAI,MAAM,EAAE;EAChB,MAAM,KAAK;CACb;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
var HEX_DIGITS = "0123456789abcdef";
|
|
2
|
+
function bytesToHex(bytes) {
|
|
3
|
+
var out = "";
|
|
4
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
5
|
+
try {
|
|
6
|
+
for (var _iterator = bytes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
7
|
+
var byte = _step.value;
|
|
8
|
+
out += HEX_DIGITS[byte >> 4] + HEX_DIGITS[byte & 15];
|
|
9
|
+
}
|
|
10
|
+
} catch (err) {
|
|
11
|
+
_didIteratorError = true;
|
|
12
|
+
_iteratorError = err;
|
|
13
|
+
} finally {
|
|
14
|
+
try {
|
|
15
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
16
|
+
_iterator.return();
|
|
17
|
+
}
|
|
18
|
+
} finally {
|
|
19
|
+
if (_didIteratorError) {
|
|
20
|
+
throw _iteratorError;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
function hexToBytes(hex, verb) {
|
|
27
|
+
if (hex.length % 2 !== 0 || /[^0-9a-fA-F]/.test(hex)) {
|
|
28
|
+
throw new Error(`${verb}: expected an even-length hex string`);
|
|
29
|
+
}
|
|
30
|
+
var out = new Uint8Array(hex.length / 2);
|
|
31
|
+
for (var index2 = 0; index2 < out.length; index2++) {
|
|
32
|
+
out[index2] = parseInt(hex.slice(index2 * 2, index2 * 2 + 2), 16);
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
var BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
37
|
+
var BASE64_VALUES = new Int16Array(128).fill(-1);
|
|
38
|
+
for (var index = 0; index < BASE64_ALPHABET.length; index++) {
|
|
39
|
+
BASE64_VALUES[BASE64_ALPHABET.charCodeAt(index)] = index;
|
|
40
|
+
}
|
|
41
|
+
function bytesToBase64(bytes) {
|
|
42
|
+
var out = "";
|
|
43
|
+
for (var index2 = 0; index2 < bytes.length; index2 += 3) {
|
|
44
|
+
var first = bytes[index2];
|
|
45
|
+
var second = bytes[index2 + 1];
|
|
46
|
+
var third = bytes[index2 + 2];
|
|
47
|
+
out += BASE64_ALPHABET[first >> 2];
|
|
48
|
+
out += BASE64_ALPHABET[(first & 3) << 4 | (second !== null && second !== void 0 ? second : 0) >> 4];
|
|
49
|
+
out += second === void 0 ? "=" : BASE64_ALPHABET[(second & 15) << 2 | (third !== null && third !== void 0 ? third : 0) >> 6];
|
|
50
|
+
out += third === void 0 ? "=" : BASE64_ALPHABET[third & 63];
|
|
51
|
+
}
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
function base64ToBytes(base64, verb) {
|
|
55
|
+
var _loop = function(index3) {
|
|
56
|
+
var values = [
|
|
57
|
+
0,
|
|
58
|
+
1,
|
|
59
|
+
2,
|
|
60
|
+
3
|
|
61
|
+
].map(function(offset) {
|
|
62
|
+
var code = base64.charCodeAt(index3 + offset);
|
|
63
|
+
return code === 61 ? 0 : BASE64_VALUES[code];
|
|
64
|
+
});
|
|
65
|
+
if (values.some(function(value) {
|
|
66
|
+
return value < 0;
|
|
67
|
+
})) throw new Error(`${verb}: expected a base64 string`);
|
|
68
|
+
if (at < out.length) out[at++] = values[0] << 2 | values[1] >> 4;
|
|
69
|
+
if (at < out.length) out[at++] = (values[1] & 15) << 4 | values[2] >> 2;
|
|
70
|
+
if (at < out.length) out[at++] = (values[2] & 3) << 6 | values[3];
|
|
71
|
+
};
|
|
72
|
+
if (base64.length % 4 !== 0 || /[^A-Za-z0-9+/=]/.test(base64)) {
|
|
73
|
+
throw new Error(`${verb}: expected a base64 string`);
|
|
74
|
+
}
|
|
75
|
+
var padding = base64.endsWith("==") ? 2 : base64.endsWith("=") ? 1 : 0;
|
|
76
|
+
if (base64.slice(0, base64.length - padding).includes("=")) {
|
|
77
|
+
throw new Error(`${verb}: expected a base64 string`);
|
|
78
|
+
}
|
|
79
|
+
var out = new Uint8Array(base64.length / 4 * 3 - padding);
|
|
80
|
+
var at = 0;
|
|
81
|
+
for (var index2 = 0; index2 < base64.length; index2 += 4) _loop(index2);
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
function utf8Encode(text) {
|
|
85
|
+
var bytes = [];
|
|
86
|
+
for (var index2 = 0; index2 < text.length; index2++) {
|
|
87
|
+
var code = text.charCodeAt(index2);
|
|
88
|
+
if (code >= 55296 && code <= 56319) {
|
|
89
|
+
var next = text.charCodeAt(index2 + 1);
|
|
90
|
+
if (next >= 56320 && next <= 57343) {
|
|
91
|
+
code = 65536 + (code - 55296 << 10) + (next - 56320);
|
|
92
|
+
index2++;
|
|
93
|
+
} else {
|
|
94
|
+
code = 65533;
|
|
95
|
+
}
|
|
96
|
+
} else if (code >= 56320 && code <= 57343) {
|
|
97
|
+
code = 65533;
|
|
98
|
+
}
|
|
99
|
+
if (code < 128) {
|
|
100
|
+
bytes.push(code);
|
|
101
|
+
} else if (code < 2048) {
|
|
102
|
+
bytes.push(192 | code >> 6, 128 | code & 63);
|
|
103
|
+
} else if (code < 65536) {
|
|
104
|
+
bytes.push(224 | code >> 12, 128 | code >> 6 & 63, 128 | code & 63);
|
|
105
|
+
} else {
|
|
106
|
+
bytes.push(240 | code >> 18, 128 | code >> 12 & 63, 128 | code >> 6 & 63, 128 | code & 63);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return new Uint8Array(bytes);
|
|
110
|
+
}
|
|
111
|
+
function exactBytes(view) {
|
|
112
|
+
return new Uint8Array(view);
|
|
113
|
+
}
|
|
114
|
+
function concatBytes(parts) {
|
|
115
|
+
var length = parts.reduce(function(sum, part2) {
|
|
116
|
+
return sum + part2.length;
|
|
117
|
+
}, 0);
|
|
118
|
+
var out = new Uint8Array(length);
|
|
119
|
+
var at = 0;
|
|
120
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
121
|
+
try {
|
|
122
|
+
for (var _iterator = parts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
123
|
+
var part = _step.value;
|
|
124
|
+
out.set(part, at);
|
|
125
|
+
at += part.length;
|
|
126
|
+
}
|
|
127
|
+
} catch (err) {
|
|
128
|
+
_didIteratorError = true;
|
|
129
|
+
_iteratorError = err;
|
|
130
|
+
} finally {
|
|
131
|
+
try {
|
|
132
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
133
|
+
_iterator.return();
|
|
134
|
+
}
|
|
135
|
+
} finally {
|
|
136
|
+
if (_didIteratorError) {
|
|
137
|
+
throw _iteratorError;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return out;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export { base64ToBytes, bytesToBase64, bytesToHex, concatBytes, exactBytes, hexToBytes, utf8Encode };
|
|
145
|
+
//# sourceMappingURL=bytes.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes.native.js","names":[],"sources":["esm/platform/crypto/bytes.native.js"],"sourcesContent":["var HEX_DIGITS = \"0123456789abcdef\";\nfunction bytesToHex(bytes) {\n var out = \"\";\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = bytes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var byte = _step.value;\n out += HEX_DIGITS[byte >> 4] + HEX_DIGITS[byte & 15];\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return out;\n}\nfunction hexToBytes(hex, verb) {\n if (hex.length % 2 !== 0 || /[^0-9a-fA-F]/.test(hex)) {\n throw new Error(`${verb}: expected an even-length hex string`);\n }\n var out = new Uint8Array(hex.length / 2);\n for (var index2 = 0; index2 < out.length; index2++) {\n out[index2] = parseInt(hex.slice(index2 * 2, index2 * 2 + 2), 16);\n }\n return out;\n}\nvar BASE64_ALPHABET = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\nvar BASE64_VALUES = new Int16Array(128).fill(-1);\nfor (var index = 0; index < BASE64_ALPHABET.length; index++) {\n BASE64_VALUES[BASE64_ALPHABET.charCodeAt(index)] = index;\n}\nfunction bytesToBase64(bytes) {\n var out = \"\";\n for (var index2 = 0; index2 < bytes.length; index2 += 3) {\n var first = bytes[index2];\n var second = bytes[index2 + 1];\n var third = bytes[index2 + 2];\n out += BASE64_ALPHABET[first >> 2];\n out += BASE64_ALPHABET[(first & 3) << 4 | (second !== null && second !== void 0 ? second : 0) >> 4];\n out += second === void 0 ? \"=\" : BASE64_ALPHABET[(second & 15) << 2 | (third !== null && third !== void 0 ? third : 0) >> 6];\n out += third === void 0 ? \"=\" : BASE64_ALPHABET[third & 63];\n }\n return out;\n}\nfunction base64ToBytes(base64, verb) {\n var _loop = function(index3) {\n var values = [\n 0,\n 1,\n 2,\n 3\n ].map(function(offset) {\n var code = base64.charCodeAt(index3 + offset);\n return code === 61 ? 0 : BASE64_VALUES[code];\n });\n if (values.some(function(value) {\n return value < 0;\n })) throw new Error(`${verb}: expected a base64 string`);\n if (at < out.length) out[at++] = values[0] << 2 | values[1] >> 4;\n if (at < out.length) out[at++] = (values[1] & 15) << 4 | values[2] >> 2;\n if (at < out.length) out[at++] = (values[2] & 3) << 6 | values[3];\n };\n if (base64.length % 4 !== 0 || /[^A-Za-z0-9+/=]/.test(base64)) {\n throw new Error(`${verb}: expected a base64 string`);\n }\n var padding = base64.endsWith(\"==\") ? 2 : base64.endsWith(\"=\") ? 1 : 0;\n if (base64.slice(0, base64.length - padding).includes(\"=\")) {\n throw new Error(`${verb}: expected a base64 string`);\n }\n var out = new Uint8Array(base64.length / 4 * 3 - padding);\n var at = 0;\n for (var index2 = 0; index2 < base64.length; index2 += 4) _loop(index2);\n return out;\n}\nfunction utf8Encode(text) {\n var bytes = [];\n for (var index2 = 0; index2 < text.length; index2++) {\n var code = text.charCodeAt(index2);\n if (code >= 55296 && code <= 56319) {\n var next = text.charCodeAt(index2 + 1);\n if (next >= 56320 && next <= 57343) {\n code = 65536 + (code - 55296 << 10) + (next - 56320);\n index2++;\n } else {\n code = 65533;\n }\n } else if (code >= 56320 && code <= 57343) {\n code = 65533;\n }\n if (code < 128) {\n bytes.push(code);\n } else if (code < 2048) {\n bytes.push(192 | code >> 6, 128 | code & 63);\n } else if (code < 65536) {\n bytes.push(224 | code >> 12, 128 | code >> 6 & 63, 128 | code & 63);\n } else {\n bytes.push(240 | code >> 18, 128 | code >> 12 & 63, 128 | code >> 6 & 63, 128 | code & 63);\n }\n }\n return new Uint8Array(bytes);\n}\nfunction exactBytes(view) {\n return new Uint8Array(view);\n}\nfunction concatBytes(parts) {\n var length = parts.reduce(function(sum, part2) {\n return sum + part2.length;\n }, 0);\n var out = new Uint8Array(length);\n var at = 0;\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = parts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var part = _step.value;\n out.set(part, at);\n at += part.length;\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return out;\n}\nexport {\n base64ToBytes,\n bytesToBase64,\n bytesToHex,\n concatBytes,\n exactBytes,\n hexToBytes,\n utf8Encode\n};\n//# sourceMappingURL=bytes.js.map\n"],"mappings":";AAAA,IAAI,aAAa;AACjB,SAAS,WAAW,OAAO;CACzB,IAAI,MAAM;CACV,IAAI,4BAA4B,MAAM,oBAAoB,OAAO,iBAAiB,KAAK;CACvF,IAAI;EACF,KAAK,IAAI,YAAY,MAAM,OAAO,SAAS,CAAC,GAAG,OAAO,EAAE,6BAA6B,QAAQ,UAAU,KAAK,EAAC,CAAE,OAAO,4BAA4B,MAAM;GACtJ,IAAI,OAAO,MAAM;GACjB,OAAO,WAAW,QAAQ,KAAK,WAAW,OAAO;EACnD;CACF,SAAS,KAAK;EACZ,oBAAoB;EACpB,iBAAiB;CACnB,UAAU;EACR,IAAI;GACF,IAAI,CAAC,6BAA6B,UAAU,UAAU,MAAM;IAC1D,UAAU,OAAO;GACnB;EACF,UAAU;GACR,IAAI,mBAAmB;IACrB,MAAM;GACR;EACF;CACF;CACA,OAAO;AACT;AACA,SAAS,WAAW,KAAK,MAAM;CAC7B,IAAI,IAAI,SAAS,MAAM,KAAK,eAAe,KAAK,GAAG,GAAG;EACpD,MAAM,IAAI,MAAM,GAAG,KAAK,qCAAqC;CAC/D;CACA,IAAI,MAAM,IAAI,WAAW,IAAI,SAAS,CAAC;CACvC,KAAK,IAAI,SAAS,GAAG,SAAS,IAAI,QAAQ,UAAU;EAClD,IAAI,UAAU,SAAS,IAAI,MAAM,SAAS,GAAG,SAAS,IAAI,CAAC,GAAG,EAAE;CAClE;CACA,OAAO;AACT;AACA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,IAAI,MAAM,OAAO,EAAE;EAC3F;CACF;CACA,OAAO,IAAI,WAAW,KAAK;AAC7B;AACA,SAAS,WAAW,MAAM;CACxB,OAAO,IAAI,WAAW,IAAI;AAC5B;AACA,SAAS,YAAY,OAAO;CAC1B,IAAI,SAAS,MAAM,OAAO,SAAS,KAAK,OAAO;EAC7C,OAAO,MAAM,MAAM;CACrB,GAAG,CAAC;CACJ,IAAI,MAAM,IAAI,WAAW,MAAM;CAC/B,IAAI,KAAK;CACT,IAAI,4BAA4B,MAAM,oBAAoB,OAAO,iBAAiB,KAAK;CACvF,IAAI;EACF,KAAK,IAAI,YAAY,MAAM,OAAO,SAAS,CAAC,GAAG,OAAO,EAAE,6BAA6B,QAAQ,UAAU,KAAK,EAAC,CAAE,OAAO,4BAA4B,MAAM;GACtJ,IAAI,OAAO,MAAM;GACjB,IAAI,IAAI,MAAM,EAAE;GAChB,MAAM,KAAK;EACb;CACF,SAAS,KAAK;EACZ,oBAAoB;EACpB,iBAAiB;CACnB,UAAU;EACR,IAAI;GACF,IAAI,CAAC,6BAA6B,UAAU,UAAU,MAAM;IAC1D,UAAU,OAAO;GACnB;EACF,UAAU;GACR,IAAI,mBAAmB;IACrB,MAAM;GACR;EACF;CACF;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { bytesToBase64, bytesToHex, utf8Encode } from "./bytes.mjs";
|
|
2
|
+
import { bufferSourceRange } from "./digest.mjs";
|
|
3
|
+
|
|
4
|
+
const DIGEST_ALGORITHMS = [
|
|
5
|
+
"MD5",
|
|
6
|
+
"SHA-1",
|
|
7
|
+
"SHA-256",
|
|
8
|
+
"SHA-384",
|
|
9
|
+
"SHA-512"
|
|
10
|
+
];
|
|
11
|
+
function assertDigestAlgorithm(algorithm, verb) {
|
|
12
|
+
if (!DIGEST_ALGORITHMS.includes(algorithm)) {
|
|
13
|
+
throw new Error(`${verb}: unknown algorithm ${JSON.stringify(algorithm)}. Expected one of: ${DIGEST_ALGORITHMS.join(", ")}`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function createDigestApi(source) {
|
|
17
|
+
async function digest(algorithm, data) {
|
|
18
|
+
assertDigestAlgorithm(algorithm, "Crypto.digest");
|
|
19
|
+
const { buffer, offset, length } = bufferSourceRange(data, "Crypto.digest");
|
|
20
|
+
return source(algorithm, buffer, offset, length);
|
|
21
|
+
}
|
|
22
|
+
async function digestString(algorithm, data, options = {}) {
|
|
23
|
+
assertDigestAlgorithm(algorithm, "Crypto.digestString");
|
|
24
|
+
if (typeof data !== "string") {
|
|
25
|
+
throw new TypeError("Crypto.digestString: data must be a string");
|
|
26
|
+
}
|
|
27
|
+
const encoding = options?.encoding ?? "hex";
|
|
28
|
+
if (encoding !== "hex" && encoding !== "base64") {
|
|
29
|
+
throw new Error(`Crypto.digestString: encoding must be 'hex' or 'base64'`);
|
|
30
|
+
}
|
|
31
|
+
const bytes = utf8Encode(data);
|
|
32
|
+
const hashed = new Uint8Array(await source(algorithm, bytes.buffer, 0, bytes.length));
|
|
33
|
+
return encoding === "base64" ? bytesToBase64(hashed) : bytesToHex(hashed);
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
digest,
|
|
37
|
+
digestString
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { DIGEST_ALGORITHMS, assertDigestAlgorithm, createDigestApi };
|
|
42
|
+
//# sourceMappingURL=digest-api.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digest-api.js","names":[],"sources":["esm/platform/crypto/digest-api.js"],"sourcesContent":["import { bytesToBase64, bytesToHex, utf8Encode } from \"./bytes\";\nimport { bufferSourceRange } from \"./digest\";\nconst DIGEST_ALGORITHMS = [\n \"MD5\",\n \"SHA-1\",\n \"SHA-256\",\n \"SHA-384\",\n \"SHA-512\"\n];\nfunction assertDigestAlgorithm(algorithm, verb) {\n if (!DIGEST_ALGORITHMS.includes(algorithm)) {\n throw new Error(\n `${verb}: unknown algorithm ${JSON.stringify(algorithm)}. Expected one of: ${DIGEST_ALGORITHMS.join(\", \")}`\n );\n }\n}\nfunction createDigestApi(source) {\n async function digest(algorithm, data) {\n assertDigestAlgorithm(algorithm, \"Crypto.digest\");\n const { buffer, offset, length } = bufferSourceRange(data, \"Crypto.digest\");\n return source(algorithm, buffer, offset, length);\n }\n async function digestString(algorithm, data, options = {}) {\n assertDigestAlgorithm(algorithm, \"Crypto.digestString\");\n if (typeof data !== \"string\") {\n throw new TypeError(\"Crypto.digestString: data must be a string\");\n }\n const encoding = options?.encoding ?? \"hex\";\n if (encoding !== \"hex\" && encoding !== \"base64\") {\n throw new Error(`Crypto.digestString: encoding must be 'hex' or 'base64'`);\n }\n const bytes = utf8Encode(data);\n const hashed = new Uint8Array(await source(algorithm, bytes.buffer, 0, bytes.length));\n return encoding === \"base64\" ? bytesToBase64(hashed) : bytesToHex(hashed);\n }\n return { digest, digestString };\n}\nexport {\n DIGEST_ALGORITHMS,\n assertDigestAlgorithm,\n createDigestApi\n};\n//# sourceMappingURL=digest-api.js.map\n"],"mappings":";;;;AAEA,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;CACA;AACF;AACA,SAAS,sBAAsB,WAAW,MAAM;CAC9C,IAAI,CAAC,kBAAkB,SAAS,SAAS,GAAG;EAC1C,MAAM,IAAI,MACR,GAAG,KAAK,sBAAsB,KAAK,UAAU,SAAS,EAAE,qBAAqB,kBAAkB,KAAK,IAAI,GAC1G;CACF;AACF;AACA,SAAS,gBAAgB,QAAQ;CAC/B,eAAe,OAAO,WAAW,MAAM;EACrC,sBAAsB,WAAW,eAAe;EAChD,MAAM,EAAE,QAAQ,QAAQ,WAAW,kBAAkB,MAAM,eAAe;EAC1E,OAAO,OAAO,WAAW,QAAQ,QAAQ,MAAM;CACjD;CACA,eAAe,aAAa,WAAW,MAAM,UAAU,CAAC,GAAG;EACzD,sBAAsB,WAAW,qBAAqB;EACtD,IAAI,OAAO,SAAS,UAAU;GAC5B,MAAM,IAAI,UAAU,4CAA4C;EAClE;EACA,MAAM,WAAW,SAAS,YAAY;EACtC,IAAI,aAAa,SAAS,aAAa,UAAU;GAC/C,MAAM,IAAI,MAAM,yDAAyD;EAC3E;EACA,MAAM,QAAQ,WAAW,IAAI;EAC7B,MAAM,SAAS,IAAI,WAAW,MAAM,OAAO,WAAW,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC;EACpF,OAAO,aAAa,WAAW,cAAc,MAAM,IAAI,WAAW,MAAM;CAC1E;CACA,OAAO;EAAE;EAAQ;CAAa;AAChC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { bytesToBase64, bytesToHex, utf8Encode } from "./bytes.native.js";
|
|
2
|
+
import { bufferSourceRange } from "./digest.native.js";
|
|
3
|
+
|
|
4
|
+
var DIGEST_ALGORITHMS = [
|
|
5
|
+
"MD5",
|
|
6
|
+
"SHA-1",
|
|
7
|
+
"SHA-256",
|
|
8
|
+
"SHA-384",
|
|
9
|
+
"SHA-512"
|
|
10
|
+
];
|
|
11
|
+
function assertDigestAlgorithm(algorithm, verb) {
|
|
12
|
+
if (!DIGEST_ALGORITHMS.includes(algorithm)) {
|
|
13
|
+
throw new Error(`${verb}: unknown algorithm ${JSON.stringify(algorithm)}. Expected one of: ${DIGEST_ALGORITHMS.join(", ")}`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function createDigestApi(source) {
|
|
17
|
+
async function digest(algorithm, data) {
|
|
18
|
+
assertDigestAlgorithm(algorithm, "Crypto.digest");
|
|
19
|
+
var { buffer, offset, length } = bufferSourceRange(data, "Crypto.digest");
|
|
20
|
+
return source(algorithm, buffer, offset, length);
|
|
21
|
+
}
|
|
22
|
+
async function digestString(algorithm, data) {
|
|
23
|
+
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
24
|
+
var _ref;
|
|
25
|
+
assertDigestAlgorithm(algorithm, "Crypto.digestString");
|
|
26
|
+
if (typeof data !== "string") {
|
|
27
|
+
throw new TypeError("Crypto.digestString: data must be a string");
|
|
28
|
+
}
|
|
29
|
+
var encoding = (_ref = options === null || options === void 0 ? void 0 : options.encoding) !== null && _ref !== void 0 ? _ref : "hex";
|
|
30
|
+
if (encoding !== "hex" && encoding !== "base64") {
|
|
31
|
+
throw new Error(`Crypto.digestString: encoding must be 'hex' or 'base64'`);
|
|
32
|
+
}
|
|
33
|
+
var bytes = utf8Encode(data);
|
|
34
|
+
var hashed = new Uint8Array(await source(algorithm, bytes.buffer, 0, bytes.length));
|
|
35
|
+
return encoding === "base64" ? bytesToBase64(hashed) : bytesToHex(hashed);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
digest,
|
|
39
|
+
digestString
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { DIGEST_ALGORITHMS, assertDigestAlgorithm, createDigestApi };
|
|
44
|
+
//# sourceMappingURL=digest-api.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digest-api.native.js","names":[],"sources":["esm/platform/crypto/digest-api.native.js"],"sourcesContent":["import { bytesToBase64, bytesToHex, utf8Encode } from \"./bytes\";\nimport { bufferSourceRange } from \"./digest\";\nvar DIGEST_ALGORITHMS = [\n \"MD5\",\n \"SHA-1\",\n \"SHA-256\",\n \"SHA-384\",\n \"SHA-512\"\n];\nfunction assertDigestAlgorithm(algorithm, verb) {\n if (!DIGEST_ALGORITHMS.includes(algorithm)) {\n throw new Error(`${verb}: unknown algorithm ${JSON.stringify(algorithm)}. Expected one of: ${DIGEST_ALGORITHMS.join(\", \")}`);\n }\n}\nfunction createDigestApi(source) {\n async function digest(algorithm, data) {\n assertDigestAlgorithm(algorithm, \"Crypto.digest\");\n var { buffer, offset, length } = bufferSourceRange(data, \"Crypto.digest\");\n return source(algorithm, buffer, offset, length);\n }\n async function digestString(algorithm, data) {\n var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};\n var _ref;\n assertDigestAlgorithm(algorithm, \"Crypto.digestString\");\n if (typeof data !== \"string\") {\n throw new TypeError(\"Crypto.digestString: data must be a string\");\n }\n var encoding = (_ref = options === null || options === void 0 ? void 0 : options.encoding) !== null && _ref !== void 0 ? _ref : \"hex\";\n if (encoding !== \"hex\" && encoding !== \"base64\") {\n throw new Error(`Crypto.digestString: encoding must be 'hex' or 'base64'`);\n }\n var bytes = utf8Encode(data);\n var hashed = new Uint8Array(await source(algorithm, bytes.buffer, 0, bytes.length));\n return encoding === \"base64\" ? bytesToBase64(hashed) : bytesToHex(hashed);\n }\n return {\n digest,\n digestString\n };\n}\nexport {\n DIGEST_ALGORITHMS,\n assertDigestAlgorithm,\n createDigestApi\n};\n//# sourceMappingURL=digest-api.js.map\n"],"mappings":";;;;AAEA,IAAI,oBAAoB;CACtB;CACA;CACA;CACA;CACA;AACF;AACA,SAAS,sBAAsB,WAAW,MAAM;CAC9C,IAAI,CAAC,kBAAkB,SAAS,SAAS,GAAG;EAC1C,MAAM,IAAI,MAAM,GAAG,KAAK,sBAAsB,KAAK,UAAU,SAAS,EAAE,qBAAqB,kBAAkB,KAAK,IAAI,GAAG;CAC7H;AACF;AACA,SAAS,gBAAgB,QAAQ;CAC/B,eAAe,OAAO,WAAW,MAAM;EACrC,sBAAsB,WAAW,eAAe;EAChD,IAAI,EAAE,QAAQ,QAAQ,WAAW,kBAAkB,MAAM,eAAe;EACxE,OAAO,OAAO,WAAW,QAAQ,QAAQ,MAAM;CACjD;CACA,eAAe,aAAa,WAAW,MAAM;EAC3C,IAAI,UAAU,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK,CAAC;EAChF,IAAI;EACJ,sBAAsB,WAAW,qBAAqB;EACtD,IAAI,OAAO,SAAS,UAAU;GAC5B,MAAM,IAAI,UAAU,4CAA4C;EAClE;EACA,IAAI,YAAY,OAAO,YAAY,QAAQ,YAAY,KAAK,IAAI,KAAK,IAAI,QAAQ,cAAc,QAAQ,SAAS,KAAK,IAAI,OAAO;EAChI,IAAI,aAAa,SAAS,aAAa,UAAU;GAC/C,MAAM,IAAI,MAAM,yDAAyD;EAC3E;EACA,IAAI,QAAQ,WAAW,IAAI;EAC3B,IAAI,SAAS,IAAI,WAAW,MAAM,OAAO,WAAW,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC;EAClF,OAAO,aAAa,WAAW,cAAc,MAAM,IAAI,WAAW,MAAM;CAC1E;CACA,OAAO;EACL;EACA;CACF;AACF"}
|
|
@@ -3,24 +3,32 @@ function namedError(name, message) {
|
|
|
3
3
|
error.name = name;
|
|
4
4
|
return error;
|
|
5
5
|
}
|
|
6
|
+
function bufferSourceRange(data, verb) {
|
|
7
|
+
let buffer;
|
|
8
|
+
let offset = 0;
|
|
9
|
+
let length;
|
|
10
|
+
if (data instanceof ArrayBuffer) {
|
|
11
|
+
buffer = data;
|
|
12
|
+
length = data.byteLength;
|
|
13
|
+
} else if (ArrayBuffer.isView(data) && data.buffer instanceof ArrayBuffer) {
|
|
14
|
+
buffer = data.buffer;
|
|
15
|
+
offset = data.byteOffset;
|
|
16
|
+
length = data.byteLength;
|
|
17
|
+
} else {
|
|
18
|
+
throw new TypeError(`${verb}: expected an ArrayBuffer or view.`);
|
|
19
|
+
}
|
|
20
|
+
new Uint8Array(buffer, offset, length);
|
|
21
|
+
return {
|
|
22
|
+
buffer,
|
|
23
|
+
offset,
|
|
24
|
+
length
|
|
25
|
+
};
|
|
26
|
+
}
|
|
6
27
|
function installDigestPolyfill(source, target = globalThis) {
|
|
7
28
|
const crypto = target.crypto;
|
|
8
29
|
if (crypto == null || typeof crypto.subtle?.digest === "function") return;
|
|
9
30
|
const digest = async (algorithm, data) => {
|
|
10
|
-
|
|
11
|
-
let offset = 0;
|
|
12
|
-
let length;
|
|
13
|
-
if (data instanceof ArrayBuffer) {
|
|
14
|
-
buffer = data;
|
|
15
|
-
length = data.byteLength;
|
|
16
|
-
} else if (ArrayBuffer.isView(data) && data.buffer instanceof ArrayBuffer) {
|
|
17
|
-
buffer = data.buffer;
|
|
18
|
-
offset = data.byteOffset;
|
|
19
|
-
length = data.byteLength;
|
|
20
|
-
} else {
|
|
21
|
-
throw new TypeError("crypto.subtle.digest: expected an ArrayBuffer or view.");
|
|
22
|
-
}
|
|
23
|
-
new Uint8Array(buffer, offset, length);
|
|
31
|
+
const { buffer, offset, length } = bufferSourceRange(data, "crypto.subtle.digest");
|
|
24
32
|
let name;
|
|
25
33
|
if (algorithm !== null && (typeof algorithm === "object" || typeof algorithm === "function")) {
|
|
26
34
|
const value = algorithm.name;
|
|
@@ -44,5 +52,5 @@ function installDigestPolyfill(source, target = globalThis) {
|
|
|
44
52
|
else crypto.subtle.digest = digest;
|
|
45
53
|
}
|
|
46
54
|
|
|
47
|
-
export { installDigestPolyfill };
|
|
55
|
+
export { bufferSourceRange, installDigestPolyfill };
|
|
48
56
|
//# sourceMappingURL=digest.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"digest.js","names":[],"sources":["esm/platform/crypto/digest.js"],"sourcesContent":["function namedError(name, message) {\n const error = new Error(message);\n error.name = name;\n return error;\n}\nfunction
|
|
1
|
+
{"version":3,"file":"digest.js","names":[],"sources":["esm/platform/crypto/digest.js"],"sourcesContent":["function namedError(name, message) {\n const error = new Error(message);\n error.name = name;\n return error;\n}\nfunction bufferSourceRange(data, verb) {\n let buffer;\n let offset = 0;\n let length;\n if (data instanceof ArrayBuffer) {\n buffer = data;\n length = data.byteLength;\n } else if (ArrayBuffer.isView(data) && data.buffer instanceof ArrayBuffer) {\n buffer = data.buffer;\n offset = data.byteOffset;\n length = data.byteLength;\n } else {\n throw new TypeError(`${verb}: expected an ArrayBuffer or view.`);\n }\n new Uint8Array(buffer, offset, length);\n return { buffer, offset, length };\n}\nfunction installDigestPolyfill(source, target = globalThis) {\n const crypto = target.crypto;\n if (crypto == null || typeof crypto.subtle?.digest === \"function\") return;\n const digest = async (algorithm, data) => {\n const { buffer, offset, length } = bufferSourceRange(data, \"crypto.subtle.digest\");\n let name;\n if (algorithm !== null && (typeof algorithm === \"object\" || typeof algorithm === \"function\")) {\n const value = algorithm.name;\n if (value === void 0) {\n throw new TypeError(\"crypto.subtle.digest: algorithm.name is required.\");\n }\n name = `${value}`;\n } else {\n name = `${algorithm}`;\n }\n if (!/^sha-(1|256|384|512)$/i.test(name)) {\n throw namedError(\"NotSupportedError\", `Unsupported digest algorithm: ${name}.`);\n }\n try {\n return await source(name.toUpperCase(), buffer, offset, length);\n } catch (error) {\n throw namedError(\n \"OperationError\",\n error instanceof Error ? error.message : \"Native digest failed.\"\n );\n }\n };\n if (crypto.subtle == null) crypto.subtle = { digest };\n else crypto.subtle.digest = digest;\n}\nexport {\n bufferSourceRange,\n installDigestPolyfill\n};\n//# sourceMappingURL=digest.js.map\n"],"mappings":";AAAA,SAAS,WAAW,MAAM,SAAS;CACjC,MAAM,QAAQ,IAAI,MAAM,OAAO;CAC/B,MAAM,OAAO;CACb,OAAO;AACT;AACA,SAAS,kBAAkB,MAAM,MAAM;CACrC,IAAI;CACJ,IAAI,SAAS;CACb,IAAI;CACJ,IAAI,gBAAgB,aAAa;EAC/B,SAAS;EACT,SAAS,KAAK;CAChB,OAAO,IAAI,YAAY,OAAO,IAAI,KAAK,KAAK,kBAAkB,aAAa;EACzE,SAAS,KAAK;EACd,SAAS,KAAK;EACd,SAAS,KAAK;CAChB,OAAO;EACL,MAAM,IAAI,UAAU,GAAG,KAAK,mCAAmC;CACjE;CACA,IAAI,WAAW,QAAQ,QAAQ,MAAM;CACrC,OAAO;EAAE;EAAQ;EAAQ;CAAO;AAClC;AACA,SAAS,sBAAsB,QAAQ,SAAS,YAAY;CAC1D,MAAM,SAAS,OAAO;CACtB,IAAI,UAAU,QAAQ,OAAO,OAAO,QAAQ,WAAW,YAAY;CACnE,MAAM,SAAS,OAAO,WAAW,SAAS;EACxC,MAAM,EAAE,QAAQ,QAAQ,WAAW,kBAAkB,MAAM,sBAAsB;EACjF,IAAI;EACJ,IAAI,cAAc,SAAS,OAAO,cAAc,YAAY,OAAO,cAAc,aAAa;GAC5F,MAAM,QAAQ,UAAU;GACxB,IAAI,UAAU,KAAK,GAAG;IACpB,MAAM,IAAI,UAAU,mDAAmD;GACzE;GACA,OAAO,GAAG;EACZ,OAAO;GACL,OAAO,GAAG;EACZ;EACA,IAAI,CAAC,yBAAyB,KAAK,IAAI,GAAG;GACxC,MAAM,WAAW,qBAAqB,iCAAiC,KAAK,EAAE;EAChF;EACA,IAAI;GACF,OAAO,MAAM,OAAO,KAAK,YAAY,GAAG,QAAQ,QAAQ,MAAM;EAChE,SAAS,OAAO;GACd,MAAM,WACJ,kBACA,iBAAiB,QAAQ,MAAM,UAAU,uBAC3C;EACF;CACF;CACA,IAAI,OAAO,UAAU,MAAM,OAAO,SAAS,EAAE,OAAO;MAC/C,OAAO,OAAO,SAAS;AAC9B"}
|
|
@@ -3,26 +3,34 @@ function namedError(name, message) {
|
|
|
3
3
|
error.name = name;
|
|
4
4
|
return error;
|
|
5
5
|
}
|
|
6
|
+
function bufferSourceRange(data, verb) {
|
|
7
|
+
var buffer;
|
|
8
|
+
var offset = 0;
|
|
9
|
+
var length;
|
|
10
|
+
if (data instanceof ArrayBuffer) {
|
|
11
|
+
buffer = data;
|
|
12
|
+
length = data.byteLength;
|
|
13
|
+
} else if (ArrayBuffer.isView(data) && data.buffer instanceof ArrayBuffer) {
|
|
14
|
+
buffer = data.buffer;
|
|
15
|
+
offset = data.byteOffset;
|
|
16
|
+
length = data.byteLength;
|
|
17
|
+
} else {
|
|
18
|
+
throw new TypeError(`${verb}: expected an ArrayBuffer or view.`);
|
|
19
|
+
}
|
|
20
|
+
new Uint8Array(buffer, offset, length);
|
|
21
|
+
return {
|
|
22
|
+
buffer,
|
|
23
|
+
offset,
|
|
24
|
+
length
|
|
25
|
+
};
|
|
26
|
+
}
|
|
6
27
|
function installDigestPolyfill(source) {
|
|
7
28
|
var target = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : globalThis;
|
|
8
29
|
var _crypto_subtle;
|
|
9
30
|
var crypto = target.crypto;
|
|
10
31
|
if (crypto == null || typeof ((_crypto_subtle = crypto.subtle) === null || _crypto_subtle === void 0 ? void 0 : _crypto_subtle.digest) === "function") return;
|
|
11
32
|
var digest = async function digest2(algorithm, data) {
|
|
12
|
-
var buffer;
|
|
13
|
-
var offset = 0;
|
|
14
|
-
var length;
|
|
15
|
-
if (data instanceof ArrayBuffer) {
|
|
16
|
-
buffer = data;
|
|
17
|
-
length = data.byteLength;
|
|
18
|
-
} else if (ArrayBuffer.isView(data) && data.buffer instanceof ArrayBuffer) {
|
|
19
|
-
buffer = data.buffer;
|
|
20
|
-
offset = data.byteOffset;
|
|
21
|
-
length = data.byteLength;
|
|
22
|
-
} else {
|
|
23
|
-
throw new TypeError("crypto.subtle.digest: expected an ArrayBuffer or view.");
|
|
24
|
-
}
|
|
25
|
-
new Uint8Array(buffer, offset, length);
|
|
33
|
+
var { buffer, offset, length } = bufferSourceRange(data, "crypto.subtle.digest");
|
|
26
34
|
var name;
|
|
27
35
|
if (algorithm !== null && (typeof algorithm === "object" || typeof algorithm === "function")) {
|
|
28
36
|
var value = algorithm.name;
|
|
@@ -46,5 +54,5 @@ function installDigestPolyfill(source) {
|
|
|
46
54
|
else crypto.subtle.digest = digest;
|
|
47
55
|
}
|
|
48
56
|
|
|
49
|
-
export { installDigestPolyfill };
|
|
57
|
+
export { bufferSourceRange, installDigestPolyfill };
|
|
50
58
|
//# sourceMappingURL=digest.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"digest.native.js","names":[],"sources":["esm/platform/crypto/digest.native.js"],"sourcesContent":["function namedError(name, message) {\n var error = new Error(message);\n error.name = name;\n return error;\n}\nfunction installDigestPolyfill(source) {\n var target = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : globalThis;\n var _crypto_subtle;\n var crypto = target.crypto;\n if (crypto == null || typeof ((_crypto_subtle = crypto.subtle) === null || _crypto_subtle === void 0 ? void 0 : _crypto_subtle.digest) === \"function\") return;\n var digest = async function digest2(algorithm, data) {\n var buffer
|
|
1
|
+
{"version":3,"file":"digest.native.js","names":[],"sources":["esm/platform/crypto/digest.native.js"],"sourcesContent":["function namedError(name, message) {\n var error = new Error(message);\n error.name = name;\n return error;\n}\nfunction bufferSourceRange(data, verb) {\n var buffer;\n var offset = 0;\n var length;\n if (data instanceof ArrayBuffer) {\n buffer = data;\n length = data.byteLength;\n } else if (ArrayBuffer.isView(data) && data.buffer instanceof ArrayBuffer) {\n buffer = data.buffer;\n offset = data.byteOffset;\n length = data.byteLength;\n } else {\n throw new TypeError(`${verb}: expected an ArrayBuffer or view.`);\n }\n new Uint8Array(buffer, offset, length);\n return {\n buffer,\n offset,\n length\n };\n}\nfunction installDigestPolyfill(source) {\n var target = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : globalThis;\n var _crypto_subtle;\n var crypto = target.crypto;\n if (crypto == null || typeof ((_crypto_subtle = crypto.subtle) === null || _crypto_subtle === void 0 ? void 0 : _crypto_subtle.digest) === \"function\") return;\n var digest = async function digest2(algorithm, data) {\n var { buffer, offset, length } = bufferSourceRange(data, \"crypto.subtle.digest\");\n var name;\n if (algorithm !== null && (typeof algorithm === \"object\" || typeof algorithm === \"function\")) {\n var value = algorithm.name;\n if (value === void 0) {\n throw new TypeError(\"crypto.subtle.digest: algorithm.name is required.\");\n }\n name = `${value}`;\n } else {\n name = `${algorithm}`;\n }\n if (!/^sha-(1|256|384|512)$/i.test(name)) {\n throw namedError(\"NotSupportedError\", `Unsupported digest algorithm: ${name}.`);\n }\n try {\n return await source(name.toUpperCase(), buffer, offset, length);\n } catch (error) {\n throw namedError(\"OperationError\", error instanceof Error ? error.message : \"Native digest failed.\");\n }\n };\n if (crypto.subtle == null) crypto.subtle = {\n digest\n };\n else crypto.subtle.digest = digest;\n}\nexport {\n bufferSourceRange,\n installDigestPolyfill\n};\n//# sourceMappingURL=digest.js.map\n"],"mappings":";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OAAO;GACd,MAAM,WAAW,kBAAkB,iBAAiB,QAAQ,MAAM,UAAU,uBAAuB;EACrG;CACF;CACA,IAAI,OAAO,UAAU,MAAM,OAAO,SAAS,EACzC,OACF;MACK,OAAO,OAAO,SAAS;AAC9B"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { createAesApi } from "./aes.mjs";
|
|
2
|
+
import { createDigestApi } from "./digest-api.mjs";
|
|
1
3
|
import { formatUuidV4, installCryptoPolyfill } from "./random.mjs";
|
|
4
|
+
import { webAesEngine, webDigestSource } from "./web.mjs";
|
|
2
5
|
|
|
3
6
|
function fill(bytes) {
|
|
4
7
|
const getRandomValues = globalThis.crypto?.getRandomValues;
|
|
@@ -18,6 +21,16 @@ const source = {
|
|
|
18
21
|
function installCrypto() {
|
|
19
22
|
installCryptoPolyfill(source);
|
|
20
23
|
}
|
|
24
|
+
const aes = createAesApi(webAesEngine);
|
|
25
|
+
const digestApi = createDigestApi(webDigestSource);
|
|
26
|
+
const AESEncryptionKey = aes.AESEncryptionKey;
|
|
27
|
+
const AESSealedData = aes.AESSealedData;
|
|
28
|
+
const Crypto = Object.freeze({
|
|
29
|
+
digest: digestApi.digest,
|
|
30
|
+
digestString: digestApi.digestString,
|
|
31
|
+
aesEncrypt: aes.aesEncrypt,
|
|
32
|
+
aesDecrypt: aes.aesDecrypt
|
|
33
|
+
});
|
|
21
34
|
|
|
22
|
-
export { installCrypto };
|
|
35
|
+
export { AESEncryptionKey, AESSealedData, Crypto, installCrypto };
|
|
23
36
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["esm/platform/crypto/index.js"],"sourcesContent":["import { formatUuidV4, installCryptoPolyfill } from \"./random\";\nfunction fill(bytes) {\n const getRandomValues = globalThis.crypto?.getRandomValues;\n if (typeof getRandomValues !== \"function\") {\n throw new Error(\"secure random: web crypto is unavailable in this browser.\");\n }\n getRandomValues.call(globalThis.crypto, bytes);\n}\nconst source = {\n fill,\n randomUUID() {\n const bytes = new Uint8Array(16);\n fill(bytes);\n return formatUuidV4(bytes);\n }\n};\nfunction installCrypto() {\n installCryptoPolyfill(source);\n}\nexport {\n installCrypto\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["esm/platform/crypto/index.js"],"sourcesContent":["import { createAesApi } from \"./aes\";\nimport { createDigestApi } from \"./digest-api\";\nimport { formatUuidV4, installCryptoPolyfill } from \"./random\";\nimport { webAesEngine, webDigestSource } from \"./web\";\nfunction fill(bytes) {\n const getRandomValues = globalThis.crypto?.getRandomValues;\n if (typeof getRandomValues !== \"function\") {\n throw new Error(\"secure random: web crypto is unavailable in this browser.\");\n }\n getRandomValues.call(globalThis.crypto, bytes);\n}\nconst source = {\n fill,\n randomUUID() {\n const bytes = new Uint8Array(16);\n fill(bytes);\n return formatUuidV4(bytes);\n }\n};\nfunction installCrypto() {\n installCryptoPolyfill(source);\n}\nconst aes = createAesApi(webAesEngine);\nconst digestApi = createDigestApi(webDigestSource);\nconst AESEncryptionKey = aes.AESEncryptionKey;\nconst AESSealedData = aes.AESSealedData;\nconst Crypto = Object.freeze({\n digest: digestApi.digest,\n digestString: digestApi.digestString,\n aesEncrypt: aes.aesEncrypt,\n aesDecrypt: aes.aesDecrypt\n});\nexport {\n AESEncryptionKey,\n AESSealedData,\n Crypto,\n installCrypto\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;;;AAIA,SAAS,KAAK,OAAO;CACnB,MAAM,kBAAkB,WAAW,QAAQ;CAC3C,IAAI,OAAO,oBAAoB,YAAY;EACzC,MAAM,IAAI,MAAM,2DAA2D;CAC7E;CACA,gBAAgB,KAAK,WAAW,QAAQ,KAAK;AAC/C;AACA,MAAM,SAAS;CACb;CACA,aAAa;EACX,MAAM,QAAQ,IAAI,WAAW,EAAE;EAC/B,KAAK,KAAK;EACV,OAAO,aAAa,KAAK;CAC3B;AACF;AACA,SAAS,gBAAgB;CACvB,sBAAsB,MAAM;AAC9B;AACA,MAAM,MAAM,aAAa,YAAY;AACrC,MAAM,YAAY,gBAAgB,eAAe;AACjD,MAAM,mBAAmB,IAAI;AAC7B,MAAM,gBAAgB,IAAI;AAC1B,MAAM,SAAS,OAAO,OAAO;CAC3B,QAAQ,UAAU;CAClB,cAAc,UAAU;CACxB,YAAY,IAAI;CAChB,YAAY,IAAI;AAClB,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { createAesApi } from "./aes.native.js";
|
|
1
2
|
import { installDigestPolyfill } from "./digest.native.js";
|
|
3
|
+
import { createDigestApi } from "./digest-api.native.js";
|
|
2
4
|
import { NitroModules } from "react-native-nitro-modules";
|
|
3
5
|
import { installCryptoPolyfill } from "./random.native.js";
|
|
4
6
|
|
|
@@ -14,6 +16,37 @@ var nativeSource = {
|
|
|
14
16
|
return native().randomUUID();
|
|
15
17
|
}
|
|
16
18
|
};
|
|
19
|
+
function required() {
|
|
20
|
+
if (!NitroModules.hasHybridObject("OneCrypto")) {
|
|
21
|
+
throw new Error("Crypto needs a native build that includes one");
|
|
22
|
+
}
|
|
23
|
+
return native();
|
|
24
|
+
}
|
|
25
|
+
var aesEngine = {
|
|
26
|
+
async seal(key, iv, plaintext, additionalData, tagLength) {
|
|
27
|
+
var sealed = await required().aesEncrypt(key.buffer, iv.buffer, plaintext.buffer, additionalData === null || additionalData === void 0 ? void 0 : additionalData.buffer, tagLength);
|
|
28
|
+
return new Uint8Array(sealed);
|
|
29
|
+
},
|
|
30
|
+
async open(key, iv, ciphertextWithTag, additionalData, tagLength) {
|
|
31
|
+
var opened = await required().aesDecrypt(key.buffer, iv.buffer, ciphertextWithTag.buffer, additionalData === null || additionalData === void 0 ? void 0 : additionalData.buffer, tagLength);
|
|
32
|
+
return new Uint8Array(opened);
|
|
33
|
+
},
|
|
34
|
+
random(bytes) {
|
|
35
|
+
required().fillRandomBytes(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var aes = createAesApi(aesEngine);
|
|
39
|
+
var digestApi = createDigestApi(function(algorithm, buffer, offset, length) {
|
|
40
|
+
return required().digest(algorithm, buffer, offset, length);
|
|
41
|
+
});
|
|
42
|
+
var AESEncryptionKey = aes.AESEncryptionKey;
|
|
43
|
+
var AESSealedData = aes.AESSealedData;
|
|
44
|
+
var Crypto = Object.freeze({
|
|
45
|
+
digest: digestApi.digest,
|
|
46
|
+
digestString: digestApi.digestString,
|
|
47
|
+
aesEncrypt: aes.aesEncrypt,
|
|
48
|
+
aesDecrypt: aes.aesDecrypt
|
|
49
|
+
});
|
|
17
50
|
function installCrypto() {
|
|
18
51
|
if (!NitroModules.hasHybridObject("OneCrypto")) {
|
|
19
52
|
return;
|
|
@@ -24,5 +57,5 @@ function installCrypto() {
|
|
|
24
57
|
});
|
|
25
58
|
}
|
|
26
59
|
|
|
27
|
-
export { installCrypto };
|
|
60
|
+
export { AESEncryptionKey, AESSealedData, Crypto, installCrypto };
|
|
28
61
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.native.js","names":[],"sources":["esm/platform/crypto/index.native.js"],"sourcesContent":["import { installDigestPolyfill } from \"./digest\";\nimport { NitroModules } from \"react-native-nitro-modules\";\nimport { installCryptoPolyfill } from \"./random\";\nvar hybrid;\nfunction native() {\n return hybrid !== null && hybrid !== void 0 ? hybrid : hybrid = NitroModules.createHybridObject(\"OneCrypto\");\n}\nvar nativeSource = {\n fill(bytes) {\n native().fillRandomBytes(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n },\n randomUUID: function randomUUID() {\n return native().randomUUID();\n }\n};\nfunction installCrypto() {\n if (!NitroModules.hasHybridObject(\"OneCrypto\")) {\n return;\n }\n installCryptoPolyfill(nativeSource);\n installDigestPolyfill(function(algorithm, buffer, offset, length) {\n return native().digest(algorithm, buffer, offset, length);\n });\n}\nexport {\n installCrypto\n};\n//# sourceMappingURL=index.native.js.map\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.native.js","names":[],"sources":["esm/platform/crypto/index.native.js"],"sourcesContent":["import { createAesApi } from \"./aes\";\nimport { installDigestPolyfill } from \"./digest\";\nimport { createDigestApi } from \"./digest-api\";\nimport { NitroModules } from \"react-native-nitro-modules\";\nimport { installCryptoPolyfill } from \"./random\";\nvar hybrid;\nfunction native() {\n return hybrid !== null && hybrid !== void 0 ? hybrid : hybrid = NitroModules.createHybridObject(\"OneCrypto\");\n}\nvar nativeSource = {\n fill(bytes) {\n native().fillRandomBytes(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n },\n randomUUID: function randomUUID() {\n return native().randomUUID();\n }\n};\nfunction required() {\n if (!NitroModules.hasHybridObject(\"OneCrypto\")) {\n throw new Error(\"Crypto needs a native build that includes one\");\n }\n return native();\n}\nvar aesEngine = {\n async seal(key, iv, plaintext, additionalData, tagLength) {\n var sealed = await required().aesEncrypt(key.buffer, iv.buffer, plaintext.buffer, additionalData === null || additionalData === void 0 ? void 0 : additionalData.buffer, tagLength);\n return new Uint8Array(sealed);\n },\n async open(key, iv, ciphertextWithTag, additionalData, tagLength) {\n var opened = await required().aesDecrypt(key.buffer, iv.buffer, ciphertextWithTag.buffer, additionalData === null || additionalData === void 0 ? void 0 : additionalData.buffer, tagLength);\n return new Uint8Array(opened);\n },\n random(bytes) {\n required().fillRandomBytes(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n }\n};\nvar aes = createAesApi(aesEngine);\nvar digestApi = createDigestApi(function(algorithm, buffer, offset, length) {\n return required().digest(algorithm, buffer, offset, length);\n});\nvar AESEncryptionKey = aes.AESEncryptionKey;\nvar AESSealedData = aes.AESSealedData;\nvar Crypto = Object.freeze({\n digest: digestApi.digest,\n digestString: digestApi.digestString,\n aesEncrypt: aes.aesEncrypt,\n aesDecrypt: aes.aesDecrypt\n});\nfunction installCrypto() {\n if (!NitroModules.hasHybridObject(\"OneCrypto\")) {\n return;\n }\n installCryptoPolyfill(nativeSource);\n installDigestPolyfill(function(algorithm, buffer, offset, length) {\n return native().digest(algorithm, buffer, offset, length);\n });\n}\nexport {\n AESEncryptionKey,\n AESSealedData,\n Crypto,\n installCrypto\n};\n//# sourceMappingURL=index.native.js.map\n"],"mappings":";;;;;;;AAKA,IAAI;AACJ,SAAS,SAAS;CAChB,OAAO,WAAW,QAAQ,WAAW,KAAK,IAAI,SAAS,SAAS,aAAa,mBAAmB,WAAW;AAC7G;AACA,IAAI,eAAe;CACjB,KAAK,OAAO;EACV,OAAO,CAAC,CAAC,gBAAgB,MAAM,QAAQ,MAAM,YAAY,MAAM,UAAU;CAC3E;CACA,YAAY,SAAS,aAAa;EAChC,OAAO,OAAO,CAAC,CAAC,WAAW;CAC7B;AACF;AACA,SAAS,WAAW;CAClB,IAAI,CAAC,aAAa,gBAAgB,WAAW,GAAG;EAC9C,MAAM,IAAI,MAAM,+CAA+C;CACjE;CACA,OAAO,OAAO;AAChB;AACA,IAAI,YAAY;CACd,MAAM,KAAK,KAAK,IAAI,WAAW,gBAAgB,WAAW;EACxD,IAAI,SAAS,MAAM,SAAS,CAAC,CAAC,WAAW,IAAI,QAAQ,GAAG,QAAQ,UAAU,QAAQ,mBAAmB,QAAQ,mBAAmB,KAAK,IAAI,KAAK,IAAI,eAAe,QAAQ,SAAS;EAClL,OAAO,IAAI,WAAW,MAAM;CAC9B;CACA,MAAM,KAAK,KAAK,IAAI,mBAAmB,gBAAgB,WAAW;EAChE,IAAI,SAAS,MAAM,SAAS,CAAC,CAAC,WAAW,IAAI,QAAQ,GAAG,QAAQ,kBAAkB,QAAQ,mBAAmB,QAAQ,mBAAmB,KAAK,IAAI,KAAK,IAAI,eAAe,QAAQ,SAAS;EAC1L,OAAO,IAAI,WAAW,MAAM;CAC9B;CACA,OAAO,OAAO;EACZ,SAAS,CAAC,CAAC,gBAAgB,MAAM,QAAQ,MAAM,YAAY,MAAM,UAAU;CAC7E;AACF;AACA,I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