@shuttle.technology/authorization 0.0.0-stage → 0.1.0
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 +708 -2
- package/dist/aesGcmSiv.d.ts +14 -0
- package/dist/aesGcmSiv.js +160 -0
- package/dist/auth.d.ts +68 -0
- package/dist/auth.js +215 -0
- package/dist/balances.d.ts +31 -0
- package/dist/balances.js +44 -0
- package/dist/canonicalize.d.ts +19 -0
- package/dist/canonicalize.js +107 -0
- package/dist/client.d.ts +264 -0
- package/dist/client.js +754 -0
- package/dist/deviceKey.d.ts +13 -0
- package/dist/deviceKey.js +28 -0
- package/dist/deviceShare.d.ts +9 -0
- package/dist/deviceShare.js +24 -0
- package/dist/deviceShareEnvelope.d.ts +13 -0
- package/dist/deviceShareEnvelope.js +139 -0
- package/dist/linkedChecks.d.ts +17 -0
- package/dist/linkedChecks.js +31 -0
- package/dist/linkedSendDisplay.d.ts +73 -0
- package/dist/linkedSendDisplay.js +84 -0
- package/dist/linkedWalletSignals.d.ts +22 -0
- package/dist/linkedWalletSignals.js +101 -0
- package/dist/linkedWallets.d.ts +373 -0
- package/dist/linkedWallets.js +471 -0
- package/dist/mediatedOperation.d.ts +27 -0
- package/dist/mediatedOperation.js +68 -0
- package/dist/modeC.d.ts +131 -0
- package/dist/modeC.js +248 -0
- package/dist/modeCLinked.d.ts +207 -0
- package/dist/modeCLinked.js +270 -0
- package/dist/pages.d.ts +22 -0
- package/dist/pages.js +45 -0
- package/dist/poll.d.ts +15 -0
- package/dist/poll.js +76 -0
- package/dist/requestGrant.d.ts +169 -0
- package/dist/requestGrant.js +243 -0
- package/dist/sends.d.ts +89 -0
- package/dist/sends.js +127 -0
- package/dist/slice4.d.ts +173 -0
- package/dist/slice4.js +285 -0
- package/dist/streams.d.ts +212 -0
- package/dist/streams.js +282 -0
- package/dist/trackedWallets.d.ts +53 -0
- package/dist/trackedWallets.js +104 -0
- package/dist/transferStatus.d.ts +45 -0
- package/dist/transferStatus.js +43 -0
- package/dist/walletDisplayParts.d.ts +15 -0
- package/dist/walletDisplayParts.js +43 -0
- package/dist/walletEvents.d.ts +43 -0
- package/dist/walletEvents.js +97 -0
- package/dist/walletLimits.d.ts +65 -0
- package/dist/walletLimits.js +102 -0
- package/dist/walletOperations.d.ts +192 -0
- package/dist/walletOperations.js +308 -0
- package/package.json +64 -4
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { type ClientChannel, type IdentityMethod } from "./auth.ts";
|
|
2
|
+
import { type AccountIdentity, type ConfirmationChallenge, type HostedIdentityFlow, type IdentityVerificationMethod, type LocalOperation, type LocalOperationCreate, type LocalOperationResult, type PasskeyBootstrapResult, type ServiceReadScope, type VerifiedIdentityResult } from "./slice4.ts";
|
|
3
|
+
import { StreamsReads } from "./streams.ts";
|
|
4
|
+
import { LinkedWallets } from "./linkedWallets.ts";
|
|
5
|
+
export { LinkedWallets, eventOfTransaction, isWalletLimitRefusal, resumeCursor, sendEvents, transferFinal, WalletLimitRefusals } from "./linkedWallets.ts";
|
|
6
|
+
export type { AssetBalance, LinkedWalletBalances, NetworkBalanceStatus, NetworkBalances, ListedSend, SendPage, TransferOutcome, TransferState, TransferStatus, WalletConnection, LinkedWallet, WalletLinkChallenge, WalletLinkAssertion, LinkedRegistrationCreate, LinkedRegistrationOperation, LinkedRegistrationDisplay, LinkedRegistrationPurgedDisplay, LinkedRegistrationResult, LinkedRegistrationListOptions, LinkedEventsOptions, LinkedStreamsRegistration, LinkedStreamsRegistrationList, LinkedSendInput, LinkedReplaceInput, LinkedSendDisplay, ReplaceAction, LinkedTransportKey, LimitAsset, WalletCeiling, WalletLimitRefusal, WalletLimits, WalletLimitsDisplay, WalletLimitsInput } from "./linkedWallets.ts";
|
|
7
|
+
import { type UserWalletOperation, type UserWalletOperationCreate, type WalletResult } from "./walletOperations.ts";
|
|
8
|
+
import { type PageOptions } from "./pages.ts";
|
|
9
|
+
export type { PageOptions } from "./pages.ts";
|
|
10
|
+
export { AuthorizationError, ClientFlowError } from "./auth.ts";
|
|
11
|
+
export type { AuthIntent, ClientChannel, IdentityMethod, NextAction } from "./auth.ts";
|
|
12
|
+
export { pollAuthoritative } from "./poll.ts";
|
|
13
|
+
export type { PollDisposition, PollOptions, PollResult } from "./poll.ts";
|
|
14
|
+
export type { AccountIdentity, ConfirmationChallenge, HostedIdentityFlow, IdentityVerificationMethod, LocalOperation, LocalOperationCreate, LocalOperationResult, PasskeyBootstrapResult, ResultRecipient, ServiceReadScope, VerifiedIdentityResult, } from "./slice4.ts";
|
|
15
|
+
export { MaxTransferCommentBytes, MaxWalletMessageBytes, ReplaceActions, transferComment, walletMaterialPurged } from "./walletOperations.ts";
|
|
16
|
+
export type { UserWalletAuthorizationBasis, UserWalletDisplay, UserWalletEffectState, UserWalletOperation, UserWalletOperationCreate, UserWalletOperationKind, UserWalletPurgedDisplay, UserWalletState, WalletResult, WalletResultKind, } from "./walletOperations.ts";
|
|
17
|
+
export interface ClientConfiguration {
|
|
18
|
+
mode: "mode_b";
|
|
19
|
+
channel: ClientChannel;
|
|
20
|
+
authorizationOrigin: string;
|
|
21
|
+
applicationOrigin?: string;
|
|
22
|
+
redirectUri: string;
|
|
23
|
+
publishableClientId: string;
|
|
24
|
+
tenantId: string;
|
|
25
|
+
applicationId: string;
|
|
26
|
+
environmentId: string;
|
|
27
|
+
methods: readonly IdentityMethod[];
|
|
28
|
+
mobileApplicationIdentifier?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface PublicClientConfiguration {
|
|
31
|
+
requestId: string;
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
environmentId: string;
|
|
35
|
+
methods: readonly IdentityMethod[];
|
|
36
|
+
providerOrigin: string;
|
|
37
|
+
rpId: string;
|
|
38
|
+
redirects: readonly string[];
|
|
39
|
+
platform: ClientChannel;
|
|
40
|
+
}
|
|
41
|
+
export interface FetchRequest {
|
|
42
|
+
url: string;
|
|
43
|
+
method?: string;
|
|
44
|
+
headers?: Record<string, string>;
|
|
45
|
+
body?: string;
|
|
46
|
+
credentials?: "include" | "omit";
|
|
47
|
+
cache?: "no-store";
|
|
48
|
+
signal?: AbortSignal;
|
|
49
|
+
}
|
|
50
|
+
export interface FetchResponse {
|
|
51
|
+
status: number;
|
|
52
|
+
ok: boolean;
|
|
53
|
+
json(): Promise<unknown>;
|
|
54
|
+
/** The answer as it arrives and its headers; only a signal stream reads them. */
|
|
55
|
+
body?: ReadableStream<Uint8Array> | null;
|
|
56
|
+
headers?: {
|
|
57
|
+
get(name: string): string | null;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export type FetchLike = (url: string, init?: Omit<FetchRequest, "url">) => Promise<FetchResponse>;
|
|
61
|
+
export interface MobileSecureStorage {
|
|
62
|
+
get(key: string): Promise<string | null>;
|
|
63
|
+
set(key: string, value: string): Promise<void>;
|
|
64
|
+
delete(key: string): Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
export interface MobileAssociationInput {
|
|
67
|
+
redirectUri: string;
|
|
68
|
+
applicationIdentifier: string;
|
|
69
|
+
}
|
|
70
|
+
export interface MobileAssociationVerification {
|
|
71
|
+
source: "os_verified_https_association";
|
|
72
|
+
redirectUri: string;
|
|
73
|
+
applicationIdentifier: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Host/native trust boundary. Implementations must ask the operating system to
|
|
77
|
+
* verify the configured HTTPS app/universal-link association. This result is a
|
|
78
|
+
* port contract, not cryptographic proof produced by this TypeScript package.
|
|
79
|
+
*/
|
|
80
|
+
export interface MobileBrowserBridge {
|
|
81
|
+
verifyAssociatedRedirect(input: MobileAssociationInput): Promise<MobileAssociationVerification | null>;
|
|
82
|
+
openSystemBrowser(url: string): Promise<void> | void;
|
|
83
|
+
}
|
|
84
|
+
interface CommonDependencies {
|
|
85
|
+
fetch?: FetchLike;
|
|
86
|
+
crypto?: Crypto;
|
|
87
|
+
now?: () => number;
|
|
88
|
+
}
|
|
89
|
+
export interface WebDependencies extends CommonDependencies {
|
|
90
|
+
currentOrigin: () => string;
|
|
91
|
+
/**
|
|
92
|
+
* Opens a separate top-level browsing context. Restore requires the host to
|
|
93
|
+
* return the final registered app redirect while this caller stays alive so
|
|
94
|
+
* its state and PKCE verifier remain only in memory.
|
|
95
|
+
*/
|
|
96
|
+
openHosted: (url: string) => Promise<string | void> | string | void;
|
|
97
|
+
}
|
|
98
|
+
export interface MobileDependencies extends CommonDependencies {
|
|
99
|
+
browserBridge: MobileBrowserBridge;
|
|
100
|
+
secureStorage: MobileSecureStorage;
|
|
101
|
+
}
|
|
102
|
+
export type ClientDependencies = WebDependencies | MobileDependencies;
|
|
103
|
+
export interface AuthAttempt {
|
|
104
|
+
requestId: string;
|
|
105
|
+
attemptId: string;
|
|
106
|
+
launchUrl: string;
|
|
107
|
+
expiresAt: number;
|
|
108
|
+
}
|
|
109
|
+
export interface Session {
|
|
110
|
+
requestId: string;
|
|
111
|
+
accessExpiresAt: number;
|
|
112
|
+
accountId: string;
|
|
113
|
+
sessionId: string;
|
|
114
|
+
setupRequired?: boolean;
|
|
115
|
+
}
|
|
116
|
+
export interface MeProjection {
|
|
117
|
+
requestId: string;
|
|
118
|
+
account: {
|
|
119
|
+
accountId: string;
|
|
120
|
+
version: string;
|
|
121
|
+
setupRequired: boolean;
|
|
122
|
+
};
|
|
123
|
+
sessionId: string;
|
|
124
|
+
serverTime: number;
|
|
125
|
+
}
|
|
126
|
+
export interface SessionProjection {
|
|
127
|
+
requestId: string;
|
|
128
|
+
items: Array<{
|
|
129
|
+
sessionId: string;
|
|
130
|
+
clientId: string;
|
|
131
|
+
state: string;
|
|
132
|
+
createdAt: string;
|
|
133
|
+
expiresAt: string;
|
|
134
|
+
current: boolean;
|
|
135
|
+
}>;
|
|
136
|
+
hasMore: boolean;
|
|
137
|
+
nextCursor?: string;
|
|
138
|
+
}
|
|
139
|
+
export interface WalletProjection {
|
|
140
|
+
requestId: string;
|
|
141
|
+
items: Array<{
|
|
142
|
+
walletId: string;
|
|
143
|
+
network: string;
|
|
144
|
+
address: string;
|
|
145
|
+
state: string;
|
|
146
|
+
generation: string;
|
|
147
|
+
mappingVersion: string;
|
|
148
|
+
}>;
|
|
149
|
+
hasMore: boolean;
|
|
150
|
+
nextCursor?: string;
|
|
151
|
+
}
|
|
152
|
+
type NormalizedDependencies = {
|
|
153
|
+
fetch: FetchLike;
|
|
154
|
+
crypto: Crypto;
|
|
155
|
+
now: () => number;
|
|
156
|
+
launch: (url: string) => Promise<string | void>;
|
|
157
|
+
secureStorage?: MobileSecureStorage;
|
|
158
|
+
};
|
|
159
|
+
export declare function initializeAuthorizationClient(configuration: ClientConfiguration, dependencies: ClientDependencies): Promise<AuthorizationClient>;
|
|
160
|
+
export declare class AuthorizationClient {
|
|
161
|
+
#private;
|
|
162
|
+
readonly capabilities: {
|
|
163
|
+
mode: "mode_b";
|
|
164
|
+
channel: ClientChannel;
|
|
165
|
+
methods: readonly IdentityMethod[];
|
|
166
|
+
};
|
|
167
|
+
readonly publicConfiguration?: PublicClientConfiguration;
|
|
168
|
+
constructor(configuration: ClientConfiguration, dependencies: NormalizedDependencies, publicConfiguration?: PublicClientConfiguration);
|
|
169
|
+
get hasSession(): boolean;
|
|
170
|
+
signup(method: IdentityMethod): Promise<AuthAttempt>;
|
|
171
|
+
login(method: IdentityMethod): Promise<AuthAttempt>;
|
|
172
|
+
bootstrapPasskey(signal?: AbortSignal): Promise<HostedIdentityFlow>;
|
|
173
|
+
verifyIdentity(method: IdentityVerificationMethod, signal?: AbortSignal): Promise<HostedIdentityFlow>;
|
|
174
|
+
completePasskeyBootstrap(callbackUri: string, signal?: AbortSignal): Promise<PasskeyBootstrapResult>;
|
|
175
|
+
/** identities lists the account's own active sign-in methods; a passkey names its credential. */
|
|
176
|
+
identities(signal?: AbortSignal): Promise<AccountIdentity[]>;
|
|
177
|
+
completeIdentityVerification(callbackUri: string, signal?: AbortSignal): Promise<VerifiedIdentityResult>;
|
|
178
|
+
createOperation(create: LocalOperationCreate, idempotencyKey: string, signal?: AbortSignal): Promise<LocalOperation>;
|
|
179
|
+
createIdentityLink(verifiedIdentityHandle: string, idempotencyKey: string, signal?: AbortSignal): Promise<LocalOperation>;
|
|
180
|
+
createIdentityUnlink(identityId: string, idempotencyKey: string, signal?: AbortSignal): Promise<LocalOperation>;
|
|
181
|
+
createSessionRevocation(sessionId: string, idempotencyKey: string, signal?: AbortSignal): Promise<LocalOperation>;
|
|
182
|
+
createServiceGrant(input: {
|
|
183
|
+
walletId: string;
|
|
184
|
+
servicePrincipalId: string;
|
|
185
|
+
enabled: boolean;
|
|
186
|
+
scopes: ServiceReadScope[];
|
|
187
|
+
externalRef?: string;
|
|
188
|
+
}, idempotencyKey: string, signal?: AbortSignal): Promise<LocalOperation>;
|
|
189
|
+
operation(operationId: string, signal?: AbortSignal): Promise<LocalOperation>;
|
|
190
|
+
challengeOperation(operationId: string, credentialId: string, signal?: AbortSignal): Promise<ConfirmationChallenge>;
|
|
191
|
+
completeOperationConfirmation(callbackUri: string, signal?: AbortSignal): Promise<LocalOperation>;
|
|
192
|
+
/**
|
|
193
|
+
* createWalletOperation admits one Mode B wallet intent on POST /v1/operations.
|
|
194
|
+
* The closed body is validated locally against the current session account
|
|
195
|
+
* before the request leaves the client (source §1.3, §2.2).
|
|
196
|
+
*/
|
|
197
|
+
createWalletOperation(create: UserWalletOperationCreate, idempotencyKey: string, signal?: AbortSignal): Promise<UserWalletOperation>;
|
|
198
|
+
createWallet(input: {
|
|
199
|
+
network: string;
|
|
200
|
+
recipientPublicKey: string;
|
|
201
|
+
}, idempotencyKey: string, signal?: AbortSignal): Promise<UserWalletOperation>;
|
|
202
|
+
signWithWallet(input: {
|
|
203
|
+
walletId: string;
|
|
204
|
+
network: string;
|
|
205
|
+
messageBase64url: string;
|
|
206
|
+
}, idempotencyKey: string, signal?: AbortSignal): Promise<UserWalletOperation>;
|
|
207
|
+
sendFromWallet(input: {
|
|
208
|
+
walletId: string;
|
|
209
|
+
network: string;
|
|
210
|
+
recipient: string;
|
|
211
|
+
amountRaw: string;
|
|
212
|
+
maxFeeRaw: string;
|
|
213
|
+
}, idempotencyKey: string, signal?: AbortSignal): Promise<UserWalletOperation>;
|
|
214
|
+
exportWallet(input: {
|
|
215
|
+
walletId: string;
|
|
216
|
+
recipientPublicKey: string;
|
|
217
|
+
}, idempotencyKey: string, signal?: AbortSignal): Promise<UserWalletOperation>;
|
|
218
|
+
recoverWallet(input: {
|
|
219
|
+
walletId: string;
|
|
220
|
+
expectedGeneration: string;
|
|
221
|
+
recipientPublicKey: string;
|
|
222
|
+
}, idempotencyKey: string, signal?: AbortSignal): Promise<UserWalletOperation>;
|
|
223
|
+
/** walletOperation reads the safe wallet status on GET /v1/operations/{operation_id}. */
|
|
224
|
+
walletOperation(operationId: string, signal?: AbortSignal): Promise<UserWalletOperation>;
|
|
225
|
+
/**
|
|
226
|
+
* challengeWalletOperation reuses the shared confirmation challenge route and
|
|
227
|
+
* pending-state bookkeeping; the wallet and local challenge contracts are the
|
|
228
|
+
* same closed response.
|
|
229
|
+
*/
|
|
230
|
+
challengeWalletOperation(operationId: string, credentialId: string, signal?: AbortSignal): Promise<ConfirmationChallenge>;
|
|
231
|
+
completeWalletOperationConfirmation(callbackUri: string, signal?: AbortSignal): Promise<UserWalletOperation>;
|
|
232
|
+
/**
|
|
233
|
+
* executeWalletOperation claims one confirmed wallet effect. The first claim
|
|
234
|
+
* answers 202 and an exact replay answers 200; both carry the same operation.
|
|
235
|
+
*/
|
|
236
|
+
executeWalletOperation(operationId: string, version: string, idempotencyKey: string, signal?: AbortSignal): Promise<UserWalletOperation>;
|
|
237
|
+
/** walletOperationResult reads the protected wallet output for its frozen recipient. */
|
|
238
|
+
walletOperationResult(operationId: string, signal?: AbortSignal): Promise<WalletResult>;
|
|
239
|
+
executeOperation(operationId: string, version: string, idempotencyKey: string, signal?: AbortSignal): Promise<LocalOperation>;
|
|
240
|
+
/** HTTP-only Auth-owned links and session-authorized Streams registration. */
|
|
241
|
+
linkedWallets(): LinkedWallets;
|
|
242
|
+
/**
|
|
243
|
+
* streams binds the two authorized Streams reads of source §2.6 to this
|
|
244
|
+
* session's protected GET, so the account caller reuses the one access-token
|
|
245
|
+
* and refresh path. The read contract, its types and its bounds live in the
|
|
246
|
+
* `./streams` entry point, which this file deliberately does not re-export; a
|
|
247
|
+
* service caller constructs `StreamsReads` there with its own credentialed
|
|
248
|
+
* GET. The caller supplies the stable `idempotencyKey` in each read's options;
|
|
249
|
+
* it is forwarded unchanged on the original GET and any protected 401 retry.
|
|
250
|
+
*/
|
|
251
|
+
streams(): StreamsReads;
|
|
252
|
+
operationResult(operationId: string, signal?: AbortSignal): Promise<LocalOperationResult>;
|
|
253
|
+
cancel(attemptId: string): "local_canceled";
|
|
254
|
+
exchangeHandoff(callbackUri: string, signal?: AbortSignal): Promise<Session>;
|
|
255
|
+
restoreSession(signal?: AbortSignal): Promise<Session>;
|
|
256
|
+
refreshSession(signal?: AbortSignal): Promise<Session>;
|
|
257
|
+
logout(signal?: AbortSignal): Promise<{
|
|
258
|
+
localCleared: true;
|
|
259
|
+
serverDisposition: "server_revoked" | "server_unconfirmed";
|
|
260
|
+
}>;
|
|
261
|
+
me(signal?: AbortSignal): Promise<MeProjection>;
|
|
262
|
+
sessions(input?: AbortSignal | PageOptions): Promise<SessionProjection>;
|
|
263
|
+
wallets(input?: AbortSignal | PageOptions): Promise<WalletProjection>;
|
|
264
|
+
}
|