@ibgib/core-gib 0.1.42 → 0.1.44
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/dist/keystone/kdf/kdf-constants.d.mts +25 -0
- package/dist/keystone/kdf/kdf-constants.d.mts.map +1 -0
- package/dist/keystone/kdf/kdf-constants.mjs +28 -0
- package/dist/keystone/kdf/kdf-constants.mjs.map +1 -0
- package/dist/keystone/kdf/kdf-helpers.d.mts +45 -0
- package/dist/keystone/kdf/kdf-helpers.d.mts.map +1 -0
- package/dist/keystone/kdf/kdf-helpers.mjs +94 -0
- package/dist/keystone/kdf/kdf-helpers.mjs.map +1 -0
- package/dist/keystone/kdf/kdf-types.d.mts +49 -0
- package/dist/keystone/kdf/kdf-types.d.mts.map +1 -0
- package/dist/keystone/kdf/kdf-types.mjs +2 -0
- package/dist/keystone/kdf/kdf-types.mjs.map +1 -0
- package/dist/keystone/keystone-config-builder.d.mts +65 -12
- package/dist/keystone/keystone-config-builder.d.mts.map +1 -1
- package/dist/keystone/keystone-config-builder.mjs +138 -46
- package/dist/keystone/keystone-config-builder.mjs.map +1 -1
- package/dist/keystone/keystone-config-builder.respec.mjs +21 -13
- package/dist/keystone/keystone-config-builder.respec.mjs.map +1 -1
- package/dist/keystone/keystone-constants.d.mts +15 -0
- package/dist/keystone/keystone-constants.d.mts.map +1 -1
- package/dist/keystone/keystone-constants.mjs +16 -0
- package/dist/keystone/keystone-constants.mjs.map +1 -1
- package/dist/keystone/keystone-helpers.d.mts +4 -4
- package/dist/keystone/keystone-helpers.d.mts.map +1 -1
- package/dist/keystone/keystone-helpers.mjs +8 -5
- package/dist/keystone/keystone-helpers.mjs.map +1 -1
- package/dist/keystone/keystone-service-v1.d.mts +1 -1
- package/dist/keystone/keystone-service-v1.d.mts.map +1 -1
- package/dist/keystone/keystone-service-v1.mjs +6 -5
- package/dist/keystone/keystone-service-v1.mjs.map +1 -1
- package/dist/keystone/keystone-service-v1.respec.mjs +72 -45
- package/dist/keystone/keystone-service-v1.respec.mjs.map +1 -1
- package/dist/keystone/keystone-types.d.mts +28 -18
- package/dist/keystone/keystone-types.d.mts.map +1 -1
- package/dist/keystone/keystone-types.mjs +26 -15
- package/dist/keystone/keystone-types.mjs.map +1 -1
- package/dist/keystone/strategy/hash-reveal-v1/hash-reveal-v1.d.mts.map +1 -1
- package/dist/keystone/strategy/hash-reveal-v1/hash-reveal-v1.mjs +7 -10
- package/dist/keystone/strategy/hash-reveal-v1/hash-reveal-v1.mjs.map +1 -1
- package/dist/sync/sync-conflict-text-merge.respec.mjs +26 -26
- package/dist/sync/sync-conflict-text-merge.respec.mjs.map +1 -1
- package/dist/sync/sync-constants.d.mts +9 -0
- package/dist/sync/sync-constants.d.mts.map +1 -1
- package/dist/sync/sync-constants.mjs +10 -0
- package/dist/sync/sync-constants.mjs.map +1 -1
- package/dist/sync/sync-innerspace-dest-ahead-withid.respec.d.mts +7 -0
- package/dist/sync/sync-innerspace-dest-ahead-withid.respec.d.mts.map +1 -0
- package/dist/sync/sync-innerspace-dest-ahead-withid.respec.mjs +282 -0
- package/dist/sync/sync-innerspace-dest-ahead-withid.respec.mjs.map +1 -0
- package/dist/sync/sync-saga-coordinator.d.mts +22 -11
- package/dist/sync/sync-saga-coordinator.d.mts.map +1 -1
- package/dist/sync/sync-saga-coordinator.mjs +120 -27
- package/dist/sync/sync-saga-coordinator.mjs.map +1 -1
- package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts +1 -7
- package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts.map +1 -1
- package/dist/sync/sync-types.d.mts +11 -0
- package/dist/sync/sync-types.d.mts.map +1 -1
- package/dist/sync/sync-types.mjs.map +1 -1
- package/dist/test/mock-space.d.mts +1 -38
- package/dist/test/mock-space.d.mts.map +1 -1
- package/dist/test/mock-space.mjs +73 -78
- package/dist/test/mock-space.mjs.map +1 -1
- package/package.json +1 -1
- package/src/keystone/README.md +119 -0
- package/src/keystone/docs/architecture.md +32 -1
- package/src/keystone/kdf/kdf-constants.mts +34 -0
- package/src/keystone/kdf/kdf-helpers.mts +105 -0
- package/src/keystone/kdf/kdf-types.mts +58 -0
- package/src/keystone/keystone-config-builder.mts +170 -47
- package/src/keystone/keystone-config-builder.respec.mts +21 -14
- package/src/keystone/keystone-constants.mts +21 -2
- package/src/keystone/keystone-helpers.mts +19 -14
- package/src/keystone/keystone-service-v1.mts +23 -22
- package/src/keystone/keystone-service-v1.respec.mts +71 -44
- package/src/keystone/keystone-types.mts +37 -23
- package/src/keystone/strategy/hash-reveal-v1/hash-reveal-v1.mts +9 -13
- package/src/sync/README.md +122 -5
- package/src/sync/docs/architecture.md +2 -2
- package/src/sync/{SYNC_TESTING.md → docs/testing.md} +113 -28
- package/src/sync/sync-conflict-text-merge.respec.mts +25 -25
- package/src/sync/sync-constants.mts +12 -0
- package/src/sync/sync-innerspace-dest-ahead-withid.respec.mts +349 -0
- package/src/sync/sync-saga-coordinator.mts +158 -33
- package/src/sync/sync-saga-message/sync-saga-message-types.mts +1 -7
- package/src/sync/sync-types.mts +12 -0
- package/src/test/mock-space.mts +72 -72
- package/tmp.md +0 -274
- package/src/sync/docs/verification.md +0 -43
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KDF Strategy Constants
|
|
3
|
+
*
|
|
4
|
+
* Defines available key derivation function strategies.
|
|
5
|
+
*/
|
|
6
|
+
export declare const KDF_STRATEGY_RECURSIVE_SALT_WRAP = "recursive-salt-wrap";
|
|
7
|
+
export type KdfStrategy = typeof KDF_STRATEGY_RECURSIVE_SALT_WRAP;
|
|
8
|
+
/**
|
|
9
|
+
* Available KDF strategies for deriving keys from master secrets.
|
|
10
|
+
*
|
|
11
|
+
* - `recursive-salt-wrap`: Hash(salt + current + salt) ^ rounds
|
|
12
|
+
* Used by KeystoneStrategy_HashRevealV1 for pool secret derivation
|
|
13
|
+
*/
|
|
14
|
+
export declare const KdfStrategy: {
|
|
15
|
+
/**
|
|
16
|
+
* Recursive salt wrap strategy: Hash(salt + current + salt) ^ rounds
|
|
17
|
+
*
|
|
18
|
+
* This is the primary strategy used by keystones for deriving pool secrets
|
|
19
|
+
* from master secrets with configurable rounds for key stretching.
|
|
20
|
+
*/
|
|
21
|
+
recursive_salt_wrap: "recursive-salt-wrap";
|
|
22
|
+
};
|
|
23
|
+
export declare const KDF_STRATEGY_VALID_VALUES: "recursive-salt-wrap"[];
|
|
24
|
+
export declare function isValidKdfStrategy(strategy: string): strategy is KdfStrategy;
|
|
25
|
+
//# sourceMappingURL=kdf-constants.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kdf-constants.d.mts","sourceRoot":"","sources":["../../../src/keystone/kdf/kdf-constants.mts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,eAAO,MAAM,gCAAgC,wBAAwB,CAAC;AACtE,MAAM,MAAM,WAAW,GACjB,OAAO,gCAAgC,CACxC;AAEL;;;;;GAKG;AACH,eAAO,MAAM,WAAW;IACpB;;;;;OAKG;;CAEmC,CAAC;AAE3C,eAAO,MAAM,yBAAyB,yBAA6B,CAAC;AAEpE,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,IAAI,WAAW,CAE5E"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KDF Strategy Constants
|
|
3
|
+
*
|
|
4
|
+
* Defines available key derivation function strategies.
|
|
5
|
+
*/
|
|
6
|
+
// #region KdfStrategy
|
|
7
|
+
export const KDF_STRATEGY_RECURSIVE_SALT_WRAP = 'recursive-salt-wrap';
|
|
8
|
+
/**
|
|
9
|
+
* Available KDF strategies for deriving keys from master secrets.
|
|
10
|
+
*
|
|
11
|
+
* - `recursive-salt-wrap`: Hash(salt + current + salt) ^ rounds
|
|
12
|
+
* Used by KeystoneStrategy_HashRevealV1 for pool secret derivation
|
|
13
|
+
*/
|
|
14
|
+
export const KdfStrategy = {
|
|
15
|
+
/**
|
|
16
|
+
* Recursive salt wrap strategy: Hash(salt + current + salt) ^ rounds
|
|
17
|
+
*
|
|
18
|
+
* This is the primary strategy used by keystones for deriving pool secrets
|
|
19
|
+
* from master secrets with configurable rounds for key stretching.
|
|
20
|
+
*/
|
|
21
|
+
recursive_salt_wrap: KDF_STRATEGY_RECURSIVE_SALT_WRAP,
|
|
22
|
+
};
|
|
23
|
+
export const KDF_STRATEGY_VALID_VALUES = Object.values(KdfStrategy);
|
|
24
|
+
export function isValidKdfStrategy(strategy) {
|
|
25
|
+
return KDF_STRATEGY_VALID_VALUES.includes(strategy);
|
|
26
|
+
}
|
|
27
|
+
// #endregion KdfStrategy
|
|
28
|
+
//# sourceMappingURL=kdf-constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kdf-constants.mjs","sourceRoot":"","sources":["../../../src/keystone/kdf/kdf-constants.mts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,sBAAsB;AACtB,MAAM,CAAC,MAAM,gCAAgC,GAAG,qBAAqB,CAAC;AAKtE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACvB;;;;;OAKG;IACH,mBAAmB,EAAE,gCAAgC;CACf,CAAC;AAE3C,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAEpE,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IAC/C,OAAO,yBAAyB,CAAC,QAAQ,CAAC,QAAuB,CAAC,CAAC;AACvE,CAAC;AACD,yBAAyB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { HashAlgorithm } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
2
|
+
import { DeriveKeyParams } from './kdf-types.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* Derive a key from a master secret using the specified KDF strategy
|
|
5
|
+
*
|
|
6
|
+
* This is the main dispatch function for all KDF operations. It routes to the
|
|
7
|
+
* appropriate strategy implementation based on `kdfOpts.strategy`.
|
|
8
|
+
*
|
|
9
|
+
* @param params - Derivation parameters including master secret and KDF options
|
|
10
|
+
* @returns Derived key
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const derivedKey = await deriveKey({
|
|
15
|
+
* masterSecret: 'my-strong-password',
|
|
16
|
+
* kdfOpts: {
|
|
17
|
+
* strategy: KdfStrategy.recursiveSaltWrap,
|
|
18
|
+
* salt: 'pool-identifier',
|
|
19
|
+
* rounds: 10000,
|
|
20
|
+
* algorithm: 'SHA-256'
|
|
21
|
+
* }
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function deriveKey({ masterSecret, kdfOpts }: DeriveKeyParams): Promise<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Recursive Salt Wrap KDF Strategy
|
|
28
|
+
*
|
|
29
|
+
* Derives a key by recursively applying: Hash(salt + current + salt) for N rounds
|
|
30
|
+
*
|
|
31
|
+
* This is the strategy used by KeystoneStrategy_HashRevealV1 for deriving pool secrets.
|
|
32
|
+
*
|
|
33
|
+
* @param masterSecret - The initial secret/password to derive from
|
|
34
|
+
* @param salt - Salt value to wrap around the secret
|
|
35
|
+
* @param rounds - Number of hash iterations (key stretching)
|
|
36
|
+
* @param algorithm - Hash algorithm to use (default: SHA-256)
|
|
37
|
+
* @returns Derived key
|
|
38
|
+
*/
|
|
39
|
+
export declare function kdf_recursiveSaltWrap({ masterSecret, salt, rounds, algorithm, }: {
|
|
40
|
+
masterSecret: string;
|
|
41
|
+
salt: string;
|
|
42
|
+
rounds: number;
|
|
43
|
+
algorithm?: HashAlgorithm;
|
|
44
|
+
}): Promise<string>;
|
|
45
|
+
//# sourceMappingURL=kdf-helpers.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kdf-helpers.d.mts","sourceRoot":"","sources":["../../../src/keystone/kdf/kdf-helpers.mts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAIvG,OAAO,EAAE,eAAe,EAAgC,MAAM,iBAAiB,CAAC;AAIhF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,SAAS,CAAC,EAC5B,YAAY,EACZ,OAAO,EACV,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAyBnC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CAAC,EACxC,YAAY,EACZ,IAAI,EACJ,MAAM,EACN,SAAiC,GACpC,EAAE;IACC,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,aAAa,CAAC;CAC7B,GAAG,OAAO,CAAC,MAAM,CAAC,CAqBlB"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { extractErrorMsg, hash, HashAlgorithm } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
2
|
+
import { GLOBAL_LOG_A_LOT } from '../../core-constants.mjs';
|
|
3
|
+
import { KDF_STRATEGY_VALID_VALUES, KdfStrategy } from './kdf-constants.mjs';
|
|
4
|
+
const logalot = GLOBAL_LOG_A_LOT;
|
|
5
|
+
/**
|
|
6
|
+
* Derive a key from a master secret using the specified KDF strategy
|
|
7
|
+
*
|
|
8
|
+
* This is the main dispatch function for all KDF operations. It routes to the
|
|
9
|
+
* appropriate strategy implementation based on `kdfOpts.strategy`.
|
|
10
|
+
*
|
|
11
|
+
* @param params - Derivation parameters including master secret and KDF options
|
|
12
|
+
* @returns Derived key
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const derivedKey = await deriveKey({
|
|
17
|
+
* masterSecret: 'my-strong-password',
|
|
18
|
+
* kdfOpts: {
|
|
19
|
+
* strategy: KdfStrategy.recursiveSaltWrap,
|
|
20
|
+
* salt: 'pool-identifier',
|
|
21
|
+
* rounds: 10000,
|
|
22
|
+
* algorithm: 'SHA-256'
|
|
23
|
+
* }
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export async function deriveKey({ masterSecret, kdfOpts }) {
|
|
28
|
+
const lc = `[${deriveKey.name}]`;
|
|
29
|
+
try {
|
|
30
|
+
if (logalot) {
|
|
31
|
+
console.log(`${lc} starting... (I: 268e87ec311874ee6822bf459c5a5426)`);
|
|
32
|
+
}
|
|
33
|
+
const strategy = kdfOpts.strategy;
|
|
34
|
+
switch (strategy) {
|
|
35
|
+
case KdfStrategy['recursive-salt-wrap']:
|
|
36
|
+
return await kdf_recursiveSaltWrap({
|
|
37
|
+
masterSecret,
|
|
38
|
+
salt: kdfOpts.salt,
|
|
39
|
+
rounds: kdfOpts.rounds,
|
|
40
|
+
algorithm: kdfOpts.algorithm
|
|
41
|
+
});
|
|
42
|
+
default:
|
|
43
|
+
throw new Error(`Unknown KDF strategy: ${strategy}. valid values: ${KDF_STRATEGY_VALID_VALUES.join(', ')} (E: a1b2c3d4e5f6g7h8i9j0)`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
if (logalot) {
|
|
52
|
+
console.log(`${lc} complete.`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Recursive Salt Wrap KDF Strategy
|
|
58
|
+
*
|
|
59
|
+
* Derives a key by recursively applying: Hash(salt + current + salt) for N rounds
|
|
60
|
+
*
|
|
61
|
+
* This is the strategy used by KeystoneStrategy_HashRevealV1 for deriving pool secrets.
|
|
62
|
+
*
|
|
63
|
+
* @param masterSecret - The initial secret/password to derive from
|
|
64
|
+
* @param salt - Salt value to wrap around the secret
|
|
65
|
+
* @param rounds - Number of hash iterations (key stretching)
|
|
66
|
+
* @param algorithm - Hash algorithm to use (default: SHA-256)
|
|
67
|
+
* @returns Derived key
|
|
68
|
+
*/
|
|
69
|
+
export async function kdf_recursiveSaltWrap({ masterSecret, salt, rounds, algorithm = HashAlgorithm.sha_256, }) {
|
|
70
|
+
const lc = `[${kdf_recursiveSaltWrap.name}]`;
|
|
71
|
+
try {
|
|
72
|
+
if (logalot) {
|
|
73
|
+
console.log(`${lc} starting... (I: 850868e50aba82ff28c77da8169e4c26)`);
|
|
74
|
+
}
|
|
75
|
+
let current = masterSecret;
|
|
76
|
+
for (let i = 0; i < rounds; i++) {
|
|
77
|
+
current = await hash({
|
|
78
|
+
s: `${salt}${current}${salt}`,
|
|
79
|
+
algorithm
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return current;
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
if (logalot) {
|
|
90
|
+
console.log(`${lc} complete.`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=kdf-helpers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kdf-helpers.mjs","sourceRoot":"","sources":["../../../src/keystone/kdf/kdf-helpers.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAEvG,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAoC,yBAAyB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAG/G,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,EAC5B,YAAY,EACZ,OAAO,EACO;IACd,MAAM,EAAE,GAAG,IAAI,SAAS,CAAC,IAAI,GAAG,CAAC;IACjC,IAAI,CAAC;QACD,IAAI,OAAO,EAAE,CAAC;YAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,oDAAoD,CAAC,CAAC;QAAC,CAAC;QAExF,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QAElC,QAAQ,QAAQ,EAAE,CAAC;YACf,KAAK,WAAW,CAAC,qBAAqB,CAAC;gBACnC,OAAO,MAAM,qBAAqB,CAAC;oBAC/B,YAAY;oBACZ,IAAI,EAAE,OAAO,CAAC,IAAI;oBAClB,MAAM,EAAE,OAAO,CAAC,MAAM;oBACtB,SAAS,EAAE,OAAO,CAAC,SAAS;iBAC/B,CAAC,CAAC;YACP;gBACI,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,mBAAmB,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QAC9I,CAAC;IAEL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjD,MAAM,KAAK,CAAC;IAChB,CAAC;YAAS,CAAC;QACP,IAAI,OAAO,EAAE,CAAC;YAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAAC,CAAC;IACpD,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,EACxC,YAAY,EACZ,IAAI,EACJ,MAAM,EACN,SAAS,GAAG,aAAa,CAAC,OAAO,GAMpC;IACG,MAAM,EAAE,GAAG,IAAI,qBAAqB,CAAC,IAAI,GAAG,CAAC;IAC7C,IAAI,CAAC;QACD,IAAI,OAAO,EAAE,CAAC;YAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,oDAAoD,CAAC,CAAC;QAAC,CAAC;QAExF,IAAI,OAAO,GAAG,YAAY,CAAC;QAE3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC9B,OAAO,GAAG,MAAM,IAAI,CAAC;gBACjB,CAAC,EAAE,GAAG,IAAI,GAAG,OAAO,GAAG,IAAI,EAAE;gBAC7B,SAAS;aACZ,CAAC,CAAC;QACP,CAAC;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjD,MAAM,KAAK,CAAC;IAChB,CAAC;YAAS,CAAC;QACP,IAAI,OAAO,EAAE,CAAC;YAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAAC,CAAC;IACpD,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { HashAlgorithm } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
2
|
+
import { KdfStrategy } from './kdf-constants.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* Base options for all KDF strategies
|
|
5
|
+
*/
|
|
6
|
+
export interface KdfOptionsBase {
|
|
7
|
+
/**
|
|
8
|
+
* Name of the KDF strategy to use
|
|
9
|
+
*/
|
|
10
|
+
strategy: KdfStrategy;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Options for recursive-salt-wrap KDF strategy
|
|
14
|
+
*
|
|
15
|
+
* Derives key by recursively applying: Hash(salt + current + salt) for N rounds
|
|
16
|
+
*/
|
|
17
|
+
export interface KdfOptions_RecursiveSaltWrap extends KdfOptionsBase {
|
|
18
|
+
strategy: typeof import('./kdf-constants.mjs').KDF_STRATEGY_RECURSIVE_SALT_WRAP;
|
|
19
|
+
/**
|
|
20
|
+
* Salt value to wrap around the secret during each iteration
|
|
21
|
+
*/
|
|
22
|
+
salt: string;
|
|
23
|
+
/**
|
|
24
|
+
* Number of hash iterations for key stretching
|
|
25
|
+
*/
|
|
26
|
+
rounds: number;
|
|
27
|
+
/**
|
|
28
|
+
* Hash algorithm to use (default: SHA-256)
|
|
29
|
+
*/
|
|
30
|
+
algorithm?: HashAlgorithm;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Union of all KDF option types
|
|
34
|
+
*/
|
|
35
|
+
export type KdfOptions = KdfOptions_RecursiveSaltWrap;
|
|
36
|
+
/**
|
|
37
|
+
* Parameters for deriving a key using KDF
|
|
38
|
+
*/
|
|
39
|
+
export interface DeriveKeyParams {
|
|
40
|
+
/**
|
|
41
|
+
* The initial secret/password to derive from
|
|
42
|
+
*/
|
|
43
|
+
masterSecret: string;
|
|
44
|
+
/**
|
|
45
|
+
* KDF options specifying strategy and strategy-specific parameters
|
|
46
|
+
*/
|
|
47
|
+
kdfOpts: KdfOptions;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=kdf-types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kdf-types.d.mts","sourceRoot":"","sources":["../../../src/keystone/kdf/kdf-types.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B;;OAEG;IACH,QAAQ,EAAE,WAAW,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,4BAA6B,SAAQ,cAAc;IAChE,QAAQ,EAAE,cAAc,qBAAqB,EAAE,gCAAgC,CAAC;IAEhF;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAChB,4BAA4B,CAC7B;AAEL;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,OAAO,EAAE,UAAU,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kdf-types.mjs","sourceRoot":"","sources":["../../../src/keystone/kdf/kdf-types.mts"],"names":[],"mappings":""}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { HashAlgorithm } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
1
2
|
import { KeystonePoolConfig, KeystonePoolConfig_HashV1, KeystonePoolBehavior, KeystoneReplenishStrategy, KeystonePoolConfigBase } from './keystone-types.mjs';
|
|
2
3
|
/**
|
|
3
4
|
* Abstract Base Builder.
|
|
@@ -6,15 +7,20 @@ import { KeystonePoolConfig, KeystonePoolConfig_HashV1, KeystonePoolBehavior, Ke
|
|
|
6
7
|
* @template TConfig The concrete config type being built.
|
|
7
8
|
*/
|
|
8
9
|
export declare abstract class KeystoneConfigBuilderBase<TConfig extends KeystonePoolConfigBase> {
|
|
9
|
-
protected
|
|
10
|
-
protected
|
|
11
|
-
protected
|
|
12
|
-
protected
|
|
13
|
-
protected
|
|
10
|
+
protected _id: string | undefined;
|
|
11
|
+
protected _salt: string | undefined;
|
|
12
|
+
protected _size: number | undefined;
|
|
13
|
+
protected _replenish: KeystoneReplenishStrategy | undefined;
|
|
14
|
+
protected _seq: number | undefined;
|
|
15
|
+
protected _rand: number | undefined;
|
|
14
16
|
protected _verbs: string[];
|
|
15
|
-
protected _targetBinding: number;
|
|
17
|
+
protected _targetBinding: number | undefined;
|
|
16
18
|
/**
|
|
17
|
-
* Sets the unique
|
|
19
|
+
* Sets the unique id for this pool.
|
|
20
|
+
*/
|
|
21
|
+
withId(id: string): this;
|
|
22
|
+
/**
|
|
23
|
+
* Sets the unique salt for this pool.
|
|
18
24
|
*/
|
|
19
25
|
withSalt(salt: string): this;
|
|
20
26
|
/**
|
|
@@ -39,7 +45,10 @@ export declare abstract class KeystoneConfigBuilderBase<TConfig extends Keystone
|
|
|
39
45
|
/**
|
|
40
46
|
* Configures the pool to use Hybrid (Both FIFO and Random) selection.
|
|
41
47
|
*/
|
|
42
|
-
withHybrid(seqCount
|
|
48
|
+
withHybrid({ seqCount, randCount }: {
|
|
49
|
+
seqCount: number;
|
|
50
|
+
randCount: number;
|
|
51
|
+
}): this;
|
|
43
52
|
/**
|
|
44
53
|
* Sets the replenishment strategy.
|
|
45
54
|
*/
|
|
@@ -54,24 +63,68 @@ export declare abstract class KeystoneConfigBuilderBase<TConfig extends Keystone
|
|
|
54
63
|
* @param verbs List of verb addresses (e.g. 'revoke^gib')
|
|
55
64
|
*/
|
|
56
65
|
forVerbs(verbs: string[]): this;
|
|
57
|
-
protected buildBase(): KeystonePoolConfigBase;
|
|
58
66
|
abstract build(): TConfig;
|
|
59
67
|
}
|
|
60
68
|
/**
|
|
61
69
|
* Concrete Builder for Hash-Reveal V1 Strategy.
|
|
62
70
|
*/
|
|
63
71
|
export declare class KeystoneConfigBuilder_HashV1 extends KeystoneConfigBuilderBase<KeystonePoolConfig_HashV1> {
|
|
72
|
+
protected lc: string;
|
|
64
73
|
private _algo;
|
|
65
74
|
private _rounds;
|
|
66
75
|
/**
|
|
67
76
|
* Sets the hashing strength.
|
|
68
77
|
*/
|
|
69
|
-
withHash(algo
|
|
78
|
+
withHash({ algo, rounds }: {
|
|
79
|
+
algo: HashAlgorithm;
|
|
80
|
+
rounds: number;
|
|
81
|
+
}): this;
|
|
70
82
|
build(): KeystonePoolConfig_HashV1;
|
|
71
83
|
}
|
|
72
84
|
export declare class KeystoneConfig {
|
|
73
85
|
static hash(): KeystoneConfigBuilder_HashV1;
|
|
74
86
|
}
|
|
75
|
-
|
|
76
|
-
|
|
87
|
+
interface KeystoneConfigFactoryOptions_Standard {
|
|
88
|
+
/**
|
|
89
|
+
* id for pool that this config pertains to
|
|
90
|
+
*/
|
|
91
|
+
id: string;
|
|
92
|
+
/**
|
|
93
|
+
* should be a unique string
|
|
94
|
+
*/
|
|
95
|
+
salt: string;
|
|
96
|
+
/**
|
|
97
|
+
* number of challenges in the pool
|
|
98
|
+
* @see {@link KeystonePoolConfig}
|
|
99
|
+
*/
|
|
100
|
+
size?: number;
|
|
101
|
+
/**
|
|
102
|
+
* number of sequential challenges required for solution per action
|
|
103
|
+
*/
|
|
104
|
+
sequential?: number;
|
|
105
|
+
/**
|
|
106
|
+
* number of random challenges required for solution per action
|
|
107
|
+
*/
|
|
108
|
+
random?: number;
|
|
109
|
+
/**
|
|
110
|
+
* number of target binding characters required for solution per action
|
|
111
|
+
* @see {@link KeystonePoolBehavior.targetBindingChars}
|
|
112
|
+
*/
|
|
113
|
+
targetBinding?: number;
|
|
114
|
+
/**
|
|
115
|
+
* @see {@link KeystonePoolBehavior.replenish}
|
|
116
|
+
*/
|
|
117
|
+
replenishStrategy?: KeystoneReplenishStrategy;
|
|
118
|
+
/**
|
|
119
|
+
* verbs for the pool
|
|
120
|
+
*/
|
|
121
|
+
verbs?: string[];
|
|
122
|
+
hashAlgorithm?: HashAlgorithm;
|
|
123
|
+
hashRounds?: number;
|
|
124
|
+
}
|
|
125
|
+
export declare function createStandardPoolConfig(opts: KeystoneConfigFactoryOptions_Standard): KeystonePoolConfig;
|
|
126
|
+
export declare function createHighSecurityPoolConfig(opts: KeystoneConfigFactoryOptions_Standard): KeystonePoolConfig;
|
|
127
|
+
export declare function createManagePoolConfig(opts: KeystoneConfigFactoryOptions_Standard): KeystonePoolConfig;
|
|
128
|
+
export declare function createRevocationPoolConfig(opts: KeystoneConfigFactoryOptions_Standard): KeystonePoolConfig;
|
|
129
|
+
export {};
|
|
77
130
|
//# sourceMappingURL=keystone-config-builder.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keystone-config-builder.d.mts","sourceRoot":"","sources":["../../src/keystone/keystone-config-builder.mts"],"names":[],"mappings":"AAAA,OAAO,EACH,kBAAkB,
|
|
1
|
+
{"version":3,"file":"keystone-config-builder.d.mts","sourceRoot":"","sources":["../../src/keystone/keystone-config-builder.mts"],"names":[],"mappings":"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"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
2
|
+
import { GLOBAL_LOG_A_LOT } from '../core-constants.mjs';
|
|
3
|
+
import { KeystoneReplenishStrategy, KeystoneChallengeType, } from './keystone-types.mjs';
|
|
4
|
+
import { KEYSTONE_CONFIG_DEFAULT_SIZE, KEYSTONE_CONFIG_DEFAULT_BINDING, KEYSTONE_CONFIG_DEFAULT_REPLENISH_STRATEGY, KEYSTONE_CONFIG_DEFAULT_SEQUENTIAL, KEYSTONE_CONFIG_DEFAULT_RANDOM, KEYSTONE_CONFIG_DEFAULT_SIZE_HIGHSECURITY, KEYSTONE_CONFIG_DEFAULT_SEQUENTIAL_HIGHSECURITY, KEYSTONE_CONFIG_DEFAULT_RANDOM_HIGHSECURITY, KEYSTONE_CONFIG_DEFAULT_BINDING_HIGHSECURITY, KEYSTONE_CONFIG_DEFAULT_REPLENISH_STRATEGY_HIGHSECURITY, KeystoneVerb, KEYSTONE_CONFIG_DEFAULT_HASH_ALGORITHM, KEYSTONE_CONFIG_DEFAULT_HASH_ROUNDS, KEYSTONE_CONFIG_DEFAULT_HASH_ALGORITHM_HIGHSECURITY, KEYSTONE_CONFIG_DEFAULT_HASH_ROUNDS_HIGHSECURITY } from './keystone-constants.mjs';
|
|
5
|
+
const logalot = GLOBAL_LOG_A_LOT;
|
|
3
6
|
/**
|
|
4
7
|
* Abstract Base Builder.
|
|
5
8
|
* Handles configuration common to ALL strategies (Salt, Size, Replenishment, Selection).
|
|
@@ -7,15 +10,23 @@ import { POOL_ID_DEFAULT, POOL_ID_REVOKE, KEYSTONE_VERB_REVOKE } from './keyston
|
|
|
7
10
|
* @template TConfig The concrete config type being built.
|
|
8
11
|
*/
|
|
9
12
|
export class KeystoneConfigBuilderBase {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
_id;
|
|
14
|
+
_salt;
|
|
15
|
+
_size;
|
|
16
|
+
_replenish;
|
|
17
|
+
_seq;
|
|
18
|
+
_rand;
|
|
15
19
|
_verbs = [];
|
|
16
|
-
_targetBinding
|
|
20
|
+
_targetBinding;
|
|
17
21
|
/**
|
|
18
|
-
* Sets the unique
|
|
22
|
+
* Sets the unique id for this pool.
|
|
23
|
+
*/
|
|
24
|
+
withId(id) {
|
|
25
|
+
this._id = id;
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Sets the unique salt for this pool.
|
|
19
30
|
*/
|
|
20
31
|
withSalt(salt) {
|
|
21
32
|
this._salt = salt;
|
|
@@ -57,7 +68,7 @@ export class KeystoneConfigBuilderBase {
|
|
|
57
68
|
/**
|
|
58
69
|
* Configures the pool to use Hybrid (Both FIFO and Random) selection.
|
|
59
70
|
*/
|
|
60
|
-
withHybrid(seqCount, randCount) {
|
|
71
|
+
withHybrid({ seqCount, randCount }) {
|
|
61
72
|
this._seq = seqCount;
|
|
62
73
|
this._rand = randCount;
|
|
63
74
|
return this;
|
|
@@ -74,6 +85,21 @@ export class KeystoneConfigBuilderBase {
|
|
|
74
85
|
* Helper for subclasses.
|
|
75
86
|
*/
|
|
76
87
|
buildBehavior() {
|
|
88
|
+
if (this._size === undefined) {
|
|
89
|
+
throw new Error(`size required (E: 68320865d9adb8477836485b20b08826)`);
|
|
90
|
+
}
|
|
91
|
+
if (this._replenish === undefined) {
|
|
92
|
+
throw new Error(`replenish strategy required (E: 9f8798d1a568763a282e53c89185b826)`);
|
|
93
|
+
}
|
|
94
|
+
if (this._seq === undefined) {
|
|
95
|
+
throw new Error(`sequential required (E: e0da08a24e9790d0a8c1a9322f8eb826)`);
|
|
96
|
+
}
|
|
97
|
+
if (this._rand === undefined) {
|
|
98
|
+
throw new Error(`selectRandomly required (E: 7721d84d1a8b7d020d0ab33c3f811426)`);
|
|
99
|
+
}
|
|
100
|
+
if (this._targetBinding === undefined) {
|
|
101
|
+
throw new Error(`targetBinding required (E: 9add64d7e8e8cba01d901727a8e9b826)`);
|
|
102
|
+
}
|
|
77
103
|
return {
|
|
78
104
|
size: this._size,
|
|
79
105
|
replenish: this._replenish,
|
|
@@ -90,39 +116,75 @@ export class KeystoneConfigBuilderBase {
|
|
|
90
116
|
this._verbs = verbs;
|
|
91
117
|
return this;
|
|
92
118
|
}
|
|
93
|
-
buildBase() {
|
|
94
|
-
// Helper to keep the concrete build() clean
|
|
95
|
-
return {
|
|
96
|
-
type: 'hash-reveal-v1', // This is overridden by concrete/interface usually, but needed for base shape
|
|
97
|
-
salt: this._salt,
|
|
98
|
-
allowedVerbs: this._verbs
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
119
|
}
|
|
102
120
|
/**
|
|
103
121
|
* Concrete Builder for Hash-Reveal V1 Strategy.
|
|
104
122
|
*/
|
|
105
123
|
export class KeystoneConfigBuilder_HashV1 extends KeystoneConfigBuilderBase {
|
|
106
|
-
|
|
107
|
-
|
|
124
|
+
lc = `[${KeystoneConfigBuilder_HashV1}]`;
|
|
125
|
+
_algo;
|
|
126
|
+
_rounds;
|
|
108
127
|
/**
|
|
109
128
|
* Sets the hashing strength.
|
|
110
129
|
*/
|
|
111
|
-
withHash(algo, rounds
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
130
|
+
withHash({ algo, rounds }) {
|
|
131
|
+
const lc = `${this.lc}[${this.withHash.name}]`;
|
|
132
|
+
try {
|
|
133
|
+
if (logalot) {
|
|
134
|
+
console.log(`${lc} starting... (I: 15d1b3bd2e98bba33fc6c78228755826)`);
|
|
135
|
+
}
|
|
136
|
+
this._algo = algo;
|
|
137
|
+
this._rounds = rounds;
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
finally {
|
|
145
|
+
if (logalot) {
|
|
146
|
+
console.log(`${lc} complete.`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
115
149
|
}
|
|
116
150
|
build() {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
151
|
+
const lc = `${this.lc}[${this.build.name}]`;
|
|
152
|
+
try {
|
|
153
|
+
if (logalot) {
|
|
154
|
+
console.log(`${lc} starting... (I: 5df568c63c4993bb98df0a319ee16826)`);
|
|
155
|
+
}
|
|
156
|
+
if (!this._id) {
|
|
157
|
+
throw new Error(`id required (E: b50d082adf38bcbf463552f80d2c3226)`);
|
|
158
|
+
}
|
|
159
|
+
if (!this._salt) {
|
|
160
|
+
throw new Error(`salt required (E: b0f1926657b8d7d3a88fb9385ead5826)`);
|
|
161
|
+
}
|
|
162
|
+
if (!this._algo) {
|
|
163
|
+
throw new Error(`algorithm required (E: cff228f9898fd6383ef752088dae6826)`);
|
|
164
|
+
}
|
|
165
|
+
if (this._rounds === undefined) {
|
|
166
|
+
throw new Error(`rounds required (E: eb72580f3b014cda18cba3e399683c26)`);
|
|
167
|
+
}
|
|
168
|
+
const result = {
|
|
169
|
+
id: this._id,
|
|
170
|
+
type: KeystoneChallengeType.hash_reveal_v1,
|
|
171
|
+
salt: this._salt,
|
|
172
|
+
allowedVerbs: this._verbs,
|
|
173
|
+
behavior: this.buildBehavior(),
|
|
174
|
+
algo: this._algo,
|
|
175
|
+
rounds: this._rounds,
|
|
176
|
+
};
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
181
|
+
throw error;
|
|
182
|
+
}
|
|
183
|
+
finally {
|
|
184
|
+
if (logalot) {
|
|
185
|
+
console.log(`${lc} complete.`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
126
188
|
}
|
|
127
189
|
}
|
|
128
190
|
// ===========================================================================
|
|
@@ -133,25 +195,55 @@ export class KeystoneConfig {
|
|
|
133
195
|
return new KeystoneConfigBuilder_HashV1();
|
|
134
196
|
}
|
|
135
197
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
// ===========================================================================
|
|
139
|
-
export function createStandardPoolConfig(salt = POOL_ID_DEFAULT) {
|
|
198
|
+
export function createStandardPoolConfig(opts) {
|
|
199
|
+
let { salt, id, size, sequential, random, targetBinding, replenishStrategy, verbs, hashAlgorithm, hashRounds, } = opts;
|
|
140
200
|
return KeystoneConfig.hash()
|
|
201
|
+
.withId(id)
|
|
141
202
|
.withSalt(salt)
|
|
142
|
-
.withSize(
|
|
143
|
-
.withHybrid(
|
|
144
|
-
|
|
203
|
+
.withSize(size ?? KEYSTONE_CONFIG_DEFAULT_SIZE)
|
|
204
|
+
.withHybrid({
|
|
205
|
+
seqCount: sequential ?? KEYSTONE_CONFIG_DEFAULT_SEQUENTIAL,
|
|
206
|
+
randCount: random ?? KEYSTONE_CONFIG_DEFAULT_RANDOM,
|
|
207
|
+
})
|
|
208
|
+
.withTargetBinding(targetBinding ?? KEYSTONE_CONFIG_DEFAULT_BINDING)
|
|
209
|
+
.withReplenishStrategy(replenishStrategy ?? KEYSTONE_CONFIG_DEFAULT_REPLENISH_STRATEGY)
|
|
210
|
+
.withHash({
|
|
211
|
+
algo: hashAlgorithm ?? KEYSTONE_CONFIG_DEFAULT_HASH_ALGORITHM,
|
|
212
|
+
rounds: hashRounds ?? KEYSTONE_CONFIG_DEFAULT_HASH_ROUNDS
|
|
213
|
+
})
|
|
214
|
+
.forVerbs(verbs ?? [])
|
|
145
215
|
.build();
|
|
146
216
|
}
|
|
147
|
-
export function
|
|
217
|
+
export function createHighSecurityPoolConfig(opts) {
|
|
218
|
+
let { salt, id, size, sequential, random, targetBinding, replenishStrategy, verbs, hashAlgorithm, hashRounds, } = opts;
|
|
148
219
|
return KeystoneConfig.hash()
|
|
220
|
+
.withId(id)
|
|
149
221
|
.withSalt(salt)
|
|
150
|
-
.
|
|
151
|
-
.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
222
|
+
.withSize(size ?? KEYSTONE_CONFIG_DEFAULT_SIZE_HIGHSECURITY)
|
|
223
|
+
.withHybrid({
|
|
224
|
+
seqCount: sequential ?? KEYSTONE_CONFIG_DEFAULT_SEQUENTIAL_HIGHSECURITY,
|
|
225
|
+
randCount: random ?? KEYSTONE_CONFIG_DEFAULT_RANDOM_HIGHSECURITY,
|
|
226
|
+
})
|
|
227
|
+
.withTargetBinding(targetBinding ?? KEYSTONE_CONFIG_DEFAULT_BINDING_HIGHSECURITY)
|
|
228
|
+
.withReplenishStrategy(replenishStrategy ?? KEYSTONE_CONFIG_DEFAULT_REPLENISH_STRATEGY_HIGHSECURITY)
|
|
229
|
+
.withHash({
|
|
230
|
+
algo: hashAlgorithm ?? KEYSTONE_CONFIG_DEFAULT_HASH_ALGORITHM_HIGHSECURITY,
|
|
231
|
+
rounds: hashRounds ?? KEYSTONE_CONFIG_DEFAULT_HASH_ROUNDS_HIGHSECURITY
|
|
232
|
+
})
|
|
233
|
+
.forVerbs(verbs ?? [])
|
|
155
234
|
.build();
|
|
156
235
|
}
|
|
236
|
+
export function createManagePoolConfig(opts) {
|
|
237
|
+
return createHighSecurityPoolConfig({
|
|
238
|
+
...opts,
|
|
239
|
+
verbs: [KeystoneVerb.MANAGE],
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
export function createRevocationPoolConfig(opts) {
|
|
243
|
+
return createHighSecurityPoolConfig({
|
|
244
|
+
...opts,
|
|
245
|
+
verbs: [KeystoneVerb.REVOKE],
|
|
246
|
+
replenishStrategy: KeystoneReplenishStrategy.deleteAll,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
157
249
|
//# sourceMappingURL=keystone-config-builder.mjs.map
|