@dstorage-tech/dstorage-sdk 0.0.5 → 0.0.8
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 +22 -4
- package/dist/KeypairEncryptionAdapter-EOBRCIGP-5PFPNLLA.mjs +8 -0
- package/dist/{KeypairEncryptionAdapter-XUKCLRFU-AYDAZ2TZ.mjs → KeypairEncryptionAdapter-EOBRCIGP-FLPJIL26.mjs} +3 -3
- package/dist/{MnemonicEncryptionAdapter-RCHUETBP-M7NHGSHO.mjs → MnemonicEncryptionAdapter-S56YG63Q-B3F3TO3T.mjs} +3 -3
- package/dist/MnemonicEncryptionAdapter-S56YG63Q-POTD74UN.mjs +8 -0
- package/dist/{PasswordEncryptionAdapter-ECHND672-MUTHAMZY.mjs → PasswordEncryptionAdapter-B2UG7MWB-M4C3KJ4S.mjs} +3 -3
- package/dist/{PasswordEncryptionAdapter-ECHND672-3DEFO6FP.mjs → PasswordEncryptionAdapter-B2UG7MWB-QCSOIQJA.mjs} +3 -3
- package/dist/browser.d.mts +92 -196
- package/dist/browser.mjs +1886 -2139
- package/dist/{chunk-HDD6SUU4.mjs → chunk-42O7KEL4.mjs} +30 -11
- package/dist/{chunk-X4LEBNK6.mjs → chunk-5F3HZ2RJ.mjs} +30 -11
- package/dist/{chunk-6IAQVMSM.mjs → chunk-E73HFT6J.mjs} +5 -5
- package/dist/{chunk-UDYXMII2.mjs → chunk-EOPUNIUH.mjs} +5 -5
- package/dist/{chunk-O37NHERH.mjs → chunk-L6WCT64V.mjs} +4 -2
- package/dist/{chunk-4X5K43JF.mjs → chunk-M3F2LR3B.mjs} +3 -1
- package/dist/{chunk-JMPRZK5D.mjs → chunk-O6COTUD4.mjs} +3 -1
- package/dist/{chunk-BWLEAAFW.mjs → chunk-PCXBQRCO.mjs} +55 -2056
- package/dist/{chunk-OLGVVM5Y.mjs → chunk-QFJ2Y4XE.mjs} +5 -5
- package/dist/{chunk-Z6DUAI5B.mjs → chunk-XW4RZG2X.mjs} +5 -5
- package/dist/{contract-api-TJ7JPHZA-6FUBJ6DS.mjs → contract-api-NUY4UEKE-ZANT3ICG.mjs} +3 -3
- package/dist/{contract-api-AO4RGPLT-ENC72WCG.mjs → contract-api-P6YEDYQ6-2X6BMD64.mjs} +3 -3
- package/dist/{dist-INTAFXQ7.mjs → dist-AGNOIJI4.mjs} +3 -1
- package/dist/{dist-MOLWJ4Y7.mjs → dist-J4JUJ2J5.mjs} +3 -1
- package/dist/errors.d.mts +2 -3
- package/dist/errors.d.ts +2 -3
- package/dist/errors.js +10 -2059
- package/dist/errors.mjs +10 -2059
- package/dist/index.d.mts +109 -196
- package/dist/index.d.ts +109 -196
- package/dist/index.js +2106 -4347
- package/dist/index.mjs +1941 -2194
- package/package.json +3 -2
- package/dist/KeypairEncryptionAdapter-XUKCLRFU-ERPYK5S4.mjs +0 -8
- package/dist/MnemonicEncryptionAdapter-RCHUETBP-DZPBGQG6.mjs +0 -8
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EncryptionErrorCode
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-L6WCT64V.mjs";
|
|
4
4
|
import {
|
|
5
5
|
DStorageError,
|
|
6
6
|
deriveKek,
|
|
7
7
|
unwrapKey,
|
|
8
8
|
wrapKey
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-PCXBQRCO.mjs";
|
|
10
10
|
|
|
11
|
-
// ../encryption/dist/chunk-
|
|
11
|
+
// ../encryption/dist/chunk-ENX7VXEV.mjs
|
|
12
12
|
import { scrypt } from "@noble/hashes/scrypt.js";
|
|
13
13
|
var KDF_PRESETS = {
|
|
14
14
|
v1: { N: 131072, r: 8, p: 1 },
|
|
@@ -137,8 +137,8 @@ var PasswordEncryptionAdapter = class _PasswordEncryptionAdapter {
|
|
|
137
137
|
* @param variant ML-KEM variant. Default: "mlkem768".
|
|
138
138
|
*/
|
|
139
139
|
async intoKeypairEncryptionAdapter(context, variant) {
|
|
140
|
-
const { KeypairEncryptionAdapter } = await import("./KeypairEncryptionAdapter-
|
|
141
|
-
const { mlkemGenerateKeypairFromSeed } = await import("./dist-
|
|
140
|
+
const { KeypairEncryptionAdapter } = await import("./KeypairEncryptionAdapter-EOBRCIGP-5PFPNLLA.mjs");
|
|
141
|
+
const { mlkemGenerateKeypairFromSeed } = await import("./dist-J4JUJ2J5.mjs");
|
|
142
142
|
const kekMaterial = await this.kekMaterialPromise;
|
|
143
143
|
const mlkemBits = await globalThis.crypto.subtle.deriveBits(
|
|
144
144
|
{
|
|
@@ -170,7 +170,23 @@ function resolveSalt(salt) {
|
|
|
170
170
|
}
|
|
171
171
|
return bytes;
|
|
172
172
|
}
|
|
173
|
+
var MIN_SCRYPT_N = 32768;
|
|
174
|
+
function assertScryptCost(N) {
|
|
175
|
+
if (!Number.isInteger(N) || N < 2 || (N & N - 1) !== 0) {
|
|
176
|
+
throw new DStorageError(
|
|
177
|
+
EncryptionErrorCode.PASSWORD_SCRYPT_N_NOT_POWER_OF_TWO,
|
|
178
|
+
`[dStorage] PasswordEncryptionAdapter: scrypt N must be a power of two >= 2 (got ${N}).`
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
if (N < MIN_SCRYPT_N) {
|
|
182
|
+
throw new DStorageError(
|
|
183
|
+
EncryptionErrorCode.PASSWORD_SCRYPT_N_TOO_LOW,
|
|
184
|
+
`[dStorage] PasswordEncryptionAdapter: scrypt N=${N} is below the minimum cost floor of ${MIN_SCRYPT_N} (OWASP 2024 minimum, 32 MB memory-hard). A lower N makes the KDF cheap enough to brute-force offline. Use a preset ("v1" or "v1-lite") or a custom N >= 32768.`
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
173
188
|
function resolveParams(preset, params) {
|
|
189
|
+
let resolved;
|
|
174
190
|
if (preset !== void 0) {
|
|
175
191
|
if (!(preset in KDF_PRESETS)) {
|
|
176
192
|
throw new DStorageError(
|
|
@@ -178,13 +194,16 @@ function resolveParams(preset, params) {
|
|
|
178
194
|
`[dStorage] PasswordEncryptionAdapter: unknown preset "${preset}". Valid presets: ${Object.keys(KDF_PRESETS).join(", ")}.`
|
|
179
195
|
);
|
|
180
196
|
}
|
|
181
|
-
|
|
197
|
+
resolved = KDF_PRESETS[preset];
|
|
198
|
+
} else {
|
|
199
|
+
resolved = {
|
|
200
|
+
N: params?.N ?? KDF_PRESETS["v1"].N,
|
|
201
|
+
r: params?.r ?? KDF_PRESETS["v1"].r,
|
|
202
|
+
p: params?.p ?? KDF_PRESETS["v1"].p
|
|
203
|
+
};
|
|
182
204
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
r: params?.r ?? KDF_PRESETS["v1"].r,
|
|
186
|
-
p: params?.p ?? KDF_PRESETS["v1"].p
|
|
187
|
-
};
|
|
205
|
+
assertScryptCost(resolved.N);
|
|
206
|
+
return resolved;
|
|
188
207
|
}
|
|
189
208
|
function estimateEntropyBits(password) {
|
|
190
209
|
let pool = 0;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EncryptionErrorCode
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-L6WCT64V.mjs";
|
|
4
4
|
import {
|
|
5
5
|
DStorageError,
|
|
6
6
|
deriveKek,
|
|
7
7
|
unwrapKey,
|
|
8
8
|
wrapKey
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-PCXBQRCO.mjs";
|
|
10
10
|
|
|
11
|
-
// ../encryption/dist/chunk-
|
|
11
|
+
// ../encryption/dist/chunk-ENX7VXEV.mjs
|
|
12
12
|
import { scrypt } from "@noble/hashes/scrypt.js";
|
|
13
13
|
var KDF_PRESETS = {
|
|
14
14
|
v1: { N: 131072, r: 8, p: 1 },
|
|
@@ -137,8 +137,8 @@ var PasswordEncryptionAdapter = class _PasswordEncryptionAdapter {
|
|
|
137
137
|
* @param variant ML-KEM variant. Default: "mlkem768".
|
|
138
138
|
*/
|
|
139
139
|
async intoKeypairEncryptionAdapter(context, variant) {
|
|
140
|
-
const { KeypairEncryptionAdapter } = await import("./KeypairEncryptionAdapter-
|
|
141
|
-
const { mlkemGenerateKeypairFromSeed } = await import("./dist-
|
|
140
|
+
const { KeypairEncryptionAdapter } = await import("./KeypairEncryptionAdapter-EOBRCIGP-FLPJIL26.mjs");
|
|
141
|
+
const { mlkemGenerateKeypairFromSeed } = await import("./dist-AGNOIJI4.mjs");
|
|
142
142
|
const kekMaterial = await this.kekMaterialPromise;
|
|
143
143
|
const mlkemBits = await globalThis.crypto.subtle.deriveBits(
|
|
144
144
|
{
|
|
@@ -170,7 +170,23 @@ function resolveSalt(salt) {
|
|
|
170
170
|
}
|
|
171
171
|
return bytes;
|
|
172
172
|
}
|
|
173
|
+
var MIN_SCRYPT_N = 32768;
|
|
174
|
+
function assertScryptCost(N) {
|
|
175
|
+
if (!Number.isInteger(N) || N < 2 || (N & N - 1) !== 0) {
|
|
176
|
+
throw new DStorageError(
|
|
177
|
+
EncryptionErrorCode.PASSWORD_SCRYPT_N_NOT_POWER_OF_TWO,
|
|
178
|
+
`[dStorage] PasswordEncryptionAdapter: scrypt N must be a power of two >= 2 (got ${N}).`
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
if (N < MIN_SCRYPT_N) {
|
|
182
|
+
throw new DStorageError(
|
|
183
|
+
EncryptionErrorCode.PASSWORD_SCRYPT_N_TOO_LOW,
|
|
184
|
+
`[dStorage] PasswordEncryptionAdapter: scrypt N=${N} is below the minimum cost floor of ${MIN_SCRYPT_N} (OWASP 2024 minimum, 32 MB memory-hard). A lower N makes the KDF cheap enough to brute-force offline. Use a preset ("v1" or "v1-lite") or a custom N >= 32768.`
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
173
188
|
function resolveParams(preset, params) {
|
|
189
|
+
let resolved;
|
|
174
190
|
if (preset !== void 0) {
|
|
175
191
|
if (!(preset in KDF_PRESETS)) {
|
|
176
192
|
throw new DStorageError(
|
|
@@ -178,13 +194,16 @@ function resolveParams(preset, params) {
|
|
|
178
194
|
`[dStorage] PasswordEncryptionAdapter: unknown preset "${preset}". Valid presets: ${Object.keys(KDF_PRESETS).join(", ")}.`
|
|
179
195
|
);
|
|
180
196
|
}
|
|
181
|
-
|
|
197
|
+
resolved = KDF_PRESETS[preset];
|
|
198
|
+
} else {
|
|
199
|
+
resolved = {
|
|
200
|
+
N: params?.N ?? KDF_PRESETS["v1"].N,
|
|
201
|
+
r: params?.r ?? KDF_PRESETS["v1"].r,
|
|
202
|
+
p: params?.p ?? KDF_PRESETS["v1"].p
|
|
203
|
+
};
|
|
182
204
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
r: params?.r ?? KDF_PRESETS["v1"].r,
|
|
186
|
-
p: params?.p ?? KDF_PRESETS["v1"].p
|
|
187
|
-
};
|
|
205
|
+
assertScryptCost(resolved.N);
|
|
206
|
+
return resolved;
|
|
188
207
|
}
|
|
189
208
|
function estimateEntropyBits(password) {
|
|
190
209
|
let pool = 0;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EncryptionErrorCode
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-L6WCT64V.mjs";
|
|
4
4
|
import {
|
|
5
5
|
DStorageError,
|
|
6
6
|
KeyDeriver,
|
|
7
7
|
deriveKek,
|
|
8
8
|
unwrapKey,
|
|
9
9
|
wrapKey
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-PCXBQRCO.mjs";
|
|
11
11
|
|
|
12
|
-
// ../encryption/dist/chunk-
|
|
12
|
+
// ../encryption/dist/chunk-SOX5GKK4.mjs
|
|
13
13
|
var MnemonicEncryptionAdapter = class {
|
|
14
14
|
constructor(input) {
|
|
15
15
|
this.name = "mnemonic";
|
|
@@ -73,8 +73,8 @@ var MnemonicEncryptionAdapter = class {
|
|
|
73
73
|
* @param variant ML-KEM variant. Default: "mlkem768".
|
|
74
74
|
*/
|
|
75
75
|
async intoKeypairEncryptionAdapter(context, variant) {
|
|
76
|
-
const { KeypairEncryptionAdapter } = await import("./KeypairEncryptionAdapter-
|
|
77
|
-
const { mlkemGenerateKeypairFromSeed } = await import("./dist-
|
|
76
|
+
const { KeypairEncryptionAdapter } = await import("./KeypairEncryptionAdapter-EOBRCIGP-5PFPNLLA.mjs");
|
|
77
|
+
const { mlkemGenerateKeypairFromSeed } = await import("./dist-J4JUJ2J5.mjs");
|
|
78
78
|
const kekMaterial = await this.kekMaterialPromise;
|
|
79
79
|
const mlkemBits = await globalThis.crypto.subtle.deriveBits(
|
|
80
80
|
{
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EncryptionErrorCode
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-L6WCT64V.mjs";
|
|
4
4
|
import {
|
|
5
5
|
DStorageError,
|
|
6
6
|
mlkemGenerateKeypair,
|
|
7
7
|
mlkemUnwrapDek,
|
|
8
8
|
mlkemWrapDek
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-PCXBQRCO.mjs";
|
|
10
10
|
|
|
11
|
-
// ../encryption/dist/chunk-
|
|
11
|
+
// ../encryption/dist/chunk-A7BIR2QB.mjs
|
|
12
12
|
var KeypairEncryptionAdapter = class _KeypairEncryptionAdapter {
|
|
13
13
|
constructor(pk, sk, context, variant) {
|
|
14
14
|
this.publicKey = pk;
|
|
@@ -64,7 +64,7 @@ var KeypairEncryptionAdapter = class _KeypairEncryptionAdapter {
|
|
|
64
64
|
* @param variant Default: "mlkem768"
|
|
65
65
|
*/
|
|
66
66
|
static async fromMnemonic(input, context, variant = "mlkem768") {
|
|
67
|
-
const { MnemonicEncryptionAdapter } = await import("./MnemonicEncryptionAdapter-
|
|
67
|
+
const { MnemonicEncryptionAdapter } = await import("./MnemonicEncryptionAdapter-S56YG63Q-B3F3TO3T.mjs");
|
|
68
68
|
const ms = new MnemonicEncryptionAdapter(input);
|
|
69
69
|
return ms.intoKeypairEncryptionAdapter(context, variant);
|
|
70
70
|
}
|
|
@@ -84,7 +84,7 @@ var KeypairEncryptionAdapter = class _KeypairEncryptionAdapter {
|
|
|
84
84
|
* @param params Optional custom scrypt params
|
|
85
85
|
*/
|
|
86
86
|
static async fromPassword(password, salt, context, variant = "mlkem768", params) {
|
|
87
|
-
const { PasswordEncryptionAdapter } = await import("./PasswordEncryptionAdapter-
|
|
87
|
+
const { PasswordEncryptionAdapter } = await import("./PasswordEncryptionAdapter-B2UG7MWB-QCSOIQJA.mjs");
|
|
88
88
|
const ps = new PasswordEncryptionAdapter({
|
|
89
89
|
password,
|
|
90
90
|
salt,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../encryption/dist/chunk-
|
|
1
|
+
// ../encryption/dist/chunk-AGSZ3S6J.mjs
|
|
2
2
|
var EncryptionErrorCode = {
|
|
3
3
|
KEYPAIR_MISSING_SECRET_KEY: 13001,
|
|
4
4
|
MNEMONIC_TOO_SHORT: 13002,
|
|
@@ -9,7 +9,9 @@ var EncryptionErrorCode = {
|
|
|
9
9
|
PASSWORD_TOO_FEW_DISTINCT: 13007,
|
|
10
10
|
PASSWORD_SEQUENTIAL_RUN: 13008,
|
|
11
11
|
PASSWORD_KEYBOARD_WALK: 13009,
|
|
12
|
-
PASSWORD_ENTROPY_TOO_LOW: 13010
|
|
12
|
+
PASSWORD_ENTROPY_TOO_LOW: 13010,
|
|
13
|
+
PASSWORD_SCRYPT_N_TOO_LOW: 13011,
|
|
14
|
+
PASSWORD_SCRYPT_N_NOT_POWER_OF_TWO: 13012
|
|
13
15
|
};
|
|
14
16
|
|
|
15
17
|
export {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../chain/dist/chunk-
|
|
1
|
+
// ../chain/dist/chunk-XMWGGIPS.mjs
|
|
2
2
|
var ChainErrorCode = {
|
|
3
3
|
// mock.ts — 11001-11009
|
|
4
4
|
MOCK_REF_NOT_FOUND: 11001,
|
|
@@ -21,6 +21,8 @@ var ChainErrorCode = {
|
|
|
21
21
|
GATEWAY_LIST_NOT_ARRAY: 11212,
|
|
22
22
|
GATEWAY_REMOVE_FAILED: 11213,
|
|
23
23
|
GATEWAY_REMOVE_HTTP_ERROR: 11214,
|
|
24
|
+
GATEWAY_READ_RESPONSE_TOO_LARGE: 11215,
|
|
25
|
+
GATEWAY_LIST_RESPONSE_TOO_LARGE: 11216,
|
|
24
26
|
// contract-api.ts — 11401-11409
|
|
25
27
|
CONTRACT_UNSUPPORTED_VERSION: 11401,
|
|
26
28
|
CONTRACT_CIRCUIT_RESULT_MISSING: 11402,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../chain/dist/chunk-
|
|
1
|
+
// ../chain/dist/chunk-GNG6TMQC.mjs
|
|
2
2
|
var ChainErrorCode = {
|
|
3
3
|
// mock.ts — 11001-11009
|
|
4
4
|
MOCK_REF_NOT_FOUND: 11001,
|
|
@@ -21,6 +21,8 @@ var ChainErrorCode = {
|
|
|
21
21
|
GATEWAY_LIST_NOT_ARRAY: 11212,
|
|
22
22
|
GATEWAY_REMOVE_FAILED: 11213,
|
|
23
23
|
GATEWAY_REMOVE_HTTP_ERROR: 11214,
|
|
24
|
+
GATEWAY_READ_RESPONSE_TOO_LARGE: 11215,
|
|
25
|
+
GATEWAY_LIST_RESPONSE_TOO_LARGE: 11216,
|
|
24
26
|
// contract-api.ts — 11401-11409
|
|
25
27
|
CONTRACT_UNSUPPORTED_VERSION: 11401,
|
|
26
28
|
CONTRACT_CIRCUIT_RESULT_MISSING: 11402,
|