@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
|
@@ -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
package/node.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { NodeSharedConfigurationSdkOptions } from '@safetech/inheriti-core-
|
|
|
3
3
|
import ElementsClient from './src/elements/elements-client';
|
|
4
4
|
import type { KeyVault } from './src/elements/key-vault';
|
|
5
5
|
import type { MasterKeyResolver } from './src/elements/master-key';
|
|
6
|
+
import type { ElementsClientOptions } from './src/elements/elements-client';
|
|
6
7
|
import type { StatePort } from './src/elements/state-port';
|
|
7
8
|
import HttpElementsApiPort from './src/elements/http-elements-api-port';
|
|
8
9
|
import NodePlanMaterialReconstructor from './src/elements/node-plan-material-reconstructor';
|
|
@@ -11,10 +12,16 @@ export interface NodeElementsClientOptions extends NodeSharedConfigurationSdkOpt
|
|
|
11
12
|
environment: 'TEST' | 'LIVE';
|
|
12
13
|
keyVault?: KeyVault;
|
|
13
14
|
state?: StatePort;
|
|
14
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Resolves master keys per plan reference. A host that composes its own custody passes this;
|
|
17
|
+
* one that only declares what it holds passes `masterKey` instead and lets the client compose
|
|
18
|
+
* acquisition — including asking the device that holds the key.
|
|
19
|
+
*/
|
|
15
20
|
masterKeys?: MasterKeyResolver;
|
|
21
|
+
/** What custody this host holds locally. See `ElementsClientOptions['masterKey']`. */
|
|
22
|
+
masterKey?: ElementsClientOptions['masterKey'];
|
|
16
23
|
/** The Application this client acts for; needed to wrap keys of plans it creates. */
|
|
17
|
-
applicationId
|
|
24
|
+
applicationId: string;
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
export function createNodeElementsClient(options: NodeElementsClientOptions): ElementsClient {
|
|
@@ -26,11 +33,13 @@ export function createNodeElementsClient(options: NodeElementsClientOptions): El
|
|
|
26
33
|
};
|
|
27
34
|
const coreSdk = createNodeSharedConfigurationSdk({ apiUrl: options.apiUrl, getBearerToken: options.getBearerToken, transport, workerUrl: options.workerUrl, reconciliationConcurrency: options.reconciliationConcurrency, eventListeners: options.eventListeners });
|
|
28
35
|
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 });
|
|
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 });
|
|
30
37
|
}
|
|
31
38
|
|
|
32
39
|
export { ElementsClient };
|
|
33
|
-
|
|
40
|
+
// The API port itself, not only its error: a Node host that just reads plans wants this rather than
|
|
41
|
+
// the full client, and it must not reach the root barrel to get it — that barrel is React-flavoured.
|
|
42
|
+
export { default as HttpElementsApiPort, ElementsApiRequestFailed } from './src/elements/http-elements-api-port';
|
|
34
43
|
export type { StepUpReadContext } from './src/elements/elements-api-port';
|
|
35
44
|
export { MemoryKeyVault } from './src/elements/key-vault';
|
|
36
45
|
export type { KeyVault } from './src/elements/key-vault';
|
|
@@ -40,7 +49,26 @@ export { MasterKeyRequired, StaticMasterKeyResolver, masterKeyRefFor, masterKeyR
|
|
|
40
49
|
export type { MasterKeyRef, MasterKeyResolver } from './src/elements/master-key';
|
|
41
50
|
export { unwrapDekWithMasterKey } from './src/elements/unwrap-dek';
|
|
42
51
|
export { RelayMasterKeySource, MasterKeyRelayExpired, MasterKeyRelayTimedOut } from './src/elements/relay-master-key-source';
|
|
52
|
+
export { createMasterKeyResolver } from './src/elements/master-key-acquisition';
|
|
53
|
+
export type { MasterKeySource } from '@safetech/inheriti-core-sdk';
|
|
54
|
+
export type { DeclaredMasterKeySource, MasterKeyAcquisitionOptions } from './src/elements/master-key-acquisition';
|
|
55
|
+
export type { MasterKeyAcquisition, MasterKeyRelaySessionOpened, MasterKeyRelaySessionState } from './src/elements/elements-api-port';
|
|
43
56
|
export type { MasterKeyRelayPort } from './src/elements/relay-master-key-source';
|
|
57
|
+
// The guided-create path is the one a non-browser host drives itself, so the Node entry has to
|
|
58
|
+
// carry it: the orchestration, the Core-backed material builder, and the contract types and
|
|
59
|
+
// validators a host needs to build material the API will accept.
|
|
60
|
+
export { GuidedPlanCreator, GuidedCreateRecoveryError, MemoryGuidedCreateCheckpointStore } from './src/elements/guided-plan-creator';
|
|
61
|
+
export type { GuidedCreateCheckpointStore, GuidedCreateOptions, PlanMaterialBuilder } from './src/elements/guided-plan-creator';
|
|
62
|
+
export { CorePlanMaterialBuilder } from './src/elements/core-plan-material-builder';
|
|
63
|
+
export type { CorePlanSecrets } from './src/elements/core-plan-material-builder';
|
|
64
|
+
export { InvalidPlanDeclaration, InvalidPlanMaterial, PLAN_CREATION_SERVER_STAGES, validatePlanCreationInput, validatePlanCreationMaterial } from './src/elements/plan-operations';
|
|
65
|
+
export type {
|
|
66
|
+
EncryptedPlanMaterial, EncryptedPlanShard, GuidedCreateCheckpoint, GuidedCreateLocalStage, ListPlansInput,
|
|
67
|
+
PlanCreationOutcome, PlanCreationProgress, PlanCreationServerStage, PlanDetail, PlanPage, StartPlanCreationInput,
|
|
68
|
+
} from './src/elements/plan-operations';
|
|
44
69
|
export { PassphraseMasterKeySource, RawMasterKeySource, deriveMasterKey, generateHexSeed, computePassphraseVerifier } from '@safetech/inheriti-core-sdk/node';
|
|
70
|
+
export { PlanAssetDeclaration } from '@safetech/inheriti-core-sdk/node';
|
|
71
|
+
export type { PlanAssetDeclarationEntry, PlanAssetDeclarationInput } from '@safetech/inheriti-core-sdk/node';
|
|
45
72
|
export type { MasterKeySource } from '@safetech/inheriti-core-sdk/node';
|
|
46
73
|
export { decodeAssetContainer };
|
|
74
|
+
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.
|
|
3
|
+
"version": "1.17.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
|
-
"types": "./dist/
|
|
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.
|
|
45
|
+
"@safetech/inheriti-core-sdk": "4.0.19"
|
|
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
|
]
|