@ibgib/core-gib 0.1.63 → 0.1.65
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/keystone-constants.d.mts +1 -0
- package/dist/keystone/keystone-constants.d.mts.map +1 -1
- package/dist/keystone/keystone-constants.mjs +1 -0
- package/dist/keystone/keystone-constants.mjs.map +1 -1
- package/dist/keystone/keystone-helpers.d.mts +27 -1
- package/dist/keystone/keystone-helpers.d.mts.map +1 -1
- package/dist/keystone/keystone-helpers.mjs +261 -16
- package/dist/keystone/keystone-helpers.mjs.map +1 -1
- package/dist/keystone/keystone-service-v1.d.mts +113 -1
- package/dist/keystone/keystone-service-v1.d.mts.map +1 -1
- package/dist/keystone/keystone-service-v1.mjs +442 -27
- package/dist/keystone/keystone-service-v1.mjs.map +1 -1
- package/dist/keystone/keystone-service-v1.respec.mjs +641 -47
- package/dist/keystone/keystone-service-v1.respec.mjs.map +1 -1
- package/dist/keystone/keystone-types.d.mts +31 -2
- package/dist/keystone/keystone-types.d.mts.map +1 -1
- package/dist/keystone/keystone-types.mjs +15 -0
- package/dist/keystone/keystone-types.mjs.map +1 -1
- package/dist/keystone/policy/profiles/profile-domain.json +2 -61
- package/dist/keystone/policy/profiles/profile-sync.json +2 -16
- package/dist/keystone/policy/schemas/keystone.high.schema.json +1 -1
- package/dist/keystone/policy/schemas/keystone.medium.schema.json +1 -1
- package/package.json +2 -2
- package/src/keystone/keystone-constants.mts +1 -0
- package/src/keystone/keystone-helpers.mts +308 -15
- package/src/keystone/keystone-service-v1.mts +535 -28
- package/src/keystone/keystone-service-v1.respec.mts +2130 -1459
- package/src/keystone/keystone-types.mts +50 -2
- package/src/keystone/policy/profiles/profile-domain.json +3 -62
- package/src/keystone/policy/profiles/profile-sync.json +2 -16
- package/src/keystone/policy/schemas/keystone.high.schema.json +1 -1
- package/src/keystone/policy/schemas/keystone.medium.schema.json +1 -1
|
@@ -81,6 +81,7 @@ export declare function isKeystoneVerb(value: string): value is KeystoneVerb;
|
|
|
81
81
|
*/
|
|
82
82
|
export declare const POOL_ID_REVOKE = "revoke";
|
|
83
83
|
export declare const POOL_ID_MANAGE = "manage";
|
|
84
|
+
export declare const POOL_ID_CUSTODIAN_MANAGE = "custodian-manage";
|
|
84
85
|
export declare const POOL_ID_DEFAULT = "default";
|
|
85
86
|
/**
|
|
86
87
|
* Pool ID for the session keystone's transport connect pool.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keystone-constants.d.mts","sourceRoot":"","sources":["../../src/keystone/keystone-constants.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAGhF,eAAO,MAAM,aAAa,aAAa,CAAC;AACxC,eAAO,MAAM,uBAAuB,QAAiB,CAAC;AACtD,eAAO,MAAM,oBAAoB,QAA2B,CAAC;AAC7D,eAAO,MAAM,wBAAwB,QAA4B,CAAC;AAClE,eAAO,MAAM,2BAA2B,QAAqD,CAAC;AAC9F;;GAEG;AACH,eAAO,MAAM,wBAAwB,OAAQ,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAC7C;;GAEG;AACH,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAC7C;;GAEG;AACH,eAAO,MAAM,kBAAkB,SAAS,CAAC;AACzC;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,SAAS,CAAC;AACzC;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAC/C,MAAM,MAAM,YAAY,GAClB,OAAO,oBAAoB,GAC3B,OAAO,oBAAoB,GAC3B,OAAO,kBAAkB,GACzB,OAAO,kBAAkB,GACzB,OAAO,qBAAqB,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,YAAY;IACrB;;;OAGG;;IAEH;;;;;;;;;;OAUG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAEH;;;OAGG;;CAEoC,CAAC;AAC5C,eAAO,M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BAA8B,IAAI,CAAC;AAChD,eAAO,MAAM,+BAA+B,IAAI,CAAC;AACjD,eAAO,MAAM,0CAA0C,UAAkC,CAAC;AAC1F,eAAO,MAAM,sCAAsC,eAAwB,CAAC;AAC5E,eAAO,MAAM,mCAAmC,IAAI,CAAC;AAErD,eAAO,MAAM,yCAAyC,OAAO,CAAC;AAC9D,eAAO,MAAM,+CAA+C,IAAI,CAAC;AACjE,eAAO,MAAM,2CAA2C,IAAI,CAAC;AAC7D,eAAO,MAAM,4CAA4C,KAAK,CAAC;AAC/D,eAAO,MAAM,uDAAuD,eAAuC,CAAC;AAC5G,eAAO,MAAM,mDAAmD,eAAwB,CAAC;AACzF,eAAO,MAAM,gDAAgD,KAAK,CAAC;AACnE;;;GAGG;AACH,eAAO,MAAM,6BAA6B,KAAK,CAAC"}
|
|
@@ -84,6 +84,7 @@ export function isKeystoneVerb(value) {
|
|
|
84
84
|
*/
|
|
85
85
|
export const POOL_ID_REVOKE = KEYSTONE_VERB_REVOKE;
|
|
86
86
|
export const POOL_ID_MANAGE = KEYSTONE_VERB_MANAGE;
|
|
87
|
+
export const POOL_ID_CUSTODIAN_MANAGE = "custodian-manage";
|
|
87
88
|
export const POOL_ID_DEFAULT = "default";
|
|
88
89
|
/**
|
|
89
90
|
* Pool ID for the session keystone's transport connect pool.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keystone-constants.mjs","sourceRoot":"","sources":["../../src/keystone/keystone-constants.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC;AACxC,MAAM,CAAC,MAAM,uBAAuB,GAAG,cAAc,CAAC;AACtD,MAAM,CAAC,MAAM,oBAAoB,GAAG,wBAAwB,CAAC;AAC7D,MAAM,CAAC,MAAM,wBAAwB,GAAG,yBAAyB,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e,GAAG,qBAAqB,CAAC;AACrD;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,CAAC;AAC/C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAE/C,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC;AAChD,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,CAAC;AACpD,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,CAAC;AAChD,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC;AACjD,MAAM,CAAC,MAAM,0CAA0C,GAAG,yBAAyB,CAAC,KAAK,CAAC;AAC1F,MAAM,CAAC,MAAM,sCAAsC,GAAG,aAAa,CAAC,OAAO,CAAC;AAC5E,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,CAAC;AAErD,MAAM,CAAC,MAAM,yCAAyC,GAAG,IAAI,CAAC;AAC9D,MAAM,CAAC,MAAM,+CAA+C,GAAG,CAAC,CAAC;AACjE,MAAM,CAAC,MAAM,2CAA2C,GAAG,CAAC,CAAC;AAC7D,MAAM,CAAC,MAAM,4CAA4C,GAAG,EAAE,CAAC;AAC/D,MAAM,CAAC,MAAM,uDAAuD,GAAG,yBAAyB,CAAC,UAAU,CAAC;AAC5G,MAAM,CAAC,MAAM,mDAAmD,GAAG,aAAa,CAAC,OAAO,CAAC;AACzF,MAAM,CAAC,MAAM,gDAAgD,GAAG,EAAE,CAAC;AACnE;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,CAAC"}
|
|
@@ -90,7 +90,7 @@ export declare function generateOpaqueChallengeId({ salt, timestamp, index }: {
|
|
|
90
90
|
*
|
|
91
91
|
* @returns The new array of KeystoneChallengePools (including the modified one).
|
|
92
92
|
*/
|
|
93
|
-
export declare function applyReplenishmentStrategy({ prevPools, targetPoolId, consumedIds, masterSecret, strategy, config, }: {
|
|
93
|
+
export declare function applyReplenishmentStrategy({ prevPools, targetPoolId, consumedIds, masterSecret, strategy, config, verb, }: {
|
|
94
94
|
prevPools: KeystoneChallengePool[];
|
|
95
95
|
targetPoolId: string;
|
|
96
96
|
consumedIds: string[];
|
|
@@ -100,6 +100,7 @@ export declare function applyReplenishmentStrategy({ prevPools, targetPoolId, co
|
|
|
100
100
|
*/
|
|
101
101
|
strategy: any;
|
|
102
102
|
config: KeystonePoolConfig;
|
|
103
|
+
verb?: string;
|
|
103
104
|
}): Promise<KeystoneChallengePool[]>;
|
|
104
105
|
/**
|
|
105
106
|
* High-level orchestration helper.
|
|
@@ -214,4 +215,29 @@ export declare function getIdentity_throwIfUndefined({ addr, metaspace, space, }
|
|
|
214
215
|
metaspace: MetaspaceService;
|
|
215
216
|
space: IbGibSpaceAny;
|
|
216
217
|
}): Promise<KeystoneIbGib_V1>;
|
|
218
|
+
/**
|
|
219
|
+
* Pure helper to generate challenges map for a pool configuration using a masterSecret.
|
|
220
|
+
*/
|
|
221
|
+
export declare function generatePoolChallenges({ config, masterSecret }: {
|
|
222
|
+
config: KeystonePoolConfig;
|
|
223
|
+
masterSecret: string;
|
|
224
|
+
}): Promise<{
|
|
225
|
+
[challengeId: string]: any;
|
|
226
|
+
}>;
|
|
227
|
+
/**
|
|
228
|
+
* Pure helper to rotate a pool to a new masterSecret.
|
|
229
|
+
* Takes the previous pool config, generates a new salt, and builds a new pool with refreshed challenges.
|
|
230
|
+
*/
|
|
231
|
+
export declare function rotatePoolChallenges({ prevPool, newMasterSecret }: {
|
|
232
|
+
prevPool: KeystoneChallengePool;
|
|
233
|
+
newMasterSecret: string;
|
|
234
|
+
}): Promise<KeystoneChallengePool>;
|
|
235
|
+
/**
|
|
236
|
+
* Pure helper to verify if a candidate signing secret (passphrase) is correct for a specific challenge pool.
|
|
237
|
+
* Does not mutate any state.
|
|
238
|
+
*/
|
|
239
|
+
export declare function verifyPoolSecret({ pool, signingSecret }: {
|
|
240
|
+
pool: KeystoneChallengePool;
|
|
241
|
+
signingSecret: string;
|
|
242
|
+
}): Promise<boolean>;
|
|
217
243
|
//# sourceMappingURL=keystone-helpers.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keystone-helpers.d.mts","sourceRoot":"","sources":["../../src/keystone/keystone-helpers.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,SAAS,EAAmB,MAAM,8BAA8B,CAAC;AAS9E,OAAO,EACH,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAE,qBAAqB,EACvE,mBAAmB,EAAE,aAAa,EAAE,kBAAkB,EAEtD,aAAa,EAIb,oBAAoB,
|
|
1
|
+
{"version":3,"file":"keystone-helpers.d.mts","sourceRoot":"","sources":["../../src/keystone/keystone-helpers.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,SAAS,EAAmB,MAAM,8BAA8B,CAAC;AAS9E,OAAO,EACH,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAE,qBAAqB,EACvE,mBAAmB,EAAE,aAAa,EAAE,kBAAkB,EAEtD,aAAa,EAIb,oBAAoB,EAMvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAMnE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAIjE;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,EAChC,YAAY,GACf,EAAE;IACC,YAAY,EAAE,eAAe,CAAC;CACjC,GAAG,OAAO,CAAC,EAAE,CAAC,CAkBd;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAC,EAClC,EAAE,GACL,EAAE;IACC,EAAE,EAAE,EAAE,CAAC;CACV,GAAG,OAAO,CAAC,aAAa,CAAC,CAqBzB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,EACrC,EAAE,GACL,EAAE;IACC,EAAE,EAAE,EAAE,CAAC;CACV,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AE,MAAM,CAAC;CACxB,GAAG,OAAO,CAAC;IAAE,CAAC,WAAW,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAC,CAqB1C;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,EACvC,QAAQ,EACR,eAAe,EAClB,EAAE;IACC,QAAQ,EAAE,qBAAqB,CAAC;IAChC,eAAe,EAAE,MAAM,CAAC;CAC3B,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAsBjC;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,EACnC,IAAI,EACJ,aAAa,EAChB,EAAE;IACC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;CACzB,GAAG,OAAO,CAAC,OAAO,CAAC,CAoBnB"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { extractErrorMsg, hash, HashAlgorithm, pretty } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
|
|
1
|
+
import { extractErrorMsg, hash, HashAlgorithm, pretty, getUUID } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
|
|
2
2
|
import { getIbGibAddr } from "@ibgib/ts-gib/dist/helper.mjs";
|
|
3
3
|
import { validateIbGibIntrinsically } from "@ibgib/ts-gib/dist/V1/validate-helper.mjs";
|
|
4
4
|
import { mut8 } from "@ibgib/ts-gib/dist/V1/transforms/mut8.mjs";
|
|
5
5
|
import { Factory_V1 } from "@ibgib/ts-gib/dist/V1/factory.mjs";
|
|
6
6
|
import { getGib } from "@ibgib/ts-gib/dist/V1/transforms/transform-helper.mjs";
|
|
7
7
|
import { GLOBAL_LOG_A_LOT } from "../core-constants.mjs";
|
|
8
|
-
import { KEYSTONE_ATOM, KEYSTONE_HASH_MAX_ROUNDS, KEYSTONE_POOL_ID_REGEXP, KEYSTONE_SALT_REGEXP, KEYSTONE_USERNAME_REGEXP, KEYSTONE_DESCRIPTION_REGEXP, KEYSTONE_VERB_MANAGE } from "./keystone-constants.mjs";
|
|
9
|
-
import { KeystoneReplenishStrategy, KEYSTONE_REPLENISH_STRATEGY_VALID_VALUES, KeystoneChallengeType, KEYSTONE_CHALLENGE_TYPE_VALID_VALUES
|
|
8
|
+
import { KEYSTONE_ATOM, KEYSTONE_HASH_MAX_ROUNDS, KEYSTONE_POOL_ID_REGEXP, KEYSTONE_SALT_REGEXP, KEYSTONE_USERNAME_REGEXP, KEYSTONE_DESCRIPTION_REGEXP, KEYSTONE_VERB_MANAGE, KEYSTONE_VERB_REVOKE } from "./keystone-constants.mjs";
|
|
9
|
+
import { KeystoneReplenishStrategy, KEYSTONE_REPLENISH_STRATEGY_VALID_VALUES, KeystoneChallengeType, KEYSTONE_CHALLENGE_TYPE_VALID_VALUES } from "./keystone-types.mjs";
|
|
10
10
|
import { KeystoneStrategyFactory } from "./strategy/keystone-strategy-factory.mjs";
|
|
11
11
|
import { getDependencyGraph } from "../common/other/graph-helper.mjs";
|
|
12
12
|
import { getIbGibsFromCache_fallbackToSpaces, getTimelinesGroupedByTjp, splitPerTjpAndOrDna } from "../common/other/ibgib-helper.mjs";
|
|
@@ -255,7 +255,7 @@ export async function generateOpaqueChallengeId({ salt, timestamp, index }) {
|
|
|
255
255
|
*
|
|
256
256
|
* @returns The new array of KeystoneChallengePools (including the modified one).
|
|
257
257
|
*/
|
|
258
|
-
export async function applyReplenishmentStrategy({ prevPools, targetPoolId, consumedIds, masterSecret, strategy, config, }) {
|
|
258
|
+
export async function applyReplenishmentStrategy({ prevPools, targetPoolId, consumedIds, masterSecret, strategy, config, verb, }) {
|
|
259
259
|
const lc = `[applyReplenishmentStrategy]`;
|
|
260
260
|
try {
|
|
261
261
|
const newPools = JSON.parse(JSON.stringify(prevPools));
|
|
@@ -266,7 +266,10 @@ export async function applyReplenishmentStrategy({ prevPools, targetPoolId, cons
|
|
|
266
266
|
const pool = newPools[targetIdx];
|
|
267
267
|
const poolSecret = await strategy.derivePoolSecret({ masterSecret });
|
|
268
268
|
const timestamp = Date.now().toString();
|
|
269
|
-
|
|
269
|
+
let strategyType = config.behavior.replenish;
|
|
270
|
+
if (verb === KEYSTONE_VERB_REVOKE) {
|
|
271
|
+
strategyType = KeystoneReplenishStrategy.deleteAll;
|
|
272
|
+
}
|
|
270
273
|
if (strategyType === KeystoneReplenishStrategy.topUp) {
|
|
271
274
|
// Remove consumed
|
|
272
275
|
consumedIds.forEach(id => delete pool.challenges[id]);
|
|
@@ -282,16 +285,10 @@ export async function applyReplenishmentStrategy({ prevPools, targetPoolId, cons
|
|
|
282
285
|
}
|
|
283
286
|
}
|
|
284
287
|
else if (strategyType === KeystoneReplenishStrategy.replaceAll) {
|
|
285
|
-
pool.challenges = {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
});
|
|
290
|
-
const solution = await strategy.generateSolution({
|
|
291
|
-
poolSecret, poolId: pool.id, challengeId: newId
|
|
292
|
-
});
|
|
293
|
-
pool.challenges[newId] = await strategy.generateChallenge({ solution });
|
|
294
|
-
}
|
|
288
|
+
pool.challenges = await generatePoolChallenges({
|
|
289
|
+
config,
|
|
290
|
+
masterSecret
|
|
291
|
+
});
|
|
295
292
|
}
|
|
296
293
|
else if (strategyType === KeystoneReplenishStrategy.consume) {
|
|
297
294
|
consumedIds.forEach(id => delete pool.challenges[id]);
|
|
@@ -331,6 +328,11 @@ export async function solveAndReplenish({ targetPoolId, prevPools, masterSecret,
|
|
|
331
328
|
}
|
|
332
329
|
const strategy = KeystoneStrategyFactory.create({ config: pool.config });
|
|
333
330
|
const poolSecret = await strategy.derivePoolSecret({ masterSecret });
|
|
331
|
+
// Verify secret correctness before solving
|
|
332
|
+
const isSecretCorrect = await verifyPoolSecret({ pool, signingSecret: masterSecret });
|
|
333
|
+
if (!isSecretCorrect) {
|
|
334
|
+
throw new Error(`Crypto Violation: Invalid signing secret for pool: ${pool.id} (E: 8a4c2b1d3e5f6a7b8c9d0e1f2a3b4c5f)`);
|
|
335
|
+
}
|
|
334
336
|
const solutions = [];
|
|
335
337
|
// 1. Solve
|
|
336
338
|
for (const id of challengeIds) {
|
|
@@ -352,7 +354,8 @@ export async function solveAndReplenish({ targetPoolId, prevPools, masterSecret,
|
|
|
352
354
|
consumedIds: challengeIds,
|
|
353
355
|
masterSecret,
|
|
354
356
|
strategy,
|
|
355
|
-
config: pool.config
|
|
357
|
+
config: pool.config,
|
|
358
|
+
verb: claim.verb
|
|
356
359
|
});
|
|
357
360
|
return { proof, nextPools };
|
|
358
361
|
}
|
|
@@ -676,6 +679,176 @@ export async function validateKeystoneTransition({ currentIbGib, prevIbGib, }) {
|
|
|
676
679
|
errors.push(`Revocation target mismatch. Expected ${expectedTarget}, got ${target}`);
|
|
677
680
|
}
|
|
678
681
|
}
|
|
682
|
+
// Claim details verification (transition validation)
|
|
683
|
+
const signingPoolIds = new Set(currData.proofs.map(p => p.solutions?.[0]?.poolId).filter(Boolean));
|
|
684
|
+
for (const proof of currData.proofs) {
|
|
685
|
+
const claim = proof.claim;
|
|
686
|
+
if (claim?.details) {
|
|
687
|
+
const details = claim.details;
|
|
688
|
+
const type = details.type;
|
|
689
|
+
const info = details.info;
|
|
690
|
+
if (type === 'add-pool') {
|
|
691
|
+
// Cast info to ClaimDetails_AddPool
|
|
692
|
+
const addInfo = info;
|
|
693
|
+
if (!addInfo || !Array.isArray(addInfo.add) || addInfo.add.length === 0) {
|
|
694
|
+
errors.push(`details type is '${type}' but payload is invalid. (E: 1fa2a8cb28c9b60e68994511a5825)`);
|
|
695
|
+
continue;
|
|
696
|
+
}
|
|
697
|
+
// Verify that the set of pools in current equals previous plus the added pools
|
|
698
|
+
const prevIds = new Set(prevData.challengePools.map(p => p.id));
|
|
699
|
+
const currIds = new Set(currData.challengePools.map(p => p.id));
|
|
700
|
+
// All added pools must be in current
|
|
701
|
+
for (const id of addInfo.add) {
|
|
702
|
+
if (!currIds.has(id)) {
|
|
703
|
+
errors.push(`ClaimDetails_AddPool lists pool ${id} but it is missing in the evolved keystone. (E: 2fa2a8cb28c9b60e68994511a5825)`);
|
|
704
|
+
}
|
|
705
|
+
if (prevIds.has(id)) {
|
|
706
|
+
errors.push(`ClaimDetails_AddPool attempts to add existing pool ${id}. (E: 3fa2a8cb28c9b60e68994511a5825)`);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
// Verify size
|
|
710
|
+
if (currData.challengePools.length !== prevData.challengePools.length + addInfo.add.length) {
|
|
711
|
+
errors.push(`Structural mismatch: expected ${prevData.challengePools.length + addInfo.add.length} pools, found ${currData.challengePools.length}. (E: 4fa2a8cb28c9b60e68994511a5825)`);
|
|
712
|
+
}
|
|
713
|
+
// Verify all previous pools are unmodified
|
|
714
|
+
for (const prevPool of prevData.challengePools) {
|
|
715
|
+
const currPool = currData.challengePools.find(p => p.id === prevPool.id);
|
|
716
|
+
if (!currPool) {
|
|
717
|
+
errors.push(`Existing pool ${prevPool.id} was removed during add-pool transition. (E: 5fa2a8cb28c9b60e68994511a5825)`);
|
|
718
|
+
continue;
|
|
719
|
+
}
|
|
720
|
+
// Verify configuration did not change
|
|
721
|
+
if (JSON.stringify(prevPool.config) !== JSON.stringify(currPool.config)) {
|
|
722
|
+
errors.push(`Existing pool config ${prevPool.id} was mutated during add-pool transition. (E: 6fa2a8cb28c9b60e68994511a5825)`);
|
|
723
|
+
}
|
|
724
|
+
// Verify challenges did not change, unless this was the signing pool used to authorize the transition
|
|
725
|
+
if (!signingPoolIds.has(prevPool.id) && JSON.stringify(prevPool.challenges) !== JSON.stringify(currPool.challenges)) {
|
|
726
|
+
errors.push(`Existing pool challenges ${prevPool.id} were mutated during add-pool transition. (E: 7fa2a8cb28c9b60e68994511a5825)`);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
else if (type === 'replace-pool') {
|
|
731
|
+
const replaceInfo = info;
|
|
732
|
+
if (!replaceInfo || typeof replaceInfo.replace !== 'string' || !replaceInfo.replace) {
|
|
733
|
+
errors.push(`details type is '${type}' but payload is invalid. (E: 8fa2a8cb28c9b60e68994511a5825)`);
|
|
734
|
+
continue;
|
|
735
|
+
}
|
|
736
|
+
const targetId = replaceInfo.replace;
|
|
737
|
+
// Verify that the set of pool IDs in current equals previous
|
|
738
|
+
const prevIds = prevData.challengePools.map(p => p.id).sort();
|
|
739
|
+
const currIds = currData.challengePools.map(p => p.id).sort();
|
|
740
|
+
if (JSON.stringify(prevIds) !== JSON.stringify(currIds)) {
|
|
741
|
+
errors.push(`replace-pool transition mutated the pool IDs set. (E: 9fa2a8cb28c9b60e68994511a5825)`);
|
|
742
|
+
}
|
|
743
|
+
// Assert target pool was replaced (challenges modified)
|
|
744
|
+
const prevTarget = prevData.challengePools.find(p => p.id === targetId);
|
|
745
|
+
const currTarget = currData.challengePools.find(p => p.id === targetId);
|
|
746
|
+
if (!prevTarget || !currTarget) {
|
|
747
|
+
errors.push(`Replaced pool ${targetId} not found in keystone challenge pools. (E: afa2a8cb28c9b60e68994511a5825)`);
|
|
748
|
+
}
|
|
749
|
+
// Verify all other pools are completely unmodified
|
|
750
|
+
for (const prevPool of prevData.challengePools) {
|
|
751
|
+
if (prevPool.id === targetId)
|
|
752
|
+
continue;
|
|
753
|
+
const currPool = currData.challengePools.find(p => p.id === prevPool.id);
|
|
754
|
+
if (!currPool)
|
|
755
|
+
continue;
|
|
756
|
+
if (JSON.stringify(prevPool.config) !== JSON.stringify(currPool.config)) {
|
|
757
|
+
errors.push(`Unrelated pool config ${prevPool.id} was mutated during replace-pool. (E: bfa2a8cb28c9b60e68994511a5825)`);
|
|
758
|
+
}
|
|
759
|
+
if (!signingPoolIds.has(prevPool.id) && JSON.stringify(prevPool.challenges) !== JSON.stringify(currPool.challenges)) {
|
|
760
|
+
errors.push(`Unrelated pool challenges ${prevPool.id} were mutated during replace-pool. (E: cfa2a8cb28c9b60e68994511a5825)`);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
else if (type === 'remove-pool') {
|
|
765
|
+
const removeInfo = info;
|
|
766
|
+
if (!removeInfo || !Array.isArray(removeInfo.remove) || removeInfo.remove.length === 0) {
|
|
767
|
+
errors.push(`details type is '${type}' but payload is invalid. (E: b7a2a8cb28c9b60e68994511a5825)`);
|
|
768
|
+
continue;
|
|
769
|
+
}
|
|
770
|
+
const removeSet = new Set(removeInfo.remove);
|
|
771
|
+
// Verify that the set of pool IDs in current equals previous minus the removed pools
|
|
772
|
+
const prevIds = new Set(prevData.challengePools.map(p => p.id));
|
|
773
|
+
const currIds = new Set(currData.challengePools.map(p => p.id));
|
|
774
|
+
for (const id of removeInfo.remove) {
|
|
775
|
+
if (!prevIds.has(id)) {
|
|
776
|
+
errors.push(`ClaimDetails_RemovePool lists pool ${id} but it is missing in the previous keystone. (E: c7a2a8cb28c9b60e68994511a5825)`);
|
|
777
|
+
}
|
|
778
|
+
if (currIds.has(id)) {
|
|
779
|
+
errors.push(`ClaimDetails_RemovePool lists pool ${id} but it is still present in the evolved keystone. (E: d7a2a8cb28c9b60e68994511a5825)`);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
// Verify size
|
|
783
|
+
if (currData.challengePools.length !== prevData.challengePools.length - removeInfo.remove.length) {
|
|
784
|
+
errors.push(`Structural mismatch: expected ${prevData.challengePools.length - removeInfo.remove.length} pools, found ${currData.challengePools.length}. (E: e7a2a8cb28c9b60e68994511a5825)`);
|
|
785
|
+
}
|
|
786
|
+
// Verify all remaining pools are unmodified
|
|
787
|
+
for (const prevPool of prevData.challengePools) {
|
|
788
|
+
if (removeSet.has(prevPool.id))
|
|
789
|
+
continue;
|
|
790
|
+
const currPool = currData.challengePools.find(p => p.id === prevPool.id);
|
|
791
|
+
if (!currPool) {
|
|
792
|
+
errors.push(`Pool ${prevPool.id} was unexpectedly removed. (E: f7a2a8cb28c9b60e68994511a5825)`);
|
|
793
|
+
continue;
|
|
794
|
+
}
|
|
795
|
+
if (JSON.stringify(prevPool.config) !== JSON.stringify(currPool.config)) {
|
|
796
|
+
errors.push(`Remaining pool config ${prevPool.id} was mutated during remove-pool. (E: 07a2a8cb28c9b60e68994511a5825)`);
|
|
797
|
+
}
|
|
798
|
+
if (!signingPoolIds.has(prevPool.id) && JSON.stringify(prevPool.challenges) !== JSON.stringify(currPool.challenges)) {
|
|
799
|
+
errors.push(`Remaining pool challenges ${prevPool.id} were mutated during remove-pool. (E: 17a2a8cb28c9b60e68994511a5825)`);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
else if (type === 'change-password') {
|
|
804
|
+
const changeInfo = info;
|
|
805
|
+
if (!changeInfo || !Array.isArray(changeInfo.change) || changeInfo.change.length === 0) {
|
|
806
|
+
errors.push(`details type is '${type}' but payload is invalid. (E: dfa2a8cb28c9b60e68994511a5825)`);
|
|
807
|
+
continue;
|
|
808
|
+
}
|
|
809
|
+
// Verify that the set of pool IDs is unmodified
|
|
810
|
+
const prevIds = prevData.challengePools.map(p => p.id).sort();
|
|
811
|
+
const currIds = currData.challengePools.map(p => p.id).sort();
|
|
812
|
+
if (JSON.stringify(prevIds) !== JSON.stringify(currIds)) {
|
|
813
|
+
errors.push(`change-password transition mutated the pool IDs set. (E: efa2a8cb28c9b60e68994511a5825)`);
|
|
814
|
+
}
|
|
815
|
+
const rotatedIds = new Set(changeInfo.change);
|
|
816
|
+
for (const prevPool of prevData.challengePools) {
|
|
817
|
+
const currPool = currData.challengePools.find(p => p.id === prevPool.id);
|
|
818
|
+
if (!currPool)
|
|
819
|
+
continue;
|
|
820
|
+
if (rotatedIds.has(prevPool.id)) {
|
|
821
|
+
// Check: rotated pool must not be foreign!
|
|
822
|
+
if (prevPool.isForeign) {
|
|
823
|
+
errors.push(`Security Violation: Password rotation attempted on foreign pool ${prevPool.id}. (E: ffa2a8cb28c9b60e68994511a5825)`);
|
|
824
|
+
}
|
|
825
|
+
// Config must be identical except for the salt
|
|
826
|
+
const prevConfCopy = { ...prevPool.config, salt: '' };
|
|
827
|
+
const currConfCopy = { ...currPool.config, salt: '' };
|
|
828
|
+
if (JSON.stringify(prevConfCopy) !== JSON.stringify(currConfCopy)) {
|
|
829
|
+
errors.push(`Pool config metadata for rotated pool ${prevPool.id} was mutated. (E: 00b2a8cb28c9b60e68994511a5825)`);
|
|
830
|
+
}
|
|
831
|
+
// Salt must be different
|
|
832
|
+
if (prevPool.config.salt === currPool.config.salt) {
|
|
833
|
+
errors.push(`Pool salt for rotated pool ${prevPool.id} was not rotated. (E: 01b2a8cb28c9b60e68994511a5825)`);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
else {
|
|
837
|
+
// Non-rotated pools must be completely unmodified
|
|
838
|
+
if (JSON.stringify(prevPool.config) !== JSON.stringify(currPool.config)) {
|
|
839
|
+
errors.push(`Unrelated pool config ${prevPool.id} was mutated during change-password. (E: 02b2a8cb28c9b60e68994511a5825)`);
|
|
840
|
+
}
|
|
841
|
+
if (!signingPoolIds.has(prevPool.id) && JSON.stringify(prevPool.challenges) !== JSON.stringify(currPool.challenges)) {
|
|
842
|
+
errors.push(`Unrelated pool challenges ${prevPool.id} were mutated during change-password. (E: 03b2a8cb28c9b60e68994511a5825)`);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
else {
|
|
848
|
+
errors.push(`Unknown claim details type: ${type}`);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}
|
|
679
852
|
return errors;
|
|
680
853
|
}
|
|
681
854
|
catch (error) {
|
|
@@ -1058,4 +1231,76 @@ export async function getIdentity_throwIfUndefined({ addr, metaspace, space, })
|
|
|
1058
1231
|
}
|
|
1059
1232
|
return identityIbGib;
|
|
1060
1233
|
}
|
|
1234
|
+
/**
|
|
1235
|
+
* Pure helper to generate challenges map for a pool configuration using a masterSecret.
|
|
1236
|
+
*/
|
|
1237
|
+
export async function generatePoolChallenges({ config, masterSecret }) {
|
|
1238
|
+
const strategy = KeystoneStrategyFactory.create({ config });
|
|
1239
|
+
const poolSecret = await strategy.derivePoolSecret({ masterSecret });
|
|
1240
|
+
const challenges = {};
|
|
1241
|
+
const targetSize = config.behavior.size;
|
|
1242
|
+
const timestamp = Date.now().toString();
|
|
1243
|
+
for (let i = 0; i < targetSize; i++) {
|
|
1244
|
+
const challengeId = await generateOpaqueChallengeId({
|
|
1245
|
+
salt: config.salt,
|
|
1246
|
+
timestamp,
|
|
1247
|
+
index: i
|
|
1248
|
+
});
|
|
1249
|
+
const solution = await strategy.generateSolution({
|
|
1250
|
+
poolSecret,
|
|
1251
|
+
poolId: config.id,
|
|
1252
|
+
challengeId
|
|
1253
|
+
});
|
|
1254
|
+
challenges[challengeId] = await strategy.generateChallenge({ solution });
|
|
1255
|
+
}
|
|
1256
|
+
return challenges;
|
|
1257
|
+
}
|
|
1258
|
+
/**
|
|
1259
|
+
* Pure helper to rotate a pool to a new masterSecret.
|
|
1260
|
+
* Takes the previous pool config, generates a new salt, and builds a new pool with refreshed challenges.
|
|
1261
|
+
*/
|
|
1262
|
+
export async function rotatePoolChallenges({ prevPool, newMasterSecret }) {
|
|
1263
|
+
const prevConfig = prevPool.config;
|
|
1264
|
+
const newSalt = (await getUUID()).substring(0, 16);
|
|
1265
|
+
// Copy the config exactly, updating only the salt
|
|
1266
|
+
const newConfig = {
|
|
1267
|
+
...prevConfig,
|
|
1268
|
+
salt: newSalt
|
|
1269
|
+
};
|
|
1270
|
+
const newChallenges = await generatePoolChallenges({
|
|
1271
|
+
config: newConfig,
|
|
1272
|
+
masterSecret: newMasterSecret
|
|
1273
|
+
});
|
|
1274
|
+
return {
|
|
1275
|
+
id: prevPool.id,
|
|
1276
|
+
config: newConfig,
|
|
1277
|
+
challenges: newChallenges,
|
|
1278
|
+
...(prevPool.isForeign !== undefined ? { isForeign: prevPool.isForeign } : {}),
|
|
1279
|
+
...(prevPool.metadata ? { metadata: prevPool.metadata } : {})
|
|
1280
|
+
};
|
|
1281
|
+
}
|
|
1282
|
+
/**
|
|
1283
|
+
* Pure helper to verify if a candidate signing secret (passphrase) is correct for a specific challenge pool.
|
|
1284
|
+
* Does not mutate any state.
|
|
1285
|
+
*/
|
|
1286
|
+
export async function verifyPoolSecret({ pool, signingSecret }) {
|
|
1287
|
+
const challengeIds = Object.keys(pool.challenges);
|
|
1288
|
+
if (challengeIds.length === 0)
|
|
1289
|
+
return false;
|
|
1290
|
+
try {
|
|
1291
|
+
const firstId = challengeIds[0];
|
|
1292
|
+
const challenge = pool.challenges[firstId];
|
|
1293
|
+
const strategy = KeystoneStrategyFactory.create({ config: pool.config });
|
|
1294
|
+
const poolSecret = await strategy.derivePoolSecret({ masterSecret: signingSecret });
|
|
1295
|
+
const solution = await strategy.generateSolution({
|
|
1296
|
+
poolSecret,
|
|
1297
|
+
poolId: pool.id,
|
|
1298
|
+
challengeId: firstId
|
|
1299
|
+
});
|
|
1300
|
+
return await strategy.validateSolution({ solution, challenge });
|
|
1301
|
+
}
|
|
1302
|
+
catch {
|
|
1303
|
+
return false;
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1061
1306
|
//# sourceMappingURL=keystone-helpers.mjs.map
|