@dexterai/connect 0.34.0 → 0.36.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 +21 -0
- package/dist/{accountIdentity-DQ_C-WAi.d.ts → accountIdentity-BHazSkuz.d.ts} +1 -8
- package/dist/{chunk-SLI2QCWN.js → chunk-5B3IO3JU.js} +22 -1
- package/dist/{chunk-Q7HTBUJF.js → chunk-SGWYN67U.js} +679 -935
- package/dist/{chunk-3SBEND6T.js → chunk-ZVUFVXUG.js} +1 -1
- package/dist/{connectionContract-BA03zq2D.d.ts → connectionContract-CSZiddpS.d.ts} +1 -1
- package/dist/hosted.d.ts +1 -1
- package/dist/hosted.js +5 -12
- package/dist/index.d.ts +151 -9
- package/dist/index.js +225 -28
- package/dist/react.d.ts +18 -4
- package/dist/react.js +86 -11
- package/package.json +13 -1
package/README.md
CHANGED
|
@@ -92,6 +92,27 @@ await sendFromAccount({ identity, send: { mint, amount: '2500000', to } });
|
|
|
92
92
|
- With lazy opening, sign-up's approvals are checked and held, not sent. Each setup step can be confirmed with `signature: null`, and the Account's status is then `held`: its address takes money at once and it opens on the chain by itself on the first money or the first action. Show a `held` Account exactly like a `ready` one; `openAccount` returns it without prompting. A send is never taken as confirmed without the signature of what it sent.
|
|
93
93
|
- The first action on a held Account finishes the opening inside that request, so it can take a minute. Connect sets no timeout of its own on these requests.
|
|
94
94
|
|
|
95
|
+
### Agent connections
|
|
96
|
+
|
|
97
|
+
An agent asks through OAuth to pay on the owner's behalf. The owner reviews the request and approves one exact spending permission with their passkey, through the same approval step as setup and send.
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
import { getConnectionRequest, grantConnection, listConnections, revokeConnection } from '@dexterai/connect';
|
|
101
|
+
|
|
102
|
+
const review = await getConnectionRequest({ identity, requestId }); // client, limits, payee: show them as sent
|
|
103
|
+
const { redirectUrl } = await grantConnection({ identity, request: review, confirmStep, onStep });
|
|
104
|
+
window.location.assign(redirectUrl); // only ever on review.client.redirectHost
|
|
105
|
+
|
|
106
|
+
const connections = await listConnections({ identity });
|
|
107
|
+
await revokeConnection({ identity, connectionId, confirmStep, onStep });
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
- The API holds every figure (per payment, per 30 days, how long). Show what it returns, and write no amount into a page.
|
|
111
|
+
- `grantConnection` refuses to prompt for anything but `grant-permission`, and refuses a redirect to any host but the one the request named (`connection_redirect_refused`).
|
|
112
|
+
- A connection is `pending` (an approval that didn't finish; stop it to abandon it), `active`, `stopped` or `revoked`.
|
|
113
|
+
- `revokeConnection`: Dexter's servers stop signing for the connection when the stop is prepared (`connection.state` is `stopped` in the step view). The passkey approval then revokes the permission on chain, and the result's state is `revoked`.
|
|
114
|
+
- A lost reply leaves the step unsettled with `flow: 'connection'`, the same as a send.
|
|
115
|
+
|
|
95
116
|
## Interrupted wallet setup
|
|
96
117
|
|
|
97
118
|
`createWallet()` retains the original passkey when setup is interrupted. Calling
|
|
@@ -265,14 +265,7 @@ interface CreateWalletResult {
|
|
|
265
265
|
/** Dexter-signed proof used to restore this Wallet's account relationship. */
|
|
266
266
|
walletIdentityProof: WalletIdentityProof;
|
|
267
267
|
}
|
|
268
|
-
/**
|
|
269
|
-
* Mint a brand-new Dexter wallet (passkey + vault). Commit mode (the default)
|
|
270
|
-
* makes it active immediately; provisional mode returns it without changing
|
|
271
|
-
* the active-wallet store.
|
|
272
|
-
*
|
|
273
|
-
* One passkey approval. Throws ConnectError on any failed leg (the `code` is the
|
|
274
|
-
* server's error string, or webauthn_failed / no_credential for the ceremony).
|
|
275
|
-
*/
|
|
268
|
+
/** Always rejects with `dexter_wallet_closed`. Use enrollAccountIdentity for new users. */
|
|
276
269
|
declare function createWallet(config?: CreateWalletConfig): Promise<CreateWalletResult>;
|
|
277
270
|
|
|
278
271
|
declare const ACCOUNT_IDENTITY_API_PATH = "/api/connect/account-identity";
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
subscribe,
|
|
11
11
|
walletBindingCandidate,
|
|
12
12
|
walletProofSessionStore
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-SGWYN67U.js";
|
|
14
14
|
|
|
15
15
|
// src/relationController.ts
|
|
16
16
|
function provisionalRelation(walletPresent, accountPresent) {
|
|
@@ -533,6 +533,24 @@ function createDexterControlModel(intent, relation) {
|
|
|
533
533
|
});
|
|
534
534
|
}
|
|
535
535
|
|
|
536
|
+
// src/policy.ts
|
|
537
|
+
var SESSION_TTL_30D = "2592000";
|
|
538
|
+
function usdToAtomic(input) {
|
|
539
|
+
const cleaned = input.trim().replace(/^\$/, "").replace(/,/g, "");
|
|
540
|
+
if (!/^\d+(\.\d{1,6})?$/.test(cleaned)) return null;
|
|
541
|
+
const [whole, frac = ""] = cleaned.split(".");
|
|
542
|
+
try {
|
|
543
|
+
return BigInt(whole) * 1000000n + BigInt((frac + "000000").slice(0, 6));
|
|
544
|
+
} catch {
|
|
545
|
+
return null;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
function authoredPolicy(usdInput) {
|
|
549
|
+
const atomic = usdToAtomic(usdInput);
|
|
550
|
+
if (atomic === null || atomic <= 0n) return null;
|
|
551
|
+
return { spendLimitAtomic: atomic.toString(), sessionTtlSeconds: SESSION_TTL_30D };
|
|
552
|
+
}
|
|
553
|
+
|
|
536
554
|
// src/phase.ts
|
|
537
555
|
var PHASE_LABEL = {
|
|
538
556
|
challenge: "Preparing\u2026",
|
|
@@ -610,6 +628,9 @@ export {
|
|
|
610
628
|
connectDexterIdentity,
|
|
611
629
|
disconnectDexterIdentity,
|
|
612
630
|
createDexterControlModel,
|
|
631
|
+
SESSION_TTL_30D,
|
|
632
|
+
usdToAtomic,
|
|
633
|
+
authoredPolicy,
|
|
613
634
|
ceremonyPhaseLabel,
|
|
614
635
|
passkeySignalSupport,
|
|
615
636
|
renamePasskey,
|