@safetech/inheriti-client-sdk 1.17.2 → 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 (36) 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 +86 -83
  7. package/dist/node.d.ts +12 -3
  8. package/dist/node.js +1 -1
  9. package/dist/sdk-types.d.ts +711 -19
  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 +88 -3
  13. package/dist/src/elements/elements-client.d.ts +58 -12
  14. package/dist/src/elements/guided-plan-creator.d.ts +47 -0
  15. package/dist/src/elements/http-elements-api-port.d.ts +17 -1
  16. package/dist/src/elements/index.d.ts +10 -1
  17. package/dist/src/elements/plan-operation-codec.d.ts +4 -0
  18. package/dist/src/elements/plan-operations.d.ts +160 -0
  19. package/dist/src/elements/polling-shared-plan-event-listener.d.ts +29 -0
  20. package/dist/src/elements/reveal-session-operations.d.ts +13 -0
  21. package/dist/src/elements/scoped-reveal.d.ts +44 -0
  22. package/dist/src/operator-auth/defaults.d.ts +9 -0
  23. package/dist/src/operator-auth/errors.d.ts +11 -0
  24. package/dist/src/operator-auth/http-operator-auth-transport.d.ts +16 -0
  25. package/dist/src/operator-auth/index.d.ts +7 -0
  26. package/dist/src/operator-auth/operator-auth-client.d.ts +35 -0
  27. package/dist/src/operator-auth/operator-session-controller.d.ts +10 -0
  28. package/dist/src/operator-auth/ports.d.ts +53 -0
  29. package/dist/src/operator-auth/types.d.ts +77 -0
  30. package/docs/docs.json +18331 -0
  31. package/docs/elements-shared-mode.md +28 -0
  32. package/docs/operator-auth.md +76 -0
  33. package/docs/plan-operations.md +41 -0
  34. package/index.ts +1 -0
  35. package/node.ts +21 -4
  36. package/package.json +14 -3
@@ -0,0 +1,28 @@
1
+ # Elements shared mode
2
+
3
+ `ElementsClient` is the developer-facing facade over the Core SDK shared-configuration module. Supply an initialized
4
+ Core `SDKContainer`; browser hosts may use the normal shared module assembly, while Node hosts use
5
+ `createNodeSharedConfigurationSdk` from `@safetech/inheriti-core-sdk/node`.
6
+
7
+ ```ts
8
+ const client = createElementsClient({ coreSdk, applicationId, masterKeys });
9
+ const plan = await client.createPlan(input);
10
+ await client.configurePlan({ planId: plan.id, assets });
11
+ const material = await client.collectPlanMaterial(plan.id);
12
+ const reconstructedBytes = await client.reconstructPlanMaterial(material);
13
+ ```
14
+
15
+ `KeyVault` owns where the host keeps the required master key after relay. `StatePort` owns resumable process state.
16
+ Both default to isolated in-memory implementations and can be replaced by the host. Test-only implementations are
17
+ exported from `@safetech/inheriti-client-sdk/test`. Personal mode is intentionally not part of this facade.
18
+
19
+ The Node entry also supplies the authenticated Elements API collection adapter and the worker-thread SSDP-v2
20
+ reconstructor. `collectPlanMaterial` uses the narrow non-governed collection route: Vault and Chain shares are read
21
+ through the extracted package `SharesCollector`, while HSM reveals the protected plan key. The response lists the
22
+ verified storage-layer types so a host can require all three before reconstructing. Applications must have their
23
+ default storage spaces provisioned before the round trip.
24
+
25
+ The executable proof is `examples/elements-round-trip.mjs`. After building the SDK, provide
26
+ `ELEMENTS_API_URL`, `ELEMENTS_APPLICATION_ID`, and a scoped `ELEMENTS_BEARER_TOKEN`, then run
27
+ `yarn proof:elements-round-trip`. It compares the reconstructed secret with the input byte for byte. The manually
28
+ dispatched GitHub Actions workflow uses the same command and repository secrets; it is present but has not been run.
@@ -0,0 +1,76 @@
1
+ # Operator OAuth and sessions
2
+
3
+ `OperatorAuthClient` is the host-neutral OAuth facade for Elements integrations. It supports OIDC discovery,
4
+ authorization code with PKCE S256, RFC 8628 device authorization, validated bearer-token delivery, and rotating
5
+ refresh tokens. `OperatorSessionController` adds session inventory, logout, and revocation through an injected
6
+ Elements control-plane port.
7
+
8
+ ## Responsibility boundary
9
+
10
+ The SDK owns protocol state, callback validation, token binding checks, polling cadence, and in-process refresh
11
+ serialization. A host owns browser launch/callback handling, secure token and transaction persistence, the
12
+ cryptographic token validator, and any UI. This lets a Chrome extension, VS Code extension, CLI, or server-side
13
+ portal BFF use the same flow without the SDK importing browser, editor, terminal, or server frameworks.
14
+
15
+ The SDK never creates identity-provider clients and does not accept Account, Application, or actor identifiers.
16
+ The Elements API derives those from the validated operator session. SafeKey approval remains an external access
17
+ decision and is not an OAuth login method.
18
+
19
+ ## Minimal wiring
20
+
21
+ ```ts
22
+ import {
23
+ HttpOperatorAuthTransport,
24
+ OperatorAuthClient,
25
+ } from '@safetech/inheriti-client-sdk';
26
+
27
+ const auth = new OperatorAuthClient({
28
+ configuration: {
29
+ issuer: 'https://safeid.example/realms/elements-test',
30
+ clientId: 'registered-client-id',
31
+ audience: 'inheriti-elements-api',
32
+ environment: 'TEST',
33
+ redirectUri: 'http://127.0.0.1:3210/callback',
34
+ scopes: ['openid', 'profile', 'elements.plans.read'],
35
+ },
36
+ transport: new HttpOperatorAuthTransport(),
37
+ tokenValidator,
38
+ sessions: secureSessionStore,
39
+ transactions: secureTransactionStore,
40
+ });
41
+
42
+ const { authorizationUrl } = await auth.beginAuthorizationCode();
43
+ // The host opens authorizationUrl in the system browser and owns the callback listener.
44
+ const session = await auth.completeAuthorizationCode(callbackUrl);
45
+
46
+ // Give ElementsClient only the short-lived, validated access token.
47
+ const getBearerToken = () => auth.getAccessToken();
48
+ ```
49
+
50
+ `OperatorTokenValidator` must verify signatures and time claims before returning normalized metadata. The facade
51
+ then requires the exact issuer, resource audience, authorized client, and Elements environment before persisting
52
+ or returning the access token. Authorization-code completion additionally requires a validated ID token with the
53
+ original nonce and the same subject/session.
54
+
55
+ For a portal BFF, implement the stores and validator on the server and never serialize `OperatorSession` to the
56
+ browser. Confidential clients should inject an `OperatorAuthTransport` that applies their server-side client
57
+ authentication; `HttpOperatorAuthTransport` intentionally implements public-client requests and never accepts a
58
+ client secret.
59
+
60
+ ## Refresh and device guarantees
61
+
62
+ Refresh calls are single-flight inside one SDK instance. All concurrent callers share one request and therefore
63
+ consume a rotating refresh token once. `invalid_grant`, disabled/unauthorized client errors, expired refresh state,
64
+ or a missing rotated refresh token clear local state and require a new login. A CLI that runs multiple processes
65
+ must additionally place a host-level cross-process lock around access to its session store.
66
+
67
+ Device polling never runs faster than five seconds. `authorization_pending` preserves the interval, `slow_down`
68
+ adds five seconds, and polling ends before the authorization expiry. A successful transaction is consumed once.
69
+
70
+ ## Existing `connect` authentication
71
+
72
+ The existing `InheritiClientProvider`, `useClient`, Core SDK wildcard exports, and application-key `connect` flow
73
+ remain source-compatible in this release. They are legacy integration surfaces and are not operator OAuth
74
+ sessions. New Elements integrations should use `OperatorAuthClient`; existing consumers can migrate host by host
75
+ without changing their current imports. Removal or narrowing of legacy exports requires a separate major-version
76
+ migration and is outside this slice.
@@ -0,0 +1,41 @@
1
+ # Application plan operations
2
+
3
+ `ElementsClient` exposes the `elements.integration.v1` Application-scoped plan surface:
4
+
5
+ - `listPlans()` returns stable cursor pagination and metadata-only summaries.
6
+ - `getPlan()` returns non-secret metadata, opaque participant IDs, and explicit source compatibility values.
7
+ - `startPlanCreation()`, `getPlanCreation()`, `supplyPlanCreationMaterial()`, and `cancelPlanCreation()` map to the
8
+ resumable guided-create routes.
9
+ - `GuidedPlanCreator` validates declarations, reports local/server progress, persists a non-secret recovery
10
+ checkpoint, and requires secrets to be supplied again after restart.
11
+
12
+ No method accepts an Account, Application, actor, tenant, environment, or provider role. Those values come from the
13
+ validated operator token and are resolved by Elements. Participant email is routing data only.
14
+
15
+ Canonical asset types and structured field names are exported as `CANONICAL_PLAN_ASSET_TYPES` and
16
+ `CANONICAL_STRUCTURED_ASSET_FIELDS`. New writes reject unknown types, fields, URLs, or undeclared properties. Binary
17
+ assets are `{data: Uint8Array, fileName, mimeType}` at the local material-builder boundary; declarations send only
18
+ safe metadata. Media is never a URL and this SDK provides no preview behavior.
19
+
20
+ Read values that a newer server introduced are returned as `{kind: 'UNKNOWN', raw}` rather than silently coerced.
21
+ Unknown participant relationships are rejected because they could change authority.
22
+
23
+ ## Recovery boundary
24
+
25
+ The only durable SDK checkpoint fields are:
26
+
27
+ ```ts
28
+ interface GuidedCreateCheckpoint {
29
+ idempotencyKey: string;
30
+ operationId: string;
31
+ declarationHash: string;
32
+ serverStage: PlanCreationServerStage | {kind: 'UNKNOWN'; raw: string};
33
+ }
34
+ ```
35
+
36
+ Secrets, plaintext, media bytes, encrypted material, routing email, and provider errors are not checkpointed. The
37
+ host must store the checkpoint securely and re-supply local secret values before `resume()` can encrypt again.
38
+
39
+ Governed material completion is temporarily blocked by plan decision D017: the current v1 API has no unified,
40
+ idempotent validator-share plus final-material route. Do not bridge this by calling the legacy shared-plan validator
41
+ route from individual hosts.
package/index.ts CHANGED
@@ -7,3 +7,4 @@ 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 * from './src/operator-auth';
package/node.ts CHANGED
@@ -12,9 +12,9 @@ export interface NodeElementsClientOptions extends NodeSharedConfigurationSdkOpt
12
12
  keyVault?: KeyVault;
13
13
  state?: StatePort;
14
14
  /** Resolves master keys per plan reference; required to open non-custodial plans. */
15
- masterKeys?: MasterKeyResolver;
15
+ masterKeys: MasterKeyResolver;
16
16
  /** The Application this client acts for; needed to wrap keys of plans it creates. */
17
- applicationId?: string;
17
+ applicationId: string;
18
18
  }
19
19
 
20
20
  export function createNodeElementsClient(options: NodeElementsClientOptions): ElementsClient {
@@ -26,11 +26,13 @@ export function createNodeElementsClient(options: NodeElementsClientOptions): El
26
26
  };
27
27
  const coreSdk = createNodeSharedConfigurationSdk({ apiUrl: options.apiUrl, getBearerToken: options.getBearerToken, transport, workerUrl: options.workerUrl, reconciliationConcurrency: options.reconciliationConcurrency, eventListeners: options.eventListeners });
28
28
  const api = new HttpElementsApiPort(options.apiUrl, options.environment, options.getBearerToken, transport);
29
- return new ElementsClient(coreSdk, { keyVault: options.keyVault, state: options.state, api, reconstructor: new NodePlanMaterialReconstructor(), masterKeys: options.masterKeys, applicationId: options.applicationId });
29
+ return new ElementsClient(coreSdk, { keyVault: options.keyVault, state: options.state, api, reconstructor: new NodePlanMaterialReconstructor(), masterKeys: options.masterKeys, applicationId: options.applicationId, assetDecoder: decodeAssetContainer });
30
30
  }
31
31
 
32
32
  export { ElementsClient };
33
- export { ElementsApiRequestFailed } from './src/elements/http-elements-api-port';
33
+ // The API port itself, not only its error: a Node host that just reads plans wants this rather than
34
+ // the full client, and it must not reach the root barrel to get it — that barrel is React-flavoured.
35
+ export { default as HttpElementsApiPort, ElementsApiRequestFailed } from './src/elements/http-elements-api-port';
34
36
  export type { StepUpReadContext } from './src/elements/elements-api-port';
35
37
  export { MemoryKeyVault } from './src/elements/key-vault';
36
38
  export type { KeyVault } from './src/elements/key-vault';
@@ -41,6 +43,21 @@ export type { MasterKeyRef, MasterKeyResolver } from './src/elements/master-key'
41
43
  export { unwrapDekWithMasterKey } from './src/elements/unwrap-dek';
42
44
  export { RelayMasterKeySource, MasterKeyRelayExpired, MasterKeyRelayTimedOut } from './src/elements/relay-master-key-source';
43
45
  export type { MasterKeyRelayPort } from './src/elements/relay-master-key-source';
46
+ // The guided-create path is the one a non-browser host drives itself, so the Node entry has to
47
+ // carry it: the orchestration, the Core-backed material builder, and the contract types and
48
+ // validators a host needs to build material the API will accept.
49
+ export { GuidedPlanCreator, GuidedCreateRecoveryError, MemoryGuidedCreateCheckpointStore } from './src/elements/guided-plan-creator';
50
+ export type { GuidedCreateCheckpointStore, GuidedCreateOptions, PlanMaterialBuilder } from './src/elements/guided-plan-creator';
51
+ export { CorePlanMaterialBuilder } from './src/elements/core-plan-material-builder';
52
+ export type { CorePlanSecrets } from './src/elements/core-plan-material-builder';
53
+ export { InvalidPlanDeclaration, InvalidPlanMaterial, PLAN_CREATION_SERVER_STAGES, validatePlanCreationInput, validatePlanCreationMaterial } from './src/elements/plan-operations';
54
+ export type {
55
+ EncryptedPlanMaterial, EncryptedPlanShard, GuidedCreateCheckpoint, GuidedCreateLocalStage, ListPlansInput,
56
+ PlanCreationOutcome, PlanCreationProgress, PlanCreationServerStage, PlanDetail, PlanPage, StartPlanCreationInput,
57
+ } from './src/elements/plan-operations';
44
58
  export { PassphraseMasterKeySource, RawMasterKeySource, deriveMasterKey, generateHexSeed, computePassphraseVerifier } from '@safetech/inheriti-core-sdk/node';
59
+ export { PlanAssetDeclaration } from '@safetech/inheriti-core-sdk/node';
60
+ export type { PlanAssetDeclarationEntry, PlanAssetDeclarationInput } from '@safetech/inheriti-core-sdk/node';
45
61
  export type { MasterKeySource } from '@safetech/inheriti-core-sdk/node';
46
62
  export { decodeAssetContainer };
63
+ export * from './src/operator-auth';
package/package.json CHANGED
@@ -1,15 +1,21 @@
1
1
  {
2
2
  "name": "@safetech/inheriti-client-sdk",
3
- "version": "1.17.2",
3
+ "version": "1.17.3",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
7
+ "types": "./dist/sdk-types.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
+ "types": "./dist/sdk-types.d.ts",
10
11
  "import": "./dist/index.js",
11
12
  "require": "./dist/index.js"
12
13
  },
14
+ "./browser": {
15
+ "types": "./dist/browser.d.ts",
16
+ "import": "./dist/browser.js",
17
+ "require": "./dist/browser.js"
18
+ },
13
19
  "./test": {
14
20
  "import": "./dist/test/index.js",
15
21
  "require": "./dist/test/index.js"
@@ -26,6 +32,9 @@
26
32
  ],
27
33
  "node": [
28
34
  "dist/node.d.ts"
35
+ ],
36
+ "browser": [
37
+ "dist/browser.d.ts"
29
38
  ]
30
39
  }
31
40
  },
@@ -33,7 +42,7 @@
33
42
  "license": "MIT",
34
43
  "dependencies": {
35
44
  "@safetech/safekey-sdk": "^1.0.0",
36
- "@safetech/inheriti-core-sdk": "4.0.16"
45
+ "@safetech/inheriti-core-sdk": "4.0.17"
37
46
  },
38
47
  "devDependencies": {
39
48
  "@rollup/plugin-alias": "^5.1.1",
@@ -69,6 +78,7 @@
69
78
  },
70
79
  "scripts": {
71
80
  "build": "node esbuild.config.js",
81
+ "test": "vitest run",
72
82
  "prepublishOnly": "node esbuild.config.js",
73
83
  "publish-version": "node scripts/publish-sdk-version.js",
74
84
  "add-patch": "node scripts/bump-version.js patch",
@@ -80,6 +90,7 @@
80
90
  "dist",
81
91
  "README.md",
82
92
  "LICENSE",
93
+ "docs",
83
94
  "index.ts",
84
95
  "node.ts"
85
96
  ]