@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
|
@@ -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,23 @@
|
|
|
1
|
+
import type { SsdpV2Processor } from '@safetech/inheriti-core-sdk/workers/ssdp-v2';
|
|
2
|
+
import SsdpV2PlanMaterialReconstructor from './ssdp-v2-plan-material-reconstructor';
|
|
3
|
+
export interface BrowserPlanMaterialReconstructorOptions {
|
|
4
|
+
/** An already-built processor, for a host that owns its own worker lifecycle. */
|
|
5
|
+
processor?: SsdpV2Processor;
|
|
6
|
+
/**
|
|
7
|
+
* URL of the bundled `ssdp-v2.worker.js`. Honoured only where `Worker` exists; a host that
|
|
8
|
+
* supplies one in an environment without it still reconstructs, on the calling thread.
|
|
9
|
+
*/
|
|
10
|
+
workerUrl?: string | URL;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Reconstruction in a browser, with no Node entry anywhere in its import graph.
|
|
14
|
+
*
|
|
15
|
+
* The calling thread is a real fallback here, not a degraded one: only `split` has a size ceiling
|
|
16
|
+
* off-worker, and reconstruction has none. That matters because the host this exists for — an MV3
|
|
17
|
+
* service worker — cannot start a `Worker` at all, so there is nothing to fall back *from*. A host
|
|
18
|
+
* that does have `Worker` (an offscreen document, a normal page) passes `workerUrl` and gets the
|
|
19
|
+
* worker path instead.
|
|
20
|
+
*/
|
|
21
|
+
export default class BrowserPlanMaterialReconstructor extends SsdpV2PlanMaterialReconstructor {
|
|
22
|
+
constructor(options?: BrowserPlanMaterialReconstructorOptions);
|
|
23
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
/** @deprecated Custodian posture is derived from the plan declaration and this value is ignored. */
|
|
11
|
+
withCustodian?: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface PreparedCorePlanMaterial {
|
|
14
|
+
data: Uint8Array;
|
|
15
|
+
assets: DataAsset[];
|
|
16
|
+
totalShares: number;
|
|
17
|
+
threshold: number;
|
|
18
|
+
withCustodian: boolean;
|
|
19
|
+
masterKey: string;
|
|
20
|
+
}
|
|
21
|
+
/** Uses Core's registered SSDP+ generator and production share sealer as one guided-create adapter. */
|
|
22
|
+
export declare class CorePlanMaterialBuilder implements PlanMaterialBuilder<CorePlanSecrets, PreparedCorePlanMaterial> {
|
|
23
|
+
private readonly masterKeySource;
|
|
24
|
+
private readonly generator;
|
|
25
|
+
private readonly sealer;
|
|
26
|
+
constructor(coreSdk: SDKContainer, masterKeySource: MasterKeySource);
|
|
27
|
+
encrypt(input: {
|
|
28
|
+
planId: string;
|
|
29
|
+
declaration: StartPlanCreationInput;
|
|
30
|
+
secrets: CorePlanSecrets;
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
}): Promise<PreparedCorePlanMaterial>;
|
|
33
|
+
generateShares(input: {
|
|
34
|
+
planId: string;
|
|
35
|
+
declaration: StartPlanCreationInput;
|
|
36
|
+
encrypted: PreparedCorePlanMaterial;
|
|
37
|
+
signal?: AbortSignal;
|
|
38
|
+
}): Promise<EncryptedPlanMaterial>;
|
|
39
|
+
private sealCustodianPair;
|
|
40
|
+
}
|
|
41
|
+
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. */
|
|
@@ -31,7 +31,44 @@ export interface PlanKeyReference {
|
|
|
31
31
|
contextId: string;
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* How a host may obtain the master key for one context.
|
|
36
|
+
*
|
|
37
|
+
* Custody says how the key came into existence; `relayAvailable` says whether *this* caller can be
|
|
38
|
+
* given it by the device holding it. The two are independent, and the verifier is never returned:
|
|
39
|
+
* handing it out would hand out the check a wrong key must fail.
|
|
40
|
+
*/
|
|
41
|
+
export interface MasterKeyAcquisition {
|
|
42
|
+
custody: 'DERIVED' | 'EXTERNAL';
|
|
43
|
+
configured: boolean;
|
|
44
|
+
argon2Salt: string | null;
|
|
45
|
+
relayAvailable: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface MasterKeyRelaySessionOpened {
|
|
48
|
+
sessionId: string;
|
|
49
|
+
expiresAt: string | Date;
|
|
50
|
+
}
|
|
51
|
+
export interface MasterKeyRelaySessionState {
|
|
52
|
+
status: 'PENDING' | 'DELIVERED' | 'EXPIRED';
|
|
53
|
+
sealedMasterKey?: string;
|
|
54
|
+
}
|
|
34
55
|
export interface ElementsApiPort {
|
|
56
|
+
/** How this host can obtain the key for its own Application. */
|
|
57
|
+
masterKeyAcquisition(): Promise<MasterKeyAcquisition>;
|
|
58
|
+
/** The same, for the source context of a plan bridged from another system. */
|
|
59
|
+
foreignMasterKeyAcquisition(system: string, contextId: string): Promise<MasterKeyAcquisition>;
|
|
60
|
+
/**
|
|
61
|
+
* Asks the device holding the key to release it to this host. Creating the session *is* the
|
|
62
|
+
* SafeKey request; there is no separate "notify" step.
|
|
63
|
+
*/
|
|
64
|
+
startMasterKeyRelaySession(clientPublicKey: string): Promise<MasterKeyRelaySessionOpened>;
|
|
65
|
+
readMasterKeyRelaySession(sessionId: string): Promise<MasterKeyRelaySessionState>;
|
|
66
|
+
listPlans(input?: import('./plan-operations').ListPlansInput): Promise<import('./plan-operations').PlanPage>;
|
|
67
|
+
getPlan(planId: string): Promise<import('./plan-operations').PlanDetail>;
|
|
68
|
+
startPlanCreation(input: import('./plan-operations').StartPlanCreationInput): Promise<import('./plan-operations').PlanCreationProgress>;
|
|
69
|
+
getPlanCreation(operationId: string): Promise<import('./plan-operations').PlanCreationProgress>;
|
|
70
|
+
supplyPlanCreationMaterial(operationId: string, material: import('./plan-operations').EncryptedPlanMaterial): Promise<import('./plan-operations').PlanCreationProgress>;
|
|
71
|
+
cancelPlanCreation(operationId: string): Promise<import('./plan-operations').PlanCreationProgress>;
|
|
35
72
|
planKeyReference(planId: string): Promise<PlanKeyReference>;
|
|
36
73
|
collectPlanMaterial(planId: string, stepUp?: StepUpReadContext): Promise<CollectedPlanMaterial>;
|
|
37
74
|
initializeGovernedReveal(planId: string, stepUp?: StepUpReadContext): Promise<GovernedRevealSession>;
|
|
@@ -42,6 +79,34 @@ export interface ElementsApiPort {
|
|
|
42
79
|
markGovernedSharesReconstructed(processId: string): Promise<void>;
|
|
43
80
|
markGovernedDataRevealed(processId: string): Promise<void>;
|
|
44
81
|
closeGovernedReveal(processId: string): Promise<void>;
|
|
82
|
+
startReveal(planId: string, input: StartRevealInput): Promise<RevealSession>;
|
|
83
|
+
getReveal(revealId: string): Promise<RevealSession>;
|
|
84
|
+
releaseRevealMaterial(revealId: string, materialVersion: string): Promise<unknown>;
|
|
85
|
+
/** The host declaring it holds the storage-layer shares. Governed reveals only. */
|
|
86
|
+
markRevealSharesCollected(revealId: string): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* The custodian steps on the operator surface. The `/shared-plans/merge/...` equivalents are
|
|
89
|
+
* credential routes and refuse an operator token, so a host addresses them by reveal id.
|
|
90
|
+
*/
|
|
91
|
+
requestRevealCustodianRelease(revealId: string): Promise<void>;
|
|
92
|
+
getRevealCustodianAccess(revealId: string): Promise<CustodianShareAccess>;
|
|
93
|
+
getRevealCustodianShare(revealId: string): Promise<CustodianShareResult>;
|
|
94
|
+
reportRevealReconstruction(revealId: string, input: RevealReconstructionInput): Promise<RevealSession>;
|
|
95
|
+
closeReveal(revealId: string, reason: RevealCloseReason): Promise<RevealSession>;
|
|
96
|
+
/**
|
|
97
|
+
* Gives up the governed access this operator holds on a plan.
|
|
98
|
+
*
|
|
99
|
+
* A governed reveal outlives the session that started it, so a host that cancelled or crashed
|
|
100
|
+
* leaves an access still open; the next reveal resumes it. This is how a host says the access is
|
|
101
|
+
* not wanted after all. `aborted: false` means there was nothing to give up.
|
|
102
|
+
*/
|
|
103
|
+
abortPlanAccess(planId: string): Promise<{
|
|
104
|
+
aborted: boolean;
|
|
105
|
+
}>;
|
|
106
|
+
authorizeRevealAction(revealId: string, input: AuthorizeRevealActionInput): Promise<RevealAction>;
|
|
107
|
+
reportRevealActionOutcome(revealId: string, actionId: string, input: ReportRevealActionOutcomeInput): Promise<RevealAction>;
|
|
108
|
+
getCustodianShare(processId: string, stepUp?: StepUpReadContext): Promise<CustodianShareResult>;
|
|
109
|
+
releaseCustodianShare(processId: string): Promise<void>;
|
|
45
110
|
exportPlanBridge(planId: string, input: ExportPlanBridgeInput): Promise<PlanBridgeEnvelope>;
|
|
46
111
|
importPlanBridge(envelope: PlanBridgeEnvelope): Promise<{
|
|
47
112
|
planId: string;
|
|
@@ -59,7 +124,7 @@ export interface ExportPlanBridgeInput {
|
|
|
59
124
|
}
|
|
60
125
|
export interface PlanRevealProfile {
|
|
61
126
|
governance: 'KEEP' | 'BYPASS';
|
|
62
|
-
masterKeyRelease: 'REQUIRED'
|
|
127
|
+
masterKeyRelease: 'REQUIRED';
|
|
63
128
|
custodian: 'BYPASS' | 'FORCE';
|
|
64
129
|
}
|
|
65
130
|
export interface PlanBridgeEnvelope {
|
|
@@ -136,7 +201,7 @@ export interface GovernedRevealSession {
|
|
|
136
201
|
mergeThreshold: number;
|
|
137
202
|
status?: string;
|
|
138
203
|
/** Same key signalling the direct collection route returns, for the governed path. */
|
|
139
|
-
masterKeyWrapped
|
|
204
|
+
masterKeyWrapped: boolean;
|
|
140
205
|
tenantId?: string;
|
|
141
206
|
sourceReference?: {
|
|
142
207
|
system: string;
|
|
@@ -167,6 +232,101 @@ export interface GovernedSharesMaterial {
|
|
|
167
232
|
keyShards: GovernedShare[];
|
|
168
233
|
dek: string;
|
|
169
234
|
}
|
|
235
|
+
export type RevealMode = 'DIRECT' | 'GOVERNED';
|
|
236
|
+
/** Reveal stages are additive. Hosts must treat unknown non-terminal values as waiting. */
|
|
237
|
+
export 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';
|
|
238
|
+
export type RevealCloseReason = 'COMPLETED' | 'CANCELED' | 'DMS_RESET' | 'ERROR';
|
|
239
|
+
export type RevealActionType = 'VIEW_FIELD' | 'COPY_FIELD' | 'USE_FIELD' | 'EXPORT_ASSET' | 'AUTOFILL_FIELD' | 'INSERT_FIELD';
|
|
240
|
+
export type RevealActionDestination = 'STDIN' | 'ENVIRONMENT' | 'FILE_DESCRIPTOR' | 'LOCAL_SOCKET' | 'TEMPORARY_FILE';
|
|
241
|
+
export type RevealActionOutcome = 'SUCCEEDED' | 'FAILED' | 'CANCELED';
|
|
242
|
+
export interface StartRevealInput {
|
|
243
|
+
mode: RevealMode;
|
|
244
|
+
idempotencyKey: string;
|
|
245
|
+
}
|
|
246
|
+
export interface RevealReconstructionInput {
|
|
247
|
+
status: 'SUCCEEDED' | 'FAILED';
|
|
248
|
+
errorCode?: string;
|
|
249
|
+
}
|
|
250
|
+
export interface RevealSession {
|
|
251
|
+
id: string;
|
|
252
|
+
idempotencyKey: string;
|
|
253
|
+
applicationId: string;
|
|
254
|
+
environment: 'TEST' | 'LIVE';
|
|
255
|
+
planId: string;
|
|
256
|
+
mode: RevealMode;
|
|
257
|
+
stage: RevealStage;
|
|
258
|
+
materialVersion?: string;
|
|
259
|
+
expiresAt: string;
|
|
260
|
+
/** Expiry of the active dead-man's-switch gate. Present only while the DMS is pending. */
|
|
261
|
+
dmsExpiresAt?: string;
|
|
262
|
+
createdAt: string;
|
|
263
|
+
updatedAt: string;
|
|
264
|
+
participantDecisions?: unknown;
|
|
265
|
+
/** Server-resolved governed progress. Omitted for direct reveals or unavailable source progress. */
|
|
266
|
+
approvedModerators?: number;
|
|
267
|
+
requiredModerators?: number;
|
|
268
|
+
/** Server-resolved decision state for each plan moderator. */
|
|
269
|
+
moderators?: Array<{
|
|
270
|
+
id: string;
|
|
271
|
+
status: 'PENDING' | 'APPROVED' | 'REJECTED';
|
|
272
|
+
}>;
|
|
273
|
+
/**
|
|
274
|
+
* Which governance layer the reveal is stopped at, in the order they run: the dead man's switch,
|
|
275
|
+
* the member proving who they are, then the moderators. One waiting stage covers all three, so
|
|
276
|
+
* without this a host cannot tell whose action it is waiting for. Absent past governance.
|
|
277
|
+
*/
|
|
278
|
+
governanceGate?: 'DMS' | 'AUTHENTICATION' | 'MODERATION';
|
|
279
|
+
/** Deadline of the active authentication or moderation layer. */
|
|
280
|
+
governanceExpiresAt?: string;
|
|
281
|
+
closedReason?: RevealCloseReason;
|
|
282
|
+
}
|
|
283
|
+
export interface CustodianShareAccess {
|
|
284
|
+
status: 'PENDING' | 'DISTRIBUTED' | 'CLAIMED' | 'INVALID' | 'NOT_FOUND';
|
|
285
|
+
deviceType: string;
|
|
286
|
+
shareId: string;
|
|
287
|
+
distributedAt: string | null;
|
|
288
|
+
}
|
|
289
|
+
export interface AuthorizeRevealActionInput {
|
|
290
|
+
idempotencyKey: string;
|
|
291
|
+
assetId: string;
|
|
292
|
+
fieldName?: string;
|
|
293
|
+
action: RevealActionType;
|
|
294
|
+
destination?: RevealActionDestination;
|
|
295
|
+
origin?: string;
|
|
296
|
+
}
|
|
297
|
+
export interface ReportRevealActionOutcomeInput {
|
|
298
|
+
idempotencyKey: string;
|
|
299
|
+
outcome: RevealActionOutcome;
|
|
300
|
+
reportedAt: string;
|
|
301
|
+
errorCode?: string;
|
|
302
|
+
}
|
|
303
|
+
export interface RevealAction {
|
|
304
|
+
id: string;
|
|
305
|
+
revealId: string;
|
|
306
|
+
assetId: string;
|
|
307
|
+
fieldName?: string;
|
|
308
|
+
action: RevealActionType;
|
|
309
|
+
destination?: RevealActionDestination;
|
|
310
|
+
status: 'AUTHORIZED' | RevealActionOutcome;
|
|
311
|
+
origin?: string;
|
|
312
|
+
outcome?: RevealActionOutcome;
|
|
313
|
+
errorCode?: string;
|
|
314
|
+
createdAt?: string;
|
|
315
|
+
updatedAt?: string;
|
|
316
|
+
}
|
|
317
|
+
export type CustodianShareResult = {
|
|
318
|
+
status: 'PENDING';
|
|
319
|
+
} | {
|
|
320
|
+
id: string;
|
|
321
|
+
shares: string[];
|
|
322
|
+
planId: string;
|
|
323
|
+
isMergeAuthority: boolean;
|
|
324
|
+
};
|
|
325
|
+
export declare class RevealActionsNotOpen extends Error {
|
|
326
|
+
readonly stage: string;
|
|
327
|
+
readonly code = "reveal_actions_not_open";
|
|
328
|
+
constructor(stage: string);
|
|
329
|
+
}
|
|
170
330
|
export declare class ElementsApiPortRequired extends Error {
|
|
171
331
|
constructor();
|
|
172
332
|
}
|
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
import type { SDKContainer } from '@safetech/inheriti-core-sdk/vanilla';
|
|
2
|
+
import type { MasterKeyAcquisitionOptions } from './master-key-acquisition';
|
|
2
3
|
import type { KeyVault } from './key-vault';
|
|
3
4
|
import type { StatePort } from './state-port';
|
|
4
|
-
import type { CollectedPlanMaterial, ElementsApiPort, ExportPlanBridgeInput, GovernedRevealSession, GovernedRevealState, PlanBridgeEnvelope, StepUpReadContext } from './elements-api-port';
|
|
5
|
+
import type { AuthorizeRevealActionInput, CollectedPlanMaterial, CustodianShareResult, ElementsApiPort, ExportPlanBridgeInput, GovernedRevealSession, GovernedRevealState, PlanBridgeEnvelope, ReportRevealActionOutcomeInput, RevealAction, RevealCloseReason, RevealReconstructionInput, RevealSession, StartRevealInput, StepUpReadContext } from './elements-api-port';
|
|
5
6
|
import type { PlanMaterialReconstructor } from './plan-material-reconstructor';
|
|
6
|
-
import type { MasterKeyResolver } from './master-key';
|
|
7
|
+
import type { MasterKeyRef, MasterKeyResolver } from './master-key';
|
|
8
|
+
import type { PlanAssetDeclaration } from '@safetech/inheriti-core-sdk';
|
|
9
|
+
import type { EncryptedPlanMaterial, ListPlansInput, PlanCreationProgress, PlanDetail, PlanPage, StartPlanCreationInput } from './plan-operations';
|
|
10
|
+
import type { GuidedCreateCheckpointStore } from './guided-plan-creator';
|
|
11
|
+
import { GuidedPlanCreator } from './guided-plan-creator';
|
|
12
|
+
import type { OpenRevealOptions, RevealHandle } from './scoped-reveal';
|
|
13
|
+
export interface DecodedPlanAsset {
|
|
14
|
+
id: string;
|
|
15
|
+
data: Uint8Array;
|
|
16
|
+
}
|
|
17
|
+
export type PlanAssetContainerDecoder = (material: Uint8Array) => readonly DecodedPlanAsset[];
|
|
7
18
|
export interface ElementsClientOptions {
|
|
8
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Only plan *creation* needs the Core container. `createPlan` and `configurePlan` reach it
|
|
21
|
+
* through `useCase()`; nothing on the reveal path — `prepareReveal`, `collectPlanMaterial`,
|
|
22
|
+
* `reconstructPlanMaterial`, `openScopedReveal` — touches it. A reveal-only host therefore
|
|
23
|
+
* composes a client without one rather than porting Core's container to its platform.
|
|
24
|
+
*/
|
|
25
|
+
coreSdk?: SDKContainer;
|
|
9
26
|
keyVault?: KeyVault;
|
|
10
27
|
state?: StatePort;
|
|
11
28
|
api?: ElementsApiPort;
|
|
@@ -13,38 +30,79 @@ export interface ElementsClientOptions {
|
|
|
13
30
|
/**
|
|
14
31
|
* Resolves master keys per plan. A host may need several: its own Application key
|
|
15
32
|
* and a foreign organization key for each bridged plan it opens.
|
|
33
|
+
*
|
|
34
|
+
* A host that has no reason to compose its own leaves this out and declares `masterKey`
|
|
35
|
+
* instead, which is the shape every integration host should use.
|
|
16
36
|
*/
|
|
17
37
|
masterKeys?: MasterKeyResolver;
|
|
38
|
+
/**
|
|
39
|
+
* What custody this host holds locally, for the client to compose acquisition around.
|
|
40
|
+
*
|
|
41
|
+
* `source` present means this host can produce the key alone; absent means it must be given the
|
|
42
|
+
* key by the device holding it. Either way the host declares custody and consumes the result —
|
|
43
|
+
* it never decides between deriving and relaying, and never speaks the relay protocol itself.
|
|
44
|
+
* Ignored when `masterKeys` is given, so an explicitly composed resolver always wins.
|
|
45
|
+
*/
|
|
46
|
+
masterKey?: {
|
|
47
|
+
source?: MasterKeyAcquisitionOptions['source'];
|
|
48
|
+
relay?: MasterKeyAcquisitionOptions['relay'];
|
|
49
|
+
};
|
|
18
50
|
/** The Application this client acts for; needed to wrap keys of plans it creates. */
|
|
19
|
-
applicationId
|
|
51
|
+
applicationId: string;
|
|
52
|
+
assetDecoder: PlanAssetContainerDecoder;
|
|
20
53
|
}
|
|
21
54
|
export default class ElementsClient {
|
|
22
|
-
|
|
55
|
+
readonly coreSdk: SDKContainer | undefined;
|
|
23
56
|
readonly keyVault: KeyVault;
|
|
24
57
|
readonly state: StatePort;
|
|
25
|
-
constructor(coreSdk: SDKContainer, options?: {
|
|
58
|
+
constructor(coreSdk: SDKContainer | undefined, options?: {
|
|
26
59
|
keyVault?: KeyVault;
|
|
27
60
|
state?: StatePort;
|
|
28
61
|
api?: ElementsApiPort;
|
|
29
62
|
reconstructor?: PlanMaterialReconstructor;
|
|
30
63
|
masterKeys?: MasterKeyResolver;
|
|
64
|
+
masterKey?: ElementsClientOptions['masterKey'];
|
|
31
65
|
applicationId?: string;
|
|
66
|
+
assetDecoder?: PlanAssetContainerDecoder;
|
|
32
67
|
});
|
|
33
68
|
private readonly api?;
|
|
34
69
|
private readonly reconstructor?;
|
|
35
70
|
private readonly masterKeys?;
|
|
36
71
|
private readonly applicationId?;
|
|
37
|
-
|
|
72
|
+
readonly assetDecoder?: PlanAssetContainerDecoder;
|
|
73
|
+
listPlans(input?: ListPlansInput): Promise<PlanPage>;
|
|
74
|
+
getPlan(planId: string): Promise<PlanDetail>;
|
|
75
|
+
startPlanCreation(input: StartPlanCreationInput): Promise<PlanCreationProgress>;
|
|
76
|
+
getPlanCreation(operationId: string): Promise<PlanCreationProgress>;
|
|
77
|
+
supplyPlanCreationMaterial(operationId: string, material: EncryptedPlanMaterial): Promise<PlanCreationProgress>;
|
|
78
|
+
cancelPlanCreation(operationId: string): Promise<PlanCreationProgress>;
|
|
38
79
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
80
|
+
* The resumable creation flow over this client's own port.
|
|
81
|
+
*
|
|
82
|
+
* The four calls above are the raw stages; a host that wants recovery, progress and the
|
|
83
|
+
* encrypt/split step in the right order drives them through here instead. Checkpoints
|
|
84
|
+
* default to process memory because they only need to outlive the operation, not the host.
|
|
85
|
+
*/
|
|
86
|
+
guidedPlanCreator(checkpoints?: GuidedCreateCheckpointStore): GuidedPlanCreator;
|
|
87
|
+
/**
|
|
88
|
+
* Creates the plan definition from a declaration of what it will protect.
|
|
89
|
+
*
|
|
90
|
+
* Elements takes a `PlanAssetDeclaration` rather than the assets themselves: creation
|
|
91
|
+
* persists metadata only, and a host that has not yet collected any secret should be
|
|
92
|
+
* able to reach this point. Where Business keeps the secrets in browser storage between
|
|
93
|
+
* its create and configure pages, an Elements host holds the declaration and supplies
|
|
94
|
+
* the secrets to `configurePlan()` — how it carries them across is its own decision.
|
|
42
95
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
96
|
+
createPlan<TInput extends {
|
|
97
|
+
assets: PlanAssetDeclaration;
|
|
45
98
|
}, TResult>(input: TInput): Promise<TResult>;
|
|
46
|
-
/**
|
|
47
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Configures a plan under the Application's required master key. The key is resolved
|
|
101
|
+
* through the configured custody source; it is never an operation parameter.
|
|
102
|
+
*/
|
|
103
|
+
configurePlan<TInput extends object, TResult>(input: TInput): Promise<TResult>;
|
|
104
|
+
/** Resolves the Application's required master key without exposing it as an operation argument. */
|
|
105
|
+
applicationMasterKey(): Promise<string>;
|
|
48
106
|
/**
|
|
49
107
|
* Resolves the key that opens a plan before anything is collected.
|
|
50
108
|
*
|
|
@@ -64,6 +122,15 @@ export default class ElementsClient {
|
|
|
64
122
|
revealPlan(planId: string, stepUp?: StepUpReadContext): Promise<Uint8Array>;
|
|
65
123
|
collectPlanMaterial(planId: string, stepUp?: StepUpReadContext): Promise<CollectedPlanMaterial>;
|
|
66
124
|
reconstructPlanMaterial(material: CollectedPlanMaterial): Promise<Uint8Array>;
|
|
125
|
+
/**
|
|
126
|
+
* Drops a held master key, so the next reveal acquires it again.
|
|
127
|
+
*
|
|
128
|
+
* The vault keeps a resolved key for the life of this client — a whole editor window or browser
|
|
129
|
+
* service worker — which is what stops a second reveal asking the phone again. This is how a host
|
|
130
|
+
* gives that up: a "lock" action, and the only way to see the acquisition happen twice.
|
|
131
|
+
* Omitting `ref` forgets the key for this client's own Application.
|
|
132
|
+
*/
|
|
133
|
+
forgetMasterKey(ref?: MasterKeyRef): Promise<void>;
|
|
67
134
|
/**
|
|
68
135
|
* Resolves the key that opens this plan, caching it in the vault.
|
|
69
136
|
*
|
|
@@ -82,6 +149,31 @@ export default class ElementsClient {
|
|
|
82
149
|
}): Promise<string | undefined>;
|
|
83
150
|
initializeGovernedReveal(planId: string, stepUp?: StepUpReadContext): Promise<GovernedRevealSession>;
|
|
84
151
|
getGovernedReveal(processId: string, stepUp?: StepUpReadContext): Promise<GovernedRevealState>;
|
|
152
|
+
startReveal(planId: string, input: StartRevealInput): Promise<RevealSession>;
|
|
153
|
+
getReveal(revealId: string): Promise<RevealSession>;
|
|
154
|
+
openReveal(planId: string, options?: OpenRevealOptions): Promise<RevealHandle>;
|
|
155
|
+
withReveal<TResult>(planId: string, options: OpenRevealOptions, work: (reveal: RevealHandle) => Promise<TResult>): Promise<TResult>;
|
|
156
|
+
releaseRevealMaterial(revealId: string, materialVersion: string): Promise<unknown>;
|
|
157
|
+
/**
|
|
158
|
+
* States that this client holds the storage-layer shares.
|
|
159
|
+
*
|
|
160
|
+
* Only the client can say so, so it is a call rather than something the release infers. It also
|
|
161
|
+
* settles the custodian: a first access advances straight past it, because the custodian shard
|
|
162
|
+
* travelled with the material, and every access after this one goes through SafeKey Mobile.
|
|
163
|
+
*/
|
|
164
|
+
markRevealSharesCollected(revealId: string): Promise<void>;
|
|
165
|
+
requestRevealCustodianRelease(revealId: string): Promise<void>;
|
|
166
|
+
getRevealCustodianAccess(revealId: string): Promise<import("./elements-api-port").CustodianShareAccess>;
|
|
167
|
+
getRevealCustodianShare(revealId: string): Promise<CustodianShareResult>;
|
|
168
|
+
reportRevealReconstruction(revealId: string, input: RevealReconstructionInput): Promise<RevealSession>;
|
|
169
|
+
closeReveal(revealId: string, reason: RevealCloseReason): Promise<RevealSession>;
|
|
170
|
+
abortPlanAccess(planId: string): Promise<{
|
|
171
|
+
aborted: boolean;
|
|
172
|
+
}>;
|
|
173
|
+
authorizeRevealAction(revealId: string, input: AuthorizeRevealActionInput): Promise<RevealAction>;
|
|
174
|
+
reportRevealActionOutcome(revealId: string, actionId: string, input: ReportRevealActionOutcomeInput): Promise<RevealAction>;
|
|
175
|
+
getCustodianShare(processId: string, stepUp?: StepUpReadContext): Promise<CustodianShareResult>;
|
|
176
|
+
releaseCustodianShare(processId: string): Promise<void>;
|
|
85
177
|
exportPlanBridge(planId: string, input: ExportPlanBridgeInput): Promise<PlanBridgeEnvelope>;
|
|
86
178
|
importPlanBridge(envelope: PlanBridgeEnvelope): Promise<{
|
|
87
179
|
planId: string;
|
|
@@ -90,4 +182,9 @@ export default class ElementsClient {
|
|
|
90
182
|
reconstructGovernedPlanMaterial(session: GovernedRevealSession, material: CollectedPlanMaterial): Promise<Uint8Array>;
|
|
91
183
|
private useCase;
|
|
92
184
|
}
|
|
185
|
+
/** Names the one capability a reveal-only client lacks, instead of failing on a missing property. */
|
|
186
|
+
export declare class CoreSdkContainerRequired extends Error {
|
|
187
|
+
readonly code = "core_sdk_container_required";
|
|
188
|
+
constructor();
|
|
189
|
+
}
|
|
93
190
|
export declare function createElementsClient(options: ElementsClientOptions): ElementsClient;
|
|
@@ -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, MasterKeyAcquisition, MasterKeyRelaySessionOpened, MasterKeyRelaySessionState, 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,24 @@ 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>;
|
|
23
|
+
/**
|
|
24
|
+
* Master key acquisition, on the operator lane.
|
|
25
|
+
*
|
|
26
|
+
* Elements answers these questions on two lanes with the same use cases behind them: `/master-key`
|
|
27
|
+
* for a caller holding an Application credential, `v1/master-key` for one signed in as an
|
|
28
|
+
* operator. This client authenticates as an operator everywhere else it reads a plan, so it asks
|
|
29
|
+
* on that lane too — a credential bearer is refused here and an operator token is refused there.
|
|
30
|
+
*/
|
|
31
|
+
masterKeyAcquisition(): Promise<MasterKeyAcquisition>;
|
|
32
|
+
foreignMasterKeyAcquisition(system: string, contextId: string): Promise<MasterKeyAcquisition>;
|
|
33
|
+
startMasterKeyRelaySession(clientPublicKey: string): Promise<MasterKeyRelaySessionOpened>;
|
|
34
|
+
readMasterKeyRelaySession(sessionId: string): Promise<MasterKeyRelaySessionState>;
|
|
16
35
|
planKeyReference(planId: string): Promise<PlanKeyReference>;
|
|
17
36
|
collectPlanMaterial(planId: string, stepUp?: StepUpReadContext): Promise<CollectedPlanMaterial>;
|
|
18
37
|
initializeGovernedReveal(planId: string, stepUp?: StepUpReadContext): Promise<GovernedRevealSession>;
|
|
@@ -23,6 +42,22 @@ export default class HttpElementsApiPort implements ElementsApiPort {
|
|
|
23
42
|
markGovernedSharesReconstructed(processId: string): Promise<void>;
|
|
24
43
|
markGovernedDataRevealed(processId: string): Promise<void>;
|
|
25
44
|
closeGovernedReveal(processId: string): Promise<void>;
|
|
45
|
+
startReveal(planId: string, input: StartRevealInput): Promise<RevealSession>;
|
|
46
|
+
getReveal(revealId: string): Promise<RevealSession>;
|
|
47
|
+
releaseRevealMaterial(revealId: string, materialVersion: string): Promise<unknown>;
|
|
48
|
+
markRevealSharesCollected(revealId: string): Promise<void>;
|
|
49
|
+
requestRevealCustodianRelease(revealId: string): Promise<void>;
|
|
50
|
+
getRevealCustodianAccess(revealId: string): Promise<import('./elements-api-port').CustodianShareAccess>;
|
|
51
|
+
getRevealCustodianShare(revealId: string): Promise<CustodianShareResult>;
|
|
52
|
+
reportRevealReconstruction(revealId: string, input: RevealReconstructionInput): Promise<RevealSession>;
|
|
53
|
+
closeReveal(revealId: string, reason: RevealCloseReason): Promise<RevealSession>;
|
|
54
|
+
abortPlanAccess(planId: string): Promise<{
|
|
55
|
+
aborted: boolean;
|
|
56
|
+
}>;
|
|
57
|
+
authorizeRevealAction(revealId: string, input: AuthorizeRevealActionInput): Promise<RevealAction>;
|
|
58
|
+
reportRevealActionOutcome(revealId: string, actionId: string, input: ReportRevealActionOutcomeInput): Promise<RevealAction>;
|
|
59
|
+
getCustodianShare(processId: string, stepUp?: StepUpReadContext): Promise<CustodianShareResult>;
|
|
60
|
+
releaseCustodianShare(processId: string): Promise<void>;
|
|
26
61
|
exportPlanBridge(planId: string, input: ExportPlanBridgeInput): Promise<PlanBridgeEnvelope>;
|
|
27
62
|
importPlanBridge(envelope: PlanBridgeEnvelope): Promise<{
|
|
28
63
|
planId: string;
|
|
@@ -1,17 +1,30 @@
|
|
|
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, RevealActionDestination, 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, revealPhaseOf, RevealFieldAccessError, RevealHandleClosed } from './scoped-reveal';
|
|
14
|
+
export type { AssetFieldSelector, ConsumedRevealField, OpenRevealOptions, RevealFieldConsumption, RevealFieldDestination, RevealFieldOptions, RevealHandle, RevealPhase, RevealProgress } 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';
|
|
14
19
|
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';
|
|
22
|
+
export { createMasterKeyResolver } from './master-key-acquisition';
|
|
23
|
+
export type { MasterKeySource } from '@safetech/inheriti-core-sdk';
|
|
24
|
+
export type { DeclaredMasterKeySource, MasterKeyAcquisitionOptions } from './master-key-acquisition';
|
|
25
|
+
export type { MasterKeyAcquisition, MasterKeyRelaySessionOpened, MasterKeyRelaySessionState } from './elements-api-port';
|
|
17
26
|
export type { MasterKeyRelayPort, RelayMasterKeySourceOptions } from './relay-master-key-source';
|
|
27
|
+
export { HostProcessRuntimeEnvironment, LocalProcessReconciliationOwnership, PollingSharedPlanEventListener } from './polling-shared-plan-event-listener';
|
|
28
|
+
export * from './plan-operations';
|
|
29
|
+
export * from './guided-plan-creator';
|
|
30
|
+
export * from './core-plan-material-builder';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ElementsApiPort } from './elements-api-port';
|
|
2
|
+
import type { MasterKeyResolver } from './master-key';
|
|
3
|
+
import type { RelayMasterKeySourceOptions } from './relay-master-key-source';
|
|
4
|
+
/**
|
|
5
|
+
* Local custody as a host declares it.
|
|
6
|
+
*
|
|
7
|
+
* Wider than `MasterKeySource` on purpose — see `MasterKeyAcquisitionOptions.source`. Every
|
|
8
|
+
* `MasterKeySource` satisfies it.
|
|
9
|
+
*/
|
|
10
|
+
export interface DeclaredMasterKeySource {
|
|
11
|
+
resolve(): Promise<string | undefined>;
|
|
12
|
+
}
|
|
13
|
+
export interface MasterKeyAcquisitionOptions {
|
|
14
|
+
api: ElementsApiPort;
|
|
15
|
+
/** The Application this host acts for. A ref naming any other context is foreign. */
|
|
16
|
+
applicationId: string;
|
|
17
|
+
/**
|
|
18
|
+
* What this host can produce on its own: a passphrase-derived key, or key material it already
|
|
19
|
+
* holds. Absent means the host has no custody of its own and must be given the key.
|
|
20
|
+
*
|
|
21
|
+
* Wider than `MasterKeySource` on purpose — a host may only discover at reveal time that it holds
|
|
22
|
+
* nothing, because the operator has not stored a secret yet. Answering `undefined` then is not a
|
|
23
|
+
* failure: it falls through to asking the device that holds the key, which is the same outcome as
|
|
24
|
+
* declaring no source at all. Every `MasterKeySource` satisfies this.
|
|
25
|
+
*/
|
|
26
|
+
source?: DeclaredMasterKeySource;
|
|
27
|
+
/** Passed through to the relay, for hosts that want a different wait or poll interval. */
|
|
28
|
+
relay?: Omit<RelayMasterKeySourceOptions, 'api'>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Decides how this host obtains the key that opens a plan, and does it.
|
|
32
|
+
*
|
|
33
|
+
* The decision belongs here rather than in each host. A host declares what custody it holds — a
|
|
34
|
+
* passphrase, raw key material, or nothing — and this composes the rest: a host that can derive
|
|
35
|
+
* never asks anyone, and a host that cannot asks Elements whether a device holds the key and then
|
|
36
|
+
* asks that device. Nothing here prompts a person for a secret; acquisition during a reveal is
|
|
37
|
+
* either automatic or a request to the holder.
|
|
38
|
+
*
|
|
39
|
+
* `EXTERNAL` custody is expected to arrive as `source` — the host loaded it from its own key
|
|
40
|
+
* management. Relay is not refused for it, because relay is a transport rather than a custody, but
|
|
41
|
+
* it is not the path such a host is meant to take.
|
|
42
|
+
*
|
|
43
|
+
* Nothing is cached here: `ElementsClient` checks its `KeyVault` before calling a resolver and
|
|
44
|
+
* stores what comes back, so a second reveal in the same process never asks a phone again.
|
|
45
|
+
*/
|
|
46
|
+
export declare function createMasterKeyResolver(options: MasterKeyAcquisitionOptions): MasterKeyResolver;
|