@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,44 @@
1
+ import type ElementsClient from './elements-client';
2
+ import type { 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
+ origin?: string;
10
+ idempotencyKey?: string;
11
+ }
12
+ export interface OpenRevealOptions {
13
+ mode?: RevealMode;
14
+ idempotencyKey?: string;
15
+ signal?: AbortSignal;
16
+ pollIntervalMs?: number;
17
+ onSession?: (session: RevealSession) => void;
18
+ }
19
+ export interface RevealHandle {
20
+ readonly session: RevealSession;
21
+ readonly material: Uint8Array;
22
+ readonly closed: boolean;
23
+ field<TValue = unknown>(selector: AssetFieldSelector, options?: RevealFieldOptions): Promise<TValue>;
24
+ close(reason?: RevealCloseReason): Promise<void>;
25
+ [Symbol.asyncDispose](): Promise<void>;
26
+ }
27
+ export declare class RevealHandleClosed extends Error {
28
+ readonly code = "reveal_handle_closed";
29
+ constructor();
30
+ }
31
+ export declare class RevealFieldAccessError extends Error {
32
+ readonly code: 'asset_selector_invalid' | 'asset_not_found' | 'asset_field_not_found' | 'action_not_allowed' | 'asset_decoder_required' | 'asset_value_invalid';
33
+ constructor(code: 'asset_selector_invalid' | 'asset_not_found' | 'asset_field_not_found' | 'action_not_allowed' | 'asset_decoder_required' | 'asset_value_invalid');
34
+ }
35
+ export declare function openScopedReveal(client: ElementsClient, planId: string, options?: OpenRevealOptions): Promise<RevealHandle>;
36
+ export declare class RevealAuthorizationEnded extends Error {
37
+ readonly stage: RevealSession['stage'];
38
+ readonly code = "reveal_authorization_ended";
39
+ constructor(stage: RevealSession['stage']);
40
+ }
41
+ export declare function parseAssetFieldSelector(selector: AssetFieldSelector): {
42
+ asset: string;
43
+ field: string;
44
+ };
@@ -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,7 @@
1
+ export * from './defaults';
2
+ export * from './errors';
3
+ export * from './http-operator-auth-transport';
4
+ export * from './operator-auth-client';
5
+ export * from './operator-session-controller';
6
+ export type * from './ports';
7
+ export type * from './types';
@@ -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
+ }