@safetech/inheriti-client-sdk 1.17.3 → 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.
@@ -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
+ }
@@ -7,6 +7,7 @@ export interface CorePlanSecrets {
7
7
  /** Number of non-custodian share destinations. */
8
8
  totalShares: number;
9
9
  threshold: number;
10
+ /** @deprecated Custodian posture is derived from the plan declaration and this value is ignored. */
10
11
  withCustodian?: boolean;
11
12
  }
12
13
  interface PreparedCorePlanMaterial {
@@ -31,7 +31,38 @@ 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>;
35
66
  listPlans(input?: import('./plan-operations').ListPlansInput): Promise<import('./plan-operations').PlanPage>;
36
67
  getPlan(planId: string): Promise<import('./plan-operations').PlanDetail>;
37
68
  startPlanCreation(input: import('./plan-operations').StartPlanCreationInput): Promise<import('./plan-operations').PlanCreationProgress>;
@@ -51,8 +82,27 @@ export interface ElementsApiPort {
51
82
  startReveal(planId: string, input: StartRevealInput): Promise<RevealSession>;
52
83
  getReveal(revealId: string): Promise<RevealSession>;
53
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>;
54
94
  reportRevealReconstruction(revealId: string, input: RevealReconstructionInput): Promise<RevealSession>;
55
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
+ }>;
56
106
  authorizeRevealAction(revealId: string, input: AuthorizeRevealActionInput): Promise<RevealAction>;
57
107
  reportRevealActionOutcome(revealId: string, actionId: string, input: ReportRevealActionOutcomeInput): Promise<RevealAction>;
58
108
  getCustodianShare(processId: string, stepUp?: StepUpReadContext): Promise<CustodianShareResult>;
@@ -183,9 +233,11 @@ export interface GovernedSharesMaterial {
183
233
  dek: string;
184
234
  }
185
235
  export type RevealMode = 'DIRECT' | 'GOVERNED';
186
- export type RevealStage = 'STARTING' | 'WAITING_FOR_PARTICIPANTS' | 'AUTHORIZED' | 'MATERIAL_AUTHORIZED' | 'MATERIAL_RELEASED' | 'RECONSTRUCTED' | 'ACTIONS_OPEN' | 'CLOSING' | 'CLOSED' | 'DENIED' | 'PARTICIPANT_REVOKED' | 'RECONCILIATION_REQUIRED' | 'EXPIRED' | 'CANCELED' | 'FAILED';
187
- export type RevealCloseReason = 'COMPLETED' | 'CANCELED' | 'ERROR';
188
- export type RevealActionType = 'VIEW_FIELD' | 'COPY_FIELD' | 'EXPORT_ASSET' | 'AUTOFILL_FIELD' | 'INSERT_FIELD';
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';
189
241
  export type RevealActionOutcome = 'SUCCEEDED' | 'FAILED' | 'CANCELED';
190
242
  export interface StartRevealInput {
191
243
  mode: RevealMode;
@@ -205,19 +257,41 @@ export interface RevealSession {
205
257
  stage: RevealStage;
206
258
  materialVersion?: string;
207
259
  expiresAt: string;
260
+ /** Expiry of the active dead-man's-switch gate. Present only while the DMS is pending. */
261
+ dmsExpiresAt?: string;
208
262
  createdAt: string;
209
263
  updatedAt: string;
210
264
  participantDecisions?: unknown;
211
265
  /** Server-resolved governed progress. Omitted for direct reveals or unavailable source progress. */
212
266
  approvedModerators?: number;
213
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;
214
281
  closedReason?: RevealCloseReason;
215
282
  }
283
+ export interface CustodianShareAccess {
284
+ status: 'PENDING' | 'DISTRIBUTED' | 'CLAIMED' | 'INVALID' | 'NOT_FOUND';
285
+ deviceType: string;
286
+ shareId: string;
287
+ distributedAt: string | null;
288
+ }
216
289
  export interface AuthorizeRevealActionInput {
217
290
  idempotencyKey: string;
218
291
  assetId: string;
219
292
  fieldName?: string;
220
293
  action: RevealActionType;
294
+ destination?: RevealActionDestination;
221
295
  origin?: string;
222
296
  }
223
297
  export interface ReportRevealActionOutcomeInput {
@@ -232,6 +306,7 @@ export interface RevealAction {
232
306
  assetId: string;
233
307
  fieldName?: string;
234
308
  action: RevealActionType;
309
+ destination?: RevealActionDestination;
235
310
  status: 'AUTHORIZED' | RevealActionOutcome;
236
311
  origin?: string;
237
312
  outcome?: RevealActionOutcome;
@@ -1,9 +1,10 @@
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
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';
7
8
  import type { PlanAssetDeclaration } from '@safetech/inheriti-core-sdk';
8
9
  import type { EncryptedPlanMaterial, ListPlansInput, PlanCreationProgress, PlanDetail, PlanPage, StartPlanCreationInput } from './plan-operations';
9
10
  import type { GuidedCreateCheckpointStore } from './guided-plan-creator';
@@ -15,7 +16,13 @@ export interface DecodedPlanAsset {
15
16
  }
16
17
  export type PlanAssetContainerDecoder = (material: Uint8Array) => readonly DecodedPlanAsset[];
17
18
  export interface ElementsClientOptions {
18
- coreSdk: SDKContainer;
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;
19
26
  keyVault?: KeyVault;
20
27
  state?: StatePort;
21
28
  api?: ElementsApiPort;
@@ -23,22 +30,38 @@ export interface ElementsClientOptions {
23
30
  /**
24
31
  * Resolves master keys per plan. A host may need several: its own Application key
25
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.
26
36
  */
27
- masterKeys: MasterKeyResolver;
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
+ };
28
50
  /** The Application this client acts for; needed to wrap keys of plans it creates. */
29
51
  applicationId: string;
30
52
  assetDecoder: PlanAssetContainerDecoder;
31
53
  }
32
54
  export default class ElementsClient {
33
- readonly coreSdk: SDKContainer;
55
+ readonly coreSdk: SDKContainer | undefined;
34
56
  readonly keyVault: KeyVault;
35
57
  readonly state: StatePort;
36
- constructor(coreSdk: SDKContainer, options?: {
58
+ constructor(coreSdk: SDKContainer | undefined, options?: {
37
59
  keyVault?: KeyVault;
38
60
  state?: StatePort;
39
61
  api?: ElementsApiPort;
40
62
  reconstructor?: PlanMaterialReconstructor;
41
63
  masterKeys?: MasterKeyResolver;
64
+ masterKey?: ElementsClientOptions['masterKey'];
42
65
  applicationId?: string;
43
66
  assetDecoder?: PlanAssetContainerDecoder;
44
67
  });
@@ -99,6 +122,15 @@ export default class ElementsClient {
99
122
  revealPlan(planId: string, stepUp?: StepUpReadContext): Promise<Uint8Array>;
100
123
  collectPlanMaterial(planId: string, stepUp?: StepUpReadContext): Promise<CollectedPlanMaterial>;
101
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>;
102
134
  /**
103
135
  * Resolves the key that opens this plan, caching it in the vault.
104
136
  *
@@ -122,8 +154,22 @@ export default class ElementsClient {
122
154
  openReveal(planId: string, options?: OpenRevealOptions): Promise<RevealHandle>;
123
155
  withReveal<TResult>(planId: string, options: OpenRevealOptions, work: (reveal: RevealHandle) => Promise<TResult>): Promise<TResult>;
124
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>;
125
168
  reportRevealReconstruction(revealId: string, input: RevealReconstructionInput): Promise<RevealSession>;
126
169
  closeReveal(revealId: string, reason: RevealCloseReason): Promise<RevealSession>;
170
+ abortPlanAccess(planId: string): Promise<{
171
+ aborted: boolean;
172
+ }>;
127
173
  authorizeRevealAction(revealId: string, input: AuthorizeRevealActionInput): Promise<RevealAction>;
128
174
  reportRevealActionOutcome(revealId: string, actionId: string, input: ReportRevealActionOutcomeInput): Promise<RevealAction>;
129
175
  getCustodianShare(processId: string, stepUp?: StepUpReadContext): Promise<CustodianShareResult>;
@@ -136,4 +182,9 @@ export default class ElementsClient {
136
182
  reconstructGovernedPlanMaterial(session: GovernedRevealSession, material: CollectedPlanMaterial): Promise<Uint8Array>;
137
183
  private useCase;
138
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
+ }
139
190
  export declare function createElementsClient(options: ElementsClientOptions): ElementsClient;
@@ -1,5 +1,5 @@
1
1
  import type { BearerTokenResolver, HttpTransport } from '@safetech/inheriti-core-sdk/node';
2
- import type { AuthorizeRevealActionInput, CollectedPlanMaterial, CustodianShareResult, ElementsApiPort, PlanKeyReference, ExportPlanBridgeInput, GovernedRevealSession, GovernedRevealState, GovernedSharesMaterial, GovernedValidatorMaterial, PlanBridgeEnvelope, ReportRevealActionOutcomeInput, RevealAction, RevealCloseReason, RevealReconstructionInput, RevealSession, StartRevealInput, StepUpReadContext } from './elements-api-port';
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
3
  import type { EncryptedPlanMaterial, ListPlansInput, PlanCreationProgress, PlanDetail, PlanPage, StartPlanCreationInput } from './plan-operations';
4
4
  export declare class ElementsApiRequestFailed extends Error {
5
5
  readonly status: number;
@@ -20,6 +20,18 @@ export default class HttpElementsApiPort implements ElementsApiPort {
20
20
  getPlanCreation(operationId: string): Promise<PlanCreationProgress>;
21
21
  supplyPlanCreationMaterial(operationId: string, material: EncryptedPlanMaterial): Promise<PlanCreationProgress>;
22
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>;
23
35
  planKeyReference(planId: string): Promise<PlanKeyReference>;
24
36
  collectPlanMaterial(planId: string, stepUp?: StepUpReadContext): Promise<CollectedPlanMaterial>;
25
37
  initializeGovernedReveal(planId: string, stepUp?: StepUpReadContext): Promise<GovernedRevealSession>;
@@ -33,8 +45,15 @@ export default class HttpElementsApiPort implements ElementsApiPort {
33
45
  startReveal(planId: string, input: StartRevealInput): Promise<RevealSession>;
34
46
  getReveal(revealId: string): Promise<RevealSession>;
35
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>;
36
52
  reportRevealReconstruction(revealId: string, input: RevealReconstructionInput): Promise<RevealSession>;
37
53
  closeReveal(revealId: string, reason: RevealCloseReason): Promise<RevealSession>;
54
+ abortPlanAccess(planId: string): Promise<{
55
+ aborted: boolean;
56
+ }>;
38
57
  authorizeRevealAction(revealId: string, input: AuthorizeRevealActionInput): Promise<RevealAction>;
39
58
  reportRevealActionOutcome(revealId: string, actionId: string, input: ReportRevealActionOutcomeInput): Promise<RevealAction>;
40
59
  getCustodianShare(processId: string, stepUp?: StepUpReadContext): Promise<CustodianShareResult>;
@@ -7,11 +7,11 @@ export { MemoryStatePort } from './state-port';
7
7
  export type { StatePort } from './state-port';
8
8
  export type { CollectedPlanMaterial, ElementsApiPort, StepUpReadContext } from './elements-api-port';
9
9
  export type { GovernedRevealSession, GovernedRevealState, GovernedShare, GovernedSharesMaterial, GovernedValidatorMaterial } from './elements-api-port';
10
- export type { AuthorizeRevealActionInput, CustodianShareResult, ReportRevealActionOutcomeInput, RevealAction, RevealActionOutcome, RevealActionType, RevealCloseReason, RevealMode, RevealReconstructionInput, RevealSession, RevealStage, StartRevealInput } from './elements-api-port';
10
+ export type { AuthorizeRevealActionInput, CustodianShareResult, ReportRevealActionOutcomeInput, RevealAction, RevealActionDestination, RevealActionOutcome, RevealActionType, RevealCloseReason, RevealMode, RevealReconstructionInput, RevealSession, RevealStage, StartRevealInput } from './elements-api-port';
11
11
  export type { ExportPlanBridgeInput, PlanBridgeEnvelope, PlanRevealProfile } from './elements-api-port';
12
12
  export { ElementsApiPortRequired, RevealActionsNotOpen } from './elements-api-port';
13
- export { parseAssetFieldSelector, RevealFieldAccessError, RevealHandleClosed } from './scoped-reveal';
14
- export type { AssetFieldSelector, OpenRevealOptions, RevealFieldOptions, RevealHandle } from './scoped-reveal';
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
15
  export { default as HttpElementsApiPort, ElementsApiRequestFailed } from './http-elements-api-port';
16
16
  export type { PlanMaterialReconstructor } from './plan-material-reconstructor';
17
17
  export { PlanMaterialReconstructorRequired } from './plan-material-reconstructor';
@@ -19,6 +19,10 @@ export { MasterKeyRequired, StaticMasterKeyResolver, masterKeyRefFor, masterKeyR
19
19
  export type { MasterKeyRef, MasterKeyResolver } from './master-key';
20
20
  export { unwrapDekWithMasterKey } from './unwrap-dek';
21
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';
22
26
  export type { MasterKeyRelayPort, RelayMasterKeySourceOptions } from './relay-master-key-source';
23
27
  export { HostProcessRuntimeEnvironment, LocalProcessReconciliationOwnership, PollingSharedPlanEventListener } from './polling-shared-plan-event-listener';
24
28
  export * from './plan-operations';
@@ -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;
@@ -1,7 +1,10 @@
1
- import type { CollectedPlanMaterial } from './elements-api-port';
2
- import type { PlanMaterialReconstructor } from './plan-material-reconstructor';
3
- export default class NodePlanMaterialReconstructor implements PlanMaterialReconstructor {
4
- reconstruct(material: CollectedPlanMaterial, masterKeyHex?: string): Promise<Uint8Array>;
5
- private decryptShare;
6
- private decodeBase64;
1
+ import SsdpV2PlanMaterialReconstructor from './ssdp-v2-plan-material-reconstructor';
2
+ /**
3
+ * Reconstruction on Node, over the worker factory the Node SDK container configured.
4
+ *
5
+ * The unwrap-and-decrypt half is shared with the browser reconstructor; only the processor is
6
+ * Node's, which is the one import a browser host cannot follow.
7
+ */
8
+ export default class NodePlanMaterialReconstructor extends SsdpV2PlanMaterialReconstructor {
9
+ constructor();
7
10
  }
@@ -11,6 +11,8 @@ export type PlanParticipantRelationship = 'OWNER' | 'MERGER' | 'MODERATOR' | 'CU
11
11
  export interface PlanAssetSummary {
12
12
  count: number;
13
13
  types: CompatibleValue<CanonicalPlanAssetType>[];
14
+ /** The names the developer gave the assets, in plan order. A binary asset's filename is not here. */
15
+ names: string[];
14
16
  }
15
17
  export interface PlanSummary {
16
18
  id: string;
@@ -29,6 +31,14 @@ export interface PlanSummary {
29
31
  mergers: number;
30
32
  moderators: number;
31
33
  };
34
+ /**
35
+ * The authentication a merge has to satisfy before the plan opens. Empty means the plan carries
36
+ * none. A method's own settings are not part of the host-facing shape.
37
+ */
38
+ authentication: Array<{
39
+ id: CompatibleValue<'SK_MOBILE'>;
40
+ status: CompatibleValue<'ACTIVE' | 'INACTIVE'>;
41
+ }>;
32
42
  }
33
43
  export interface PlanPage {
34
44
  items: PlanSummary[];
@@ -50,6 +60,10 @@ export interface PlanDetail extends PlanSummary {
50
60
  name: string;
51
61
  isBinary: boolean;
52
62
  fieldNames: string[];
63
+ /** Binary assets only: what the file was called, what it is, and how big. */
64
+ fileName?: string;
65
+ mimeType?: string;
66
+ size?: number;
53
67
  matchOrigins?: string[];
54
68
  }>;
55
69
  participants: Array<{
@@ -62,6 +76,12 @@ export interface PlanDetail extends PlanSummary {
62
76
  masterKeyRelease: CompatibleValue<'REQUIRED'>;
63
77
  custodian: CompatibleValue<'FORCE' | 'BYPASS'>;
64
78
  };
79
+ dms?: {
80
+ subjectEmail: string;
81
+ countdownDays: number;
82
+ countdownHours: number;
83
+ countdownMinutes: number;
84
+ };
65
85
  source: {
66
86
  kind: 'NATIVE';
67
87
  } | {
@@ -78,6 +98,12 @@ export interface IntegrationPlanAssetDeclaration {
78
98
  type: CanonicalPlanAssetType;
79
99
  name: string;
80
100
  fieldNames?: readonly string[];
101
+ /**
102
+ * Origins this asset belongs to, so an origin-bound host can tell which of a plan's logins
103
+ * matches the page in front of the operator. Declared at creation and returned on the plan;
104
+ * without it a browser host offers every field in the plan and ranks none of them.
105
+ */
106
+ matchOrigins?: readonly string[];
81
107
  isBinary: boolean;
82
108
  fileName?: string;
83
109
  mimeType?: string;
@@ -96,12 +122,37 @@ export interface StartPlanCreationInput {
96
122
  description?: string;
97
123
  assets: readonly IntegrationPlanAssetDeclaration[];
98
124
  participants: readonly NativePlanParticipant[];
99
- policy?: {
100
- governance?: 'DIRECT' | 'GOVERNED';
125
+ policy?: PlanGovernancePolicy;
126
+ }
127
+ /**
128
+ * How a plan is governed, declared one layer at a time.
129
+ *
130
+ * The three layers are independent and each is optional on its own — the member confirming on their
131
+ * device, moderators approving, a dead man's switch running down — but a plan must select at least
132
+ * one. A plan nobody has to answer for is not a protected plan, so there is no way to declare one.
133
+ *
134
+ * This replaces a single `governance: 'DIRECT' | 'GOVERNED'` switch, which said that a plan was
135
+ * governed without saying by what, and left every layer's real configuration to a default.
136
+ */
137
+ export interface PlanGovernancePolicy {
138
+ /** The member proving it is them, on SafeKey Mobile. `true` takes the Application's method. */
139
+ authentication?: boolean | {
140
+ mode?: 'EXCLUSIVE' | 'ALL_REQUIRED';
141
+ };
142
+ /** Approval by the plan's `MODERATOR` participants. `UNANIMOUS` ignores `minimumApprovals`. */
143
+ moderation?: {
101
144
  minimumApprovals?: number;
102
- masterKeyRelease?: 'REQUIRED';
103
- custodian?: 'FORCE' | 'BYPASS';
145
+ approvalMode?: 'THRESHOLD' | 'UNANIMOUS';
146
+ };
147
+ /** A countdown a designated participant can stop. Independent of the plan's type in Elements. */
148
+ dms?: {
149
+ subjectEmail: string;
150
+ countdownDays: number;
151
+ countdownHours?: number;
152
+ countdownMinutes?: number;
104
153
  };
154
+ masterKeyRelease?: 'REQUIRED';
155
+ custodian?: 'FORCE' | 'BYPASS';
105
156
  }
106
157
  export declare const PLAN_CREATION_SERVER_STAGES: readonly ["VALIDATED", "PLAN_CREATED", "PARTICIPANTS_PERSISTED", "STORAGE_PREPARED", "AWAITING_ENCRYPTED_MATERIAL", "VALIDATOR_SHARES_DISTRIBUTED", "CONFIGURED", "COMPLETED"];
107
158
  export type PlanCreationServerStage = (typeof PLAN_CREATION_SERVER_STAGES)[number];
@@ -129,7 +180,14 @@ export interface EncryptedPlanMaterial {
129
180
  meta: {
130
181
  name: string;
131
182
  notes?: string;
183
+ code?: string;
184
+ matchOrigins?: readonly string[];
132
185
  };
186
+ fieldNames?: readonly string[];
187
+ isBinary?: boolean;
188
+ fileName?: string;
189
+ mimeType?: string;
190
+ size?: number;
133
191
  }>>;
134
192
  custodianShard?: {
135
193
  keyShard: EncryptedPlanShard;
@@ -1,26 +1,77 @@
1
1
  import type ElementsClient from './elements-client';
2
- import type { RevealActionType, RevealCloseReason, RevealMode, RevealSession } from './elements-api-port';
2
+ import type { RevealActionDestination, RevealActionType, RevealCloseReason, RevealMode, RevealSession } from './elements-api-port';
3
3
  export type AssetFieldSelector = string | {
4
4
  asset: string;
5
5
  field: string;
6
6
  };
7
7
  export interface RevealFieldOptions {
8
8
  action?: Exclude<RevealActionType, 'EXPORT_ASSET'>;
9
+ destination?: RevealActionDestination;
9
10
  origin?: string;
10
11
  idempotencyKey?: string;
11
12
  }
13
+ export interface RevealFieldConsumption {
14
+ selector: AssetFieldSelector;
15
+ options?: RevealFieldOptions;
16
+ }
17
+ export interface ConsumedRevealField {
18
+ /** Canonical metadata only; the value must never be logged or returned by the workflow. */
19
+ selector: string;
20
+ value: unknown;
21
+ }
22
+ export type RevealFieldDestination = (fields: readonly ConsumedRevealField[]) => void | Promise<void>;
23
+ /**
24
+ * Where a reveal has got to, in the order a reveal runs.
25
+ *
26
+ * The sequence is this client's own: it clears the governance layers in turn — the dead man's switch,
27
+ * the member proving who they are, then the moderators — releases the material from its storage
28
+ * layers, asks the device for the custodian shard when one is owed, and rebuilds the secret. Only the
29
+ * governance layers have server stages, and the server collapses all of them into one; everything
30
+ * after `AUTHORIZED` happens here and was invisible to callers. So the phase is reported here, where
31
+ * it is known, rather than inferred by each host from a stage that cannot express it.
32
+ */
33
+ export type RevealPhase =
34
+ /**
35
+ * The key that opens the plan is being asked of the device holding it.
36
+ *
37
+ * First, and before the reveal exists: the key is resolved ahead of governance and ahead of any
38
+ * one-shot material release. A host that derives its own key never sees this phase — it passes
39
+ * through in a single call — so its presence means a person has to answer on SafeKey Mobile.
40
+ */
41
+ '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'
42
+ /** A stage this build has not been taught to name. Stages are additive, so it is a wait. */
43
+ | 'CONTINUING';
44
+ export interface RevealProgress {
45
+ readonly phase: RevealPhase;
46
+ /**
47
+ * The server's own view, for the deadlines and counts a caller renders beside the phase.
48
+ *
49
+ * Absent before the reveal is started: `WAITING_FOR_MASTER_KEY` is reported while the key is
50
+ * being acquired, which happens before there is a session to describe. Every phase from
51
+ * `STARTING` onwards carries one.
52
+ */
53
+ readonly session?: RevealSession;
54
+ }
12
55
  export interface OpenRevealOptions {
13
56
  mode?: RevealMode;
14
57
  idempotencyKey?: string;
15
58
  signal?: AbortSignal;
16
59
  pollIntervalMs?: number;
60
+ /** How long to wait for a SafeKey Mobile custodian release before giving up. Default 2 minutes. */
61
+ custodianTimeoutMs?: number;
62
+ /** Every step of the reveal, named. Prefer this to `onSession`, which reports server stages only. */
63
+ onProgress?: (progress: RevealProgress) => void;
17
64
  onSession?: (session: RevealSession) => void;
18
65
  }
66
+ /** The governance layers the server does report, read from the gate it names. */
67
+ export declare function revealPhaseOf(session: RevealSession): RevealPhase;
19
68
  export interface RevealHandle {
20
69
  readonly session: RevealSession;
21
70
  readonly material: Uint8Array;
22
71
  readonly closed: boolean;
23
72
  field<TValue = unknown>(selector: AssetFieldSelector, options?: RevealFieldOptions): Promise<TValue>;
73
+ /** Authorize, decode and deliver fields without returning their plaintext to the caller. */
74
+ consumeFields(fields: readonly RevealFieldConsumption[], destination: RevealFieldDestination): Promise<void>;
24
75
  close(reason?: RevealCloseReason): Promise<void>;
25
76
  [Symbol.asyncDispose](): Promise<void>;
26
77
  }
@@ -42,3 +93,13 @@ export declare function parseAssetFieldSelector(selector: AssetFieldSelector): {
42
93
  asset: string;
43
94
  field: string;
44
95
  };
96
+ /** The device answered, but with nothing usable — a released record carrying no share. */
97
+ export declare class CustodianShareUnavailable extends Error {
98
+ readonly code = "custodian_share_unavailable";
99
+ constructor();
100
+ }
101
+ /** Nobody approved on the device in time. A person did not act; nothing is wrong with the reveal. */
102
+ export declare class CustodianShareTimedOut extends Error {
103
+ readonly code = "custodian_share_timed_out";
104
+ constructor();
105
+ }
@@ -0,0 +1,17 @@
1
+ import type { CollectedPlanMaterial } from './elements-api-port';
2
+ import type { PlanMaterialReconstructor } from './plan-material-reconstructor';
3
+ import type { SsdpV2Processor } from '@safetech/inheriti-core-sdk/workers/ssdp-v2';
4
+ /**
5
+ * Everything a reconstruction does apart from choosing an SSDP v2 processor.
6
+ *
7
+ * Unwrapping the plan key and decrypting the shares is WebCrypto and base64 and nothing else, so it
8
+ * is identical on Node and in a browser; only where the shares are recombined differs — a Node
9
+ * worker thread, a dedicated Worker, or the calling thread. The processor is resolved lazily
10
+ * because the Node entry configures its worker factory when the SDK container is built, which may
11
+ * happen after this object exists.
12
+ */
13
+ export default class SsdpV2PlanMaterialReconstructor implements PlanMaterialReconstructor {
14
+ private readonly processor;
15
+ constructor(processor: () => SsdpV2Processor);
16
+ reconstruct(material: CollectedPlanMaterial, masterKeyHex?: string): Promise<Uint8Array>;
17
+ }