@safetech/inheriti-client-sdk 1.17.2 → 1.17.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/browser.d.ts +23 -0
- package/dist/browser.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/inheriti-client-sdk.umd.js +86 -83
- package/dist/node.d.ts +12 -3
- package/dist/node.js +1 -1
- package/dist/sdk-types.d.ts +711 -19
- package/dist/src/auth/inheriti-client-provider.d.ts +1 -1
- package/dist/src/elements/core-plan-material-builder.d.ts +40 -0
- package/dist/src/elements/elements-api-port.d.ts +88 -3
- package/dist/src/elements/elements-client.d.ts +58 -12
- package/dist/src/elements/guided-plan-creator.d.ts +47 -0
- package/dist/src/elements/http-elements-api-port.d.ts +17 -1
- package/dist/src/elements/index.d.ts +10 -1
- package/dist/src/elements/plan-operation-codec.d.ts +4 -0
- package/dist/src/elements/plan-operations.d.ts +160 -0
- package/dist/src/elements/polling-shared-plan-event-listener.d.ts +29 -0
- package/dist/src/elements/reveal-session-operations.d.ts +13 -0
- package/dist/src/elements/scoped-reveal.d.ts +44 -0
- package/dist/src/operator-auth/defaults.d.ts +9 -0
- package/dist/src/operator-auth/errors.d.ts +11 -0
- package/dist/src/operator-auth/http-operator-auth-transport.d.ts +16 -0
- package/dist/src/operator-auth/index.d.ts +7 -0
- package/dist/src/operator-auth/operator-auth-client.d.ts +35 -0
- package/dist/src/operator-auth/operator-session-controller.d.ts +10 -0
- package/dist/src/operator-auth/ports.d.ts +53 -0
- package/dist/src/operator-auth/types.d.ts +77 -0
- package/docs/docs.json +18331 -0
- package/docs/elements-shared-mode.md +28 -0
- package/docs/operator-auth.md +76 -0
- package/docs/plan-operations.md +41 -0
- package/index.ts +1 -0
- package/node.ts +21 -4
- package/package.json +14 -3
|
@@ -31,4 +31,4 @@ export interface InheritiClientProviderProps {
|
|
|
31
31
|
*
|
|
32
32
|
* @param props - The provider props including children, clientId, and options.
|
|
33
33
|
*/
|
|
34
|
-
export default function InheritiClientProvider({ children, clientId, options }: InheritiClientProviderProps): import("react
|
|
34
|
+
export default function InheritiClientProvider({ children, clientId, options }: InheritiClientProviderProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { DataAsset, MasterKeySource } from '@safetech/inheriti-core-sdk';
|
|
2
|
+
import type { SDKContainer } from '@safetech/inheriti-core-sdk/vanilla';
|
|
3
|
+
import type { PlanMaterialBuilder } from './guided-plan-creator';
|
|
4
|
+
import type { EncryptedPlanMaterial, StartPlanCreationInput } from './plan-operations';
|
|
5
|
+
export interface CorePlanSecrets {
|
|
6
|
+
assets: DataAsset[];
|
|
7
|
+
/** Number of non-custodian share destinations. */
|
|
8
|
+
totalShares: number;
|
|
9
|
+
threshold: number;
|
|
10
|
+
withCustodian?: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface PreparedCorePlanMaterial {
|
|
13
|
+
data: Uint8Array;
|
|
14
|
+
assets: DataAsset[];
|
|
15
|
+
totalShares: number;
|
|
16
|
+
threshold: number;
|
|
17
|
+
withCustodian: boolean;
|
|
18
|
+
masterKey: string;
|
|
19
|
+
}
|
|
20
|
+
/** Uses Core's registered SSDP+ generator and production share sealer as one guided-create adapter. */
|
|
21
|
+
export declare class CorePlanMaterialBuilder implements PlanMaterialBuilder<CorePlanSecrets, PreparedCorePlanMaterial> {
|
|
22
|
+
private readonly masterKeySource;
|
|
23
|
+
private readonly generator;
|
|
24
|
+
private readonly sealer;
|
|
25
|
+
constructor(coreSdk: SDKContainer, masterKeySource: MasterKeySource);
|
|
26
|
+
encrypt(input: {
|
|
27
|
+
planId: string;
|
|
28
|
+
declaration: StartPlanCreationInput;
|
|
29
|
+
secrets: CorePlanSecrets;
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
}): Promise<PreparedCorePlanMaterial>;
|
|
32
|
+
generateShares(input: {
|
|
33
|
+
planId: string;
|
|
34
|
+
declaration: StartPlanCreationInput;
|
|
35
|
+
encrypted: PreparedCorePlanMaterial;
|
|
36
|
+
signal?: AbortSignal;
|
|
37
|
+
}): Promise<EncryptedPlanMaterial>;
|
|
38
|
+
private sealCustodianPair;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -10,7 +10,7 @@ export interface CollectedPlanMaterial {
|
|
|
10
10
|
}>;
|
|
11
11
|
verifiedStorageLayerTypes: string[];
|
|
12
12
|
/** True when `planKey` is still sealed under a master key and must be unwrapped. */
|
|
13
|
-
masterKeyWrapped
|
|
13
|
+
masterKeyWrapped: boolean;
|
|
14
14
|
/** The tenant holding the plan. With no source reference, this names the key. */
|
|
15
15
|
tenantId?: string;
|
|
16
16
|
/** Present when the plan came from another system, whose key still opens it. */
|
|
@@ -32,6 +32,12 @@ export interface PlanKeyReference {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
export interface ElementsApiPort {
|
|
35
|
+
listPlans(input?: import('./plan-operations').ListPlansInput): Promise<import('./plan-operations').PlanPage>;
|
|
36
|
+
getPlan(planId: string): Promise<import('./plan-operations').PlanDetail>;
|
|
37
|
+
startPlanCreation(input: import('./plan-operations').StartPlanCreationInput): Promise<import('./plan-operations').PlanCreationProgress>;
|
|
38
|
+
getPlanCreation(operationId: string): Promise<import('./plan-operations').PlanCreationProgress>;
|
|
39
|
+
supplyPlanCreationMaterial(operationId: string, material: import('./plan-operations').EncryptedPlanMaterial): Promise<import('./plan-operations').PlanCreationProgress>;
|
|
40
|
+
cancelPlanCreation(operationId: string): Promise<import('./plan-operations').PlanCreationProgress>;
|
|
35
41
|
planKeyReference(planId: string): Promise<PlanKeyReference>;
|
|
36
42
|
collectPlanMaterial(planId: string, stepUp?: StepUpReadContext): Promise<CollectedPlanMaterial>;
|
|
37
43
|
initializeGovernedReveal(planId: string, stepUp?: StepUpReadContext): Promise<GovernedRevealSession>;
|
|
@@ -42,6 +48,15 @@ export interface ElementsApiPort {
|
|
|
42
48
|
markGovernedSharesReconstructed(processId: string): Promise<void>;
|
|
43
49
|
markGovernedDataRevealed(processId: string): Promise<void>;
|
|
44
50
|
closeGovernedReveal(processId: string): Promise<void>;
|
|
51
|
+
startReveal(planId: string, input: StartRevealInput): Promise<RevealSession>;
|
|
52
|
+
getReveal(revealId: string): Promise<RevealSession>;
|
|
53
|
+
releaseRevealMaterial(revealId: string, materialVersion: string): Promise<unknown>;
|
|
54
|
+
reportRevealReconstruction(revealId: string, input: RevealReconstructionInput): Promise<RevealSession>;
|
|
55
|
+
closeReveal(revealId: string, reason: RevealCloseReason): Promise<RevealSession>;
|
|
56
|
+
authorizeRevealAction(revealId: string, input: AuthorizeRevealActionInput): Promise<RevealAction>;
|
|
57
|
+
reportRevealActionOutcome(revealId: string, actionId: string, input: ReportRevealActionOutcomeInput): Promise<RevealAction>;
|
|
58
|
+
getCustodianShare(processId: string, stepUp?: StepUpReadContext): Promise<CustodianShareResult>;
|
|
59
|
+
releaseCustodianShare(processId: string): Promise<void>;
|
|
45
60
|
exportPlanBridge(planId: string, input: ExportPlanBridgeInput): Promise<PlanBridgeEnvelope>;
|
|
46
61
|
importPlanBridge(envelope: PlanBridgeEnvelope): Promise<{
|
|
47
62
|
planId: string;
|
|
@@ -59,7 +74,7 @@ export interface ExportPlanBridgeInput {
|
|
|
59
74
|
}
|
|
60
75
|
export interface PlanRevealProfile {
|
|
61
76
|
governance: 'KEEP' | 'BYPASS';
|
|
62
|
-
masterKeyRelease: 'REQUIRED'
|
|
77
|
+
masterKeyRelease: 'REQUIRED';
|
|
63
78
|
custodian: 'BYPASS' | 'FORCE';
|
|
64
79
|
}
|
|
65
80
|
export interface PlanBridgeEnvelope {
|
|
@@ -136,7 +151,7 @@ export interface GovernedRevealSession {
|
|
|
136
151
|
mergeThreshold: number;
|
|
137
152
|
status?: string;
|
|
138
153
|
/** Same key signalling the direct collection route returns, for the governed path. */
|
|
139
|
-
masterKeyWrapped
|
|
154
|
+
masterKeyWrapped: boolean;
|
|
140
155
|
tenantId?: string;
|
|
141
156
|
sourceReference?: {
|
|
142
157
|
system: string;
|
|
@@ -167,6 +182,76 @@ export interface GovernedSharesMaterial {
|
|
|
167
182
|
keyShards: GovernedShare[];
|
|
168
183
|
dek: string;
|
|
169
184
|
}
|
|
185
|
+
export type RevealMode = 'DIRECT' | 'GOVERNED';
|
|
186
|
+
export type RevealStage = 'STARTING' | 'WAITING_FOR_PARTICIPANTS' | 'AUTHORIZED' | 'MATERIAL_AUTHORIZED' | 'MATERIAL_RELEASED' | 'RECONSTRUCTED' | 'ACTIONS_OPEN' | 'CLOSING' | 'CLOSED' | 'DENIED' | 'PARTICIPANT_REVOKED' | 'RECONCILIATION_REQUIRED' | 'EXPIRED' | 'CANCELED' | 'FAILED';
|
|
187
|
+
export type RevealCloseReason = 'COMPLETED' | 'CANCELED' | 'ERROR';
|
|
188
|
+
export type RevealActionType = 'VIEW_FIELD' | 'COPY_FIELD' | 'EXPORT_ASSET' | 'AUTOFILL_FIELD' | 'INSERT_FIELD';
|
|
189
|
+
export type RevealActionOutcome = 'SUCCEEDED' | 'FAILED' | 'CANCELED';
|
|
190
|
+
export interface StartRevealInput {
|
|
191
|
+
mode: RevealMode;
|
|
192
|
+
idempotencyKey: string;
|
|
193
|
+
}
|
|
194
|
+
export interface RevealReconstructionInput {
|
|
195
|
+
status: 'SUCCEEDED' | 'FAILED';
|
|
196
|
+
errorCode?: string;
|
|
197
|
+
}
|
|
198
|
+
export interface RevealSession {
|
|
199
|
+
id: string;
|
|
200
|
+
idempotencyKey: string;
|
|
201
|
+
applicationId: string;
|
|
202
|
+
environment: 'TEST' | 'LIVE';
|
|
203
|
+
planId: string;
|
|
204
|
+
mode: RevealMode;
|
|
205
|
+
stage: RevealStage;
|
|
206
|
+
materialVersion?: string;
|
|
207
|
+
expiresAt: string;
|
|
208
|
+
createdAt: string;
|
|
209
|
+
updatedAt: string;
|
|
210
|
+
participantDecisions?: unknown;
|
|
211
|
+
/** Server-resolved governed progress. Omitted for direct reveals or unavailable source progress. */
|
|
212
|
+
approvedModerators?: number;
|
|
213
|
+
requiredModerators?: number;
|
|
214
|
+
closedReason?: RevealCloseReason;
|
|
215
|
+
}
|
|
216
|
+
export interface AuthorizeRevealActionInput {
|
|
217
|
+
idempotencyKey: string;
|
|
218
|
+
assetId: string;
|
|
219
|
+
fieldName?: string;
|
|
220
|
+
action: RevealActionType;
|
|
221
|
+
origin?: string;
|
|
222
|
+
}
|
|
223
|
+
export interface ReportRevealActionOutcomeInput {
|
|
224
|
+
idempotencyKey: string;
|
|
225
|
+
outcome: RevealActionOutcome;
|
|
226
|
+
reportedAt: string;
|
|
227
|
+
errorCode?: string;
|
|
228
|
+
}
|
|
229
|
+
export interface RevealAction {
|
|
230
|
+
id: string;
|
|
231
|
+
revealId: string;
|
|
232
|
+
assetId: string;
|
|
233
|
+
fieldName?: string;
|
|
234
|
+
action: RevealActionType;
|
|
235
|
+
status: 'AUTHORIZED' | RevealActionOutcome;
|
|
236
|
+
origin?: string;
|
|
237
|
+
outcome?: RevealActionOutcome;
|
|
238
|
+
errorCode?: string;
|
|
239
|
+
createdAt?: string;
|
|
240
|
+
updatedAt?: string;
|
|
241
|
+
}
|
|
242
|
+
export type CustodianShareResult = {
|
|
243
|
+
status: 'PENDING';
|
|
244
|
+
} | {
|
|
245
|
+
id: string;
|
|
246
|
+
shares: string[];
|
|
247
|
+
planId: string;
|
|
248
|
+
isMergeAuthority: boolean;
|
|
249
|
+
};
|
|
250
|
+
export declare class RevealActionsNotOpen extends Error {
|
|
251
|
+
readonly stage: string;
|
|
252
|
+
readonly code = "reveal_actions_not_open";
|
|
253
|
+
constructor(stage: string);
|
|
254
|
+
}
|
|
170
255
|
export declare class ElementsApiPortRequired extends Error {
|
|
171
256
|
constructor();
|
|
172
257
|
}
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import type { SDKContainer } from '@safetech/inheriti-core-sdk/vanilla';
|
|
2
2
|
import type { KeyVault } from './key-vault';
|
|
3
3
|
import type { StatePort } from './state-port';
|
|
4
|
-
import type { CollectedPlanMaterial, ElementsApiPort, ExportPlanBridgeInput, GovernedRevealSession, GovernedRevealState, PlanBridgeEnvelope, StepUpReadContext } from './elements-api-port';
|
|
4
|
+
import type { AuthorizeRevealActionInput, CollectedPlanMaterial, CustodianShareResult, ElementsApiPort, ExportPlanBridgeInput, GovernedRevealSession, GovernedRevealState, PlanBridgeEnvelope, ReportRevealActionOutcomeInput, RevealAction, RevealCloseReason, RevealReconstructionInput, RevealSession, StartRevealInput, StepUpReadContext } from './elements-api-port';
|
|
5
5
|
import type { PlanMaterialReconstructor } from './plan-material-reconstructor';
|
|
6
6
|
import type { MasterKeyResolver } from './master-key';
|
|
7
|
+
import type { PlanAssetDeclaration } from '@safetech/inheriti-core-sdk';
|
|
8
|
+
import type { EncryptedPlanMaterial, ListPlansInput, PlanCreationProgress, PlanDetail, PlanPage, StartPlanCreationInput } from './plan-operations';
|
|
9
|
+
import type { GuidedCreateCheckpointStore } from './guided-plan-creator';
|
|
10
|
+
import { GuidedPlanCreator } from './guided-plan-creator';
|
|
11
|
+
import type { OpenRevealOptions, RevealHandle } from './scoped-reveal';
|
|
12
|
+
export interface DecodedPlanAsset {
|
|
13
|
+
id: string;
|
|
14
|
+
data: Uint8Array;
|
|
15
|
+
}
|
|
16
|
+
export type PlanAssetContainerDecoder = (material: Uint8Array) => readonly DecodedPlanAsset[];
|
|
7
17
|
export interface ElementsClientOptions {
|
|
8
18
|
coreSdk: SDKContainer;
|
|
9
19
|
keyVault?: KeyVault;
|
|
@@ -14,12 +24,13 @@ export interface ElementsClientOptions {
|
|
|
14
24
|
* Resolves master keys per plan. A host may need several: its own Application key
|
|
15
25
|
* and a foreign organization key for each bridged plan it opens.
|
|
16
26
|
*/
|
|
17
|
-
masterKeys
|
|
27
|
+
masterKeys: MasterKeyResolver;
|
|
18
28
|
/** The Application this client acts for; needed to wrap keys of plans it creates. */
|
|
19
|
-
applicationId
|
|
29
|
+
applicationId: string;
|
|
30
|
+
assetDecoder: PlanAssetContainerDecoder;
|
|
20
31
|
}
|
|
21
32
|
export default class ElementsClient {
|
|
22
|
-
|
|
33
|
+
readonly coreSdk: SDKContainer;
|
|
23
34
|
readonly keyVault: KeyVault;
|
|
24
35
|
readonly state: StatePort;
|
|
25
36
|
constructor(coreSdk: SDKContainer, options?: {
|
|
@@ -29,22 +40,46 @@ export default class ElementsClient {
|
|
|
29
40
|
reconstructor?: PlanMaterialReconstructor;
|
|
30
41
|
masterKeys?: MasterKeyResolver;
|
|
31
42
|
applicationId?: string;
|
|
43
|
+
assetDecoder?: PlanAssetContainerDecoder;
|
|
32
44
|
});
|
|
33
45
|
private readonly api?;
|
|
34
46
|
private readonly reconstructor?;
|
|
35
47
|
private readonly masterKeys?;
|
|
36
48
|
private readonly applicationId?;
|
|
37
|
-
|
|
49
|
+
readonly assetDecoder?: PlanAssetContainerDecoder;
|
|
50
|
+
listPlans(input?: ListPlansInput): Promise<PlanPage>;
|
|
51
|
+
getPlan(planId: string): Promise<PlanDetail>;
|
|
52
|
+
startPlanCreation(input: StartPlanCreationInput): Promise<PlanCreationProgress>;
|
|
53
|
+
getPlanCreation(operationId: string): Promise<PlanCreationProgress>;
|
|
54
|
+
supplyPlanCreationMaterial(operationId: string, material: EncryptedPlanMaterial): Promise<PlanCreationProgress>;
|
|
55
|
+
cancelPlanCreation(operationId: string): Promise<PlanCreationProgress>;
|
|
38
56
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
57
|
+
* The resumable creation flow over this client's own port.
|
|
58
|
+
*
|
|
59
|
+
* The four calls above are the raw stages; a host that wants recovery, progress and the
|
|
60
|
+
* encrypt/split step in the right order drives them through here instead. Checkpoints
|
|
61
|
+
* default to process memory because they only need to outlive the operation, not the host.
|
|
42
62
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
63
|
+
guidedPlanCreator(checkpoints?: GuidedCreateCheckpointStore): GuidedPlanCreator;
|
|
64
|
+
/**
|
|
65
|
+
* Creates the plan definition from a declaration of what it will protect.
|
|
66
|
+
*
|
|
67
|
+
* Elements takes a `PlanAssetDeclaration` rather than the assets themselves: creation
|
|
68
|
+
* persists metadata only, and a host that has not yet collected any secret should be
|
|
69
|
+
* able to reach this point. Where Business keeps the secrets in browser storage between
|
|
70
|
+
* its create and configure pages, an Elements host holds the declaration and supplies
|
|
71
|
+
* the secrets to `configurePlan()` — how it carries them across is its own decision.
|
|
72
|
+
*/
|
|
73
|
+
createPlan<TInput extends {
|
|
74
|
+
assets: PlanAssetDeclaration;
|
|
45
75
|
}, TResult>(input: TInput): Promise<TResult>;
|
|
46
|
-
/**
|
|
47
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Configures a plan under the Application's required master key. The key is resolved
|
|
78
|
+
* through the configured custody source; it is never an operation parameter.
|
|
79
|
+
*/
|
|
80
|
+
configurePlan<TInput extends object, TResult>(input: TInput): Promise<TResult>;
|
|
81
|
+
/** Resolves the Application's required master key without exposing it as an operation argument. */
|
|
82
|
+
applicationMasterKey(): Promise<string>;
|
|
48
83
|
/**
|
|
49
84
|
* Resolves the key that opens a plan before anything is collected.
|
|
50
85
|
*
|
|
@@ -82,6 +117,17 @@ export default class ElementsClient {
|
|
|
82
117
|
}): Promise<string | undefined>;
|
|
83
118
|
initializeGovernedReveal(planId: string, stepUp?: StepUpReadContext): Promise<GovernedRevealSession>;
|
|
84
119
|
getGovernedReveal(processId: string, stepUp?: StepUpReadContext): Promise<GovernedRevealState>;
|
|
120
|
+
startReveal(planId: string, input: StartRevealInput): Promise<RevealSession>;
|
|
121
|
+
getReveal(revealId: string): Promise<RevealSession>;
|
|
122
|
+
openReveal(planId: string, options?: OpenRevealOptions): Promise<RevealHandle>;
|
|
123
|
+
withReveal<TResult>(planId: string, options: OpenRevealOptions, work: (reveal: RevealHandle) => Promise<TResult>): Promise<TResult>;
|
|
124
|
+
releaseRevealMaterial(revealId: string, materialVersion: string): Promise<unknown>;
|
|
125
|
+
reportRevealReconstruction(revealId: string, input: RevealReconstructionInput): Promise<RevealSession>;
|
|
126
|
+
closeReveal(revealId: string, reason: RevealCloseReason): Promise<RevealSession>;
|
|
127
|
+
authorizeRevealAction(revealId: string, input: AuthorizeRevealActionInput): Promise<RevealAction>;
|
|
128
|
+
reportRevealActionOutcome(revealId: string, actionId: string, input: ReportRevealActionOutcomeInput): Promise<RevealAction>;
|
|
129
|
+
getCustodianShare(processId: string, stepUp?: StepUpReadContext): Promise<CustodianShareResult>;
|
|
130
|
+
releaseCustodianShare(processId: string): Promise<void>;
|
|
85
131
|
exportPlanBridge(planId: string, input: ExportPlanBridgeInput): Promise<PlanBridgeEnvelope>;
|
|
86
132
|
importPlanBridge(envelope: PlanBridgeEnvelope): Promise<{
|
|
87
133
|
planId: string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ElementsApiPort } from './elements-api-port';
|
|
2
|
+
import type { EncryptedPlanMaterial, GuidedCreateCheckpoint, GuidedCreateLocalStage, PlanCreationProgress, StartPlanCreationInput } from './plan-operations';
|
|
3
|
+
export interface GuidedCreateCheckpointStore {
|
|
4
|
+
load(operationId: string): Promise<GuidedCreateCheckpoint | undefined>;
|
|
5
|
+
save(checkpoint: GuidedCreateCheckpoint): Promise<void>;
|
|
6
|
+
remove(operationId: string): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export interface PlanMaterialBuilder<TSecrets, TEncrypted = unknown> {
|
|
9
|
+
encrypt(input: {
|
|
10
|
+
planId: string;
|
|
11
|
+
declaration: StartPlanCreationInput;
|
|
12
|
+
secrets: TSecrets;
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
}): Promise<TEncrypted>;
|
|
15
|
+
generateShares(input: {
|
|
16
|
+
planId: string;
|
|
17
|
+
declaration: StartPlanCreationInput;
|
|
18
|
+
encrypted: TEncrypted;
|
|
19
|
+
signal?: AbortSignal;
|
|
20
|
+
}): Promise<EncryptedPlanMaterial>;
|
|
21
|
+
}
|
|
22
|
+
export interface GuidedCreateOptions {
|
|
23
|
+
signal?: AbortSignal;
|
|
24
|
+
onProgress?: (stage: GuidedCreateLocalStage | PlanCreationProgress['stage']) => void;
|
|
25
|
+
}
|
|
26
|
+
/** Process-lifetime checkpoints. A host that must survive a restart supplies a durable store. */
|
|
27
|
+
export declare class MemoryGuidedCreateCheckpointStore implements GuidedCreateCheckpointStore {
|
|
28
|
+
private readonly checkpoints;
|
|
29
|
+
load(operationId: string): Promise<GuidedCreateCheckpoint | undefined>;
|
|
30
|
+
save(checkpoint: GuidedCreateCheckpoint): Promise<void>;
|
|
31
|
+
remove(operationId: string): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
/** Resumable orchestration. Only its non-secret checkpoint may survive process restart. */
|
|
34
|
+
export declare class GuidedPlanCreator {
|
|
35
|
+
private readonly api;
|
|
36
|
+
private readonly checkpoints;
|
|
37
|
+
constructor(api: ElementsApiPort, checkpoints: GuidedCreateCheckpointStore);
|
|
38
|
+
start(input: StartPlanCreationInput, options?: GuidedCreateOptions): Promise<PlanCreationProgress>;
|
|
39
|
+
status(operationId: string): Promise<PlanCreationProgress>;
|
|
40
|
+
resume<TSecrets, TEncrypted>(operationId: string, declaration: StartPlanCreationInput, secrets: TSecrets, builder: PlanMaterialBuilder<TSecrets, TEncrypted>, options?: GuidedCreateOptions): Promise<PlanCreationProgress>;
|
|
41
|
+
cancel(operationId: string): Promise<PlanCreationProgress>;
|
|
42
|
+
private saveCheckpoint;
|
|
43
|
+
}
|
|
44
|
+
export declare class GuidedCreateRecoveryError extends Error {
|
|
45
|
+
readonly code: string;
|
|
46
|
+
constructor(code: string);
|
|
47
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BearerTokenResolver, HttpTransport } from '@safetech/inheriti-core-sdk/node';
|
|
2
|
-
import type { CollectedPlanMaterial, ElementsApiPort, PlanKeyReference, ExportPlanBridgeInput, GovernedRevealSession, GovernedRevealState, GovernedSharesMaterial, GovernedValidatorMaterial, PlanBridgeEnvelope, StepUpReadContext } from './elements-api-port';
|
|
2
|
+
import type { AuthorizeRevealActionInput, CollectedPlanMaterial, CustodianShareResult, ElementsApiPort, PlanKeyReference, ExportPlanBridgeInput, GovernedRevealSession, GovernedRevealState, GovernedSharesMaterial, GovernedValidatorMaterial, PlanBridgeEnvelope, ReportRevealActionOutcomeInput, RevealAction, RevealCloseReason, RevealReconstructionInput, RevealSession, StartRevealInput, StepUpReadContext } from './elements-api-port';
|
|
3
|
+
import type { EncryptedPlanMaterial, ListPlansInput, PlanCreationProgress, PlanDetail, PlanPage, StartPlanCreationInput } from './plan-operations';
|
|
3
4
|
export declare class ElementsApiRequestFailed extends Error {
|
|
4
5
|
readonly status: number;
|
|
5
6
|
readonly code?: string | undefined;
|
|
@@ -13,6 +14,12 @@ export default class HttpElementsApiPort implements ElementsApiPort {
|
|
|
13
14
|
private readonly getBearerToken;
|
|
14
15
|
private readonly transport;
|
|
15
16
|
constructor(apiUrl: string, environment: 'TEST' | 'LIVE', getBearerToken: BearerTokenResolver, transport: HttpTransport);
|
|
17
|
+
listPlans(input?: ListPlansInput): Promise<PlanPage>;
|
|
18
|
+
getPlan(planId: string): Promise<PlanDetail>;
|
|
19
|
+
startPlanCreation(input: StartPlanCreationInput): Promise<PlanCreationProgress>;
|
|
20
|
+
getPlanCreation(operationId: string): Promise<PlanCreationProgress>;
|
|
21
|
+
supplyPlanCreationMaterial(operationId: string, material: EncryptedPlanMaterial): Promise<PlanCreationProgress>;
|
|
22
|
+
cancelPlanCreation(operationId: string): Promise<PlanCreationProgress>;
|
|
16
23
|
planKeyReference(planId: string): Promise<PlanKeyReference>;
|
|
17
24
|
collectPlanMaterial(planId: string, stepUp?: StepUpReadContext): Promise<CollectedPlanMaterial>;
|
|
18
25
|
initializeGovernedReveal(planId: string, stepUp?: StepUpReadContext): Promise<GovernedRevealSession>;
|
|
@@ -23,6 +30,15 @@ export default class HttpElementsApiPort implements ElementsApiPort {
|
|
|
23
30
|
markGovernedSharesReconstructed(processId: string): Promise<void>;
|
|
24
31
|
markGovernedDataRevealed(processId: string): Promise<void>;
|
|
25
32
|
closeGovernedReveal(processId: string): Promise<void>;
|
|
33
|
+
startReveal(planId: string, input: StartRevealInput): Promise<RevealSession>;
|
|
34
|
+
getReveal(revealId: string): Promise<RevealSession>;
|
|
35
|
+
releaseRevealMaterial(revealId: string, materialVersion: string): Promise<unknown>;
|
|
36
|
+
reportRevealReconstruction(revealId: string, input: RevealReconstructionInput): Promise<RevealSession>;
|
|
37
|
+
closeReveal(revealId: string, reason: RevealCloseReason): Promise<RevealSession>;
|
|
38
|
+
authorizeRevealAction(revealId: string, input: AuthorizeRevealActionInput): Promise<RevealAction>;
|
|
39
|
+
reportRevealActionOutcome(revealId: string, actionId: string, input: ReportRevealActionOutcomeInput): Promise<RevealAction>;
|
|
40
|
+
getCustodianShare(processId: string, stepUp?: StepUpReadContext): Promise<CustodianShareResult>;
|
|
41
|
+
releaseCustodianShare(processId: string): Promise<void>;
|
|
26
42
|
exportPlanBridge(planId: string, input: ExportPlanBridgeInput): Promise<PlanBridgeEnvelope>;
|
|
27
43
|
importPlanBridge(envelope: PlanBridgeEnvelope): Promise<{
|
|
28
44
|
planId: string;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
export { default as ElementsClient, createElementsClient } from './elements-client';
|
|
2
2
|
export type { ElementsClientOptions } from './elements-client';
|
|
3
|
+
export type { DecodedPlanAsset, PlanAssetContainerDecoder } from './elements-client';
|
|
3
4
|
export { MemoryKeyVault } from './key-vault';
|
|
4
5
|
export type { KeyVault } from './key-vault';
|
|
5
6
|
export { MemoryStatePort } from './state-port';
|
|
6
7
|
export type { StatePort } from './state-port';
|
|
7
8
|
export type { CollectedPlanMaterial, ElementsApiPort, StepUpReadContext } from './elements-api-port';
|
|
8
9
|
export type { GovernedRevealSession, GovernedRevealState, GovernedShare, GovernedSharesMaterial, GovernedValidatorMaterial } from './elements-api-port';
|
|
10
|
+
export type { AuthorizeRevealActionInput, CustodianShareResult, ReportRevealActionOutcomeInput, RevealAction, RevealActionOutcome, RevealActionType, RevealCloseReason, RevealMode, RevealReconstructionInput, RevealSession, RevealStage, StartRevealInput } from './elements-api-port';
|
|
9
11
|
export type { ExportPlanBridgeInput, PlanBridgeEnvelope, PlanRevealProfile } from './elements-api-port';
|
|
10
|
-
export { ElementsApiPortRequired } from './elements-api-port';
|
|
12
|
+
export { ElementsApiPortRequired, RevealActionsNotOpen } from './elements-api-port';
|
|
13
|
+
export { parseAssetFieldSelector, RevealFieldAccessError, RevealHandleClosed } from './scoped-reveal';
|
|
14
|
+
export type { AssetFieldSelector, OpenRevealOptions, RevealFieldOptions, RevealHandle } from './scoped-reveal';
|
|
15
|
+
export { default as HttpElementsApiPort, ElementsApiRequestFailed } from './http-elements-api-port';
|
|
11
16
|
export type { PlanMaterialReconstructor } from './plan-material-reconstructor';
|
|
12
17
|
export { PlanMaterialReconstructorRequired } from './plan-material-reconstructor';
|
|
13
18
|
export { MasterKeyRequired, StaticMasterKeyResolver, masterKeyRefFor, masterKeyRefKey } from './master-key';
|
|
@@ -15,3 +20,7 @@ export type { MasterKeyRef, MasterKeyResolver } from './master-key';
|
|
|
15
20
|
export { unwrapDekWithMasterKey } from './unwrap-dek';
|
|
16
21
|
export { RelayMasterKeySource, MasterKeyRelayExpired, MasterKeyRelayTimedOut } from './relay-master-key-source';
|
|
17
22
|
export type { MasterKeyRelayPort, RelayMasterKeySourceOptions } from './relay-master-key-source';
|
|
23
|
+
export { HostProcessRuntimeEnvironment, LocalProcessReconciliationOwnership, PollingSharedPlanEventListener } from './polling-shared-plan-event-listener';
|
|
24
|
+
export * from './plan-operations';
|
|
25
|
+
export * from './guided-plan-creator';
|
|
26
|
+
export * from './core-plan-material-builder';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PlanCreationProgress, PlanDetail, PlanPage } from './plan-operations';
|
|
2
|
+
export declare function decodePlanPage(value: unknown): PlanPage;
|
|
3
|
+
export declare function decodePlanDetail(value: unknown): PlanDetail;
|
|
4
|
+
export declare function decodePlanCreationProgress(value: unknown): PlanCreationProgress;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
export declare const CANONICAL_PLAN_ASSET_TYPES: readonly ["PLAIN-TEXT", "USER-PSWD", "RECOVERY-CODE", "PIN-CODE", "API-KEY", "PRIVATE-KEY", "SEED-PHRASE", "PAYMENT-DEBIT-CARD", "PAYMENT-CREDIT-CARD", "DOCUMENT", "IMAGE", "VIDEO"];
|
|
2
|
+
export type CanonicalPlanAssetType = (typeof CANONICAL_PLAN_ASSET_TYPES)[number];
|
|
3
|
+
export declare const CANONICAL_STRUCTURED_ASSET_FIELDS: Readonly<Record<Exclude<CanonicalPlanAssetType, 'DOCUMENT' | 'IMAGE' | 'VIDEO'>, readonly string[]>>;
|
|
4
|
+
export type CompatibleValue<T extends string> = T | {
|
|
5
|
+
readonly kind: 'UNKNOWN';
|
|
6
|
+
readonly raw: string;
|
|
7
|
+
};
|
|
8
|
+
export type PlanStatus = CompatibleValue<'DRAFT' | 'ACTIVE' | 'CONFIGURED' | 'ARCHIVED'>;
|
|
9
|
+
export type PlanGovernanceMode = CompatibleValue<'DIRECT' | 'GOVERNED'>;
|
|
10
|
+
export type PlanParticipantRelationship = 'OWNER' | 'MERGER' | 'MODERATOR' | 'CUSTODIAN' | 'ALLOW' | 'DENY';
|
|
11
|
+
export interface PlanAssetSummary {
|
|
12
|
+
count: number;
|
|
13
|
+
types: CompatibleValue<CanonicalPlanAssetType>[];
|
|
14
|
+
}
|
|
15
|
+
export interface PlanSummary {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
status: PlanStatus;
|
|
20
|
+
createdAt: string;
|
|
21
|
+
configuredAt?: string;
|
|
22
|
+
assetSummary: PlanAssetSummary;
|
|
23
|
+
governance: {
|
|
24
|
+
mode: PlanGovernanceMode;
|
|
25
|
+
minimumApprovals: number;
|
|
26
|
+
};
|
|
27
|
+
participantSummary: {
|
|
28
|
+
owners: number;
|
|
29
|
+
mergers: number;
|
|
30
|
+
moderators: number;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface PlanPage {
|
|
34
|
+
items: PlanSummary[];
|
|
35
|
+
nextCursor: string | null;
|
|
36
|
+
}
|
|
37
|
+
export interface ListPlansInput {
|
|
38
|
+
cursor?: string;
|
|
39
|
+
limit?: number;
|
|
40
|
+
status?: readonly string[];
|
|
41
|
+
assetType?: CanonicalPlanAssetType;
|
|
42
|
+
namePrefix?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface PlanDetail extends PlanSummary {
|
|
45
|
+
assets: Array<{
|
|
46
|
+
id: string;
|
|
47
|
+
/** Developer-defined stable address. Older plans may not have one and fall back to `id`. */
|
|
48
|
+
code?: string;
|
|
49
|
+
type: CompatibleValue<CanonicalPlanAssetType>;
|
|
50
|
+
name: string;
|
|
51
|
+
isBinary: boolean;
|
|
52
|
+
fieldNames: string[];
|
|
53
|
+
matchOrigins?: string[];
|
|
54
|
+
}>;
|
|
55
|
+
participants: Array<{
|
|
56
|
+
id: string;
|
|
57
|
+
displayName: string;
|
|
58
|
+
relationships: CompatibleValue<PlanParticipantRelationship>[];
|
|
59
|
+
lifecycle: CompatibleValue<'ACTIVE' | 'REVOKED'>;
|
|
60
|
+
}>;
|
|
61
|
+
revealPolicy: {
|
|
62
|
+
masterKeyRelease: CompatibleValue<'REQUIRED'>;
|
|
63
|
+
custodian: CompatibleValue<'FORCE' | 'BYPASS'>;
|
|
64
|
+
};
|
|
65
|
+
source: {
|
|
66
|
+
kind: 'NATIVE';
|
|
67
|
+
} | {
|
|
68
|
+
kind: 'BRIDGED';
|
|
69
|
+
system: CompatibleValue<'INHERITI_BUSINESS'>;
|
|
70
|
+
status: CompatibleValue<'IN_SYNC' | 'RECONCILIATION_REQUIRED'>;
|
|
71
|
+
} | {
|
|
72
|
+
kind: 'UNKNOWN';
|
|
73
|
+
raw: string;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export interface IntegrationPlanAssetDeclaration {
|
|
77
|
+
clientAssetRef: string;
|
|
78
|
+
type: CanonicalPlanAssetType;
|
|
79
|
+
name: string;
|
|
80
|
+
fieldNames?: readonly string[];
|
|
81
|
+
isBinary: boolean;
|
|
82
|
+
fileName?: string;
|
|
83
|
+
mimeType?: string;
|
|
84
|
+
size?: number;
|
|
85
|
+
}
|
|
86
|
+
export interface NativePlanParticipant {
|
|
87
|
+
clientParticipantRef: string;
|
|
88
|
+
/** Routing only. It is not identity or evidence of a SafeID/SafeKey account. */
|
|
89
|
+
routingEmail: string;
|
|
90
|
+
displayName: string;
|
|
91
|
+
relationships: readonly PlanParticipantRelationship[];
|
|
92
|
+
}
|
|
93
|
+
export interface StartPlanCreationInput {
|
|
94
|
+
idempotencyKey: string;
|
|
95
|
+
name: string;
|
|
96
|
+
description?: string;
|
|
97
|
+
assets: readonly IntegrationPlanAssetDeclaration[];
|
|
98
|
+
participants: readonly NativePlanParticipant[];
|
|
99
|
+
policy?: {
|
|
100
|
+
governance?: 'DIRECT' | 'GOVERNED';
|
|
101
|
+
minimumApprovals?: number;
|
|
102
|
+
masterKeyRelease?: 'REQUIRED';
|
|
103
|
+
custodian?: 'FORCE' | 'BYPASS';
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export declare const PLAN_CREATION_SERVER_STAGES: readonly ["VALIDATED", "PLAN_CREATED", "PARTICIPANTS_PERSISTED", "STORAGE_PREPARED", "AWAITING_ENCRYPTED_MATERIAL", "VALIDATOR_SHARES_DISTRIBUTED", "CONFIGURED", "COMPLETED"];
|
|
107
|
+
export type PlanCreationServerStage = (typeof PLAN_CREATION_SERVER_STAGES)[number];
|
|
108
|
+
export type PlanCreationOutcome = 'IN_PROGRESS' | 'COMPLETED' | 'CANCELED' | 'FAILED_RETRYABLE' | 'FAILED_TERMINAL' | 'RECONCILIATION_REQUIRED';
|
|
109
|
+
export interface PlanCreationProgress {
|
|
110
|
+
operationId: string;
|
|
111
|
+
stage: CompatibleValue<PlanCreationServerStage>;
|
|
112
|
+
outcome: CompatibleValue<PlanCreationOutcome>;
|
|
113
|
+
planId?: string;
|
|
114
|
+
lastErrorCode?: string;
|
|
115
|
+
participants?: Array<{
|
|
116
|
+
clientParticipantRef: string;
|
|
117
|
+
planParticipantId: string;
|
|
118
|
+
relationships: PlanParticipantRelationship[];
|
|
119
|
+
}>;
|
|
120
|
+
}
|
|
121
|
+
export interface EncryptedPlanMaterial {
|
|
122
|
+
protectionProtocol?: 'SSDP_PLUS_V1' | 'SSDP_PLUS_V2';
|
|
123
|
+
validatorShares?: readonly EncryptedPlanShard[];
|
|
124
|
+
dataShards: readonly EncryptedPlanShard[];
|
|
125
|
+
backupShards: readonly EncryptedPlanShard[];
|
|
126
|
+
encryptedKey?: string;
|
|
127
|
+
assetsMetadata?: Readonly<Record<string, {
|
|
128
|
+
type: CanonicalPlanAssetType;
|
|
129
|
+
meta: {
|
|
130
|
+
name: string;
|
|
131
|
+
notes?: string;
|
|
132
|
+
};
|
|
133
|
+
}>>;
|
|
134
|
+
custodianShard?: {
|
|
135
|
+
keyShard: EncryptedPlanShard;
|
|
136
|
+
dataShard: EncryptedPlanShard;
|
|
137
|
+
};
|
|
138
|
+
operation?: 'DRAFT' | 'FINALIZE';
|
|
139
|
+
}
|
|
140
|
+
export interface EncryptedPlanShard {
|
|
141
|
+
id: string;
|
|
142
|
+
data?: string;
|
|
143
|
+
}
|
|
144
|
+
export type GuidedCreateLocalStage = 'VALIDATING_ASSETS' | 'ENCRYPTING' | 'GENERATING_SHARES';
|
|
145
|
+
export interface GuidedCreateCheckpoint {
|
|
146
|
+
idempotencyKey: string;
|
|
147
|
+
operationId: string;
|
|
148
|
+
declarationHash: string;
|
|
149
|
+
serverStage: CompatibleValue<PlanCreationServerStage>;
|
|
150
|
+
}
|
|
151
|
+
export declare class InvalidPlanDeclaration extends Error {
|
|
152
|
+
readonly code: string;
|
|
153
|
+
constructor(code: string);
|
|
154
|
+
}
|
|
155
|
+
export declare class InvalidPlanMaterial extends Error {
|
|
156
|
+
readonly code: string;
|
|
157
|
+
constructor(code: string);
|
|
158
|
+
}
|
|
159
|
+
export declare function validatePlanCreationMaterial(material: EncryptedPlanMaterial): void;
|
|
160
|
+
export declare function validatePlanCreationInput(input: StartPlanCreationInput): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ProcessReconciliationOwnership, ProcessRuntimeEnvironment, SharedPlanEventHandlers, SharedPlanEventListener } from '@safetech/inheriti-core-sdk/shared-configuration';
|
|
2
|
+
import type { ElementsApiPort } from './elements-api-port';
|
|
3
|
+
/** Elements adapter for Core's transport-neutral event port. Scheduling remains owned by Core's mature loop. */
|
|
4
|
+
export declare class PollingSharedPlanEventListener implements SharedPlanEventListener {
|
|
5
|
+
private readonly api;
|
|
6
|
+
private readonly subscriptions;
|
|
7
|
+
private readonly loop;
|
|
8
|
+
constructor(api: ElementsApiPort, environment?: ProcessRuntimeEnvironment, ownership?: ProcessReconciliationOwnership, random?: () => number);
|
|
9
|
+
refreshConnection(): void;
|
|
10
|
+
subscribe(processId: string, handlers: SharedPlanEventHandlers): void;
|
|
11
|
+
unsubscribe(processId: string): void;
|
|
12
|
+
}
|
|
13
|
+
/** Cross-host runtime: browsers regain work on online/visibility events; Node uses timer-only recovery. */
|
|
14
|
+
export declare class HostProcessRuntimeEnvironment implements ProcessRuntimeEnvironment {
|
|
15
|
+
visibility(): 'visible' | 'hidden';
|
|
16
|
+
isOnline(): boolean;
|
|
17
|
+
now(): number;
|
|
18
|
+
schedule(callback: () => void, delayMs: number): () => void;
|
|
19
|
+
onRecovery(callback: () => void): () => void;
|
|
20
|
+
}
|
|
21
|
+
/** One host process owns its own polling; Core's loop still enforces one active lease per subscription. */
|
|
22
|
+
export declare class LocalProcessReconciliationOwnership implements ProcessReconciliationOwnership {
|
|
23
|
+
join(_processId: string, handlers: Parameters<ProcessReconciliationOwnership['join']>[1]): {
|
|
24
|
+
isOwner: () => boolean;
|
|
25
|
+
requestReconciliation: () => void;
|
|
26
|
+
publishReconciled: () => undefined;
|
|
27
|
+
leave: () => void;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AuthorizeRevealActionInput, ElementsApiPort, RevealAction } from './elements-api-port';
|
|
2
|
+
export declare function authorizeActionWhenOpen(api: ElementsApiPort, revealId: string, input: AuthorizeRevealActionInput): Promise<RevealAction>;
|
|
3
|
+
/**
|
|
4
|
+
* Resolves the plan key before the material is released, where the caller's credential can.
|
|
5
|
+
*
|
|
6
|
+
* The key reference lives on `/shared-plans`, which takes an Application or Account credential. A
|
|
7
|
+
* host drives a reveal with the *operator* credential it gets at sign-in, and that route refuses it —
|
|
8
|
+
* so requiring this step made a reveal impossible from any integration host. It stays a fail-fast for
|
|
9
|
+
* the callers that can make the call, and is skipped for the ones that cannot: the released material
|
|
10
|
+
* carries its own key reference, so reconstruction resolves the key from that either way. Any other
|
|
11
|
+
* failure is still the caller's to see.
|
|
12
|
+
*/
|
|
13
|
+
export declare function releaseMaterialAfterKeyResolution(api: ElementsApiPort, revealId: string, materialVersion: string, prepareReveal: (planId: string) => Promise<unknown>): Promise<unknown>;
|