@safetech/inheriti-client-sdk 1.17.2 → 1.17.4
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 +12 -3
- package/dist/browser.d.ts +91 -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 +99 -61
- package/dist/node.d.ts +23 -3
- package/dist/node.js +1 -1
- package/dist/sdk-types.d.ts +1113 -127
- package/dist/src/auth/inheriti-client-provider.d.ts +1 -1
- package/dist/src/elements/browser-plan-material-reconstructor.d.ts +23 -0
- package/dist/src/elements/core-plan-material-builder.d.ts +41 -0
- package/dist/src/elements/elements-api-port.d.ts +163 -3
- package/dist/src/elements/elements-client.d.ts +111 -14
- package/dist/src/elements/guided-plan-creator.d.ts +47 -0
- package/dist/src/elements/http-elements-api-port.d.ts +36 -1
- package/dist/src/elements/index.d.ts +14 -1
- package/dist/src/elements/master-key-acquisition.d.ts +46 -0
- package/dist/src/elements/node-plan-material-reconstructor.d.ts +9 -6
- package/dist/src/elements/plan-operation-codec.d.ts +4 -0
- package/dist/src/elements/plan-operations.d.ts +218 -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 +105 -0
- package/dist/src/elements/ssdp-v2-plan-material-reconstructor.d.ts +17 -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 +32 -4
- package/package.json +14 -3
package/dist/sdk-types.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { SDKContainer } from '@safetech/inheriti-core-sdk/vanilla';
|
|
2
2
|
export { SDKContainer } from '@safetech/inheriti-core-sdk/vanilla';
|
|
3
|
-
import { ValidEnv, AuthClientProps, MasterKeySource } from '@safetech/inheriti-core-sdk';
|
|
3
|
+
import { ValidEnv, AuthClientProps, MasterKeySource, PlanAssetDeclaration, DataAsset } from '@safetech/inheriti-core-sdk';
|
|
4
4
|
export * from '@safetech/inheriti-core-sdk';
|
|
5
|
-
|
|
5
|
+
export { MasterKeySource } from '@safetech/inheriti-core-sdk';
|
|
6
|
+
import * as react from 'react';
|
|
6
7
|
import { ReactNode } from 'react';
|
|
8
|
+
import { BearerTokenResolver, HttpTransport } from '@safetech/inheriti-core-sdk/node';
|
|
9
|
+
import { ProcessRuntimeEnvironment, ProcessReconciliationOwnership, SharedPlanEventListener, SharedPlanEventHandlers } from '@safetech/inheriti-core-sdk/shared-configuration';
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
12
|
* Props for the `InheritiClientProvider` component.
|
|
@@ -35,7 +38,7 @@ interface InheritiClientProviderProps {
|
|
|
35
38
|
*
|
|
36
39
|
* @param props - The provider props including children, clientId, and options.
|
|
37
40
|
*/
|
|
38
|
-
declare function InheritiClientProvider({ children, clientId, options }: InheritiClientProviderProps):
|
|
41
|
+
declare function InheritiClientProvider({ children, clientId, options }: InheritiClientProviderProps): react.JSX.Element;
|
|
39
42
|
|
|
40
43
|
/**
|
|
41
44
|
* Wraps core's useClient to update the httpClient's apiUrl
|
|
@@ -56,94 +59,224 @@ declare function getAvailableEnvs(): {
|
|
|
56
59
|
demoKeyApiUrl: string;
|
|
57
60
|
};
|
|
58
61
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
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"];
|
|
63
|
+
type CanonicalPlanAssetType = (typeof CANONICAL_PLAN_ASSET_TYPES)[number];
|
|
64
|
+
declare const CANONICAL_STRUCTURED_ASSET_FIELDS: Readonly<Record<Exclude<CanonicalPlanAssetType, 'DOCUMENT' | 'IMAGE' | 'VIDEO'>, readonly string[]>>;
|
|
65
|
+
type CompatibleValue<T extends string> = T | {
|
|
66
|
+
readonly kind: 'UNKNOWN';
|
|
67
|
+
readonly raw: string;
|
|
68
|
+
};
|
|
69
|
+
type PlanStatus = CompatibleValue<'DRAFT' | 'ACTIVE' | 'CONFIGURED' | 'ARCHIVED'>;
|
|
70
|
+
type PlanGovernanceMode = CompatibleValue<'DIRECT' | 'GOVERNED'>;
|
|
71
|
+
type PlanParticipantRelationship = 'OWNER' | 'MERGER' | 'MODERATOR' | 'CUSTODIAN' | 'ALLOW' | 'DENY';
|
|
72
|
+
interface PlanAssetSummary {
|
|
73
|
+
count: number;
|
|
74
|
+
types: CompatibleValue<CanonicalPlanAssetType>[];
|
|
75
|
+
/** The names the developer gave the assets, in plan order. A binary asset's filename is not here. */
|
|
76
|
+
names: string[];
|
|
70
77
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
interface PlanSummary {
|
|
79
|
+
id: string;
|
|
80
|
+
name: string;
|
|
81
|
+
description?: string;
|
|
82
|
+
status: PlanStatus;
|
|
83
|
+
createdAt: string;
|
|
84
|
+
configuredAt?: string;
|
|
85
|
+
assetSummary: PlanAssetSummary;
|
|
86
|
+
governance: {
|
|
87
|
+
mode: PlanGovernanceMode;
|
|
88
|
+
minimumApprovals: number;
|
|
89
|
+
};
|
|
90
|
+
participantSummary: {
|
|
91
|
+
owners: number;
|
|
92
|
+
mergers: number;
|
|
93
|
+
moderators: number;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* The authentication a merge has to satisfy before the plan opens. Empty means the plan carries
|
|
97
|
+
* none. A method's own settings are not part of the host-facing shape.
|
|
98
|
+
*/
|
|
99
|
+
authentication: Array<{
|
|
100
|
+
id: CompatibleValue<'SK_MOBILE'>;
|
|
101
|
+
status: CompatibleValue<'ACTIVE' | 'INACTIVE'>;
|
|
102
|
+
}>;
|
|
82
103
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
104
|
+
interface PlanPage {
|
|
105
|
+
items: PlanSummary[];
|
|
106
|
+
nextCursor: string | null;
|
|
107
|
+
}
|
|
108
|
+
interface ListPlansInput {
|
|
109
|
+
cursor?: string;
|
|
110
|
+
limit?: number;
|
|
111
|
+
status?: readonly string[];
|
|
112
|
+
assetType?: CanonicalPlanAssetType;
|
|
113
|
+
namePrefix?: string;
|
|
114
|
+
}
|
|
115
|
+
interface PlanDetail extends PlanSummary {
|
|
116
|
+
assets: Array<{
|
|
117
|
+
id: string;
|
|
118
|
+
/** Developer-defined stable address. Older plans may not have one and fall back to `id`. */
|
|
119
|
+
code?: string;
|
|
120
|
+
type: CompatibleValue<CanonicalPlanAssetType>;
|
|
121
|
+
name: string;
|
|
122
|
+
isBinary: boolean;
|
|
123
|
+
fieldNames: string[];
|
|
124
|
+
/** Binary assets only: what the file was called, what it is, and how big. */
|
|
125
|
+
fileName?: string;
|
|
126
|
+
mimeType?: string;
|
|
127
|
+
size?: number;
|
|
128
|
+
matchOrigins?: string[];
|
|
129
|
+
}>;
|
|
130
|
+
participants: Array<{
|
|
131
|
+
id: string;
|
|
132
|
+
displayName: string;
|
|
133
|
+
relationships: CompatibleValue<PlanParticipantRelationship>[];
|
|
134
|
+
lifecycle: CompatibleValue<'ACTIVE' | 'REVOKED'>;
|
|
135
|
+
}>;
|
|
136
|
+
revealPolicy: {
|
|
137
|
+
masterKeyRelease: CompatibleValue<'REQUIRED'>;
|
|
138
|
+
custodian: CompatibleValue<'FORCE' | 'BYPASS'>;
|
|
139
|
+
};
|
|
140
|
+
dms?: {
|
|
141
|
+
subjectEmail: string;
|
|
142
|
+
countdownDays: number;
|
|
143
|
+
countdownHours: number;
|
|
144
|
+
countdownMinutes: number;
|
|
145
|
+
};
|
|
146
|
+
source: {
|
|
147
|
+
kind: 'NATIVE';
|
|
148
|
+
} | {
|
|
149
|
+
kind: 'BRIDGED';
|
|
150
|
+
system: CompatibleValue<'INHERITI_BUSINESS'>;
|
|
151
|
+
status: CompatibleValue<'IN_SYNC' | 'RECONCILIATION_REQUIRED'>;
|
|
152
|
+
} | {
|
|
153
|
+
kind: 'UNKNOWN';
|
|
154
|
+
raw: string;
|
|
94
155
|
};
|
|
95
|
-
}): MasterKeyRef | undefined;
|
|
96
|
-
/** Thrown when a plan is master key wrapped and no key resolves for its reference. */
|
|
97
|
-
declare class MasterKeyRequired extends Error {
|
|
98
|
-
readonly ref: MasterKeyRef;
|
|
99
|
-
constructor(ref: MasterKeyRef);
|
|
100
156
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
157
|
+
interface IntegrationPlanAssetDeclaration {
|
|
158
|
+
clientAssetRef: string;
|
|
159
|
+
type: CanonicalPlanAssetType;
|
|
160
|
+
name: string;
|
|
161
|
+
fieldNames?: readonly string[];
|
|
162
|
+
/**
|
|
163
|
+
* Origins this asset belongs to, so an origin-bound host can tell which of a plan's logins
|
|
164
|
+
* matches the page in front of the operator. Declared at creation and returned on the plan;
|
|
165
|
+
* without it a browser host offers every field in the plan and ranks none of them.
|
|
166
|
+
*/
|
|
167
|
+
matchOrigins?: readonly string[];
|
|
168
|
+
isBinary: boolean;
|
|
169
|
+
fileName?: string;
|
|
170
|
+
mimeType?: string;
|
|
171
|
+
size?: number;
|
|
172
|
+
}
|
|
173
|
+
interface NativePlanParticipant {
|
|
174
|
+
clientParticipantRef: string;
|
|
175
|
+
/** Routing only. It is not identity or evidence of a SafeID/SafeKey account. */
|
|
176
|
+
routingEmail: string;
|
|
177
|
+
displayName: string;
|
|
178
|
+
relationships: readonly PlanParticipantRelationship[];
|
|
179
|
+
}
|
|
180
|
+
interface StartPlanCreationInput {
|
|
181
|
+
idempotencyKey: string;
|
|
182
|
+
name: string;
|
|
183
|
+
description?: string;
|
|
184
|
+
assets: readonly IntegrationPlanAssetDeclaration[];
|
|
185
|
+
participants: readonly NativePlanParticipant[];
|
|
186
|
+
policy?: PlanGovernancePolicy;
|
|
115
187
|
}
|
|
116
|
-
|
|
117
188
|
/**
|
|
118
|
-
*
|
|
189
|
+
* How a plan is governed, declared one layer at a time.
|
|
119
190
|
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
191
|
+
* The three layers are independent and each is optional on its own — the member confirming on their
|
|
192
|
+
* device, moderators approving, a dead man's switch running down — but a plan must select at least
|
|
193
|
+
* one. A plan nobody has to answer for is not a protected plan, so there is no way to declare one.
|
|
194
|
+
*
|
|
195
|
+
* This replaces a single `governance: 'DIRECT' | 'GOVERNED'` switch, which said that a plan was
|
|
196
|
+
* governed without saying by what, and left every layer's real configuration to a default.
|
|
123
197
|
*/
|
|
124
|
-
interface
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
198
|
+
interface PlanGovernancePolicy {
|
|
199
|
+
/** The member proving it is them, on SafeKey Mobile. `true` takes the Application's method. */
|
|
200
|
+
authentication?: boolean | {
|
|
201
|
+
mode?: 'EXCLUSIVE' | 'ALL_REQUIRED';
|
|
202
|
+
};
|
|
203
|
+
/** Approval by the plan's `MODERATOR` participants. `UNANIMOUS` ignores `minimumApprovals`. */
|
|
204
|
+
moderation?: {
|
|
205
|
+
minimumApprovals?: number;
|
|
206
|
+
approvalMode?: 'THRESHOLD' | 'UNANIMOUS';
|
|
207
|
+
};
|
|
208
|
+
/** A countdown a designated participant can stop. Independent of the plan's type in Elements. */
|
|
209
|
+
dms?: {
|
|
210
|
+
subjectEmail: string;
|
|
211
|
+
countdownDays: number;
|
|
212
|
+
countdownHours?: number;
|
|
213
|
+
countdownMinutes?: number;
|
|
214
|
+
};
|
|
215
|
+
masterKeyRelease?: 'REQUIRED';
|
|
216
|
+
custodian?: 'FORCE' | 'BYPASS';
|
|
128
217
|
}
|
|
129
|
-
declare
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
218
|
+
declare const PLAN_CREATION_SERVER_STAGES: readonly ["VALIDATED", "PLAN_CREATED", "PARTICIPANTS_PERSISTED", "STORAGE_PREPARED", "AWAITING_ENCRYPTED_MATERIAL", "VALIDATOR_SHARES_DISTRIBUTED", "CONFIGURED", "COMPLETED"];
|
|
219
|
+
type PlanCreationServerStage = (typeof PLAN_CREATION_SERVER_STAGES)[number];
|
|
220
|
+
type PlanCreationOutcome = 'IN_PROGRESS' | 'COMPLETED' | 'CANCELED' | 'FAILED_RETRYABLE' | 'FAILED_TERMINAL' | 'RECONCILIATION_REQUIRED';
|
|
221
|
+
interface PlanCreationProgress {
|
|
222
|
+
operationId: string;
|
|
223
|
+
stage: CompatibleValue<PlanCreationServerStage>;
|
|
224
|
+
outcome: CompatibleValue<PlanCreationOutcome>;
|
|
225
|
+
planId?: string;
|
|
226
|
+
lastErrorCode?: string;
|
|
227
|
+
participants?: Array<{
|
|
228
|
+
clientParticipantRef: string;
|
|
229
|
+
planParticipantId: string;
|
|
230
|
+
relationships: PlanParticipantRelationship[];
|
|
231
|
+
}>;
|
|
134
232
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
233
|
+
interface EncryptedPlanMaterial {
|
|
234
|
+
protectionProtocol?: 'SSDP_PLUS_V1' | 'SSDP_PLUS_V2';
|
|
235
|
+
validatorShares?: readonly EncryptedPlanShard[];
|
|
236
|
+
dataShards: readonly EncryptedPlanShard[];
|
|
237
|
+
backupShards: readonly EncryptedPlanShard[];
|
|
238
|
+
encryptedKey?: string;
|
|
239
|
+
assetsMetadata?: Readonly<Record<string, {
|
|
240
|
+
type: CanonicalPlanAssetType;
|
|
241
|
+
meta: {
|
|
242
|
+
name: string;
|
|
243
|
+
notes?: string;
|
|
244
|
+
code?: string;
|
|
245
|
+
matchOrigins?: readonly string[];
|
|
246
|
+
};
|
|
247
|
+
fieldNames?: readonly string[];
|
|
248
|
+
isBinary?: boolean;
|
|
249
|
+
fileName?: string;
|
|
250
|
+
mimeType?: string;
|
|
251
|
+
size?: number;
|
|
252
|
+
}>>;
|
|
253
|
+
custodianShard?: {
|
|
254
|
+
keyShard: EncryptedPlanShard;
|
|
255
|
+
dataShard: EncryptedPlanShard;
|
|
256
|
+
};
|
|
257
|
+
operation?: 'DRAFT' | 'FINALIZE';
|
|
140
258
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
259
|
+
interface EncryptedPlanShard {
|
|
260
|
+
id: string;
|
|
261
|
+
data?: string;
|
|
262
|
+
}
|
|
263
|
+
type GuidedCreateLocalStage = 'VALIDATING_ASSETS' | 'ENCRYPTING' | 'GENERATING_SHARES';
|
|
264
|
+
interface GuidedCreateCheckpoint {
|
|
265
|
+
idempotencyKey: string;
|
|
266
|
+
operationId: string;
|
|
267
|
+
declarationHash: string;
|
|
268
|
+
serverStage: CompatibleValue<PlanCreationServerStage>;
|
|
269
|
+
}
|
|
270
|
+
declare class InvalidPlanDeclaration extends Error {
|
|
271
|
+
readonly code: string;
|
|
272
|
+
constructor(code: string);
|
|
146
273
|
}
|
|
274
|
+
declare class InvalidPlanMaterial extends Error {
|
|
275
|
+
readonly code: string;
|
|
276
|
+
constructor(code: string);
|
|
277
|
+
}
|
|
278
|
+
declare function validatePlanCreationMaterial(material: EncryptedPlanMaterial): void;
|
|
279
|
+
declare function validatePlanCreationInput(input: StartPlanCreationInput): void;
|
|
147
280
|
|
|
148
281
|
interface CollectedPlanMaterial {
|
|
149
282
|
planId: string;
|
|
@@ -157,7 +290,7 @@ interface CollectedPlanMaterial {
|
|
|
157
290
|
}>;
|
|
158
291
|
verifiedStorageLayerTypes: string[];
|
|
159
292
|
/** True when `planKey` is still sealed under a master key and must be unwrapped. */
|
|
160
|
-
masterKeyWrapped
|
|
293
|
+
masterKeyWrapped: boolean;
|
|
161
294
|
/** The tenant holding the plan. With no source reference, this names the key. */
|
|
162
295
|
tenantId?: string;
|
|
163
296
|
/** Present when the plan came from another system, whose key still opens it. */
|
|
@@ -178,7 +311,44 @@ interface PlanKeyReference {
|
|
|
178
311
|
contextId: string;
|
|
179
312
|
};
|
|
180
313
|
}
|
|
314
|
+
/**
|
|
315
|
+
* How a host may obtain the master key for one context.
|
|
316
|
+
*
|
|
317
|
+
* Custody says how the key came into existence; `relayAvailable` says whether *this* caller can be
|
|
318
|
+
* given it by the device holding it. The two are independent, and the verifier is never returned:
|
|
319
|
+
* handing it out would hand out the check a wrong key must fail.
|
|
320
|
+
*/
|
|
321
|
+
interface MasterKeyAcquisition {
|
|
322
|
+
custody: 'DERIVED' | 'EXTERNAL';
|
|
323
|
+
configured: boolean;
|
|
324
|
+
argon2Salt: string | null;
|
|
325
|
+
relayAvailable: boolean;
|
|
326
|
+
}
|
|
327
|
+
interface MasterKeyRelaySessionOpened {
|
|
328
|
+
sessionId: string;
|
|
329
|
+
expiresAt: string | Date;
|
|
330
|
+
}
|
|
331
|
+
interface MasterKeyRelaySessionState {
|
|
332
|
+
status: 'PENDING' | 'DELIVERED' | 'EXPIRED';
|
|
333
|
+
sealedMasterKey?: string;
|
|
334
|
+
}
|
|
181
335
|
interface ElementsApiPort {
|
|
336
|
+
/** How this host can obtain the key for its own Application. */
|
|
337
|
+
masterKeyAcquisition(): Promise<MasterKeyAcquisition>;
|
|
338
|
+
/** The same, for the source context of a plan bridged from another system. */
|
|
339
|
+
foreignMasterKeyAcquisition(system: string, contextId: string): Promise<MasterKeyAcquisition>;
|
|
340
|
+
/**
|
|
341
|
+
* Asks the device holding the key to release it to this host. Creating the session *is* the
|
|
342
|
+
* SafeKey request; there is no separate "notify" step.
|
|
343
|
+
*/
|
|
344
|
+
startMasterKeyRelaySession(clientPublicKey: string): Promise<MasterKeyRelaySessionOpened>;
|
|
345
|
+
readMasterKeyRelaySession(sessionId: string): Promise<MasterKeyRelaySessionState>;
|
|
346
|
+
listPlans(input?: ListPlansInput): Promise<PlanPage>;
|
|
347
|
+
getPlan(planId: string): Promise<PlanDetail>;
|
|
348
|
+
startPlanCreation(input: StartPlanCreationInput): Promise<PlanCreationProgress>;
|
|
349
|
+
getPlanCreation(operationId: string): Promise<PlanCreationProgress>;
|
|
350
|
+
supplyPlanCreationMaterial(operationId: string, material: EncryptedPlanMaterial): Promise<PlanCreationProgress>;
|
|
351
|
+
cancelPlanCreation(operationId: string): Promise<PlanCreationProgress>;
|
|
182
352
|
planKeyReference(planId: string): Promise<PlanKeyReference>;
|
|
183
353
|
collectPlanMaterial(planId: string, stepUp?: StepUpReadContext): Promise<CollectedPlanMaterial>;
|
|
184
354
|
initializeGovernedReveal(planId: string, stepUp?: StepUpReadContext): Promise<GovernedRevealSession>;
|
|
@@ -189,6 +359,34 @@ interface ElementsApiPort {
|
|
|
189
359
|
markGovernedSharesReconstructed(processId: string): Promise<void>;
|
|
190
360
|
markGovernedDataRevealed(processId: string): Promise<void>;
|
|
191
361
|
closeGovernedReveal(processId: string): Promise<void>;
|
|
362
|
+
startReveal(planId: string, input: StartRevealInput): Promise<RevealSession>;
|
|
363
|
+
getReveal(revealId: string): Promise<RevealSession>;
|
|
364
|
+
releaseRevealMaterial(revealId: string, materialVersion: string): Promise<unknown>;
|
|
365
|
+
/** The host declaring it holds the storage-layer shares. Governed reveals only. */
|
|
366
|
+
markRevealSharesCollected(revealId: string): Promise<void>;
|
|
367
|
+
/**
|
|
368
|
+
* The custodian steps on the operator surface. The `/shared-plans/merge/...` equivalents are
|
|
369
|
+
* credential routes and refuse an operator token, so a host addresses them by reveal id.
|
|
370
|
+
*/
|
|
371
|
+
requestRevealCustodianRelease(revealId: string): Promise<void>;
|
|
372
|
+
getRevealCustodianAccess(revealId: string): Promise<CustodianShareAccess>;
|
|
373
|
+
getRevealCustodianShare(revealId: string): Promise<CustodianShareResult>;
|
|
374
|
+
reportRevealReconstruction(revealId: string, input: RevealReconstructionInput): Promise<RevealSession>;
|
|
375
|
+
closeReveal(revealId: string, reason: RevealCloseReason): Promise<RevealSession>;
|
|
376
|
+
/**
|
|
377
|
+
* Gives up the governed access this operator holds on a plan.
|
|
378
|
+
*
|
|
379
|
+
* A governed reveal outlives the session that started it, so a host that cancelled or crashed
|
|
380
|
+
* leaves an access still open; the next reveal resumes it. This is how a host says the access is
|
|
381
|
+
* not wanted after all. `aborted: false` means there was nothing to give up.
|
|
382
|
+
*/
|
|
383
|
+
abortPlanAccess(planId: string): Promise<{
|
|
384
|
+
aborted: boolean;
|
|
385
|
+
}>;
|
|
386
|
+
authorizeRevealAction(revealId: string, input: AuthorizeRevealActionInput): Promise<RevealAction>;
|
|
387
|
+
reportRevealActionOutcome(revealId: string, actionId: string, input: ReportRevealActionOutcomeInput): Promise<RevealAction>;
|
|
388
|
+
getCustodianShare(processId: string, stepUp?: StepUpReadContext): Promise<CustodianShareResult>;
|
|
389
|
+
releaseCustodianShare(processId: string): Promise<void>;
|
|
192
390
|
exportPlanBridge(planId: string, input: ExportPlanBridgeInput): Promise<PlanBridgeEnvelope>;
|
|
193
391
|
importPlanBridge(envelope: PlanBridgeEnvelope): Promise<{
|
|
194
392
|
planId: string;
|
|
@@ -206,7 +404,7 @@ interface ExportPlanBridgeInput {
|
|
|
206
404
|
}
|
|
207
405
|
interface PlanRevealProfile {
|
|
208
406
|
governance: 'KEEP' | 'BYPASS';
|
|
209
|
-
masterKeyRelease: 'REQUIRED'
|
|
407
|
+
masterKeyRelease: 'REQUIRED';
|
|
210
408
|
custodian: 'BYPASS' | 'FORCE';
|
|
211
409
|
}
|
|
212
410
|
interface PlanBridgeEnvelope {
|
|
@@ -283,7 +481,7 @@ interface GovernedRevealSession {
|
|
|
283
481
|
mergeThreshold: number;
|
|
284
482
|
status?: string;
|
|
285
483
|
/** Same key signalling the direct collection route returns, for the governed path. */
|
|
286
|
-
masterKeyWrapped
|
|
484
|
+
masterKeyWrapped: boolean;
|
|
287
485
|
tenantId?: string;
|
|
288
486
|
sourceReference?: {
|
|
289
487
|
system: string;
|
|
@@ -314,10 +512,276 @@ interface GovernedSharesMaterial {
|
|
|
314
512
|
keyShards: GovernedShare[];
|
|
315
513
|
dek: string;
|
|
316
514
|
}
|
|
515
|
+
type RevealMode = 'DIRECT' | 'GOVERNED';
|
|
516
|
+
/** Reveal stages are additive. Hosts must treat unknown non-terminal values as waiting. */
|
|
517
|
+
type RevealStage = 'STARTING' | 'WAITING_FOR_DMS' | 'WAITING_FOR_PARTICIPANTS' | 'AUTHORIZED' | 'MATERIAL_AUTHORIZED' | 'MATERIAL_RELEASED' | 'RECONSTRUCTED' | 'ACTIONS_OPEN' | 'CLOSING' | 'CLOSED' | 'DENIED' | 'PARTICIPANT_REVOKED' | 'RECONCILIATION_REQUIRED' | 'EXPIRED' | 'CANCELED' | 'FAILED' | 'WAITING_FOR_CUSTODIAN_CLAIM' | 'WAITING_FOR_CUSTODIAN';
|
|
518
|
+
type RevealCloseReason = 'COMPLETED' | 'CANCELED' | 'DMS_RESET' | 'ERROR';
|
|
519
|
+
type RevealActionType = 'VIEW_FIELD' | 'COPY_FIELD' | 'USE_FIELD' | 'EXPORT_ASSET' | 'AUTOFILL_FIELD' | 'INSERT_FIELD';
|
|
520
|
+
type RevealActionDestination = 'STDIN' | 'ENVIRONMENT' | 'FILE_DESCRIPTOR' | 'LOCAL_SOCKET' | 'TEMPORARY_FILE';
|
|
521
|
+
type RevealActionOutcome = 'SUCCEEDED' | 'FAILED' | 'CANCELED';
|
|
522
|
+
interface StartRevealInput {
|
|
523
|
+
mode: RevealMode;
|
|
524
|
+
idempotencyKey: string;
|
|
525
|
+
}
|
|
526
|
+
interface RevealReconstructionInput {
|
|
527
|
+
status: 'SUCCEEDED' | 'FAILED';
|
|
528
|
+
errorCode?: string;
|
|
529
|
+
}
|
|
530
|
+
interface RevealSession {
|
|
531
|
+
id: string;
|
|
532
|
+
idempotencyKey: string;
|
|
533
|
+
applicationId: string;
|
|
534
|
+
environment: 'TEST' | 'LIVE';
|
|
535
|
+
planId: string;
|
|
536
|
+
mode: RevealMode;
|
|
537
|
+
stage: RevealStage;
|
|
538
|
+
materialVersion?: string;
|
|
539
|
+
expiresAt: string;
|
|
540
|
+
/** Expiry of the active dead-man's-switch gate. Present only while the DMS is pending. */
|
|
541
|
+
dmsExpiresAt?: string;
|
|
542
|
+
createdAt: string;
|
|
543
|
+
updatedAt: string;
|
|
544
|
+
participantDecisions?: unknown;
|
|
545
|
+
/** Server-resolved governed progress. Omitted for direct reveals or unavailable source progress. */
|
|
546
|
+
approvedModerators?: number;
|
|
547
|
+
requiredModerators?: number;
|
|
548
|
+
/** Server-resolved decision state for each plan moderator. */
|
|
549
|
+
moderators?: Array<{
|
|
550
|
+
id: string;
|
|
551
|
+
status: 'PENDING' | 'APPROVED' | 'REJECTED';
|
|
552
|
+
}>;
|
|
553
|
+
/**
|
|
554
|
+
* Which governance layer the reveal is stopped at, in the order they run: the dead man's switch,
|
|
555
|
+
* the member proving who they are, then the moderators. One waiting stage covers all three, so
|
|
556
|
+
* without this a host cannot tell whose action it is waiting for. Absent past governance.
|
|
557
|
+
*/
|
|
558
|
+
governanceGate?: 'DMS' | 'AUTHENTICATION' | 'MODERATION';
|
|
559
|
+
/** Deadline of the active authentication or moderation layer. */
|
|
560
|
+
governanceExpiresAt?: string;
|
|
561
|
+
closedReason?: RevealCloseReason;
|
|
562
|
+
}
|
|
563
|
+
interface CustodianShareAccess {
|
|
564
|
+
status: 'PENDING' | 'DISTRIBUTED' | 'CLAIMED' | 'INVALID' | 'NOT_FOUND';
|
|
565
|
+
deviceType: string;
|
|
566
|
+
shareId: string;
|
|
567
|
+
distributedAt: string | null;
|
|
568
|
+
}
|
|
569
|
+
interface AuthorizeRevealActionInput {
|
|
570
|
+
idempotencyKey: string;
|
|
571
|
+
assetId: string;
|
|
572
|
+
fieldName?: string;
|
|
573
|
+
action: RevealActionType;
|
|
574
|
+
destination?: RevealActionDestination;
|
|
575
|
+
origin?: string;
|
|
576
|
+
}
|
|
577
|
+
interface ReportRevealActionOutcomeInput {
|
|
578
|
+
idempotencyKey: string;
|
|
579
|
+
outcome: RevealActionOutcome;
|
|
580
|
+
reportedAt: string;
|
|
581
|
+
errorCode?: string;
|
|
582
|
+
}
|
|
583
|
+
interface RevealAction {
|
|
584
|
+
id: string;
|
|
585
|
+
revealId: string;
|
|
586
|
+
assetId: string;
|
|
587
|
+
fieldName?: string;
|
|
588
|
+
action: RevealActionType;
|
|
589
|
+
destination?: RevealActionDestination;
|
|
590
|
+
status: 'AUTHORIZED' | RevealActionOutcome;
|
|
591
|
+
origin?: string;
|
|
592
|
+
outcome?: RevealActionOutcome;
|
|
593
|
+
errorCode?: string;
|
|
594
|
+
createdAt?: string;
|
|
595
|
+
updatedAt?: string;
|
|
596
|
+
}
|
|
597
|
+
type CustodianShareResult = {
|
|
598
|
+
status: 'PENDING';
|
|
599
|
+
} | {
|
|
600
|
+
id: string;
|
|
601
|
+
shares: string[];
|
|
602
|
+
planId: string;
|
|
603
|
+
isMergeAuthority: boolean;
|
|
604
|
+
};
|
|
605
|
+
declare class RevealActionsNotOpen extends Error {
|
|
606
|
+
readonly stage: string;
|
|
607
|
+
readonly code = "reveal_actions_not_open";
|
|
608
|
+
constructor(stage: string);
|
|
609
|
+
}
|
|
317
610
|
declare class ElementsApiPortRequired extends Error {
|
|
318
611
|
constructor();
|
|
319
612
|
}
|
|
320
613
|
|
|
614
|
+
/**
|
|
615
|
+
* Identifies which master key opens a plan.
|
|
616
|
+
*
|
|
617
|
+
* A plan's key is a property of the plan, not of the Application holding it: a bridged
|
|
618
|
+
* plan is never re-wrapped, so it stays sealed under the key of the context it came
|
|
619
|
+
* from. One host may therefore need several keys at once — its own Application key and
|
|
620
|
+
* a foreign organization key for each bridged plan.
|
|
621
|
+
*/
|
|
622
|
+
interface MasterKeyRef {
|
|
623
|
+
system: 'INHERITI_BUSINESS' | 'INHERITI_ELEMENTS';
|
|
624
|
+
contextId: string;
|
|
625
|
+
}
|
|
626
|
+
/** Stable string form of a ref, used as the `KeyVault` key. */
|
|
627
|
+
declare function masterKeyRefKey(ref: MasterKeyRef): string;
|
|
628
|
+
/**
|
|
629
|
+
* Resolves the master key for a given plan's key reference.
|
|
630
|
+
*
|
|
631
|
+
* Custody says how a key came into existence; a resolver says how *this* host obtains
|
|
632
|
+
* it. The two are independent, so a resolver may derive one key, read another from a
|
|
633
|
+
* KMS, and relay a third.
|
|
634
|
+
*/
|
|
635
|
+
interface MasterKeyResolver {
|
|
636
|
+
resolve(ref: MasterKeyRef): Promise<string | undefined>;
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Derives which key opens a plan.
|
|
640
|
+
*
|
|
641
|
+
* A bridged plan names its source context; a locally created one is opened by the key
|
|
642
|
+
* of the Application holding it.
|
|
643
|
+
*/
|
|
644
|
+
declare function masterKeyRefFor(material: {
|
|
645
|
+
tenantId?: string;
|
|
646
|
+
sourceReference?: {
|
|
647
|
+
system: string;
|
|
648
|
+
contextId: string;
|
|
649
|
+
};
|
|
650
|
+
}): MasterKeyRef | undefined;
|
|
651
|
+
/** Thrown when a plan is master key wrapped and no key resolves for its reference. */
|
|
652
|
+
declare class MasterKeyRequired extends Error {
|
|
653
|
+
readonly ref: MasterKeyRef;
|
|
654
|
+
constructor(ref: MasterKeyRef);
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Resolves keys from a static map of references to sources.
|
|
658
|
+
*
|
|
659
|
+
* Sources come from the Core SDK, so a passphrase-derived key and one supplied from a
|
|
660
|
+
* KMS are the same to everything downstream.
|
|
661
|
+
*/
|
|
662
|
+
declare class StaticMasterKeyResolver implements MasterKeyResolver {
|
|
663
|
+
private readonly sources;
|
|
664
|
+
constructor(entries?: Array<{
|
|
665
|
+
ref: MasterKeyRef;
|
|
666
|
+
source: MasterKeySource;
|
|
667
|
+
}>);
|
|
668
|
+
register(ref: MasterKeyRef, source: MasterKeySource): this;
|
|
669
|
+
resolve(ref: MasterKeyRef): Promise<string | undefined>;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
interface MasterKeyRelayPort {
|
|
673
|
+
startRelaySession(clientPublicKey: string): Promise<{
|
|
674
|
+
sessionId: string;
|
|
675
|
+
expiresAt: string | Date;
|
|
676
|
+
}>;
|
|
677
|
+
readRelaySession(sessionId: string): Promise<{
|
|
678
|
+
status: 'PENDING' | 'DELIVERED' | 'EXPIRED';
|
|
679
|
+
sealedMasterKey?: string;
|
|
680
|
+
}>;
|
|
681
|
+
}
|
|
682
|
+
declare class MasterKeyRelayTimedOut extends Error {
|
|
683
|
+
readonly sessionId: string;
|
|
684
|
+
constructor(sessionId: string);
|
|
685
|
+
}
|
|
686
|
+
declare class MasterKeyRelayExpired extends Error {
|
|
687
|
+
readonly sessionId: string;
|
|
688
|
+
constructor(sessionId: string);
|
|
689
|
+
}
|
|
690
|
+
interface RelayMasterKeySourceOptions {
|
|
691
|
+
api: MasterKeyRelayPort;
|
|
692
|
+
/** How long to wait for the device before giving up. Defaults to the session lifetime. */
|
|
693
|
+
timeoutMs?: number;
|
|
694
|
+
pollIntervalMs?: number;
|
|
695
|
+
sleep?: (ms: number) => Promise<void>;
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Obtains the master key from the device holding it.
|
|
699
|
+
*
|
|
700
|
+
* Elements has no websocket layer, so the host polls. The key is sealed to an ephemeral
|
|
701
|
+
* public key generated here and never leaves this process in the clear: the private half
|
|
702
|
+
* is not persisted, so a relayed key cannot be replayed from stored state.
|
|
703
|
+
*/
|
|
704
|
+
declare class RelayMasterKeySource implements MasterKeySource {
|
|
705
|
+
private readonly options;
|
|
706
|
+
constructor(options: RelayMasterKeySourceOptions);
|
|
707
|
+
resolve(): Promise<string>;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Local custody as a host declares it.
|
|
712
|
+
*
|
|
713
|
+
* Wider than `MasterKeySource` on purpose — see `MasterKeyAcquisitionOptions.source`. Every
|
|
714
|
+
* `MasterKeySource` satisfies it.
|
|
715
|
+
*/
|
|
716
|
+
interface DeclaredMasterKeySource {
|
|
717
|
+
resolve(): Promise<string | undefined>;
|
|
718
|
+
}
|
|
719
|
+
interface MasterKeyAcquisitionOptions {
|
|
720
|
+
api: ElementsApiPort;
|
|
721
|
+
/** The Application this host acts for. A ref naming any other context is foreign. */
|
|
722
|
+
applicationId: string;
|
|
723
|
+
/**
|
|
724
|
+
* What this host can produce on its own: a passphrase-derived key, or key material it already
|
|
725
|
+
* holds. Absent means the host has no custody of its own and must be given the key.
|
|
726
|
+
*
|
|
727
|
+
* Wider than `MasterKeySource` on purpose — a host may only discover at reveal time that it holds
|
|
728
|
+
* nothing, because the operator has not stored a secret yet. Answering `undefined` then is not a
|
|
729
|
+
* failure: it falls through to asking the device that holds the key, which is the same outcome as
|
|
730
|
+
* declaring no source at all. Every `MasterKeySource` satisfies this.
|
|
731
|
+
*/
|
|
732
|
+
source?: DeclaredMasterKeySource;
|
|
733
|
+
/** Passed through to the relay, for hosts that want a different wait or poll interval. */
|
|
734
|
+
relay?: Omit<RelayMasterKeySourceOptions, 'api'>;
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Decides how this host obtains the key that opens a plan, and does it.
|
|
738
|
+
*
|
|
739
|
+
* The decision belongs here rather than in each host. A host declares what custody it holds — a
|
|
740
|
+
* passphrase, raw key material, or nothing — and this composes the rest: a host that can derive
|
|
741
|
+
* never asks anyone, and a host that cannot asks Elements whether a device holds the key and then
|
|
742
|
+
* asks that device. Nothing here prompts a person for a secret; acquisition during a reveal is
|
|
743
|
+
* either automatic or a request to the holder.
|
|
744
|
+
*
|
|
745
|
+
* `EXTERNAL` custody is expected to arrive as `source` — the host loaded it from its own key
|
|
746
|
+
* management. Relay is not refused for it, because relay is a transport rather than a custody, but
|
|
747
|
+
* it is not the path such a host is meant to take.
|
|
748
|
+
*
|
|
749
|
+
* Nothing is cached here: `ElementsClient` checks its `KeyVault` before calling a resolver and
|
|
750
|
+
* stores what comes back, so a second reveal in the same process never asks a phone again.
|
|
751
|
+
*/
|
|
752
|
+
declare function createMasterKeyResolver(options: MasterKeyAcquisitionOptions): MasterKeyResolver;
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* Where the host keeps master keys between operations.
|
|
756
|
+
*
|
|
757
|
+
* Keyed by master key reference rather than by Application: a host may hold its own
|
|
758
|
+
* Application key alongside a foreign organization key for each bridged plan, and those
|
|
759
|
+
* are different keys that must not collide.
|
|
760
|
+
*/
|
|
761
|
+
interface KeyVault {
|
|
762
|
+
store(ref: MasterKeyRef, key: Uint8Array): Promise<void>;
|
|
763
|
+
load(ref: MasterKeyRef): Promise<Uint8Array | undefined>;
|
|
764
|
+
remove(ref: MasterKeyRef): Promise<void>;
|
|
765
|
+
}
|
|
766
|
+
declare class MemoryKeyVault implements KeyVault {
|
|
767
|
+
private readonly keys;
|
|
768
|
+
store(ref: MasterKeyRef, key: Uint8Array): Promise<void>;
|
|
769
|
+
load(ref: MasterKeyRef): Promise<Uint8Array | undefined>;
|
|
770
|
+
remove(ref: MasterKeyRef): Promise<void>;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
interface StatePort {
|
|
774
|
+
set<T>(key: string, value: T): Promise<void>;
|
|
775
|
+
get<T>(key: string): Promise<T | undefined>;
|
|
776
|
+
remove(key: string): Promise<void>;
|
|
777
|
+
}
|
|
778
|
+
declare class MemoryStatePort implements StatePort {
|
|
779
|
+
private readonly values;
|
|
780
|
+
set<T>(key: string, value: T): Promise<void>;
|
|
781
|
+
get<T>(key: string): Promise<T | undefined>;
|
|
782
|
+
remove(key: string): Promise<void>;
|
|
783
|
+
}
|
|
784
|
+
|
|
321
785
|
interface PlanMaterialReconstructor {
|
|
322
786
|
/**
|
|
323
787
|
* `masterKeyHex` is required when the material reports `masterKeyWrapped`: the plan
|
|
@@ -329,8 +793,153 @@ declare class PlanMaterialReconstructorRequired extends Error {
|
|
|
329
793
|
constructor();
|
|
330
794
|
}
|
|
331
795
|
|
|
796
|
+
interface GuidedCreateCheckpointStore {
|
|
797
|
+
load(operationId: string): Promise<GuidedCreateCheckpoint | undefined>;
|
|
798
|
+
save(checkpoint: GuidedCreateCheckpoint): Promise<void>;
|
|
799
|
+
remove(operationId: string): Promise<void>;
|
|
800
|
+
}
|
|
801
|
+
interface PlanMaterialBuilder<TSecrets, TEncrypted = unknown> {
|
|
802
|
+
encrypt(input: {
|
|
803
|
+
planId: string;
|
|
804
|
+
declaration: StartPlanCreationInput;
|
|
805
|
+
secrets: TSecrets;
|
|
806
|
+
signal?: AbortSignal;
|
|
807
|
+
}): Promise<TEncrypted>;
|
|
808
|
+
generateShares(input: {
|
|
809
|
+
planId: string;
|
|
810
|
+
declaration: StartPlanCreationInput;
|
|
811
|
+
encrypted: TEncrypted;
|
|
812
|
+
signal?: AbortSignal;
|
|
813
|
+
}): Promise<EncryptedPlanMaterial>;
|
|
814
|
+
}
|
|
815
|
+
interface GuidedCreateOptions {
|
|
816
|
+
signal?: AbortSignal;
|
|
817
|
+
onProgress?: (stage: GuidedCreateLocalStage | PlanCreationProgress['stage']) => void;
|
|
818
|
+
}
|
|
819
|
+
/** Process-lifetime checkpoints. A host that must survive a restart supplies a durable store. */
|
|
820
|
+
declare class MemoryGuidedCreateCheckpointStore implements GuidedCreateCheckpointStore {
|
|
821
|
+
private readonly checkpoints;
|
|
822
|
+
load(operationId: string): Promise<GuidedCreateCheckpoint | undefined>;
|
|
823
|
+
save(checkpoint: GuidedCreateCheckpoint): Promise<void>;
|
|
824
|
+
remove(operationId: string): Promise<void>;
|
|
825
|
+
}
|
|
826
|
+
/** Resumable orchestration. Only its non-secret checkpoint may survive process restart. */
|
|
827
|
+
declare class GuidedPlanCreator {
|
|
828
|
+
private readonly api;
|
|
829
|
+
private readonly checkpoints;
|
|
830
|
+
constructor(api: ElementsApiPort, checkpoints: GuidedCreateCheckpointStore);
|
|
831
|
+
start(input: StartPlanCreationInput, options?: GuidedCreateOptions): Promise<PlanCreationProgress>;
|
|
832
|
+
status(operationId: string): Promise<PlanCreationProgress>;
|
|
833
|
+
resume<TSecrets, TEncrypted>(operationId: string, declaration: StartPlanCreationInput, secrets: TSecrets, builder: PlanMaterialBuilder<TSecrets, TEncrypted>, options?: GuidedCreateOptions): Promise<PlanCreationProgress>;
|
|
834
|
+
cancel(operationId: string): Promise<PlanCreationProgress>;
|
|
835
|
+
private saveCheckpoint;
|
|
836
|
+
}
|
|
837
|
+
declare class GuidedCreateRecoveryError extends Error {
|
|
838
|
+
readonly code: string;
|
|
839
|
+
constructor(code: string);
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
type AssetFieldSelector = string | {
|
|
843
|
+
asset: string;
|
|
844
|
+
field: string;
|
|
845
|
+
};
|
|
846
|
+
interface RevealFieldOptions {
|
|
847
|
+
action?: Exclude<RevealActionType, 'EXPORT_ASSET'>;
|
|
848
|
+
destination?: RevealActionDestination;
|
|
849
|
+
origin?: string;
|
|
850
|
+
idempotencyKey?: string;
|
|
851
|
+
}
|
|
852
|
+
interface RevealFieldConsumption {
|
|
853
|
+
selector: AssetFieldSelector;
|
|
854
|
+
options?: RevealFieldOptions;
|
|
855
|
+
}
|
|
856
|
+
interface ConsumedRevealField {
|
|
857
|
+
/** Canonical metadata only; the value must never be logged or returned by the workflow. */
|
|
858
|
+
selector: string;
|
|
859
|
+
value: unknown;
|
|
860
|
+
}
|
|
861
|
+
type RevealFieldDestination = (fields: readonly ConsumedRevealField[]) => void | Promise<void>;
|
|
862
|
+
/**
|
|
863
|
+
* Where a reveal has got to, in the order a reveal runs.
|
|
864
|
+
*
|
|
865
|
+
* The sequence is this client's own: it clears the governance layers in turn — the dead man's switch,
|
|
866
|
+
* the member proving who they are, then the moderators — releases the material from its storage
|
|
867
|
+
* layers, asks the device for the custodian shard when one is owed, and rebuilds the secret. Only the
|
|
868
|
+
* governance layers have server stages, and the server collapses all of them into one; everything
|
|
869
|
+
* after `AUTHORIZED` happens here and was invisible to callers. So the phase is reported here, where
|
|
870
|
+
* it is known, rather than inferred by each host from a stage that cannot express it.
|
|
871
|
+
*/
|
|
872
|
+
type RevealPhase =
|
|
873
|
+
/**
|
|
874
|
+
* The key that opens the plan is being asked of the device holding it.
|
|
875
|
+
*
|
|
876
|
+
* First, and before the reveal exists: the key is resolved ahead of governance and ahead of any
|
|
877
|
+
* one-shot material release. A host that derives its own key never sees this phase — it passes
|
|
878
|
+
* through in a single call — so its presence means a person has to answer on SafeKey Mobile.
|
|
879
|
+
*/
|
|
880
|
+
'WAITING_FOR_MASTER_KEY' | 'STARTING' | 'WAITING_FOR_DMS' | 'WAITING_FOR_AUTHENTICATION' | 'WAITING_FOR_MODERATION' | 'RELEASING_MATERIAL' | 'WAITING_FOR_CUSTODIAN_CLAIM' | 'WAITING_FOR_CUSTODIAN' | 'RECONSTRUCTING' | 'OPEN' | 'DENIED' | 'EXPIRED' | 'PARTICIPANT_REVOKED' | 'RECONCILIATION_REQUIRED' | 'STOPPED_BY_DMS' | 'ENDED'
|
|
881
|
+
/** A stage this build has not been taught to name. Stages are additive, so it is a wait. */
|
|
882
|
+
| 'CONTINUING';
|
|
883
|
+
interface RevealProgress {
|
|
884
|
+
readonly phase: RevealPhase;
|
|
885
|
+
/**
|
|
886
|
+
* The server's own view, for the deadlines and counts a caller renders beside the phase.
|
|
887
|
+
*
|
|
888
|
+
* Absent before the reveal is started: `WAITING_FOR_MASTER_KEY` is reported while the key is
|
|
889
|
+
* being acquired, which happens before there is a session to describe. Every phase from
|
|
890
|
+
* `STARTING` onwards carries one.
|
|
891
|
+
*/
|
|
892
|
+
readonly session?: RevealSession;
|
|
893
|
+
}
|
|
894
|
+
interface OpenRevealOptions {
|
|
895
|
+
mode?: RevealMode;
|
|
896
|
+
idempotencyKey?: string;
|
|
897
|
+
signal?: AbortSignal;
|
|
898
|
+
pollIntervalMs?: number;
|
|
899
|
+
/** How long to wait for a SafeKey Mobile custodian release before giving up. Default 2 minutes. */
|
|
900
|
+
custodianTimeoutMs?: number;
|
|
901
|
+
/** Every step of the reveal, named. Prefer this to `onSession`, which reports server stages only. */
|
|
902
|
+
onProgress?: (progress: RevealProgress) => void;
|
|
903
|
+
onSession?: (session: RevealSession) => void;
|
|
904
|
+
}
|
|
905
|
+
/** The governance layers the server does report, read from the gate it names. */
|
|
906
|
+
declare function revealPhaseOf(session: RevealSession): RevealPhase;
|
|
907
|
+
interface RevealHandle {
|
|
908
|
+
readonly session: RevealSession;
|
|
909
|
+
readonly material: Uint8Array;
|
|
910
|
+
readonly closed: boolean;
|
|
911
|
+
field<TValue = unknown>(selector: AssetFieldSelector, options?: RevealFieldOptions): Promise<TValue>;
|
|
912
|
+
/** Authorize, decode and deliver fields without returning their plaintext to the caller. */
|
|
913
|
+
consumeFields(fields: readonly RevealFieldConsumption[], destination: RevealFieldDestination): Promise<void>;
|
|
914
|
+
close(reason?: RevealCloseReason): Promise<void>;
|
|
915
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
916
|
+
}
|
|
917
|
+
declare class RevealHandleClosed extends Error {
|
|
918
|
+
readonly code = "reveal_handle_closed";
|
|
919
|
+
constructor();
|
|
920
|
+
}
|
|
921
|
+
declare class RevealFieldAccessError extends Error {
|
|
922
|
+
readonly code: 'asset_selector_invalid' | 'asset_not_found' | 'asset_field_not_found' | 'action_not_allowed' | 'asset_decoder_required' | 'asset_value_invalid';
|
|
923
|
+
constructor(code: 'asset_selector_invalid' | 'asset_not_found' | 'asset_field_not_found' | 'action_not_allowed' | 'asset_decoder_required' | 'asset_value_invalid');
|
|
924
|
+
}
|
|
925
|
+
declare function parseAssetFieldSelector(selector: AssetFieldSelector): {
|
|
926
|
+
asset: string;
|
|
927
|
+
field: string;
|
|
928
|
+
};
|
|
929
|
+
|
|
930
|
+
interface DecodedPlanAsset {
|
|
931
|
+
id: string;
|
|
932
|
+
data: Uint8Array;
|
|
933
|
+
}
|
|
934
|
+
type PlanAssetContainerDecoder = (material: Uint8Array) => readonly DecodedPlanAsset[];
|
|
332
935
|
interface ElementsClientOptions {
|
|
333
|
-
|
|
936
|
+
/**
|
|
937
|
+
* Only plan *creation* needs the Core container. `createPlan` and `configurePlan` reach it
|
|
938
|
+
* through `useCase()`; nothing on the reveal path — `prepareReveal`, `collectPlanMaterial`,
|
|
939
|
+
* `reconstructPlanMaterial`, `openScopedReveal` — touches it. A reveal-only host therefore
|
|
940
|
+
* composes a client without one rather than porting Core's container to its platform.
|
|
941
|
+
*/
|
|
942
|
+
coreSdk?: SDKContainer;
|
|
334
943
|
keyVault?: KeyVault;
|
|
335
944
|
state?: StatePort;
|
|
336
945
|
api?: ElementsApiPort;
|
|
@@ -338,38 +947,79 @@ interface ElementsClientOptions {
|
|
|
338
947
|
/**
|
|
339
948
|
* Resolves master keys per plan. A host may need several: its own Application key
|
|
340
949
|
* and a foreign organization key for each bridged plan it opens.
|
|
950
|
+
*
|
|
951
|
+
* A host that has no reason to compose its own leaves this out and declares `masterKey`
|
|
952
|
+
* instead, which is the shape every integration host should use.
|
|
341
953
|
*/
|
|
342
954
|
masterKeys?: MasterKeyResolver;
|
|
955
|
+
/**
|
|
956
|
+
* What custody this host holds locally, for the client to compose acquisition around.
|
|
957
|
+
*
|
|
958
|
+
* `source` present means this host can produce the key alone; absent means it must be given the
|
|
959
|
+
* key by the device holding it. Either way the host declares custody and consumes the result —
|
|
960
|
+
* it never decides between deriving and relaying, and never speaks the relay protocol itself.
|
|
961
|
+
* Ignored when `masterKeys` is given, so an explicitly composed resolver always wins.
|
|
962
|
+
*/
|
|
963
|
+
masterKey?: {
|
|
964
|
+
source?: MasterKeyAcquisitionOptions['source'];
|
|
965
|
+
relay?: MasterKeyAcquisitionOptions['relay'];
|
|
966
|
+
};
|
|
343
967
|
/** The Application this client acts for; needed to wrap keys of plans it creates. */
|
|
344
|
-
applicationId
|
|
968
|
+
applicationId: string;
|
|
969
|
+
assetDecoder: PlanAssetContainerDecoder;
|
|
345
970
|
}
|
|
346
971
|
declare class ElementsClient {
|
|
347
|
-
|
|
972
|
+
readonly coreSdk: SDKContainer | undefined;
|
|
348
973
|
readonly keyVault: KeyVault;
|
|
349
974
|
readonly state: StatePort;
|
|
350
|
-
constructor(coreSdk: SDKContainer, options?: {
|
|
975
|
+
constructor(coreSdk: SDKContainer | undefined, options?: {
|
|
351
976
|
keyVault?: KeyVault;
|
|
352
977
|
state?: StatePort;
|
|
353
978
|
api?: ElementsApiPort;
|
|
354
979
|
reconstructor?: PlanMaterialReconstructor;
|
|
355
980
|
masterKeys?: MasterKeyResolver;
|
|
981
|
+
masterKey?: ElementsClientOptions['masterKey'];
|
|
356
982
|
applicationId?: string;
|
|
983
|
+
assetDecoder?: PlanAssetContainerDecoder;
|
|
357
984
|
});
|
|
358
985
|
private readonly api?;
|
|
359
986
|
private readonly reconstructor?;
|
|
360
987
|
private readonly masterKeys?;
|
|
361
988
|
private readonly applicationId?;
|
|
362
|
-
|
|
989
|
+
readonly assetDecoder?: PlanAssetContainerDecoder;
|
|
990
|
+
listPlans(input?: ListPlansInput): Promise<PlanPage>;
|
|
991
|
+
getPlan(planId: string): Promise<PlanDetail>;
|
|
992
|
+
startPlanCreation(input: StartPlanCreationInput): Promise<PlanCreationProgress>;
|
|
993
|
+
getPlanCreation(operationId: string): Promise<PlanCreationProgress>;
|
|
994
|
+
supplyPlanCreationMaterial(operationId: string, material: EncryptedPlanMaterial): Promise<PlanCreationProgress>;
|
|
995
|
+
cancelPlanCreation(operationId: string): Promise<PlanCreationProgress>;
|
|
363
996
|
/**
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
*
|
|
997
|
+
* The resumable creation flow over this client's own port.
|
|
998
|
+
*
|
|
999
|
+
* The four calls above are the raw stages; a host that wants recovery, progress and the
|
|
1000
|
+
* encrypt/split step in the right order drives them through here instead. Checkpoints
|
|
1001
|
+
* default to process memory because they only need to outlive the operation, not the host.
|
|
367
1002
|
*/
|
|
368
|
-
|
|
369
|
-
|
|
1003
|
+
guidedPlanCreator(checkpoints?: GuidedCreateCheckpointStore): GuidedPlanCreator;
|
|
1004
|
+
/**
|
|
1005
|
+
* Creates the plan definition from a declaration of what it will protect.
|
|
1006
|
+
*
|
|
1007
|
+
* Elements takes a `PlanAssetDeclaration` rather than the assets themselves: creation
|
|
1008
|
+
* persists metadata only, and a host that has not yet collected any secret should be
|
|
1009
|
+
* able to reach this point. Where Business keeps the secrets in browser storage between
|
|
1010
|
+
* its create and configure pages, an Elements host holds the declaration and supplies
|
|
1011
|
+
* the secrets to `configurePlan()` — how it carries them across is its own decision.
|
|
1012
|
+
*/
|
|
1013
|
+
createPlan<TInput extends {
|
|
1014
|
+
assets: PlanAssetDeclaration;
|
|
370
1015
|
}, TResult>(input: TInput): Promise<TResult>;
|
|
371
|
-
/**
|
|
372
|
-
|
|
1016
|
+
/**
|
|
1017
|
+
* Configures a plan under the Application's required master key. The key is resolved
|
|
1018
|
+
* through the configured custody source; it is never an operation parameter.
|
|
1019
|
+
*/
|
|
1020
|
+
configurePlan<TInput extends object, TResult>(input: TInput): Promise<TResult>;
|
|
1021
|
+
/** Resolves the Application's required master key without exposing it as an operation argument. */
|
|
1022
|
+
applicationMasterKey(): Promise<string>;
|
|
373
1023
|
/**
|
|
374
1024
|
* Resolves the key that opens a plan before anything is collected.
|
|
375
1025
|
*
|
|
@@ -389,6 +1039,15 @@ declare class ElementsClient {
|
|
|
389
1039
|
revealPlan(planId: string, stepUp?: StepUpReadContext): Promise<Uint8Array>;
|
|
390
1040
|
collectPlanMaterial(planId: string, stepUp?: StepUpReadContext): Promise<CollectedPlanMaterial>;
|
|
391
1041
|
reconstructPlanMaterial(material: CollectedPlanMaterial): Promise<Uint8Array>;
|
|
1042
|
+
/**
|
|
1043
|
+
* Drops a held master key, so the next reveal acquires it again.
|
|
1044
|
+
*
|
|
1045
|
+
* The vault keeps a resolved key for the life of this client — a whole editor window or browser
|
|
1046
|
+
* service worker — which is what stops a second reveal asking the phone again. This is how a host
|
|
1047
|
+
* gives that up: a "lock" action, and the only way to see the acquisition happen twice.
|
|
1048
|
+
* Omitting `ref` forgets the key for this client's own Application.
|
|
1049
|
+
*/
|
|
1050
|
+
forgetMasterKey(ref?: MasterKeyRef): Promise<void>;
|
|
392
1051
|
/**
|
|
393
1052
|
* Resolves the key that opens this plan, caching it in the vault.
|
|
394
1053
|
*
|
|
@@ -407,6 +1066,31 @@ declare class ElementsClient {
|
|
|
407
1066
|
}): Promise<string | undefined>;
|
|
408
1067
|
initializeGovernedReveal(planId: string, stepUp?: StepUpReadContext): Promise<GovernedRevealSession>;
|
|
409
1068
|
getGovernedReveal(processId: string, stepUp?: StepUpReadContext): Promise<GovernedRevealState>;
|
|
1069
|
+
startReveal(planId: string, input: StartRevealInput): Promise<RevealSession>;
|
|
1070
|
+
getReveal(revealId: string): Promise<RevealSession>;
|
|
1071
|
+
openReveal(planId: string, options?: OpenRevealOptions): Promise<RevealHandle>;
|
|
1072
|
+
withReveal<TResult>(planId: string, options: OpenRevealOptions, work: (reveal: RevealHandle) => Promise<TResult>): Promise<TResult>;
|
|
1073
|
+
releaseRevealMaterial(revealId: string, materialVersion: string): Promise<unknown>;
|
|
1074
|
+
/**
|
|
1075
|
+
* States that this client holds the storage-layer shares.
|
|
1076
|
+
*
|
|
1077
|
+
* Only the client can say so, so it is a call rather than something the release infers. It also
|
|
1078
|
+
* settles the custodian: a first access advances straight past it, because the custodian shard
|
|
1079
|
+
* travelled with the material, and every access after this one goes through SafeKey Mobile.
|
|
1080
|
+
*/
|
|
1081
|
+
markRevealSharesCollected(revealId: string): Promise<void>;
|
|
1082
|
+
requestRevealCustodianRelease(revealId: string): Promise<void>;
|
|
1083
|
+
getRevealCustodianAccess(revealId: string): Promise<CustodianShareAccess>;
|
|
1084
|
+
getRevealCustodianShare(revealId: string): Promise<CustodianShareResult>;
|
|
1085
|
+
reportRevealReconstruction(revealId: string, input: RevealReconstructionInput): Promise<RevealSession>;
|
|
1086
|
+
closeReveal(revealId: string, reason: RevealCloseReason): Promise<RevealSession>;
|
|
1087
|
+
abortPlanAccess(planId: string): Promise<{
|
|
1088
|
+
aborted: boolean;
|
|
1089
|
+
}>;
|
|
1090
|
+
authorizeRevealAction(revealId: string, input: AuthorizeRevealActionInput): Promise<RevealAction>;
|
|
1091
|
+
reportRevealActionOutcome(revealId: string, actionId: string, input: ReportRevealActionOutcomeInput): Promise<RevealAction>;
|
|
1092
|
+
getCustodianShare(processId: string, stepUp?: StepUpReadContext): Promise<CustodianShareResult>;
|
|
1093
|
+
releaseCustodianShare(processId: string): Promise<void>;
|
|
410
1094
|
exportPlanBridge(planId: string, input: ExportPlanBridgeInput): Promise<PlanBridgeEnvelope>;
|
|
411
1095
|
importPlanBridge(envelope: PlanBridgeEnvelope): Promise<{
|
|
412
1096
|
planId: string;
|
|
@@ -417,6 +1101,71 @@ declare class ElementsClient {
|
|
|
417
1101
|
}
|
|
418
1102
|
declare function createElementsClient(options: ElementsClientOptions): ElementsClient;
|
|
419
1103
|
|
|
1104
|
+
declare class ElementsApiRequestFailed extends Error {
|
|
1105
|
+
readonly status: number;
|
|
1106
|
+
readonly code?: string | undefined;
|
|
1107
|
+
readonly detail?: string | undefined;
|
|
1108
|
+
constructor(status: number, code?: string | undefined, detail?: string | undefined);
|
|
1109
|
+
get stepUpRequestId(): string | undefined;
|
|
1110
|
+
}
|
|
1111
|
+
declare class HttpElementsApiPort implements ElementsApiPort {
|
|
1112
|
+
private readonly apiUrl;
|
|
1113
|
+
private readonly environment;
|
|
1114
|
+
private readonly getBearerToken;
|
|
1115
|
+
private readonly transport;
|
|
1116
|
+
constructor(apiUrl: string, environment: 'TEST' | 'LIVE', getBearerToken: BearerTokenResolver, transport: HttpTransport);
|
|
1117
|
+
listPlans(input?: ListPlansInput): Promise<PlanPage>;
|
|
1118
|
+
getPlan(planId: string): Promise<PlanDetail>;
|
|
1119
|
+
startPlanCreation(input: StartPlanCreationInput): Promise<PlanCreationProgress>;
|
|
1120
|
+
getPlanCreation(operationId: string): Promise<PlanCreationProgress>;
|
|
1121
|
+
supplyPlanCreationMaterial(operationId: string, material: EncryptedPlanMaterial): Promise<PlanCreationProgress>;
|
|
1122
|
+
cancelPlanCreation(operationId: string): Promise<PlanCreationProgress>;
|
|
1123
|
+
/**
|
|
1124
|
+
* Master key acquisition, on the operator lane.
|
|
1125
|
+
*
|
|
1126
|
+
* Elements answers these questions on two lanes with the same use cases behind them: `/master-key`
|
|
1127
|
+
* for a caller holding an Application credential, `v1/master-key` for one signed in as an
|
|
1128
|
+
* operator. This client authenticates as an operator everywhere else it reads a plan, so it asks
|
|
1129
|
+
* on that lane too — a credential bearer is refused here and an operator token is refused there.
|
|
1130
|
+
*/
|
|
1131
|
+
masterKeyAcquisition(): Promise<MasterKeyAcquisition>;
|
|
1132
|
+
foreignMasterKeyAcquisition(system: string, contextId: string): Promise<MasterKeyAcquisition>;
|
|
1133
|
+
startMasterKeyRelaySession(clientPublicKey: string): Promise<MasterKeyRelaySessionOpened>;
|
|
1134
|
+
readMasterKeyRelaySession(sessionId: string): Promise<MasterKeyRelaySessionState>;
|
|
1135
|
+
planKeyReference(planId: string): Promise<PlanKeyReference>;
|
|
1136
|
+
collectPlanMaterial(planId: string, stepUp?: StepUpReadContext): Promise<CollectedPlanMaterial>;
|
|
1137
|
+
initializeGovernedReveal(planId: string, stepUp?: StepUpReadContext): Promise<GovernedRevealSession>;
|
|
1138
|
+
getGovernedReveal(processId: string, stepUp?: StepUpReadContext): Promise<GovernedRevealState>;
|
|
1139
|
+
collectGovernedValidatorShares(processId: string, stepUp?: StepUpReadContext): Promise<GovernedValidatorMaterial>;
|
|
1140
|
+
collectGovernedShares(processId: string, stepUp?: StepUpReadContext): Promise<GovernedSharesMaterial>;
|
|
1141
|
+
markGovernedSharesCollected(processId: string): Promise<void>;
|
|
1142
|
+
markGovernedSharesReconstructed(processId: string): Promise<void>;
|
|
1143
|
+
markGovernedDataRevealed(processId: string): Promise<void>;
|
|
1144
|
+
closeGovernedReveal(processId: string): Promise<void>;
|
|
1145
|
+
startReveal(planId: string, input: StartRevealInput): Promise<RevealSession>;
|
|
1146
|
+
getReveal(revealId: string): Promise<RevealSession>;
|
|
1147
|
+
releaseRevealMaterial(revealId: string, materialVersion: string): Promise<unknown>;
|
|
1148
|
+
markRevealSharesCollected(revealId: string): Promise<void>;
|
|
1149
|
+
requestRevealCustodianRelease(revealId: string): Promise<void>;
|
|
1150
|
+
getRevealCustodianAccess(revealId: string): Promise<CustodianShareAccess>;
|
|
1151
|
+
getRevealCustodianShare(revealId: string): Promise<CustodianShareResult>;
|
|
1152
|
+
reportRevealReconstruction(revealId: string, input: RevealReconstructionInput): Promise<RevealSession>;
|
|
1153
|
+
closeReveal(revealId: string, reason: RevealCloseReason): Promise<RevealSession>;
|
|
1154
|
+
abortPlanAccess(planId: string): Promise<{
|
|
1155
|
+
aborted: boolean;
|
|
1156
|
+
}>;
|
|
1157
|
+
authorizeRevealAction(revealId: string, input: AuthorizeRevealActionInput): Promise<RevealAction>;
|
|
1158
|
+
reportRevealActionOutcome(revealId: string, actionId: string, input: ReportRevealActionOutcomeInput): Promise<RevealAction>;
|
|
1159
|
+
getCustodianShare(processId: string, stepUp?: StepUpReadContext): Promise<CustodianShareResult>;
|
|
1160
|
+
releaseCustodianShare(processId: string): Promise<void>;
|
|
1161
|
+
exportPlanBridge(planId: string, input: ExportPlanBridgeInput): Promise<PlanBridgeEnvelope>;
|
|
1162
|
+
importPlanBridge(envelope: PlanBridgeEnvelope): Promise<{
|
|
1163
|
+
planId: string;
|
|
1164
|
+
}>;
|
|
1165
|
+
private request;
|
|
1166
|
+
private requestWithoutResult;
|
|
1167
|
+
}
|
|
1168
|
+
|
|
420
1169
|
/**
|
|
421
1170
|
* Opens a plan key that was sealed under a master key.
|
|
422
1171
|
*
|
|
@@ -425,43 +1174,280 @@ declare function createElementsClient(options: ElementsClientOptions): ElementsC
|
|
|
425
1174
|
*/
|
|
426
1175
|
declare function unwrapDekWithMasterKey(wrappedDekBase64: string, masterKeyHex?: string): Promise<string>;
|
|
427
1176
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
1177
|
+
/** Elements adapter for Core's transport-neutral event port. Scheduling remains owned by Core's mature loop. */
|
|
1178
|
+
declare class PollingSharedPlanEventListener implements SharedPlanEventListener {
|
|
1179
|
+
private readonly api;
|
|
1180
|
+
private readonly subscriptions;
|
|
1181
|
+
private readonly loop;
|
|
1182
|
+
constructor(api: ElementsApiPort, environment?: ProcessRuntimeEnvironment, ownership?: ProcessReconciliationOwnership, random?: () => number);
|
|
1183
|
+
refreshConnection(): void;
|
|
1184
|
+
subscribe(processId: string, handlers: SharedPlanEventHandlers): void;
|
|
1185
|
+
unsubscribe(processId: string): void;
|
|
437
1186
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
1187
|
+
/** Cross-host runtime: browsers regain work on online/visibility events; Node uses timer-only recovery. */
|
|
1188
|
+
declare class HostProcessRuntimeEnvironment implements ProcessRuntimeEnvironment {
|
|
1189
|
+
visibility(): 'visible' | 'hidden';
|
|
1190
|
+
isOnline(): boolean;
|
|
1191
|
+
now(): number;
|
|
1192
|
+
schedule(callback: () => void, delayMs: number): () => void;
|
|
1193
|
+
onRecovery(callback: () => void): () => void;
|
|
441
1194
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
1195
|
+
/** One host process owns its own polling; Core's loop still enforces one active lease per subscription. */
|
|
1196
|
+
declare class LocalProcessReconciliationOwnership implements ProcessReconciliationOwnership {
|
|
1197
|
+
join(_processId: string, handlers: Parameters<ProcessReconciliationOwnership['join']>[1]): {
|
|
1198
|
+
isOwner: () => boolean;
|
|
1199
|
+
requestReconciliation: () => void;
|
|
1200
|
+
publishReconciled: () => undefined;
|
|
1201
|
+
leave: () => void;
|
|
1202
|
+
};
|
|
445
1203
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
1204
|
+
|
|
1205
|
+
interface CorePlanSecrets {
|
|
1206
|
+
assets: DataAsset[];
|
|
1207
|
+
/** Number of non-custodian share destinations. */
|
|
1208
|
+
totalShares: number;
|
|
1209
|
+
threshold: number;
|
|
1210
|
+
/** @deprecated Custodian posture is derived from the plan declaration and this value is ignored. */
|
|
1211
|
+
withCustodian?: boolean;
|
|
452
1212
|
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
1213
|
+
interface PreparedCorePlanMaterial {
|
|
1214
|
+
data: Uint8Array;
|
|
1215
|
+
assets: DataAsset[];
|
|
1216
|
+
totalShares: number;
|
|
1217
|
+
threshold: number;
|
|
1218
|
+
withCustodian: boolean;
|
|
1219
|
+
masterKey: string;
|
|
1220
|
+
}
|
|
1221
|
+
/** Uses Core's registered SSDP+ generator and production share sealer as one guided-create adapter. */
|
|
1222
|
+
declare class CorePlanMaterialBuilder implements PlanMaterialBuilder<CorePlanSecrets, PreparedCorePlanMaterial> {
|
|
1223
|
+
private readonly masterKeySource;
|
|
1224
|
+
private readonly generator;
|
|
1225
|
+
private readonly sealer;
|
|
1226
|
+
constructor(coreSdk: SDKContainer, masterKeySource: MasterKeySource);
|
|
1227
|
+
encrypt(input: {
|
|
1228
|
+
planId: string;
|
|
1229
|
+
declaration: StartPlanCreationInput;
|
|
1230
|
+
secrets: CorePlanSecrets;
|
|
1231
|
+
signal?: AbortSignal;
|
|
1232
|
+
}): Promise<PreparedCorePlanMaterial>;
|
|
1233
|
+
generateShares(input: {
|
|
1234
|
+
planId: string;
|
|
1235
|
+
declaration: StartPlanCreationInput;
|
|
1236
|
+
encrypted: PreparedCorePlanMaterial;
|
|
1237
|
+
signal?: AbortSignal;
|
|
1238
|
+
}): Promise<EncryptedPlanMaterial>;
|
|
1239
|
+
private sealCustodianPair;
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
type ElementsEnvironment = 'TEST' | 'LIVE';
|
|
1243
|
+
interface OidcDiscoveryDocument {
|
|
1244
|
+
issuer: string;
|
|
1245
|
+
authorizationEndpoint: string;
|
|
1246
|
+
tokenEndpoint: string;
|
|
1247
|
+
deviceAuthorizationEndpoint?: string;
|
|
1248
|
+
endSessionEndpoint?: string;
|
|
1249
|
+
revocationEndpoint?: string;
|
|
1250
|
+
}
|
|
1251
|
+
interface OperatorAuthConfiguration {
|
|
1252
|
+
issuer: string;
|
|
1253
|
+
clientId: string;
|
|
1254
|
+
audience: string;
|
|
1255
|
+
environment: ElementsEnvironment;
|
|
1256
|
+
redirectUri: string;
|
|
1257
|
+
scopes: readonly string[];
|
|
1258
|
+
}
|
|
1259
|
+
interface OAuthTokenResponse {
|
|
1260
|
+
accessToken: string;
|
|
1261
|
+
refreshToken?: string;
|
|
1262
|
+
idToken?: string;
|
|
1263
|
+
tokenType: string;
|
|
1264
|
+
expiresInSeconds: number;
|
|
1265
|
+
refreshExpiresInSeconds?: number;
|
|
1266
|
+
scope?: string;
|
|
1267
|
+
}
|
|
1268
|
+
interface ValidatedOperatorToken {
|
|
1269
|
+
issuer: string;
|
|
1270
|
+
audience: string | readonly string[];
|
|
1271
|
+
authorizedParty: string;
|
|
1272
|
+
environment: ElementsEnvironment;
|
|
1273
|
+
subject: string;
|
|
1274
|
+
sessionId: string;
|
|
1275
|
+
tokenId: string;
|
|
1276
|
+
scopes: readonly string[];
|
|
1277
|
+
nonce?: string;
|
|
1278
|
+
}
|
|
1279
|
+
interface OperatorSession {
|
|
1280
|
+
accessToken: string;
|
|
1281
|
+
refreshToken?: string;
|
|
1282
|
+
idToken?: string;
|
|
1283
|
+
tokenType: 'Bearer';
|
|
1284
|
+
expiresAt: number;
|
|
1285
|
+
refreshExpiresAt?: number;
|
|
1286
|
+
principal: ValidatedOperatorToken;
|
|
1287
|
+
}
|
|
1288
|
+
interface AuthorizationTransaction {
|
|
1289
|
+
kind: 'authorization-code';
|
|
1290
|
+
state: string;
|
|
1291
|
+
nonce: string;
|
|
1292
|
+
codeVerifier: string;
|
|
1293
|
+
redirectUri: string;
|
|
1294
|
+
expiresAt: number;
|
|
1295
|
+
}
|
|
1296
|
+
interface DeviceAuthorization {
|
|
1297
|
+
deviceCode: string;
|
|
1298
|
+
userCode: string;
|
|
1299
|
+
verificationUri: string;
|
|
1300
|
+
verificationUriComplete?: string;
|
|
1301
|
+
expiresInSeconds: number;
|
|
1302
|
+
intervalSeconds?: number;
|
|
1303
|
+
}
|
|
1304
|
+
interface DeviceTransaction extends DeviceAuthorization {
|
|
1305
|
+
kind: 'device-code';
|
|
1306
|
+
expiresAt: number;
|
|
1307
|
+
nextPollAt: number;
|
|
1308
|
+
consumed: boolean;
|
|
1309
|
+
}
|
|
1310
|
+
type OAuthTransaction = AuthorizationTransaction | DeviceTransaction;
|
|
1311
|
+
interface OperatorSessionSummary {
|
|
1312
|
+
id: string;
|
|
1313
|
+
createdAt: string;
|
|
1314
|
+
lastSeenAt?: string;
|
|
1315
|
+
current: boolean;
|
|
1316
|
+
clientId: string;
|
|
1317
|
+
environment: ElementsEnvironment;
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
interface OperatorAuthTransport {
|
|
1321
|
+
discover(issuer: string): Promise<OidcDiscoveryDocument>;
|
|
1322
|
+
exchangeAuthorizationCode(input: {
|
|
1323
|
+
tokenEndpoint: string;
|
|
1324
|
+
clientId: string;
|
|
1325
|
+
code: string;
|
|
1326
|
+
codeVerifier: string;
|
|
1327
|
+
redirectUri: string;
|
|
1328
|
+
}): Promise<OAuthTokenResponse>;
|
|
1329
|
+
startDeviceAuthorization(input: {
|
|
1330
|
+
endpoint: string;
|
|
1331
|
+
clientId: string;
|
|
1332
|
+
scopes: readonly string[];
|
|
1333
|
+
}): Promise<DeviceAuthorization>;
|
|
1334
|
+
pollDeviceToken(input: {
|
|
1335
|
+
tokenEndpoint: string;
|
|
1336
|
+
clientId: string;
|
|
1337
|
+
deviceCode: string;
|
|
1338
|
+
}): Promise<OAuthTokenResponse>;
|
|
1339
|
+
refresh(input: {
|
|
1340
|
+
tokenEndpoint: string;
|
|
1341
|
+
clientId: string;
|
|
1342
|
+
refreshToken: string;
|
|
1343
|
+
}): Promise<OAuthTokenResponse>;
|
|
1344
|
+
}
|
|
1345
|
+
interface OperatorTokenValidator {
|
|
1346
|
+
validateAccessToken(accessToken: string): Promise<ValidatedOperatorToken>;
|
|
1347
|
+
validateIdToken?(idToken: string): Promise<ValidatedOperatorToken>;
|
|
1348
|
+
}
|
|
1349
|
+
interface OperatorSessionStore {
|
|
1350
|
+
load(): Promise<OperatorSession | undefined>;
|
|
1351
|
+
save(session: OperatorSession): Promise<void>;
|
|
1352
|
+
clear(): Promise<void>;
|
|
1353
|
+
}
|
|
1354
|
+
interface OAuthTransactionStore {
|
|
1355
|
+
load(key: string): Promise<OAuthTransaction | undefined>;
|
|
1356
|
+
save(key: string, transaction: OAuthTransaction): Promise<void>;
|
|
1357
|
+
remove(key: string): Promise<void>;
|
|
1358
|
+
}
|
|
1359
|
+
interface OAuthClock {
|
|
1360
|
+
now(): number;
|
|
1361
|
+
sleep(milliseconds: number, signal?: AbortSignal): Promise<void>;
|
|
1362
|
+
}
|
|
1363
|
+
interface OAuthCrypto {
|
|
1364
|
+
randomUrlSafe(byteLength: number): string;
|
|
1365
|
+
sha256UrlSafe(value: string): Promise<string>;
|
|
1366
|
+
}
|
|
1367
|
+
interface OperatorSessionControlPort {
|
|
1368
|
+
list(): Promise<readonly OperatorSessionSummary[]>;
|
|
1369
|
+
revoke(sessionId: string): Promise<void>;
|
|
1370
|
+
logout(sessionId: string): Promise<void>;
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
declare class WebOAuthCrypto implements OAuthCrypto {
|
|
1374
|
+
randomUrlSafe(byteLength: number): string;
|
|
1375
|
+
sha256UrlSafe(value: string): Promise<string>;
|
|
1376
|
+
}
|
|
1377
|
+
declare class SystemOAuthClock implements OAuthClock {
|
|
1378
|
+
now(): number;
|
|
1379
|
+
sleep(milliseconds: number, signal?: AbortSignal): Promise<void>;
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
declare class OperatorAuthError extends Error {
|
|
1383
|
+
readonly code: string;
|
|
1384
|
+
constructor(code: string, message?: string);
|
|
1385
|
+
}
|
|
1386
|
+
declare class OperatorReauthenticationRequired extends OperatorAuthError {
|
|
1387
|
+
constructor(message?: string);
|
|
1388
|
+
}
|
|
1389
|
+
declare class OAuthProtocolError extends OperatorAuthError {
|
|
1390
|
+
constructor(code: string, message?: string);
|
|
1391
|
+
}
|
|
1392
|
+
declare function oauthErrorCode(error: unknown): string | undefined;
|
|
1393
|
+
|
|
1394
|
+
type OAuthHttpTransport = (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
1395
|
+
/** Standard public-client OAuth/OIDC transport. Confidential BFFs should inject their own transport. */
|
|
1396
|
+
declare class HttpOperatorAuthTransport implements OperatorAuthTransport {
|
|
1397
|
+
private readonly http;
|
|
1398
|
+
constructor(http?: OAuthHttpTransport);
|
|
1399
|
+
discover(issuer: string): Promise<OidcDiscoveryDocument>;
|
|
1400
|
+
exchangeAuthorizationCode(input: Parameters<OperatorAuthTransport['exchangeAuthorizationCode']>[0]): Promise<OAuthTokenResponse>;
|
|
1401
|
+
startDeviceAuthorization(input: Parameters<OperatorAuthTransport['startDeviceAuthorization']>[0]): Promise<DeviceAuthorization>;
|
|
1402
|
+
pollDeviceToken(input: Parameters<OperatorAuthTransport['pollDeviceToken']>[0]): Promise<OAuthTokenResponse>;
|
|
1403
|
+
refresh(input: Parameters<OperatorAuthTransport['refresh']>[0]): Promise<OAuthTokenResponse>;
|
|
1404
|
+
private token;
|
|
1405
|
+
private form;
|
|
1406
|
+
private json;
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
interface OperatorAuthClientOptions {
|
|
1410
|
+
configuration: OperatorAuthConfiguration;
|
|
1411
|
+
transport: OperatorAuthTransport;
|
|
1412
|
+
tokenValidator: OperatorTokenValidator;
|
|
1413
|
+
sessions: OperatorSessionStore;
|
|
1414
|
+
transactions: OAuthTransactionStore;
|
|
1415
|
+
crypto?: OAuthCrypto;
|
|
1416
|
+
clock?: OAuthClock;
|
|
1417
|
+
}
|
|
1418
|
+
declare class OperatorAuthClient {
|
|
461
1419
|
private readonly options;
|
|
462
|
-
|
|
463
|
-
|
|
1420
|
+
private readonly crypto;
|
|
1421
|
+
private readonly clock;
|
|
1422
|
+
private discovery?;
|
|
1423
|
+
private refreshFlight?;
|
|
1424
|
+
constructor(options: OperatorAuthClientOptions);
|
|
1425
|
+
beginAuthorizationCode(): Promise<{
|
|
1426
|
+
authorizationUrl: string;
|
|
1427
|
+
expiresAt: number;
|
|
1428
|
+
}>;
|
|
1429
|
+
completeAuthorizationCode(callbackUrl: string): Promise<OperatorSession>;
|
|
1430
|
+
beginDeviceAuthorization(): Promise<DeviceTransaction>;
|
|
1431
|
+
pollDeviceAuthorization(signal?: AbortSignal): Promise<OperatorSession>;
|
|
1432
|
+
getAccessToken(): Promise<string | undefined>;
|
|
1433
|
+
refresh(): Promise<OperatorSession>;
|
|
1434
|
+
clear(): Promise<void>;
|
|
1435
|
+
private performRefresh;
|
|
1436
|
+
private getDiscovery;
|
|
1437
|
+
private transactionKey;
|
|
1438
|
+
private acceptTokens;
|
|
1439
|
+
private assertPrincipal;
|
|
1440
|
+
private assertIdentity;
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
declare class OperatorSessionController {
|
|
1444
|
+
private readonly control;
|
|
1445
|
+
private readonly local;
|
|
1446
|
+
constructor(control: OperatorSessionControlPort, local: OperatorSessionStore);
|
|
1447
|
+
list(): Promise<readonly OperatorSessionSummary[]>;
|
|
1448
|
+
revoke(sessionId: string): Promise<void>;
|
|
1449
|
+
logout(): Promise<void>;
|
|
464
1450
|
}
|
|
465
1451
|
|
|
466
|
-
export { ElementsApiPortRequired, ElementsClient, InheritiClientProvider, MasterKeyRelayExpired, MasterKeyRelayTimedOut, MasterKeyRequired, MemoryKeyVault, MemoryStatePort, PlanMaterialReconstructorRequired, RelayMasterKeySource, StaticMasterKeyResolver, createElementsClient, getAvailableEnvs, masterKeyRefFor, masterKeyRefKey, unwrapDekWithMasterKey, useClient };
|
|
467
|
-
export type { CollectedPlanMaterial, ElementsApiPort, ElementsClientOptions, ExportPlanBridgeInput, GovernedRevealSession, GovernedRevealState, GovernedShare, GovernedSharesMaterial, GovernedValidatorMaterial, InheritiClientProviderProps, KeyVault, MasterKeyRef, MasterKeyRelayPort, MasterKeyResolver, PlanBridgeEnvelope, PlanMaterialReconstructor, PlanRevealProfile, RelayMasterKeySourceOptions, StatePort, StepUpReadContext };
|
|
1452
|
+
export { CANONICAL_PLAN_ASSET_TYPES, CANONICAL_STRUCTURED_ASSET_FIELDS, CorePlanMaterialBuilder, ElementsApiPortRequired, ElementsApiRequestFailed, ElementsClient, GuidedCreateRecoveryError, GuidedPlanCreator, HostProcessRuntimeEnvironment, HttpElementsApiPort, HttpOperatorAuthTransport, InheritiClientProvider, InvalidPlanDeclaration, InvalidPlanMaterial, LocalProcessReconciliationOwnership, MasterKeyRelayExpired, MasterKeyRelayTimedOut, MasterKeyRequired, MemoryGuidedCreateCheckpointStore, MemoryKeyVault, MemoryStatePort, OAuthProtocolError, OperatorAuthClient, OperatorAuthError, OperatorReauthenticationRequired, OperatorSessionController, PLAN_CREATION_SERVER_STAGES, PlanMaterialReconstructorRequired, PollingSharedPlanEventListener, RelayMasterKeySource, RevealActionsNotOpen, RevealFieldAccessError, RevealHandleClosed, StaticMasterKeyResolver, SystemOAuthClock, WebOAuthCrypto, createElementsClient, createMasterKeyResolver, getAvailableEnvs, masterKeyRefFor, masterKeyRefKey, oauthErrorCode, parseAssetFieldSelector, revealPhaseOf, unwrapDekWithMasterKey, useClient, validatePlanCreationInput, validatePlanCreationMaterial };
|
|
1453
|
+
export type { AssetFieldSelector, AuthorizationTransaction, AuthorizeRevealActionInput, CanonicalPlanAssetType, CollectedPlanMaterial, CompatibleValue, ConsumedRevealField, CorePlanSecrets, CustodianShareResult, DeclaredMasterKeySource, DecodedPlanAsset, DeviceAuthorization, DeviceTransaction, ElementsApiPort, ElementsClientOptions, ElementsEnvironment, EncryptedPlanMaterial, EncryptedPlanShard, ExportPlanBridgeInput, GovernedRevealSession, GovernedRevealState, GovernedShare, GovernedSharesMaterial, GovernedValidatorMaterial, GuidedCreateCheckpoint, GuidedCreateCheckpointStore, GuidedCreateLocalStage, GuidedCreateOptions, InheritiClientProviderProps, IntegrationPlanAssetDeclaration, KeyVault, ListPlansInput, MasterKeyAcquisition, MasterKeyAcquisitionOptions, MasterKeyRef, MasterKeyRelayPort, MasterKeyRelaySessionOpened, MasterKeyRelaySessionState, MasterKeyResolver, NativePlanParticipant, OAuthClock, OAuthCrypto, OAuthHttpTransport, OAuthTokenResponse, OAuthTransaction, OAuthTransactionStore, OidcDiscoveryDocument, OpenRevealOptions, OperatorAuthClientOptions, OperatorAuthConfiguration, OperatorAuthTransport, OperatorSession, OperatorSessionControlPort, OperatorSessionStore, OperatorSessionSummary, OperatorTokenValidator, PlanAssetContainerDecoder, PlanAssetSummary, PlanBridgeEnvelope, PlanCreationOutcome, PlanCreationProgress, PlanCreationServerStage, PlanDetail, PlanGovernanceMode, PlanGovernancePolicy, PlanMaterialBuilder, PlanMaterialReconstructor, PlanPage, PlanParticipantRelationship, PlanRevealProfile, PlanStatus, PlanSummary, RelayMasterKeySourceOptions, ReportRevealActionOutcomeInput, RevealAction, RevealActionDestination, RevealActionOutcome, RevealActionType, RevealCloseReason, RevealFieldConsumption, RevealFieldDestination, RevealFieldOptions, RevealHandle, RevealMode, RevealPhase, RevealProgress, RevealReconstructionInput, RevealSession, RevealStage, StartPlanCreationInput, StartRevealInput, StatePort, StepUpReadContext, ValidatedOperatorToken };
|