@ibgib/core-gib 0.1.6 → 0.1.9
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-config-builder.d.mts +77 -0
- package/dist/keystone/keystone-config-builder.d.mts.map +1 -0
- package/dist/keystone/keystone-config-builder.mjs +157 -0
- package/dist/keystone/keystone-config-builder.mjs.map +1 -0
- package/dist/keystone/keystone-config-builder.respec.d.mts +2 -0
- package/dist/keystone/keystone-config-builder.respec.d.mts.map +1 -0
- package/dist/keystone/keystone-config-builder.respec.mjs +34 -0
- package/dist/keystone/keystone-config-builder.respec.mjs.map +1 -0
- package/dist/keystone/keystone-constants.d.mts +38 -0
- package/dist/keystone/keystone-constants.d.mts.map +1 -0
- package/dist/keystone/keystone-constants.mjs +41 -0
- package/dist/keystone/keystone-constants.mjs.map +1 -0
- package/dist/keystone/keystone-helpers.d.mts +170 -0
- package/dist/keystone/keystone-helpers.d.mts.map +1 -0
- package/dist/keystone/keystone-helpers.mjs +639 -0
- package/dist/keystone/keystone-helpers.mjs.map +1 -0
- package/dist/keystone/keystone-service-v1.d.mts +110 -0
- package/dist/keystone/keystone-service-v1.d.mts.map +1 -0
- package/dist/keystone/keystone-service-v1.mjs +325 -0
- package/dist/keystone/keystone-service-v1.mjs.map +1 -0
- package/dist/keystone/keystone-service-v1.respec.d.mts +2 -0
- package/dist/keystone/keystone-service-v1.respec.d.mts.map +1 -0
- package/dist/keystone/keystone-service-v1.respec.mjs +838 -0
- package/dist/keystone/keystone-service-v1.respec.mjs.map +1 -0
- package/dist/keystone/keystone-types.d.mts +270 -0
- package/dist/keystone/keystone-types.d.mts.map +1 -0
- package/dist/keystone/keystone-types.mjs +50 -0
- package/dist/keystone/keystone-types.mjs.map +1 -0
- package/dist/keystone/strategy/hash-reveal-v1/hash-reveal-v1.d.mts +35 -0
- package/dist/keystone/strategy/hash-reveal-v1/hash-reveal-v1.d.mts.map +1 -0
- package/dist/keystone/strategy/hash-reveal-v1/hash-reveal-v1.mjs +107 -0
- package/dist/keystone/strategy/hash-reveal-v1/hash-reveal-v1.mjs.map +1 -0
- package/dist/keystone/strategy/keystone-strategy-factory.d.mts +15 -0
- package/dist/keystone/strategy/keystone-strategy-factory.d.mts.map +1 -0
- package/dist/keystone/strategy/keystone-strategy-factory.mjs +26 -0
- package/dist/keystone/strategy/keystone-strategy-factory.mjs.map +1 -0
- package/dist/keystone/strategy/keystone-strategy.d.mts +48 -0
- package/dist/keystone/strategy/keystone-strategy.d.mts.map +1 -0
- package/dist/keystone/strategy/keystone-strategy.mjs +14 -0
- package/dist/keystone/strategy/keystone-strategy.mjs.map +1 -0
- package/package.json +2 -1
- package/src/keystone/README.md +162 -0
- package/src/keystone/keystone-config-builder.mts +187 -0
- package/src/keystone/keystone-config-builder.respec.mts +49 -0
- package/src/keystone/keystone-constants.mts +46 -0
- package/src/keystone/keystone-helpers.mts +780 -0
- package/src/keystone/keystone-service-v1.mts +427 -0
- package/src/keystone/keystone-service-v1.respec.mts +1012 -0
- package/src/keystone/keystone-types.mts +339 -0
- package/src/keystone/strategy/hash-reveal-v1/hash-reveal-v1.mts +146 -0
- package/src/keystone/strategy/keystone-strategy-factory.mts +35 -0
- package/src/keystone/strategy/keystone-strategy.mts +71 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { KeystonePoolConfig, KeystonePoolConfig_HashV1, KeystonePoolBehavior, KeystoneReplenishStrategy, KeystonePoolConfigBase } from './keystone-types.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Abstract Base Builder.
|
|
4
|
+
* Handles configuration common to ALL strategies (Salt, Size, Replenishment, Selection).
|
|
5
|
+
*
|
|
6
|
+
* @template TConfig The concrete config type being built.
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class KeystoneConfigBuilderBase<TConfig extends KeystonePoolConfigBase> {
|
|
9
|
+
protected _salt: string;
|
|
10
|
+
protected _size: number;
|
|
11
|
+
protected _replenish: KeystoneReplenishStrategy;
|
|
12
|
+
protected _seq: number;
|
|
13
|
+
protected _rand: number;
|
|
14
|
+
protected _verbs: string[];
|
|
15
|
+
protected _targetBinding: number;
|
|
16
|
+
/**
|
|
17
|
+
* Sets the unique salt/ID for this pool.
|
|
18
|
+
*/
|
|
19
|
+
withSalt(salt: string): this;
|
|
20
|
+
/**
|
|
21
|
+
* Sets the total number of challenges to maintain in the pool.
|
|
22
|
+
*/
|
|
23
|
+
withSize(size: number): this;
|
|
24
|
+
/**
|
|
25
|
+
* Binds challenge selection to the content address of the target.
|
|
26
|
+
* @param chars Number of hex characters to match (e.g. 4).
|
|
27
|
+
*/
|
|
28
|
+
withTargetBinding(chars: number): this;
|
|
29
|
+
/**
|
|
30
|
+
* Configures the pool to use strictly Sequential (FIFO) selection.
|
|
31
|
+
* @param count Number of challenges to consume per sign.
|
|
32
|
+
*/
|
|
33
|
+
withFIFO(count: number): this;
|
|
34
|
+
/**
|
|
35
|
+
* Configures the pool to use strictly Random selection.
|
|
36
|
+
* @param count Number of challenges to consume per sign.
|
|
37
|
+
*/
|
|
38
|
+
withRandom(count: number): this;
|
|
39
|
+
/**
|
|
40
|
+
* Configures the pool to use Hybrid (Both FIFO and Random) selection.
|
|
41
|
+
*/
|
|
42
|
+
withHybrid(seqCount: number, randCount: number): this;
|
|
43
|
+
/**
|
|
44
|
+
* Sets the replenishment strategy.
|
|
45
|
+
*/
|
|
46
|
+
withReplenishStrategy(strategy: KeystoneReplenishStrategy): this;
|
|
47
|
+
/**
|
|
48
|
+
* Constructs the behavioral config object.
|
|
49
|
+
* Helper for subclasses.
|
|
50
|
+
*/
|
|
51
|
+
protected buildBehavior(): KeystonePoolBehavior;
|
|
52
|
+
/**
|
|
53
|
+
* Restricts this pool to specific verbs.
|
|
54
|
+
* @param verbs List of verb addresses (e.g. 'revoke^gib')
|
|
55
|
+
*/
|
|
56
|
+
forVerbs(verbs: string[]): this;
|
|
57
|
+
protected buildBase(): KeystonePoolConfigBase;
|
|
58
|
+
abstract build(): TConfig;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Concrete Builder for Hash-Reveal V1 Strategy.
|
|
62
|
+
*/
|
|
63
|
+
export declare class KeystoneConfigBuilder_HashV1 extends KeystoneConfigBuilderBase<KeystonePoolConfig_HashV1> {
|
|
64
|
+
private _algo;
|
|
65
|
+
private _rounds;
|
|
66
|
+
/**
|
|
67
|
+
* Sets the hashing strength.
|
|
68
|
+
*/
|
|
69
|
+
withHash(algo: 'SHA-256' | 'SHA-512', rounds?: number): this;
|
|
70
|
+
build(): KeystonePoolConfig_HashV1;
|
|
71
|
+
}
|
|
72
|
+
export declare class KeystoneConfig {
|
|
73
|
+
static hash(): KeystoneConfigBuilder_HashV1;
|
|
74
|
+
}
|
|
75
|
+
export declare function createStandardPoolConfig(salt?: string): KeystonePoolConfig;
|
|
76
|
+
export declare function createRevocationPoolConfig(salt?: string): KeystonePoolConfig;
|
|
77
|
+
//# sourceMappingURL=keystone-config-builder.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keystone-config-builder.d.mts","sourceRoot":"","sources":["../../src/keystone/keystone-config-builder.mts"],"names":[],"mappings":"AAAA,OAAO,EACH,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EACzB,MAAM,sBAAsB,CAAC;AAG9B;;;;;GAKG;AACH,8BAAsB,yBAAyB,CAAC,OAAO,SAAS,sBAAsB;IAClF,SAAS,CAAC,KAAK,EAAE,MAAM,CAAa;IACpC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAO;IAC9B,SAAS,CAAC,UAAU,EAAE,yBAAyB,CAAY;IAC3D,SAAS,CAAC,IAAI,EAAE,MAAM,CAAK;IAC3B,SAAS,CAAC,KAAK,EAAE,MAAM,CAAK;IAC5B,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,CAAM;IAChC,SAAS,CAAC,cAAc,EAAE,MAAM,CAAK;IAGrC;;OAEG;IACH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T, POOL_ID_REVOKE, KEYSTONE_VERB_REVOKE } from './keystone-constants.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* Abstract Base Builder.
|
|
5
|
+
* Handles configuration common to ALL strategies (Salt, Size, Replenishment, Selection).
|
|
6
|
+
*
|
|
7
|
+
* @template TConfig The concrete config type being built.
|
|
8
|
+
*/
|
|
9
|
+
export class KeystoneConfigBuilderBase {
|
|
10
|
+
_salt = 'default';
|
|
11
|
+
_size = 100;
|
|
12
|
+
_replenish = 'top-up';
|
|
13
|
+
_seq = 0;
|
|
14
|
+
_rand = 0;
|
|
15
|
+
_verbs = [];
|
|
16
|
+
_targetBinding = 0; // Default 0
|
|
17
|
+
/**
|
|
18
|
+
* Sets the unique salt/ID for this pool.
|
|
19
|
+
*/
|
|
20
|
+
withSalt(salt) {
|
|
21
|
+
this._salt = salt;
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Sets the total number of challenges to maintain in the pool.
|
|
26
|
+
*/
|
|
27
|
+
withSize(size) {
|
|
28
|
+
this._size = size;
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Binds challenge selection to the content address of the target.
|
|
33
|
+
* @param chars Number of hex characters to match (e.g. 4).
|
|
34
|
+
*/
|
|
35
|
+
withTargetBinding(chars) {
|
|
36
|
+
this._targetBinding = chars;
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Configures the pool to use strictly Sequential (FIFO) selection.
|
|
41
|
+
* @param count Number of challenges to consume per sign.
|
|
42
|
+
*/
|
|
43
|
+
withFIFO(count) {
|
|
44
|
+
this._seq = count;
|
|
45
|
+
this._rand = 0;
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Configures the pool to use strictly Random selection.
|
|
50
|
+
* @param count Number of challenges to consume per sign.
|
|
51
|
+
*/
|
|
52
|
+
withRandom(count) {
|
|
53
|
+
this._seq = 0;
|
|
54
|
+
this._rand = count;
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Configures the pool to use Hybrid (Both FIFO and Random) selection.
|
|
59
|
+
*/
|
|
60
|
+
withHybrid(seqCount, randCount) {
|
|
61
|
+
this._seq = seqCount;
|
|
62
|
+
this._rand = randCount;
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Sets the replenishment strategy.
|
|
67
|
+
*/
|
|
68
|
+
withReplenishStrategy(strategy) {
|
|
69
|
+
this._replenish = strategy;
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Constructs the behavioral config object.
|
|
74
|
+
* Helper for subclasses.
|
|
75
|
+
*/
|
|
76
|
+
buildBehavior() {
|
|
77
|
+
return {
|
|
78
|
+
size: this._size,
|
|
79
|
+
replenish: this._replenish,
|
|
80
|
+
selectSequentially: this._seq,
|
|
81
|
+
selectRandomly: this._rand,
|
|
82
|
+
targetBindingChars: this._targetBinding,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Restricts this pool to specific verbs.
|
|
87
|
+
* @param verbs List of verb addresses (e.g. 'revoke^gib')
|
|
88
|
+
*/
|
|
89
|
+
forVerbs(verbs) {
|
|
90
|
+
this._verbs = verbs;
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
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
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Concrete Builder for Hash-Reveal V1 Strategy.
|
|
104
|
+
*/
|
|
105
|
+
export class KeystoneConfigBuilder_HashV1 extends KeystoneConfigBuilderBase {
|
|
106
|
+
_algo = 'SHA-256';
|
|
107
|
+
_rounds = 1;
|
|
108
|
+
/**
|
|
109
|
+
* Sets the hashing strength.
|
|
110
|
+
*/
|
|
111
|
+
withHash(algo, rounds = 1) {
|
|
112
|
+
this._algo = algo;
|
|
113
|
+
this._rounds = rounds;
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
116
|
+
build() {
|
|
117
|
+
return {
|
|
118
|
+
id: this._salt, // Using salt as the unique ID for the pool config
|
|
119
|
+
type: 'hash-reveal-v1',
|
|
120
|
+
salt: this._salt,
|
|
121
|
+
allowedVerbs: this._verbs, // <--- Mapped here
|
|
122
|
+
behavior: this.buildBehavior(),
|
|
123
|
+
algo: this._algo,
|
|
124
|
+
rounds: this._rounds,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// ===========================================================================
|
|
129
|
+
// STATIC ENTRY POINT (Optional Convenience)
|
|
130
|
+
// ===========================================================================
|
|
131
|
+
export class KeystoneConfig {
|
|
132
|
+
static hash() {
|
|
133
|
+
return new KeystoneConfigBuilder_HashV1();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// ===========================================================================
|
|
137
|
+
// FACTORY FUNCTIONS (Presets)
|
|
138
|
+
// ===========================================================================
|
|
139
|
+
export function createStandardPoolConfig(salt = POOL_ID_DEFAULT) {
|
|
140
|
+
return KeystoneConfig.hash()
|
|
141
|
+
.withSalt(salt)
|
|
142
|
+
.withSize(100)
|
|
143
|
+
.withHybrid(2, 2)
|
|
144
|
+
.withReplenishStrategy('top-up')
|
|
145
|
+
.build();
|
|
146
|
+
}
|
|
147
|
+
export function createRevocationPoolConfig(salt = POOL_ID_REVOKE) {
|
|
148
|
+
return KeystoneConfig.hash()
|
|
149
|
+
.withSalt(salt)
|
|
150
|
+
.withHash('SHA-256', 10)
|
|
151
|
+
.withSize(500)
|
|
152
|
+
.withHybrid(10, 10)
|
|
153
|
+
.withReplenishStrategy(KeystoneReplenishStrategy.scorchedEarth)
|
|
154
|
+
.forVerbs([KEYSTONE_VERB_REVOKE])
|
|
155
|
+
.build();
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=keystone-config-builder.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keystone-config-builder.mjs","sourceRoot":"","sources":["../../src/keystone/keystone-config-builder.mts"],"names":[],"mappings":"AAAA,OAAO,EAIH,yBAAyB,EAE5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEjG;;;;;GAKG;AACH,MAAM,OAAgB,yBAAyB;IACjC,KAAK,GAAW,SAAS,CAAC;IAC1B,KAAK,GAAW,GAAG,CAAC;IACpB,UAAU,GAA8B,QAAQ,CAAC;IACjD,IAAI,GAAW,CAAC,CAAC;IACjB,KAAK,GAAW,CAAC,CAAC;IAClB,MAAM,GAAa,EAAE,CAAC;IACtB,cAAc,GAAW,CAAC,CAAC,CAAC,YAAY;IAGlD;;OAEG;IACH,QAAQ,CAAC,IAAY;QACjB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,IAAY;QACjB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;MAGE;IACF,iBAAiB,CAAC,KAAa;QAC3B,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;QAC5B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,KAAa;QAClB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACf,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,KAAa;QACpB,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QAC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appings":""}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { iReckon, respecfullyDear, ifWeMight } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
2
|
+
const maam = `[${import.meta.url}]`, sir = maam;
|
|
3
|
+
import { GLOBAL_LOG_A_LOT } from '../core-constants.mjs';
|
|
4
|
+
import { createRevocationPoolConfig, createStandardPoolConfig } from './keystone-config-builder.mjs';
|
|
5
|
+
import { KEYSTONE_VERB_REVOKE, } from './keystone-constants.mjs';
|
|
6
|
+
const logalot = GLOBAL_LOG_A_LOT;
|
|
7
|
+
await respecfullyDear(sir, 'Config Builders', async () => {
|
|
8
|
+
await ifWeMight(sir, 'createStandardPoolConfig defaults are correct', async () => {
|
|
9
|
+
const config = createStandardPoolConfig("test_salt");
|
|
10
|
+
iReckon(sir, config.salt).willEqual("test_salt");
|
|
11
|
+
iReckon(sir, config.id).willEqual("test_salt");
|
|
12
|
+
iReckon(sir, config.type).willEqual("hash-reveal-v1");
|
|
13
|
+
// Behavior check
|
|
14
|
+
const b = config.behavior;
|
|
15
|
+
iReckon(sir, b.size).willEqual(100);
|
|
16
|
+
iReckon(sir, b.selectSequentially).willEqual(2);
|
|
17
|
+
iReckon(sir, b.selectRandomly).willEqual(2);
|
|
18
|
+
iReckon(sir, b.replenish).willEqual("top-up");
|
|
19
|
+
// Verbs should be empty/undefined (permissive)
|
|
20
|
+
iReckon(sir, config.allowedVerbs.length).willEqual(0);
|
|
21
|
+
});
|
|
22
|
+
await ifWeMight(sir, 'createRevocationPoolConfig defaults are correct', async () => {
|
|
23
|
+
const config = createRevocationPoolConfig("revoke_salt");
|
|
24
|
+
iReckon(sir, config.salt).willEqual("revoke_salt");
|
|
25
|
+
// Behavior check
|
|
26
|
+
const b = config.behavior;
|
|
27
|
+
iReckon(sir, b.size).willEqual(500); // Higher security
|
|
28
|
+
iReckon(sir, b.replenish).willEqual("scorched-earth");
|
|
29
|
+
// Verbs should be restricted
|
|
30
|
+
iReckon(sir, config.allowedVerbs).includes(KEYSTONE_VERB_REVOKE);
|
|
31
|
+
iReckon(sir, config.allowedVerbs.length).willEqual(1);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=keystone-config-builder.respec.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keystone-config-builder.respec.mjs","sourceRoot":"","sources":["../../src/keystone/keystone-config-builder.respec.mts"],"names":[],"mappings":"AAAA,OAAO,EACU,OAAO,EAAwD,eAAe,EAAE,SAAS,EACzG,MAAM,kDAAkD,CAAC;AAC1D,MAAM,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACrG,OAAO,EAAE,oBAAoB,GAAG,MAAM,0BAA0B,CAAC;AAEjE,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAGjC,MAAM,eAAe,CAAC,GAAG,EAAE,iBAAiB,EAAE,KAAK,IAAI,EAAE;IAErD,MAAM,SAAS,CAAC,GAAG,EAAE,+CAA+C,EAAE,KAAK,IAAI,EAAE;QAC7E,MAAM,MAAM,GAAG,wBAAwB,CAAC,WAAW,CAA8B,CAAC;QAElF,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QACjD,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAC/C,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;QAEtD,iBAAiB;QACjB,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC;QAC1B,OAAO,CAAC,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AC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare const KEYSTONE_ATOM = "keystone";
|
|
2
|
+
/**
|
|
3
|
+
* @see {@link KeystoneVerb.REVOKE}
|
|
4
|
+
*/
|
|
5
|
+
export declare const KEYSTONE_VERB_REVOKE = "revoke";
|
|
6
|
+
/**
|
|
7
|
+
* @see {@link KeystoneVerb.MANAGE}
|
|
8
|
+
*/
|
|
9
|
+
export declare const KEYSTONE_VERB_MANAGE = "manage";
|
|
10
|
+
export type KeystoneVerb = typeof KEYSTONE_VERB_REVOKE | typeof KEYSTONE_VERB_MANAGE;
|
|
11
|
+
/**
|
|
12
|
+
* Verbs that describe actions that can be authorized by a Keystone.
|
|
13
|
+
*/
|
|
14
|
+
export declare const KeystoneVerb: {
|
|
15
|
+
/**
|
|
16
|
+
* The specific ibGib address for the 'revoke' verb.
|
|
17
|
+
* Used in Claims to indicate the Keystone should be considered dead.
|
|
18
|
+
*/
|
|
19
|
+
REVOKE: "revoke";
|
|
20
|
+
/**
|
|
21
|
+
* The meta-verb used to authorize structural changes to the Keystone,
|
|
22
|
+
* specifically adding or removing challenge pools.
|
|
23
|
+
*
|
|
24
|
+
* "Root access" to the identity.
|
|
25
|
+
*
|
|
26
|
+
* Basically, this is the verb for the "admin" pool.
|
|
27
|
+
*/
|
|
28
|
+
MANAGE: "manage";
|
|
29
|
+
};
|
|
30
|
+
export declare const KEYSTONE_VERB_VALID_VALUES: ("revoke" | "manage")[];
|
|
31
|
+
export declare function isKeystoneVerb(value: string): value is KeystoneVerb;
|
|
32
|
+
/**
|
|
33
|
+
* Standard pool IDs can be conventionally named after their primary verb.
|
|
34
|
+
*/
|
|
35
|
+
export declare const POOL_ID_REVOKE = "revoke";
|
|
36
|
+
export declare const POOL_ID_MANAGE = "manage";
|
|
37
|
+
export declare const POOL_ID_DEFAULT = "default";
|
|
38
|
+
//# sourceMappingURL=keystone-constants.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keystone-constants.d.mts","sourceRoot":"","sources":["../../src/keystone/keystone-constants.mts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,aAAa,CAAC;AAGxC;;GAEG;AACH,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAC7C;;GAEG;AACH,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAC7C,MAAM,MAAM,YAAY,GAClB,OAAO,oBAAoB,GAC3B,OAAO,oBAAoB,CAAC;AAElC;;GAEG;AACH,eAAO,MAAM,YAAY;IACrB;;;OAGG;;IAEH;;;;;;;OAOG;;CAEoC,CAAC;AAC5C,eAAO,MAAM,0BAA0B,yBAA8B,CAAC;AACtE,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,YAAY,CAEnE;AAGD;;GAEG;AACH,eAAO,MAAM,cAAc,WAAuB,CAAC;AACnD,eAAO,MAAM,cAAc,WAAuB,CAAC;AACnD,eAAO,MAAM,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const KEYSTONE_ATOM = "keystone";
|
|
2
|
+
// #region KeystoneVerb enum
|
|
3
|
+
/**
|
|
4
|
+
* @see {@link KeystoneVerb.REVOKE}
|
|
5
|
+
*/
|
|
6
|
+
export const KEYSTONE_VERB_REVOKE = "revoke";
|
|
7
|
+
/**
|
|
8
|
+
* @see {@link KeystoneVerb.MANAGE}
|
|
9
|
+
*/
|
|
10
|
+
export const KEYSTONE_VERB_MANAGE = "manage";
|
|
11
|
+
/**
|
|
12
|
+
* Verbs that describe actions that can be authorized by a Keystone.
|
|
13
|
+
*/
|
|
14
|
+
export const KeystoneVerb = {
|
|
15
|
+
/**
|
|
16
|
+
* The specific ibGib address for the 'revoke' verb.
|
|
17
|
+
* Used in Claims to indicate the Keystone should be considered dead.
|
|
18
|
+
*/
|
|
19
|
+
REVOKE: KEYSTONE_VERB_REVOKE,
|
|
20
|
+
/**
|
|
21
|
+
* The meta-verb used to authorize structural changes to the Keystone,
|
|
22
|
+
* specifically adding or removing challenge pools.
|
|
23
|
+
*
|
|
24
|
+
* "Root access" to the identity.
|
|
25
|
+
*
|
|
26
|
+
* Basically, this is the verb for the "admin" pool.
|
|
27
|
+
*/
|
|
28
|
+
MANAGE: KEYSTONE_VERB_MANAGE,
|
|
29
|
+
};
|
|
30
|
+
export const KEYSTONE_VERB_VALID_VALUES = Object.values(KeystoneVerb);
|
|
31
|
+
export function isKeystoneVerb(value) {
|
|
32
|
+
return KEYSTONE_VERB_VALID_VALUES.includes(value);
|
|
33
|
+
}
|
|
34
|
+
// #endregion KeystoneVerb enum
|
|
35
|
+
/**
|
|
36
|
+
* Standard pool IDs can be conventionally named after their primary verb.
|
|
37
|
+
*/
|
|
38
|
+
export const POOL_ID_REVOKE = KEYSTONE_VERB_REVOKE;
|
|
39
|
+
export const POOL_ID_MANAGE = KEYSTONE_VERB_MANAGE;
|
|
40
|
+
export const POOL_ID_DEFAULT = "default";
|
|
41
|
+
//# sourceMappingURL=keystone-constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keystone-constants.mjs","sourceRoot":"","sources":["../../src/keystone/keystone-constants.mts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC;AAExC,4BAA4B;AAC5B;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAC;AAC7C;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAC;AAK7C;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB;;;OAGG;IACH,MAAM,EAAE,oBAAoB;IAC5B;;;;;;;OAOG;IACH,MAAM,EAAE,oBAAoB;CACW,CAAC;AAC5C,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AACtE,MAAM,UAAU,cAAc,CAAC,KAAa;IACxC,OAAO,0BAA0B,CAAC,QAAQ,CAAC,KAAqB,CAAC,CAAC;AACtE,CAAC;AACD,+BAA+B;AAE/B;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,CAAC;AACnD,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,CAAC;AACnD,MAAM,CAAC,MAAM,eAAe,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { Ib } from "@ibgib/ts-gib/dist/types.mjs";
|
|
2
|
+
import { KeystoneData_V1, KeystoneIbGib_V1, KeystoneIbInfo_V1, KeystoneChallengePool, DeterministicResult, KeystoneProof, KeystonePoolConfig, KeystoneClaim } from "./keystone-types.mjs";
|
|
3
|
+
import { MetaspaceService } from "../witness/space/metaspace/metaspace-types.mjs";
|
|
4
|
+
import { IbGibSpaceAny } from "../witness/space/space-base-v1.mjs";
|
|
5
|
+
/**
|
|
6
|
+
* space-delimited keystone ib containing select keystone metadata.
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This must match {@link parseKeystoneIb}
|
|
9
|
+
* @see {@link KeystoneIbInfo_V1}
|
|
10
|
+
*/
|
|
11
|
+
export declare function getKeystoneIb({ keystoneData, }: {
|
|
12
|
+
keystoneData: KeystoneData_V1;
|
|
13
|
+
}): Promise<Ib>;
|
|
14
|
+
/**
|
|
15
|
+
* NOTE: This must match {@link getKeystoneIb}
|
|
16
|
+
* @see {@link KeystoneIbInfo_V1}
|
|
17
|
+
*/
|
|
18
|
+
export declare function parseKeystoneIb({ ib, }: {
|
|
19
|
+
ib: Ib;
|
|
20
|
+
}): Promise<KeystoneIbInfo_V1>;
|
|
21
|
+
/**
|
|
22
|
+
* The Policy Engine.
|
|
23
|
+
* Calculates exactly which challenges MUST be consumed based on config and demands.
|
|
24
|
+
* Enforces STRICT DISTINCTNESS (No double-dipping).
|
|
25
|
+
*/
|
|
26
|
+
export declare function getDeterministicRequirements({ pool, requiredChallengeIds, targetAddr }: {
|
|
27
|
+
pool: KeystoneChallengePool;
|
|
28
|
+
requiredChallengeIds?: string[];
|
|
29
|
+
targetAddr?: string;
|
|
30
|
+
}): DeterministicResult;
|
|
31
|
+
/**
|
|
32
|
+
* Helper to update the Binding Map when adding new Challenge IDs.
|
|
33
|
+
* Uses "Implicit Bucketing" (ID start char) but can be extended for full coverage.
|
|
34
|
+
*/
|
|
35
|
+
export declare function addToBindingMap(map: {
|
|
36
|
+
[char: string]: string[];
|
|
37
|
+
}, challengeId: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Helper to clean up Binding Map when removing IDs.
|
|
40
|
+
*/
|
|
41
|
+
export declare function removeFromBindingMap(map: {
|
|
42
|
+
[char: string]: string[];
|
|
43
|
+
}, challengeId: string): void;
|
|
44
|
+
/**
|
|
45
|
+
* Selects the specific pool to use for an operation based on ID, filter criteria, or verb authorization.
|
|
46
|
+
*
|
|
47
|
+
* @returns The matching KeystoneChallengePool
|
|
48
|
+
* @throws If no pool matches or if multiple pools match but one was expected.
|
|
49
|
+
*/
|
|
50
|
+
export declare function resolveTargetPool({ pools, poolId, poolFilter, verb, }: {
|
|
51
|
+
pools: KeystoneChallengePool[];
|
|
52
|
+
/**
|
|
53
|
+
* Explicit ID of the pool to use.
|
|
54
|
+
*/
|
|
55
|
+
poolId?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Optional predicate to find a pool.
|
|
58
|
+
* Useful for finding delegates via metadata.
|
|
59
|
+
*/
|
|
60
|
+
poolFilter?: (pool: KeystoneChallengePool) => boolean;
|
|
61
|
+
/**
|
|
62
|
+
* The verb being performed (e.g. 'revoke', 'manage', 'post').
|
|
63
|
+
* Used for authorization checks and auto-resolution.
|
|
64
|
+
*/
|
|
65
|
+
verb?: string;
|
|
66
|
+
}): KeystoneChallengePool;
|
|
67
|
+
/**
|
|
68
|
+
* Calculates the complete list of Challenge IDs to solve for a given operation.
|
|
69
|
+
* Combines Deterministic requirements (Mandatory/Binding/FIFO) with Stochastic requirements.
|
|
70
|
+
*
|
|
71
|
+
* @returns Array of unique challenge IDs.
|
|
72
|
+
*/
|
|
73
|
+
export declare function selectChallengeIds({ pool, targetAddr, requiredChallengeIds, }: {
|
|
74
|
+
pool: KeystoneChallengePool;
|
|
75
|
+
/**
|
|
76
|
+
* The address of the target ibgib (used for binding entropy).
|
|
77
|
+
*/
|
|
78
|
+
targetAddr?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Explicit demands from a verifier.
|
|
81
|
+
*/
|
|
82
|
+
requiredChallengeIds?: string[];
|
|
83
|
+
}): string[];
|
|
84
|
+
/**
|
|
85
|
+
* Generates an opaque, collision-resistant ID for a challenge.
|
|
86
|
+
* atow (2025/12/22) - Hash(Salt + Timestamp + Index)
|
|
87
|
+
*/
|
|
88
|
+
export declare function generateOpaqueChallengeId({ salt, timestamp, index }: {
|
|
89
|
+
salt: string;
|
|
90
|
+
timestamp: string;
|
|
91
|
+
index: number;
|
|
92
|
+
}): Promise<string>;
|
|
93
|
+
/**
|
|
94
|
+
* Calculates the NEXT state of the Challenge Pools given a specific consumption event.
|
|
95
|
+
* Handles TopUp, ReplaceAll, Consume, and ScorchedEarth strategies.
|
|
96
|
+
*
|
|
97
|
+
* @returns The new array of KeystoneChallengePools (including the modified one).
|
|
98
|
+
*/
|
|
99
|
+
export declare function applyReplenishmentStrategy({ prevPools, targetPoolId, consumedIds, masterSecret, strategy, config, }: {
|
|
100
|
+
prevPools: KeystoneChallengePool[];
|
|
101
|
+
targetPoolId: string;
|
|
102
|
+
consumedIds: string[];
|
|
103
|
+
masterSecret: string;
|
|
104
|
+
/**
|
|
105
|
+
* The instantiated KeystoneStrategy (e.g. HashRevealV1) used to generate new challenges.
|
|
106
|
+
*/
|
|
107
|
+
strategy: any;
|
|
108
|
+
config: KeystonePoolConfig;
|
|
109
|
+
}): Promise<KeystoneChallengePool[]>;
|
|
110
|
+
/**
|
|
111
|
+
* High-level orchestration helper.
|
|
112
|
+
* 1. Instantiates Strategy.
|
|
113
|
+
* 2. Derives Secret.
|
|
114
|
+
* 3. Solves Challenges (Generates Solutions).
|
|
115
|
+
* 4. Replenishes Pool (Calculates the next state of ALL pools).
|
|
116
|
+
* 5. Constructs Proof.
|
|
117
|
+
*
|
|
118
|
+
* @returns The resulting Proof and the full list of Next Pools.
|
|
119
|
+
*/
|
|
120
|
+
export declare function solveAndReplenish({ targetPoolId, prevPools, masterSecret, challengeIds, claim, requiredChallengeIds, }: {
|
|
121
|
+
/**
|
|
122
|
+
* The ID of the pool to use for signing.
|
|
123
|
+
*/
|
|
124
|
+
targetPoolId: string;
|
|
125
|
+
/**
|
|
126
|
+
* The full list of pools from the previous Keystone frame.
|
|
127
|
+
* Required to reconstruct the full state for the next frame.
|
|
128
|
+
*/
|
|
129
|
+
prevPools: KeystoneChallengePool[];
|
|
130
|
+
masterSecret: string;
|
|
131
|
+
challengeIds: string[];
|
|
132
|
+
claim: Partial<KeystoneClaim>;
|
|
133
|
+
requiredChallengeIds?: string[];
|
|
134
|
+
}): Promise<{
|
|
135
|
+
proof: KeystoneProof;
|
|
136
|
+
nextPools: KeystoneChallengePool[];
|
|
137
|
+
}>;
|
|
138
|
+
/**
|
|
139
|
+
* Validates the transition from Prev -> Curr.
|
|
140
|
+
* Enforces Cryptography AND Behavioral Policy.
|
|
141
|
+
*
|
|
142
|
+
* @returns Array of validation error strings. Empty array means Valid.
|
|
143
|
+
*/
|
|
144
|
+
export declare function validateKeystoneTransition({ currentIbGib, prevIbGib, }: {
|
|
145
|
+
currentIbGib: KeystoneIbGib_V1;
|
|
146
|
+
prevIbGib: KeystoneIbGib_V1;
|
|
147
|
+
}): Promise<string[]>;
|
|
148
|
+
/**
|
|
149
|
+
* Helper to verify a single proof against a specific pool.
|
|
150
|
+
*/
|
|
151
|
+
export declare function verifyProofAgainstPool({ proof, pool, errors, }: {
|
|
152
|
+
proof: KeystoneProof;
|
|
153
|
+
pool: KeystoneChallengePool;
|
|
154
|
+
errors: string[];
|
|
155
|
+
}): Promise<void>;
|
|
156
|
+
export declare function evolvePersistAndRegisterKeystone({ prevIbGib, newData, metaspace, space, }: {
|
|
157
|
+
prevIbGib: KeystoneIbGib_V1;
|
|
158
|
+
newData: KeystoneData_V1;
|
|
159
|
+
metaspace: MetaspaceService;
|
|
160
|
+
space: IbGibSpaceAny;
|
|
161
|
+
}): Promise<KeystoneIbGib_V1>;
|
|
162
|
+
/**
|
|
163
|
+
* Creates a new keystone ibgib that has no dna and no past.
|
|
164
|
+
*/
|
|
165
|
+
export declare function createKeystoneIbGibImpl({ data, metaspace, space, }: {
|
|
166
|
+
data: KeystoneData_V1;
|
|
167
|
+
metaspace: MetaspaceService;
|
|
168
|
+
space?: IbGibSpaceAny;
|
|
169
|
+
}): Promise<KeystoneIbGib_V1>;
|
|
170
|
+
//# sourceMappingURL=keystone-helpers.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keystone-helpers.d.mts","sourceRoot":"","sources":["../../src/keystone/keystone-helpers.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAmB,MAAM,8BAA8B,CAAC;AASnE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,aAAa,EAAE,kBAAkB,EAAuE,aAAa,EAAoB,MAAM,sBAAsB,CAAC;AACjR,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAKnE;;;;;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,iBAAiB,CAAC,CAqB7B;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,EACzC,IAAI,EAC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