@safetech/inheriti-client-sdk 1.17.1 → 1.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +9 -0
  2. package/dist/browser.d.ts +23 -0
  3. package/dist/browser.js +1 -0
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +1 -1
  6. package/dist/inheriti-client-sdk.umd.js +141 -83
  7. package/dist/node.d.ts +22 -1
  8. package/dist/node.js +1 -1
  9. package/dist/sdk-types.d.ts +906 -16
  10. package/dist/src/auth/inheriti-client-provider.d.ts +1 -1
  11. package/dist/src/elements/core-plan-material-builder.d.ts +40 -0
  12. package/dist/src/elements/elements-api-port.d.ts +116 -1
  13. package/dist/src/elements/elements-client.d.ts +104 -4
  14. package/dist/src/elements/guided-plan-creator.d.ts +47 -0
  15. package/dist/src/elements/http-elements-api-port.d.ts +18 -1
  16. package/dist/src/elements/index.d.ts +15 -1
  17. package/dist/src/elements/key-vault.d.ts +14 -6
  18. package/dist/src/elements/master-key.d.ts +58 -0
  19. package/dist/src/elements/node-plan-material-reconstructor.d.ts +1 -1
  20. package/dist/src/elements/plan-material-reconstructor.d.ts +5 -1
  21. package/dist/src/elements/plan-operation-codec.d.ts +4 -0
  22. package/dist/src/elements/plan-operations.d.ts +160 -0
  23. package/dist/src/elements/polling-shared-plan-event-listener.d.ts +29 -0
  24. package/dist/src/elements/relay-master-key-source.d.ts +38 -0
  25. package/dist/src/elements/reveal-session-operations.d.ts +13 -0
  26. package/dist/src/elements/scoped-reveal.d.ts +44 -0
  27. package/dist/src/elements/unwrap-dek.d.ts +7 -0
  28. package/dist/src/operator-auth/defaults.d.ts +9 -0
  29. package/dist/src/operator-auth/errors.d.ts +11 -0
  30. package/dist/src/operator-auth/http-operator-auth-transport.d.ts +16 -0
  31. package/dist/src/operator-auth/index.d.ts +7 -0
  32. package/dist/src/operator-auth/operator-auth-client.d.ts +35 -0
  33. package/dist/src/operator-auth/operator-session-controller.d.ts +10 -0
  34. package/dist/src/operator-auth/ports.d.ts +53 -0
  35. package/dist/src/operator-auth/types.d.ts +77 -0
  36. package/dist/test/index.js +1 -1
  37. package/docs/docs.json +18331 -0
  38. package/docs/elements-shared-mode.md +28 -0
  39. package/docs/operator-auth.md +76 -0
  40. package/docs/plan-operations.md +41 -0
  41. package/index.ts +1 -0
  42. package/node.ts +36 -3
  43. package/package.json +14 -3
@@ -1,9 +1,11 @@
1
1
  import { SDKContainer } from '@safetech/inheriti-core-sdk/vanilla';
2
2
  export { SDKContainer } from '@safetech/inheriti-core-sdk/vanilla';
3
- import { ValidEnv, AuthClientProps } 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
- import * as react_jsx_runtime from 'react/jsx-runtime';
5
+ import * as react from 'react';
6
6
  import { ReactNode } from 'react';
7
+ import { BearerTokenResolver, HttpTransport } from '@safetech/inheriti-core-sdk/node';
8
+ import { ProcessRuntimeEnvironment, ProcessReconciliationOwnership, SharedPlanEventListener, SharedPlanEventHandlers } from '@safetech/inheriti-core-sdk/shared-configuration';
7
9
 
8
10
  /**
9
11
  * Props for the `InheritiClientProvider` component.
@@ -35,7 +37,7 @@ interface InheritiClientProviderProps {
35
37
  *
36
38
  * @param props - The provider props including children, clientId, and options.
37
39
  */
38
- declare function InheritiClientProvider({ children, clientId, options }: InheritiClientProviderProps): react_jsx_runtime.JSX.Element;
40
+ declare function InheritiClientProvider({ children, clientId, options }: InheritiClientProviderProps): react.JSX.Element;
39
41
 
40
42
  /**
41
43
  * Wraps core's useClient to update the httpClient's apiUrl
@@ -56,16 +58,81 @@ declare function getAvailableEnvs(): {
56
58
  demoKeyApiUrl: string;
57
59
  };
58
60
 
61
+ /**
62
+ * Identifies which master key opens a plan.
63
+ *
64
+ * A plan's key is a property of the plan, not of the Application holding it: a bridged
65
+ * plan is never re-wrapped, so it stays sealed under the key of the context it came
66
+ * from. One host may therefore need several keys at once — its own Application key and
67
+ * a foreign organization key for each bridged plan.
68
+ */
69
+ interface MasterKeyRef {
70
+ system: 'INHERITI_BUSINESS' | 'INHERITI_ELEMENTS';
71
+ contextId: string;
72
+ }
73
+ /** Stable string form of a ref, used as the `KeyVault` key. */
74
+ declare function masterKeyRefKey(ref: MasterKeyRef): string;
75
+ /**
76
+ * Resolves the master key for a given plan's key reference.
77
+ *
78
+ * Custody says how a key came into existence; a resolver says how *this* host obtains
79
+ * it. The two are independent, so a resolver may derive one key, read another from a
80
+ * KMS, and relay a third.
81
+ */
82
+ interface MasterKeyResolver {
83
+ resolve(ref: MasterKeyRef): Promise<string | undefined>;
84
+ }
85
+ /**
86
+ * Derives which key opens a plan.
87
+ *
88
+ * A bridged plan names its source context; a locally created one is opened by the key
89
+ * of the Application holding it.
90
+ */
91
+ declare function masterKeyRefFor(material: {
92
+ tenantId?: string;
93
+ sourceReference?: {
94
+ system: string;
95
+ contextId: string;
96
+ };
97
+ }): MasterKeyRef | undefined;
98
+ /** Thrown when a plan is master key wrapped and no key resolves for its reference. */
99
+ declare class MasterKeyRequired extends Error {
100
+ readonly ref: MasterKeyRef;
101
+ constructor(ref: MasterKeyRef);
102
+ }
103
+ /**
104
+ * Resolves keys from a static map of references to sources.
105
+ *
106
+ * Sources come from the Core SDK, so a passphrase-derived key and one supplied from a
107
+ * KMS are the same to everything downstream.
108
+ */
109
+ declare class StaticMasterKeyResolver implements MasterKeyResolver {
110
+ private readonly sources;
111
+ constructor(entries?: Array<{
112
+ ref: MasterKeyRef;
113
+ source: MasterKeySource;
114
+ }>);
115
+ register(ref: MasterKeyRef, source: MasterKeySource): this;
116
+ resolve(ref: MasterKeyRef): Promise<string | undefined>;
117
+ }
118
+
119
+ /**
120
+ * Where the host keeps master keys between operations.
121
+ *
122
+ * Keyed by master key reference rather than by Application: a host may hold its own
123
+ * Application key alongside a foreign organization key for each bridged plan, and those
124
+ * are different keys that must not collide.
125
+ */
59
126
  interface KeyVault {
60
- store(applicationId: string, key: Uint8Array): Promise<void>;
61
- load(applicationId: string): Promise<Uint8Array | undefined>;
62
- remove(applicationId: string): Promise<void>;
127
+ store(ref: MasterKeyRef, key: Uint8Array): Promise<void>;
128
+ load(ref: MasterKeyRef): Promise<Uint8Array | undefined>;
129
+ remove(ref: MasterKeyRef): Promise<void>;
63
130
  }
64
131
  declare class MemoryKeyVault implements KeyVault {
65
132
  private readonly keys;
66
- store(applicationId: string, key: Uint8Array): Promise<void>;
67
- load(applicationId: string): Promise<Uint8Array | undefined>;
68
- remove(applicationId: string): Promise<void>;
133
+ store(ref: MasterKeyRef, key: Uint8Array): Promise<void>;
134
+ load(ref: MasterKeyRef): Promise<Uint8Array | undefined>;
135
+ remove(ref: MasterKeyRef): Promise<void>;
69
136
  }
70
137
 
71
138
  interface StatePort {
@@ -80,6 +147,167 @@ declare class MemoryStatePort implements StatePort {
80
147
  remove(key: string): Promise<void>;
81
148
  }
82
149
 
150
+ 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"];
151
+ type CanonicalPlanAssetType = (typeof CANONICAL_PLAN_ASSET_TYPES)[number];
152
+ declare const CANONICAL_STRUCTURED_ASSET_FIELDS: Readonly<Record<Exclude<CanonicalPlanAssetType, 'DOCUMENT' | 'IMAGE' | 'VIDEO'>, readonly string[]>>;
153
+ type CompatibleValue<T extends string> = T | {
154
+ readonly kind: 'UNKNOWN';
155
+ readonly raw: string;
156
+ };
157
+ type PlanStatus = CompatibleValue<'DRAFT' | 'ACTIVE' | 'CONFIGURED' | 'ARCHIVED'>;
158
+ type PlanGovernanceMode = CompatibleValue<'DIRECT' | 'GOVERNED'>;
159
+ type PlanParticipantRelationship = 'OWNER' | 'MERGER' | 'MODERATOR' | 'CUSTODIAN' | 'ALLOW' | 'DENY';
160
+ interface PlanAssetSummary {
161
+ count: number;
162
+ types: CompatibleValue<CanonicalPlanAssetType>[];
163
+ }
164
+ interface PlanSummary {
165
+ id: string;
166
+ name: string;
167
+ description?: string;
168
+ status: PlanStatus;
169
+ createdAt: string;
170
+ configuredAt?: string;
171
+ assetSummary: PlanAssetSummary;
172
+ governance: {
173
+ mode: PlanGovernanceMode;
174
+ minimumApprovals: number;
175
+ };
176
+ participantSummary: {
177
+ owners: number;
178
+ mergers: number;
179
+ moderators: number;
180
+ };
181
+ }
182
+ interface PlanPage {
183
+ items: PlanSummary[];
184
+ nextCursor: string | null;
185
+ }
186
+ interface ListPlansInput {
187
+ cursor?: string;
188
+ limit?: number;
189
+ status?: readonly string[];
190
+ assetType?: CanonicalPlanAssetType;
191
+ namePrefix?: string;
192
+ }
193
+ interface PlanDetail extends PlanSummary {
194
+ assets: Array<{
195
+ id: string;
196
+ /** Developer-defined stable address. Older plans may not have one and fall back to `id`. */
197
+ code?: string;
198
+ type: CompatibleValue<CanonicalPlanAssetType>;
199
+ name: string;
200
+ isBinary: boolean;
201
+ fieldNames: string[];
202
+ matchOrigins?: string[];
203
+ }>;
204
+ participants: Array<{
205
+ id: string;
206
+ displayName: string;
207
+ relationships: CompatibleValue<PlanParticipantRelationship>[];
208
+ lifecycle: CompatibleValue<'ACTIVE' | 'REVOKED'>;
209
+ }>;
210
+ revealPolicy: {
211
+ masterKeyRelease: CompatibleValue<'REQUIRED'>;
212
+ custodian: CompatibleValue<'FORCE' | 'BYPASS'>;
213
+ };
214
+ source: {
215
+ kind: 'NATIVE';
216
+ } | {
217
+ kind: 'BRIDGED';
218
+ system: CompatibleValue<'INHERITI_BUSINESS'>;
219
+ status: CompatibleValue<'IN_SYNC' | 'RECONCILIATION_REQUIRED'>;
220
+ } | {
221
+ kind: 'UNKNOWN';
222
+ raw: string;
223
+ };
224
+ }
225
+ interface IntegrationPlanAssetDeclaration {
226
+ clientAssetRef: string;
227
+ type: CanonicalPlanAssetType;
228
+ name: string;
229
+ fieldNames?: readonly string[];
230
+ isBinary: boolean;
231
+ fileName?: string;
232
+ mimeType?: string;
233
+ size?: number;
234
+ }
235
+ interface NativePlanParticipant {
236
+ clientParticipantRef: string;
237
+ /** Routing only. It is not identity or evidence of a SafeID/SafeKey account. */
238
+ routingEmail: string;
239
+ displayName: string;
240
+ relationships: readonly PlanParticipantRelationship[];
241
+ }
242
+ interface StartPlanCreationInput {
243
+ idempotencyKey: string;
244
+ name: string;
245
+ description?: string;
246
+ assets: readonly IntegrationPlanAssetDeclaration[];
247
+ participants: readonly NativePlanParticipant[];
248
+ policy?: {
249
+ governance?: 'DIRECT' | 'GOVERNED';
250
+ minimumApprovals?: number;
251
+ masterKeyRelease?: 'REQUIRED';
252
+ custodian?: 'FORCE' | 'BYPASS';
253
+ };
254
+ }
255
+ declare const PLAN_CREATION_SERVER_STAGES: readonly ["VALIDATED", "PLAN_CREATED", "PARTICIPANTS_PERSISTED", "STORAGE_PREPARED", "AWAITING_ENCRYPTED_MATERIAL", "VALIDATOR_SHARES_DISTRIBUTED", "CONFIGURED", "COMPLETED"];
256
+ type PlanCreationServerStage = (typeof PLAN_CREATION_SERVER_STAGES)[number];
257
+ type PlanCreationOutcome = 'IN_PROGRESS' | 'COMPLETED' | 'CANCELED' | 'FAILED_RETRYABLE' | 'FAILED_TERMINAL' | 'RECONCILIATION_REQUIRED';
258
+ interface PlanCreationProgress {
259
+ operationId: string;
260
+ stage: CompatibleValue<PlanCreationServerStage>;
261
+ outcome: CompatibleValue<PlanCreationOutcome>;
262
+ planId?: string;
263
+ lastErrorCode?: string;
264
+ participants?: Array<{
265
+ clientParticipantRef: string;
266
+ planParticipantId: string;
267
+ relationships: PlanParticipantRelationship[];
268
+ }>;
269
+ }
270
+ interface EncryptedPlanMaterial {
271
+ protectionProtocol?: 'SSDP_PLUS_V1' | 'SSDP_PLUS_V2';
272
+ validatorShares?: readonly EncryptedPlanShard[];
273
+ dataShards: readonly EncryptedPlanShard[];
274
+ backupShards: readonly EncryptedPlanShard[];
275
+ encryptedKey?: string;
276
+ assetsMetadata?: Readonly<Record<string, {
277
+ type: CanonicalPlanAssetType;
278
+ meta: {
279
+ name: string;
280
+ notes?: string;
281
+ };
282
+ }>>;
283
+ custodianShard?: {
284
+ keyShard: EncryptedPlanShard;
285
+ dataShard: EncryptedPlanShard;
286
+ };
287
+ operation?: 'DRAFT' | 'FINALIZE';
288
+ }
289
+ interface EncryptedPlanShard {
290
+ id: string;
291
+ data?: string;
292
+ }
293
+ type GuidedCreateLocalStage = 'VALIDATING_ASSETS' | 'ENCRYPTING' | 'GENERATING_SHARES';
294
+ interface GuidedCreateCheckpoint {
295
+ idempotencyKey: string;
296
+ operationId: string;
297
+ declarationHash: string;
298
+ serverStage: CompatibleValue<PlanCreationServerStage>;
299
+ }
300
+ declare class InvalidPlanDeclaration extends Error {
301
+ readonly code: string;
302
+ constructor(code: string);
303
+ }
304
+ declare class InvalidPlanMaterial extends Error {
305
+ readonly code: string;
306
+ constructor(code: string);
307
+ }
308
+ declare function validatePlanCreationMaterial(material: EncryptedPlanMaterial): void;
309
+ declare function validatePlanCreationInput(input: StartPlanCreationInput): void;
310
+
83
311
  interface CollectedPlanMaterial {
84
312
  planId: string;
85
313
  mergeThreshold: number;
@@ -91,8 +319,36 @@ interface CollectedPlanMaterial {
91
319
  data: string;
92
320
  }>;
93
321
  verifiedStorageLayerTypes: string[];
322
+ /** True when `planKey` is still sealed under a master key and must be unwrapped. */
323
+ masterKeyWrapped: boolean;
324
+ /** The tenant holding the plan. With no source reference, this names the key. */
325
+ tenantId?: string;
326
+ /** Present when the plan came from another system, whose key still opens it. */
327
+ sourceReference?: {
328
+ system: string;
329
+ planId: string;
330
+ contextId: string;
331
+ };
332
+ }
333
+ /** Metadata naming the key that opens a plan, without collecting anything. */
334
+ interface PlanKeyReference {
335
+ planId: string;
336
+ masterKeyWrapped: boolean;
337
+ tenantId: string;
338
+ sourceReference?: {
339
+ system: string;
340
+ planId: string;
341
+ contextId: string;
342
+ };
94
343
  }
95
344
  interface ElementsApiPort {
345
+ listPlans(input?: ListPlansInput): Promise<PlanPage>;
346
+ getPlan(planId: string): Promise<PlanDetail>;
347
+ startPlanCreation(input: StartPlanCreationInput): Promise<PlanCreationProgress>;
348
+ getPlanCreation(operationId: string): Promise<PlanCreationProgress>;
349
+ supplyPlanCreationMaterial(operationId: string, material: EncryptedPlanMaterial): Promise<PlanCreationProgress>;
350
+ cancelPlanCreation(operationId: string): Promise<PlanCreationProgress>;
351
+ planKeyReference(planId: string): Promise<PlanKeyReference>;
96
352
  collectPlanMaterial(planId: string, stepUp?: StepUpReadContext): Promise<CollectedPlanMaterial>;
97
353
  initializeGovernedReveal(planId: string, stepUp?: StepUpReadContext): Promise<GovernedRevealSession>;
98
354
  getGovernedReveal(processId: string, stepUp?: StepUpReadContext): Promise<GovernedRevealState>;
@@ -102,6 +358,15 @@ interface ElementsApiPort {
102
358
  markGovernedSharesReconstructed(processId: string): Promise<void>;
103
359
  markGovernedDataRevealed(processId: string): Promise<void>;
104
360
  closeGovernedReveal(processId: string): Promise<void>;
361
+ startReveal(planId: string, input: StartRevealInput): Promise<RevealSession>;
362
+ getReveal(revealId: string): Promise<RevealSession>;
363
+ releaseRevealMaterial(revealId: string, materialVersion: string): Promise<unknown>;
364
+ reportRevealReconstruction(revealId: string, input: RevealReconstructionInput): Promise<RevealSession>;
365
+ closeReveal(revealId: string, reason: RevealCloseReason): Promise<RevealSession>;
366
+ authorizeRevealAction(revealId: string, input: AuthorizeRevealActionInput): Promise<RevealAction>;
367
+ reportRevealActionOutcome(revealId: string, actionId: string, input: ReportRevealActionOutcomeInput): Promise<RevealAction>;
368
+ getCustodianShare(processId: string, stepUp?: StepUpReadContext): Promise<CustodianShareResult>;
369
+ releaseCustodianShare(processId: string): Promise<void>;
105
370
  exportPlanBridge(planId: string, input: ExportPlanBridgeInput): Promise<PlanBridgeEnvelope>;
106
371
  importPlanBridge(envelope: PlanBridgeEnvelope): Promise<{
107
372
  planId: string;
@@ -119,7 +384,7 @@ interface ExportPlanBridgeInput {
119
384
  }
120
385
  interface PlanRevealProfile {
121
386
  governance: 'KEEP' | 'BYPASS';
122
- masterKeyRelease: 'REQUIRED' | 'BYPASS';
387
+ masterKeyRelease: 'REQUIRED';
123
388
  custodian: 'BYPASS' | 'FORCE';
124
389
  }
125
390
  interface PlanBridgeEnvelope {
@@ -195,6 +460,14 @@ interface GovernedRevealSession {
195
460
  planId: string;
196
461
  mergeThreshold: number;
197
462
  status?: string;
463
+ /** Same key signalling the direct collection route returns, for the governed path. */
464
+ masterKeyWrapped: boolean;
465
+ tenantId?: string;
466
+ sourceReference?: {
467
+ system: string;
468
+ planId: string;
469
+ contextId: string;
470
+ };
198
471
  }
199
472
  interface GovernedRevealState {
200
473
  id: string;
@@ -219,26 +492,196 @@ interface GovernedSharesMaterial {
219
492
  keyShards: GovernedShare[];
220
493
  dek: string;
221
494
  }
495
+ type RevealMode = 'DIRECT' | 'GOVERNED';
496
+ type RevealStage = 'STARTING' | 'WAITING_FOR_PARTICIPANTS' | 'AUTHORIZED' | 'MATERIAL_AUTHORIZED' | 'MATERIAL_RELEASED' | 'RECONSTRUCTED' | 'ACTIONS_OPEN' | 'CLOSING' | 'CLOSED' | 'DENIED' | 'PARTICIPANT_REVOKED' | 'RECONCILIATION_REQUIRED' | 'EXPIRED' | 'CANCELED' | 'FAILED';
497
+ type RevealCloseReason = 'COMPLETED' | 'CANCELED' | 'ERROR';
498
+ type RevealActionType = 'VIEW_FIELD' | 'COPY_FIELD' | 'EXPORT_ASSET' | 'AUTOFILL_FIELD' | 'INSERT_FIELD';
499
+ type RevealActionOutcome = 'SUCCEEDED' | 'FAILED' | 'CANCELED';
500
+ interface StartRevealInput {
501
+ mode: RevealMode;
502
+ idempotencyKey: string;
503
+ }
504
+ interface RevealReconstructionInput {
505
+ status: 'SUCCEEDED' | 'FAILED';
506
+ errorCode?: string;
507
+ }
508
+ interface RevealSession {
509
+ id: string;
510
+ idempotencyKey: string;
511
+ applicationId: string;
512
+ environment: 'TEST' | 'LIVE';
513
+ planId: string;
514
+ mode: RevealMode;
515
+ stage: RevealStage;
516
+ materialVersion?: string;
517
+ expiresAt: string;
518
+ createdAt: string;
519
+ updatedAt: string;
520
+ participantDecisions?: unknown;
521
+ /** Server-resolved governed progress. Omitted for direct reveals or unavailable source progress. */
522
+ approvedModerators?: number;
523
+ requiredModerators?: number;
524
+ closedReason?: RevealCloseReason;
525
+ }
526
+ interface AuthorizeRevealActionInput {
527
+ idempotencyKey: string;
528
+ assetId: string;
529
+ fieldName?: string;
530
+ action: RevealActionType;
531
+ origin?: string;
532
+ }
533
+ interface ReportRevealActionOutcomeInput {
534
+ idempotencyKey: string;
535
+ outcome: RevealActionOutcome;
536
+ reportedAt: string;
537
+ errorCode?: string;
538
+ }
539
+ interface RevealAction {
540
+ id: string;
541
+ revealId: string;
542
+ assetId: string;
543
+ fieldName?: string;
544
+ action: RevealActionType;
545
+ status: 'AUTHORIZED' | RevealActionOutcome;
546
+ origin?: string;
547
+ outcome?: RevealActionOutcome;
548
+ errorCode?: string;
549
+ createdAt?: string;
550
+ updatedAt?: string;
551
+ }
552
+ type CustodianShareResult = {
553
+ status: 'PENDING';
554
+ } | {
555
+ id: string;
556
+ shares: string[];
557
+ planId: string;
558
+ isMergeAuthority: boolean;
559
+ };
560
+ declare class RevealActionsNotOpen extends Error {
561
+ readonly stage: string;
562
+ readonly code = "reveal_actions_not_open";
563
+ constructor(stage: string);
564
+ }
222
565
  declare class ElementsApiPortRequired extends Error {
223
566
  constructor();
224
567
  }
225
568
 
226
569
  interface PlanMaterialReconstructor {
227
- reconstruct(material: CollectedPlanMaterial): Promise<Uint8Array>;
570
+ /**
571
+ * `masterKeyHex` is required when the material reports `masterKeyWrapped`: the plan
572
+ * key comes back sealed and the platform cannot open it.
573
+ */
574
+ reconstruct(material: CollectedPlanMaterial, masterKeyHex?: string): Promise<Uint8Array>;
228
575
  }
229
576
  declare class PlanMaterialReconstructorRequired extends Error {
230
577
  constructor();
231
578
  }
232
579
 
580
+ interface GuidedCreateCheckpointStore {
581
+ load(operationId: string): Promise<GuidedCreateCheckpoint | undefined>;
582
+ save(checkpoint: GuidedCreateCheckpoint): Promise<void>;
583
+ remove(operationId: string): Promise<void>;
584
+ }
585
+ interface PlanMaterialBuilder<TSecrets, TEncrypted = unknown> {
586
+ encrypt(input: {
587
+ planId: string;
588
+ declaration: StartPlanCreationInput;
589
+ secrets: TSecrets;
590
+ signal?: AbortSignal;
591
+ }): Promise<TEncrypted>;
592
+ generateShares(input: {
593
+ planId: string;
594
+ declaration: StartPlanCreationInput;
595
+ encrypted: TEncrypted;
596
+ signal?: AbortSignal;
597
+ }): Promise<EncryptedPlanMaterial>;
598
+ }
599
+ interface GuidedCreateOptions {
600
+ signal?: AbortSignal;
601
+ onProgress?: (stage: GuidedCreateLocalStage | PlanCreationProgress['stage']) => void;
602
+ }
603
+ /** Process-lifetime checkpoints. A host that must survive a restart supplies a durable store. */
604
+ declare class MemoryGuidedCreateCheckpointStore implements GuidedCreateCheckpointStore {
605
+ private readonly checkpoints;
606
+ load(operationId: string): Promise<GuidedCreateCheckpoint | undefined>;
607
+ save(checkpoint: GuidedCreateCheckpoint): Promise<void>;
608
+ remove(operationId: string): Promise<void>;
609
+ }
610
+ /** Resumable orchestration. Only its non-secret checkpoint may survive process restart. */
611
+ declare class GuidedPlanCreator {
612
+ private readonly api;
613
+ private readonly checkpoints;
614
+ constructor(api: ElementsApiPort, checkpoints: GuidedCreateCheckpointStore);
615
+ start(input: StartPlanCreationInput, options?: GuidedCreateOptions): Promise<PlanCreationProgress>;
616
+ status(operationId: string): Promise<PlanCreationProgress>;
617
+ resume<TSecrets, TEncrypted>(operationId: string, declaration: StartPlanCreationInput, secrets: TSecrets, builder: PlanMaterialBuilder<TSecrets, TEncrypted>, options?: GuidedCreateOptions): Promise<PlanCreationProgress>;
618
+ cancel(operationId: string): Promise<PlanCreationProgress>;
619
+ private saveCheckpoint;
620
+ }
621
+ declare class GuidedCreateRecoveryError extends Error {
622
+ readonly code: string;
623
+ constructor(code: string);
624
+ }
625
+
626
+ type AssetFieldSelector = string | {
627
+ asset: string;
628
+ field: string;
629
+ };
630
+ interface RevealFieldOptions {
631
+ action?: Exclude<RevealActionType, 'EXPORT_ASSET'>;
632
+ origin?: string;
633
+ idempotencyKey?: string;
634
+ }
635
+ interface OpenRevealOptions {
636
+ mode?: RevealMode;
637
+ idempotencyKey?: string;
638
+ signal?: AbortSignal;
639
+ pollIntervalMs?: number;
640
+ onSession?: (session: RevealSession) => void;
641
+ }
642
+ interface RevealHandle {
643
+ readonly session: RevealSession;
644
+ readonly material: Uint8Array;
645
+ readonly closed: boolean;
646
+ field<TValue = unknown>(selector: AssetFieldSelector, options?: RevealFieldOptions): Promise<TValue>;
647
+ close(reason?: RevealCloseReason): Promise<void>;
648
+ [Symbol.asyncDispose](): Promise<void>;
649
+ }
650
+ declare class RevealHandleClosed extends Error {
651
+ readonly code = "reveal_handle_closed";
652
+ constructor();
653
+ }
654
+ declare class RevealFieldAccessError extends Error {
655
+ readonly code: 'asset_selector_invalid' | 'asset_not_found' | 'asset_field_not_found' | 'action_not_allowed' | 'asset_decoder_required' | 'asset_value_invalid';
656
+ constructor(code: 'asset_selector_invalid' | 'asset_not_found' | 'asset_field_not_found' | 'action_not_allowed' | 'asset_decoder_required' | 'asset_value_invalid');
657
+ }
658
+ declare function parseAssetFieldSelector(selector: AssetFieldSelector): {
659
+ asset: string;
660
+ field: string;
661
+ };
662
+
663
+ interface DecodedPlanAsset {
664
+ id: string;
665
+ data: Uint8Array;
666
+ }
667
+ type PlanAssetContainerDecoder = (material: Uint8Array) => readonly DecodedPlanAsset[];
233
668
  interface ElementsClientOptions {
234
669
  coreSdk: SDKContainer;
235
670
  keyVault?: KeyVault;
236
671
  state?: StatePort;
237
672
  api?: ElementsApiPort;
238
673
  reconstructor?: PlanMaterialReconstructor;
674
+ /**
675
+ * Resolves master keys per plan. A host may need several: its own Application key
676
+ * and a foreign organization key for each bridged plan it opens.
677
+ */
678
+ masterKeys: MasterKeyResolver;
679
+ /** The Application this client acts for; needed to wrap keys of plans it creates. */
680
+ applicationId: string;
681
+ assetDecoder: PlanAssetContainerDecoder;
239
682
  }
240
683
  declare class ElementsClient {
241
- private readonly coreSdk;
684
+ readonly coreSdk: SDKContainer;
242
685
  readonly keyVault: KeyVault;
243
686
  readonly state: StatePort;
244
687
  constructor(coreSdk: SDKContainer, options?: {
@@ -246,15 +689,96 @@ declare class ElementsClient {
246
689
  state?: StatePort;
247
690
  api?: ElementsApiPort;
248
691
  reconstructor?: PlanMaterialReconstructor;
692
+ masterKeys?: MasterKeyResolver;
693
+ applicationId?: string;
694
+ assetDecoder?: PlanAssetContainerDecoder;
249
695
  });
250
696
  private readonly api?;
251
697
  private readonly reconstructor?;
252
- createPlan<TInput, TResult>(input: TInput): Promise<TResult>;
253
- configurePlan<TInput, TResult>(input: TInput): Promise<TResult>;
698
+ private readonly masterKeys?;
699
+ private readonly applicationId?;
700
+ readonly assetDecoder?: PlanAssetContainerDecoder;
701
+ listPlans(input?: ListPlansInput): Promise<PlanPage>;
702
+ getPlan(planId: string): Promise<PlanDetail>;
703
+ startPlanCreation(input: StartPlanCreationInput): Promise<PlanCreationProgress>;
704
+ getPlanCreation(operationId: string): Promise<PlanCreationProgress>;
705
+ supplyPlanCreationMaterial(operationId: string, material: EncryptedPlanMaterial): Promise<PlanCreationProgress>;
706
+ cancelPlanCreation(operationId: string): Promise<PlanCreationProgress>;
707
+ /**
708
+ * The resumable creation flow over this client's own port.
709
+ *
710
+ * The four calls above are the raw stages; a host that wants recovery, progress and the
711
+ * encrypt/split step in the right order drives them through here instead. Checkpoints
712
+ * default to process memory because they only need to outlive the operation, not the host.
713
+ */
714
+ guidedPlanCreator(checkpoints?: GuidedCreateCheckpointStore): GuidedPlanCreator;
715
+ /**
716
+ * Creates the plan definition from a declaration of what it will protect.
717
+ *
718
+ * Elements takes a `PlanAssetDeclaration` rather than the assets themselves: creation
719
+ * persists metadata only, and a host that has not yet collected any secret should be
720
+ * able to reach this point. Where Business keeps the secrets in browser storage between
721
+ * its create and configure pages, an Elements host holds the declaration and supplies
722
+ * the secrets to `configurePlan()` — how it carries them across is its own decision.
723
+ */
724
+ createPlan<TInput extends {
725
+ assets: PlanAssetDeclaration;
726
+ }, TResult>(input: TInput): Promise<TResult>;
727
+ /**
728
+ * Configures a plan under the Application's required master key. The key is resolved
729
+ * through the configured custody source; it is never an operation parameter.
730
+ */
731
+ configurePlan<TInput extends object, TResult>(input: TInput): Promise<TResult>;
732
+ /** Resolves the Application's required master key without exposing it as an operation argument. */
733
+ applicationMasterKey(): Promise<string>;
734
+ /**
735
+ * Resolves the key that opens a plan before anything is collected.
736
+ *
737
+ * Ordering matters: collecting releases the custodian share and advances the reveal,
738
+ * so discovering afterwards that the key is unavailable spends a one-shot release for
739
+ * nothing. Resolving first also keeps a single SafeKey interaction — the relay — ahead
740
+ * of the custodian's, instead of interleaving two device round trips.
741
+ */
742
+ prepareReveal(planId: string): Promise<{
743
+ masterKeyWrapped: boolean;
744
+ masterKeyHex?: string;
745
+ }>;
746
+ /**
747
+ * The whole direct reveal in the order it must happen: hold the key, then collect,
748
+ * then reconstruct.
749
+ */
750
+ revealPlan(planId: string, stepUp?: StepUpReadContext): Promise<Uint8Array>;
254
751
  collectPlanMaterial(planId: string, stepUp?: StepUpReadContext): Promise<CollectedPlanMaterial>;
255
752
  reconstructPlanMaterial(material: CollectedPlanMaterial): Promise<Uint8Array>;
753
+ /**
754
+ * Resolves the key that opens this plan, caching it in the vault.
755
+ *
756
+ * Fails with the reference named rather than letting an unwrap collapse into an
757
+ * opaque decrypt error: "you are missing the key for Business organization X" is the
758
+ * diagnostic that matters.
759
+ */
760
+ resolveMasterKey(material: {
761
+ planId: string;
762
+ masterKeyWrapped?: boolean;
763
+ tenantId?: string;
764
+ sourceReference?: {
765
+ system: string;
766
+ contextId: string;
767
+ };
768
+ }): Promise<string | undefined>;
256
769
  initializeGovernedReveal(planId: string, stepUp?: StepUpReadContext): Promise<GovernedRevealSession>;
257
770
  getGovernedReveal(processId: string, stepUp?: StepUpReadContext): Promise<GovernedRevealState>;
771
+ startReveal(planId: string, input: StartRevealInput): Promise<RevealSession>;
772
+ getReveal(revealId: string): Promise<RevealSession>;
773
+ openReveal(planId: string, options?: OpenRevealOptions): Promise<RevealHandle>;
774
+ withReveal<TResult>(planId: string, options: OpenRevealOptions, work: (reveal: RevealHandle) => Promise<TResult>): Promise<TResult>;
775
+ releaseRevealMaterial(revealId: string, materialVersion: string): Promise<unknown>;
776
+ reportRevealReconstruction(revealId: string, input: RevealReconstructionInput): Promise<RevealSession>;
777
+ closeReveal(revealId: string, reason: RevealCloseReason): Promise<RevealSession>;
778
+ authorizeRevealAction(revealId: string, input: AuthorizeRevealActionInput): Promise<RevealAction>;
779
+ reportRevealActionOutcome(revealId: string, actionId: string, input: ReportRevealActionOutcomeInput): Promise<RevealAction>;
780
+ getCustodianShare(processId: string, stepUp?: StepUpReadContext): Promise<CustodianShareResult>;
781
+ releaseCustodianShare(processId: string): Promise<void>;
258
782
  exportPlanBridge(planId: string, input: ExportPlanBridgeInput): Promise<PlanBridgeEnvelope>;
259
783
  importPlanBridge(envelope: PlanBridgeEnvelope): Promise<{
260
784
  planId: string;
@@ -265,5 +789,371 @@ declare class ElementsClient {
265
789
  }
266
790
  declare function createElementsClient(options: ElementsClientOptions): ElementsClient;
267
791
 
268
- export { ElementsApiPortRequired, ElementsClient, InheritiClientProvider, MemoryKeyVault, MemoryStatePort, PlanMaterialReconstructorRequired, createElementsClient, getAvailableEnvs, useClient };
269
- export type { CollectedPlanMaterial, ElementsApiPort, ElementsClientOptions, ExportPlanBridgeInput, GovernedRevealSession, GovernedRevealState, GovernedShare, GovernedSharesMaterial, GovernedValidatorMaterial, InheritiClientProviderProps, KeyVault, PlanBridgeEnvelope, PlanMaterialReconstructor, PlanRevealProfile, StatePort, StepUpReadContext };
792
+ declare class ElementsApiRequestFailed extends Error {
793
+ readonly status: number;
794
+ readonly code?: string | undefined;
795
+ readonly detail?: string | undefined;
796
+ constructor(status: number, code?: string | undefined, detail?: string | undefined);
797
+ get stepUpRequestId(): string | undefined;
798
+ }
799
+ declare class HttpElementsApiPort implements ElementsApiPort {
800
+ private readonly apiUrl;
801
+ private readonly environment;
802
+ private readonly getBearerToken;
803
+ private readonly transport;
804
+ constructor(apiUrl: string, environment: 'TEST' | 'LIVE', getBearerToken: BearerTokenResolver, transport: HttpTransport);
805
+ listPlans(input?: ListPlansInput): Promise<PlanPage>;
806
+ getPlan(planId: string): Promise<PlanDetail>;
807
+ startPlanCreation(input: StartPlanCreationInput): Promise<PlanCreationProgress>;
808
+ getPlanCreation(operationId: string): Promise<PlanCreationProgress>;
809
+ supplyPlanCreationMaterial(operationId: string, material: EncryptedPlanMaterial): Promise<PlanCreationProgress>;
810
+ cancelPlanCreation(operationId: string): Promise<PlanCreationProgress>;
811
+ planKeyReference(planId: string): Promise<PlanKeyReference>;
812
+ collectPlanMaterial(planId: string, stepUp?: StepUpReadContext): Promise<CollectedPlanMaterial>;
813
+ initializeGovernedReveal(planId: string, stepUp?: StepUpReadContext): Promise<GovernedRevealSession>;
814
+ getGovernedReveal(processId: string, stepUp?: StepUpReadContext): Promise<GovernedRevealState>;
815
+ collectGovernedValidatorShares(processId: string, stepUp?: StepUpReadContext): Promise<GovernedValidatorMaterial>;
816
+ collectGovernedShares(processId: string, stepUp?: StepUpReadContext): Promise<GovernedSharesMaterial>;
817
+ markGovernedSharesCollected(processId: string): Promise<void>;
818
+ markGovernedSharesReconstructed(processId: string): Promise<void>;
819
+ markGovernedDataRevealed(processId: string): Promise<void>;
820
+ closeGovernedReveal(processId: string): Promise<void>;
821
+ startReveal(planId: string, input: StartRevealInput): Promise<RevealSession>;
822
+ getReveal(revealId: string): Promise<RevealSession>;
823
+ releaseRevealMaterial(revealId: string, materialVersion: string): Promise<unknown>;
824
+ reportRevealReconstruction(revealId: string, input: RevealReconstructionInput): Promise<RevealSession>;
825
+ closeReveal(revealId: string, reason: RevealCloseReason): Promise<RevealSession>;
826
+ authorizeRevealAction(revealId: string, input: AuthorizeRevealActionInput): Promise<RevealAction>;
827
+ reportRevealActionOutcome(revealId: string, actionId: string, input: ReportRevealActionOutcomeInput): Promise<RevealAction>;
828
+ getCustodianShare(processId: string, stepUp?: StepUpReadContext): Promise<CustodianShareResult>;
829
+ releaseCustodianShare(processId: string): Promise<void>;
830
+ exportPlanBridge(planId: string, input: ExportPlanBridgeInput): Promise<PlanBridgeEnvelope>;
831
+ importPlanBridge(envelope: PlanBridgeEnvelope): Promise<{
832
+ planId: string;
833
+ }>;
834
+ private request;
835
+ private requestWithoutResult;
836
+ }
837
+
838
+ /**
839
+ * Opens a plan key that was sealed under a master key.
840
+ *
841
+ * The wrap is AES-GCM with a 12-byte prefixed IV, matching the Core SDK's
842
+ * `wrapKeyWithMasterKeyThenRsa`; the platform only ever removed the outer RSA layer.
843
+ */
844
+ declare function unwrapDekWithMasterKey(wrappedDekBase64: string, masterKeyHex?: string): Promise<string>;
845
+
846
+ interface MasterKeyRelayPort {
847
+ startRelaySession(clientPublicKey: string): Promise<{
848
+ sessionId: string;
849
+ expiresAt: string | Date;
850
+ }>;
851
+ readRelaySession(sessionId: string): Promise<{
852
+ status: 'PENDING' | 'DELIVERED' | 'EXPIRED';
853
+ sealedMasterKey?: string;
854
+ }>;
855
+ }
856
+ declare class MasterKeyRelayTimedOut extends Error {
857
+ readonly sessionId: string;
858
+ constructor(sessionId: string);
859
+ }
860
+ declare class MasterKeyRelayExpired extends Error {
861
+ readonly sessionId: string;
862
+ constructor(sessionId: string);
863
+ }
864
+ interface RelayMasterKeySourceOptions {
865
+ api: MasterKeyRelayPort;
866
+ /** How long to wait for the device before giving up. Defaults to the session lifetime. */
867
+ timeoutMs?: number;
868
+ pollIntervalMs?: number;
869
+ sleep?: (ms: number) => Promise<void>;
870
+ }
871
+ /**
872
+ * Obtains the master key from the device holding it.
873
+ *
874
+ * Elements has no websocket layer, so the host polls. The key is sealed to an ephemeral
875
+ * public key generated here and never leaves this process in the clear: the private half
876
+ * is not persisted, so a relayed key cannot be replayed from stored state.
877
+ */
878
+ declare class RelayMasterKeySource implements MasterKeySource {
879
+ private readonly options;
880
+ constructor(options: RelayMasterKeySourceOptions);
881
+ resolve(): Promise<string>;
882
+ }
883
+
884
+ /** Elements adapter for Core's transport-neutral event port. Scheduling remains owned by Core's mature loop. */
885
+ declare class PollingSharedPlanEventListener implements SharedPlanEventListener {
886
+ private readonly api;
887
+ private readonly subscriptions;
888
+ private readonly loop;
889
+ constructor(api: ElementsApiPort, environment?: ProcessRuntimeEnvironment, ownership?: ProcessReconciliationOwnership, random?: () => number);
890
+ refreshConnection(): void;
891
+ subscribe(processId: string, handlers: SharedPlanEventHandlers): void;
892
+ unsubscribe(processId: string): void;
893
+ }
894
+ /** Cross-host runtime: browsers regain work on online/visibility events; Node uses timer-only recovery. */
895
+ declare class HostProcessRuntimeEnvironment implements ProcessRuntimeEnvironment {
896
+ visibility(): 'visible' | 'hidden';
897
+ isOnline(): boolean;
898
+ now(): number;
899
+ schedule(callback: () => void, delayMs: number): () => void;
900
+ onRecovery(callback: () => void): () => void;
901
+ }
902
+ /** One host process owns its own polling; Core's loop still enforces one active lease per subscription. */
903
+ declare class LocalProcessReconciliationOwnership implements ProcessReconciliationOwnership {
904
+ join(_processId: string, handlers: Parameters<ProcessReconciliationOwnership['join']>[1]): {
905
+ isOwner: () => boolean;
906
+ requestReconciliation: () => void;
907
+ publishReconciled: () => undefined;
908
+ leave: () => void;
909
+ };
910
+ }
911
+
912
+ interface CorePlanSecrets {
913
+ assets: DataAsset[];
914
+ /** Number of non-custodian share destinations. */
915
+ totalShares: number;
916
+ threshold: number;
917
+ withCustodian?: boolean;
918
+ }
919
+ interface PreparedCorePlanMaterial {
920
+ data: Uint8Array;
921
+ assets: DataAsset[];
922
+ totalShares: number;
923
+ threshold: number;
924
+ withCustodian: boolean;
925
+ masterKey: string;
926
+ }
927
+ /** Uses Core's registered SSDP+ generator and production share sealer as one guided-create adapter. */
928
+ declare class CorePlanMaterialBuilder implements PlanMaterialBuilder<CorePlanSecrets, PreparedCorePlanMaterial> {
929
+ private readonly masterKeySource;
930
+ private readonly generator;
931
+ private readonly sealer;
932
+ constructor(coreSdk: SDKContainer, masterKeySource: MasterKeySource);
933
+ encrypt(input: {
934
+ planId: string;
935
+ declaration: StartPlanCreationInput;
936
+ secrets: CorePlanSecrets;
937
+ signal?: AbortSignal;
938
+ }): Promise<PreparedCorePlanMaterial>;
939
+ generateShares(input: {
940
+ planId: string;
941
+ declaration: StartPlanCreationInput;
942
+ encrypted: PreparedCorePlanMaterial;
943
+ signal?: AbortSignal;
944
+ }): Promise<EncryptedPlanMaterial>;
945
+ private sealCustodianPair;
946
+ }
947
+
948
+ type ElementsEnvironment = 'TEST' | 'LIVE';
949
+ interface OidcDiscoveryDocument {
950
+ issuer: string;
951
+ authorizationEndpoint: string;
952
+ tokenEndpoint: string;
953
+ deviceAuthorizationEndpoint?: string;
954
+ endSessionEndpoint?: string;
955
+ revocationEndpoint?: string;
956
+ }
957
+ interface OperatorAuthConfiguration {
958
+ issuer: string;
959
+ clientId: string;
960
+ audience: string;
961
+ environment: ElementsEnvironment;
962
+ redirectUri: string;
963
+ scopes: readonly string[];
964
+ }
965
+ interface OAuthTokenResponse {
966
+ accessToken: string;
967
+ refreshToken?: string;
968
+ idToken?: string;
969
+ tokenType: string;
970
+ expiresInSeconds: number;
971
+ refreshExpiresInSeconds?: number;
972
+ scope?: string;
973
+ }
974
+ interface ValidatedOperatorToken {
975
+ issuer: string;
976
+ audience: string | readonly string[];
977
+ authorizedParty: string;
978
+ environment: ElementsEnvironment;
979
+ subject: string;
980
+ sessionId: string;
981
+ tokenId: string;
982
+ scopes: readonly string[];
983
+ nonce?: string;
984
+ }
985
+ interface OperatorSession {
986
+ accessToken: string;
987
+ refreshToken?: string;
988
+ idToken?: string;
989
+ tokenType: 'Bearer';
990
+ expiresAt: number;
991
+ refreshExpiresAt?: number;
992
+ principal: ValidatedOperatorToken;
993
+ }
994
+ interface AuthorizationTransaction {
995
+ kind: 'authorization-code';
996
+ state: string;
997
+ nonce: string;
998
+ codeVerifier: string;
999
+ redirectUri: string;
1000
+ expiresAt: number;
1001
+ }
1002
+ interface DeviceAuthorization {
1003
+ deviceCode: string;
1004
+ userCode: string;
1005
+ verificationUri: string;
1006
+ verificationUriComplete?: string;
1007
+ expiresInSeconds: number;
1008
+ intervalSeconds?: number;
1009
+ }
1010
+ interface DeviceTransaction extends DeviceAuthorization {
1011
+ kind: 'device-code';
1012
+ expiresAt: number;
1013
+ nextPollAt: number;
1014
+ consumed: boolean;
1015
+ }
1016
+ type OAuthTransaction = AuthorizationTransaction | DeviceTransaction;
1017
+ interface OperatorSessionSummary {
1018
+ id: string;
1019
+ createdAt: string;
1020
+ lastSeenAt?: string;
1021
+ current: boolean;
1022
+ clientId: string;
1023
+ environment: ElementsEnvironment;
1024
+ }
1025
+
1026
+ interface OperatorAuthTransport {
1027
+ discover(issuer: string): Promise<OidcDiscoveryDocument>;
1028
+ exchangeAuthorizationCode(input: {
1029
+ tokenEndpoint: string;
1030
+ clientId: string;
1031
+ code: string;
1032
+ codeVerifier: string;
1033
+ redirectUri: string;
1034
+ }): Promise<OAuthTokenResponse>;
1035
+ startDeviceAuthorization(input: {
1036
+ endpoint: string;
1037
+ clientId: string;
1038
+ scopes: readonly string[];
1039
+ }): Promise<DeviceAuthorization>;
1040
+ pollDeviceToken(input: {
1041
+ tokenEndpoint: string;
1042
+ clientId: string;
1043
+ deviceCode: string;
1044
+ }): Promise<OAuthTokenResponse>;
1045
+ refresh(input: {
1046
+ tokenEndpoint: string;
1047
+ clientId: string;
1048
+ refreshToken: string;
1049
+ }): Promise<OAuthTokenResponse>;
1050
+ }
1051
+ interface OperatorTokenValidator {
1052
+ validateAccessToken(accessToken: string): Promise<ValidatedOperatorToken>;
1053
+ validateIdToken?(idToken: string): Promise<ValidatedOperatorToken>;
1054
+ }
1055
+ interface OperatorSessionStore {
1056
+ load(): Promise<OperatorSession | undefined>;
1057
+ save(session: OperatorSession): Promise<void>;
1058
+ clear(): Promise<void>;
1059
+ }
1060
+ interface OAuthTransactionStore {
1061
+ load(key: string): Promise<OAuthTransaction | undefined>;
1062
+ save(key: string, transaction: OAuthTransaction): Promise<void>;
1063
+ remove(key: string): Promise<void>;
1064
+ }
1065
+ interface OAuthClock {
1066
+ now(): number;
1067
+ sleep(milliseconds: number, signal?: AbortSignal): Promise<void>;
1068
+ }
1069
+ interface OAuthCrypto {
1070
+ randomUrlSafe(byteLength: number): string;
1071
+ sha256UrlSafe(value: string): Promise<string>;
1072
+ }
1073
+ interface OperatorSessionControlPort {
1074
+ list(): Promise<readonly OperatorSessionSummary[]>;
1075
+ revoke(sessionId: string): Promise<void>;
1076
+ logout(sessionId: string): Promise<void>;
1077
+ }
1078
+
1079
+ declare class WebOAuthCrypto implements OAuthCrypto {
1080
+ randomUrlSafe(byteLength: number): string;
1081
+ sha256UrlSafe(value: string): Promise<string>;
1082
+ }
1083
+ declare class SystemOAuthClock implements OAuthClock {
1084
+ now(): number;
1085
+ sleep(milliseconds: number, signal?: AbortSignal): Promise<void>;
1086
+ }
1087
+
1088
+ declare class OperatorAuthError extends Error {
1089
+ readonly code: string;
1090
+ constructor(code: string, message?: string);
1091
+ }
1092
+ declare class OperatorReauthenticationRequired extends OperatorAuthError {
1093
+ constructor(message?: string);
1094
+ }
1095
+ declare class OAuthProtocolError extends OperatorAuthError {
1096
+ constructor(code: string, message?: string);
1097
+ }
1098
+ declare function oauthErrorCode(error: unknown): string | undefined;
1099
+
1100
+ type OAuthHttpTransport = (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>;
1101
+ /** Standard public-client OAuth/OIDC transport. Confidential BFFs should inject their own transport. */
1102
+ declare class HttpOperatorAuthTransport implements OperatorAuthTransport {
1103
+ private readonly http;
1104
+ constructor(http?: OAuthHttpTransport);
1105
+ discover(issuer: string): Promise<OidcDiscoveryDocument>;
1106
+ exchangeAuthorizationCode(input: Parameters<OperatorAuthTransport['exchangeAuthorizationCode']>[0]): Promise<OAuthTokenResponse>;
1107
+ startDeviceAuthorization(input: Parameters<OperatorAuthTransport['startDeviceAuthorization']>[0]): Promise<DeviceAuthorization>;
1108
+ pollDeviceToken(input: Parameters<OperatorAuthTransport['pollDeviceToken']>[0]): Promise<OAuthTokenResponse>;
1109
+ refresh(input: Parameters<OperatorAuthTransport['refresh']>[0]): Promise<OAuthTokenResponse>;
1110
+ private token;
1111
+ private form;
1112
+ private json;
1113
+ }
1114
+
1115
+ interface OperatorAuthClientOptions {
1116
+ configuration: OperatorAuthConfiguration;
1117
+ transport: OperatorAuthTransport;
1118
+ tokenValidator: OperatorTokenValidator;
1119
+ sessions: OperatorSessionStore;
1120
+ transactions: OAuthTransactionStore;
1121
+ crypto?: OAuthCrypto;
1122
+ clock?: OAuthClock;
1123
+ }
1124
+ declare class OperatorAuthClient {
1125
+ private readonly options;
1126
+ private readonly crypto;
1127
+ private readonly clock;
1128
+ private discovery?;
1129
+ private refreshFlight?;
1130
+ constructor(options: OperatorAuthClientOptions);
1131
+ beginAuthorizationCode(): Promise<{
1132
+ authorizationUrl: string;
1133
+ expiresAt: number;
1134
+ }>;
1135
+ completeAuthorizationCode(callbackUrl: string): Promise<OperatorSession>;
1136
+ beginDeviceAuthorization(): Promise<DeviceTransaction>;
1137
+ pollDeviceAuthorization(signal?: AbortSignal): Promise<OperatorSession>;
1138
+ getAccessToken(): Promise<string | undefined>;
1139
+ refresh(): Promise<OperatorSession>;
1140
+ clear(): Promise<void>;
1141
+ private performRefresh;
1142
+ private getDiscovery;
1143
+ private transactionKey;
1144
+ private acceptTokens;
1145
+ private assertPrincipal;
1146
+ private assertIdentity;
1147
+ }
1148
+
1149
+ declare class OperatorSessionController {
1150
+ private readonly control;
1151
+ private readonly local;
1152
+ constructor(control: OperatorSessionControlPort, local: OperatorSessionStore);
1153
+ list(): Promise<readonly OperatorSessionSummary[]>;
1154
+ revoke(sessionId: string): Promise<void>;
1155
+ logout(): Promise<void>;
1156
+ }
1157
+
1158
+ 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, getAvailableEnvs, masterKeyRefFor, masterKeyRefKey, oauthErrorCode, parseAssetFieldSelector, unwrapDekWithMasterKey, useClient, validatePlanCreationInput, validatePlanCreationMaterial };
1159
+ export type { AssetFieldSelector, AuthorizationTransaction, AuthorizeRevealActionInput, CanonicalPlanAssetType, CollectedPlanMaterial, CompatibleValue, CorePlanSecrets, CustodianShareResult, DecodedPlanAsset, DeviceAuthorization, DeviceTransaction, ElementsApiPort, ElementsClientOptions, ElementsEnvironment, EncryptedPlanMaterial, EncryptedPlanShard, ExportPlanBridgeInput, GovernedRevealSession, GovernedRevealState, GovernedShare, GovernedSharesMaterial, GovernedValidatorMaterial, GuidedCreateCheckpoint, GuidedCreateCheckpointStore, GuidedCreateLocalStage, GuidedCreateOptions, InheritiClientProviderProps, IntegrationPlanAssetDeclaration, KeyVault, ListPlansInput, MasterKeyRef, MasterKeyRelayPort, 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, PlanMaterialBuilder, PlanMaterialReconstructor, PlanPage, PlanParticipantRelationship, PlanRevealProfile, PlanStatus, PlanSummary, RelayMasterKeySourceOptions, ReportRevealActionOutcomeInput, RevealAction, RevealActionOutcome, RevealActionType, RevealCloseReason, RevealFieldOptions, RevealHandle, RevealMode, RevealReconstructionInput, RevealSession, RevealStage, StartPlanCreationInput, StartRevealInput, StatePort, StepUpReadContext, ValidatedOperatorToken };