@lockerpm/desktop-service 2.1.0 → 2.1.1
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.
|
@@ -19,8 +19,12 @@ exports.CoreCryptoService = void 0;
|
|
|
19
19
|
const crypto_1 = __importDefault(require("crypto"));
|
|
20
20
|
const crypto_service_1 = require("../abstractions/crypto.service");
|
|
21
21
|
const utils_1 = require("../misc/utils");
|
|
22
|
-
const argon2_js_1 = require("@noble/hashes/argon2.js");
|
|
23
22
|
const crypto = crypto_1.default.webcrypto;
|
|
23
|
+
// `@noble/hashes@2` is ESM-only. Under the CommonJS build, TypeScript would
|
|
24
|
+
// downlevel a static `import()` back into `require()`, which Node 18 cannot use
|
|
25
|
+
// to load an ES module (ERR_REQUIRE_ESM). Hide the dynamic import behind
|
|
26
|
+
// `new Function` so the compiler leaves it untouched in both builds.
|
|
27
|
+
const importESM = new Function('p', 'return import(p)');
|
|
24
28
|
class CoreCryptoService {
|
|
25
29
|
makeKey(password, salt, kdf, kdfIterations, kdfMemory, kdfParallelism) {
|
|
26
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -86,9 +90,10 @@ class CoreCryptoService {
|
|
|
86
90
|
}
|
|
87
91
|
argon2id(password, salt, iterations, memory, parallelism, outputByteSize) {
|
|
88
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
const { argon2idAsync } = yield importESM('@noble/hashes/argon2.js');
|
|
89
94
|
const nodePassword = new Uint8Array(this.toBuf(password));
|
|
90
95
|
const nodeSalt = new Uint8Array(this.toBuf(salt));
|
|
91
|
-
const res = yield
|
|
96
|
+
const res = yield argon2idAsync(nodePassword, nodeSalt, {
|
|
92
97
|
t: iterations,
|
|
93
98
|
m: memory,
|
|
94
99
|
p: parallelism,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-crypto.service.d.ts","sourceRoot":"","sources":["../../../../src/services/core-crypto.service.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,SAAS,EAEV,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"core-crypto.service.d.ts","sourceRoot":"","sources":["../../../../src/services/core-crypto.service.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,SAAS,EAEV,MAAM,gCAAgC,CAAA;AAavC,qBAAa,iBAAiB;IACtB,OAAO,CACX,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,OAAO,EACZ,aAAa,EAAE,MAAM,EACrB,SAAS,CAAC,EAAE,MAAM,EAClB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,kBAAkB,CAAC;IAwBxB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;IAQxE,YAAY,CAChB,aAAa,EAAE,WAAW,EAC1B,GAAG,EAAE,kBAAkB,GACtB,OAAO,CAAC,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC;YAe7B,MAAM;YA2BN,QAAQ;IAsBtB,OAAO,CAAC,KAAK;IAUb,OAAO,CAAC,oBAAoB;YAOd,UAAU;YASV,UAAU;YAmCV,IAAI;YAaJ,OAAO;YAkBP,UAAU;IAgBxB,OAAO,CAAC,WAAW;YAIL,WAAW;CAU1B"}
|
|
@@ -4,8 +4,12 @@
|
|
|
4
4
|
import c from 'crypto';
|
|
5
5
|
import { KdfType, SymmetricCryptoKey, EncString, EncryptedObject, } from '../abstractions/crypto.service';
|
|
6
6
|
import { Utils } from '../misc/utils';
|
|
7
|
-
import { argon2idAsync } from '@noble/hashes/argon2.js';
|
|
8
7
|
const crypto = c.webcrypto;
|
|
8
|
+
// `@noble/hashes@2` is ESM-only. Under the CommonJS build, TypeScript would
|
|
9
|
+
// downlevel a static `import()` back into `require()`, which Node 18 cannot use
|
|
10
|
+
// to load an ES module (ERR_REQUIRE_ESM). Hide the dynamic import behind
|
|
11
|
+
// `new Function` so the compiler leaves it untouched in both builds.
|
|
12
|
+
const importESM = new Function('p', 'return import(p)');
|
|
9
13
|
export class CoreCryptoService {
|
|
10
14
|
async makeKey(password, salt, kdf, kdfIterations, kdfMemory, kdfParallelism) {
|
|
11
15
|
let key;
|
|
@@ -62,6 +66,7 @@ export class CoreCryptoService {
|
|
|
62
66
|
return await crypto.subtle.deriveBits(pbkdf2Params, impKey, wcLen);
|
|
63
67
|
}
|
|
64
68
|
async argon2id(password, salt, iterations, memory, parallelism, outputByteSize) {
|
|
69
|
+
const { argon2idAsync } = await importESM('@noble/hashes/argon2.js');
|
|
65
70
|
const nodePassword = new Uint8Array(this.toBuf(password));
|
|
66
71
|
const nodeSalt = new Uint8Array(this.toBuf(salt));
|
|
67
72
|
const res = await argon2idAsync(nodePassword, nodeSalt, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-crypto.service.d.ts","sourceRoot":"","sources":["../../../../src/services/core-crypto.service.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,SAAS,EAEV,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"core-crypto.service.d.ts","sourceRoot":"","sources":["../../../../src/services/core-crypto.service.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,SAAS,EAEV,MAAM,gCAAgC,CAAA;AAavC,qBAAa,iBAAiB;IACtB,OAAO,CACX,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,OAAO,EACZ,aAAa,EAAE,MAAM,EACrB,SAAS,CAAC,EAAE,MAAM,EAClB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,kBAAkB,CAAC;IAwBxB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;IAQxE,YAAY,CAChB,aAAa,EAAE,WAAW,EAC1B,GAAG,EAAE,kBAAkB,GACtB,OAAO,CAAC,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC;YAe7B,MAAM;YA2BN,QAAQ;IAsBtB,OAAO,CAAC,KAAK;IAUb,OAAO,CAAC,oBAAoB;YAOd,UAAU;YASV,UAAU;YAmCV,IAAI;YAaJ,OAAO;YAkBP,UAAU;IAgBxB,OAAO,CAAC,WAAW;YAIL,WAAW;CAU1B"}
|