lib0 0.2.61 → 0.2.62

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/README.md CHANGED
@@ -245,6 +245,30 @@ Using getAsync & setIfUndefined ensures that the init function is only calle
245
245
  <b><code>conditions.undefinedToNull</code></b><br>
246
246
  </dl>
247
247
  </details>
248
+ <details><summary><b>[lib0/crypto]</b> </summary>
249
+ <pre>import * as crypto from 'lib0/crypto'</pre>
250
+ <dl>
251
+ <b><code>y(data: string | Uint8Array): Uint8Array</code></b><br>
252
+ <b><code>ymmetricKey(secret: string | Uint8Array, salt: string | Uint8Array, opts: Object, opts.extractable: boolean, opts.usages: Array&lt;'sign'|'verify'|'encrypt'|'decrypt'&gt;): PromiseLike&lt;CryptoKey&gt;</code></b><br>
253
+ <b><code>ymmetricKey()</code></b><br>
254
+ <b><code>eAsymmetricKey(opts: Object, opts.extractable: boolean, opts.usages: Array&lt;'sign'|'verify'|'encrypt'|'decrypt'&gt;)</code></b><br>
255
+ <b><code>eAsymmetricKey()</code></b><br>
256
+ <b><code>ey(key: CryptoKey)</code></b><br>
257
+ <b><code>ey()</code></b><br>
258
+ <b><code>ymmetricKey(jwk: any, opts: Object, opts.extractable: boolean, opts.usages: Array&lt;'sign'|'verify'|'encrypt'|'decrypt'&gt;)</code></b><br>
259
+ <b><code>ymmetricKey()</code></b><br>
260
+ <b><code>symmetricKey(jwk: any, opts: Object, opts.extractable: boolean, opts.usages: Array&lt;'sign'|'verify'|'encrypt'|'decrypt'&gt;)</code></b><br>
261
+ <b><code>symmetricKey()</code></b><br>
262
+ <b><code>(data: Uint8Array, key: CryptoKey): PromiseLike&lt;Uint8Array&gt;</code></b><br>
263
+ <b><code>()</code></b><br>
264
+ <b><code>(data: Uint8Array, key: CryptoKey): PromiseLike&lt;Uint8Array&gt;</code></b><br>
265
+ <b><code>()</code></b><br>
266
+ <b><code>(data: Uint8Array, privateKey: CryptoKey): PromiseLike&lt;Uint8Array&gt;</code></b><br>
267
+ <b><code>()</code></b><br>
268
+ <b><code>(signature: Uint8Array, data: Uint8Array, publicKey: CryptoKey): PromiseLike&lt;boolean&gt;</code></b><br>
269
+ <b><code>()</code></b><br>
270
+ </dl>
271
+ </details>
248
272
  <details><summary><b>[lib0/decoding]</b> Efficient schema-less binary decoding with support for variable length encoding.</summary>
249
273
  <pre>import * as decoding from 'lib0/decoding'</pre>
250
274
 
@@ -1329,6 +1353,25 @@ export const testMyFirstTest = tc => {
1329
1353
  <b><code>url.encodeQueryParams(params: Object&lt;string,string&gt;): string</code></b><br>
1330
1354
  </dl>
1331
1355
  </details>
1356
+ <details><summary><b>[lib0/webcrypto.browser]</b> </summary>
1357
+ <pre>import * as webcrypto.browser from 'lib0/webcrypto.browser'</pre>
1358
+ <dl>
1359
+ <b><code></code></b><br>
1360
+ <b><code>()</code></b><br>
1361
+ <b><code>omValues</code></b><br>
1362
+ <b><code>omValues()</code></b><br>
1363
+ </dl>
1364
+ </details>
1365
+ <details><summary><b>[lib0/webcrypto.node]</b> </summary>
1366
+ <pre>import * as webcrypto.node from 'lib0/webcrypto.node'</pre>
1367
+ <dl>
1368
+ <b><code></code></b><br>
1369
+ <b><code>()</code></b><br>
1370
+ <b><code>to.subtle: any</code></b><br>
1371
+ <b><code>omValues</code></b><br>
1372
+ <b><code>omValues()</code></b><br>
1373
+ </dl>
1374
+ </details>
1332
1375
  <details><summary><b>[lib0/websocket]</b> Tiny websocket connection handler.</summary>
1333
1376
  <pre>import * as websocket from 'lib0/websocket'</pre>
1334
1377
 
package/crypto.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ export function deriveSymmetricKey(secret: string | Uint8Array, salt: string | Uint8Array, { extractable, usages }?: {
2
+ extractable?: boolean | undefined;
3
+ usages?: ("decrypt" | "encrypt" | "sign" | "verify")[] | undefined;
4
+ }): PromiseLike<CryptoKey>;
5
+ export function generateAsymmetricKey({ extractable, usages }?: {
6
+ extractable?: boolean | undefined;
7
+ usages?: ("decrypt" | "encrypt" | "sign" | "verify")[] | undefined;
8
+ }): Promise<CryptoKeyPair>;
9
+ export function exportKey(key: CryptoKey): Promise<JsonWebKey>;
10
+ export function importSymmetricKey(jwk: any, { extractable, usages }?: {
11
+ extractable?: boolean | undefined;
12
+ usages?: ("decrypt" | "encrypt" | "sign" | "verify")[] | undefined;
13
+ }): Promise<CryptoKey>;
14
+ export function importAsymmetricKey(jwk: any, { extractable, usages }?: {
15
+ extractable?: boolean | undefined;
16
+ usages?: ("decrypt" | "encrypt" | "sign" | "verify")[] | undefined;
17
+ }): Promise<CryptoKey>;
18
+ export function encrypt(data: Uint8Array, key: CryptoKey): PromiseLike<Uint8Array>;
19
+ export function decrypt(data: Uint8Array, key: CryptoKey): PromiseLike<Uint8Array>;
20
+ export function sign(data: Uint8Array, privateKey: CryptoKey): PromiseLike<Uint8Array>;
21
+ export function verify(signature: Uint8Array, data: Uint8Array, publicKey: CryptoKey): PromiseLike<boolean>;
22
+ //# sourceMappingURL=crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["crypto.js"],"names":[],"mappings":"AA0BO,2CAPI,MAAM,GAAG,UAAU,QACnB,MAAM,GAAG,UAAU;IAEJ,WAAW;IACwB,MAAM;IACvD,YAAY,SAAS,CAAC,CA4BjC;AAQM;IAHmB,WAAW;IACwB,MAAM;2BAUhE;AAMI,+BAFI,SAAS,uBAEkD;AAS/D,wCALI,GAAG;IAEY,WAAW;IACwB,MAAM;uBAGI;AAShE,yCALI,GAAG;IAEY,WAAW;IACwB,MAAM;uBAGkC;AAW9F,8BAJI,UAAU,OACV,SAAS,GACR,YAAY,UAAU,CAAC,CAkBlC;AAWM,8BAJI,UAAU,OACV,SAAS,GACR,YAAY,UAAU,CAAC,CAclC;AAWM,2BAJI,UAAU,cACV,SAAS,GACR,YAAY,UAAU,CAAC,CAUa;AAYzC,kCALI,UAAU,QACV,UAAU,aACV,SAAS,GACR,YAAY,OAAO,CAAC,CAW7B"}
package/crypto.js ADDED
@@ -0,0 +1,185 @@
1
+ /* eslint-env browser */
2
+
3
+ import * as encoding from './encoding.js'
4
+ import * as decoding from './decoding.js'
5
+ import * as string from './string.js'
6
+ import * as webcrypto from 'lib0/webcrypto'
7
+
8
+ /* istanbul ignore next */
9
+ /**
10
+ * @param {string | Uint8Array} data
11
+ * @return {Uint8Array}
12
+ */
13
+ const toBinary = data => typeof data === 'string' ? string.encodeUtf8(data) : data
14
+
15
+ /**
16
+ * @experimental The API is not final!
17
+ *
18
+ * Derive an symmetric key using the Password-Based-Key-Derivation-Function-2.
19
+ *
20
+ * @param {string | Uint8Array} secret
21
+ * @param {string | Uint8Array} salt
22
+ * @param {Object} opts
23
+ * @param {boolean} [opts.extractable]
24
+ * @param {Array<'sign'|'verify'|'encrypt'|'decrypt'>} [opts.usages]
25
+ * @return {PromiseLike<CryptoKey>}
26
+ */
27
+ export const deriveSymmetricKey = (secret, salt, { extractable = false, usages = ['encrypt', 'decrypt'] } = {}) => {
28
+ const binSecret = toBinary(secret)
29
+ const binSalt = toBinary(salt)
30
+ return webcrypto.subtle.importKey(
31
+ 'raw',
32
+ binSecret,
33
+ 'PBKDF2',
34
+ false,
35
+ ['deriveKey']
36
+ ).then(keyMaterial =>
37
+ webcrypto.subtle.deriveKey(
38
+ {
39
+ name: 'PBKDF2',
40
+ salt: binSalt, // NIST recommends at least 64 bits
41
+ iterations: 600000, // OWASP recommends 600k iterations
42
+ hash: 'SHA-256'
43
+ },
44
+ keyMaterial,
45
+ {
46
+ name: 'AES-GCM',
47
+ length: 256
48
+ },
49
+ extractable,
50
+ usages
51
+ )
52
+ )
53
+ }
54
+
55
+ /* istanbul ignore next */
56
+ /**
57
+ * @param {Object} opts
58
+ * @param {boolean} [opts.extractable]
59
+ * @param {Array<'sign'|'verify'|'encrypt'|'decrypt'>} [opts.usages]
60
+ */
61
+ export const generateAsymmetricKey = ({ extractable = false, usages = ['sign', 'verify'] } = {}) =>
62
+ webcrypto.subtle.generateKey(
63
+ {
64
+ name: 'ECDSA',
65
+ namedCurve: 'P-384'
66
+ },
67
+ extractable,
68
+ usages
69
+ )
70
+
71
+ /* istanbul ignore next */
72
+ /**
73
+ * @param {CryptoKey} key - Symmetric or Asymmetric key
74
+ */
75
+ export const exportKey = key => webcrypto.subtle.exportKey('jwk', key)
76
+
77
+ /* istanbul ignore next */
78
+ /**
79
+ * @param {any} jwk
80
+ * @param {Object} opts
81
+ * @param {boolean} [opts.extractable]
82
+ * @param {Array<'sign'|'verify'|'encrypt'|'decrypt'>} [opts.usages]
83
+ */
84
+ export const importSymmetricKey = (jwk, { extractable = false, usages = ['encrypt', 'decrypt'] } = {}) =>
85
+ webcrypto.subtle.importKey('jwk', jwk, 'PBKDF2', extractable, usages)
86
+
87
+ /* istanbul ignore next */
88
+ /**
89
+ * @param {any} jwk
90
+ * @param {Object} opts
91
+ * @param {boolean} [opts.extractable]
92
+ * @param {Array<'sign'|'verify'|'encrypt'|'decrypt'>} [opts.usages]
93
+ */
94
+ export const importAsymmetricKey = (jwk, { extractable = false, usages = ['encrypt', 'decrypt'] } = {}) =>
95
+ webcrypto.subtle.importKey('jwk', jwk, { name: 'ECDSA', namedCurve: 'P-384' }, extractable, usages)
96
+
97
+ /**
98
+ * @experimental The API is not final!
99
+ *
100
+ * Encrypt some data using AES-GCM method.
101
+ *
102
+ * @param {Uint8Array} data data to be encrypted
103
+ * @param {CryptoKey} key
104
+ * @return {PromiseLike<Uint8Array>} encrypted, base64 encoded message
105
+ */
106
+ export const encrypt = (data, key) => {
107
+ const iv = webcrypto.getRandomValues(new Uint8Array(16)) // 92bit is enough. 128bit is recommended if space is not an issue.
108
+ return webcrypto.subtle.encrypt(
109
+ {
110
+ name: 'AES-GCM',
111
+ iv
112
+ },
113
+ key,
114
+ data
115
+ ).then(cipher => {
116
+ const encryptedDataEncoder = encoding.createEncoder()
117
+ // iv may be sent in the clear to the other peers
118
+ encoding.writeUint8Array(encryptedDataEncoder, iv)
119
+ encoding.writeVarUint8Array(encryptedDataEncoder, new Uint8Array(cipher))
120
+ return encoding.toUint8Array(encryptedDataEncoder)
121
+ })
122
+ }
123
+
124
+ /**
125
+ * @experimental The API is not final!
126
+ *
127
+ * Decrypt some data using AES-GCM method.
128
+ *
129
+ * @param {Uint8Array} data
130
+ * @param {CryptoKey} key
131
+ * @return {PromiseLike<Uint8Array>} decrypted buffer
132
+ */
133
+ export const decrypt = (data, key) => {
134
+ const dataDecoder = decoding.createDecoder(data)
135
+ const iv = decoding.readUint8Array(dataDecoder, 16)
136
+ const cipher = decoding.readVarUint8Array(dataDecoder)
137
+ return webcrypto.subtle.decrypt(
138
+ {
139
+ name: 'AES-GCM',
140
+ iv
141
+ },
142
+ key,
143
+ cipher
144
+ ).then(data => new Uint8Array(data))
145
+ }
146
+
147
+ /**
148
+ * @experimental The API is not final!
149
+ *
150
+ * Sign a message
151
+ *
152
+ * @param {Uint8Array} data
153
+ * @param {CryptoKey} privateKey
154
+ * @return {PromiseLike<Uint8Array>} signature
155
+ */
156
+ export const sign = (data, privateKey) =>
157
+ webcrypto.subtle.sign(
158
+ {
159
+ name: 'ECDSA',
160
+ hash: { name: 'SHA-384' }
161
+ },
162
+ privateKey,
163
+ data
164
+ ).then(signature => new Uint8Array(signature))
165
+
166
+ /**
167
+ * @experimental The API is not final!
168
+ *
169
+ * Sign a message
170
+ *
171
+ * @param {Uint8Array} signature
172
+ * @param {Uint8Array} data
173
+ * @param {CryptoKey} publicKey
174
+ * @return {PromiseLike<boolean>} signature
175
+ */
176
+ export const verify = (signature, data, publicKey) =>
177
+ webcrypto.subtle.verify(
178
+ {
179
+ name: 'ECDSA',
180
+ hash: { name: 'SHA-384' }
181
+ },
182
+ publicKey,
183
+ signature,
184
+ data
185
+ )
@@ -0,0 +1,6 @@
1
+ export function testReapeatEncryption(tc: t.TestCase): Promise<void>;
2
+ export function testEncryptionPerformance(tc: t.TestCase): Promise<void>;
3
+ export function testConsistentKeyGeneration(_tc: t.TestCase): Promise<void>;
4
+ export function testSigning(tc: t.TestCase): Promise<void>;
5
+ import * as t from "./testing.js";
6
+ //# sourceMappingURL=crypto.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.test.d.ts","sourceRoot":"","sources":["crypto.test.js"],"names":[],"mappings":"AAQO,0CAFI,EAAE,QAAQ,iBA+BpB;AAKM,8CAFI,EAAE,QAAQ,iBAsCpB;AAKM,iDAFI,EAAE,QAAQ,iBA0CpB;AAKM,gCAFI,EAAE,QAAQ,iBAapB"}
@@ -0,0 +1,231 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var encoding = require('./buffer-22bb9fae.cjs');
6
+ var string = require('./string-ad04f734.cjs');
7
+ var webcrypto = require('lib0/webcrypto');
8
+ require('./environment-f6386808.cjs');
9
+ require('./map-28a001c9.cjs');
10
+ require('./conditions-fb475c70.cjs');
11
+ require('./storage.cjs');
12
+ require('./function-40d38a5b.cjs');
13
+ require('./array-42d0736b.cjs');
14
+ require('./set-b596ef38.cjs');
15
+ require('./object-fe9c0021.cjs');
16
+ require('./binary-ac8e39e2.cjs');
17
+ require('./math-08e068f9.cjs');
18
+ require('./number-e62129bc.cjs');
19
+ require('./error-873c9cbf.cjs');
20
+
21
+ function _interopNamespace(e) {
22
+ if (e && e.__esModule) return e;
23
+ var n = Object.create(null);
24
+ if (e) {
25
+ Object.keys(e).forEach(function (k) {
26
+ if (k !== 'default') {
27
+ var d = Object.getOwnPropertyDescriptor(e, k);
28
+ Object.defineProperty(n, k, d.get ? d : {
29
+ enumerable: true,
30
+ get: function () { return e[k]; }
31
+ });
32
+ }
33
+ });
34
+ }
35
+ n["default"] = e;
36
+ return Object.freeze(n);
37
+ }
38
+
39
+ var webcrypto__namespace = /*#__PURE__*/_interopNamespace(webcrypto);
40
+
41
+ /* eslint-env browser */
42
+
43
+ /* istanbul ignore next */
44
+ /**
45
+ * @param {string | Uint8Array} data
46
+ * @return {Uint8Array}
47
+ */
48
+ const toBinary = data => typeof data === 'string' ? string.encodeUtf8(data) : data;
49
+
50
+ /**
51
+ * @experimental The API is not final!
52
+ *
53
+ * Derive an symmetric key using the Password-Based-Key-Derivation-Function-2.
54
+ *
55
+ * @param {string | Uint8Array} secret
56
+ * @param {string | Uint8Array} salt
57
+ * @param {Object} opts
58
+ * @param {boolean} [opts.extractable]
59
+ * @param {Array<'sign'|'verify'|'encrypt'|'decrypt'>} [opts.usages]
60
+ * @return {PromiseLike<CryptoKey>}
61
+ */
62
+ const deriveSymmetricKey = (secret, salt, { extractable = false, usages = ['encrypt', 'decrypt'] } = {}) => {
63
+ const binSecret = toBinary(secret);
64
+ const binSalt = toBinary(salt);
65
+ return webcrypto__namespace.subtle.importKey(
66
+ 'raw',
67
+ binSecret,
68
+ 'PBKDF2',
69
+ false,
70
+ ['deriveKey']
71
+ ).then(keyMaterial =>
72
+ webcrypto__namespace.subtle.deriveKey(
73
+ {
74
+ name: 'PBKDF2',
75
+ salt: binSalt, // NIST recommends at least 64 bits
76
+ iterations: 600000, // OWASP recommends 600k iterations
77
+ hash: 'SHA-256'
78
+ },
79
+ keyMaterial,
80
+ {
81
+ name: 'AES-GCM',
82
+ length: 256
83
+ },
84
+ extractable,
85
+ usages
86
+ )
87
+ )
88
+ };
89
+
90
+ /* istanbul ignore next */
91
+ /**
92
+ * @param {Object} opts
93
+ * @param {boolean} [opts.extractable]
94
+ * @param {Array<'sign'|'verify'|'encrypt'|'decrypt'>} [opts.usages]
95
+ */
96
+ const generateAsymmetricKey = ({ extractable = false, usages = ['sign', 'verify'] } = {}) =>
97
+ webcrypto__namespace.subtle.generateKey(
98
+ {
99
+ name: 'ECDSA',
100
+ namedCurve: 'P-384'
101
+ },
102
+ extractable,
103
+ usages
104
+ );
105
+
106
+ /* istanbul ignore next */
107
+ /**
108
+ * @param {CryptoKey} key - Symmetric or Asymmetric key
109
+ */
110
+ const exportKey = key => webcrypto__namespace.subtle.exportKey('jwk', key);
111
+
112
+ /* istanbul ignore next */
113
+ /**
114
+ * @param {any} jwk
115
+ * @param {Object} opts
116
+ * @param {boolean} [opts.extractable]
117
+ * @param {Array<'sign'|'verify'|'encrypt'|'decrypt'>} [opts.usages]
118
+ */
119
+ const importSymmetricKey = (jwk, { extractable = false, usages = ['encrypt', 'decrypt'] } = {}) =>
120
+ webcrypto__namespace.subtle.importKey('jwk', jwk, 'PBKDF2', extractable, usages);
121
+
122
+ /* istanbul ignore next */
123
+ /**
124
+ * @param {any} jwk
125
+ * @param {Object} opts
126
+ * @param {boolean} [opts.extractable]
127
+ * @param {Array<'sign'|'verify'|'encrypt'|'decrypt'>} [opts.usages]
128
+ */
129
+ const importAsymmetricKey = (jwk, { extractable = false, usages = ['encrypt', 'decrypt'] } = {}) =>
130
+ webcrypto__namespace.subtle.importKey('jwk', jwk, { name: 'ECDSA', namedCurve: 'P-384' }, extractable, usages);
131
+
132
+ /**
133
+ * @experimental The API is not final!
134
+ *
135
+ * Encrypt some data using AES-GCM method.
136
+ *
137
+ * @param {Uint8Array} data data to be encrypted
138
+ * @param {CryptoKey} key
139
+ * @return {PromiseLike<Uint8Array>} encrypted, base64 encoded message
140
+ */
141
+ const encrypt = (data, key) => {
142
+ const iv = webcrypto__namespace.getRandomValues(new Uint8Array(16)); // 92bit is enough. 128bit is recommended if space is not an issue.
143
+ return webcrypto__namespace.subtle.encrypt(
144
+ {
145
+ name: 'AES-GCM',
146
+ iv
147
+ },
148
+ key,
149
+ data
150
+ ).then(cipher => {
151
+ const encryptedDataEncoder = encoding.createEncoder();
152
+ // iv may be sent in the clear to the other peers
153
+ encoding.writeUint8Array(encryptedDataEncoder, iv);
154
+ encoding.writeVarUint8Array(encryptedDataEncoder, new Uint8Array(cipher));
155
+ return encoding.toUint8Array(encryptedDataEncoder)
156
+ })
157
+ };
158
+
159
+ /**
160
+ * @experimental The API is not final!
161
+ *
162
+ * Decrypt some data using AES-GCM method.
163
+ *
164
+ * @param {Uint8Array} data
165
+ * @param {CryptoKey} key
166
+ * @return {PromiseLike<Uint8Array>} decrypted buffer
167
+ */
168
+ const decrypt = (data, key) => {
169
+ const dataDecoder = encoding.createDecoder(data);
170
+ const iv = encoding.readUint8Array(dataDecoder, 16);
171
+ const cipher = encoding.readVarUint8Array(dataDecoder);
172
+ return webcrypto__namespace.subtle.decrypt(
173
+ {
174
+ name: 'AES-GCM',
175
+ iv
176
+ },
177
+ key,
178
+ cipher
179
+ ).then(data => new Uint8Array(data))
180
+ };
181
+
182
+ /**
183
+ * @experimental The API is not final!
184
+ *
185
+ * Sign a message
186
+ *
187
+ * @param {Uint8Array} data
188
+ * @param {CryptoKey} privateKey
189
+ * @return {PromiseLike<Uint8Array>} signature
190
+ */
191
+ const sign = (data, privateKey) =>
192
+ webcrypto__namespace.subtle.sign(
193
+ {
194
+ name: 'ECDSA',
195
+ hash: { name: 'SHA-384' }
196
+ },
197
+ privateKey,
198
+ data
199
+ ).then(signature => new Uint8Array(signature));
200
+
201
+ /**
202
+ * @experimental The API is not final!
203
+ *
204
+ * Sign a message
205
+ *
206
+ * @param {Uint8Array} signature
207
+ * @param {Uint8Array} data
208
+ * @param {CryptoKey} publicKey
209
+ * @return {PromiseLike<boolean>} signature
210
+ */
211
+ const verify = (signature, data, publicKey) =>
212
+ webcrypto__namespace.subtle.verify(
213
+ {
214
+ name: 'ECDSA',
215
+ hash: { name: 'SHA-384' }
216
+ },
217
+ publicKey,
218
+ signature,
219
+ data
220
+ );
221
+
222
+ exports.decrypt = decrypt;
223
+ exports.deriveSymmetricKey = deriveSymmetricKey;
224
+ exports.encrypt = encrypt;
225
+ exports.exportKey = exportKey;
226
+ exports.generateAsymmetricKey = generateAsymmetricKey;
227
+ exports.importAsymmetricKey = importAsymmetricKey;
228
+ exports.importSymmetricKey = importSymmetricKey;
229
+ exports.sign = sign;
230
+ exports.verify = verify;
231
+ //# sourceMappingURL=crypto.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.cjs","sources":["../crypto.js"],"sourcesContent":["/* eslint-env browser */\n\nimport * as encoding from './encoding.js'\nimport * as decoding from './decoding.js'\nimport * as string from './string.js'\nimport * as webcrypto from 'lib0/webcrypto'\n\n/* istanbul ignore next */\n/**\n * @param {string | Uint8Array} data\n * @return {Uint8Array}\n */\nconst toBinary = data => typeof data === 'string' ? string.encodeUtf8(data) : data\n\n/**\n * @experimental The API is not final!\n *\n * Derive an symmetric key using the Password-Based-Key-Derivation-Function-2.\n *\n * @param {string | Uint8Array} secret\n * @param {string | Uint8Array} salt\n * @param {Object} opts\n * @param {boolean} [opts.extractable]\n * @param {Array<'sign'|'verify'|'encrypt'|'decrypt'>} [opts.usages]\n * @return {PromiseLike<CryptoKey>}\n */\nexport const deriveSymmetricKey = (secret, salt, { extractable = false, usages = ['encrypt', 'decrypt'] } = {}) => {\n const binSecret = toBinary(secret)\n const binSalt = toBinary(salt)\n return webcrypto.subtle.importKey(\n 'raw',\n binSecret,\n 'PBKDF2',\n false,\n ['deriveKey']\n ).then(keyMaterial =>\n webcrypto.subtle.deriveKey(\n {\n name: 'PBKDF2',\n salt: binSalt, // NIST recommends at least 64 bits\n iterations: 600000, // OWASP recommends 600k iterations\n hash: 'SHA-256'\n },\n keyMaterial,\n {\n name: 'AES-GCM',\n length: 256\n },\n extractable,\n usages\n )\n )\n}\n\n/* istanbul ignore next */\n/**\n * @param {Object} opts\n * @param {boolean} [opts.extractable]\n * @param {Array<'sign'|'verify'|'encrypt'|'decrypt'>} [opts.usages]\n */\nexport const generateAsymmetricKey = ({ extractable = false, usages = ['sign', 'verify'] } = {}) =>\n webcrypto.subtle.generateKey(\n {\n name: 'ECDSA',\n namedCurve: 'P-384'\n },\n extractable,\n usages\n )\n\n/* istanbul ignore next */\n/**\n * @param {CryptoKey} key - Symmetric or Asymmetric key\n */\nexport const exportKey = key => webcrypto.subtle.exportKey('jwk', key)\n\n/* istanbul ignore next */\n/**\n * @param {any} jwk\n * @param {Object} opts\n * @param {boolean} [opts.extractable]\n * @param {Array<'sign'|'verify'|'encrypt'|'decrypt'>} [opts.usages]\n */\nexport const importSymmetricKey = (jwk, { extractable = false, usages = ['encrypt', 'decrypt'] } = {}) =>\n webcrypto.subtle.importKey('jwk', jwk, 'PBKDF2', extractable, usages)\n\n/* istanbul ignore next */\n/**\n * @param {any} jwk\n * @param {Object} opts\n * @param {boolean} [opts.extractable]\n * @param {Array<'sign'|'verify'|'encrypt'|'decrypt'>} [opts.usages]\n */\nexport const importAsymmetricKey = (jwk, { extractable = false, usages = ['encrypt', 'decrypt'] } = {}) =>\n webcrypto.subtle.importKey('jwk', jwk, { name: 'ECDSA', namedCurve: 'P-384' }, extractable, usages)\n\n/**\n * @experimental The API is not final!\n *\n * Encrypt some data using AES-GCM method.\n *\n * @param {Uint8Array} data data to be encrypted\n * @param {CryptoKey} key\n * @return {PromiseLike<Uint8Array>} encrypted, base64 encoded message\n */\nexport const encrypt = (data, key) => {\n const iv = webcrypto.getRandomValues(new Uint8Array(16)) // 92bit is enough. 128bit is recommended if space is not an issue.\n return webcrypto.subtle.encrypt(\n {\n name: 'AES-GCM',\n iv\n },\n key,\n data\n ).then(cipher => {\n const encryptedDataEncoder = encoding.createEncoder()\n // iv may be sent in the clear to the other peers\n encoding.writeUint8Array(encryptedDataEncoder, iv)\n encoding.writeVarUint8Array(encryptedDataEncoder, new Uint8Array(cipher))\n return encoding.toUint8Array(encryptedDataEncoder)\n })\n}\n\n/**\n * @experimental The API is not final!\n *\n * Decrypt some data using AES-GCM method.\n *\n * @param {Uint8Array} data\n * @param {CryptoKey} key\n * @return {PromiseLike<Uint8Array>} decrypted buffer\n */\nexport const decrypt = (data, key) => {\n const dataDecoder = decoding.createDecoder(data)\n const iv = decoding.readUint8Array(dataDecoder, 16)\n const cipher = decoding.readVarUint8Array(dataDecoder)\n return webcrypto.subtle.decrypt(\n {\n name: 'AES-GCM',\n iv\n },\n key,\n cipher\n ).then(data => new Uint8Array(data))\n}\n\n/**\n * @experimental The API is not final!\n *\n * Sign a message\n *\n * @param {Uint8Array} data\n * @param {CryptoKey} privateKey\n * @return {PromiseLike<Uint8Array>} signature\n */\nexport const sign = (data, privateKey) =>\n webcrypto.subtle.sign(\n {\n name: 'ECDSA',\n hash: { name: 'SHA-384' }\n },\n privateKey,\n data\n ).then(signature => new Uint8Array(signature))\n\n/**\n * @experimental The API is not final!\n *\n * Sign a message\n *\n * @param {Uint8Array} signature\n * @param {Uint8Array} data\n * @param {CryptoKey} publicKey\n * @return {PromiseLike<boolean>} signature\n */\nexport const verify = (signature, data, publicKey) =>\n webcrypto.subtle.verify(\n {\n name: 'ECDSA',\n hash: { name: 'SHA-384' }\n },\n publicKey,\n signature,\n data\n )\n"],"names":["string.encodeUtf8","webcrypto","encoding.createEncoder","encoding.writeUint8Array","encoding.writeVarUint8Array","encoding.toUint8Array","decoding.createDecoder","decoding.readUint8Array","decoding.readVarUint8Array"],"mappings":"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"}
@@ -0,0 +1,22 @@
1
+ export function deriveSymmetricKey(secret: string | Uint8Array, salt: string | Uint8Array, { extractable, usages }?: {
2
+ extractable?: boolean | undefined;
3
+ usages?: ("decrypt" | "encrypt" | "sign" | "verify")[] | undefined;
4
+ }): PromiseLike<CryptoKey>;
5
+ export function generateAsymmetricKey({ extractable, usages }?: {
6
+ extractable?: boolean | undefined;
7
+ usages?: ("decrypt" | "encrypt" | "sign" | "verify")[] | undefined;
8
+ }): Promise<CryptoKeyPair>;
9
+ export function exportKey(key: CryptoKey): Promise<JsonWebKey>;
10
+ export function importSymmetricKey(jwk: any, { extractable, usages }?: {
11
+ extractable?: boolean | undefined;
12
+ usages?: ("decrypt" | "encrypt" | "sign" | "verify")[] | undefined;
13
+ }): Promise<CryptoKey>;
14
+ export function importAsymmetricKey(jwk: any, { extractable, usages }?: {
15
+ extractable?: boolean | undefined;
16
+ usages?: ("decrypt" | "encrypt" | "sign" | "verify")[] | undefined;
17
+ }): Promise<CryptoKey>;
18
+ export function encrypt(data: Uint8Array, key: CryptoKey): PromiseLike<Uint8Array>;
19
+ export function decrypt(data: Uint8Array, key: CryptoKey): PromiseLike<Uint8Array>;
20
+ export function sign(data: Uint8Array, privateKey: CryptoKey): PromiseLike<Uint8Array>;
21
+ export function verify(signature: Uint8Array, data: Uint8Array, publicKey: CryptoKey): PromiseLike<boolean>;
22
+ //# sourceMappingURL=crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../crypto.js"],"names":[],"mappings":"AA0BO,2CAPI,MAAM,GAAG,UAAU,QACnB,MAAM,GAAG,UAAU;IAEJ,WAAW;IACwB,MAAM;IACvD,YAAY,SAAS,CAAC,CA4BjC;AAQM;IAHmB,WAAW;IACwB,MAAM;2BAUhE;AAMI,+BAFI,SAAS,uBAEkD;AAS/D,wCALI,GAAG;IAEY,WAAW;IACwB,MAAM;uBAGI;AAShE,yCALI,GAAG;IAEY,WAAW;IACwB,MAAM;uBAGkC;AAW9F,8BAJI,UAAU,OACV,SAAS,GACR,YAAY,UAAU,CAAC,CAkBlC;AAWM,8BAJI,UAAU,OACV,SAAS,GACR,YAAY,UAAU,CAAC,CAclC;AAWM,2BAJI,UAAU,cACV,SAAS,GACR,YAAY,UAAU,CAAC,CAUa;AAYzC,kCALI,UAAU,QACV,UAAU,aACV,SAAS,GACR,YAAY,OAAO,CAAC,CAW7B"}
@@ -0,0 +1,6 @@
1
+ export function testReapeatEncryption(tc: t.TestCase): Promise<void>;
2
+ export function testEncryptionPerformance(tc: t.TestCase): Promise<void>;
3
+ export function testConsistentKeyGeneration(_tc: t.TestCase): Promise<void>;
4
+ export function testSigning(tc: t.TestCase): Promise<void>;
5
+ import * as t from "./testing.js";
6
+ //# sourceMappingURL=crypto.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.test.d.ts","sourceRoot":"","sources":["../crypto.test.js"],"names":[],"mappings":"AAQO,0CAFI,EAAE,QAAQ,iBA+BpB;AAKM,8CAFI,EAAE,QAAQ,iBAsCpB;AAKM,iDAFI,EAAE,QAAQ,iBA0CpB;AAKM,gCAFI,EAAE,QAAQ,iBAapB"}
@@ -33,7 +33,7 @@ declare var _default: ({
33
33
  file?: undefined;
34
34
  };
35
35
  external: string[];
36
- plugins?: undefined;
36
+ plugins: import("rollup").Plugin[];
37
37
  })[];
38
38
  export default _default;
39
39
  //# sourceMappingURL=rollup.config.d.ts.map
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /* eslint-env browser */
6
+
7
+ const subtle = crypto.subtle;
8
+ const getRandomValues = crypto.getRandomValues.bind(crypto);
9
+
10
+ exports.getRandomValues = getRandomValues;
11
+ exports.subtle = subtle;
12
+ //# sourceMappingURL=webcrypto.browser.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webcrypto.browser.cjs","sources":["../webcrypto.browser.js"],"sourcesContent":["/* eslint-env browser */\n\nexport const subtle = crypto.subtle\nexport const getRandomValues = crypto.getRandomValues.bind(crypto)\n"],"names":[],"mappings":";;;;AAAA;AACA;AACY,MAAC,MAAM,GAAG,MAAM,CAAC,OAAM;AACvB,MAAC,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM;;;;;"}
@@ -0,0 +1,3 @@
1
+ export const subtle: SubtleCrypto;
2
+ export const getRandomValues: <T extends ArrayBufferView | null>(array: T) => T;
3
+ //# sourceMappingURL=webcrypto.browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webcrypto.browser.d.ts","sourceRoot":"","sources":["../webcrypto.browser.js"],"names":[],"mappings":"AAEA,kCAAmC;AACnC,gFAAkE"}
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var node_crypto = require('node:crypto');
6
+
7
+ const subtle = /** @type {any} */ (node_crypto.webcrypto).subtle;
8
+ const getRandomValues = /** @type {any} */ (node_crypto.webcrypto).getRandomValues.bind(node_crypto.webcrypto);
9
+
10
+ exports.getRandomValues = getRandomValues;
11
+ exports.subtle = subtle;
12
+ //# sourceMappingURL=webcrypto.node.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webcrypto.node.cjs","sources":["../webcrypto.node.js"],"sourcesContent":["\nimport { webcrypto } from 'node:crypto'\n\nexport const subtle = /** @type {any} */ (webcrypto).subtle\nexport const getRandomValues = /** @type {any} */ (webcrypto).getRandomValues.bind(webcrypto)\n"],"names":["webcrypto"],"mappings":";;;;;;AAGY,MAAC,MAAM,sBAAsB,CAACA,qBAAS,EAAE,OAAM;AAC/C,MAAC,eAAe,sBAAsB,CAACA,qBAAS,EAAE,eAAe,CAAC,IAAI,CAACA,qBAAS;;;;;"}
@@ -0,0 +1,3 @@
1
+ export const subtle: any;
2
+ export const getRandomValues: any;
3
+ //# sourceMappingURL=webcrypto.node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webcrypto.node.d.ts","sourceRoot":"","sources":["../webcrypto.node.js"],"names":[],"mappings":"AAGA,yBAA2D;AAC3D,kCAA6F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lib0",
3
- "version": "0.2.61",
3
+ "version": "0.2.62",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -75,6 +75,12 @@
75
75
  "import": "./condititons.js",
76
76
  "require": "./dist/conditions.cjs"
77
77
  },
78
+ "./crypto": {
79
+ "types": "./crypto.d.ts",
80
+ "module": "./crypto.js",
81
+ "import": "./crypto.js",
82
+ "require": "./dist/crypto.cjs"
83
+ },
78
84
  "./decoding.js": "./decoding.js",
79
85
  "./dist/decoding.cjs": "./dist/decoding.cjs",
80
86
  "./decoding": {
@@ -370,6 +376,18 @@
370
376
  "module": "./websocket.js",
371
377
  "import": "./websocket.js",
372
378
  "require": "./dist/websocket.cjs"
379
+ },
380
+ "./webcrypto": {
381
+ "types": "./webcrypto.browser.d.ts",
382
+ "node": {
383
+ "import": "./webcrypto.node.js",
384
+ "require": "./dist/webcrypto.node.cjs"
385
+ },
386
+ "browser": {
387
+ "import": "./webcrypto.browser.js",
388
+ "require": "./dist/webcrypto.browser.cjs"
389
+ },
390
+ "module": "./webcrypto.browser.js"
373
391
  }
374
392
  },
375
393
  "dependencies": {
@@ -33,7 +33,7 @@ declare var _default: ({
33
33
  file?: undefined;
34
34
  };
35
35
  external: string[];
36
- plugins?: undefined;
36
+ plugins: import("rollup").Plugin[];
37
37
  })[];
38
38
  export default _default;
39
39
  //# sourceMappingURL=rollup.config.d.ts.map
package/test.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { runTests } from './testing.js'
2
2
  import * as array from './array.test.js'
3
3
  import * as broadcastchannel from './broadcastchannel.test.js'
4
+ import * as crypto from './crypto.test.js'
4
5
  import * as logging from './logging.test.js'
5
6
  import * as string from './string.test.js'
6
7
  import * as encoding from './encoding.test.js'
@@ -41,6 +42,7 @@ if (isBrowser) {
41
42
  runTests({
42
43
  array,
43
44
  broadcastchannel,
45
+ crypto,
44
46
  logging,
45
47
  string,
46
48
  encoding,
@@ -0,0 +1,3 @@
1
+ export const subtle: SubtleCrypto;
2
+ export const getRandomValues: <T extends ArrayBufferView | null>(array: T) => T;
3
+ //# sourceMappingURL=webcrypto.browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webcrypto.browser.d.ts","sourceRoot":"","sources":["webcrypto.browser.js"],"names":[],"mappings":"AAEA,kCAAmC;AACnC,gFAAkE"}
@@ -0,0 +1,4 @@
1
+ /* eslint-env browser */
2
+
3
+ export const subtle = crypto.subtle
4
+ export const getRandomValues = crypto.getRandomValues.bind(crypto)
@@ -0,0 +1,3 @@
1
+ export const subtle: any;
2
+ export const getRandomValues: any;
3
+ //# sourceMappingURL=webcrypto.node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webcrypto.node.d.ts","sourceRoot":"","sources":["webcrypto.node.js"],"names":[],"mappings":"AAGA,yBAA2D;AAC3D,kCAA6F"}
@@ -0,0 +1,5 @@
1
+
2
+ import { webcrypto } from 'node:crypto'
3
+
4
+ export const subtle = /** @type {any} */ (webcrypto).subtle
5
+ export const getRandomValues = /** @type {any} */ (webcrypto).getRandomValues.bind(webcrypto)