@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.
Files changed (56) hide show
  1. package/README.md +708 -2
  2. package/dist/aesGcmSiv.d.ts +14 -0
  3. package/dist/aesGcmSiv.js +160 -0
  4. package/dist/auth.d.ts +68 -0
  5. package/dist/auth.js +215 -0
  6. package/dist/balances.d.ts +31 -0
  7. package/dist/balances.js +44 -0
  8. package/dist/canonicalize.d.ts +19 -0
  9. package/dist/canonicalize.js +107 -0
  10. package/dist/client.d.ts +264 -0
  11. package/dist/client.js +754 -0
  12. package/dist/deviceKey.d.ts +13 -0
  13. package/dist/deviceKey.js +28 -0
  14. package/dist/deviceShare.d.ts +9 -0
  15. package/dist/deviceShare.js +24 -0
  16. package/dist/deviceShareEnvelope.d.ts +13 -0
  17. package/dist/deviceShareEnvelope.js +139 -0
  18. package/dist/linkedChecks.d.ts +17 -0
  19. package/dist/linkedChecks.js +31 -0
  20. package/dist/linkedSendDisplay.d.ts +73 -0
  21. package/dist/linkedSendDisplay.js +84 -0
  22. package/dist/linkedWalletSignals.d.ts +22 -0
  23. package/dist/linkedWalletSignals.js +101 -0
  24. package/dist/linkedWallets.d.ts +373 -0
  25. package/dist/linkedWallets.js +471 -0
  26. package/dist/mediatedOperation.d.ts +27 -0
  27. package/dist/mediatedOperation.js +68 -0
  28. package/dist/modeC.d.ts +131 -0
  29. package/dist/modeC.js +248 -0
  30. package/dist/modeCLinked.d.ts +207 -0
  31. package/dist/modeCLinked.js +270 -0
  32. package/dist/pages.d.ts +22 -0
  33. package/dist/pages.js +45 -0
  34. package/dist/poll.d.ts +15 -0
  35. package/dist/poll.js +76 -0
  36. package/dist/requestGrant.d.ts +169 -0
  37. package/dist/requestGrant.js +243 -0
  38. package/dist/sends.d.ts +89 -0
  39. package/dist/sends.js +127 -0
  40. package/dist/slice4.d.ts +173 -0
  41. package/dist/slice4.js +285 -0
  42. package/dist/streams.d.ts +212 -0
  43. package/dist/streams.js +282 -0
  44. package/dist/trackedWallets.d.ts +53 -0
  45. package/dist/trackedWallets.js +104 -0
  46. package/dist/transferStatus.d.ts +45 -0
  47. package/dist/transferStatus.js +43 -0
  48. package/dist/walletDisplayParts.d.ts +15 -0
  49. package/dist/walletDisplayParts.js +43 -0
  50. package/dist/walletEvents.d.ts +43 -0
  51. package/dist/walletEvents.js +97 -0
  52. package/dist/walletLimits.d.ts +65 -0
  53. package/dist/walletLimits.js +102 -0
  54. package/dist/walletOperations.d.ts +192 -0
  55. package/dist/walletOperations.js +308 -0
  56. package/package.json +64 -4
@@ -0,0 +1,373 @@
1
+ import { type NextAction } from './auth.ts';
2
+ import { type WalletEventPage } from './streams.ts';
3
+ export { resumeCursor } from './streams.ts';
4
+ import { type LocalOperation, type ResultRecipient } from './slice4.ts';
5
+ import { type LinkedWalletSignalEnd, type LinkedWalletSignalHandlers } from './linkedWalletSignals.ts';
6
+ export { linkedSignalsPath, readLinkedWalletSignals, MaxSignalWallets, type LinkedWalletSignalEnd, type LinkedWalletSignalHandlers } from './linkedWalletSignals.ts';
7
+ import { type TransferStatus } from './transferStatus.ts';
8
+ import { type LinkedWalletBalances } from './balances.ts';
9
+ export { parseLinkedWalletBalances, type AssetBalance, type LinkedWalletBalances, type NetworkBalanceStatus, type NetworkBalances } from './balances.ts';
10
+ import { type SendPage } from './sends.ts';
11
+ export { eventOfTransaction, parseSendPage, sendEvents, sendsPath, type ListedSend, type SendPage, type TransferOutcome } from './sends.ts';
12
+ export type { LinkedSendDisplay, ReplaceAction } from './walletOperations.ts';
13
+ import type { PageOptions } from './pages.ts';
14
+ export { parseTransferStatus, transferFinal, transferStatusPath, TransferStates, type TransferState, type TransferStatus } from './transferStatus.ts';
15
+ import { type WalletLimits, type WalletLimitsInput } from './walletLimits.ts';
16
+ export { WalletLimitRefusals, isWalletLimitRefusal, MaxLimitCeilings, MaxLimitRecipients, type LimitAsset, type WalletCeiling, type WalletLimitRefusal, type WalletLimits, type WalletLimitsDisplay, type WalletLimitsInput } from './walletLimits.ts';
17
+ import { type LinkedSendAsset, type ReplaceAction, type DeviceSharePackage, type UserWalletOperation, type UserWalletState, type UserWalletEffectState, type UserWalletAuthorizationBasis } from './walletOperations.ts';
18
+ /** session_authorized: the account's session registered its own linked wallet; no confirmation exists. */
19
+ export type LinkedRegistrationAuthorizationBasis = UserWalletAuthorizationBasis;
20
+ export interface WalletConnection {
21
+ requestId: string;
22
+ id: string;
23
+ connectorId: string;
24
+ state: 'connected' | 'revoked' | 'reauth_required';
25
+ createdAt: string;
26
+ lastSyncedAt: string;
27
+ revokedAt?: string;
28
+ }
29
+ export interface LinkedWallet {
30
+ id: string;
31
+ connectionId: string;
32
+ externalWalletId: string;
33
+ externalKeyId: string;
34
+ network: string;
35
+ address: string;
36
+ algorithm: 'secp256k1' | 'ed25519';
37
+ publicKey: string;
38
+ bindingRevision: string;
39
+ status: 'active' | 'inactive';
40
+ observedAt: string;
41
+ }
42
+ export interface WalletLinkChallenge {
43
+ requestId: string;
44
+ challengeId: string;
45
+ expiresAt: string;
46
+ publicKey: {
47
+ challenge: string;
48
+ rpId: string;
49
+ timeoutMs: number;
50
+ userVerification: 'required';
51
+ allowCredentials: [{
52
+ type: 'public-key';
53
+ id: string;
54
+ }];
55
+ };
56
+ }
57
+ /** Assertion JSON from a credential ceremony on its server-approved RP/origin. */
58
+ export interface WalletLinkAssertion {
59
+ id: string;
60
+ rawId: string;
61
+ type: 'public-key';
62
+ response: {
63
+ clientDataJSON: string;
64
+ authenticatorData: string;
65
+ signature: string;
66
+ userHandle: string;
67
+ };
68
+ }
69
+ export interface LinkedRegistrationCreate {
70
+ kind: 'streams.register';
71
+ owner_type: 'account';
72
+ owner_id: string;
73
+ linked_wallet_id: string;
74
+ payload: {
75
+ network: string;
76
+ assets?: string[];
77
+ activity_types?: string[];
78
+ };
79
+ result_recipient?: ResultRecipient;
80
+ }
81
+ export interface LinkedRegistrationDisplay {
82
+ kind: 'streams.register';
83
+ ownerId: string;
84
+ requesterId: string;
85
+ resultRecipient: ResultRecipient;
86
+ bindingSource: 'linked_wallet';
87
+ connectionId: string;
88
+ linkedWalletId: string;
89
+ bindingRevision: string;
90
+ assets: readonly string[];
91
+ network: string;
92
+ address: string;
93
+ streamsMappingId: string;
94
+ streamsMappingVersion: string;
95
+ targetCustomerId: string;
96
+ targetProjectId: string;
97
+ targetEnvironmentId: string;
98
+ }
99
+ export interface LinkedRegistrationPurgedDisplay {
100
+ kind: 'streams.register';
101
+ materialPurged: true;
102
+ ownerId: string;
103
+ requesterId: string;
104
+ resultRecipient: ResultRecipient;
105
+ }
106
+ export interface LinkedRegistrationOperation {
107
+ id: string;
108
+ version: string;
109
+ kind: 'streams.register';
110
+ state: UserWalletState;
111
+ effectState: UserWalletEffectState;
112
+ authorizationBasis: LinkedRegistrationAuthorizationBasis;
113
+ ownerType: 'account';
114
+ ownerId: string;
115
+ requesterId: string;
116
+ bindingSource: 'linked_wallet';
117
+ connectionId: string;
118
+ linkedWalletId: string;
119
+ bindingRevision: string;
120
+ requestFingerprint: string;
121
+ operationFingerprint: string;
122
+ display: LinkedRegistrationDisplay | LinkedRegistrationPurgedDisplay;
123
+ createdAt: string;
124
+ expiresAt: string;
125
+ nextAction: NextAction;
126
+ confirmationLocation?: string;
127
+ }
128
+ export interface LinkedRegistrationResult {
129
+ requestId: string;
130
+ result: {
131
+ kind: 'streams_registration';
132
+ operationId: string;
133
+ bindingSource: 'linked_wallet';
134
+ connectionId: string;
135
+ linkedWalletId: string;
136
+ bindingRevision: string;
137
+ sourceRegistrationId: string;
138
+ registrationDigest: string;
139
+ receiptId: string;
140
+ };
141
+ }
142
+ /**
143
+ * A send from a linked wallet. asset is the network's own coin ("native") or a
144
+ * token the own-wallet system sends on that network; amountRaw is in that
145
+ * asset's minimal units, and a token's decimals differ by network. comment
146
+ * is a text the transfer carries to its recipient, on a TON network only:
147
+ * the comment an exchange credits a deposit by (transferComment() is its
148
+ * rule). It is sent exactly as given.
149
+ */
150
+ export interface LinkedSendInput {
151
+ linkedWalletId: string;
152
+ network: string;
153
+ asset: LinkedSendAsset;
154
+ recipient: string;
155
+ amountRaw: string;
156
+ comment?: string;
157
+ resultRecipient?: ResultRecipient;
158
+ }
159
+ /**
160
+ * The replacement of a send the network has not included. operationId is the
161
+ * account's own send from the same wallet; what the replacement moves is
162
+ * that send's own and is not given here.
163
+ */
164
+ export interface LinkedReplaceInput {
165
+ linkedWalletId: string;
166
+ operationId: string;
167
+ action: ReplaceAction;
168
+ resultRecipient?: ResultRecipient;
169
+ }
170
+ /** The own-wallet system's transport key, as that system publishes it. It carries no proof of where the key lives. */
171
+ export interface LinkedTransportKey {
172
+ requestId: string;
173
+ publicKey: string;
174
+ encryptionAlgorithm: string;
175
+ }
176
+ /** Metadata position is an Auth registration ID, never a deposit cursor. */
177
+ export interface LinkedRegistrationListOptions {
178
+ afterRegistrationId?: string;
179
+ limit?: number;
180
+ signal?: AbortSignal;
181
+ }
182
+ /** eventTypes is the kinds of wallet event wanted: deposit, withdrawal, activity in any combination, or activity:<type>; left out, every kind. */
183
+ export interface LinkedEventsOptions {
184
+ registrationId?: string;
185
+ cursor?: string;
186
+ limit?: number;
187
+ eventTypes?: readonly string[];
188
+ signal?: AbortSignal;
189
+ }
190
+ export interface LinkedStreamsRegistration {
191
+ readonly registrationId: string;
192
+ readonly bindingSource: 'linked_wallet';
193
+ readonly connectionId: string;
194
+ readonly linkedWalletId: string;
195
+ readonly bindingRevision: string;
196
+ readonly sourceRegistrationId: string;
197
+ readonly network: string;
198
+ readonly address: string;
199
+ readonly assets: readonly string[];
200
+ readonly status: 'pending' | 'active';
201
+ readonly effectiveFrom: string;
202
+ readonly revision: number;
203
+ readonly sourceVersion: string;
204
+ }
205
+ export interface LinkedStreamsRegistrationList {
206
+ readonly items: readonly LinkedStreamsRegistration[];
207
+ readonly hasMore: boolean;
208
+ readonly nextAfterRegistrationId?: string;
209
+ }
210
+ /** Consumer-owned ports reuse AuthorizationClient's existing session transport. */
211
+ export interface LinkedWalletTransport {
212
+ get(path: string, signal?: AbortSignal): Promise<unknown>;
213
+ /** Opens a long-lived answer and returns it as it arrives. */
214
+ stream(path: string, signal?: AbortSignal): Promise<ReadableStream<Uint8Array>>;
215
+ write(path: string, method: 'POST' | 'DELETE', body: unknown | undefined, signal?: AbortSignal, idempotencyKey?: string, version?: string): Promise<{
216
+ payload: unknown;
217
+ accountId: string;
218
+ }>;
219
+ accountId(): string;
220
+ now(): number;
221
+ }
222
+ export declare class LinkedWallets {
223
+ #private;
224
+ constructor(transport: LinkedWalletTransport);
225
+ challenge(cognitoAccessToken: string, credentialId: string, signal?: AbortSignal): Promise<WalletLinkChallenge>;
226
+ connect(challengeId: string, cognitoAccessToken: string, assertion: WalletLinkAssertion, signal?: AbortSignal): Promise<WalletConnection>;
227
+ connection(connectionId: string, signal?: AbortSignal): Promise<WalletConnection>;
228
+ sync(connectionId: string, cognitoAccessToken: string, signal?: AbortSignal): Promise<WalletConnection>;
229
+ /**
230
+ * refresh binds the account to the Wallet identity the provider owns for it
231
+ * and synchronizes its public wallet inventory. It carries no Wallet token
232
+ * and no body; repeating it converges on the same connection. Call it after
233
+ * a wallet was created so the wallet appears in list().
234
+ */
235
+ refresh(signal?: AbortSignal): Promise<WalletConnection>;
236
+ disconnect(connectionId: string, signal?: AbortSignal): Promise<WalletConnection>;
237
+ list(signal?: AbortSignal): Promise<{
238
+ requestId: string;
239
+ items: readonly LinkedWallet[];
240
+ }>;
241
+ wallet(linkedWalletId: string, signal?: AbortSignal): Promise<{
242
+ requestId: string;
243
+ wallet: LinkedWallet;
244
+ }>;
245
+ /** Every metadata page is fresh; restart at the beginning to discover earlier insertions. */
246
+ registrations(linkedWalletId: string, options?: LinkedRegistrationListOptions): Promise<LinkedStreamsRegistrationList>;
247
+ /**
248
+ * One page of the linked wallet's retained events as wallet events 3.0:
249
+ * what came in, what went out and what else happened, each with kind,
250
+ * status and revision, those of the kinds eventTypes names. Continuations
251
+ * are sealed opaque cursors.
252
+ */
253
+ events(linkedWalletId: string, options?: LinkedEventsOptions): Promise<WalletEventPage>;
254
+ /**
255
+ * Opens one signal stream for these linked wallets and reads it to its end.
256
+ * onOpen says the stream is live: read every wallet once then. onWallets
257
+ * names wallets with new events: read them with events(). The promise
258
+ * resolves with the reason the stream ended; a stream lives no longer than
259
+ * an access token, so the caller opens the next one. It rejects with the
260
+ * server's refusal, with the abort reason, or when the connection fails;
261
+ * keep an ordinary timed read for those times.
262
+ */
263
+ signals(linkedWalletIds: readonly string[], handlers: LinkedWalletSignalHandlers): Promise<LinkedWalletSignalEnd>;
264
+ createRegistration(create: LinkedRegistrationCreate, idempotencyKey: string, signal?: AbortSignal): Promise<LinkedRegistrationOperation>;
265
+ /**
266
+ * Starts tracking a linked wallet on one network. An EVM wallet has one
267
+ * address on every EVM network, so it is registered on each of them with its
268
+ * own call. activityTypes names the kinds of activity events asked for beside
269
+ * deposits; omitted or empty means deposits only, and Streams refuses a kind
270
+ * the network does not have. The operation comes back authorized;
271
+ * executeRegistration() with its version dispatches it.
272
+ */
273
+ register(input: {
274
+ linkedWalletId: string;
275
+ network: string;
276
+ assets?: string[];
277
+ activityTypes?: string[];
278
+ resultRecipient?: ResultRecipient;
279
+ }, idempotencyKey: string, signal?: AbortSignal): Promise<LinkedRegistrationOperation>;
280
+ operation(operationId: string, signal?: AbortSignal): Promise<LinkedRegistrationOperation>;
281
+ executeRegistration(operationId: string, version: string, idempotencyKey: string, signal?: AbortSignal): Promise<LinkedRegistrationOperation>;
282
+ registrationResult(operationId: string, signal?: AbortSignal): Promise<LinkedRegistrationResult>;
283
+ /**
284
+ * Starts a send from a linked wallet. The account's session authorizes it:
285
+ * the operation comes back authorized (authorizationBasis
286
+ * session_authorized), with no passkey and no confirmation window. Then
287
+ * prepare() has the own-wallet system prepare the transfer and name its
288
+ * fee; show the owner what was prepared and, on their confirm,
289
+ * executeSend() with the device share.
290
+ */
291
+ send(input: LinkedSendInput, idempotencyKey: string, signal?: AbortSignal): Promise<UserWalletOperation>;
292
+ /**
293
+ * Replaces a send the own-wallet system broadcast on an EVM network and the
294
+ * network has not included: "speed_up" sends the same transfer again with a
295
+ * higher fee, "cancel" sends nothing to the wallet's own address in its
296
+ * place. The answer is a send of its own, authorized by the session like
297
+ * send(): prepare() has the own-wallet system prepare the replacement (it
298
+ * may answer that the transfer no longer waits), show it with its new fee,
299
+ * and on the owner's confirm executeSend(). Whichever of the two
300
+ * transactions the network includes, the other fails; read
301
+ * transferStatus() of both.
302
+ */
303
+ replaceSend(input: LinkedReplaceInput, idempotencyKey: string, signal?: AbortSignal): Promise<UserWalletOperation>;
304
+ /**
305
+ * What the wallet holds on each of its networks: the coin and the tokens
306
+ * the stand names there, in minimal units with their decimals. The provider
307
+ * reads its own stand's nodes. A network whose node gave no amount is in
308
+ * the answer with its status and without amounts; it fails nothing.
309
+ */
310
+ balances(linkedWalletId: string, signal?: AbortSignal): Promise<LinkedWalletBalances>;
311
+ /**
312
+ * Has the own-wallet system prepare the transfer of a send or replacement
313
+ * the session authorized, and returns the send with what was prepared:
314
+ * display.preparedSummary, the sending address and the fee estimate. Show
315
+ * them to the owner; executeSend() sends exactly that transfer. The
316
+ * transfer is prepared once: calling again returns the same prepared send
317
+ * and asks the own-wallet system nothing. A prepared send expires within
318
+ * 150 seconds; one that expired is sent again from send(). The request
319
+ * carries no body, idempotency key or version.
320
+ */
321
+ prepare(operationId: string, signal?: AbortSignal): Promise<UserWalletOperation>;
322
+ /** The key the device seals its share to, read right before executeSend(). */
323
+ transportKey(linkedWalletId: string, signal?: AbortSignal): Promise<LinkedTransportKey>;
324
+ /**
325
+ * Executes a prepared send, on the owner's confirm, with the device share
326
+ * resealed for the own-wallet system (resealDeviceShare). The provider
327
+ * cannot open the share. A send never prepared is refused with
328
+ * VERSION_CONFLICT, an expired one with OPERATION_EXPIRED.
329
+ */
330
+ executeSend(operationId: string, version: string, idempotencyKey: string, deviceShare: DeviceSharePackage, signal?: AbortSignal): Promise<UserWalletOperation>;
331
+ /**
332
+ * What became of the transfer a send prepared: on its way, confirmed by the
333
+ * network, or failed and why. The send's operation succeeds when the
334
+ * own-wallet system accepted the transfer; this is what the network did
335
+ * with it. Read it until final is true. Before the send was prepared
336
+ * there is no transfer and the read is refused with NOT_FOUND.
337
+ */
338
+ transferStatus(operationId: string, signal?: AbortSignal): Promise<TransferStatus>;
339
+ /**
340
+ * One page of the account's send history, newest first: every wallet.send
341
+ * the account can read, with its transaction hash and the recorded final
342
+ * fate of its transfer. A send with a hash and no transfer has not been
343
+ * reported final yet: read transferStatus() for it, which records the fate.
344
+ * The cursor carries the first page's limit.
345
+ */
346
+ sends(options?: PageOptions): Promise<SendPage>;
347
+ /** The limits every send from the wallet obeys, read with the session (walletLimits.ts). Revision "0": never set. */
348
+ limits(linkedWalletId: string, signal?: AbortSignal): Promise<WalletLimits>;
349
+ /**
350
+ * Asks to replace the wallet's limits as a whole; empty ceilings and recipients remove them all. The operation
351
+ * awaits the owner's passkey: the client's challengeOperation(), completeOperationConfirmation() and
352
+ * executeOperation() apply it. A send the limits refuse answers one of WalletLimitRefusals.
353
+ */
354
+ setLimits(linkedWalletId: string, limits: WalletLimitsInput, idempotencyKey: string, signal?: AbortSignal): Promise<LocalOperation>;
355
+ }
356
+ export declare function parseWalletConnection(payload: unknown): WalletConnection;
357
+ export declare function parseLinkedWallet(payload: unknown): LinkedWallet;
358
+ export declare function parseLinkedWalletList(payload: unknown): {
359
+ requestId: string;
360
+ items: readonly LinkedWallet[];
361
+ };
362
+ export declare function parseWalletLinkChallenge(payload: unknown, now: number): WalletLinkChallenge;
363
+ export declare function validateWalletLinkAssertion(value: WalletLinkAssertion): WalletLinkAssertion;
364
+ export declare function validateLinkedRegistrationCreate(value: LinkedRegistrationCreate, ownerId: string): LinkedRegistrationCreate;
365
+ export declare function parseLinkedRegistrationOperationEnvelope(payload: unknown): {
366
+ requestId: string;
367
+ operation: LinkedRegistrationOperation;
368
+ };
369
+ export declare function parseLinkedRegistrationOperation(payload: unknown): LinkedRegistrationOperation;
370
+ export declare function parseLinkedRegistrationResult(payload: unknown, operationId: string): LinkedRegistrationResult;
371
+ export declare function linkedRegistrationsPath(linkedWalletId: string, options?: LinkedRegistrationListOptions): string;
372
+ export declare function linkedEventsPath(linkedWalletId: string, options?: LinkedEventsOptions): string;
373
+ export declare function parseLinkedStreamsRegistrationList(payload: unknown, linkedWalletId: string): LinkedStreamsRegistrationList;