@shuttle.technology/authorization 0.0.0-stage → 0.2.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/CHANGELOG.md +191 -0
- package/README.md +1124 -2
- package/dist/accountLists.d.ts +28 -0
- package/dist/accountLists.js +27 -0
- package/dist/aesGcmSiv.d.ts +14 -0
- package/dist/aesGcmSiv.js +160 -0
- package/dist/auth.d.ts +68 -0
- package/dist/auth.js +189 -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 +152 -0
- package/dist/client.js +781 -0
- package/dist/clientTypes.d.ts +56 -0
- package/dist/clientTypes.js +5 -0
- package/dist/configuration.d.ts +48 -0
- package/dist/configuration.js +72 -0
- package/dist/consentDebit.d.ts +36 -0
- package/dist/consentDebit.js +95 -0
- package/dist/credentials.d.ts +116 -0
- package/dist/credentials.js +315 -0
- package/dist/debitPermissionWire.d.ts +90 -0
- package/dist/debitPermissionWire.js +118 -0
- package/dist/debitPermissions.d.ts +39 -0
- package/dist/debitPermissions.js +117 -0
- package/dist/deviceKey.d.ts +13 -0
- package/dist/deviceKey.js +28 -0
- package/dist/deviceRecovery.d.ts +40 -0
- package/dist/deviceRecovery.js +143 -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/deviceShares.d.ts +91 -0
- package/dist/deviceShares.js +204 -0
- package/dist/errors.d.ts +280 -0
- package/dist/errors.js +85 -0
- package/dist/linkedChecks.d.ts +17 -0
- package/dist/linkedChecks.js +31 -0
- package/dist/linkedRecovery.d.ts +40 -0
- package/dist/linkedRecovery.js +49 -0
- package/dist/linkedRegistrations.d.ts +11 -0
- package/dist/linkedRegistrations.js +109 -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 +401 -0
- package/dist/linkedWallets.js +436 -0
- package/dist/me.d.ts +27 -0
- package/dist/me.js +30 -0
- package/dist/mediatedOperation.d.ts +27 -0
- package/dist/mediatedOperation.js +68 -0
- package/dist/mobile.d.ts +64 -0
- package/dist/mobile.js +69 -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/redirects.d.ts +45 -0
- package/dist/redirects.js +108 -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/serviceGrants.d.ts +52 -0
- package/dist/serviceGrants.js +46 -0
- package/dist/slice4.d.ts +187 -0
- package/dist/slice4.js +299 -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/walletCreateGrant.d.ts +62 -0
- package/dist/walletCreateGrant.js +89 -0
- package/dist/walletDisplayParts.d.ts +17 -0
- package/dist/walletDisplayParts.js +47 -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 +209 -0
- package/dist/walletOperations.js +317 -0
- package/dist/webRenewal.d.ts +92 -0
- package/dist/webRenewal.js +179 -0
- package/package.json +65 -3
package/dist/sends.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// The account's history of sends: GET /v1/operations narrowed to wallet.send,
|
|
2
|
+
// newest first. Every row is one send with what a history shows of it: where,
|
|
3
|
+
// what, how much, to whom, its state, its transaction hash and, once the
|
|
4
|
+
// own-wallet system reported it, the final fate of its transfer.
|
|
5
|
+
import { ClientFlowError, opaqueId, record, rfc3339UTC } from './auth.js';
|
|
6
|
+
import { pageEnvelope, pageRequest } from './pages.js';
|
|
7
|
+
import { parseUserWalletOperation, walletMaterialPurged } from './walletOperations.js';
|
|
8
|
+
const hashPattern = /^[A-Za-z0-9_.:-]{1,128}$/;
|
|
9
|
+
/** The path of one page of the send history. */
|
|
10
|
+
export function sendsPath(options) {
|
|
11
|
+
const { path, signal } = pageRequest('/v1/operations', options);
|
|
12
|
+
return { path: `${path}${path.includes('?') ? '&' : '?'}kind=wallet.send`, signal };
|
|
13
|
+
}
|
|
14
|
+
/** Parses one closed page of the send history. */
|
|
15
|
+
export function parseSendPage(payload) {
|
|
16
|
+
const page = pageEnvelope(payload);
|
|
17
|
+
const items = page.items.map(parseListedSend);
|
|
18
|
+
// Newest first: a page out of order is not this list.
|
|
19
|
+
if (items.some((item, index) => index > 0 && Date.parse(items[index - 1].createdAt) < Date.parse(item.createdAt)))
|
|
20
|
+
fault();
|
|
21
|
+
const out = { requestId: page.request_id, items: Object.freeze(items), hasMore: page.has_more };
|
|
22
|
+
return Object.freeze(page.has_more ? { ...out, nextCursor: page.next_cursor } : out);
|
|
23
|
+
}
|
|
24
|
+
function parseListedSend(payload) {
|
|
25
|
+
const item = record(payload, ['operation'], ['transaction_hash', 'transfer']);
|
|
26
|
+
const raw = item.operation;
|
|
27
|
+
if (raw === null || typeof raw !== 'object' || Array.isArray(raw) || raw.kind !== 'wallet.send')
|
|
28
|
+
fault();
|
|
29
|
+
const send = listedSend(item.operation);
|
|
30
|
+
if (item.transaction_hash !== undefined) {
|
|
31
|
+
if (typeof item.transaction_hash !== 'string' || !hashPattern.test(item.transaction_hash) || send.linkedWalletId === undefined)
|
|
32
|
+
fault();
|
|
33
|
+
send.transactionHash = item.transaction_hash;
|
|
34
|
+
}
|
|
35
|
+
if (item.transfer !== undefined) {
|
|
36
|
+
if (send.linkedWalletId === undefined)
|
|
37
|
+
fault();
|
|
38
|
+
send.transfer = parseTransferOutcome(item.transfer);
|
|
39
|
+
if (send.transfer.replacedByOperationId === send.operationId)
|
|
40
|
+
fault();
|
|
41
|
+
}
|
|
42
|
+
return Object.freeze(send);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* One send of the account: from a linked wallet authorized by its session,
|
|
46
|
+
* confirmed with its passkey, or forwarded by a service on the person's signed
|
|
47
|
+
* request (Mode C, from a bound or a linked wallet), each read with the parser
|
|
48
|
+
* of the projection the provider serves for it.
|
|
49
|
+
*/
|
|
50
|
+
function listedSend(payload) {
|
|
51
|
+
const operation = parseUserWalletOperation(payload);
|
|
52
|
+
const send = {
|
|
53
|
+
operationId: operation.id, state: operation.state, effectState: operation.effectState, authorizationBasis: operation.authorizationBasis,
|
|
54
|
+
createdAt: operation.createdAt, expiresAt: operation.expiresAt, materialPurged: walletMaterialPurged(operation.display),
|
|
55
|
+
};
|
|
56
|
+
if (operation.linkedWallet)
|
|
57
|
+
send.linkedWalletId = operation.linkedWallet.linkedWalletId;
|
|
58
|
+
if (operation.walletId !== undefined)
|
|
59
|
+
send.walletId = operation.walletId;
|
|
60
|
+
const display = operation.display;
|
|
61
|
+
if (!walletMaterialPurged(display) && display.kind === 'wallet.send') {
|
|
62
|
+
send.network = display.network;
|
|
63
|
+
send.asset = display.asset;
|
|
64
|
+
send.recipient = display.recipient;
|
|
65
|
+
send.amountRaw = display.amountRaw;
|
|
66
|
+
if ('address' in display && display.address !== undefined)
|
|
67
|
+
send.address = display.address;
|
|
68
|
+
if ('comment' in display && display.comment !== undefined)
|
|
69
|
+
send.comment = display.comment;
|
|
70
|
+
if ('replacesOperationId' in display && display.replacesOperationId !== undefined) {
|
|
71
|
+
send.replacesOperationId = display.replacesOperationId;
|
|
72
|
+
send.replaceAction = display.replaceAction;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return send;
|
|
76
|
+
}
|
|
77
|
+
function parseTransferOutcome(payload) {
|
|
78
|
+
const t = record(payload, ['observed_at', 'state'], ['transaction_hash', 'failure_reason', 'replaced_by_operation_id']);
|
|
79
|
+
const hash = t.transaction_hash, reason = t.failure_reason, replacedBy = t.replaced_by_operation_id;
|
|
80
|
+
if (!['confirmed', 'failed', 'expired'].includes(t.state) || !rfc3339UTC(t.observed_at) ||
|
|
81
|
+
(hash !== undefined && (typeof hash !== 'string' || !hashPattern.test(hash))) || (t.state === 'confirmed' && hash === undefined) ||
|
|
82
|
+
(reason !== undefined && (t.state !== 'failed' || typeof reason !== 'string' || reason.length === 0 || new TextEncoder().encode(reason).length > 1024 || /[\x00-\x1f\x7f-\x9f]/.test(reason))) ||
|
|
83
|
+
(replacedBy !== undefined && (reason !== 'nonce_used' || !opaqueId(replacedBy))))
|
|
84
|
+
fault();
|
|
85
|
+
const out = { state: t.state, observedAt: t.observed_at };
|
|
86
|
+
if (hash !== undefined)
|
|
87
|
+
out.transactionHash = hash;
|
|
88
|
+
if (replacedBy !== undefined)
|
|
89
|
+
out.replacedByOperationId = replacedBy;
|
|
90
|
+
if (reason !== undefined)
|
|
91
|
+
out.failureReason = reason;
|
|
92
|
+
return Object.freeze(out);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Says whether a wallet event is the network's record of the transaction with
|
|
96
|
+
* this hash on this network: true or false where an event's sourceReference
|
|
97
|
+
* is the transaction hash, and undefined on every other network, where
|
|
98
|
+
* nothing ties an event to a hash yet. On the EVM networks and TRON the two
|
|
99
|
+
* are one hexadecimal hash and differ at most in a 0x prefix and letter case.
|
|
100
|
+
* On Solana both are the transaction's signature in base58, where case is
|
|
101
|
+
* part of the value. On TON the event names the transaction the network made
|
|
102
|
+
* and the own-wallet system names the message it sent; the two hashes differ.
|
|
103
|
+
*/
|
|
104
|
+
export function eventOfTransaction(event, networkId, transactionHash) {
|
|
105
|
+
const family = networkId.split(':', 1)[0];
|
|
106
|
+
if (family === 'solana')
|
|
107
|
+
return event.networkId === networkId && /^[1-9A-HJ-NP-Za-km-z]{64,88}$/.test(transactionHash) && event.sourceReference === transactionHash;
|
|
108
|
+
if (family !== 'eip155' && family !== 'tron')
|
|
109
|
+
return undefined;
|
|
110
|
+
const bare = (value) => value.toLowerCase().replace(/^0x/, '');
|
|
111
|
+
return event.networkId === networkId && /^(0x)?[0-9a-fA-F]{64}$/.test(transactionHash) && bare(event.sourceReference) === bare(transactionHash);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The wallet events that record one listed send on its network: the
|
|
115
|
+
* withdrawal from the sending wallet and any activity of the same
|
|
116
|
+
* transaction. It returns undefined where events cannot be tied to the send
|
|
117
|
+
* (no hash yet, details purged, or a network without that tie), and an empty
|
|
118
|
+
* list where they can and none of the given events is of this send.
|
|
119
|
+
*/
|
|
120
|
+
export function sendEvents(send, events) {
|
|
121
|
+
if (send.network === undefined || send.transactionHash === undefined)
|
|
122
|
+
return undefined;
|
|
123
|
+
if (eventOfTransaction({ networkId: send.network, sourceReference: '' }, send.network, send.transactionHash) === undefined)
|
|
124
|
+
return undefined;
|
|
125
|
+
return events.filter((event) => eventOfTransaction(event, send.network, send.transactionHash) === true);
|
|
126
|
+
}
|
|
127
|
+
function fault() { throw new ClientFlowError('invalid_server_response'); }
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { LocalOperationCreate, ServiceReadScope } from "./slice4.ts";
|
|
2
|
+
/** What a grant gives, or changes a grant to; `enabled: false` withdraws it. */
|
|
3
|
+
export interface ServiceGrantInput {
|
|
4
|
+
walletId: string;
|
|
5
|
+
servicePrincipalId: string;
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
scopes: ServiceReadScope[];
|
|
8
|
+
/** The service's own reference for its user, returned only to that service; it proves nothing. */
|
|
9
|
+
externalRef?: string;
|
|
10
|
+
}
|
|
11
|
+
/** The one grant to withdraw: the wallet and the service it names. */
|
|
12
|
+
export interface ServiceGrantTarget {
|
|
13
|
+
walletId: string;
|
|
14
|
+
servicePrincipalId: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* pending_source: a first streams:read grant waits until Streams opens the
|
|
18
|
+
* wallet's events to the service. active: the service reads under it now.
|
|
19
|
+
* revoked: withdrawn with `enabled: false`. stale: the wallet or the service
|
|
20
|
+
* changed since the grant was set, and the service reads nothing under it
|
|
21
|
+
* until it is set again.
|
|
22
|
+
*/
|
|
23
|
+
export type ServiceGrantState = "pending_source" | "active" | "revoked" | "stale";
|
|
24
|
+
/**
|
|
25
|
+
* One grant the account gave. walletKind names the wallet as me() does: "wallet" for a wallet Authorization
|
|
26
|
+
* created for the account, "linked_wallet" for one of its linked wallets. network and address are empty for a
|
|
27
|
+
* wallet that is no longer the one granted.
|
|
28
|
+
*/
|
|
29
|
+
export interface AccountServiceGrant {
|
|
30
|
+
servicePrincipalId: string;
|
|
31
|
+
walletId: string;
|
|
32
|
+
walletKind: "wallet" | "linked_wallet";
|
|
33
|
+
network: string;
|
|
34
|
+
address: string;
|
|
35
|
+
scopes: ServiceReadScope[];
|
|
36
|
+
state: ServiceGrantState;
|
|
37
|
+
/** UTC RFC 3339 date-time of the last change. */
|
|
38
|
+
grantedAt: string;
|
|
39
|
+
externalRef?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface ServiceGrantPage {
|
|
42
|
+
requestId: string;
|
|
43
|
+
items: AccountServiceGrant[];
|
|
44
|
+
hasMore: boolean;
|
|
45
|
+
nextCursor?: string;
|
|
46
|
+
}
|
|
47
|
+
/** serviceGrantCreate is the closed `service_grant.set` body of the account. */
|
|
48
|
+
export declare function serviceGrantCreate(ownerId: string, input: ServiceGrantInput): LocalOperationCreate;
|
|
49
|
+
/** serviceGrantRevocation withdraws the grant of one service on one wallet: enabled false, no scopes. */
|
|
50
|
+
export declare function serviceGrantRevocation(ownerId: string, target: ServiceGrantTarget): LocalOperationCreate;
|
|
51
|
+
/** parseServiceGrantPage reads exactly one `GET /v1/service-grants` page. */
|
|
52
|
+
export declare function parseServiceGrantPage(payload: unknown): ServiceGrantPage;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The grants an account gives services on its wallets. `service_grant.set`
|
|
3
|
+
* gives one service read access to one wallet the account owns, changes it or
|
|
4
|
+
* withdraws it (`enabled: false`); the person confirms every change with a
|
|
5
|
+
* passkey. `GET /v1/service-grants` lists the grants the account gave, in every
|
|
6
|
+
* state, so the application can show them and offer to withdraw one.
|
|
7
|
+
*/
|
|
8
|
+
import { ClientFlowError, opaqueId, record, rfc3339UTC } from "./auth.js";
|
|
9
|
+
import { pageEnvelope, pageProjection } from "./pages.js";
|
|
10
|
+
const readScopes = ["wallet:read", "operation:read", "streams:read"];
|
|
11
|
+
/** serviceGrantCreate is the closed `service_grant.set` body of the account. */
|
|
12
|
+
export function serviceGrantCreate(ownerId, input) {
|
|
13
|
+
const payload = { service_principal_id: input.servicePrincipalId, enabled: input.enabled, scopes: [...input.scopes] };
|
|
14
|
+
if (input.externalRef !== undefined)
|
|
15
|
+
payload.external_ref = input.externalRef;
|
|
16
|
+
return { kind: "service_grant.set", owner_type: "account", owner_id: ownerId, wallet_id: input.walletId, payload };
|
|
17
|
+
}
|
|
18
|
+
/** serviceGrantRevocation withdraws the grant of one service on one wallet: enabled false, no scopes. */
|
|
19
|
+
export function serviceGrantRevocation(ownerId, target) {
|
|
20
|
+
if (target === null || typeof target !== "object")
|
|
21
|
+
throw new ClientFlowError("invalid_operation_create");
|
|
22
|
+
return serviceGrantCreate(ownerId, { walletId: target.walletId, servicePrincipalId: target.servicePrincipalId, enabled: false, scopes: [] });
|
|
23
|
+
}
|
|
24
|
+
/** parseServiceGrantPage reads exactly one `GET /v1/service-grants` page. */
|
|
25
|
+
export function parseServiceGrantPage(payload) {
|
|
26
|
+
const root = pageEnvelope(payload);
|
|
27
|
+
const items = root.items.map((value) => {
|
|
28
|
+
const item = record(value, ["address", "granted_at", "network", "scopes", "service_principal_id", "state", "wallet_id", "wallet_kind"], ["external_ref"]);
|
|
29
|
+
const scopes = item.scopes;
|
|
30
|
+
if (!opaqueId(item.service_principal_id) || !opaqueId(item.wallet_id) || (item.wallet_kind !== "wallet" && item.wallet_kind !== "linked_wallet") ||
|
|
31
|
+
typeof item.network !== "string" || item.network.length > 64 || typeof item.address !== "string" || item.address.length > 256 ||
|
|
32
|
+
!Array.isArray(scopes) || scopes.length > readScopes.length || new Set(scopes).size !== scopes.length || !scopes.every((scope) => readScopes.includes(scope)) ||
|
|
33
|
+
(item.state !== "pending_source" && item.state !== "active" && item.state !== "revoked" && item.state !== "stale") || !rfc3339UTC(item.granted_at) ||
|
|
34
|
+
(item.external_ref !== undefined && (typeof item.external_ref !== "string" || !/^[\x20-\x7E]{1,128}$/.test(item.external_ref)))) {
|
|
35
|
+
throw new ClientFlowError("invalid_server_response");
|
|
36
|
+
}
|
|
37
|
+
const grant = {
|
|
38
|
+
servicePrincipalId: item.service_principal_id, walletId: item.wallet_id, walletKind: item.wallet_kind, network: item.network, address: item.address,
|
|
39
|
+
scopes: [...scopes], state: item.state, grantedAt: item.granted_at,
|
|
40
|
+
};
|
|
41
|
+
if (item.external_ref !== undefined)
|
|
42
|
+
grant.externalRef = item.external_ref;
|
|
43
|
+
return grant;
|
|
44
|
+
});
|
|
45
|
+
return pageProjection(root.request_id, items, root.has_more, root.next_cursor);
|
|
46
|
+
}
|
package/dist/slice4.d.ts
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { type IdentityMethod, type NextAction } from "./auth.ts";
|
|
2
|
+
import { type WalletLimitsDisplay } from "./walletLimits.ts";
|
|
3
|
+
import { type DebitPermissionDisplay, type DebitPermissionRevokeDisplay } from "./debitPermissionWire.ts";
|
|
4
|
+
import { type ConsentDebitOutcome, type DebitTerms } from "./consentDebit.ts";
|
|
5
|
+
import { type LinkedEnrollmentDisplay, type LinkedRequestGrantEnrollmentCreate, type LinkedRequestGrantResult } from "./modeCLinked.ts";
|
|
6
|
+
export interface HostedIdentityFlow {
|
|
7
|
+
requestId: string;
|
|
8
|
+
flowId: string;
|
|
9
|
+
launchUrl: string;
|
|
10
|
+
expiresAt: number;
|
|
11
|
+
}
|
|
12
|
+
export interface PasskeyBootstrapResult {
|
|
13
|
+
requestId: string;
|
|
14
|
+
credentialId: string;
|
|
15
|
+
version: string;
|
|
16
|
+
state: "active";
|
|
17
|
+
}
|
|
18
|
+
export interface VerifiedIdentityResult {
|
|
19
|
+
requestId: string;
|
|
20
|
+
verifiedIdentityHandle: string;
|
|
21
|
+
expiresAt: number;
|
|
22
|
+
}
|
|
23
|
+
export type IdentityVerificationMethod = IdentityMethod;
|
|
24
|
+
/**
|
|
25
|
+
* AccountIdentity is one active sign-in method of the account. A passkey
|
|
26
|
+
* carries credentialId: the credential to name when a confirmation is asked
|
|
27
|
+
* for, also in a browser that did not create that passkey.
|
|
28
|
+
*/
|
|
29
|
+
export interface AccountIdentity {
|
|
30
|
+
identityId: string;
|
|
31
|
+
method: IdentityMethod;
|
|
32
|
+
credentialId?: string;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
}
|
|
35
|
+
/** parseIdentityList accepts the closed answer of GET /v1/identities. */
|
|
36
|
+
export declare function parseIdentityList(payload: unknown): AccountIdentity[];
|
|
37
|
+
/**
|
|
38
|
+
* wallet_limits.set changes a linked wallet's limits (LinkedWallets.setLimits); its result kind is wallet_limits.
|
|
39
|
+
* session.authorize_requests enrolls a Mode C request key on a linked wallet (modeCLinked.ts); its result kind is
|
|
40
|
+
* request_grant, with the grant. debit_permission.create and debit_permission.revoke give and end a service's
|
|
41
|
+
* permission to debit a linked wallet without the device (debitPermissions.ts); their result kind is debit_permission.
|
|
42
|
+
*/
|
|
43
|
+
export type LocalOperationKind = "identity.link" | "identity.unlink" | "session.revoke" | "service_grant.set" | "wallet_limits.set" | "session.authorize_requests" | "debit_permission.create" | "debit_permission.revoke";
|
|
44
|
+
export type LocalResultKind = "identity" | "session" | "service_grant" | "wallet_limits" | "request_grant" | "debit_permission";
|
|
45
|
+
export type LocalResultState = "active" | "revoked";
|
|
46
|
+
export type ServiceReadScope = "wallet:read" | "operation:read" | "streams:read";
|
|
47
|
+
export type ResultRecipient = {
|
|
48
|
+
type: "account" | "service";
|
|
49
|
+
id: string;
|
|
50
|
+
};
|
|
51
|
+
type LocalOperationCommon = {
|
|
52
|
+
owner_type: "account";
|
|
53
|
+
owner_id: string;
|
|
54
|
+
result_recipient?: ResultRecipient;
|
|
55
|
+
};
|
|
56
|
+
export type LocalOperationCreate = (LocalOperationCommon & {
|
|
57
|
+
kind: "identity.link";
|
|
58
|
+
payload: {
|
|
59
|
+
verified_identity_handle: string;
|
|
60
|
+
};
|
|
61
|
+
}) | (LocalOperationCommon & {
|
|
62
|
+
kind: "identity.unlink";
|
|
63
|
+
payload: {
|
|
64
|
+
identity_id: string;
|
|
65
|
+
};
|
|
66
|
+
}) | (LocalOperationCommon & {
|
|
67
|
+
kind: "session.revoke";
|
|
68
|
+
payload: {
|
|
69
|
+
session_id: string;
|
|
70
|
+
};
|
|
71
|
+
}) | (LocalOperationCommon & {
|
|
72
|
+
kind: "service_grant.set";
|
|
73
|
+
wallet_id: string;
|
|
74
|
+
payload: {
|
|
75
|
+
service_principal_id: string;
|
|
76
|
+
enabled: boolean;
|
|
77
|
+
scopes: ServiceReadScope[];
|
|
78
|
+
external_ref?: string;
|
|
79
|
+
};
|
|
80
|
+
}) | LinkedRequestGrantEnrollmentCreate;
|
|
81
|
+
export type OperationDisplay = {
|
|
82
|
+
kind: "identity.link";
|
|
83
|
+
ownerId: string;
|
|
84
|
+
requesterId: string;
|
|
85
|
+
method: IdentityMethod;
|
|
86
|
+
} | {
|
|
87
|
+
kind: "identity.unlink";
|
|
88
|
+
ownerId: string;
|
|
89
|
+
requesterId: string;
|
|
90
|
+
identityId: string;
|
|
91
|
+
} | {
|
|
92
|
+
kind: "session.revoke";
|
|
93
|
+
ownerId: string;
|
|
94
|
+
requesterId: string;
|
|
95
|
+
sessionId: string;
|
|
96
|
+
} | {
|
|
97
|
+
kind: "service_grant.set";
|
|
98
|
+
ownerId: string;
|
|
99
|
+
requesterId: string;
|
|
100
|
+
walletId: string;
|
|
101
|
+
servicePrincipalId: string;
|
|
102
|
+
enabled: boolean;
|
|
103
|
+
scopes: ServiceReadScope[];
|
|
104
|
+
externalRef?: string;
|
|
105
|
+
debit?: DebitTerms;
|
|
106
|
+
} | WalletLimitsDisplay | LinkedEnrollmentDisplay | DebitPermissionDisplay | DebitPermissionRevokeDisplay;
|
|
107
|
+
export interface LocalOperation {
|
|
108
|
+
id: string;
|
|
109
|
+
version: string;
|
|
110
|
+
kind: LocalOperationKind;
|
|
111
|
+
state: "awaiting_confirmation" | "authorized" | "pending_target_fence" | "succeeded" | "failed" | "denied" | "canceled" | "expired";
|
|
112
|
+
effectState: "no_effect" | "known";
|
|
113
|
+
authorizationBasis: "" | "user_confirmed";
|
|
114
|
+
ownerType: "account";
|
|
115
|
+
ownerId: string;
|
|
116
|
+
requesterId: string;
|
|
117
|
+
walletId?: string;
|
|
118
|
+
requestFingerprint: string;
|
|
119
|
+
operationFingerprint: string;
|
|
120
|
+
display: OperationDisplay;
|
|
121
|
+
/** UTC RFC 3339 date-time string (source §2.2), not NumericDate seconds. */
|
|
122
|
+
createdAt: string;
|
|
123
|
+
/** UTC RFC 3339 date-time string (source §2.2), not NumericDate seconds. */
|
|
124
|
+
expiresAt: string;
|
|
125
|
+
confirmationLocation?: string;
|
|
126
|
+
resultKind?: LocalResultKind;
|
|
127
|
+
nextAction: NextAction;
|
|
128
|
+
}
|
|
129
|
+
export interface ConfirmationChallenge {
|
|
130
|
+
requestId: string;
|
|
131
|
+
challengeId: string;
|
|
132
|
+
publicKey: {
|
|
133
|
+
challenge: string;
|
|
134
|
+
rpId: string;
|
|
135
|
+
timeoutMs: number;
|
|
136
|
+
allowCredentials: [{
|
|
137
|
+
type: "public-key";
|
|
138
|
+
id: string;
|
|
139
|
+
}];
|
|
140
|
+
userVerification: "required";
|
|
141
|
+
};
|
|
142
|
+
confirmationLocation: string;
|
|
143
|
+
/** UTC RFC 3339 date-time string (source §2.2), not NumericDate seconds. */
|
|
144
|
+
expiresAt: string;
|
|
145
|
+
/** The registered redirect the host's launcher answered once the page came back, when it answered one; complete…Confirmation() takes it. */
|
|
146
|
+
callbackUri?: string;
|
|
147
|
+
}
|
|
148
|
+
export interface LocalOperationResult {
|
|
149
|
+
requestId: string;
|
|
150
|
+
/**
|
|
151
|
+
* grant is present for the request_grant kind of a linked wallet's enrollment; debit for a service_grant whose service
|
|
152
|
+
* holds wallet:debit:user: the debit permission the grant's passkey also created (consentDebit.ts).
|
|
153
|
+
*/
|
|
154
|
+
result: {
|
|
155
|
+
kind: LocalResultKind;
|
|
156
|
+
targetId: string;
|
|
157
|
+
newVersion: string;
|
|
158
|
+
state: LocalResultState;
|
|
159
|
+
grant?: LinkedRequestGrantResult;
|
|
160
|
+
debit?: ConsentDebitOutcome;
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
export declare function parseHostedIdentityFlow(payload: unknown, now: number): HostedIdentityFlow;
|
|
164
|
+
export declare function parsePasskeyBootstrapResult(payload: unknown): PasskeyBootstrapResult;
|
|
165
|
+
export declare function parseVerifiedIdentityResult(payload: unknown, now: number): VerifiedIdentityResult;
|
|
166
|
+
export declare function parseIdentityFlowCallback(value: string, expectedRedirect: string): {
|
|
167
|
+
flowId: string;
|
|
168
|
+
state: string;
|
|
169
|
+
code: string;
|
|
170
|
+
};
|
|
171
|
+
export declare function validateLocalOperationCreate(value: LocalOperationCreate, expectedOwnerId: string): LocalOperationCreate;
|
|
172
|
+
export declare function parseOperationEnvelope(payload: unknown): {
|
|
173
|
+
requestId: string;
|
|
174
|
+
operation: LocalOperation;
|
|
175
|
+
};
|
|
176
|
+
export declare function parseOperation(payload: unknown): LocalOperation;
|
|
177
|
+
export declare function parseConfirmationChallenge(payload: unknown, now: number): ConfirmationChallenge;
|
|
178
|
+
export declare function parseOperationConfirmationCallback(value: string, expectedRedirect: string): {
|
|
179
|
+
state: string;
|
|
180
|
+
operationId: string;
|
|
181
|
+
};
|
|
182
|
+
export declare function parseLocalOperationResult(payload: unknown): LocalOperationResult;
|
|
183
|
+
/** serviceScopes accepts the read scopes of a service grant: at most the three, each once (none: a withdrawal). */
|
|
184
|
+
export declare function serviceScopes(value: unknown): value is ServiceReadScope[];
|
|
185
|
+
/** printableReference accepts a grant's external_ref: 1 to 128 printable ASCII characters. */
|
|
186
|
+
export declare function printableReference(value: unknown): value is string;
|
|
187
|
+
export {};
|