@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
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PlanCreationProgress, PlanDetail, PlanPage } from './plan-operations';
|
|
2
|
+
export declare function decodePlanPage(value: unknown): PlanPage;
|
|
3
|
+
export declare function decodePlanDetail(value: unknown): PlanDetail;
|
|
4
|
+
export declare function decodePlanCreationProgress(value: unknown): PlanCreationProgress;
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
export declare const CANONICAL_PLAN_ASSET_TYPES: readonly ["PLAIN-TEXT", "USER-PSWD", "RECOVERY-CODE", "PIN-CODE", "API-KEY", "PRIVATE-KEY", "SEED-PHRASE", "PAYMENT-DEBIT-CARD", "PAYMENT-CREDIT-CARD", "DOCUMENT", "IMAGE", "VIDEO"];
|
|
2
|
+
export type CanonicalPlanAssetType = (typeof CANONICAL_PLAN_ASSET_TYPES)[number];
|
|
3
|
+
export declare const CANONICAL_STRUCTURED_ASSET_FIELDS: Readonly<Record<Exclude<CanonicalPlanAssetType, 'DOCUMENT' | 'IMAGE' | 'VIDEO'>, readonly string[]>>;
|
|
4
|
+
export type CompatibleValue<T extends string> = T | {
|
|
5
|
+
readonly kind: 'UNKNOWN';
|
|
6
|
+
readonly raw: string;
|
|
7
|
+
};
|
|
8
|
+
export type PlanStatus = CompatibleValue<'DRAFT' | 'ACTIVE' | 'CONFIGURED' | 'ARCHIVED'>;
|
|
9
|
+
export type PlanGovernanceMode = CompatibleValue<'DIRECT' | 'GOVERNED'>;
|
|
10
|
+
export type PlanParticipantRelationship = 'OWNER' | 'MERGER' | 'MODERATOR' | 'CUSTODIAN' | 'ALLOW' | 'DENY';
|
|
11
|
+
export interface PlanAssetSummary {
|
|
12
|
+
count: number;
|
|
13
|
+
types: CompatibleValue<CanonicalPlanAssetType>[];
|
|
14
|
+
/** The names the developer gave the assets, in plan order. A binary asset's filename is not here. */
|
|
15
|
+
names: string[];
|
|
16
|
+
}
|
|
17
|
+
export interface PlanSummary {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
status: PlanStatus;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
configuredAt?: string;
|
|
24
|
+
assetSummary: PlanAssetSummary;
|
|
25
|
+
governance: {
|
|
26
|
+
mode: PlanGovernanceMode;
|
|
27
|
+
minimumApprovals: number;
|
|
28
|
+
};
|
|
29
|
+
participantSummary: {
|
|
30
|
+
owners: number;
|
|
31
|
+
mergers: number;
|
|
32
|
+
moderators: number;
|
|
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
|
+
}>;
|
|
42
|
+
}
|
|
43
|
+
export interface PlanPage {
|
|
44
|
+
items: PlanSummary[];
|
|
45
|
+
nextCursor: string | null;
|
|
46
|
+
}
|
|
47
|
+
export interface ListPlansInput {
|
|
48
|
+
cursor?: string;
|
|
49
|
+
limit?: number;
|
|
50
|
+
status?: readonly string[];
|
|
51
|
+
assetType?: CanonicalPlanAssetType;
|
|
52
|
+
namePrefix?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface PlanDetail extends PlanSummary {
|
|
55
|
+
assets: Array<{
|
|
56
|
+
id: string;
|
|
57
|
+
/** Developer-defined stable address. Older plans may not have one and fall back to `id`. */
|
|
58
|
+
code?: string;
|
|
59
|
+
type: CompatibleValue<CanonicalPlanAssetType>;
|
|
60
|
+
name: string;
|
|
61
|
+
isBinary: boolean;
|
|
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;
|
|
67
|
+
matchOrigins?: string[];
|
|
68
|
+
}>;
|
|
69
|
+
participants: Array<{
|
|
70
|
+
id: string;
|
|
71
|
+
displayName: string;
|
|
72
|
+
relationships: CompatibleValue<PlanParticipantRelationship>[];
|
|
73
|
+
lifecycle: CompatibleValue<'ACTIVE' | 'REVOKED'>;
|
|
74
|
+
}>;
|
|
75
|
+
revealPolicy: {
|
|
76
|
+
masterKeyRelease: CompatibleValue<'REQUIRED'>;
|
|
77
|
+
custodian: CompatibleValue<'FORCE' | 'BYPASS'>;
|
|
78
|
+
};
|
|
79
|
+
dms?: {
|
|
80
|
+
subjectEmail: string;
|
|
81
|
+
countdownDays: number;
|
|
82
|
+
countdownHours: number;
|
|
83
|
+
countdownMinutes: number;
|
|
84
|
+
};
|
|
85
|
+
source: {
|
|
86
|
+
kind: 'NATIVE';
|
|
87
|
+
} | {
|
|
88
|
+
kind: 'BRIDGED';
|
|
89
|
+
system: CompatibleValue<'INHERITI_BUSINESS'>;
|
|
90
|
+
status: CompatibleValue<'IN_SYNC' | 'RECONCILIATION_REQUIRED'>;
|
|
91
|
+
} | {
|
|
92
|
+
kind: 'UNKNOWN';
|
|
93
|
+
raw: string;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export interface IntegrationPlanAssetDeclaration {
|
|
97
|
+
clientAssetRef: string;
|
|
98
|
+
type: CanonicalPlanAssetType;
|
|
99
|
+
name: string;
|
|
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[];
|
|
107
|
+
isBinary: boolean;
|
|
108
|
+
fileName?: string;
|
|
109
|
+
mimeType?: string;
|
|
110
|
+
size?: number;
|
|
111
|
+
}
|
|
112
|
+
export interface NativePlanParticipant {
|
|
113
|
+
clientParticipantRef: string;
|
|
114
|
+
/** Routing only. It is not identity or evidence of a SafeID/SafeKey account. */
|
|
115
|
+
routingEmail: string;
|
|
116
|
+
displayName: string;
|
|
117
|
+
relationships: readonly PlanParticipantRelationship[];
|
|
118
|
+
}
|
|
119
|
+
export interface StartPlanCreationInput {
|
|
120
|
+
idempotencyKey: string;
|
|
121
|
+
name: string;
|
|
122
|
+
description?: string;
|
|
123
|
+
assets: readonly IntegrationPlanAssetDeclaration[];
|
|
124
|
+
participants: readonly NativePlanParticipant[];
|
|
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?: {
|
|
144
|
+
minimumApprovals?: number;
|
|
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;
|
|
153
|
+
};
|
|
154
|
+
masterKeyRelease?: 'REQUIRED';
|
|
155
|
+
custodian?: 'FORCE' | 'BYPASS';
|
|
156
|
+
}
|
|
157
|
+
export declare const PLAN_CREATION_SERVER_STAGES: readonly ["VALIDATED", "PLAN_CREATED", "PARTICIPANTS_PERSISTED", "STORAGE_PREPARED", "AWAITING_ENCRYPTED_MATERIAL", "VALIDATOR_SHARES_DISTRIBUTED", "CONFIGURED", "COMPLETED"];
|
|
158
|
+
export type PlanCreationServerStage = (typeof PLAN_CREATION_SERVER_STAGES)[number];
|
|
159
|
+
export type PlanCreationOutcome = 'IN_PROGRESS' | 'COMPLETED' | 'CANCELED' | 'FAILED_RETRYABLE' | 'FAILED_TERMINAL' | 'RECONCILIATION_REQUIRED';
|
|
160
|
+
export interface PlanCreationProgress {
|
|
161
|
+
operationId: string;
|
|
162
|
+
stage: CompatibleValue<PlanCreationServerStage>;
|
|
163
|
+
outcome: CompatibleValue<PlanCreationOutcome>;
|
|
164
|
+
planId?: string;
|
|
165
|
+
lastErrorCode?: string;
|
|
166
|
+
participants?: Array<{
|
|
167
|
+
clientParticipantRef: string;
|
|
168
|
+
planParticipantId: string;
|
|
169
|
+
relationships: PlanParticipantRelationship[];
|
|
170
|
+
}>;
|
|
171
|
+
}
|
|
172
|
+
export interface EncryptedPlanMaterial {
|
|
173
|
+
protectionProtocol?: 'SSDP_PLUS_V1' | 'SSDP_PLUS_V2';
|
|
174
|
+
validatorShares?: readonly EncryptedPlanShard[];
|
|
175
|
+
dataShards: readonly EncryptedPlanShard[];
|
|
176
|
+
backupShards: readonly EncryptedPlanShard[];
|
|
177
|
+
encryptedKey?: string;
|
|
178
|
+
assetsMetadata?: Readonly<Record<string, {
|
|
179
|
+
type: CanonicalPlanAssetType;
|
|
180
|
+
meta: {
|
|
181
|
+
name: string;
|
|
182
|
+
notes?: string;
|
|
183
|
+
code?: string;
|
|
184
|
+
matchOrigins?: readonly string[];
|
|
185
|
+
};
|
|
186
|
+
fieldNames?: readonly string[];
|
|
187
|
+
isBinary?: boolean;
|
|
188
|
+
fileName?: string;
|
|
189
|
+
mimeType?: string;
|
|
190
|
+
size?: number;
|
|
191
|
+
}>>;
|
|
192
|
+
custodianShard?: {
|
|
193
|
+
keyShard: EncryptedPlanShard;
|
|
194
|
+
dataShard: EncryptedPlanShard;
|
|
195
|
+
};
|
|
196
|
+
operation?: 'DRAFT' | 'FINALIZE';
|
|
197
|
+
}
|
|
198
|
+
export interface EncryptedPlanShard {
|
|
199
|
+
id: string;
|
|
200
|
+
data?: string;
|
|
201
|
+
}
|
|
202
|
+
export type GuidedCreateLocalStage = 'VALIDATING_ASSETS' | 'ENCRYPTING' | 'GENERATING_SHARES';
|
|
203
|
+
export interface GuidedCreateCheckpoint {
|
|
204
|
+
idempotencyKey: string;
|
|
205
|
+
operationId: string;
|
|
206
|
+
declarationHash: string;
|
|
207
|
+
serverStage: CompatibleValue<PlanCreationServerStage>;
|
|
208
|
+
}
|
|
209
|
+
export declare class InvalidPlanDeclaration extends Error {
|
|
210
|
+
readonly code: string;
|
|
211
|
+
constructor(code: string);
|
|
212
|
+
}
|
|
213
|
+
export declare class InvalidPlanMaterial extends Error {
|
|
214
|
+
readonly code: string;
|
|
215
|
+
constructor(code: string);
|
|
216
|
+
}
|
|
217
|
+
export declare function validatePlanCreationMaterial(material: EncryptedPlanMaterial): void;
|
|
218
|
+
export declare function validatePlanCreationInput(input: StartPlanCreationInput): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ProcessReconciliationOwnership, ProcessRuntimeEnvironment, SharedPlanEventHandlers, SharedPlanEventListener } from '@safetech/inheriti-core-sdk/shared-configuration';
|
|
2
|
+
import type { ElementsApiPort } from './elements-api-port';
|
|
3
|
+
/** Elements adapter for Core's transport-neutral event port. Scheduling remains owned by Core's mature loop. */
|
|
4
|
+
export declare class PollingSharedPlanEventListener implements SharedPlanEventListener {
|
|
5
|
+
private readonly api;
|
|
6
|
+
private readonly subscriptions;
|
|
7
|
+
private readonly loop;
|
|
8
|
+
constructor(api: ElementsApiPort, environment?: ProcessRuntimeEnvironment, ownership?: ProcessReconciliationOwnership, random?: () => number);
|
|
9
|
+
refreshConnection(): void;
|
|
10
|
+
subscribe(processId: string, handlers: SharedPlanEventHandlers): void;
|
|
11
|
+
unsubscribe(processId: string): void;
|
|
12
|
+
}
|
|
13
|
+
/** Cross-host runtime: browsers regain work on online/visibility events; Node uses timer-only recovery. */
|
|
14
|
+
export declare class HostProcessRuntimeEnvironment implements ProcessRuntimeEnvironment {
|
|
15
|
+
visibility(): 'visible' | 'hidden';
|
|
16
|
+
isOnline(): boolean;
|
|
17
|
+
now(): number;
|
|
18
|
+
schedule(callback: () => void, delayMs: number): () => void;
|
|
19
|
+
onRecovery(callback: () => void): () => void;
|
|
20
|
+
}
|
|
21
|
+
/** One host process owns its own polling; Core's loop still enforces one active lease per subscription. */
|
|
22
|
+
export declare class LocalProcessReconciliationOwnership implements ProcessReconciliationOwnership {
|
|
23
|
+
join(_processId: string, handlers: Parameters<ProcessReconciliationOwnership['join']>[1]): {
|
|
24
|
+
isOwner: () => boolean;
|
|
25
|
+
requestReconciliation: () => void;
|
|
26
|
+
publishReconciled: () => undefined;
|
|
27
|
+
leave: () => void;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AuthorizeRevealActionInput, ElementsApiPort, RevealAction } from './elements-api-port';
|
|
2
|
+
export declare function authorizeActionWhenOpen(api: ElementsApiPort, revealId: string, input: AuthorizeRevealActionInput): Promise<RevealAction>;
|
|
3
|
+
/**
|
|
4
|
+
* Resolves the plan key before the material is released, where the caller's credential can.
|
|
5
|
+
*
|
|
6
|
+
* The key reference lives on `/shared-plans`, which takes an Application or Account credential. A
|
|
7
|
+
* host drives a reveal with the *operator* credential it gets at sign-in, and that route refuses it —
|
|
8
|
+
* so requiring this step made a reveal impossible from any integration host. It stays a fail-fast for
|
|
9
|
+
* the callers that can make the call, and is skipped for the ones that cannot: the released material
|
|
10
|
+
* carries its own key reference, so reconstruction resolves the key from that either way. Any other
|
|
11
|
+
* failure is still the caller's to see.
|
|
12
|
+
*/
|
|
13
|
+
export declare function releaseMaterialAfterKeyResolution(api: ElementsApiPort, revealId: string, materialVersion: string, prepareReveal: (planId: string) => Promise<unknown>): Promise<unknown>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type ElementsClient from './elements-client';
|
|
2
|
+
import type { RevealActionDestination, RevealActionType, RevealCloseReason, RevealMode, RevealSession } from './elements-api-port';
|
|
3
|
+
export type AssetFieldSelector = string | {
|
|
4
|
+
asset: string;
|
|
5
|
+
field: string;
|
|
6
|
+
};
|
|
7
|
+
export interface RevealFieldOptions {
|
|
8
|
+
action?: Exclude<RevealActionType, 'EXPORT_ASSET'>;
|
|
9
|
+
destination?: RevealActionDestination;
|
|
10
|
+
origin?: string;
|
|
11
|
+
idempotencyKey?: string;
|
|
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
|
+
}
|
|
55
|
+
export interface OpenRevealOptions {
|
|
56
|
+
mode?: RevealMode;
|
|
57
|
+
idempotencyKey?: string;
|
|
58
|
+
signal?: AbortSignal;
|
|
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;
|
|
64
|
+
onSession?: (session: RevealSession) => void;
|
|
65
|
+
}
|
|
66
|
+
/** The governance layers the server does report, read from the gate it names. */
|
|
67
|
+
export declare function revealPhaseOf(session: RevealSession): RevealPhase;
|
|
68
|
+
export interface RevealHandle {
|
|
69
|
+
readonly session: RevealSession;
|
|
70
|
+
readonly material: Uint8Array;
|
|
71
|
+
readonly closed: boolean;
|
|
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>;
|
|
75
|
+
close(reason?: RevealCloseReason): Promise<void>;
|
|
76
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
export declare class RevealHandleClosed extends Error {
|
|
79
|
+
readonly code = "reveal_handle_closed";
|
|
80
|
+
constructor();
|
|
81
|
+
}
|
|
82
|
+
export declare class RevealFieldAccessError extends Error {
|
|
83
|
+
readonly code: 'asset_selector_invalid' | 'asset_not_found' | 'asset_field_not_found' | 'action_not_allowed' | 'asset_decoder_required' | 'asset_value_invalid';
|
|
84
|
+
constructor(code: 'asset_selector_invalid' | 'asset_not_found' | 'asset_field_not_found' | 'action_not_allowed' | 'asset_decoder_required' | 'asset_value_invalid');
|
|
85
|
+
}
|
|
86
|
+
export declare function openScopedReveal(client: ElementsClient, planId: string, options?: OpenRevealOptions): Promise<RevealHandle>;
|
|
87
|
+
export declare class RevealAuthorizationEnded extends Error {
|
|
88
|
+
readonly stage: RevealSession['stage'];
|
|
89
|
+
readonly code = "reveal_authorization_ended";
|
|
90
|
+
constructor(stage: RevealSession['stage']);
|
|
91
|
+
}
|
|
92
|
+
export declare function parseAssetFieldSelector(selector: AssetFieldSelector): {
|
|
93
|
+
asset: string;
|
|
94
|
+
field: string;
|
|
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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { OAuthClock, OAuthCrypto } from './ports';
|
|
2
|
+
export declare class WebOAuthCrypto implements OAuthCrypto {
|
|
3
|
+
randomUrlSafe(byteLength: number): string;
|
|
4
|
+
sha256UrlSafe(value: string): Promise<string>;
|
|
5
|
+
}
|
|
6
|
+
export declare class SystemOAuthClock implements OAuthClock {
|
|
7
|
+
now(): number;
|
|
8
|
+
sleep(milliseconds: number, signal?: AbortSignal): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class OperatorAuthError extends Error {
|
|
2
|
+
readonly code: string;
|
|
3
|
+
constructor(code: string, message?: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class OperatorReauthenticationRequired extends OperatorAuthError {
|
|
6
|
+
constructor(message?: string);
|
|
7
|
+
}
|
|
8
|
+
export declare class OAuthProtocolError extends OperatorAuthError {
|
|
9
|
+
constructor(code: string, message?: string);
|
|
10
|
+
}
|
|
11
|
+
export declare function oauthErrorCode(error: unknown): string | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { OperatorAuthTransport } from './ports';
|
|
2
|
+
import type { DeviceAuthorization, OAuthTokenResponse, OidcDiscoveryDocument } from './types';
|
|
3
|
+
export type OAuthHttpTransport = (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
4
|
+
/** Standard public-client OAuth/OIDC transport. Confidential BFFs should inject their own transport. */
|
|
5
|
+
export declare class HttpOperatorAuthTransport implements OperatorAuthTransport {
|
|
6
|
+
private readonly http;
|
|
7
|
+
constructor(http?: OAuthHttpTransport);
|
|
8
|
+
discover(issuer: string): Promise<OidcDiscoveryDocument>;
|
|
9
|
+
exchangeAuthorizationCode(input: Parameters<OperatorAuthTransport['exchangeAuthorizationCode']>[0]): Promise<OAuthTokenResponse>;
|
|
10
|
+
startDeviceAuthorization(input: Parameters<OperatorAuthTransport['startDeviceAuthorization']>[0]): Promise<DeviceAuthorization>;
|
|
11
|
+
pollDeviceToken(input: Parameters<OperatorAuthTransport['pollDeviceToken']>[0]): Promise<OAuthTokenResponse>;
|
|
12
|
+
refresh(input: Parameters<OperatorAuthTransport['refresh']>[0]): Promise<OAuthTokenResponse>;
|
|
13
|
+
private token;
|
|
14
|
+
private form;
|
|
15
|
+
private json;
|
|
16
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { OAuthClock, OAuthCrypto, OAuthTransactionStore, OperatorAuthTransport, OperatorSessionStore, OperatorTokenValidator } from './ports';
|
|
2
|
+
import type { DeviceTransaction, OperatorAuthConfiguration, OperatorSession } from './types';
|
|
3
|
+
export interface OperatorAuthClientOptions {
|
|
4
|
+
configuration: OperatorAuthConfiguration;
|
|
5
|
+
transport: OperatorAuthTransport;
|
|
6
|
+
tokenValidator: OperatorTokenValidator;
|
|
7
|
+
sessions: OperatorSessionStore;
|
|
8
|
+
transactions: OAuthTransactionStore;
|
|
9
|
+
crypto?: OAuthCrypto;
|
|
10
|
+
clock?: OAuthClock;
|
|
11
|
+
}
|
|
12
|
+
export declare class OperatorAuthClient {
|
|
13
|
+
private readonly options;
|
|
14
|
+
private readonly crypto;
|
|
15
|
+
private readonly clock;
|
|
16
|
+
private discovery?;
|
|
17
|
+
private refreshFlight?;
|
|
18
|
+
constructor(options: OperatorAuthClientOptions);
|
|
19
|
+
beginAuthorizationCode(): Promise<{
|
|
20
|
+
authorizationUrl: string;
|
|
21
|
+
expiresAt: number;
|
|
22
|
+
}>;
|
|
23
|
+
completeAuthorizationCode(callbackUrl: string): Promise<OperatorSession>;
|
|
24
|
+
beginDeviceAuthorization(): Promise<DeviceTransaction>;
|
|
25
|
+
pollDeviceAuthorization(signal?: AbortSignal): Promise<OperatorSession>;
|
|
26
|
+
getAccessToken(): Promise<string | undefined>;
|
|
27
|
+
refresh(): Promise<OperatorSession>;
|
|
28
|
+
clear(): Promise<void>;
|
|
29
|
+
private performRefresh;
|
|
30
|
+
private getDiscovery;
|
|
31
|
+
private transactionKey;
|
|
32
|
+
private acceptTokens;
|
|
33
|
+
private assertPrincipal;
|
|
34
|
+
private assertIdentity;
|
|
35
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { OperatorSessionControlPort, OperatorSessionStore } from './ports';
|
|
2
|
+
import type { OperatorSessionSummary } from './types';
|
|
3
|
+
export declare class OperatorSessionController {
|
|
4
|
+
private readonly control;
|
|
5
|
+
private readonly local;
|
|
6
|
+
constructor(control: OperatorSessionControlPort, local: OperatorSessionStore);
|
|
7
|
+
list(): Promise<readonly OperatorSessionSummary[]>;
|
|
8
|
+
revoke(sessionId: string): Promise<void>;
|
|
9
|
+
logout(): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { DeviceAuthorization, OAuthTokenResponse, OAuthTransaction, OidcDiscoveryDocument, OperatorSession, OperatorSessionSummary, ValidatedOperatorToken } from './types';
|
|
2
|
+
export interface OperatorAuthTransport {
|
|
3
|
+
discover(issuer: string): Promise<OidcDiscoveryDocument>;
|
|
4
|
+
exchangeAuthorizationCode(input: {
|
|
5
|
+
tokenEndpoint: string;
|
|
6
|
+
clientId: string;
|
|
7
|
+
code: string;
|
|
8
|
+
codeVerifier: string;
|
|
9
|
+
redirectUri: string;
|
|
10
|
+
}): Promise<OAuthTokenResponse>;
|
|
11
|
+
startDeviceAuthorization(input: {
|
|
12
|
+
endpoint: string;
|
|
13
|
+
clientId: string;
|
|
14
|
+
scopes: readonly string[];
|
|
15
|
+
}): Promise<DeviceAuthorization>;
|
|
16
|
+
pollDeviceToken(input: {
|
|
17
|
+
tokenEndpoint: string;
|
|
18
|
+
clientId: string;
|
|
19
|
+
deviceCode: string;
|
|
20
|
+
}): Promise<OAuthTokenResponse>;
|
|
21
|
+
refresh(input: {
|
|
22
|
+
tokenEndpoint: string;
|
|
23
|
+
clientId: string;
|
|
24
|
+
refreshToken: string;
|
|
25
|
+
}): Promise<OAuthTokenResponse>;
|
|
26
|
+
}
|
|
27
|
+
export interface OperatorTokenValidator {
|
|
28
|
+
validateAccessToken(accessToken: string): Promise<ValidatedOperatorToken>;
|
|
29
|
+
validateIdToken?(idToken: string): Promise<ValidatedOperatorToken>;
|
|
30
|
+
}
|
|
31
|
+
export interface OperatorSessionStore {
|
|
32
|
+
load(): Promise<OperatorSession | undefined>;
|
|
33
|
+
save(session: OperatorSession): Promise<void>;
|
|
34
|
+
clear(): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
export interface OAuthTransactionStore {
|
|
37
|
+
load(key: string): Promise<OAuthTransaction | undefined>;
|
|
38
|
+
save(key: string, transaction: OAuthTransaction): Promise<void>;
|
|
39
|
+
remove(key: string): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
export interface OAuthClock {
|
|
42
|
+
now(): number;
|
|
43
|
+
sleep(milliseconds: number, signal?: AbortSignal): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
export interface OAuthCrypto {
|
|
46
|
+
randomUrlSafe(byteLength: number): string;
|
|
47
|
+
sha256UrlSafe(value: string): Promise<string>;
|
|
48
|
+
}
|
|
49
|
+
export interface OperatorSessionControlPort {
|
|
50
|
+
list(): Promise<readonly OperatorSessionSummary[]>;
|
|
51
|
+
revoke(sessionId: string): Promise<void>;
|
|
52
|
+
logout(sessionId: string): Promise<void>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export type ElementsEnvironment = 'TEST' | 'LIVE';
|
|
2
|
+
export interface OidcDiscoveryDocument {
|
|
3
|
+
issuer: string;
|
|
4
|
+
authorizationEndpoint: string;
|
|
5
|
+
tokenEndpoint: string;
|
|
6
|
+
deviceAuthorizationEndpoint?: string;
|
|
7
|
+
endSessionEndpoint?: string;
|
|
8
|
+
revocationEndpoint?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface OperatorAuthConfiguration {
|
|
11
|
+
issuer: string;
|
|
12
|
+
clientId: string;
|
|
13
|
+
audience: string;
|
|
14
|
+
environment: ElementsEnvironment;
|
|
15
|
+
redirectUri: string;
|
|
16
|
+
scopes: readonly string[];
|
|
17
|
+
}
|
|
18
|
+
export interface OAuthTokenResponse {
|
|
19
|
+
accessToken: string;
|
|
20
|
+
refreshToken?: string;
|
|
21
|
+
idToken?: string;
|
|
22
|
+
tokenType: string;
|
|
23
|
+
expiresInSeconds: number;
|
|
24
|
+
refreshExpiresInSeconds?: number;
|
|
25
|
+
scope?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ValidatedOperatorToken {
|
|
28
|
+
issuer: string;
|
|
29
|
+
audience: string | readonly string[];
|
|
30
|
+
authorizedParty: string;
|
|
31
|
+
environment: ElementsEnvironment;
|
|
32
|
+
subject: string;
|
|
33
|
+
sessionId: string;
|
|
34
|
+
tokenId: string;
|
|
35
|
+
scopes: readonly string[];
|
|
36
|
+
nonce?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface OperatorSession {
|
|
39
|
+
accessToken: string;
|
|
40
|
+
refreshToken?: string;
|
|
41
|
+
idToken?: string;
|
|
42
|
+
tokenType: 'Bearer';
|
|
43
|
+
expiresAt: number;
|
|
44
|
+
refreshExpiresAt?: number;
|
|
45
|
+
principal: ValidatedOperatorToken;
|
|
46
|
+
}
|
|
47
|
+
export interface AuthorizationTransaction {
|
|
48
|
+
kind: 'authorization-code';
|
|
49
|
+
state: string;
|
|
50
|
+
nonce: string;
|
|
51
|
+
codeVerifier: string;
|
|
52
|
+
redirectUri: string;
|
|
53
|
+
expiresAt: number;
|
|
54
|
+
}
|
|
55
|
+
export interface DeviceAuthorization {
|
|
56
|
+
deviceCode: string;
|
|
57
|
+
userCode: string;
|
|
58
|
+
verificationUri: string;
|
|
59
|
+
verificationUriComplete?: string;
|
|
60
|
+
expiresInSeconds: number;
|
|
61
|
+
intervalSeconds?: number;
|
|
62
|
+
}
|
|
63
|
+
export interface DeviceTransaction extends DeviceAuthorization {
|
|
64
|
+
kind: 'device-code';
|
|
65
|
+
expiresAt: number;
|
|
66
|
+
nextPollAt: number;
|
|
67
|
+
consumed: boolean;
|
|
68
|
+
}
|
|
69
|
+
export type OAuthTransaction = AuthorizationTransaction | DeviceTransaction;
|
|
70
|
+
export interface OperatorSessionSummary {
|
|
71
|
+
id: string;
|
|
72
|
+
createdAt: string;
|
|
73
|
+
lastSeenAt?: string;
|
|
74
|
+
current: boolean;
|
|
75
|
+
clientId: string;
|
|
76
|
+
environment: ElementsEnvironment;
|
|
77
|
+
}
|