@xkova/sdk 0.1.0-alpha.7 → 0.1.0-alpha.9

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.
@@ -0,0 +1,34 @@
1
+ import { Resource, type ReqBody } from './base.js';
2
+ import type { XKOVAMutationOptions } from '../client.js';
3
+ /** Current workforce human's canonical wallet, never selected by browser identity. */
4
+ export declare class WorkforceWalletsResource extends Resource {
5
+ list(): Promise<{
6
+ data?: import("../generated/types.js").components["schemas"]["StaffMpcWallet"][];
7
+ }>;
8
+ /** Fresh exact human proof is required before a provider admission can be issued. */
9
+ provision(options?: XKOVAMutationOptions): Promise<{
10
+ mpc_wallet: import("../generated/types.js").components["schemas"]["StaffMpcWallet"];
11
+ wallet_auth: import("../generated/types.js").components["schemas"]["WalletAdmissionBootstrap"];
12
+ challenge: {
13
+ challenge_id: string;
14
+ nonce: string;
15
+ typed_data: import("../generated/types.js").components["schemas"]["StaffMpcEnrollmentTypedData"];
16
+ expires_at: string;
17
+ };
18
+ }>;
19
+ /** Activate only after signing the API's exact one-time enrollment typed data. */
20
+ register(body: ReqBody<'workforceWalletRegister'>, options?: XKOVAMutationOptions): Promise<{
21
+ id: import("../generated/types.js").components["schemas"]["StaffMpcWalletId"];
22
+ staff_id: import("../generated/types.js").components["schemas"]["StaffId"];
23
+ address: string | null;
24
+ state: "pending_provisioning" | "active" | "decommissioned";
25
+ provider_resolution: "pending" | "resolved" | "review_required";
26
+ created_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
27
+ updated_at: import("../generated/types.js").components["schemas"]["TimestampUtc"];
28
+ }>;
29
+ /** Binds one ceremony to the current resource's frozen Safe digest and nonce. */
30
+ signingBootstrap(body: ReqBody<'workforceWalletSigningBootstrap'>, options?: XKOVAMutationOptions): Promise<{
31
+ mpc_wallet: import("../generated/types.js").components["schemas"]["StaffMpcWallet"];
32
+ wallet_auth: import("../generated/types.js").components["schemas"]["WalletAdmissionBootstrap"];
33
+ }>;
34
+ }
@@ -0,0 +1,19 @@
1
+ import { Resource } from './base.js';
2
+ /** Current workforce human's canonical wallet, never selected by browser identity. */
3
+ export class WorkforceWalletsResource extends Resource {
4
+ list() {
5
+ return this.getJson('/workforce-auth/me/wallets');
6
+ }
7
+ /** Fresh exact human proof is required before a provider admission can be issued. */
8
+ provision(options) {
9
+ return this.postJson('/workforce-auth/me/wallets/provision', undefined, options);
10
+ }
11
+ /** Activate only after signing the API's exact one-time enrollment typed data. */
12
+ register(body, options) {
13
+ return this.postJson('/workforce-auth/me/wallets/register', body, options);
14
+ }
15
+ /** Binds one ceremony to the current resource's frozen Safe digest and nonce. */
16
+ signingBootstrap(body, options) {
17
+ return this.postJson('/workforce-auth/me/wallets/signing-bootstrap', body, options);
18
+ }
19
+ }
@@ -0,0 +1,202 @@
1
+ import { type XKOVAClientOptions } from './client.js';
2
+ import { WorkforceWalletsResource } from './resources/workforce-wallets.js';
3
+ export { serializeXKOVAMemberSessionCookie as serializeXKOVAWorkforceSessionCookie, serializeXKOVAMemberFlowCookie as serializeXKOVAWorkforceFlowCookie, serializeClearedXKOVAMemberCookie as serializeClearedXKOVAWorkforceCookie, readXKOVAMemberCookie as readXKOVAWorkforceCookie, readXKOVAMemberCallbackFlow as readXKOVAWorkforceCallbackFlow, xkovaMemberFlowCookieName as xkovaWorkforceFlowCookieName, createXKOVAMemberCsrfToken as createXKOVAWorkforceCsrfToken, verifyXKOVAMemberCsrfToken as verifyXKOVAWorkforceCsrfToken, assertXKOVAMemberRequestOrigin as assertXKOVAWorkforceRequestOrigin, } from './member-bff.js';
4
+ export interface XKOVAWorkforceBffClientOptions extends XKOVAClientOptions {
5
+ /** Exact nonsecret workforce registration selector. This is not a member selector. */
6
+ readonly workforceKey: string;
7
+ }
8
+ export interface XKOVAWorkforceSession {
9
+ readonly session_id: string;
10
+ readonly application_id: string;
11
+ readonly staff_id: string;
12
+ readonly person_id: string;
13
+ readonly tenant_id: string;
14
+ readonly workspace_id: string;
15
+ readonly provider_namespace: string;
16
+ readonly provider_subject: string;
17
+ readonly roles: readonly string[];
18
+ readonly scopes: readonly string[];
19
+ readonly resource_grants: {
20
+ readonly treasury_wallet_ids: readonly string[];
21
+ readonly customer_token_ids: readonly string[];
22
+ };
23
+ readonly action_authorization_enabled: boolean;
24
+ readonly expires_at: string;
25
+ readonly absolute_expires_at: string;
26
+ }
27
+ export interface XKOVAWorkforceSessionMaterial {
28
+ readonly session_token: string;
29
+ readonly refresh_token: string;
30
+ readonly refresh_attempt_token: string;
31
+ readonly session: XKOVAWorkforceSession;
32
+ }
33
+ export interface XKOVAWorkforceActionReview {
34
+ readonly operation: string;
35
+ readonly proof_method: string;
36
+ readonly review: Readonly<Record<string, unknown>>;
37
+ readonly review_digest: string;
38
+ readonly expires_at: string;
39
+ }
40
+ export interface XKOVAWorkforceActionChallenge {
41
+ readonly nonce: string;
42
+ readonly issuer: string;
43
+ readonly audience: string;
44
+ readonly authorization_endpoint: string;
45
+ readonly max_auth_age_seconds: number;
46
+ readonly required_acr_values: readonly string[];
47
+ readonly required_amr_values: readonly string[];
48
+ readonly expires_at: string;
49
+ readonly review: Readonly<Record<string, unknown>>;
50
+ readonly review_digest: string;
51
+ }
52
+ /** Confidential, one-use authority for the unchanged reviewed request only. */
53
+ export interface XKOVAWorkforceActionGrant {
54
+ readonly grant_token: string;
55
+ readonly expires_at: string;
56
+ }
57
+ export interface StoredXKOVAWorkforceSession<T = unknown> {
58
+ readonly clientFingerprint: string;
59
+ readonly authorizationCodeHash: string;
60
+ readonly material: XKOVAWorkforceSessionMaterial;
61
+ readonly applicationExpiresAt: number;
62
+ readonly applicationData: T;
63
+ /** Persist before remote logout. It permanently blocks refresh and resource resolution. */
64
+ readonly logoutPending?: boolean;
65
+ }
66
+ /**
67
+ * Encrypt credentials and proofs at rest. All writes commit before resolving,
68
+ * independently of later callback errors. replace is exact-existing-only.
69
+ * runExclusive serializes the same record across every BFF replica. It is not
70
+ * a surrounding rollback transaction. Use separate transaction/session stores.
71
+ */
72
+ export interface XKOVAWorkforceStore<T> {
73
+ put(reference: string, value: T): Promise<void>;
74
+ get(reference: string): Promise<T | null>;
75
+ replace(reference: string, value: T): Promise<void>;
76
+ delete(reference: string): Promise<void>;
77
+ runExclusive<R>(reference: string, work: () => Promise<R>): Promise<R>;
78
+ }
79
+ export interface XKOVAWorkforceAuthorizationTransaction<T = unknown> {
80
+ readonly clientFingerprint: string;
81
+ readonly status: 'pending' | 'completed';
82
+ readonly redirectUri: string;
83
+ readonly codeVerifier: string;
84
+ readonly codeChallenge: string;
85
+ readonly exchangeAttemptId: string;
86
+ readonly sessionReference: string;
87
+ readonly expiresAt: number;
88
+ readonly transactionId?: string;
89
+ readonly nonce?: string;
90
+ readonly issuer?: string;
91
+ readonly audience?: string;
92
+ /** Written before the one-use provider call. An unknown result is never redeemed again. */
93
+ readonly providerExchangeStarted?: {
94
+ readonly codeHash: string;
95
+ readonly applicationData: T;
96
+ };
97
+ readonly stagedProofToken?: string;
98
+ }
99
+ export declare class XKOVAWorkforceBffError extends Error {
100
+ readonly code: 'transaction_unavailable' | 'binding_mismatch' | 'provider_exchange_outcome_unknown' | 'session_unavailable';
101
+ constructor(code: 'transaction_unavailable' | 'binding_mismatch' | 'provider_exchange_outcome_unknown' | 'session_unavailable');
102
+ }
103
+ /** Confidential workforce protocol. It neither enrolls a subject nor creates local staff authority. */
104
+ export declare class XKOVAWorkforceBffClient {
105
+ private readonly options;
106
+ private readonly client;
107
+ private readonly fingerprint;
108
+ constructor(options: XKOVAWorkforceBffClientOptions);
109
+ beginAuthorization<T>(input: {
110
+ browserOrigin: string;
111
+ redirectUri: string;
112
+ transactionStore: XKOVAWorkforceStore<XKOVAWorkforceAuthorizationTransaction<T>>;
113
+ }): Promise<{
114
+ state: string;
115
+ nonce: string;
116
+ redirectUri: string;
117
+ codeChallenge: string;
118
+ codeChallengeMethod: "S256";
119
+ issuer: string;
120
+ audience: string;
121
+ authorizationEndpoint: string;
122
+ maxAuthAgeSeconds: number;
123
+ requiredAcrValues: string[];
124
+ expiresAt: string;
125
+ }>;
126
+ completeAuthorizationCallback<T>(input: {
127
+ callbackUrl: string;
128
+ /** Read from the genuine initiating browser's HttpOnly flow cookie. */
129
+ expectedState: string;
130
+ transactionStore: XKOVAWorkforceStore<XKOVAWorkforceAuthorizationTransaction<T>>;
131
+ sessionStore: XKOVAWorkforceStore<StoredXKOVAWorkforceSession<T>>;
132
+ applicationData: T;
133
+ /** Perform the provider's real code exchange and signature/nonce checks server-side. */
134
+ exchangeProviderCode: (input: {
135
+ code: string;
136
+ codeVerifier: string;
137
+ redirectUri: string;
138
+ expectedNonce: string;
139
+ issuer: string;
140
+ audience: string;
141
+ }) => Promise<{
142
+ proofToken: string;
143
+ }>;
144
+ }): Promise<{
145
+ reference: string;
146
+ session: StoredXKOVAWorkforceSession<T>;
147
+ }>;
148
+ getSession(sessionToken: string): Promise<XKOVAWorkforceSession>;
149
+ resolveSession<T>(input: {
150
+ reference: string;
151
+ sessionStore: XKOVAWorkforceStore<StoredXKOVAWorkforceSession<T>>;
152
+ }): Promise<StoredXKOVAWorkforceSession<T> | null>;
153
+ /** Request-scoped resources only. Check the browser's Origin/CSRF before invoking writes. */
154
+ resolveResources<T>(input: {
155
+ reference: string;
156
+ sessionStore: XKOVAWorkforceStore<StoredXKOVAWorkforceSession<T>>;
157
+ browserOrigin: string;
158
+ /** Keep the API-issued grant on the server and repeat only its frozen request. */
159
+ actionGrant?: XKOVAWorkforceActionGrant;
160
+ }): Promise<{
161
+ session: StoredXKOVAWorkforceSession<T>;
162
+ resources: {
163
+ treasury: import("./resources/treasury.js").TreasuryResource;
164
+ tokenization: import("./resources/index.js").TokenizationResource;
165
+ wallets: WorkforceWalletsResource;
166
+ };
167
+ } | null>;
168
+ /** Review the locator returned by human_authorization_required. Never send it to a third-party host. */
169
+ inspectAction(input: {
170
+ authorizationToken: string;
171
+ sessionToken: string;
172
+ browserOrigin: string;
173
+ }): Promise<XKOVAWorkforceActionReview>;
174
+ /** Starts a real provider ceremony after the user reviews the exact request. No action is executed. */
175
+ beginActionProof(input: {
176
+ authorizationToken: string;
177
+ sessionToken: string;
178
+ browserOrigin: string;
179
+ }): Promise<XKOVAWorkforceActionChallenge>;
180
+ /** Submit the real, freshly verified provider token. A lost response is never automatically retried. */
181
+ completeActionProof(input: {
182
+ authorizationToken: string;
183
+ sessionToken: string;
184
+ browserOrigin: string;
185
+ nonce: string;
186
+ proofToken: string;
187
+ }): Promise<XKOVAWorkforceActionGrant>;
188
+ logoutSession<T>(input: {
189
+ reference: string;
190
+ sessionStore: XKOVAWorkforceStore<StoredXKOVAWorkforceSession<T>>;
191
+ }): Promise<void>;
192
+ private assertSession;
193
+ private postJson;
194
+ private getJson;
195
+ }
196
+ /** Advisory browser UI data only; provider identity, credentials and grants stay confidential. */
197
+ export declare function projectXKOVAWorkforceSession(value: StoredXKOVAWorkforceSession): {
198
+ signedIn: true;
199
+ staffId: string;
200
+ roles: string[];
201
+ expiresAt: string;
202
+ };