@capxul/sdk 1.0.0-alpha.9 → 1.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/README.md +121 -6
- package/dist/{InMemoryAuthCacheAdapter-v5W-XB5M.mjs → InMemoryAuthCacheAdapter-Dr1sEd9y.mjs} +36 -16
- package/dist/InMemoryAuthCacheAdapter-Dr1sEd9y.mjs.map +1 -0
- package/dist/create-capxul-client-C7H5b68l.d.mts +2764 -0
- package/dist/create-capxul-client-C7H5b68l.d.mts.map +1 -0
- package/dist/create-capxul-client-DiqVIxsV.mjs +6980 -0
- package/dist/create-capxul-client-DiqVIxsV.mjs.map +1 -0
- package/dist/index.d.mts +119 -2020
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2464 -6308
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.d.mts +3 -6
- package/dist/node/index.d.mts.map +1 -1
- package/dist/node/index.mjs +27 -27
- package/dist/node/index.mjs.map +1 -1
- package/dist/signer-CJT0pPiO.d.mts +301 -0
- package/dist/signer-CJT0pPiO.d.mts.map +1 -0
- package/dist/testing/index.d.mts +54 -0
- package/dist/testing/index.d.mts.map +1 -0
- package/dist/testing/index.mjs +1068 -0
- package/dist/testing/index.mjs.map +1 -0
- package/package.json +17 -18
- package/dist/InMemoryAuthCacheAdapter-v5W-XB5M.mjs.map +0 -1
- package/dist/index-CTXgQ_xR.d.mts +0 -158
- package/dist/index-CTXgQ_xR.d.mts.map +0 -1
- package/dist/ports/safe-deployment.d.mts +0 -2
- package/dist/ports/safe-deployment.mjs +0 -38
- package/dist/ports/safe-deployment.mjs.map +0 -1
- package/dist/safe-deployment-D3k9yndM.d.mts +0 -136
- package/dist/safe-deployment-D3k9yndM.d.mts.map +0 -1
- package/dist/signer-DqDtJU1l.d.mts +0 -145
- package/dist/signer-DqDtJU1l.d.mts.map +0 -1
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Context, Data } from "effect";
|
|
2
|
-
//#region src/ports/safe-deployment.ts
|
|
3
|
-
/**
|
|
4
|
-
* Typed error for SafeDeploymentPort operations. Mirrors the shape used
|
|
5
|
-
* by `SmartAccountError` (see `ports/smart-account.ts`) so the two
|
|
6
|
-
* domain ports compose uniformly into the deploy slice (#161).
|
|
7
|
-
*/
|
|
8
|
-
var SafeDeploymentError = class extends Data.TaggedError("SafeDeploymentError") {};
|
|
9
|
-
/**
|
|
10
|
-
* Wrap a `CapxulError` as a `SafeDeploymentError`. Adapter helper —
|
|
11
|
-
* used at every failure boundary inside a `SafeDeploymentPort` method
|
|
12
|
-
* to preserve the operation that failed alongside the typed public
|
|
13
|
-
* error.
|
|
14
|
-
*
|
|
15
|
-
* Mirrors the `smartAccountErrorFromCapxul` helper on `SmartAccountPort`
|
|
16
|
-
* — both ports follow the same Effect-native pattern: tagged port-error
|
|
17
|
-
* carries `operation` + `publicCode` + `publicError`, and the helper
|
|
18
|
-
* keeps `details` optional so the call site doesn't have to.
|
|
19
|
-
*
|
|
20
|
-
* @param operation - The port method that failed (e.g. `"deploy"`)
|
|
21
|
-
* @param error - The originating `CapxulError`
|
|
22
|
-
* @param cause - Underlying cause; defaults to `error` itself
|
|
23
|
-
* @returns A `SafeDeploymentError` ready to throw via `Effect.fail`
|
|
24
|
-
*/
|
|
25
|
-
function safeDeploymentErrorFromCapxul(operation, error, cause = error) {
|
|
26
|
-
return new SafeDeploymentError({
|
|
27
|
-
operation,
|
|
28
|
-
publicCode: error.code,
|
|
29
|
-
publicError: error,
|
|
30
|
-
cause,
|
|
31
|
-
...error.details === void 0 ? {} : { details: error.details }
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
var SafeDeploymentPortTag = class extends Context.Tag("@capxul/sdk/ports/SafeDeploymentPort")() {};
|
|
35
|
-
//#endregion
|
|
36
|
-
export { SafeDeploymentError, SafeDeploymentPortTag, safeDeploymentErrorFromCapxul };
|
|
37
|
-
|
|
38
|
-
//# sourceMappingURL=safe-deployment.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"safe-deployment.mjs","names":[],"sources":["../../src/ports/safe-deployment.ts"],"sourcesContent":["import { Context, Data, Effect } from \"effect\";\nimport type { Account } from \"viem\";\n\nimport type { CapxulError, CapxulErrorCode, CapxulErrorDetails } from \"@capxul/config\";\nimport type { Address, BlockNumber, ChainId, DurationMs, Email, TxHash } from \"@capxul/types\";\n\n/**\n * Configuration for a Safe deployment: the chain + RPC endpoint +\n * gas-sponsorship policy the adapter should use.\n *\n * `receiptTimeoutMs` is optional; the production adapter applies a\n * default when omitted. The in-memory adapter ignores it.\n */\nexport type SafeDeploymentConfig = {\n readonly chainId: ChainId;\n readonly rpcUrl: string;\n readonly gasPolicyId: string;\n readonly receiptTimeoutMs?: DurationMs;\n};\n\n/**\n * Result of `prepare`: the counterfactual Safe address derived from\n * `(signerAddress, email)` without any on-chain side effect.\n */\nexport type PreparedSafeAccount = {\n readonly chainId: ChainId;\n readonly signerAddress: Address;\n readonly safeAddress: Address;\n};\n\n/**\n * Evidence of a successful Safe deployment.\n *\n * Every field except `chainId` / `signerAddress` / `safeAddress` is\n * optional because the AC8 precheck short-circuit path (Safe already\n * on-chain at this address; off-chain receipt evidence unavailable)\n * calls the persistence step WITHOUT a `userOpHash`, `txHash`, or\n * `blockNumber` — there is no recoverable transaction. Aaron's rule:\n * \"If there is no TX and it hasn't been deployed then there shouldn't\n * be a hash.\" End-to-end nullable: `v.optional(v.string())` in the\n * backend schema.\n *\n * **`deployedAt` is NOT a field on this type.** The SDK is never the\n * oracle for `deployedAt`. The backend (`confirmDeployment` action —\n * Convex mutations cannot `fetch`, so the chain re-verification lives\n * in an action) derives it from on-chain data — `eth_getUserOperationReceipt`\n * for the real-userOp path or `eth_getLogs` for the precheck path —\n * then resolves the receipt block's timestamp via `eth_getBlockByNumber`.\n * See `docs/canon/ports/smart-account.md` for the γ-B trust-model\n * section.\n */\nexport type SafeDeploymentEvidence = {\n readonly chainId: ChainId;\n readonly signerAddress: Address;\n readonly safeAddress: Address;\n readonly txHash?: TxHash;\n readonly userOpHash?: TxHash;\n readonly blockNumber?: BlockNumber;\n};\n\nexport type SafeDeploymentInput = {\n readonly signer: Account;\n readonly email: Email;\n readonly config: SafeDeploymentConfig;\n};\n\nexport type SafeDeploymentDeployedQuery = {\n readonly safeAddress: Address;\n readonly config: SafeDeploymentConfig;\n};\n\n/**\n * Typed error for SafeDeploymentPort operations. Mirrors the shape used\n * by `SmartAccountError` (see `ports/smart-account.ts`) so the two\n * domain ports compose uniformly into the deploy slice (#161).\n */\nexport class SafeDeploymentError extends Data.TaggedError(\"SafeDeploymentError\")<{\n readonly operation: string;\n readonly publicCode: CapxulErrorCode;\n readonly publicError: CapxulError;\n readonly cause: unknown;\n readonly details?: CapxulErrorDetails;\n}> {}\n\n/**\n * Wrap a `CapxulError` as a `SafeDeploymentError`. Adapter helper —\n * used at every failure boundary inside a `SafeDeploymentPort` method\n * to preserve the operation that failed alongside the typed public\n * error.\n *\n * Mirrors the `smartAccountErrorFromCapxul` helper on `SmartAccountPort`\n * — both ports follow the same Effect-native pattern: tagged port-error\n * carries `operation` + `publicCode` + `publicError`, and the helper\n * keeps `details` optional so the call site doesn't have to.\n *\n * @param operation - The port method that failed (e.g. `\"deploy\"`)\n * @param error - The originating `CapxulError`\n * @param cause - Underlying cause; defaults to `error` itself\n * @returns A `SafeDeploymentError` ready to throw via `Effect.fail`\n */\nexport function safeDeploymentErrorFromCapxul(\n operation: string,\n error: CapxulError,\n cause: unknown = error,\n): SafeDeploymentError {\n return new SafeDeploymentError({\n operation,\n publicCode: error.code,\n publicError: error,\n cause,\n ...(error.details === undefined ? {} : { details: error.details }),\n });\n}\n\n/**\n * Domain port for off-chain + on-chain Safe lifecycle operations.\n *\n * Sibling to `SmartAccountPort` (the Convex-side aggregate). The deploy\n * slice (#161) composes both: `SafeDeploymentPort.deploy` to mint a Safe\n * on-chain, then `SmartAccountPort.confirmDeployment` to persist\n * evidence to Convex. `confirmDeployment` is NOT on this port — that\n * would couple persistence into chain-execution.\n *\n * NOT a member of `PlatformPorts` — domain ports are composed by\n * consumers per the hexagonal Option C decision. See\n * `docs/canon/ports/smart-account.md` for the precedent.\n */\nexport interface SafeDeploymentPort {\n /**\n * Off-chain derivation only: compute the counterfactual Safe address\n * for `(signer, email)`. Pure — no I/O, no state mutation.\n */\n prepare(\n input: SafeDeploymentInput,\n ): Effect.Effect<PreparedSafeAccount, SafeDeploymentError, never>;\n\n /**\n * Deploy the Safe on-chain via the bundler + paymaster (production)\n * or simulate the deployment in memory (testing). Idempotent on\n * `(signer, email)` — repeated calls produce the same `safeAddress`.\n */\n deploy(\n input: SafeDeploymentInput,\n ): Effect.Effect<SafeDeploymentEvidence, SafeDeploymentError, never>;\n\n /**\n * Returns true if `safeAddress` is already deployed on-chain\n * (`extcodesize > 0`). Used by `client._internal.account.deploySafe`\n * to short-circuit the deploy path when a partial-failure retry would\n * otherwise submit a second UserOp against an already-deployed Safe\n * (slice 5B · AC8).\n */\n isDeployed(\n input: SafeDeploymentDeployedQuery,\n ): Effect.Effect<boolean, SafeDeploymentError, never>;\n}\n\nexport class SafeDeploymentPortTag extends Context.Tag(\"@capxul/sdk/ports/SafeDeploymentPort\")<\n SafeDeploymentPortTag,\n SafeDeploymentPort\n>() {}\n"],"mappings":";;;;;;;AA4EA,IAAa,sBAAb,cAAyC,KAAK,YAAY,qBAAqB,EAM5E,CAAC;;;;;;;;;;;;;;;;;AAkBJ,SAAgB,8BACd,WACA,OACA,QAAiB,OACI;CACrB,OAAO,IAAI,oBAAoB;EAC7B;EACA,YAAY,MAAM;EAClB,aAAa;EACb;EACA,GAAI,MAAM,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,MAAM,QAAQ;CAClE,CAAC;AACH;AA6CA,IAAa,wBAAb,cAA2C,QAAQ,IAAI,sCAAsC,EAG3F,EAAE,CAAC"}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { F as CapxulErrorDetails, M as TxHash, N as CapxulError, P as CapxulErrorCode, g as Email, h as DurationMs, l as BlockNumber, r as Address, u as ChainId } from "./index-CTXgQ_xR.mjs";
|
|
2
|
-
import { Account } from "viem";
|
|
3
|
-
import { Context, Effect } from "effect";
|
|
4
|
-
|
|
5
|
-
//#region src/ports/safe-deployment.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Configuration for a Safe deployment: the chain + RPC endpoint +
|
|
8
|
-
* gas-sponsorship policy the adapter should use.
|
|
9
|
-
*
|
|
10
|
-
* `receiptTimeoutMs` is optional; the production adapter applies a
|
|
11
|
-
* default when omitted. The in-memory adapter ignores it.
|
|
12
|
-
*/
|
|
13
|
-
type SafeDeploymentConfig = {
|
|
14
|
-
readonly chainId: ChainId;
|
|
15
|
-
readonly rpcUrl: string;
|
|
16
|
-
readonly gasPolicyId: string;
|
|
17
|
-
readonly receiptTimeoutMs?: DurationMs;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Result of `prepare`: the counterfactual Safe address derived from
|
|
21
|
-
* `(signerAddress, email)` without any on-chain side effect.
|
|
22
|
-
*/
|
|
23
|
-
type PreparedSafeAccount = {
|
|
24
|
-
readonly chainId: ChainId;
|
|
25
|
-
readonly signerAddress: Address;
|
|
26
|
-
readonly safeAddress: Address;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Evidence of a successful Safe deployment.
|
|
30
|
-
*
|
|
31
|
-
* Every field except `chainId` / `signerAddress` / `safeAddress` is
|
|
32
|
-
* optional because the AC8 precheck short-circuit path (Safe already
|
|
33
|
-
* on-chain at this address; off-chain receipt evidence unavailable)
|
|
34
|
-
* calls the persistence step WITHOUT a `userOpHash`, `txHash`, or
|
|
35
|
-
* `blockNumber` — there is no recoverable transaction. Aaron's rule:
|
|
36
|
-
* "If there is no TX and it hasn't been deployed then there shouldn't
|
|
37
|
-
* be a hash." End-to-end nullable: `v.optional(v.string())` in the
|
|
38
|
-
* backend schema.
|
|
39
|
-
*
|
|
40
|
-
* **`deployedAt` is NOT a field on this type.** The SDK is never the
|
|
41
|
-
* oracle for `deployedAt`. The backend (`confirmDeployment` action —
|
|
42
|
-
* Convex mutations cannot `fetch`, so the chain re-verification lives
|
|
43
|
-
* in an action) derives it from on-chain data — `eth_getUserOperationReceipt`
|
|
44
|
-
* for the real-userOp path or `eth_getLogs` for the precheck path —
|
|
45
|
-
* then resolves the receipt block's timestamp via `eth_getBlockByNumber`.
|
|
46
|
-
* See `docs/canon/ports/smart-account.md` for the γ-B trust-model
|
|
47
|
-
* section.
|
|
48
|
-
*/
|
|
49
|
-
type SafeDeploymentEvidence = {
|
|
50
|
-
readonly chainId: ChainId;
|
|
51
|
-
readonly signerAddress: Address;
|
|
52
|
-
readonly safeAddress: Address;
|
|
53
|
-
readonly txHash?: TxHash;
|
|
54
|
-
readonly userOpHash?: TxHash;
|
|
55
|
-
readonly blockNumber?: BlockNumber;
|
|
56
|
-
};
|
|
57
|
-
type SafeDeploymentInput = {
|
|
58
|
-
readonly signer: Account;
|
|
59
|
-
readonly email: Email;
|
|
60
|
-
readonly config: SafeDeploymentConfig;
|
|
61
|
-
};
|
|
62
|
-
type SafeDeploymentDeployedQuery = {
|
|
63
|
-
readonly safeAddress: Address;
|
|
64
|
-
readonly config: SafeDeploymentConfig;
|
|
65
|
-
};
|
|
66
|
-
declare const SafeDeploymentError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
|
|
67
|
-
readonly _tag: "SafeDeploymentError";
|
|
68
|
-
} & Readonly<A>;
|
|
69
|
-
/**
|
|
70
|
-
* Typed error for SafeDeploymentPort operations. Mirrors the shape used
|
|
71
|
-
* by `SmartAccountError` (see `ports/smart-account.ts`) so the two
|
|
72
|
-
* domain ports compose uniformly into the deploy slice (#161).
|
|
73
|
-
*/
|
|
74
|
-
declare class SafeDeploymentError extends SafeDeploymentError_base<{
|
|
75
|
-
readonly operation: string;
|
|
76
|
-
readonly publicCode: CapxulErrorCode;
|
|
77
|
-
readonly publicError: CapxulError;
|
|
78
|
-
readonly cause: unknown;
|
|
79
|
-
readonly details?: CapxulErrorDetails;
|
|
80
|
-
}> {}
|
|
81
|
-
/**
|
|
82
|
-
* Wrap a `CapxulError` as a `SafeDeploymentError`. Adapter helper —
|
|
83
|
-
* used at every failure boundary inside a `SafeDeploymentPort` method
|
|
84
|
-
* to preserve the operation that failed alongside the typed public
|
|
85
|
-
* error.
|
|
86
|
-
*
|
|
87
|
-
* Mirrors the `smartAccountErrorFromCapxul` helper on `SmartAccountPort`
|
|
88
|
-
* — both ports follow the same Effect-native pattern: tagged port-error
|
|
89
|
-
* carries `operation` + `publicCode` + `publicError`, and the helper
|
|
90
|
-
* keeps `details` optional so the call site doesn't have to.
|
|
91
|
-
*
|
|
92
|
-
* @param operation - The port method that failed (e.g. `"deploy"`)
|
|
93
|
-
* @param error - The originating `CapxulError`
|
|
94
|
-
* @param cause - Underlying cause; defaults to `error` itself
|
|
95
|
-
* @returns A `SafeDeploymentError` ready to throw via `Effect.fail`
|
|
96
|
-
*/
|
|
97
|
-
declare function safeDeploymentErrorFromCapxul(operation: string, error: CapxulError, cause?: unknown): SafeDeploymentError;
|
|
98
|
-
/**
|
|
99
|
-
* Domain port for off-chain + on-chain Safe lifecycle operations.
|
|
100
|
-
*
|
|
101
|
-
* Sibling to `SmartAccountPort` (the Convex-side aggregate). The deploy
|
|
102
|
-
* slice (#161) composes both: `SafeDeploymentPort.deploy` to mint a Safe
|
|
103
|
-
* on-chain, then `SmartAccountPort.confirmDeployment` to persist
|
|
104
|
-
* evidence to Convex. `confirmDeployment` is NOT on this port — that
|
|
105
|
-
* would couple persistence into chain-execution.
|
|
106
|
-
*
|
|
107
|
-
* NOT a member of `PlatformPorts` — domain ports are composed by
|
|
108
|
-
* consumers per the hexagonal Option C decision. See
|
|
109
|
-
* `docs/canon/ports/smart-account.md` for the precedent.
|
|
110
|
-
*/
|
|
111
|
-
interface SafeDeploymentPort {
|
|
112
|
-
/**
|
|
113
|
-
* Off-chain derivation only: compute the counterfactual Safe address
|
|
114
|
-
* for `(signer, email)`. Pure — no I/O, no state mutation.
|
|
115
|
-
*/
|
|
116
|
-
prepare(input: SafeDeploymentInput): Effect.Effect<PreparedSafeAccount, SafeDeploymentError, never>;
|
|
117
|
-
/**
|
|
118
|
-
* Deploy the Safe on-chain via the bundler + paymaster (production)
|
|
119
|
-
* or simulate the deployment in memory (testing). Idempotent on
|
|
120
|
-
* `(signer, email)` — repeated calls produce the same `safeAddress`.
|
|
121
|
-
*/
|
|
122
|
-
deploy(input: SafeDeploymentInput): Effect.Effect<SafeDeploymentEvidence, SafeDeploymentError, never>;
|
|
123
|
-
/**
|
|
124
|
-
* Returns true if `safeAddress` is already deployed on-chain
|
|
125
|
-
* (`extcodesize > 0`). Used by `client._internal.account.deploySafe`
|
|
126
|
-
* to short-circuit the deploy path when a partial-failure retry would
|
|
127
|
-
* otherwise submit a second UserOp against an already-deployed Safe
|
|
128
|
-
* (slice 5B · AC8).
|
|
129
|
-
*/
|
|
130
|
-
isDeployed(input: SafeDeploymentDeployedQuery): Effect.Effect<boolean, SafeDeploymentError, never>;
|
|
131
|
-
}
|
|
132
|
-
declare const SafeDeploymentPortTag_base: Context.TagClass<SafeDeploymentPortTag, "@capxul/sdk/ports/SafeDeploymentPort", SafeDeploymentPort>;
|
|
133
|
-
declare class SafeDeploymentPortTag extends SafeDeploymentPortTag_base {}
|
|
134
|
-
//#endregion
|
|
135
|
-
export { SafeDeploymentEvidence as a, SafeDeploymentPortTag as c, SafeDeploymentError as i, safeDeploymentErrorFromCapxul as l, SafeDeploymentConfig as n, SafeDeploymentInput as o, SafeDeploymentDeployedQuery as r, SafeDeploymentPort as s, PreparedSafeAccount as t };
|
|
136
|
-
//# sourceMappingURL=safe-deployment-D3k9yndM.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"safe-deployment-D3k9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AAO,sBAAA,EAAwB,mBAAA;EAnEF;;;;;;;EA4EvC,UAAA,CACE,KAAA,EAAO,2BAAA,GACN,MAAA,CAAO,MAAA,UAAgB,mBAAA;AAAA;AAAA,cAC3B,0BAAA;cAEY,qBAAA,SAA8B,0BAGxC"}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { N as CapxulError, S as Profile$1, k as SmartAccount$1, r as Address, s as AuthSession, v as EpochSeconds, y as JwtToken } from "./index-CTXgQ_xR.mjs";
|
|
2
|
-
import { Account, Hex } from "viem";
|
|
3
|
-
import { Context, Effect } from "effect";
|
|
4
|
-
|
|
5
|
-
//#region src/ports/auth-cache.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* AuthCachePort (TA4) — replaces `SessionStoragePort` in the rebuild slice's
|
|
8
|
-
* consumer-facing wiring. Stores the user-snapshot Session AND the cached
|
|
9
|
-
* Convex JWT (W7 bridge endpoint). The two slots are independent so a session
|
|
10
|
-
* refresh doesn't invalidate the JWT and vice versa.
|
|
11
|
-
*
|
|
12
|
-
* Three adapters (TA7):
|
|
13
|
-
* - `BrowserAuthCacheAdapter` — backed by `localStorage`
|
|
14
|
-
* - `FileSystemAuthCacheAdapter` — mode-0600 JSON file in `~/.config/capxul/`
|
|
15
|
-
* - `InMemoryAuthCacheAdapter` — for tests
|
|
16
|
-
*
|
|
17
|
-
* `SessionStoragePort` was retired by the Stage 4 rebuild; session and JWT
|
|
18
|
-
* persistence now share this cache boundary.
|
|
19
|
-
*/
|
|
20
|
-
interface AuthCachePort {
|
|
21
|
-
readonly getSession: Effect.Effect<AuthSession | null, AuthCacheError>;
|
|
22
|
-
readonly setSession: (session: AuthSession) => Effect.Effect<void, AuthCacheError>;
|
|
23
|
-
readonly clearSession: Effect.Effect<void, AuthCacheError>;
|
|
24
|
-
/**
|
|
25
|
-
* JWT cache for the `/api/auth/convex/token` bridge endpoint (W7).
|
|
26
|
-
* Stored separately from the session so a session refresh doesn't
|
|
27
|
-
* invalidate cached JWT.
|
|
28
|
-
*/
|
|
29
|
-
readonly getJwt: Effect.Effect<CachedJwt | null, AuthCacheError>;
|
|
30
|
-
readonly setJwt: (jwt: CachedJwt) => Effect.Effect<void, AuthCacheError>;
|
|
31
|
-
readonly clearJwt: Effect.Effect<void, AuthCacheError>;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Cached Convex JWT shape (TA4). `expEpochSeconds` is decoded from the JWT's
|
|
35
|
-
* `exp` claim at fetch time so the `tokenProvider` cache eviction logic can
|
|
36
|
-
* proactively refresh at `exp - 30s` per TA3.
|
|
37
|
-
*/
|
|
38
|
-
interface CachedJwt {
|
|
39
|
-
readonly token: JwtToken;
|
|
40
|
-
readonly expEpochSeconds: EpochSeconds;
|
|
41
|
-
}
|
|
42
|
-
declare const AuthCacheError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
|
|
43
|
-
readonly _tag: "AuthCacheError";
|
|
44
|
-
} & Readonly<A>;
|
|
45
|
-
declare class AuthCacheError extends AuthCacheError_base<{
|
|
46
|
-
readonly operation: string;
|
|
47
|
-
readonly cause: unknown;
|
|
48
|
-
}> {}
|
|
49
|
-
declare const AuthCachePortTag_base: Context.TagClass<AuthCachePortTag, "@capxul/sdk/ports/AuthCachePort", AuthCachePort>;
|
|
50
|
-
declare class AuthCachePortTag extends AuthCachePortTag_base {}
|
|
51
|
-
//#endregion
|
|
52
|
-
//#region src/client/types.d.ts
|
|
53
|
-
type Session = AuthSession;
|
|
54
|
-
type Profile = Profile$1;
|
|
55
|
-
type SmartAccount = SmartAccount$1;
|
|
56
|
-
/**
|
|
57
|
-
* Result-shape returned by every method on `CapxulClient`. Mirrors the
|
|
58
|
-
* existing per-port `Result` aliases; centralized here so consumers have
|
|
59
|
-
* a single import for the consumer-facing surface.
|
|
60
|
-
*/
|
|
61
|
-
type CapxulResult<T> = {
|
|
62
|
-
readonly ok: true;
|
|
63
|
-
readonly value: T;
|
|
64
|
-
} | {
|
|
65
|
-
readonly ok: false;
|
|
66
|
-
readonly error: CapxulError;
|
|
67
|
-
};
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region src/client/account-providers.d.ts
|
|
70
|
-
type AccountProviderSource = "local-private-key" | "openfort-embedded" | "injected-eip1193";
|
|
71
|
-
type AccountRequirement = "none" | "counterfactual" | "deployed";
|
|
72
|
-
interface AccountProvider {
|
|
73
|
-
readonly source: AccountProviderSource;
|
|
74
|
-
/**
|
|
75
|
-
* Resolve the signer's EVM address.
|
|
76
|
-
*
|
|
77
|
-
* @determinism MUST return the same `Address` across calls for the
|
|
78
|
-
* lifetime of a single provider instance — the SDK-level deploy mutex
|
|
79
|
-
* keys on `(authUserId, safeAddress)` where `safeAddress` is computed
|
|
80
|
-
* from `getAddress()`'s result before the port's `prepare()` round-trip.
|
|
81
|
-
* If two successive calls returned different addresses, concurrent
|
|
82
|
-
* `deploySafe` invocations would compute different mutex keys and
|
|
83
|
-
* bypass dedup, defeating the mutex.
|
|
84
|
-
*
|
|
85
|
-
* The two sanctioned providers both satisfy this invariant:
|
|
86
|
-
* - `localPrivateKeyAccountProvider` — derives once from the key
|
|
87
|
-
* - `eip1193AccountProvider` — reads `eth_accounts` (idempotent once
|
|
88
|
-
* the wallet is connected; consumer is responsible for connection)
|
|
89
|
-
*
|
|
90
|
-
* The Openfort embedded path no longer needs a provider: the
|
|
91
|
-
* `openfortEmbeddedSigner` `CapxulSigner` caches its own address and the
|
|
92
|
-
* deploy is backend-orchestrated (backend-orchestrated-deploy.md).
|
|
93
|
-
*
|
|
94
|
-
* Custom providers MUST honor this contract.
|
|
95
|
-
*/
|
|
96
|
-
getAddress(): Promise<CapxulResult<Address>>;
|
|
97
|
-
getDeployAccount(): Promise<CapxulResult<Account>>;
|
|
98
|
-
}
|
|
99
|
-
interface Eip1193Provider {
|
|
100
|
-
request(args: {
|
|
101
|
-
readonly method: string;
|
|
102
|
-
readonly params?: readonly unknown[];
|
|
103
|
-
}): Promise<unknown>;
|
|
104
|
-
}
|
|
105
|
-
declare function localPrivateKeyAccountProvider(input: {
|
|
106
|
-
readonly privateKey: Hex;
|
|
107
|
-
}): AccountProvider;
|
|
108
|
-
declare function eip1193AccountProvider(input: {
|
|
109
|
-
readonly provider: Eip1193Provider;
|
|
110
|
-
}): AccountProvider;
|
|
111
|
-
//#endregion
|
|
112
|
-
//#region src/signer.d.ts
|
|
113
|
-
interface CapxulSigner {
|
|
114
|
-
/**
|
|
115
|
-
* Signer kind — surfaced on the `accountProviderReady` status so the
|
|
116
|
-
* readiness ladder reports which signer the consumer wired.
|
|
117
|
-
*/
|
|
118
|
-
readonly source: AccountProviderSource;
|
|
119
|
-
/** Owner EOA address — the Safe's single owner. */
|
|
120
|
-
getAddress(): Promise<Address>;
|
|
121
|
-
/**
|
|
122
|
-
* Sign the EIP-712 `SafeOp` digest the backend returns for the prepared
|
|
123
|
-
* deployment UserOperation. Returns the raw 65-byte ECDSA signature; the
|
|
124
|
-
* backend packs `validAfter|validUntil|signature`.
|
|
125
|
-
*/
|
|
126
|
-
signUserOpHash(hash: Hex): Promise<Hex>;
|
|
127
|
-
}
|
|
128
|
-
/** Minimal EIP-1193 surface an injected browser wallet exposes. */
|
|
129
|
-
interface Eip1193RequestProvider {
|
|
130
|
-
request(args: {
|
|
131
|
-
readonly method: string;
|
|
132
|
-
readonly params?: readonly unknown[];
|
|
133
|
-
}): Promise<unknown>;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Browser `CapxulSigner` backed by an injected EIP-1193 wallet (MetaMask, etc.).
|
|
137
|
-
* Signs the SafeOp digest via `eth_sign`, then verifies the returned signature
|
|
138
|
-
* recovers the selected account against that raw digest. Wallets that prefix
|
|
139
|
-
* `eth_sign` payloads are rejected before the backend submits an invalid SafeOp.
|
|
140
|
-
* The node key signer lives in `@capxul/sdk/node` (`localPrivateKeySigner`).
|
|
141
|
-
*/
|
|
142
|
-
declare function injectedWalletSigner(provider: Eip1193RequestProvider): CapxulSigner;
|
|
143
|
-
//#endregion
|
|
144
|
-
export { CachedJwt as _, AccountProviderSource as a, eip1193AccountProvider as c, Profile as d, Session as f, AuthCachePortTag as g, AuthCachePort as h, AccountProvider as i, localPrivateKeyAccountProvider as l, AuthCacheError as m, Eip1193RequestProvider as n, AccountRequirement as o, SmartAccount as p, injectedWalletSigner as r, Eip1193Provider as s, CapxulSigner as t, CapxulResult as u };
|
|
145
|
-
//# sourceMappingURL=signer-DqDtJU1l.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signer-DqDtJU1l.d.mts","names":[],"sources":["../src/ports/auth-cache.ts","../src/client/types.ts","../src/client/account-providers.ts","../src/signer.ts"],"mappings":";;;;;;;;AAiBA;;;;;;;;;;;UAAiB,aAAA;EAAA,SACN,UAAA,EAAY,MAAA,CAAO,MAAA,CAAO,WAAA,SAAoB,cAAA;EAAA,SAC9C,UAAA,GAAa,OAAA,EAAS,WAAA,KAAgB,MAAA,CAAO,MAAA,OAAa,cAAA;EAAA,SAC1D,YAAA,EAAc,MAAA,CAAO,MAAA,OAAa,cAAA;EAQc;;;;;EAAA,SADhD,MAAA,EAAQ,MAAA,CAAO,MAAA,CAAO,SAAA,SAAkB,cAAA;EAAA,SACxC,MAAA,GAAS,GAAA,EAAK,SAAA,KAAc,MAAA,CAAO,MAAA,OAAa,cAAA;EAAA,SAChD,QAAA,EAAU,MAAA,CAAO,MAAA,OAAa,cAAA;AAAA;;;;;;UAQxB,SAAA;EAAA,SACN,KAAA,EAAO,QAAA;EAAA,SACP,eAAA,EAAiB,YAAY;AAAA;AAAA,cACvC,mBAAA;;;cAEY,cAAA,SAAuB,mBAAA;EAAA,SACzB,SAAA;EAAA,SACA,KAAA;AAAA;AAAA,cACN,qBAAA;cAEQ,gBAAA,SAAyB,qBAGnC;;;KClCS,OAAA,GAAU,WAAW;AAAA,KACrB,OAAA,GAAU,SAAY;AAAA,K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