@safetech/inheriti-client-sdk 1.17.6 → 1.17.7

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.
@@ -6,7 +6,7 @@ import type { AuthorizeRevealActionInput, CollectedPlanMaterial, CustodianShareR
6
6
  import type { PlanMaterialReconstructor } from './plan-material-reconstructor';
7
7
  import type { MasterKeyRef, MasterKeyResolver } from './master-key';
8
8
  import type { PlanAssetDeclaration } from '@safetech/inheriti-core-sdk';
9
- import type { EncryptedPlanMaterial, ListPlansInput, PlanCreationProgress, PlanDetail, PlanPage, StartPlanCreationInput } from './plan-operations';
9
+ import type { EncryptedPlanMaterial, ListPlanLogsInput, ListPlansInput, PlanCreationProgress, PlanDetail, PlanLogPage, PlanPage, StartPlanCreationInput } from './plan-operations';
10
10
  import type { GuidedCreateCheckpointStore } from './guided-plan-creator';
11
11
  import { GuidedPlanCreator } from './guided-plan-creator';
12
12
  import type { OpenRevealOptions, RevealHandle } from './scoped-reveal';
@@ -48,7 +48,9 @@ export interface ElementsClientOptions {
48
48
  relay?: MasterKeyAcquisitionOptions['relay'];
49
49
  };
50
50
  /** The Application this client acts for; needed to wrap keys of plans it creates. */
51
- applicationId: string;
51
+ applicationId?: string;
52
+ /** The selected Business organization for this client instance. */
53
+ organizationId?: string;
52
54
  assetDecoder: PlanAssetContainerDecoder;
53
55
  }
54
56
  export default class ElementsClient {
@@ -63,15 +65,18 @@ export default class ElementsClient {
63
65
  masterKeys?: MasterKeyResolver;
64
66
  masterKey?: ElementsClientOptions['masterKey'];
65
67
  applicationId?: string;
68
+ organizationId?: string;
66
69
  assetDecoder?: PlanAssetContainerDecoder;
67
70
  });
68
71
  private readonly api?;
69
72
  private readonly reconstructor?;
70
73
  private readonly masterKeys?;
71
74
  private readonly applicationId?;
75
+ private readonly organizationId?;
72
76
  readonly assetDecoder?: PlanAssetContainerDecoder;
73
77
  listPlans(input?: ListPlansInput): Promise<PlanPage>;
74
78
  getPlan(planId: string): Promise<PlanDetail>;
79
+ listPlanLogs(planId: string, input?: ListPlanLogsInput): Promise<PlanLogPage>;
75
80
  startPlanCreation(input: StartPlanCreationInput): Promise<PlanCreationProgress>;
76
81
  getPlanCreation(operationId: string): Promise<PlanCreationProgress>;
77
82
  supplyPlanCreationMaterial(operationId: string, material: EncryptedPlanMaterial): Promise<PlanCreationProgress>;
@@ -181,6 +186,7 @@ export default class ElementsClient {
181
186
  collectGovernedPlanMaterial(session: GovernedRevealSession, stepUp?: StepUpReadContext): Promise<CollectedPlanMaterial>;
182
187
  reconstructGovernedPlanMaterial(session: GovernedRevealSession, material: CollectedPlanMaterial): Promise<Uint8Array>;
183
188
  private useCase;
189
+ private requireApplication;
184
190
  }
185
191
  /** Names the one capability a reveal-only client lacks, instead of failing on a missing property. */
186
192
  export declare class CoreSdkContainerRequired extends Error {
@@ -1,6 +1,7 @@
1
1
  import type { BearerTokenResolver, HttpTransport } from '@safetech/inheriti-core-sdk/node';
2
- import type { AuthorizeRevealActionInput, CollectedPlanMaterial, CustodianShareResult, ElementsApiPort, MasterKeyAcquisition, MasterKeyRelaySessionOpened, MasterKeyRelaySessionState, PlanKeyReference, ExportPlanBridgeInput, GovernedRevealSession, GovernedRevealState, GovernedSharesMaterial, GovernedValidatorMaterial, PlanBridgeEnvelope, ReportRevealActionOutcomeInput, RevealAction, RevealCloseReason, RevealReconstructionInput, RevealSession, StartRevealInput, StepUpReadContext } from './elements-api-port';
3
- import type { EncryptedPlanMaterial, ListPlansInput, PlanCreationProgress, PlanDetail, PlanPage, StartPlanCreationInput } from './plan-operations';
2
+ import type { AuthorizeRevealActionInput, CollectedPlanMaterial, CustodianShareResult, ElementsApiPort, MasterKeyAcquisition, MasterKeyRelayContext, MasterKeyRelaySessionOpened, MasterKeyRelaySessionState, PlanKeyReference, ExportPlanBridgeInput, GovernedRevealSession, GovernedRevealState, GovernedSharesMaterial, GovernedValidatorMaterial, PlanBridgeEnvelope, ReportRevealActionOutcomeInput, RevealAction, RevealCloseReason, RevealReconstructionInput, RevealSession, StartRevealInput, StepUpReadContext } from './elements-api-port';
3
+ import type { EncryptedPlanMaterial, ListPlanLogsInput, ListPlansInput, PlanCreationProgress, PlanDetail, PlanLogPage, PlanPage, StartPlanCreationInput } from './plan-operations';
4
+ import type { BusinessOrganization } from '../business/organizations';
4
5
  export declare class ElementsApiRequestFailed extends Error {
5
6
  readonly status: number;
6
7
  readonly code?: string | undefined;
@@ -13,9 +14,14 @@ export default class HttpElementsApiPort implements ElementsApiPort {
13
14
  private readonly environment;
14
15
  private readonly getBearerToken;
15
16
  private readonly transport;
16
- constructor(apiUrl: string, environment: 'TEST' | 'LIVE', getBearerToken: BearerTokenResolver, transport: HttpTransport);
17
+ constructor(apiUrl: string, environment: 'TEST' | 'LIVE', getBearerToken: BearerTokenResolver, transport: HttpTransport, business?: {
18
+ readonly organizationId?: string;
19
+ });
20
+ private readonly business?;
21
+ listBusinessOrganizations(): Promise<BusinessOrganization[]>;
17
22
  listPlans(input?: ListPlansInput): Promise<PlanPage>;
18
23
  getPlan(planId: string): Promise<PlanDetail>;
24
+ listPlanLogs(planId: string, input?: ListPlanLogsInput): Promise<PlanLogPage>;
19
25
  startPlanCreation(input: StartPlanCreationInput): Promise<PlanCreationProgress>;
20
26
  getPlanCreation(operationId: string): Promise<PlanCreationProgress>;
21
27
  supplyPlanCreationMaterial(operationId: string, material: EncryptedPlanMaterial): Promise<PlanCreationProgress>;
@@ -30,7 +36,7 @@ export default class HttpElementsApiPort implements ElementsApiPort {
30
36
  */
31
37
  masterKeyAcquisition(): Promise<MasterKeyAcquisition>;
32
38
  foreignMasterKeyAcquisition(system: string, contextId: string): Promise<MasterKeyAcquisition>;
33
- startMasterKeyRelaySession(clientPublicKey: string): Promise<MasterKeyRelaySessionOpened>;
39
+ startMasterKeyRelaySession(clientPublicKey: string, context?: MasterKeyRelayContext): Promise<MasterKeyRelaySessionOpened>;
34
40
  readMasterKeyRelaySession(sessionId: string): Promise<MasterKeyRelaySessionState>;
35
41
  planKeyReference(planId: string): Promise<PlanKeyReference>;
36
42
  collectPlanMaterial(planId: string, stepUp?: StepUpReadContext): Promise<CollectedPlanMaterial>;
@@ -64,4 +70,5 @@ export default class HttpElementsApiPort implements ElementsApiPort {
64
70
  }>;
65
71
  private request;
66
72
  private requestWithoutResult;
73
+ private requireBusinessSelection;
67
74
  }
@@ -22,7 +22,7 @@ export { RelayMasterKeySource, MasterKeyRelayExpired, MasterKeyRelayTimedOut } f
22
22
  export { createMasterKeyResolver } from './master-key-acquisition';
23
23
  export type { MasterKeySource } from '@safetech/inheriti-core-sdk';
24
24
  export type { DeclaredMasterKeySource, MasterKeyAcquisitionOptions } from './master-key-acquisition';
25
- export type { MasterKeyAcquisition, MasterKeyRelaySessionOpened, MasterKeyRelaySessionState } from './elements-api-port';
25
+ export type { MasterKeyAcquisition, MasterKeyRelayContext, MasterKeyRelaySessionOpened, MasterKeyRelaySessionState } from './elements-api-port';
26
26
  export type { MasterKeyRelayPort, RelayMasterKeySourceOptions } from './relay-master-key-source';
27
27
  export { HostProcessRuntimeEnvironment, LocalProcessReconciliationOwnership, PollingSharedPlanEventListener } from './polling-shared-plan-event-listener';
28
28
  export * from './plan-operations';
@@ -10,10 +10,8 @@ import type { RelayMasterKeySourceOptions } from './relay-master-key-source';
10
10
  export interface DeclaredMasterKeySource {
11
11
  resolve(): Promise<string | undefined>;
12
12
  }
13
- export interface MasterKeyAcquisitionOptions {
13
+ export type MasterKeyAcquisitionOptions = {
14
14
  api: ElementsApiPort;
15
- /** The Application this host acts for. A ref naming any other context is foreign. */
16
- applicationId: string;
17
15
  /**
18
16
  * What this host can produce on its own: a passphrase-derived key, or key material it already
19
17
  * holds. Absent means the host has no custody of its own and must be given the key.
@@ -26,7 +24,13 @@ export interface MasterKeyAcquisitionOptions {
26
24
  source?: DeclaredMasterKeySource;
27
25
  /** Passed through to the relay, for hosts that want a different wait or poll interval. */
28
26
  relay?: Omit<RelayMasterKeySourceOptions, 'api'>;
29
- }
27
+ } & ({
28
+ applicationId: string;
29
+ organizationId?: never;
30
+ } | {
31
+ organizationId: string;
32
+ applicationId?: never;
33
+ });
30
34
  /**
31
35
  * Decides how this host obtains the key that opens a plan, and does it.
32
36
  *
@@ -1,4 +1,5 @@
1
- import type { PlanCreationProgress, PlanDetail, PlanPage } from './plan-operations';
1
+ import type { PlanCreationProgress, PlanDetail, PlanLogPage, PlanPage } from './plan-operations';
2
2
  export declare function decodePlanPage(value: unknown): PlanPage;
3
+ export declare function decodePlanLogPage(value: unknown): PlanLogPage;
3
4
  export declare function decodePlanDetail(value: unknown): PlanDetail;
4
5
  export declare function decodePlanCreationProgress(value: unknown): PlanCreationProgress;
@@ -44,6 +44,27 @@ export interface PlanPage {
44
44
  items: PlanSummary[];
45
45
  nextCursor: string | null;
46
46
  }
47
+ export interface ListPlanLogsInput {
48
+ limit?: number;
49
+ offset?: number;
50
+ }
51
+ export interface PlanLog {
52
+ id: string;
53
+ planId: string;
54
+ tenantId: string;
55
+ event: string;
56
+ occurredOn: string;
57
+ status?: string;
58
+ title: string;
59
+ details: Array<{
60
+ label: string;
61
+ value: string;
62
+ }>;
63
+ }
64
+ export interface PlanLogPage {
65
+ items: PlanLog[];
66
+ total: number;
67
+ }
47
68
  export interface ListPlansInput {
48
69
  cursor?: string;
49
70
  limit?: number;
@@ -20,6 +20,12 @@ export interface ConsumedRevealField {
20
20
  value: unknown;
21
21
  }
22
22
  export type RevealFieldDestination = (fields: readonly ConsumedRevealField[]) => void | Promise<void>;
23
+ export type RevealAssetDestination = (asset: {
24
+ id: string;
25
+ fileName?: string;
26
+ mimeType?: string;
27
+ bytes: Uint8Array;
28
+ }) => void | Promise<void>;
23
29
  /**
24
30
  * Where a reveal has got to, in the order a reveal runs.
25
31
  *
@@ -72,6 +78,7 @@ export interface RevealHandle {
72
78
  field<TValue = unknown>(selector: AssetFieldSelector, options?: RevealFieldOptions): Promise<TValue>;
73
79
  /** Authorize, decode and deliver fields without returning their plaintext to the caller. */
74
80
  consumeFields(fields: readonly RevealFieldConsumption[], destination: RevealFieldDestination): Promise<void>;
81
+ exportAsset(selector: string, destination: RevealAssetDestination): Promise<void>;
75
82
  close(reason?: RevealCloseReason): Promise<void>;
76
83
  [Symbol.asyncDispose](): Promise<void>;
77
84
  }
package/index.ts CHANGED
@@ -7,4 +7,6 @@ export { default as useClient } from "./src/auth/use-client"
7
7
  export { getAvailableEnvs } from "./src/auth/get-available-envs"
8
8
  export {SDKContainer}
9
9
  export * from './src/elements';
10
+ export { selectBusinessOrganization, BusinessOrganizationSelectionError } from './src/business/organizations';
11
+ export type { BusinessOrganization } from './src/business/organizations';
10
12
  export * from './src/operator-auth';
package/node.ts CHANGED
@@ -8,7 +8,7 @@ import type { StatePort } from './src/elements/state-port';
8
8
  import HttpElementsApiPort from './src/elements/http-elements-api-port';
9
9
  import NodePlanMaterialReconstructor from './src/elements/node-plan-material-reconstructor';
10
10
 
11
- export interface NodeElementsClientOptions extends NodeSharedConfigurationSdkOptions {
11
+ export type NodeElementsClientOptions = NodeSharedConfigurationSdkOptions & {
12
12
  environment: 'TEST' | 'LIVE';
13
13
  keyVault?: KeyVault;
14
14
  state?: StatePort;
@@ -21,8 +21,8 @@ export interface NodeElementsClientOptions extends NodeSharedConfigurationSdkOpt
21
21
  /** What custody this host holds locally. See `ElementsClientOptions['masterKey']`. */
22
22
  masterKey?: ElementsClientOptions['masterKey'];
23
23
  /** The Application this client acts for; needed to wrap keys of plans it creates. */
24
- applicationId: string;
25
- }
24
+ } & ({ applicationId: string; business?: never; organizationId?: never }
25
+ | { business: true; organizationId?: string; applicationId?: never });
26
26
 
27
27
  export function createNodeElementsClient(options: NodeElementsClientOptions): ElementsClient {
28
28
  const baseTransport = options.transport ?? globalThis.fetch.bind(globalThis);
@@ -31,15 +31,18 @@ export function createNodeElementsClient(options: NodeElementsClientOptions): El
31
31
  headers.set('x-elements-environment', options.environment);
32
32
  return baseTransport(input, Object.assign({}, init, { headers }));
33
33
  };
34
- const coreSdk = createNodeSharedConfigurationSdk({ apiUrl: options.apiUrl, getBearerToken: options.getBearerToken, transport, workerUrl: options.workerUrl, reconciliationConcurrency: options.reconciliationConcurrency, eventListeners: options.eventListeners });
35
- const api = new HttpElementsApiPort(options.apiUrl, options.environment, options.getBearerToken, transport);
36
- return new ElementsClient(coreSdk, { keyVault: options.keyVault, state: options.state, api, reconstructor: new NodePlanMaterialReconstructor(), masterKeys: options.masterKeys, masterKey: options.masterKey, applicationId: options.applicationId, assetDecoder: decodeAssetContainer });
34
+ const coreSdk = options.business ? undefined : createNodeSharedConfigurationSdk({ apiUrl: options.apiUrl, getBearerToken: options.getBearerToken, transport, workerUrl: options.workerUrl, reconciliationConcurrency: options.reconciliationConcurrency, eventListeners: options.eventListeners });
35
+ const api = new HttpElementsApiPort(options.apiUrl, options.environment, options.getBearerToken, transport,
36
+ options.business ? { organizationId: options.organizationId } : undefined);
37
+ return new ElementsClient(coreSdk, { keyVault: options.keyVault, state: options.state, api, reconstructor: new NodePlanMaterialReconstructor(), masterKeys: options.masterKeys, masterKey: options.masterKey, applicationId: options.applicationId, organizationId: options.organizationId, assetDecoder: decodeAssetContainer });
37
38
  }
38
39
 
39
40
  export { ElementsClient };
40
41
  // The API port itself, not only its error: a Node host that just reads plans wants this rather than
41
42
  // the full client, and it must not reach the root barrel to get it — that barrel is React-flavoured.
42
43
  export { default as HttpElementsApiPort, ElementsApiRequestFailed } from './src/elements/http-elements-api-port';
44
+ export { selectBusinessOrganization, BusinessOrganizationSelectionError } from './src/business/organizations';
45
+ export type { BusinessOrganization } from './src/business/organizations';
43
46
  export type { StepUpReadContext } from './src/elements/elements-api-port';
44
47
  export { MemoryKeyVault } from './src/elements/key-vault';
45
48
  export type { KeyVault } from './src/elements/key-vault';
@@ -52,7 +55,7 @@ export { RelayMasterKeySource, MasterKeyRelayExpired, MasterKeyRelayTimedOut } f
52
55
  export { createMasterKeyResolver } from './src/elements/master-key-acquisition';
53
56
  export type { MasterKeySource } from '@safetech/inheriti-core-sdk';
54
57
  export type { DeclaredMasterKeySource, MasterKeyAcquisitionOptions } from './src/elements/master-key-acquisition';
55
- export type { MasterKeyAcquisition, MasterKeyRelaySessionOpened, MasterKeyRelaySessionState } from './src/elements/elements-api-port';
58
+ export type { MasterKeyAcquisition, MasterKeyRelayContext, MasterKeyRelaySessionOpened, MasterKeyRelaySessionState } from './src/elements/elements-api-port';
56
59
  export type { MasterKeyRelayPort } from './src/elements/relay-master-key-source';
57
60
  // The guided-create path is the one a non-browser host drives itself, so the Node entry has to
58
61
  // carry it: the orchestration, the Core-backed material builder, and the contract types and
@@ -64,7 +67,7 @@ export type { CorePlanSecrets } from './src/elements/core-plan-material-builder'
64
67
  export { InvalidPlanDeclaration, InvalidPlanMaterial, PLAN_CREATION_SERVER_STAGES, validatePlanCreationInput, validatePlanCreationMaterial } from './src/elements/plan-operations';
65
68
  export type {
66
69
  EncryptedPlanMaterial, EncryptedPlanShard, GuidedCreateCheckpoint, GuidedCreateLocalStage, ListPlansInput,
67
- PlanCreationOutcome, PlanCreationProgress, PlanCreationServerStage, PlanDetail, PlanPage, StartPlanCreationInput,
70
+ PlanCreationOutcome, PlanCreationProgress, PlanCreationServerStage, PlanDetail, ListPlanLogsInput, PlanLog, PlanLogPage, PlanPage, StartPlanCreationInput,
68
71
  } from './src/elements/plan-operations';
69
72
  export { PassphraseMasterKeySource, RawMasterKeySource, deriveMasterKey, generateHexSeed, computePassphraseVerifier } from '@safetech/inheriti-core-sdk/node';
70
73
  export { PlanAssetDeclaration } from '@safetech/inheriti-core-sdk/node';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@safetech/inheriti-client-sdk",
3
- "version": "1.17.6",
3
+ "version": "1.17.7",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -42,7 +42,7 @@
42
42
  "license": "MIT",
43
43
  "dependencies": {
44
44
  "@safetech/safekey-sdk": "^1.0.0",
45
- "@safetech/inheriti-core-sdk": "4.0.21"
45
+ "@safetech/inheriti-core-sdk": "4.0.25"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@rollup/plugin-alias": "^5.1.1",
@@ -94,4 +94,4 @@
94
94
  "index.ts",
95
95
  "node.ts"
96
96
  ]
97
- }
97
+ }