@capxul/sdk 1.2.2 → 2.0.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 +19 -20
- package/dist/{InMemoryAuthCacheAdapter-Dr1sEd9y.mjs → InMemoryAuthCacheAdapter-Rc8tCtml.mjs} +9 -8
- package/dist/{create-capxul-client-DVzm78RU.mjs → create-capxul-client-N36cHqE2.mjs} +2323 -1331
- package/dist/{create-capxul-client-C7H5b68l.d.mts → create-capxul-client-klbklLYW.d.mts} +513 -871
- package/dist/index.d.mts +29 -79
- package/dist/index.mjs +134 -513
- package/dist/node/index.d.mts +2 -3
- package/dist/node/index.mjs +1 -3
- package/dist/{signer-CJT0pPiO.d.mts → signer-ZijoFiUs.d.mts} +15 -20
- package/dist/testing/index.d.mts +2 -3
- package/dist/testing/index.mjs +5 -143
- package/package.json +10 -8
- package/dist/InMemoryAuthCacheAdapter-Dr1sEd9y.mjs.map +0 -1
- package/dist/create-capxul-client-C7H5b68l.d.mts.map +0 -1
- package/dist/create-capxul-client-DVzm78RU.mjs.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/node/index.d.mts.map +0 -1
- package/dist/node/index.mjs.map +0 -1
- package/dist/signer-CJT0pPiO.d.mts.map +0 -1
- package/dist/testing/index.d.mts.map +0 -1
- package/dist/testing/index.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/adapters/auth-cache/FileSystemAuthCacheAdapter.ts","../../src/node/index.ts"],"mappings":";;;;;KAwBK,iBAAA,GAAoB,UAAA,CAAmB,UAAA,GAAa,IAAA,CAAa,IAAI;AAAA,cAQ7D,0BAAA,YAAsC,aAAA;EAAA,iBAChC,IAAA;EAAA,iBACA,OAAA;EAAA,SACR,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;EAAA,SAClC,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;cAE3B,IAAA,UAAc,OAAA,GAAS,KAAA,CAAM,KAAA,CAAM,iBAAA;EAAA,QA0CvC,IAAA;EAAA,QA0BA,KAAA;EAAA,QAiBA,GAAA;AAAA;AAAA,iBAWM,wBAAA,CAAyB,KAAA;EAAA,SAC9B,IAAA;EAAA,SACA,OAAA,GAAU,KAAA,CAAM,KAAA,CAAM,iBAAA;AAAA,IAC7B,KAAA,CAAM,KAAA,CAAM,gBAAA,EAAkB,cAAA;;;UCpHjB,iCAAA;EAAA,SACN,aAAA;EAAA,SACA,oBAAoB;AAAA;;;;;;iBAQf,qBAAA,CAAsB,KAAA;EAAA,SAAkB,UAAA,EAAY,GAAA;AAAA,IAAQ,YAAY;;;;;;;;;;;iBAyBxE,0BAAA,CACd,OAAA,GAAS,iCAAA,GACR,aAAa"}
|
package/dist/node/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["PlatformFileSystem","PlatformPath"],"sources":["../../src/adapters/auth-cache/FileSystemAuthCacheAdapter.ts","../../src/node/index.ts"],"sourcesContent":["/* oxlint-disable typescript/no-this-alias -- Effect.gen callbacks are generator functions, so adapter receivers are captured explicitly. */\nimport { NodeFileSystem, NodePath } from \"@effect/platform-node\";\nimport {\n Effect,\n FileSystem as PlatformFileSystem,\n Layer,\n Path as PlatformPath,\n PlatformError,\n} from \"effect\";\nimport type { AuthSession } from \"@capxul/types\";\n\nimport {\n AuthCacheError,\n AuthCachePortTag,\n type AuthCachePort,\n type CachedJwt,\n} from \"../../ports/auth-cache\";\nimport { parseAuthSession, parseCachedJwt } from \"./serialization\";\n\ninterface FilePayload {\n readonly session: AuthSession | null;\n readonly jwt: CachedJwt | null;\n}\n\ntype FileSystemRuntime = PlatformFileSystem.FileSystem | PlatformPath.Path;\n\nfunction emptyPayload(): FilePayload {\n return { session: null, jwt: null };\n}\n\nconst nodeFileSystemRuntime = Layer.merge(NodeFileSystem.layer, NodePath.layer);\n\nexport class FileSystemAuthCacheAdapter implements AuthCachePort {\n private readonly path: string;\n private readonly runtime: Layer.Layer<FileSystemRuntime>;\n readonly getSession: Effect.Effect<AuthSession | null, AuthCacheError>;\n readonly setSession: (session: AuthSession) => Effect.Effect<void, AuthCacheError>;\n readonly clearSession: Effect.Effect<void, AuthCacheError>;\n readonly getJwt: Effect.Effect<CachedJwt | null, AuthCacheError>;\n readonly setJwt: (jwt: CachedJwt) => Effect.Effect<void, AuthCacheError>;\n readonly clearJwt: Effect.Effect<void, AuthCacheError>;\n\n constructor(path: string, runtime: Layer.Layer<FileSystemRuntime> = nodeFileSystemRuntime) {\n this.path = path;\n this.runtime = runtime;\n const self = this;\n\n this.getSession = this.run(\n \"getSession\",\n this.read().pipe(Effect.map((payload) => payload.session)),\n );\n this.setSession = (session: AuthSession) =>\n this.run(\n \"setSession\",\n Effect.gen(function* () {\n const cur = yield* self.read();\n yield* self.write({ session, jwt: cur.jwt });\n }),\n );\n this.clearSession = this.run(\n \"clearSession\",\n Effect.gen(function* () {\n const cur = yield* self.read();\n yield* self.write({ session: null, jwt: cur.jwt });\n }),\n );\n this.getJwt = this.run(\"getJwt\", this.read().pipe(Effect.map((payload) => payload.jwt)));\n this.setJwt = (jwt: CachedJwt) =>\n this.run(\n \"setJwt\",\n Effect.gen(function* () {\n const cur = yield* self.read();\n yield* self.write({ session: cur.session, jwt });\n }),\n );\n this.clearJwt = this.run(\n \"clearJwt\",\n Effect.gen(function* () {\n const cur = yield* self.read();\n yield* self.write({ session: cur.session, jwt: null });\n }),\n );\n }\n\n private read(): Effect.Effect<FilePayload, PlatformError.PlatformError, FileSystemRuntime> {\n const self = this;\n return Effect.gen(function* () {\n const fs = yield* PlatformFileSystem.FileSystem;\n const exists = yield* fs.exists(self.path);\n if (!exists) return emptyPayload();\n const raw = yield* fs.readFileString(self.path, \"utf-8\");\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n return emptyPayload();\n }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n return emptyPayload();\n }\n const payload = parsed as { readonly session?: unknown; readonly jwt?: unknown };\n\n return {\n session: parseAuthSession(payload.session),\n jwt: parseCachedJwt(payload.jwt),\n };\n });\n }\n\n private write(\n payload: FilePayload,\n ): Effect.Effect<void, PlatformError.PlatformError, FileSystemRuntime> {\n const self = this;\n return Effect.gen(function* () {\n const fs = yield* PlatformFileSystem.FileSystem;\n const path = yield* PlatformPath.Path;\n const dir = path.dirname(self.path);\n const dirExists = yield* fs.exists(dir);\n if (!dirExists) {\n yield* fs.makeDirectory(dir, { recursive: true, mode: 0o700 });\n }\n yield* fs.writeFileString(self.path, JSON.stringify(payload), { mode: 0o600 });\n yield* fs.chmod(self.path, 0o600);\n });\n }\n\n private run<T>(\n operation: string,\n effect: Effect.Effect<T, PlatformError.PlatformError, FileSystemRuntime>,\n ): Effect.Effect<T, AuthCacheError> {\n return effect.pipe(\n Effect.mapError((cause) => toAuthCacheError(operation, cause)),\n Effect.provide(this.runtime),\n );\n }\n}\n\nexport function FileSystemAuthCacheLayer(input: {\n readonly path: string;\n readonly runtime?: Layer.Layer<FileSystemRuntime>;\n}): Layer.Layer<AuthCachePortTag, AuthCacheError> {\n return Layer.effect(\n AuthCachePortTag,\n Effect.sync(() => new FileSystemAuthCacheAdapter(input.path, input.runtime)).pipe(\n Effect.mapError((cause) => toAuthCacheError(\"initialize\", cause)),\n ),\n );\n}\n\nfunction toAuthCacheError(operation: string, cause: unknown): AuthCacheError {\n return new AuthCacheError({ operation, cause });\n}\n","// `@capxul/sdk/node` — node-only entry (published-package-boundaries.md).\n//\n// The default `@capxul/sdk` entry is browser-clean: it never statically reaches\n// `@effect/platform-node`. Node consumers import the on-disk auth cache and the\n// node key `CapxulSigner` from here.\n\nimport * as os from \"node:os\";\nimport { join } from \"node:path\";\n\nimport { toAddress } from \"@capxul/types\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport type { Hex } from \"viem\";\n\nimport { BrowserAuthCacheAdapter } from \"../adapters/auth-cache/BrowserAuthCacheAdapter\";\nimport { FileSystemAuthCacheAdapter } from \"../adapters/auth-cache/FileSystemAuthCacheAdapter\";\nimport { InMemoryAuthCacheAdapter } from \"../adapters/auth-cache/InMemoryAuthCacheAdapter\";\nimport type { WindowLike } from \"../surface/window-like\";\nimport type { AuthCachePort } from \"../ports/auth-cache\";\nimport type { CapxulSigner } from \"../signer\";\n\nexport {\n FileSystemAuthCacheAdapter,\n FileSystemAuthCacheLayer,\n} from \"../adapters/auth-cache/FileSystemAuthCacheAdapter\";\n\nexport interface DetectNodeAuthCacheAdapterOptions {\n readonly authCachePath?: string;\n readonly resolveHomeDirectory?: () => string;\n}\n\n/**\n * Node `CapxulSigner` backed by a raw private key. Signs the EIP-712 `SafeOp`\n * digest the backend returns for a prepared deployment UserOperation. The\n * reference CLI builds this from `DEPLOYER_PRIVATE_KEY` for the live capstone.\n */\nexport function localPrivateKeySigner(input: { readonly privateKey: Hex }): CapxulSigner {\n const account = privateKeyToAccount(input.privateKey);\n return {\n source: \"local-private-key\",\n async getAddress() {\n return toAddress(account.address);\n },\n async signUserOpHash(hash: Hex): Promise<Hex> {\n // `sign({ hash })` signs the already-computed SafeOp digest directly.\n // `signMessage({ message: { raw: hash } })` would add an EIP-191 prefix.\n return account.sign({ hash });\n },\n };\n}\n\n/**\n * Node-aware auth-cache detection. Mirrors the historic default order:\n * 1. Browser localStorage → BrowserAuthCacheAdapter\n * 2. Node.js process → FileSystemAuthCacheAdapter\n * (`~/.config/capxul/auth-cache.json`)\n * 3. Neither detected → InMemoryAuthCacheAdapter\n *\n * Use this from a Node entrypoint and pass the result to\n * `createCapxulClient({ authCache })` for on-disk session persistence.\n */\nexport function detectNodeAuthCacheAdapter(\n options: DetectNodeAuthCacheAdapterOptions = {},\n): AuthCachePort {\n const globalAny = globalThis as unknown as {\n readonly window?: WindowLike;\n readonly process?: { readonly versions?: { readonly node?: string } };\n };\n if (globalAny.window?.localStorage !== undefined) {\n return new BrowserAuthCacheAdapter(globalAny.window.localStorage);\n }\n if (globalAny.process?.versions?.node !== undefined) {\n const authCachePath =\n normalizeConfiguredAuthCachePath(options.authCachePath) ??\n resolveDefaultAuthCachePath(options.resolveHomeDirectory ?? os.homedir);\n if (authCachePath !== null) return new FileSystemAuthCacheAdapter(authCachePath);\n }\n return new InMemoryAuthCacheAdapter();\n}\n\nfunction normalizeConfiguredAuthCachePath(path: string | undefined): string | null {\n if (path === undefined) return null;\n const trimmed = path.trim();\n return trimmed.length > 0 ? trimmed : null;\n}\n\nfunction resolveDefaultAuthCachePath(resolveHomeDirectory: () => string): string | null {\n try {\n return join(resolveHomeDirectory(), \".config\", \"capxul\", \"auth-cache.json\");\n } catch {\n return null;\n }\n}\n"],"mappings":";;;;;;;AA0BA,SAAS,eAA4B;CACnC,OAAO;EAAE,SAAS;EAAM,KAAK;CAAK;AACpC;AAEA,MAAM,wBAAwB,MAAM,MAAM,eAAe,OAAO,SAAS,KAAK;AAE9E,IAAa,6BAAb,MAAiE;CAC/D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,MAAc,UAA0C,uBAAuB;EACzF,KAAK,OAAO;EACZ,KAAK,UAAU;EACf,MAAM,OAAO;EAEb,KAAK,aAAa,KAAK,IACrB,cACA,KAAK,KAAK,EAAE,KAAK,OAAO,KAAK,YAAY,QAAQ,OAAO,CAAC,CAC3D;EACA,KAAK,cAAc,YACjB,KAAK,IACH,cACA,OAAO,IAAI,aAAa;GACtB,MAAM,MAAM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SAAS,UAAU,SAAS,KAAA,GAAW;EACnD,MAAM,gBACJ,iCAAiC,QAAQ,aAAa,KACtD,4BAA4B,QAAQ,wBAAwB,GAAG,OAAO;EACxE,IAAI,kBAAkB,MAAM,OAAO,IAAI,2BAA2B,aAAa;CACjF;CACA,OAAO,IAAI,yBAAyB;AACtC;AAEA,SAAS,iCAAiC,MAAyC;CACjF,IAAI,SAAS,KAAA,GAAW,OAAO;CAC/B,MAAM,UAAU,KAAK,KAAK;CAC1B,OAAO,QAAQ,SAAS,IAAI,UAAU;AACxC;AAEA,SAAS,4BAA4B,sBAAmD;CACtF,IAAI;EACF,OAAO,KAAK,qBAAqB,GAAG,WAAW,UAAU,iBAAiB;CAC5E,QAAQ;EACN,OAAO;CACT;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signer-CJT0pPiO.d.mts","names":[],"sources":["../../errors/src/errors.ts","../../types/src/brand.ts","../../types/src/index.ts","../src/ports/auth-cache.ts","../src/surface/types.ts","../src/surface/account-providers.ts","../src/signer.ts"],"mappings":";;;;cAKa,kBAAA;AAAA,KA6BD,eAAA,WAA0B,kBAAkB;;;AAAA;AAiDxD;;;;AAAuB;AAYvB;;;;;;;;;KAZY,WAAA;AAeiB;AAG7B;;;;AAH6B,UAHZ,OAAA;EAAA,SACN,IAAA,EAAM,eAAA;EAAA,SACN,OAAA;EAAA,SACA,IAAA,GAAO,WAAW;AAAA;AAAA,KAGjB,kBAAA,GAAqB,MAAM;AAAA,KAgB3B,kBAAA;EAAA,SACD,KAAA;EAAA,SACA,OAAA,GAAU,kBAAkB;EAAA,SAC5B,aAAA;EAAA,SACA,KAAA;AAAA;AAAA,cAGE,WAAA,SAAoB,KAAA;EAAA,SACtB,IAAA,EAAM,eAAA;EAAA,SACN,OAAA,GAAU,kBAAA;EAAA,SACV,aAAA;EAAA,SACA,KAAA;cAEG,IAAA,EAAM,eAAA,EAAiB,OAAA,UAAiB,OAAA,GAAS,kBAAA;AAAA;A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,EAAO,sBAAA,KAA2B,OAAA;EAAA,SAC7C,KAAA,GAAQ,KAAA,EAAO,mBAAA,KAAwB,OAAA;EAAA,SACvC,KAAA,QAAa,OAAA;AAAA;AA1BxB;;;;AAAA,iBAiCgB,sBAAA,CACd,OAAA,GAAS,6BAAA,GACR,gBAAgB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["#deps","#rawBalance","#pendingOtps","#otpCountersByEmail","#authUserIdByEmail","#allocatedAuthUserIds","#authCache","#clock","#otpTtlMs","#failures","#getOrIssueAuthUserId","#tokenCounter","#jwtCounter","#authUserIdCounter","#script","fail","#script","#subscribers","#resolve","#identities","#clock","fail","#now","#accounts","#clock","#identity","#failures","#provisionMutex","#now","#rows","#failures","#balanceOfRaw","#created","#sumSubAccountRaws","#patchBalance","#events","#operations","#rawMode"],"sources":["../../src/testing/account/InMemoryAccountReadAdapter.ts","../../src/adapters/_shared/clock.ts","../../src/testing/clock/ManualClockAdapter.ts","../../src/testing/auth-client/InMemoryAuthClientAdapter.ts","../../src/testing/bootstrap/BootstrapStubAdapter.ts","../../src/testing/convex-call/ConvexCallStubAdapter.ts","../../src/testing/identity/InMemoryIdentityAdapter.ts","../../src/testing/smart-account/smart-account-derivation.ts","../../src/testing/smart-account/InMemorySmartAccountAdapter.ts","../../src/testing/sub-account/InMemorySubAccountAdapter.ts","../../src/testing/telemetry/RecordingTelemetryAdapter.ts","../../src/testing/index.ts"],"sourcesContent":["import { Errors, type CapxulError } from \"@capxul/config\";\nimport type { Account } from \"@capxul/types\";\nimport { toAccountId } from \"@capxul/types\";\nimport { Effect, Layer } from \"effect\";\n\nimport { fromWei } from \"../../domain/money/from-wei\";\nimport type {\n AccountReadError,\n AccountReadPort,\n FundFromFaucetInput,\n FundFromFaucetResult,\n ReadAccountBalanceInput,\n} from \"../../ports/account-read\";\nimport { toWei } from \"../../domain/money/to-wei\";\nimport { accountReadErrorFromCapxul, AccountReadPortTag } from \"../../ports/account-read\";\n\nexport type InMemoryAccountReadLayerDeps = {\n readonly account?: Account;\n readonly rawBalance?: string;\n readonly decimals?: number;\n readonly currency?: string;\n readonly accountId?: string;\n readonly failures?: {\n readonly readBalance?: CapxulError;\n readonly fundFromFaucet?: CapxulError;\n };\n};\n\nexport class InMemoryAccountReadAdapter implements AccountReadPort {\n readonly #deps: InMemoryAccountReadLayerDeps;\n #rawBalance: string;\n\n constructor(deps: InMemoryAccountReadLayerDeps = {}) {\n this.#deps = deps;\n this.#rawBalance = deps.rawBalance ?? \"0\";\n }\n\n readBalance(_input: ReadAccountBalanceInput): Effect.Effect<Account, AccountReadError> {\n const scriptedFailure = this.#deps.failures?.readBalance;\n if (scriptedFailure !== undefined) {\n return Effect.fail(accountReadErrorFromCapxul(\"readBalance\", scriptedFailure));\n }\n if (this.#deps.account !== undefined) {\n return Effect.succeed(cloneAccount(this.#deps.account));\n }\n const decimals = this.#deps.decimals ?? 6;\n const currency = this.#deps.currency ?? \"USD\";\n const money = fromWei(this.#rawBalance, decimals, currency);\n return Effect.succeed({\n id: toAccountId(this.#deps.accountId ?? \"account_01TEST000000000000000000\"),\n balance: money,\n available: money,\n });\n }\n\n fundFromFaucet(\n input: FundFromFaucetInput,\n ): Effect.Effect<FundFromFaucetResult, AccountReadError> {\n const scriptedFailure = this.#deps.failures?.fundFromFaucet;\n if (scriptedFailure !== undefined) {\n return Effect.fail(accountReadErrorFromCapxul(\"fundFromFaucet\", scriptedFailure));\n }\n const expectedDecimals = this.#deps.decimals ?? 6;\n const expectedCurrency = this.#deps.currency ?? \"USD\";\n if (\n input.amount.decimals !== expectedDecimals ||\n String(input.amount.currency) !== expectedCurrency\n ) {\n return Effect.fail(\n accountReadErrorFromCapxul(\n \"fundFromFaucet\",\n Errors.invalidInput(\"amount\", \"decimals/currency must match adapter config\"),\n ),\n );\n }\n const minted = BigInt(toWei(input.amount));\n this.#rawBalance = (BigInt(this.#rawBalance) + minted).toString();\n return Effect.succeed({ txHash: \"0x\" + \"f\".repeat(64) });\n }\n}\n\nexport function InMemoryAccountReadLayer(\n deps: InMemoryAccountReadLayerDeps = {},\n): Layer.Layer<AccountReadPortTag, AccountReadError, never> {\n return Layer.succeed(AccountReadPortTag, new InMemoryAccountReadAdapter(deps));\n}\n\nfunction cloneAccount(account: Account): Account {\n return {\n id: account.id,\n balance: { ...account.balance },\n available: { ...account.available },\n };\n}\n","import { Errors, type CapxulError } from \"@capxul/config\";\nimport type { EpochMs } from \"@capxul/types\";\nimport { Effect, Result } from \"effect\";\n\nimport type { ClockPort } from \"../../ports/clock\";\n\nexport type ClockNowResult =\n | { readonly ok: true; readonly value: EpochMs }\n | { readonly ok: false; readonly error: CapxulError };\n\nexport async function readClockNow(clock: ClockPort): Promise<ClockNowResult> {\n try {\n const result = await Effect.runPromise(Effect.result(clock.now));\n if (Result.isFailure(result)) {\n return { ok: false, error: Errors.providerError(\"clock\", \"now\", result.failure) };\n }\n return { ok: true, value: result.success };\n } catch (cause) {\n return { ok: false, error: Errors.providerError(\"clock\", \"now\", cause) };\n }\n}\n","/* oxlint-disable typescript/no-this-alias -- Effect.gen callbacks are generator functions, so adapter receivers are captured explicitly. */\nimport type { DurationMs, EpochMs } from \"@capxul/types\";\nimport { toDurationMs, toEpochMs } from \"@capxul/types\";\nimport { Effect, Layer } from \"effect\";\n\nimport { ClockError, ClockPortTag, type ClockPort } from \"../../ports/clock\";\nimport type { ClockAdapterUnderTest } from \"./under-test\";\n\ninterface PendingSleep {\n readonly deadline: number;\n readonly resolve: () => void;\n readonly seq: number;\n}\n\n/**\n * Event-discipline test clock. Time moves only when a release primitive is\n * invoked. `tickOne()` releases EXACTLY ONE pending sleep (the earliest\n * deadline, FIFO at ties) and snaps `now()` to that deadline. `advance(ms)`\n * composes repeated `tickOne()` calls over the resulting window — used to\n * keep the cross-adapter conformance harness uniform with the distance model\n * of `VirtualClockAdapter`. See `packages/sdk/docs/architecture.md` and the\n * slice spec `docs/slices/clock-adapters.md`.\n */\nexport class ManualClockAdapter implements ClockPort {\n private currentTime = 0;\n private queue: PendingSleep[] = [];\n private seqCounter = 0;\n\n constructor(deps: Record<string, never>) {\n void deps;\n }\n\n readonly now: Effect.Effect<EpochMs, ClockError, never> = Effect.sync(() =>\n toEpochMs(this.currentTime),\n );\n\n sleep(duration: DurationMs): Effect.Effect<void, ClockError, never> {\n return Effect.promise(\n () =>\n new Promise<void>((resolve) => {\n this.queue.push({\n deadline: this.currentTime + (duration as number),\n resolve,\n seq: this.seqCounter++,\n });\n }),\n );\n }\n\n /**\n * Release exactly one pending sleep — the earliest deadline, FIFO at ties.\n * Snaps `now()` forward to that sleep's deadline. No-op if the queue is\n * empty (preserves the empty-tick safety property).\n */\n tickOne(): Promise<void> {\n return Effect.runPromise(this.tickOneEffect());\n }\n\n tickOneEffect(): Effect.Effect<void, ClockError, never> {\n const self = this;\n return Effect.gen(function* () {\n if (self.queue.length === 0) return;\n const nextIndex = self.findEarliestIndex();\n const next = self.queue.splice(nextIndex, 1)[0]!;\n if (next.deadline > self.currentTime) {\n self.currentTime = next.deadline;\n }\n next.resolve();\n yield* Effect.yieldNow;\n });\n }\n\n /**\n * Cross-adapter harness affordance. Releases every sleep whose deadline\n * falls inside `[currentTime, currentTime + ms]` via repeated `tickOne()`,\n * then snaps `now()` to `currentTime + ms`. The composition is the seam\n * that lets the harness drive Manual and Virtual identically.\n */\n advance(ms: number): Promise<void> {\n return Effect.runPromise(this.advanceEffect(toDurationMs(ms)));\n }\n\n advanceEffect(duration: DurationMs): Effect.Effect<void, ClockError, never> {\n const self = this;\n return Effect.gen(function* () {\n yield* Effect.yieldNow;\n const target = self.currentTime + (duration as number);\n while (self.queue.length > 0 && self.earliestDeadline() <= target) {\n yield* self.tickOneEffect();\n }\n self.currentTime = target;\n });\n }\n\n private findEarliestIndex(): number {\n let bestIndex = 0;\n let best = this.queue[0]!;\n for (let i = 1; i < this.queue.length; i++) {\n const candidate = this.queue[i]!;\n if (\n candidate.deadline < best.deadline ||\n (candidate.deadline === best.deadline && candidate.seq < best.seq)\n ) {\n best = candidate;\n bestIndex = i;\n }\n }\n return bestIndex;\n }\n\n private earliestDeadline(): number {\n return this.queue[this.findEarliestIndex()]!.deadline;\n }\n\n static forConformance(): ClockAdapterUnderTest {\n return new ManualClockUnderTest(new ManualClockAdapter({}));\n }\n}\n\nclass ManualClockUnderTest implements ClockAdapterUnderTest {\n constructor(public readonly clock: ManualClockAdapter) {}\n\n advance(ms: number): Promise<void> {\n return this.clock.advance(ms);\n }\n}\n\nexport function ManualClockLayer(): Layer.Layer<ClockPortTag, ClockError, never> {\n return Layer.succeed(ClockPortTag, new ManualClockAdapter({}));\n}\n\nexport function advanceManualClock(\n duration: DurationMs,\n): Effect.Effect<void, ClockError, ClockPortTag> {\n return Effect.gen(function* () {\n const clock = yield* ClockPortTag;\n if (!(clock instanceof ManualClockAdapter)) {\n return yield* Effect.fail(\n new ClockError({\n operation: \"sleep\",\n cause: new Error(\"advanceManualClock requires ManualClockLayer\"),\n }),\n );\n }\n return yield* clock.advanceEffect(duration);\n });\n}\n\nexport function tickManualClockOnce(): Effect.Effect<void, ClockError, ClockPortTag> {\n return Effect.gen(function* () {\n const clock = yield* ClockPortTag;\n if (!(clock instanceof ManualClockAdapter)) {\n return yield* Effect.fail(\n new ClockError({\n operation: \"sleep\",\n cause: new Error(\"tickManualClockOnce requires ManualClockLayer\"),\n }),\n );\n }\n return yield* clock.tickOneEffect();\n });\n}\n","import { Errors, type CapxulError } from \"@capxul/config\";\nimport type { AuthSession, AuthUserId, DurationMs, Email, EpochMs } from \"@capxul/types\";\nimport {\n toAuthUserId,\n toDurationMs,\n toEpochMs,\n toEpochSeconds,\n toJwtToken,\n toSessionToken,\n} from \"@capxul/types\";\nimport { Effect, Result } from \"effect\";\n\nimport type {\n AuthClientOperationOptions,\n AuthClientPort,\n AuthClientResult,\n CanSendOtpInput,\n CanSendOtpStatus,\n GetConvexJwtOptions,\n SendOtpInput,\n VerifyOtpInput,\n} from \"../../ports/auth-client\";\nimport { AuthClientPortTag } from \"../../ports/auth-client\";\nimport type { AuthCacheError, AuthCachePort, CachedJwt } from \"../../ports/auth-cache\";\nimport type { ClockPort } from \"../../ports/clock\";\nimport { Layer } from \"effect\";\nimport { authClientPortFromPromiseAdapter } from \"../../adapters/auth-client/effect-port\";\nimport { InMemoryAuthCacheAdapter } from \"../../adapters/auth-cache/InMemoryAuthCacheAdapter\";\nimport { readClockNow } from \"../../adapters/_shared/clock\";\nimport { ManualClockAdapter } from \"../clock/ManualClockAdapter\";\n\nconst DEFAULT_OTP_TTL_MS = toDurationMs(5 * 60 * 1000);\nconst DEFAULT_SESSION_TTL_MS = toDurationMs(24 * 60 * 60 * 1000);\nconst DEFAULT_JWT_TTL_MS = toDurationMs(15 * 60 * 1000);\n\ninterface PendingOtp {\n readonly otp: string;\n readonly issuedAt: EpochMs;\n}\n\n/**\n * Hermetic OTP + session state machine implementing `AuthClientPort`. Wires\n * through `AuthCachePort` for persistence (clause A11) and `ClockPort`\n * for TTL + expiry math. OTPs are deterministic per-email counters (`\"000000\"`,\n * `\"000001\"`, …) so test assertions remain stable. Session tokens are\n * deterministic per-adapter counters (`\"tok_0\"`, `\"tok_1\"`, …). Returning users\n * (same email post-signOut) get the same `AuthUserId`.\n *\n * Never throws — every failure path returns `{ ok: false, error: CapxulError }`.\n * Honors `options.signal` via a pre-check (clause A10): an aborted controller\n * before method entry yields `{ ok: false, error: Errors.cancelled({ operation }) }`\n * without any state change.\n */\nexport class InMemoryAuthClientAdapter {\n readonly #pendingOtps = new Map<Email, PendingOtp>();\n readonly #otpCountersByEmail = new Map<Email, number>();\n readonly #authUserIdByEmail = new Map<Email, AuthUserId>();\n readonly #allocatedAuthUserIds = new Set<AuthUserId>();\n readonly #authCache: AuthCachePort;\n readonly #clock: ClockPort;\n readonly #otpTtlMs: DurationMs;\n readonly #failures: InMemoryAuthClientFailures;\n #authUserIdCounter = 0;\n #tokenCounter = 0;\n #jwtCounter = 0;\n\n constructor(deps: {\n readonly authCache: AuthCachePort;\n readonly clock: ClockPort;\n readonly otpTtlMs?: DurationMs;\n readonly failures?: InMemoryAuthClientFailures;\n }) {\n this.#authCache = deps.authCache;\n this.#clock = deps.clock;\n this.#otpTtlMs = deps.otpTtlMs ?? DEFAULT_OTP_TTL_MS;\n this.#failures = deps.failures ?? {};\n }\n\n /** Test affordance: peek the OTP for an email, simulating \"user reads email.\" */\n peekOtpForTesting(email: Email): string | undefined {\n return this.#pendingOtps.get(email)?.otp;\n }\n\n /** Test affordance: make a seeded identity own the session minted for its email. */\n bindAuthUserIdForTesting(email: Email, authUserId: AuthUserId): void {\n this.#authUserIdByEmail.set(email, authUserId);\n this.#allocatedAuthUserIds.add(authUserId);\n }\n\n async canSendOtp(\n input: CanSendOtpInput,\n options?: AuthClientOperationOptions,\n ): Promise<AuthClientResult<CanSendOtpStatus>> {\n if (options?.signal?.aborted) {\n return { ok: false, error: Errors.cancelled({ operation: \"canSendOtp\" }) };\n }\n if (this.#failures.canSendOtp !== undefined) {\n return { ok: false, error: this.#failures.canSendOtp };\n }\n const pending = this.#pendingOtps.get(input.email);\n if (pending === undefined) {\n return { ok: true, value: { allowed: true, cooldownMs: toDurationMs(0) } };\n }\n const nowResult = await readClockNow(this.#clock);\n if (!nowResult.ok) return nowResult;\n const elapsedMs = (nowResult.value as number) - (pending.issuedAt as number);\n const cooldownMs = Math.max(0, (this.#otpTtlMs as number) - elapsedMs);\n if (cooldownMs === 0) {\n this.#pendingOtps.delete(input.email);\n return { ok: true, value: { allowed: true, cooldownMs: toDurationMs(0) } };\n }\n return { ok: true, value: { allowed: false, cooldownMs: toDurationMs(cooldownMs) } };\n }\n\n async sendOtp(\n input: SendOtpInput,\n options?: AuthClientOperationOptions,\n ): Promise<AuthClientResult<void>> {\n if (options?.signal?.aborted) {\n return { ok: false, error: Errors.cancelled({ operation: \"sendOtp\" }) };\n }\n if (this.#failures.sendOtp !== undefined) {\n return { ok: false, error: this.#failures.sendOtp };\n }\n const issuedAt = await readClockNow(this.#clock);\n if (!issuedAt.ok) return issuedAt;\n const counter = this.#otpCountersByEmail.get(input.email) ?? 0;\n this.#otpCountersByEmail.set(input.email, counter + 1);\n const otp = counter.toString().padStart(6, \"0\");\n this.#pendingOtps.set(input.email, {\n otp,\n issuedAt: issuedAt.value,\n });\n return { ok: true, value: undefined };\n }\n\n async verifyOtp(\n input: VerifyOtpInput,\n options?: AuthClientOperationOptions,\n ): Promise<AuthClientResult<AuthSession>> {\n if (options?.signal?.aborted) {\n return { ok: false, error: Errors.cancelled({ operation: \"verifyOtp\" }) };\n }\n if (this.#failures.verifyOtp !== undefined) {\n return { ok: false, error: this.#failures.verifyOtp };\n }\n const pending = this.#pendingOtps.get(input.email);\n if (pending === undefined) {\n return { ok: false, error: Errors.invalidInput(\"email\", \"no OTP issued for this email\") };\n }\n const nowResult = await readClockNow(this.#clock);\n if (!nowResult.ok) return nowResult;\n const now = nowResult.value;\n if ((now as number) - (pending.issuedAt as number) > (this.#otpTtlMs as number)) {\n this.#pendingOtps.delete(input.email);\n return { ok: false, error: Errors.otpExpired() };\n }\n if (input.otp !== pending.otp) {\n return { ok: false, error: Errors.invalidInput(\"otp\", \"incorrect OTP\") };\n }\n\n const authUserId = this.#getOrIssueAuthUserId(input.email);\n const token = toSessionToken(`tok_${this.#tokenCounter++}`);\n const expiresAt = toEpochMs((now as number) + (DEFAULT_SESSION_TTL_MS as number));\n const session: AuthSession = {\n authUserId,\n email: input.email,\n token,\n expiresAt,\n };\n const cacheWrite = await runAuthCacheEffect(this.#authCache.setSession(session), \"setSession\");\n if (!cacheWrite.ok) return cacheWrite;\n this.#pendingOtps.delete(input.email);\n return { ok: true, value: session };\n }\n\n async getSession(\n options?: AuthClientOperationOptions,\n ): Promise<AuthClientResult<AuthSession | null>> {\n if (options?.signal?.aborted) {\n return { ok: false, error: Errors.cancelled({ operation: \"getSession\" }) };\n }\n if (this.#failures.getSession !== undefined) {\n return { ok: false, error: this.#failures.getSession };\n }\n const cacheRead = await runAuthCacheEffect(this.#authCache.getSession, \"getSession\");\n if (!cacheRead.ok) return cacheRead;\n const persisted = cacheRead.value;\n if (persisted === null) {\n return { ok: true, value: null };\n }\n const nowResult = await readClockNow(this.#clock);\n if (!nowResult.ok) return nowResult;\n const now = nowResult.value;\n if ((persisted.expiresAt as number) <= (now as number)) {\n const cacheClear = await runAuthCacheEffect(this.#authCache.clearSession, \"clearSession\");\n if (!cacheClear.ok) return cacheClear;\n return { ok: true, value: null };\n }\n return { ok: true, value: persisted };\n }\n\n async signOut(options?: AuthClientOperationOptions): Promise<AuthClientResult<void>> {\n if (options?.signal?.aborted) {\n return { ok: false, error: Errors.cancelled({ operation: \"signOut\" }) };\n }\n if (this.#failures.signOut !== undefined) {\n return { ok: false, error: this.#failures.signOut };\n }\n return runAuthCacheEffect(this.#authCache.clearSession, \"clearSession\");\n }\n\n async getConvexJwt(options?: GetConvexJwtOptions): Promise<AuthClientResult<CachedJwt>> {\n if (options?.signal?.aborted) {\n return { ok: false, error: Errors.cancelled({ operation: \"getConvexJwt\" }) };\n }\n if (this.#failures.getConvexJwt !== undefined) {\n return { ok: false, error: this.#failures.getConvexJwt };\n }\n if (options?.forceRefresh !== true) {\n const cacheRead = await runAuthCacheEffect(this.#authCache.getJwt, \"getJwt\");\n if (!cacheRead.ok) return cacheRead;\n if (cacheRead.value !== null) {\n return { ok: true, value: cacheRead.value };\n }\n }\n const now = await readClockNow(this.#clock);\n if (!now.ok) return now;\n const jwt: CachedJwt = {\n token: toJwtToken(`in-memory-jwt-${this.#jwtCounter++}`),\n expEpochSeconds: toEpochSeconds(\n Math.floor((now.value as number) / 1000 + (DEFAULT_JWT_TTL_MS as number) / 1000),\n ),\n };\n const cacheWrite = await runAuthCacheEffect(this.#authCache.setJwt(jwt), \"setJwt\");\n if (!cacheWrite.ok) return cacheWrite;\n return { ok: true, value: jwt };\n }\n\n #getOrIssueAuthUserId(email: Email): AuthUserId {\n const existing = this.#authUserIdByEmail.get(email);\n if (existing !== undefined) {\n return existing;\n }\n let fresh: AuthUserId;\n do {\n fresh = toAuthUserId(`user_${this.#authUserIdCounter++}`);\n } while (this.#allocatedAuthUserIds.has(fresh));\n this.#authUserIdByEmail.set(email, fresh);\n this.#allocatedAuthUserIds.add(fresh);\n return fresh;\n }\n}\n\nexport function InMemoryAuthClientLayer(\n deps: {\n readonly authCache: AuthCachePort;\n readonly clock: ClockPort;\n readonly otpTtlMs?: DurationMs;\n readonly failures?: InMemoryAuthClientFailures;\n } = {\n authCache: new InMemoryAuthCacheAdapter(),\n clock: new ManualClockAdapter({}),\n },\n): Layer.Layer<AuthClientPortTag> {\n return Layer.succeed(AuthClientPortTag, makeInMemoryAuthClientPort(deps));\n}\n\nexport function makeInMemoryAuthClientPort(deps: {\n readonly authCache: AuthCachePort;\n readonly clock: ClockPort;\n readonly otpTtlMs?: DurationMs;\n readonly failures?: InMemoryAuthClientFailures;\n}): AuthClientPort {\n return authClientPortFromPromiseAdapter(new InMemoryAuthClientAdapter(deps));\n}\n\nexport type InMemoryAuthClientFailures = {\n readonly canSendOtp?: CapxulError;\n readonly sendOtp?: CapxulError;\n readonly verifyOtp?: CapxulError;\n readonly getSession?: CapxulError;\n readonly signOut?: CapxulError;\n readonly getConvexJwt?: CapxulError;\n};\n\nasync function runAuthCacheEffect<T>(\n effect: Effect.Effect<T, AuthCacheError>,\n operation: string,\n): Promise<AuthClientResult<T>> {\n const result = await Effect.runPromise(Effect.result(effect));\n if (Result.isFailure(result)) {\n return {\n ok: false,\n error: Errors.providerError(\"auth-cache\", operation, result.failure),\n };\n }\n return { ok: true, value: result.success };\n}\n","import type { CapxulError } from \"@capxul/config\";\nimport { Errors } from \"@capxul/config\";\nimport { Effect, Layer } from \"effect\";\n\nimport type { BootstrapInput, BootstrapPort, BootstrapResolution } from \"../../ports/bootstrap\";\nimport {\n BootstrapPortTag,\n bootstrapErrorFromCapxul,\n type BootstrapError,\n} from \"../../ports/bootstrap\";\n\nexport type BootstrapStubScript = {\n /** Keyed by `bootstrapStubScriptKey(input)`. */\n readonly resolutions?: ReadonlyMap<string, BootstrapResolution>;\n /** Keyed by `bootstrapStubScriptKey(input)`. */\n readonly failures?: ReadonlyMap<string, CapxulError>;\n /**\n * Returned when neither map matches. Defaults to `Errors.notAuthenticated()`\n * so the Stub is enumeration-resistant by default.\n */\n readonly defaultFailure?: CapxulError;\n};\n\nexport type BootstrapLayerScenario =\n | \"success\"\n | \"unknownKey\"\n | \"wrongOrigin\"\n | \"revokedKey\"\n | \"pastGraceKey\"\n | \"networkFailure\"\n | \"providerFailure\"\n | \"malformedBodyFailure\";\n\nexport type BootstrapFixtureLayerDeps = {\n readonly input: BootstrapInput;\n readonly resolution: BootstrapResolution;\n readonly scenario?: BootstrapLayerScenario;\n readonly invalidInputs?: Readonly<Record<string, BootstrapInput>>;\n readonly failures?: {\n readonly notAuthenticated?: CapxulError;\n readonly network?: CapxulError;\n readonly provider?: CapxulError;\n readonly malformedBody?: CapxulError;\n };\n};\n\nexport type BootstrapStubLayerDeps =\n | { readonly script: BootstrapStubScript }\n | BootstrapFixtureLayerDeps;\n\nexport class BootstrapStubAdapter implements BootstrapPort {\n readonly #script: BootstrapStubScript;\n\n constructor(deps: { readonly script: BootstrapStubScript }) {\n this.#script = deps.script;\n }\n\n resolve(input: BootstrapInput): Effect.Effect<BootstrapResolution, BootstrapError> {\n const key = bootstrapStubScriptKey(input);\n const failure = this.#script.failures?.get(key);\n if (failure !== undefined) {\n return fail(kindFromCapxulError(failure), failure);\n }\n const resolution = this.#script.resolutions?.get(key);\n if (resolution !== undefined) {\n return Effect.succeed(resolution);\n }\n const defaultFailure = this.#script.defaultFailure ?? Errors.notAuthenticated();\n return fail(kindFromCapxulError(defaultFailure), defaultFailure);\n }\n}\n\nexport function bootstrapStubScriptKey(input: BootstrapInput): string {\n return `${String(input.publishableKey)}::${input.origin ?? \"\"}`;\n}\n\nexport function BootstrapStubLayer(\n input: BootstrapStubLayerDeps,\n scenario: BootstrapLayerScenario = \"success\",\n): Layer.Layer<BootstrapPortTag> {\n if (\"script\" in input) {\n return Layer.succeed(BootstrapPortTag, new BootstrapStubAdapter(input));\n }\n return Layer.succeed(\n BootstrapPortTag,\n makeFixtureBootstrapPort(input, input.scenario ?? scenario),\n );\n}\n\nexport function makeFixtureBootstrapPort(\n input: BootstrapFixtureLayerDeps,\n scenario: BootstrapLayerScenario = \"success\",\n): BootstrapPort {\n return {\n resolve: (request) => {\n const scenarioFailure = failureForScenario(input, scenario);\n if (scenarioFailure !== null) return scenarioFailure;\n if (sameBootstrapInput(request, input.input)) return Effect.succeed(input.resolution);\n return fail(\n \"notAuthenticated\",\n input.failures?.notAuthenticated ?? Errors.notAuthenticated(),\n );\n },\n };\n}\n\nfunction failureForScenario(\n input: BootstrapFixtureLayerDeps,\n scenario: BootstrapLayerScenario,\n): Effect.Effect<never, BootstrapError> | null {\n if (scenario === \"networkFailure\") {\n return fail(\"network\", input.failures?.network ?? Errors.networkError(\"bootstrap.resolve\"));\n }\n if (scenario === \"providerFailure\") {\n return fail(\n \"provider\",\n input.failures?.provider ?? Errors.providerError(\"bootstrap\", \"resolve\", \"provider failure\"),\n );\n }\n if (scenario === \"malformedBodyFailure\") {\n return fail(\n \"malformedBody\",\n input.failures?.malformedBody ??\n Errors.providerError(\"bootstrap\", \"resolve\", \"malformed body\"),\n );\n }\n return null;\n}\n\nfunction kindFromCapxulError(error: CapxulError): BootstrapError[\"kind\"] {\n if (error.code === \"NOT_AUTHENTICATED\") return \"notAuthenticated\";\n if (error.code === \"NETWORK_ERROR\") return \"network\";\n if (error.code === \"RATE_LIMITED\") return \"rateLimited\";\n if (error.code === \"INVALID_INPUT\") return \"invalidInput\";\n return \"provider\";\n}\n\nfunction fail(\n kind: BootstrapError[\"kind\"],\n error: CapxulError,\n): Effect.Effect<never, BootstrapError> {\n return Effect.fail(bootstrapErrorFromCapxul(kind, error));\n}\n\nfunction sameBootstrapInput(left: BootstrapInput, right: BootstrapInput): boolean {\n if (left.publishableKey !== right.publishableKey) return false;\n if ((left.origin === undefined) !== (right.origin === undefined)) return false;\n return left.origin === right.origin;\n}\n","import { CapxulError, Errors } from \"@capxul/config\";\nimport { getFunctionName, type FunctionReference } from \"convex/server\";\nimport { Effect, Layer } from \"effect\";\n\nimport {\n ConvexCallPortTag,\n convexCallErrorFromCapxul,\n type ConvexCallError,\n type ConvexCallPort,\n type Snapshot,\n type Unsubscribe,\n} from \"../../ports/convex-call\";\n\nexport type ConvexCallStubScript = {\n readonly responses?: ReadonlyMap<string, unknown>;\n readonly failures?: ReadonlyMap<string, unknown>;\n readonly subscriptions?: ReadonlyMap<string, ReadonlyArray<Snapshot<unknown>>>;\n};\n\nexport type ConvexCallStubLayerDeps = {\n readonly script: ConvexCallStubScript;\n};\n\ntype Subscriber = {\n readonly callback: (snapshot: Snapshot<unknown>) => void;\n cursor: number;\n};\n\nconst activeStubAdapters = new Set<ConvexCallStubAdapter>();\n\nexport class ConvexCallStubAdapter implements ConvexCallPort {\n readonly #script: ConvexCallStubScript;\n readonly #subscribers = new Map<string, Set<Subscriber>>();\n\n constructor(deps: ConvexCallStubLayerDeps) {\n this.#script = deps.script;\n }\n\n query<TArgs extends Record<string, unknown>, TOutput>(\n fn: FunctionReference<\"query\", \"public\", TArgs, TOutput>,\n _args: TArgs,\n ): Effect.Effect<TOutput, ConvexCallError> {\n return this.#resolve<TOutput>(getFunctionName(fn));\n }\n\n mutation<TArgs extends Record<string, unknown>, TOutput>(\n fn: FunctionReference<\"mutation\", \"public\", TArgs, TOutput>,\n _args: TArgs,\n ): Effect.Effect<TOutput, ConvexCallError> {\n return this.#resolve<TOutput>(getFunctionName(fn));\n }\n\n action<TArgs extends Record<string, unknown>, TOutput>(\n fn: FunctionReference<\"action\", \"public\", TArgs, TOutput>,\n _args: TArgs,\n ): Effect.Effect<TOutput, ConvexCallError> {\n return this.#resolve<TOutput>(getFunctionName(fn));\n }\n\n subscribe<TArgs extends Record<string, unknown>, TOutput>(\n fn: FunctionReference<\"query\", \"public\", TArgs, TOutput>,\n _args: TArgs,\n callback: (snapshot: Snapshot<TOutput>) => void,\n ): Effect.Effect<Unsubscribe, ConvexCallError> {\n return Effect.sync(() => {\n const path = getFunctionName(fn);\n const cb = callback as (snapshot: Snapshot<unknown>) => void;\n cb({ status: \"loading\" });\n const sequence = this.#script.subscriptions?.get(path);\n const subscriber: Subscriber = { callback: cb, cursor: 0 };\n let subs = this.#subscribers.get(path);\n if (subs === undefined) {\n subs = new Set();\n this.#subscribers.set(path, subs);\n }\n subs.add(subscriber);\n if (sequence !== undefined && sequence.length > 0) {\n cb(sequence[0]!);\n subscriber.cursor = 1;\n }\n let active = true;\n return () => {\n if (!active) return;\n active = false;\n const liveSubs = this.#subscribers.get(path);\n if (liveSubs === undefined) return;\n liveSubs.delete(subscriber);\n if (liveSubs.size === 0) this.#subscribers.delete(path);\n };\n });\n }\n\n advanceSubscription(path: string): void {\n const sequence = this.#script.subscriptions?.get(path);\n if (sequence === undefined) return;\n const subs = this.#subscribers.get(path);\n if (subs === undefined) return;\n for (const sub of subs) {\n if (sub.cursor >= sequence.length) continue;\n const next = sequence[sub.cursor]!;\n sub.cursor += 1;\n sub.callback(next);\n }\n }\n\n #resolve<TOutput>(path: string): Effect.Effect<TOutput, ConvexCallError> {\n const failure = this.#script.failures?.get(path);\n if (failure !== undefined) {\n return Effect.fail(mapFailure(path, failure));\n }\n if (this.#script.responses?.has(path)) {\n return Effect.succeed(this.#script.responses.get(path) as TOutput);\n }\n return Effect.fail(\n convexCallErrorFromCapxul(path, Errors.providerError(\"convex\", path, \"unknown function\")),\n );\n }\n}\n\nexport function ConvexCallStubLayer(\n deps: ConvexCallStubLayerDeps,\n): Layer.Layer<ConvexCallPortTag, never, never> {\n return Layer.effect(\n ConvexCallPortTag,\n Effect.acquireRelease(\n Effect.sync(() => {\n const adapter = new ConvexCallStubAdapter(deps);\n activeStubAdapters.add(adapter);\n return adapter;\n }),\n (adapter) =>\n Effect.sync(() => {\n activeStubAdapters.delete(adapter);\n }),\n ),\n );\n}\n\nexport function advanceConvexCallStubSubscription<TArgs extends Record<string, unknown>, TOutput>(\n fn: FunctionReference<\"query\", \"public\", TArgs, TOutput>,\n): Effect.Effect<void> {\n return Effect.sync(() => {\n const path = getFunctionName(fn);\n for (const adapter of activeStubAdapters) {\n adapter.advanceSubscription(path);\n }\n });\n}\n\nfunction mapFailure(operation: string, failure: unknown): ConvexCallError {\n if (failure instanceof CapxulError) return convexCallErrorFromCapxul(operation, failure);\n if (failure instanceof Error) {\n return convexCallErrorFromCapxul(operation, Errors.providerError(\"convex\", operation, failure));\n }\n return convexCallErrorFromCapxul(\n operation,\n Errors.providerError(\"convex\", operation, new Error(String(failure))),\n );\n}\n","/* oxlint-disable typescript/no-this-alias -- Effect.gen callbacks are generator functions, so adapter receivers are captured explicitly. */\nimport type { CapxulError } from \"@capxul/config\";\nimport { Errors } from \"@capxul/config\";\nimport type { AuthUserId, EpochMs, Profile } from \"@capxul/types\";\nimport { toKycTier } from \"@capxul/types\";\nimport { Effect, Layer } from \"effect\";\n\nimport { ClockPortTag, type ClockPort } from \"../../ports/clock\";\nimport type {\n CompleteOnboardingIdentityInput,\n CreateIdentityInput,\n IdentityError,\n IdentityPort,\n UpdateIdentityInput,\n} from \"../../ports/identity\";\nimport { identityErrorFromCapxul, IdentityPortTag } from \"../../ports/identity\";\n\nexport type InMemoryIdentityLayerDeps = {\n readonly clock: ClockPort;\n};\n\nexport class InMemoryIdentityAdapter implements IdentityPort {\n readonly #identities = new Map<AuthUserId, Profile>();\n readonly #clock: ClockPort;\n\n constructor(deps: InMemoryIdentityLayerDeps) {\n this.#clock = deps.clock;\n }\n\n loadByAuthUserId(authUserId: AuthUserId): Effect.Effect<Profile | null, IdentityError> {\n return Effect.sync(() => cloneProfileOrNull(this.#identities.get(authUserId) ?? null));\n }\n\n create(input: CreateIdentityInput): Effect.Effect<Profile, IdentityError> {\n const self = this;\n return Effect.gen(function* () {\n if (self.#identities.has(input.authUserId)) {\n return yield* fail(\"create\", Errors.invalidInput(\"authUserId\", \"already exists\"));\n }\n const now = yield* self.#now(\"create.clock\");\n const profile: Profile = {\n authUserId: input.authUserId,\n email: input.email,\n displayName: input.displayName ?? null,\n country: input.country ?? null,\n onboarded: false,\n withdrawalAddress: null,\n username: null,\n imageUrl: null,\n kycTier: toKycTier(0),\n createdAt: now,\n updatedAt: now,\n };\n self.#identities.set(input.authUserId, cloneProfile(profile));\n return cloneProfile(profile);\n });\n }\n\n update(input: UpdateIdentityInput): Effect.Effect<Profile, IdentityError> {\n const self = this;\n return Effect.gen(function* () {\n const existing = self.#identities.get(input.authUserId);\n if (existing === undefined) {\n return yield* fail(\"update\", Errors.profileNotFound(input.authUserId));\n }\n const now = yield* self.#now(\"update.clock\");\n const updated: Profile = {\n authUserId: existing.authUserId,\n email: existing.email,\n kycTier: existing.kycTier,\n createdAt: existing.createdAt,\n displayName: input.displayName !== undefined ? input.displayName : existing.displayName,\n country: input.country !== undefined ? input.country : existing.country,\n onboarded: existing.onboarded,\n withdrawalAddress: existing.withdrawalAddress,\n username: existing.username,\n imageUrl: existing.imageUrl,\n updatedAt: now,\n };\n self.#identities.set(input.authUserId, cloneProfile(updated));\n return cloneProfile(updated);\n });\n }\n\n completeOnboarding(\n input: CompleteOnboardingIdentityInput,\n ): Effect.Effect<Profile, IdentityError> {\n const self = this;\n return Effect.gen(function* () {\n const now = yield* self.#now(\"completeOnboarding.clock\");\n const existing = self.#identities.get(input.authUserId);\n const profile: Profile = {\n authUserId: input.authUserId,\n email: existing?.email ?? input.email,\n displayName: input.displayName,\n country: input.country,\n onboarded: true,\n withdrawalAddress: input.withdrawalAddress ?? existing?.withdrawalAddress ?? null,\n username: existing?.username ?? null,\n imageUrl: existing?.imageUrl ?? null,\n kycTier: existing?.kycTier ?? toKycTier(0),\n createdAt: existing?.createdAt ?? now,\n updatedAt: now,\n };\n self.#identities.set(input.authUserId, cloneProfile(profile));\n return cloneProfile(profile);\n });\n }\n\n #now(operation: string): Effect.Effect<EpochMs, IdentityError> {\n return this.#clock.now.pipe(\n Effect.mapError((cause) =>\n identityErrorFromCapxul(operation, Errors.providerError(\"clock\", \"now\", cause), cause),\n ),\n );\n }\n}\n\nexport function InMemoryIdentityLayer(): Layer.Layer<IdentityPortTag, IdentityError, ClockPortTag> {\n return Layer.effect(\n IdentityPortTag,\n Effect.map(ClockPortTag, (clock) => new InMemoryIdentityAdapter({ clock })),\n );\n}\n\nfunction fail(operation: string, error: CapxulError): Effect.Effect<never, IdentityError> {\n return Effect.fail(identityErrorFromCapxul(operation, error));\n}\n\nfunction cloneProfile(profile: Profile): Profile {\n return {\n authUserId: profile.authUserId,\n email: profile.email,\n displayName: profile.displayName,\n country: profile.country,\n onboarded: profile.onboarded,\n withdrawalAddress: profile.withdrawalAddress,\n username: profile.username,\n imageUrl: profile.imageUrl,\n kycTier: profile.kycTier,\n createdAt: profile.createdAt,\n updatedAt: profile.updatedAt,\n };\n}\n\nfunction cloneProfileOrNull(profile: Profile | null): Profile | null {\n return profile === null ? null : cloneProfile(profile);\n}\n","import type { Address, ChainId } from \"@capxul/types\";\nimport { toAddress } from \"@capxul/types\";\nimport { encodePacked, getCreate2Address, keccak256 } from \"viem\";\n\nimport { addressForViem, wireChainId } from \"../../adapters/_shared/wire\";\n\nconst SUPPORTED_CHAIN_IDS = new Set<number>([84532, 8453]);\nconst SAFE_DEPLOYER_ADDRESS: Address = toAddress(\"0xa6b71e26c5e0845f74c812102ca7114b6a896ab2\");\nconst SAFE_INITCODE_HASH = keccak256(\"0x\");\n\nexport function isSupportedSmartAccountChain(chainId: ChainId): boolean {\n return SUPPORTED_CHAIN_IDS.has(wireChainId(chainId));\n}\n\nexport function deriveSmartAccountAddress(signerAddress: Address, chainId: ChainId): Address {\n const normalizedSigner = toAddress(signerAddress);\n const salt = keccak256(\n encodePacked([\"address\", \"uint256\"], [addressForViem(normalizedSigner), BigInt(chainId)]),\n );\n return toAddress(\n getCreate2Address({\n from: addressForViem(SAFE_DEPLOYER_ADDRESS),\n salt,\n bytecodeHash: SAFE_INITCODE_HASH,\n }),\n );\n}\n","/* oxlint-disable typescript/no-this-alias -- Effect.gen callbacks are generator functions, so adapter receivers are captured explicitly. */\nimport type { CapxulError } from \"@capxul/config\";\nimport { deriveCapxulSafeAddress, Errors } from \"@capxul/config\";\nimport type { Address, AuthUserId, EpochMs, SmartAccount } from \"@capxul/types\";\nimport { toAddress } from \"@capxul/types\";\nimport { Effect, Layer, Semaphore } from \"effect\";\n\nimport { ClockPortTag, type ClockPort } from \"../../ports/clock\";\nimport { IdentityPortTag, type IdentityPort } from \"../../ports/identity\";\nimport type {\n ClaimInput,\n ConfirmDeploymentInput,\n ProvisionInput,\n SmartAccountError,\n SmartAccountPort,\n} from \"../../ports/smart-account\";\nimport { smartAccountErrorFromCapxul, SmartAccountPortTag } from \"../../ports/smart-account\";\nimport { isSupportedSmartAccountChain } from \"./smart-account-derivation\";\n\nexport type InMemorySmartAccountLayerDeps = {\n readonly clock: ClockPort;\n readonly identity: IdentityPort;\n readonly failures?: {\n readonly loadByAuthUserId?: CapxulError;\n readonly loadBySmartAccountAddress?: CapxulError;\n readonly provision?: CapxulError;\n readonly claim?: CapxulError;\n };\n};\n\n/**\n * Hermetic backend stand-in (PRD #462 / derivation v2): `provision` derives\n * the Safe from the identity email alone via the REAL canonical derivation\n * (`deriveCapxulSafeAddress({ email })` — owner is the pinned bootstrap\n * constant). No signer exists at provision; `claim` installs the signer and\n * marks the row deployed, mirroring the backend's one-userOp claim lane.\n */\nexport class InMemorySmartAccountAdapter implements SmartAccountPort {\n readonly #accounts = new Map<AuthUserId, SmartAccount>();\n readonly #clock: ClockPort;\n readonly #identity: IdentityPort;\n readonly #failures: InMemorySmartAccountLayerDeps[\"failures\"];\n readonly #provisionMutex = Semaphore.makeUnsafe(1);\n\n constructor(deps: InMemorySmartAccountLayerDeps) {\n this.#clock = deps.clock;\n this.#identity = deps.identity;\n this.#failures = deps.failures;\n }\n\n loadByAuthUserId(authUserId: AuthUserId): Effect.Effect<SmartAccount | null, SmartAccountError> {\n const scriptedFailure = this.#failures?.loadByAuthUserId;\n if (scriptedFailure !== undefined) return fail(\"loadByAuthUserId\", scriptedFailure);\n return Effect.sync(() => cloneSmartAccountOrNull(this.#accounts.get(authUserId) ?? null));\n }\n\n loadBySmartAccountAddress(\n address: Address,\n ): Effect.Effect<SmartAccount | null, SmartAccountError> {\n const scriptedFailure = this.#failures?.loadBySmartAccountAddress;\n if (scriptedFailure !== undefined) return fail(\"loadBySmartAccountAddress\", scriptedFailure);\n return Effect.sync(() => {\n const needle = toAddress(address);\n for (const account of this.#accounts.values()) {\n if (account.smartAccountAddress === needle) return cloneSmartAccount(account);\n }\n return null;\n });\n }\n\n provision(input: ProvisionInput): Effect.Effect<SmartAccount, SmartAccountError> {\n const scriptedFailure = this.#failures?.provision;\n if (scriptedFailure !== undefined) return fail(\"provision\", scriptedFailure);\n const self = this;\n return Effect.gen(function* () {\n if (!isSupportedSmartAccountChain(input.chainId)) {\n return yield* fail(\n \"provision\",\n Errors.invalidInput(\"chainId\", `unsupported chainId ${String(input.chainId)}`),\n );\n }\n\n const identity = yield* self.#identity\n .loadByAuthUserId(input.authUserId)\n .pipe(\n Effect.mapError((error) =>\n smartAccountErrorFromCapxul(\"provision.identity\", error.publicError, error),\n ),\n );\n if (identity === null) {\n return yield* fail(\"provision\", Errors.profileNotFound(String(input.authUserId)));\n }\n\n const existing = self.#accounts.get(input.authUserId);\n if (existing !== undefined) return cloneSmartAccount(existing);\n\n const now = yield* self.#now(\"provision.clock\");\n const account: SmartAccount = {\n authUserId: input.authUserId,\n // PRD #462: no signer exists at provision — installed at claim.\n signerAddress: null,\n smartAccountAddress: toAddress(deriveCapxulSafeAddress({ email: identity.email })),\n chainId: input.chainId,\n deployedAt: null,\n claimedAt: null,\n createdAt: now,\n };\n self.#accounts.set(input.authUserId, cloneSmartAccount(account));\n return cloneSmartAccount(account);\n }).pipe(self.#provisionMutex.withPermits(1));\n }\n\n promoteDeployedAt(authUserId: AuthUserId, deployedAt: EpochMs): void {\n const existing = this.#accounts.get(authUserId);\n if (existing === undefined) return;\n if (existing.deployedAt !== null) return;\n this.#accounts.set(authUserId, { ...existing, deployedAt });\n }\n\n confirmDeployment(input: ConfirmDeploymentInput): Effect.Effect<SmartAccount, SmartAccountError> {\n const self = this;\n return Effect.gen(function* () {\n const existing = self.#accounts.get(input.authUserId);\n if (existing === undefined) {\n return yield* fail(\"confirmDeployment\", Errors.profileNotFound(String(input.authUserId)));\n }\n if (existing.smartAccountAddress !== toAddress(input.safeAddress)) {\n return yield* fail(\n \"confirmDeployment\",\n Errors.invalidInput(\"safeAddress\", \"does not match backend smart-account row\"),\n );\n }\n // γ-B: backend (this hermetic stand-in) is the ORACLE for\n // `deployedAt`. Derive from the clock — NEVER from any field on\n // `input.evidence`.\n if (existing.deployedAt !== null) {\n return cloneSmartAccount(existing);\n }\n const now = yield* self.#now(\"confirmDeployment.clock\");\n const updated: SmartAccount = { ...existing, deployedAt: now };\n self.#accounts.set(input.authUserId, cloneSmartAccount(updated));\n return cloneSmartAccount(updated);\n }).pipe(self.#provisionMutex.withPermits(1));\n }\n\n claim(input: ClaimInput): Effect.Effect<SmartAccount, SmartAccountError> {\n const scriptedFailure = this.#failures?.claim;\n if (scriptedFailure !== undefined) return fail(\"claim\", scriptedFailure);\n const self = this;\n return Effect.gen(function* () {\n const existing = self.#accounts.get(input.authUserId);\n if (existing === undefined) {\n return yield* fail(\n \"claim\",\n Errors.invalidInput(\"account\", \"no provisioned smart account for this user\"),\n );\n }\n if (existing.chainId !== input.chainId) {\n return yield* fail(\n \"claim\",\n Errors.invalidInput(\"chainId\", \"does not match backend smart-account row\"),\n );\n }\n const newOwner = toAddress(input.signerAddress);\n // Idempotency mirrors the backend claim action: a confirmed claim is\n // final; a different signer is an explicit error (recovery is a\n // separate lane, out of scope per PRD #462).\n if (existing.claimedAt !== null) {\n if (existing.signerAddress !== newOwner) {\n return yield* fail(\n \"claim\",\n Errors.invalidInput(\"signerAddress\", \"account already claimed by a different signer\"),\n );\n }\n return cloneSmartAccount(existing);\n }\n const now = yield* self.#now(\"claim.clock\");\n const updated: SmartAccount = {\n ...existing,\n signerAddress: newOwner,\n claimedAt: now,\n deployedAt: existing.deployedAt ?? now,\n };\n self.#accounts.set(input.authUserId, cloneSmartAccount(updated));\n return cloneSmartAccount(updated);\n }).pipe(self.#provisionMutex.withPermits(1));\n }\n\n #now(operation: string): Effect.Effect<EpochMs, SmartAccountError> {\n return this.#clock.now.pipe(\n Effect.mapError((cause) =>\n smartAccountErrorFromCapxul(operation, Errors.providerError(\"clock\", \"now\", cause), cause),\n ),\n );\n }\n}\n\nexport function InMemorySmartAccountLayer(\n deps: {\n readonly failures?: InMemorySmartAccountLayerDeps[\"failures\"];\n } = {},\n): Layer.Layer<SmartAccountPortTag, SmartAccountError, ClockPortTag | IdentityPortTag> {\n return Layer.effect(\n SmartAccountPortTag,\n Effect.gen(function* () {\n const clock = yield* ClockPortTag;\n const identity = yield* IdentityPortTag;\n return new InMemorySmartAccountAdapter({\n clock,\n identity,\n ...(deps.failures === undefined ? {} : { failures: deps.failures }),\n });\n }),\n );\n}\n\nfunction fail(operation: string, error: CapxulError): Effect.Effect<never, SmartAccountError> {\n return Effect.fail(smartAccountErrorFromCapxul(operation, error));\n}\n\nfunction cloneSmartAccount(account: SmartAccount): SmartAccount {\n return {\n authUserId: account.authUserId,\n signerAddress: account.signerAddress,\n smartAccountAddress: account.smartAccountAddress,\n chainId: account.chainId,\n deployedAt: account.deployedAt,\n claimedAt: account.claimedAt,\n createdAt: account.createdAt,\n };\n}\n\nfunction cloneSmartAccountOrNull(account: SmartAccount | null): SmartAccount | null {\n return account === null ? null : cloneSmartAccount(account);\n}\n","import { Errors, type CapxulError } from \"@capxul/config\";\nimport type { AccountId, Money, SubAccount } from \"@capxul/types\";\nimport { toCurrencyCode, toEpochMs, toSubAccountId } from \"@capxul/types\";\nimport { Effect, Layer } from \"effect\";\n\nimport { fromWei } from \"../../domain/money/from-wei\";\nimport { toWei } from \"../../domain/money/to-wei\";\nimport type {\n CreateSubAccountInput,\n RenameSubAccountInput,\n SubAccountError,\n SubAccountIdInput,\n SubAccountPort,\n TransferInput,\n TransferResult,\n} from \"../../ports/sub-account\";\nimport { subAccountErrorFromCapxul, SubAccountPortTag } from \"../../ports/sub-account\";\n\nexport class InMemorySubAccountAdapter implements SubAccountPort {\n readonly #rows = new Map<string, SubAccount>();\n readonly #failures: { readonly create?: CapxulError };\n // The Safe's on-chain `balanceOf` as a base-unit integer string. `transfer`\n // validates a `main`-source against `balanceOfRaw − Σ(sub-account balances)`\n // and recomputes `available` against it — mirroring the backend action which\n // reads the real chain. Defaults to \"0\" (an unfunded Safe).\n readonly #balanceOfRaw: string;\n // Monotonic id counter — never derived from #rows.size, which shrinks on\n // delete and would let a later create collide with an existing id.\n #created: number;\n\n constructor(\n deps: {\n readonly failures?: { readonly create?: CapxulError };\n readonly seed?: readonly SubAccount[];\n readonly balanceOfRaw?: string;\n } = {},\n ) {\n this.#failures = deps.failures ?? {};\n this.#balanceOfRaw = deps.balanceOfRaw ?? \"0\";\n for (const row of deps.seed ?? []) {\n this.#rows.set(row.id as string, row);\n }\n this.#created = this.#rows.size;\n }\n\n create(input: CreateSubAccountInput): Effect.Effect<SubAccount, SubAccountError> {\n const failure = this.#failures.create;\n if (failure !== undefined) {\n return Effect.fail(subAccountErrorFromCapxul(\"create\", failure));\n }\n this.#created += 1;\n const id = toSubAccountId(`subaccount_test${String(this.#created)}`);\n const row: SubAccount = {\n id,\n accountId: input.accountId,\n name: input.name,\n balance: { currency: toCurrencyCode(\"USD\"), value: \"0\", decimals: 6 },\n createdAt: toEpochMs(Date.now()),\n };\n this.#rows.set(id as string, row);\n return Effect.succeed(row);\n }\n\n get(input: SubAccountIdInput): Effect.Effect<SubAccount | null, SubAccountError> {\n return Effect.succeed(this.#rows.get(input.subAccountId as string) ?? null);\n }\n\n list(input: {\n readonly accountId: AccountId;\n }): Effect.Effect<readonly SubAccount[], SubAccountError> {\n const accountId = input.accountId as string;\n return Effect.succeed(\n [...this.#rows.values()].filter((row) => (row.accountId as string) === accountId),\n );\n }\n\n rename(input: RenameSubAccountInput): Effect.Effect<SubAccount, SubAccountError> {\n const existing = this.#rows.get(input.subAccountId as string);\n if (existing === undefined) {\n return Effect.fail(\n subAccountErrorFromCapxul(\"rename\", Errors.accountNotFound(input.subAccountId as string)),\n );\n }\n const next = { ...existing, name: input.name };\n this.#rows.set(input.subAccountId as string, next);\n return Effect.succeed(next);\n }\n\n delete(input: SubAccountIdInput): Effect.Effect<void, SubAccountError> {\n const existing = this.#rows.get(input.subAccountId as string);\n if (existing === undefined) {\n return Effect.fail(\n subAccountErrorFromCapxul(\"delete\", Errors.accountNotFound(input.subAccountId as string)),\n );\n }\n // Representation-agnostic zero check: Money.value is a major-unit decimal\n // string (\"0\", \"0.0\", \"0.00\" all denote an empty bucket). Mirrors the\n // backend `remove` invariant and the CLI money.ts zero check.\n if (Number(existing.balance.value) !== 0) {\n return Effect.fail(\n subAccountErrorFromCapxul(\n \"delete\",\n Errors.invalidInput(\"subAccountId\", \"delete requires zero balance\"),\n ),\n );\n }\n this.#rows.delete(input.subAccountId as string);\n return Effect.succeed(undefined);\n }\n\n transfer(input: TransferInput): Effect.Effect<TransferResult, SubAccountError> {\n const decimals = input.amount.decimals;\n const invalid = (\n field: string,\n reason: string,\n ): Effect.Effect<TransferResult, SubAccountError> =>\n Effect.fail(subAccountErrorFromCapxul(\"transfer\", Errors.invalidInput(field, reason)));\n\n // Brand the amount into base units. `toWei`/`parseUnits` throws on a\n // malformed decimal string; catch it as INVALID_INPUT rather than a defect.\n let rawAmount: bigint;\n try {\n rawAmount = BigInt(toWei(input.amount));\n } catch {\n return invalid(\"amount\", \"must be a decimal money string\");\n }\n if (rawAmount <= 0n) return invalid(\"amount\", \"must be positive\");\n if (input.from === input.to) return invalid(\"transfer\", \"from and to must differ\");\n\n // Resolve endpoints — an unknown sub-account id is INVALID_INPUT.\n const fromRow =\n input.from === \"main\" ? null : (this.#rows.get(input.from as string) ?? \"missing\");\n if (fromRow === \"missing\") return invalid(\"subAccountId\", \"unknown sub-account\");\n const toRow = input.to === \"main\" ? null : (this.#rows.get(input.to as string) ?? \"missing\");\n if (toRow === \"missing\") return invalid(\"subAccountId\", \"unknown sub-account\");\n\n const safeRaw = BigInt(this.#balanceOfRaw);\n const subTotalRaw = this.#sumSubAccountRaws(decimals);\n\n // Validate source funds.\n if (input.from === \"main\") {\n const availableRaw = safeRaw - subTotalRaw;\n if (availableRaw < rawAmount) {\n return Effect.fail(\n subAccountErrorFromCapxul(\n \"transfer\",\n Errors.insufficientBalance(\"main\", maxRaw(availableRaw), rawAmount.toString(10)),\n ),\n );\n }\n } else if (fromRow !== null) {\n const fromRaw = BigInt(toWei({ value: fromRow.balance.value, decimals }));\n if (fromRaw < rawAmount) {\n return Effect.fail(\n subAccountErrorFromCapxul(\n \"transfer\",\n Errors.insufficientBalance(fromRow.name, fromRaw.toString(10), rawAmount.toString(10)),\n ),\n );\n }\n }\n\n // Apply the patch (main is implicit — never a row).\n let nextFrom: SubAccount | null = null;\n let nextTo: SubAccount | null = null;\n if (fromRow !== null) {\n const fromRaw = BigInt(toWei({ value: fromRow.balance.value, decimals }));\n nextFrom = this.#patchBalance(fromRow, (fromRaw - rawAmount).toString(10), decimals);\n }\n if (toRow !== null) {\n const toRaw = BigInt(toWei({ value: toRow.balance.value, decimals }));\n nextTo = this.#patchBalance(toRow, (toRaw + rawAmount).toString(10), decimals);\n }\n\n const newAvailableRaw = safeRaw - this.#sumSubAccountRaws(decimals);\n const available = fromWei(maxRaw(newAvailableRaw), decimals, input.amount.currency as string);\n return Effect.succeed({ available, from: nextFrom, to: nextTo });\n }\n\n #sumSubAccountRaws(decimals: number): bigint {\n let total = 0n;\n for (const row of this.#rows.values()) {\n total += BigInt(toWei({ value: row.balance.value, decimals }));\n }\n return total;\n }\n\n #patchBalance(row: SubAccount, rawBalance: string, decimals: number): SubAccount {\n const balance: Money = fromWei(rawBalance, decimals, row.balance.currency as string);\n const next: SubAccount = { ...row, balance };\n this.#rows.set(row.id as string, next);\n return next;\n }\n}\n\n/** Floor a (possibly negative) base-unit raw to a non-negative base-10 string. */\nfunction maxRaw(raw: bigint): string {\n return (raw < 0n ? 0n : raw).toString(10);\n}\n\nexport function InMemorySubAccountLayer(\n deps: { readonly failures?: { readonly create?: CapxulError } } = {},\n): Layer.Layer<SubAccountPortTag, SubAccountError, never> {\n return Layer.succeed(SubAccountPortTag, new InMemorySubAccountAdapter(deps));\n}\n","import { Effect, Layer } from \"effect\";\n\nimport {\n redactTelemetryEvent,\n TelemetryPortTag,\n type TelemetryEvent,\n type TelemetryGroupInput,\n type TelemetryIdentifyInput,\n type TelemetryPort,\n type TelemetryProps,\n} from \"../../ports/telemetry\";\n\nexport type RecordingTelemetryOperation =\n | { readonly type: \"emit\"; readonly event: TelemetryEvent }\n | { readonly type: \"identify\"; readonly input: TelemetryIdentifyInput }\n | { readonly type: \"group\"; readonly input: TelemetryGroupInput }\n | { readonly type: \"reset\" };\n\nexport interface RecordingTelemetryAdapterOptions {\n readonly rawMode?: boolean;\n}\n\nexport class RecordingTelemetryAdapter implements TelemetryPort {\n readonly #events: TelemetryEvent[] = [];\n readonly #operations: RecordingTelemetryOperation[] = [];\n readonly #rawMode: boolean;\n\n constructor(options: RecordingTelemetryAdapterOptions = {}) {\n this.#rawMode = options.rawMode === true;\n }\n\n get events(): readonly TelemetryEvent[] {\n return this.#events.map(cloneEvent);\n }\n\n get operations(): readonly RecordingTelemetryOperation[] {\n return this.#operations.map(cloneOperation);\n }\n\n emit(event: TelemetryEvent): Effect.Effect<void, never, never> {\n return Effect.sync(() => {\n const recorded = redactTelemetryEvent(event, { rawMode: this.#rawMode });\n this.#events.push(recorded);\n this.#operations.push({ type: \"emit\", event: cloneEvent(recorded) });\n });\n }\n\n identify(input: TelemetryIdentifyInput): Effect.Effect<void, never, never> {\n return Effect.sync(() => {\n this.#operations.push({\n type: \"identify\",\n input: cloneIdentifyInput(input),\n });\n });\n }\n\n group(input: TelemetryGroupInput): Effect.Effect<void, never, never> {\n return Effect.sync(() => {\n this.#operations.push({\n type: \"group\",\n input: cloneGroupInput(input),\n });\n });\n }\n\n reset(): Effect.Effect<void, never, never> {\n return Effect.sync(() => {\n this.#operations.push({ type: \"reset\" });\n });\n }\n\n clear(): void {\n this.#events.length = 0;\n this.#operations.length = 0;\n }\n}\n\nexport function RecordingTelemetryLayer(\n adapter: RecordingTelemetryAdapter = new RecordingTelemetryAdapter(),\n): Layer.Layer<TelemetryPortTag, never, never> {\n return Layer.succeed(TelemetryPortTag, adapter);\n}\n\nfunction cloneEvent(event: TelemetryEvent): TelemetryEvent {\n return event.props === undefined\n ? { name: event.name }\n : { name: event.name, props: cloneProps(event.props) };\n}\n\nfunction cloneOperation(operation: RecordingTelemetryOperation): RecordingTelemetryOperation {\n switch (operation.type) {\n case \"emit\":\n return { type: \"emit\", event: cloneEvent(operation.event) };\n case \"identify\":\n return { type: \"identify\", input: cloneIdentifyInput(operation.input) };\n case \"group\":\n return { type: \"group\", input: cloneGroupInput(operation.input) };\n case \"reset\":\n return { type: \"reset\" };\n }\n}\n\nfunction cloneIdentifyInput(input: TelemetryIdentifyInput): TelemetryIdentifyInput {\n return {\n distinctId: input.distinctId,\n ...(input.anonDistinctId === undefined ? {} : { anonDistinctId: input.anonDistinctId }),\n ...(input.traits === undefined ? {} : { traits: cloneProps(input.traits) }),\n ...(input.properties === undefined ? {} : { properties: cloneProps(input.properties) }),\n };\n}\n\nfunction cloneGroupInput(input: TelemetryGroupInput): TelemetryGroupInput {\n return input.properties === undefined\n ? { groupType: input.groupType, groupKey: input.groupKey }\n : {\n groupType: input.groupType,\n groupKey: input.groupKey,\n properties: cloneProps(input.properties),\n };\n}\n\nfunction cloneProps(props: TelemetryProps): TelemetryProps {\n const cloned: TelemetryProps = {};\n for (const [key, value] of Object.entries(props)) {\n cloned[key] = cloneTelemetryValue(value);\n }\n return cloned;\n}\n\nfunction cloneTelemetryValue(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(cloneTelemetryValue);\n if (value === null || typeof value !== \"object\") return value;\n if (Object.getPrototypeOf(value) !== Object.prototype) return value;\n const cloned: Record<string, unknown> = {};\n for (const [key, nested] of Object.entries(value)) {\n cloned[key] = cloneTelemetryValue(nested);\n }\n return cloned;\n}\n","import { Effect } from \"effect\";\n\nimport {\n toAllowedOrigin,\n toAppId,\n toAuthUserId,\n toChainId,\n toCountryCode,\n toDurationMs,\n toEmail,\n toEpochMs,\n toPublishableKey,\n toSessionToken,\n} from \"@capxul/types\";\n\nimport { authClientPortFromPromiseAdapter } from \"../adapters/auth-client/effect-port\";\nimport { InMemoryAuthCacheAdapter } from \"../adapters/auth-cache/InMemoryAuthCacheAdapter\";\nimport type { IdentityTransition } from \"../domain/machine/shell\";\nimport type { FlowPorts } from \"../flows/types\";\nimport type { BootstrapResolution } from \"../ports/bootstrap\";\nimport type {\n TelemetryEvent,\n TelemetryGroupInput,\n TelemetryIdentifyInput,\n} from \"../ports/telemetry\";\nimport { assembleCapxulClient, type CapxulClient } from \"../surface/create-capxul-client\";\nimport { InMemoryAccountReadAdapter } from \"./account/InMemoryAccountReadAdapter\";\nimport { InMemoryAuthClientAdapter } from \"./auth-client/InMemoryAuthClientAdapter\";\nimport { BootstrapStubAdapter } from \"./bootstrap/BootstrapStubAdapter\";\nimport { ManualClockAdapter } from \"./clock/ManualClockAdapter\";\nimport { ConvexCallStubAdapter } from \"./convex-call/ConvexCallStubAdapter\";\nimport { InMemoryIdentityAdapter } from \"./identity/InMemoryIdentityAdapter\";\nimport { InMemorySmartAccountAdapter } from \"./smart-account/InMemorySmartAccountAdapter\";\nimport { InMemorySubAccountAdapter } from \"./sub-account/InMemorySubAccountAdapter\";\nimport {\n RecordingTelemetryAdapter,\n type RecordingTelemetryOperation,\n} from \"./telemetry/RecordingTelemetryAdapter\";\n\nconst TEST_BOOTSTRAP: BootstrapResolution = {\n applicationId: toAppId(\"app_01HX0000000000000000000000\"),\n chainId: toChainId(84_532),\n sessionToken: toSessionToken(\"bootstrap-test-token\"),\n issuedAt: toEpochMs(0),\n expiresIn: toDurationMs(60_000),\n authBaseUrl: \"https://auth.example.test\",\n convexUrl: \"https://convex.example.test\",\n siteBaseUrl: \"https://example.test\",\n openfortPublishableKey: \"pk_test_openfort_fixture\",\n shieldPublishableKey: \"shield_pk_test_fixture\",\n};\n\nexport interface CreateCapxulTestClientOptions {\n readonly requirement?: \"none\" | \"counterfactual\" | \"deployed\";\n}\n\nexport interface SeedTestIdentityInput {\n readonly authUserId: string;\n readonly email: string;\n readonly displayName?: string;\n readonly country?: string;\n}\n\nexport interface CapxulTestClient {\n readonly client: CapxulClient;\n readonly clock: CapxulTestClock;\n readonly observation: CapxulTestObservation;\n readonly transitions: readonly IdentityTransition[];\n readonly observations: readonly RecordingTelemetryOperation[];\n readonly peekOtp: (email: string) => string | undefined;\n readonly seedIdentity: (input: SeedTestIdentityInput) => Promise<void>;\n readonly close: () => Promise<void>;\n}\n\nexport interface CapxulTestClock {\n readonly advance: (ms: number) => Promise<void>;\n}\n\nexport interface CapxulTestObservation {\n readonly emit: (event: TelemetryEvent) => Promise<void>;\n readonly identify: (input: TelemetryIdentifyInput) => Promise<void>;\n readonly group: (input: TelemetryGroupInput) => Promise<void>;\n readonly reset: () => Promise<void>;\n}\n\n/**\n * Assemble the real public client over deterministic in-memory ports.\n * Unconfigured backend calls fail locally; no adapter owns a network exit.\n */\nexport function createCapxulTestClient(\n options: CreateCapxulTestClientOptions = {},\n): CapxulTestClient {\n const clock = new ManualClockAdapter({});\n const authCache = new InMemoryAuthCacheAdapter();\n const authClient = new InMemoryAuthClientAdapter({ authCache, clock });\n const identity = new InMemoryIdentityAdapter({ clock });\n const telemetry = new RecordingTelemetryAdapter();\n const ports: FlowPorts = {\n authClient: authClientPortFromPromiseAdapter(authClient),\n authCache,\n identity,\n smartAccount: new InMemorySmartAccountAdapter({ clock, identity }),\n accountRead: new InMemoryAccountReadAdapter({ rawBalance: \"0\" }),\n subAccount: new InMemorySubAccountAdapter(),\n bootstrap: new BootstrapStubAdapter({\n script: {\n resolutions: new Map([\n [\n `${toPublishableKey(\"cap_pk_test_0123456789ABCDEFGHJKMNPQRSTVWXYZ\")}::${toAllowedOrigin(\"https://example.test\")}`,\n TEST_BOOTSTRAP,\n ],\n ]),\n },\n }),\n clock,\n telemetry,\n convexCall: new ConvexCallStubAdapter({ script: {} }),\n };\n const client = assembleCapxulClient({\n ports,\n bootstrap: TEST_BOOTSTRAP,\n authCache,\n requirement: options.requirement ?? \"none\",\n });\n const transitions: IdentityTransition[] = [];\n const unsubscribe = client._internal.identity.subscribeTransitions((record) => {\n transitions.push(record);\n });\n let closed = false;\n const clockControl: CapxulTestClock = Object.freeze({\n advance: (ms: number) => clock.advance(ms),\n });\n\n return {\n client,\n clock: clockControl,\n observation: {\n emit: (event) => Effect.runPromise(telemetry.emit(event)),\n identify: (input) => Effect.runPromise(telemetry.identify(input)),\n group: (input) => Effect.runPromise(telemetry.group(input)),\n reset: () => Effect.runPromise(telemetry.reset()),\n },\n get transitions() {\n return transitions.slice();\n },\n get observations() {\n return telemetry.operations;\n },\n peekOtp: (email) => authClient.peekOtpForTesting(toEmail(email)),\n seedIdentity: async (input) => {\n const authUserId = toAuthUserId(input.authUserId);\n const email = toEmail(input.email);\n await Effect.runPromise(\n identity.create({\n authUserId,\n email,\n ...(input.displayName === undefined ? {} : { displayName: input.displayName }),\n ...(input.country === undefined ? {} : { country: toCountryCode(input.country) }),\n }),\n );\n authClient.bindAuthUserIdForTesting(email, authUserId);\n },\n close: async () => {\n if (closed) return;\n closed = true;\n unsubscribe();\n await client._internal.close?.();\n },\n };\n}\n"],"mappings":";;;;;;AA4BA,IAAa,6BAAb,MAAmE;CACjE;CACA;CAEA,YAAY,OAAqC,CAAC,GAAG;EACnD,KAAKA,QAAQ;EACb,KAAKC,cAAc,KAAK,cAAc;CACxC;CAEA,YAAY,QAA2E;EACrF,MAAM,kBAAkB,KAA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