@privateaim/kit 0.8.11 → 0.8.13
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/CHANGELOG.md +4 -0
- package/dist/index.cjs +13 -13
- package/dist/index.mjs +13 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.8.13](https://github.com/PrivateAIM/hub/compare/v0.8.12...v0.8.13) (2025-05-05)
|
|
4
|
+
|
|
5
|
+
## [0.8.12](https://github.com/PrivateAIM/hub/compare/v0.8.11...v0.8.12) (2025-04-25)
|
|
6
|
+
|
|
3
7
|
## [0.8.11](https://github.com/PrivateAIM/hub/compare/v0.8.10...v0.8.11) (2025-04-24)
|
|
4
8
|
|
|
5
9
|
|
package/dist/index.cjs
CHANGED
|
@@ -52,19 +52,19 @@ function arrayBufferToBase64(arrayBuffer) {
|
|
|
52
52
|
return btoa(String.fromCharCode.apply(null, new Uint8Array(arrayBuffer)));
|
|
53
53
|
}
|
|
54
54
|
function exportAsymmetricPublicKey(key) {
|
|
55
|
-
return
|
|
55
|
+
return _async_to_generator$2(function*() {
|
|
56
56
|
const exported = yield crypto.subtle.exportKey('spki', key);
|
|
57
57
|
return `-----BEGIN PUBLIC KEY-----\n${arrayBufferToBase64(exported)}\n-----END PUBLIC KEY-----`;
|
|
58
58
|
})();
|
|
59
59
|
}
|
|
60
60
|
function exportAsymmetricPrivateKey(key) {
|
|
61
|
-
return
|
|
61
|
+
return _async_to_generator$2(function*() {
|
|
62
62
|
const exported = yield crypto.subtle.exportKey('pkcs8', key);
|
|
63
63
|
return `-----BEGIN PRIVATE KEY-----\n${arrayBufferToBase64(exported)}\n-----END PRIVATE KEY-----`;
|
|
64
64
|
})();
|
|
65
65
|
}
|
|
66
66
|
function importAsymmetricPublicKey(pem, params) {
|
|
67
|
-
return
|
|
67
|
+
return _async_to_generator$2(function*() {
|
|
68
68
|
const pemHeader = '-----BEGIN PUBLIC KEY-----';
|
|
69
69
|
const pemFooter = '-----END PUBLIC KEY-----';
|
|
70
70
|
const pemContents = pem.substring(pemHeader.length, pem.length - pemFooter.length);
|
|
@@ -179,7 +179,7 @@ class CryptoAsymmetricAlgorithm {
|
|
|
179
179
|
throw new Error('Import params could not be created.');
|
|
180
180
|
}
|
|
181
181
|
generateKeyPair() {
|
|
182
|
-
return
|
|
182
|
+
return _async_to_generator$1(function*() {
|
|
183
183
|
if (this.algorithm.name === AsymmetricCryptoAlgorithmName.RSA_OAEP) {
|
|
184
184
|
this.keyPair = yield crypto.subtle.generateKey(this.algorithm, true, [
|
|
185
185
|
'encrypt',
|
|
@@ -197,7 +197,7 @@ class CryptoAsymmetricAlgorithm {
|
|
|
197
197
|
}).call(this);
|
|
198
198
|
}
|
|
199
199
|
useKeyPair() {
|
|
200
|
-
return
|
|
200
|
+
return _async_to_generator$1(function*() {
|
|
201
201
|
if (typeof this.keyPair !== 'undefined') {
|
|
202
202
|
return this.keyPair;
|
|
203
203
|
}
|
|
@@ -205,19 +205,19 @@ class CryptoAsymmetricAlgorithm {
|
|
|
205
205
|
}).call(this);
|
|
206
206
|
}
|
|
207
207
|
exportPublicKey() {
|
|
208
|
-
return
|
|
208
|
+
return _async_to_generator$1(function*() {
|
|
209
209
|
const keyPair = yield this.useKeyPair();
|
|
210
210
|
return exportAsymmetricPublicKey(keyPair.publicKey);
|
|
211
211
|
}).call(this);
|
|
212
212
|
}
|
|
213
213
|
exportPrivateKey() {
|
|
214
|
-
return
|
|
214
|
+
return _async_to_generator$1(function*() {
|
|
215
215
|
const keyPair = yield this.useKeyPair();
|
|
216
216
|
return exportAsymmetricPrivateKey(keyPair.privateKey);
|
|
217
217
|
}).call(this);
|
|
218
218
|
}
|
|
219
219
|
encrypt(data, remoteKey) {
|
|
220
|
-
return
|
|
220
|
+
return _async_to_generator$1(function*() {
|
|
221
221
|
const keyPair = yield this.useKeyPair();
|
|
222
222
|
if (this.algorithm.name === AsymmetricCryptoAlgorithmName.RSA_OAEP) {
|
|
223
223
|
return crypto.subtle.encrypt({
|
|
@@ -254,7 +254,7 @@ class CryptoAsymmetricAlgorithm {
|
|
|
254
254
|
}).call(this);
|
|
255
255
|
}
|
|
256
256
|
decrypt(data, remoteKey) {
|
|
257
|
-
return
|
|
257
|
+
return _async_to_generator$1(function*() {
|
|
258
258
|
const keyPair = yield this.useKeyPair();
|
|
259
259
|
if (this.algorithm.name === AsymmetricCryptoAlgorithmName.RSA_OAEP) {
|
|
260
260
|
return crypto.subtle.decrypt({
|
|
@@ -349,7 +349,7 @@ function _define_property(obj, key, value) {
|
|
|
349
349
|
}
|
|
350
350
|
class CryptoSymmetricAlgorithm {
|
|
351
351
|
generateKey() {
|
|
352
|
-
return
|
|
352
|
+
return _async_to_generator(function*() {
|
|
353
353
|
return crypto.subtle.generateKey({
|
|
354
354
|
name: this.algorithm.name,
|
|
355
355
|
length: 256
|
|
@@ -360,7 +360,7 @@ class CryptoSymmetricAlgorithm {
|
|
|
360
360
|
}).call(this);
|
|
361
361
|
}
|
|
362
362
|
importKey(buffer) {
|
|
363
|
-
return
|
|
363
|
+
return _async_to_generator(function*() {
|
|
364
364
|
return crypto.subtle.importKey('raw', buffer, {
|
|
365
365
|
name: this.algorithm.name,
|
|
366
366
|
length: 256
|
|
@@ -371,7 +371,7 @@ class CryptoSymmetricAlgorithm {
|
|
|
371
371
|
}).call(this);
|
|
372
372
|
}
|
|
373
373
|
encrypt(key, iv, data) {
|
|
374
|
-
return
|
|
374
|
+
return _async_to_generator(function*() {
|
|
375
375
|
const arrayBuffer = yield crypto.subtle.encrypt({
|
|
376
376
|
name: this.algorithm.name,
|
|
377
377
|
length: 256,
|
|
@@ -385,7 +385,7 @@ class CryptoSymmetricAlgorithm {
|
|
|
385
385
|
}).call(this);
|
|
386
386
|
}
|
|
387
387
|
decrypt(key, data) {
|
|
388
|
-
return
|
|
388
|
+
return _async_to_generator(function*() {
|
|
389
389
|
const iv = data.slice(0, 16);
|
|
390
390
|
const arrayBuffer = yield crypto.subtle.decrypt({
|
|
391
391
|
name: this.algorithm.name,
|
package/dist/index.mjs
CHANGED
|
@@ -50,19 +50,19 @@ function arrayBufferToBase64(arrayBuffer) {
|
|
|
50
50
|
return btoa(String.fromCharCode.apply(null, new Uint8Array(arrayBuffer)));
|
|
51
51
|
}
|
|
52
52
|
function exportAsymmetricPublicKey(key) {
|
|
53
|
-
return
|
|
53
|
+
return _async_to_generator$2(function*() {
|
|
54
54
|
const exported = yield crypto.subtle.exportKey('spki', key);
|
|
55
55
|
return `-----BEGIN PUBLIC KEY-----\n${arrayBufferToBase64(exported)}\n-----END PUBLIC KEY-----`;
|
|
56
56
|
})();
|
|
57
57
|
}
|
|
58
58
|
function exportAsymmetricPrivateKey(key) {
|
|
59
|
-
return
|
|
59
|
+
return _async_to_generator$2(function*() {
|
|
60
60
|
const exported = yield crypto.subtle.exportKey('pkcs8', key);
|
|
61
61
|
return `-----BEGIN PRIVATE KEY-----\n${arrayBufferToBase64(exported)}\n-----END PRIVATE KEY-----`;
|
|
62
62
|
})();
|
|
63
63
|
}
|
|
64
64
|
function importAsymmetricPublicKey(pem, params) {
|
|
65
|
-
return
|
|
65
|
+
return _async_to_generator$2(function*() {
|
|
66
66
|
const pemHeader = '-----BEGIN PUBLIC KEY-----';
|
|
67
67
|
const pemFooter = '-----END PUBLIC KEY-----';
|
|
68
68
|
const pemContents = pem.substring(pemHeader.length, pem.length - pemFooter.length);
|
|
@@ -177,7 +177,7 @@ class CryptoAsymmetricAlgorithm {
|
|
|
177
177
|
throw new Error('Import params could not be created.');
|
|
178
178
|
}
|
|
179
179
|
generateKeyPair() {
|
|
180
|
-
return
|
|
180
|
+
return _async_to_generator$1(function*() {
|
|
181
181
|
if (this.algorithm.name === AsymmetricCryptoAlgorithmName.RSA_OAEP) {
|
|
182
182
|
this.keyPair = yield crypto.subtle.generateKey(this.algorithm, true, [
|
|
183
183
|
'encrypt',
|
|
@@ -195,7 +195,7 @@ class CryptoAsymmetricAlgorithm {
|
|
|
195
195
|
}).call(this);
|
|
196
196
|
}
|
|
197
197
|
useKeyPair() {
|
|
198
|
-
return
|
|
198
|
+
return _async_to_generator$1(function*() {
|
|
199
199
|
if (typeof this.keyPair !== 'undefined') {
|
|
200
200
|
return this.keyPair;
|
|
201
201
|
}
|
|
@@ -203,19 +203,19 @@ class CryptoAsymmetricAlgorithm {
|
|
|
203
203
|
}).call(this);
|
|
204
204
|
}
|
|
205
205
|
exportPublicKey() {
|
|
206
|
-
return
|
|
206
|
+
return _async_to_generator$1(function*() {
|
|
207
207
|
const keyPair = yield this.useKeyPair();
|
|
208
208
|
return exportAsymmetricPublicKey(keyPair.publicKey);
|
|
209
209
|
}).call(this);
|
|
210
210
|
}
|
|
211
211
|
exportPrivateKey() {
|
|
212
|
-
return
|
|
212
|
+
return _async_to_generator$1(function*() {
|
|
213
213
|
const keyPair = yield this.useKeyPair();
|
|
214
214
|
return exportAsymmetricPrivateKey(keyPair.privateKey);
|
|
215
215
|
}).call(this);
|
|
216
216
|
}
|
|
217
217
|
encrypt(data, remoteKey) {
|
|
218
|
-
return
|
|
218
|
+
return _async_to_generator$1(function*() {
|
|
219
219
|
const keyPair = yield this.useKeyPair();
|
|
220
220
|
if (this.algorithm.name === AsymmetricCryptoAlgorithmName.RSA_OAEP) {
|
|
221
221
|
return crypto.subtle.encrypt({
|
|
@@ -252,7 +252,7 @@ class CryptoAsymmetricAlgorithm {
|
|
|
252
252
|
}).call(this);
|
|
253
253
|
}
|
|
254
254
|
decrypt(data, remoteKey) {
|
|
255
|
-
return
|
|
255
|
+
return _async_to_generator$1(function*() {
|
|
256
256
|
const keyPair = yield this.useKeyPair();
|
|
257
257
|
if (this.algorithm.name === AsymmetricCryptoAlgorithmName.RSA_OAEP) {
|
|
258
258
|
return crypto.subtle.decrypt({
|
|
@@ -347,7 +347,7 @@ function _define_property(obj, key, value) {
|
|
|
347
347
|
}
|
|
348
348
|
class CryptoSymmetricAlgorithm {
|
|
349
349
|
generateKey() {
|
|
350
|
-
return
|
|
350
|
+
return _async_to_generator(function*() {
|
|
351
351
|
return crypto.subtle.generateKey({
|
|
352
352
|
name: this.algorithm.name,
|
|
353
353
|
length: 256
|
|
@@ -358,7 +358,7 @@ class CryptoSymmetricAlgorithm {
|
|
|
358
358
|
}).call(this);
|
|
359
359
|
}
|
|
360
360
|
importKey(buffer) {
|
|
361
|
-
return
|
|
361
|
+
return _async_to_generator(function*() {
|
|
362
362
|
return crypto.subtle.importKey('raw', buffer, {
|
|
363
363
|
name: this.algorithm.name,
|
|
364
364
|
length: 256
|
|
@@ -369,7 +369,7 @@ class CryptoSymmetricAlgorithm {
|
|
|
369
369
|
}).call(this);
|
|
370
370
|
}
|
|
371
371
|
encrypt(key, iv, data) {
|
|
372
|
-
return
|
|
372
|
+
return _async_to_generator(function*() {
|
|
373
373
|
const arrayBuffer = yield crypto.subtle.encrypt({
|
|
374
374
|
name: this.algorithm.name,
|
|
375
375
|
length: 256,
|
|
@@ -383,7 +383,7 @@ class CryptoSymmetricAlgorithm {
|
|
|
383
383
|
}).call(this);
|
|
384
384
|
}
|
|
385
385
|
decrypt(key, data) {
|
|
386
|
-
return
|
|
386
|
+
return _async_to_generator(function*() {
|
|
387
387
|
const iv = data.slice(0, 16);
|
|
388
388
|
const arrayBuffer = yield crypto.subtle.decrypt({
|
|
389
389
|
name: this.algorithm.name,
|