@dexterai/vault 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 (43) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +61 -0
  3. package/dist/constants/index.cjs +92 -0
  4. package/dist/constants/index.d.cts +34 -0
  5. package/dist/constants/index.d.ts +34 -0
  6. package/dist/constants/index.js +57 -0
  7. package/dist/counterfactual.cjs +138 -0
  8. package/dist/counterfactual.d.cts +17 -0
  9. package/dist/counterfactual.d.ts +17 -0
  10. package/dist/counterfactual.js +113 -0
  11. package/dist/index.cjs +140 -0
  12. package/dist/index.d.cts +2 -0
  13. package/dist/index.d.ts +2 -0
  14. package/dist/index.js +113 -0
  15. package/dist/instructions/index.cjs +5016 -0
  16. package/dist/instructions/index.d.cts +290 -0
  17. package/dist/instructions/index.d.ts +290 -0
  18. package/dist/instructions/index.js +4989 -0
  19. package/dist/messages/index.cjs +156 -0
  20. package/dist/messages/index.d.cts +89 -0
  21. package/dist/messages/index.d.ts +89 -0
  22. package/dist/messages/index.js +125 -0
  23. package/dist/precompile/index.cjs +192 -0
  24. package/dist/precompile/index.d.cts +45 -0
  25. package/dist/precompile/index.d.ts +45 -0
  26. package/dist/precompile/index.js +149 -0
  27. package/dist/reader/index.cjs +121 -0
  28. package/dist/reader/index.d.cts +41 -0
  29. package/dist/reader/index.d.ts +41 -0
  30. package/dist/reader/index.js +93 -0
  31. package/dist/signers/node/index.cjs +62 -0
  32. package/dist/signers/node/index.d.cts +21 -0
  33. package/dist/signers/node/index.d.ts +21 -0
  34. package/dist/signers/node/index.js +27 -0
  35. package/dist/signers/types.cjs +18 -0
  36. package/dist/signers/types.d.cts +34 -0
  37. package/dist/signers/types.d.ts +34 -0
  38. package/dist/signers/types.js +0 -0
  39. package/dist/types.cjs +18 -0
  40. package/dist/types.d.cts +104 -0
  41. package/dist/types.d.ts +104 -0
  42. package/dist/types.js +0 -0
  43. package/package.json +53 -0
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Signer abstractions.
3
+ *
4
+ * Ed25519Signer is shipped with a Node implementation in v0.1.
5
+ * PasskeySigner is shipped as INTERFACE ONLY in v0.1 — the WebAuthn
6
+ * implementation is tracked as task #235 ("@dexterai/vault v0.2 —
7
+ * BrowserPasskeySigner") and must lift from dexter-fe/app/lib/passkey.ts +
8
+ * dexter-fe/app/lib/passkey-anon.ts. Until v0.2 ships, dexter-fe stays on
9
+ * its hand-rolled passkey ceremony.
10
+ */
11
+ interface Ed25519Signer {
12
+ /** 32-byte public key. */
13
+ readonly publicKey: Uint8Array;
14
+ /** Produce a 64-byte detached signature over `message`. */
15
+ sign(message: Uint8Array): Promise<Uint8Array>;
16
+ }
17
+ interface PasskeySigner {
18
+ /** Opaque credential ID handed back to the platform authenticator. */
19
+ readonly credentialId: Uint8Array;
20
+ /**
21
+ * Run the WebAuthn assertion ceremony over `challenge` and return the
22
+ * three things the precompile needs.
23
+ *
24
+ * Implementation: TASK #235. dexter-fe currently ships an equivalent
25
+ * function in app/lib/passkey.ts (`signOperation`) — the lift target.
26
+ */
27
+ sign(challenge: Uint8Array): Promise<{
28
+ signature: Uint8Array;
29
+ clientDataJSON: Uint8Array;
30
+ authenticatorData: Uint8Array;
31
+ }>;
32
+ }
33
+
34
+ export type { Ed25519Signer, PasskeySigner };
File without changes
package/dist/types.cjs ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/types.ts
17
+ var types_exports = {};
18
+ module.exports = __toCommonJS(types_exports);
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Canonical types for vault state, sessions, and vouchers.
3
+ *
4
+ * This file merges three previously-separate type contracts:
5
+ * - dexter-api/src/vault/vaultState.types.ts
6
+ * - dexter-x402-sdk/src/tab/types.ts (the session/voucher half)
7
+ * - dexter-facilitator/src/vault/vaultReader.ts (the ActiveSession shape)
8
+ *
9
+ * The on-chain program (dexter-vault v2) is the ultimate referee; these
10
+ * types describe the off-chain mirror of its state.
11
+ */
12
+ interface PendingWithdrawal {
13
+ amount: string;
14
+ destination: string;
15
+ requestedAt: number;
16
+ }
17
+ interface ActiveSession {
18
+ sessionPubkey: Uint8Array;
19
+ maxAmount: bigint;
20
+ expiresAt: number;
21
+ allowedCounterparty: string;
22
+ nonce: number;
23
+ spent: bigint;
24
+ }
25
+ interface VaultOnchainState {
26
+ exists: boolean;
27
+ pendingVoucherCount: number;
28
+ pendingWithdrawal: PendingWithdrawal | null;
29
+ }
30
+ interface VaultStateFull {
31
+ exists: boolean;
32
+ version: number;
33
+ swigAddress: string | null;
34
+ dexterAuthority: string | null;
35
+ pendingVoucherCount: number;
36
+ activeSession: ActiveSession | null;
37
+ }
38
+ type VaultStatus = 'not_enrolled' | 'awaiting_ceremony' | 'provisioning' | 'ready';
39
+ type VaultStateKey = {
40
+ kind: 'account';
41
+ supabaseUserId: string;
42
+ } | {
43
+ kind: 'handle';
44
+ userHandle: Uint8Array;
45
+ } | {
46
+ kind: 'session';
47
+ mcpSessionId: string;
48
+ };
49
+ interface VaultStateOnchainExtended {
50
+ vaultExists: boolean;
51
+ pendingVoucherCount: number | null;
52
+ withdrawalBlocked: boolean;
53
+ pendingWithdrawal: PendingWithdrawal | null;
54
+ recovery: {
55
+ available: boolean;
56
+ availableAt: number | null;
57
+ reason: string;
58
+ };
59
+ usdcAtaExists: boolean;
60
+ usdcAtomic: string;
61
+ }
62
+ interface VaultState {
63
+ status: VaultStatus;
64
+ vault: {
65
+ vaultPda: string;
66
+ swigAddress: string;
67
+ coolingOffSeconds: number;
68
+ initializedAt: string | Date;
69
+ faucetDrippedAt: string | Date | null;
70
+ } | null;
71
+ credentialId: string | null;
72
+ deviceLabel: string | null;
73
+ enrolledAt: string | Date | null;
74
+ claimedBySupabaseUser: boolean;
75
+ onchain: VaultStateOnchainExtended | null;
76
+ }
77
+ type TabNetworkId = 'solana:mainnet' | (string & {});
78
+ type AtomicAmount = string;
79
+ type HumanAmount = string;
80
+ interface SessionScope {
81
+ channelId: string;
82
+ maxAmountAtomic: AtomicAmount;
83
+ expiresAtUnix: number;
84
+ allowedCounterparty: string;
85
+ }
86
+ interface SessionKey {
87
+ publicKey: Uint8Array;
88
+ privateKey: Uint8Array;
89
+ scope: SessionScope;
90
+ registration: Uint8Array;
91
+ }
92
+ interface VoucherPayload {
93
+ channelId: string;
94
+ cumulativeAmount: AtomicAmount;
95
+ sequenceNumber: number;
96
+ }
97
+ interface SignedVoucher {
98
+ payload: VoucherPayload;
99
+ sessionPublicKey: Uint8Array;
100
+ sessionRegistration: Uint8Array;
101
+ sessionSignature: Uint8Array;
102
+ }
103
+
104
+ export type { ActiveSession, AtomicAmount, HumanAmount, PendingWithdrawal, SessionKey, SessionScope, SignedVoucher, TabNetworkId, VaultOnchainState, VaultState, VaultStateFull, VaultStateKey, VaultStateOnchainExtended, VaultStatus, VoucherPayload };
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Canonical types for vault state, sessions, and vouchers.
3
+ *
4
+ * This file merges three previously-separate type contracts:
5
+ * - dexter-api/src/vault/vaultState.types.ts
6
+ * - dexter-x402-sdk/src/tab/types.ts (the session/voucher half)
7
+ * - dexter-facilitator/src/vault/vaultReader.ts (the ActiveSession shape)
8
+ *
9
+ * The on-chain program (dexter-vault v2) is the ultimate referee; these
10
+ * types describe the off-chain mirror of its state.
11
+ */
12
+ interface PendingWithdrawal {
13
+ amount: string;
14
+ destination: string;
15
+ requestedAt: number;
16
+ }
17
+ interface ActiveSession {
18
+ sessionPubkey: Uint8Array;
19
+ maxAmount: bigint;
20
+ expiresAt: number;
21
+ allowedCounterparty: string;
22
+ nonce: number;
23
+ spent: bigint;
24
+ }
25
+ interface VaultOnchainState {
26
+ exists: boolean;
27
+ pendingVoucherCount: number;
28
+ pendingWithdrawal: PendingWithdrawal | null;
29
+ }
30
+ interface VaultStateFull {
31
+ exists: boolean;
32
+ version: number;
33
+ swigAddress: string | null;
34
+ dexterAuthority: string | null;
35
+ pendingVoucherCount: number;
36
+ activeSession: ActiveSession | null;
37
+ }
38
+ type VaultStatus = 'not_enrolled' | 'awaiting_ceremony' | 'provisioning' | 'ready';
39
+ type VaultStateKey = {
40
+ kind: 'account';
41
+ supabaseUserId: string;
42
+ } | {
43
+ kind: 'handle';
44
+ userHandle: Uint8Array;
45
+ } | {
46
+ kind: 'session';
47
+ mcpSessionId: string;
48
+ };
49
+ interface VaultStateOnchainExtended {
50
+ vaultExists: boolean;
51
+ pendingVoucherCount: number | null;
52
+ withdrawalBlocked: boolean;
53
+ pendingWithdrawal: PendingWithdrawal | null;
54
+ recovery: {
55
+ available: boolean;
56
+ availableAt: number | null;
57
+ reason: string;
58
+ };
59
+ usdcAtaExists: boolean;
60
+ usdcAtomic: string;
61
+ }
62
+ interface VaultState {
63
+ status: VaultStatus;
64
+ vault: {
65
+ vaultPda: string;
66
+ swigAddress: string;
67
+ coolingOffSeconds: number;
68
+ initializedAt: string | Date;
69
+ faucetDrippedAt: string | Date | null;
70
+ } | null;
71
+ credentialId: string | null;
72
+ deviceLabel: string | null;
73
+ enrolledAt: string | Date | null;
74
+ claimedBySupabaseUser: boolean;
75
+ onchain: VaultStateOnchainExtended | null;
76
+ }
77
+ type TabNetworkId = 'solana:mainnet' | (string & {});
78
+ type AtomicAmount = string;
79
+ type HumanAmount = string;
80
+ interface SessionScope {
81
+ channelId: string;
82
+ maxAmountAtomic: AtomicAmount;
83
+ expiresAtUnix: number;
84
+ allowedCounterparty: string;
85
+ }
86
+ interface SessionKey {
87
+ publicKey: Uint8Array;
88
+ privateKey: Uint8Array;
89
+ scope: SessionScope;
90
+ registration: Uint8Array;
91
+ }
92
+ interface VoucherPayload {
93
+ channelId: string;
94
+ cumulativeAmount: AtomicAmount;
95
+ sequenceNumber: number;
96
+ }
97
+ interface SignedVoucher {
98
+ payload: VoucherPayload;
99
+ sessionPublicKey: Uint8Array;
100
+ sessionRegistration: Uint8Array;
101
+ sessionSignature: Uint8Array;
102
+ }
103
+
104
+ export type { ActiveSession, AtomicAmount, HumanAmount, PendingWithdrawal, SessionKey, SessionScope, SignedVoucher, TabNetworkId, VaultOnchainState, VaultState, VaultStateFull, VaultStateKey, VaultStateOnchainExtended, VaultStatus, VoucherPayload };
package/dist/types.js ADDED
File without changes
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@dexterai/vault",
3
+ "version": "0.1.0",
4
+ "description": "Canonical off-chain mirror of the dexter-vault Solana Anchor program — Solana instruction builders, byte-precise message encoders, account decoders, secp256r1/Ed25519 precompile helpers, counterfactual Swig derivation, and signer interfaces. The single source of truth for any TypeScript code that produces bytes the on-chain program will verify.",
5
+ "author": "Dexter",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" },
10
+ "./types": { "types": "./dist/types.d.ts", "import": "./dist/types.js", "require": "./dist/types.cjs" },
11
+ "./constants": { "types": "./dist/constants/index.d.ts", "import": "./dist/constants/index.js", "require": "./dist/constants/index.cjs" },
12
+ "./counterfactual": { "types": "./dist/counterfactual.d.ts", "import": "./dist/counterfactual.js", "require": "./dist/counterfactual.cjs" },
13
+ "./instructions": { "types": "./dist/instructions/index.d.ts", "import": "./dist/instructions/index.js", "require": "./dist/instructions/index.cjs" },
14
+ "./messages": { "types": "./dist/messages/index.d.ts", "import": "./dist/messages/index.js", "require": "./dist/messages/index.cjs" },
15
+ "./reader": { "types": "./dist/reader/index.d.ts", "import": "./dist/reader/index.js", "require": "./dist/reader/index.cjs" },
16
+ "./precompile": { "types": "./dist/precompile/index.d.ts", "import": "./dist/precompile/index.js", "require": "./dist/precompile/index.cjs" },
17
+ "./signers": { "types": "./dist/signers/types.d.ts", "import": "./dist/signers/types.js", "require": "./dist/signers/types.cjs" },
18
+ "./signers/node": { "types": "./dist/signers/node/index.d.ts", "import": "./dist/signers/node/index.js", "require": "./dist/signers/node/index.cjs" }
19
+ },
20
+ "files": ["dist", "README.md", "LICENSE"],
21
+ "scripts": {
22
+ "build": "tsup",
23
+ "dev": "tsup --watch",
24
+ "typecheck": "tsc --noEmit",
25
+ "test": "vitest run",
26
+ "test:watch": "vitest",
27
+ "prepublishOnly": "npm run build && npm test",
28
+ "release": "npm version patch && npm publish --access public",
29
+ "release:minor": "npm version minor && npm publish --access public",
30
+ "release:major": "npm version major && npm publish --access public"
31
+ },
32
+ "dependencies": {
33
+ "@noble/curves": "^1.9.7",
34
+ "@noble/hashes": "^1.8.0",
35
+ "@solana/spl-token": "^0.4.9",
36
+ "@solana/web3.js": "^1.98.0",
37
+ "@swig-wallet/kit": "^1.9.0",
38
+ "@swig-wallet/lib": "^1.9.0",
39
+ "bs58": "^6.0.0",
40
+ "tweetnacl": "^1.0.3"
41
+ },
42
+ "devDependencies": {
43
+ "@types/node": "^22.10.0",
44
+ "tsup": "^8.3.5",
45
+ "typescript": "^5.7.2",
46
+ "vitest": "^2.1.8"
47
+ },
48
+ "engines": { "node": ">=18" },
49
+ "keywords": ["solana", "dexter", "vault", "passkey", "webauthn", "swig", "secp256r1", "ed25519", "ots", "tab", "x402"],
50
+ "repository": { "type": "git", "url": "https://github.com/Dexter-DAO/dexter-vault-sdk" },
51
+ "homepage": "https://dexter.cash",
52
+ "bugs": { "url": "https://github.com/Dexter-DAO/dexter-vault-sdk/issues" }
53
+ }