@capxul/sdk 1.0.0-alpha.12 → 1.0.0-alpha.13

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.
@@ -1,7 +1,7 @@
1
- import { _ as AuthCachePortTag, g as AuthCachePort, h as AuthCacheError, n as CapxulSigner, v as CachedJwt } from "../signer-DEMJbpJ2.mjs";
2
- import { AuthSession } from "@capxul/types";
3
- import { Effect, Layer } from "effect";
1
+ import { s as AuthSession } from "../index-D0SflScT.mjs";
2
+ import { _ as AuthCachePortTag, g as AuthCachePort, h as AuthCacheError, n as CapxulSigner, v as CachedJwt } from "../signer-Cp2G98ZK.mjs";
4
3
  import { Hex } from "viem";
4
+ import { Effect, Layer } from "effect";
5
5
  import * as PlatformFileSystem from "@effect/platform/FileSystem";
6
6
  import * as PlatformPath from "@effect/platform/Path";
7
7
 
@@ -1,5 +1,4 @@
1
- import { a as AuthCacheError, i as parseCachedJwt, n as BrowserAuthCacheAdapter, o as AuthCachePortTag, r as parseAuthSession, t as InMemoryAuthCacheAdapter } from "../InMemoryAuthCacheAdapter-EBzKEJmQ.mjs";
2
- import { toAddress } from "@capxul/types";
1
+ import { a as AuthCacheError, f as toAddress, i as parseCachedJwt, n as BrowserAuthCacheAdapter, o as AuthCachePortTag, r as parseAuthSession, t as InMemoryAuthCacheAdapter } from "../InMemoryAuthCacheAdapter-v5W-XB5M.mjs";
3
2
  import { Effect, Layer } from "effect";
4
3
  import { privateKeyToAccount } from "viem/accounts";
5
4
  import * as os from "node:os";
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/adapters/auth-cache/FileSystemAuthCacheAdapter.ts","../../src/node/index.ts"],"sourcesContent":["import type * as PlatformError from \"@effect/platform/Error\";\nimport * as PlatformFileSystem from \"@effect/platform/FileSystem\";\nimport * as PlatformPath from \"@effect/platform/Path\";\nimport * as NodeFileSystem from \"@effect/platform-node/NodeFileSystem\";\nimport * as NodePath from \"@effect/platform-node/NodePath\";\nimport { Effect, Layer } 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\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(this, function* () {\n const cur = yield* this.read();\n yield* this.write({ session, jwt: cur.jwt });\n }),\n );\n this.clearSession = this.run(\n \"clearSession\",\n Effect.gen(this, function* () {\n const cur = yield* this.read();\n yield* this.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(this, function* () {\n const cur = yield* this.read();\n yield* this.write({ session: cur.session, jwt });\n }),\n );\n this.clearJwt = this.run(\n \"clearJwt\",\n Effect.gen(this, function* () {\n const cur = yield* this.read();\n yield* this.write({ session: cur.session, jwt: null });\n }),\n );\n }\n\n private read(): Effect.Effect<FilePayload, PlatformError.PlatformError, FileSystemRuntime> {\n return Effect.gen(this, function* () {\n const fs = yield* PlatformFileSystem.FileSystem;\n const exists = yield* fs.exists(this.path);\n if (!exists) return emptyPayload();\n const raw = yield* fs.readFileString(this.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 return Effect.gen(this, function* () {\n const fs = yield* PlatformFileSystem.FileSystem;\n const path = yield* PlatformPath.Path;\n const dir = path.dirname(this.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(this.path, JSON.stringify(payload), { mode: 0o600 });\n yield* fs.chmod(this.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 \"../client/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":";;;;;;;;;;;AAuBA,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;EAEf,KAAK,aAAa,KAAK,IACrB,cACA,KAAK,KAAK,EAAE,KAAK,OAAO,KAAK,YAAY,QAAQ,OAAO,CAAC,CAC3D;EACA,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AiB,KAAA,GACrC,OAAO,IAAI,wBAAwB,UAAU,OAAO,YAAY;CAElE,IAAI,UAAU,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
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/adapters/auth-cache/FileSystemAuthCacheAdapter.ts","../../src/node/index.ts"],"sourcesContent":["import type * as PlatformError from \"@effect/platform/Error\";\nimport * as PlatformFileSystem from \"@effect/platform/FileSystem\";\nimport * as PlatformPath from \"@effect/platform/Path\";\nimport * as NodeFileSystem from \"@effect/platform-node/NodeFileSystem\";\nimport * as NodePath from \"@effect/platform-node/NodePath\";\nimport { Effect, Layer } 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\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(this, function* () {\n const cur = yield* this.read();\n yield* this.write({ session, jwt: cur.jwt });\n }),\n );\n this.clearSession = this.run(\n \"clearSession\",\n Effect.gen(this, function* () {\n const cur = yield* this.read();\n yield* this.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(this, function* () {\n const cur = yield* this.read();\n yield* this.write({ session: cur.session, jwt });\n }),\n );\n this.clearJwt = this.run(\n \"clearJwt\",\n Effect.gen(this, function* () {\n const cur = yield* this.read();\n yield* this.write({ session: cur.session, jwt: null });\n }),\n );\n }\n\n private read(): Effect.Effect<FilePayload, PlatformError.PlatformError, FileSystemRuntime> {\n return Effect.gen(this, function* () {\n const fs = yield* PlatformFileSystem.FileSystem;\n const exists = yield* fs.exists(this.path);\n if (!exists) return emptyPayload();\n const raw = yield* fs.readFileString(this.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 return Effect.gen(this, function* () {\n const fs = yield* PlatformFileSystem.FileSystem;\n const path = yield* PlatformPath.Path;\n const dir = path.dirname(this.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(this.path, JSON.stringify(payload), { mode: 0o600 });\n yield* fs.chmod(this.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 \"../client/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":";;;;;;;;;;AAuBA,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;EAEf,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,MAAM,aAAa;GAC5B,MAAM,MAAM,OAAO,KAAK,KAAK;GAC7B,OAAO,KAAK,MAAM;IAAE;IAAS,KAAK,IAAI;GAAI,CAAC;EAC7C,CAAC,CACH;EACF,KAAK,eAAe,KAAK,IACvB,gBACA,OAAO,IAAI,MAAM,aAAa;GAC5B,MAAM,MAAM,OAAO,KAAK,KAAK;GAC7B,OAAO,KAAK,MAAM;IAAE,SAAS;IAAM,KAAK,IAAI;GAAI,CAAC;EACnD,CAAC,CACH;EACA,KAAK,SAAS,KAAK,IAAI,UAAU,KAAK,KAAK,EAAE,KAAK,OAAO,K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,SAAS,4BAA4B,sBAAmD;CACtF,IAAI;EACF,OAAO,KAAK,qBAAqB,GAAG,WAAW,UAAU,iBAAiB;CAC5E,QAAQ;EACN,OAAO;CACT;AACF"}
@@ -1,2 +1,2 @@
1
- import { a as SafeDeploymentEvidence, c as SafeDeploymentPortTag, i as SafeDeploymentError, l as safeDeploymentErrorFromCapxul, n as SafeDeploymentConfig, o as SafeDeploymentInput, r as SafeDeploymentDeployedQuery, s as SafeDeploymentPort, t as PreparedSafeAccount } from "../safe-deployment-DMGB1kEL.mjs";
1
+ import { a as SafeDeploymentEvidence, c as SafeDeploymentPortTag, i as SafeDeploymentError, l as safeDeploymentErrorFromCapxul, n as SafeDeploymentConfig, o as SafeDeploymentInput, r as SafeDeploymentDeployedQuery, s as SafeDeploymentPort, t as PreparedSafeAccount } from "../safe-deployment-ToMPzqwk.mjs";
2
2
  export { PreparedSafeAccount, SafeDeploymentConfig, SafeDeploymentDeployedQuery, SafeDeploymentError, SafeDeploymentEvidence, SafeDeploymentInput, SafeDeploymentPort, SafeDeploymentPortTag, safeDeploymentErrorFromCapxul };
@@ -1,7 +1,6 @@
1
- import { CapxulError, CapxulErrorCode, CapxulErrorDetails } from "@capxul/config";
2
- import { Address, BlockNumber, ChainId, DurationMs, Email, TxHash } from "@capxul/types";
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-D0SflScT.mjs";
2
+ import { Account, Hex } from "viem";
3
3
  import { Context, Effect } from "effect";
4
- import { Account as Account$1 } from "viem";
5
4
 
6
5
  //#region src/ports/safe-deployment.d.ts
7
6
  /**
@@ -56,7 +55,7 @@ type SafeDeploymentEvidence = {
56
55
  readonly blockNumber?: BlockNumber;
57
56
  };
58
57
  type SafeDeploymentInput = {
59
- readonly signer: Account$1;
58
+ readonly signer: Account;
60
59
  readonly email: Email;
61
60
  readonly config: SafeDeploymentConfig;
62
61
  };
@@ -134,4 +133,4 @@ declare const SafeDeploymentPortTag_base: Context.TagClass<SafeDeploymentPortTag
134
133
  declare class SafeDeploymentPortTag extends SafeDeploymentPortTag_base {}
135
134
  //#endregion
136
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 };
137
- //# sourceMappingURL=safe-deployment-DMGB1kEL.d.mts.map
136
+ //# sourceMappingURL=safe-deployment-ToMPzqwk.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-deployment-ToMPzqwk.d.mts","names":[],"sources":["../src/ports/safe-deployment.ts"],"mappings":";;;;;;AAaA;;;;;;KAAY,oBAAA;EAAA,SACD,OAAA,EAAS,OAAA;EAAA,SACT,MAAA;EAAA,SACA,WAAA;EAAA,SACA,gBAAA,GAAmB,UAAU;AAAA;AAOxC;;;;AAAA,KAAY,mBAAA;EAAA,SACD,OAAA,EAAS,OAAA;EAAA,SACT,aAAA,EAAe,OAAA;EAAA,SACf,WAAA,EAAa,OAAA;AAAA;;;;;;;AAAO;AAwB/B;;;;;;;;;;;;;;KAAY,sBAAA;EAAA,SACD,OAAA,EAAS,OAAA;EAAA,SACT,aAAA,EAAe,OAAA;EAAA,SACf,WAAA,EAAa,OAAA;EAAA,SACb,MAAA,GAAS,MAAA;EAAA,SACT,UAAA,GAAa,MAAA;EAAA,SACb,WAAA,GAAc,WAAA;AAAA;AAAA,KAGb,mBAAA;EAAA,SACD,MAAA,EAAQ,OAAA;EAAA,SACR,KAAA,EAAO,KAAA;EAAA,SACP,MAAA,EAAQ,oBAAA;AAAA;AAAA,KAGP,2BAAA;EAAA,SACD,WAAA,EAAa,OAAA;EAAA,SACb,MAAA,EAAQ,oBAAoB;AAAA;AAAA,cACrC,wBAAA;;;;;;;;cAOW,mBAAA,SAA4B,wBAAA;EAAA,SAC9B,SAAA;EAAA,SACA,UAAA,EAAY,eAAA;EAAA,SACZ,WAAA,EAAa,WAAA;EAAA,SACb,KAAA;EAAA,SACA,OAAA,GAAU,kBAAA;AAAA;;;;AAbkB;AACrC;;;;;;;;;;;;iBA+Bc,6BAAA,CACd,SAAA,UACA,KAAA,EAAO,WAAA,EACP,KAAA,aACC,mBAAmB;;;;;;;;;;;;;;UAuBL,kBAAA;;;AAnDjB;;EAwDE,OAAA,CACE,KAAA,EAAO,mBAAA,GACN,MAAA,CAAO,MAAA,CAAO,mBAAA,EAAqB,mBAAA;EAxDjB;;;;;EA+DrB,MAAA,CACE,KAAA,EAAO,mBAAA,GACN,MAAA,CAAO,MAAA,CAAO,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,7 +1,6 @@
1
- import { CapxulError } from "@capxul/errors";
2
- import { Address, AuthSession, EpochSeconds, JwtToken, Profile, SmartAccount } from "@capxul/types";
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-D0SflScT.mjs";
2
+ import { Account, Hex } from "viem";
3
3
  import { Context, Effect } from "effect";
4
- import { Account as Account$1, Hex } from "viem";
5
4
 
6
5
  //#region src/ports/auth-cache.d.ts
7
6
  /**
@@ -52,8 +51,8 @@ declare class AuthCachePortTag extends AuthCachePortTag_base {}
52
51
  //#endregion
53
52
  //#region src/client/types.d.ts
54
53
  type Session = AuthSession;
55
- type Profile$1 = Profile;
56
- type SmartAccount$1 = SmartAccount;
54
+ type Profile = Profile$1;
55
+ type SmartAccount = SmartAccount$1;
57
56
  /**
58
57
  * Result-shape returned by every method on `CapxulClient`. Mirrors the
59
58
  * existing per-port `Result` aliases; centralized here so consumers have
@@ -95,7 +94,7 @@ interface AccountProvider {
95
94
  * Custom providers MUST honor this contract.
96
95
  */
97
96
  getAddress(): Promise<CapxulResult<Address>>;
98
- getDeployAccount(): Promise<CapxulResult<Account$1>>;
97
+ getDeployAccount(): Promise<CapxulResult<Account>>;
99
98
  }
100
99
  interface Eip1193Provider {
101
100
  request(args: {
@@ -144,5 +143,5 @@ interface Eip1193RequestProvider {
144
143
  */
145
144
  declare function injectedWalletSigner(provider: Eip1193RequestProvider): CapxulSigner;
146
145
  //#endregion
147
- export { AuthCachePortTag as _, AccountProvider as a, Eip1193Provider as c, CapxulResult as d, Profile$1 as f, AuthCachePort as g, AuthCacheError as h, injectedWalletSigner as i, eip1193AccountProvider as l, SmartAccount$1 as m, CapxulSigner as n, AccountProviderSource as o, Session as p, Eip1193RequestProvider as r, AccountRequirement as s, CapxulDigestSigner as t, localPrivateKeyAccountProvider as u, CachedJwt as v };
148
- //# sourceMappingURL=signer-DEMJbpJ2.d.mts.map
146
+ export { AuthCachePortTag as _, AccountProvider as a, Eip1193Provider as c, CapxulResult as d, Profile as f, AuthCachePort as g, AuthCacheError as h, injectedWalletSigner as i, eip1193AccountProvider as l, SmartAccount as m, CapxulSigner as n, AccountProviderSource as o, Session as p, Eip1193RequestProvider as r, AccountRequirement as s, CapxulDigestSigner as t, localPrivateKeyAccountProvider as u, CachedJwt as v };
147
+ //# sourceMappingURL=signer-Cp2G98ZK.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer-Cp2G98ZK.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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A,CAAQ,GAAA;AAAA;AAAA,UAGpB,YAAA,SAAqB,kBAAA;EHjB+B;;;;EAAA,SGsB1D,MAAA,EAAQ,qBAAA;EHdgC;EGgBjD,UAAA,IAAc,OAAA,CAAQ,OAAA;AAAA;;UAIP,sBAAA;EACf,OAAA,CAAQ,IAAA;IAAA,SACG,MAAA;IAAA,SACA,MAAA;EAAA,IACP,OAAO;AAAA;;;;;;;;iBAUG,oBAAA,CAAqB,QAAA,EAAU,sBAAA,GAAyB,YAAY"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capxul/sdk",
3
- "version": "1.0.0-alpha.12",
3
+ "version": "1.0.0-alpha.13",
4
4
  "files": [
5
5
  "dist",
6
6
  "package.json",
@@ -33,12 +33,7 @@
33
33
  "@openfort/openfort-js": "^1.3.6",
34
34
  "convex": "^1.39.1",
35
35
  "effect": "^3.21.2",
36
- "viem": "^2.53.1",
37
- "@capxul/config": "0.1.0-alpha.1",
38
- "@capxul/observability": "0.1.0-alpha.0",
39
- "@capxul/types": "0.1.0-alpha.0",
40
- "@capxul/wire": "0.1.0-alpha.1",
41
- "@capxul/errors": "0.0.0"
36
+ "viem": "^2.53.1"
42
37
  },
43
38
  "devDependencies": {
44
39
  "@effect/vitest": "^0.29.0",
@@ -46,7 +41,12 @@
46
41
  "fast-check": "^3.23.2",
47
42
  "permissionless": "0.3.4",
48
43
  "typescript": "5.9.2",
49
- "vitest": "npm:@voidzero-dev/vite-plus-test@0.1.23"
44
+ "vitest": "npm:@voidzero-dev/vite-plus-test@0.1.23",
45
+ "@capxul/errors": "0.0.0",
46
+ "@capxul/observability": "0.1.0-alpha.0",
47
+ "@capxul/types": "0.1.0-alpha.0",
48
+ "@capxul/config": "0.1.0-alpha.1",
49
+ "@capxul/wire": "0.1.0-alpha.1"
50
50
  },
51
51
  "_permissionlessPinReason": "permissionless.toSafeSmartAccount is pinned to 0.3.4 for live Safe deployment E2E. Counterfactual address fixtures captured 2026-05-17 in packages/backend/convex/_shared/__tests__/counterfactual.test.ts and packages/config/tests/safe.test.ts must be re-verified before upgrading.",
52
52
  "scripts": {
@@ -1,113 +0,0 @@
1
- import { toAuthUserId, toEmail, toEpochMs, toEpochSeconds, toJwtToken, toSessionToken } from "@capxul/types";
2
- import { Context, Data, Effect, Layer } from "effect";
3
- //#region src/ports/auth-cache.ts
4
- var AuthCacheError = class extends Data.TaggedError("AuthCacheError") {};
5
- var AuthCachePortTag = class extends Context.Tag("@capxul/sdk/ports/AuthCachePort")() {};
6
- //#endregion
7
- //#region src/adapters/auth-cache/serialization.ts
8
- function parseAuthSession(raw) {
9
- if (typeof raw !== "object" || raw === null) return null;
10
- const candidate = raw;
11
- try {
12
- return {
13
- authUserId: toAuthUserId(candidate.authUserId),
14
- email: toEmail(candidate.email),
15
- token: toSessionToken(candidate.token),
16
- expiresAt: toEpochMs(candidate.expiresAt)
17
- };
18
- } catch {
19
- return null;
20
- }
21
- }
22
- function parseCachedJwt(raw) {
23
- if (typeof raw !== "object" || raw === null) return null;
24
- const candidate = raw;
25
- try {
26
- return {
27
- token: toJwtToken(candidate.token),
28
- expEpochSeconds: toEpochSeconds(candidate.expEpochSeconds)
29
- };
30
- } catch {
31
- return null;
32
- }
33
- }
34
- //#endregion
35
- //#region src/adapters/auth-cache/BrowserAuthCacheAdapter.ts
36
- const SESSION_KEY = "capxul.session";
37
- const JWT_KEY = "capxul.jwt";
38
- var BrowserAuthCacheAdapter = class {
39
- storage;
40
- constructor(storage) {
41
- this.storage = storage;
42
- }
43
- getSession = authCacheTry("getSession", () => {
44
- const raw = this.storage.getItem(SESSION_KEY);
45
- if (raw === null) return null;
46
- try {
47
- return parseAuthSession(JSON.parse(raw));
48
- } catch {
49
- return null;
50
- }
51
- });
52
- setSession = (session) => authCacheTry("setSession", () => {
53
- this.storage.setItem(SESSION_KEY, JSON.stringify(session));
54
- });
55
- clearSession = authCacheTry("clearSession", () => {
56
- this.storage.removeItem(SESSION_KEY);
57
- });
58
- getJwt = authCacheTry("getJwt", () => {
59
- const raw = this.storage.getItem(JWT_KEY);
60
- if (raw === null) return null;
61
- try {
62
- return parseCachedJwt(JSON.parse(raw));
63
- } catch {
64
- return null;
65
- }
66
- });
67
- setJwt = (jwt) => authCacheTry("setJwt", () => {
68
- this.storage.setItem(JWT_KEY, JSON.stringify(jwt));
69
- });
70
- clearJwt = authCacheTry("clearJwt", () => {
71
- this.storage.removeItem(JWT_KEY);
72
- });
73
- };
74
- function toAuthCacheError(operation, cause) {
75
- return new AuthCacheError({
76
- operation,
77
- cause
78
- });
79
- }
80
- function authCacheTry(operation, run) {
81
- return Effect.try({
82
- try: run,
83
- catch: (cause) => toAuthCacheError(operation, cause)
84
- });
85
- }
86
- //#endregion
87
- //#region src/adapters/auth-cache/InMemoryAuthCacheAdapter.ts
88
- var InMemoryAuthCacheAdapter = class {
89
- session = null;
90
- jwt = null;
91
- getSession = Effect.sync(() => this.session);
92
- setSession = (session) => Effect.sync(() => {
93
- this.session = session;
94
- });
95
- clearSession = Effect.sync(() => {
96
- this.session = null;
97
- });
98
- getJwt = Effect.sync(() => this.jwt);
99
- setJwt = (jwt) => Effect.sync(() => {
100
- this.jwt = jwt;
101
- });
102
- clearJwt = Effect.sync(() => {
103
- this.jwt = null;
104
- });
105
- };
106
- Layer.effect(AuthCachePortTag, Effect.sync(() => new InMemoryAuthCacheAdapter()).pipe(Effect.mapError((cause) => new AuthCacheError({
107
- operation: "initialize",
108
- cause
109
- }))));
110
- //#endregion
111
- export { AuthCacheError as a, parseCachedJwt as i, BrowserAuthCacheAdapter as n, AuthCachePortTag as o, parseAuthSession as r, InMemoryAuthCacheAdapter as t };
112
-
113
- //# sourceMappingURL=InMemoryAuthCacheAdapter-EBzKEJmQ.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InMemoryAuthCacheAdapter-EBzKEJmQ.mjs","names":[],"sources":["../src/ports/auth-cache.ts","../src/adapters/auth-cache/serialization.ts","../src/adapters/auth-cache/BrowserAuthCacheAdapter.ts","../src/adapters/auth-cache/InMemoryAuthCacheAdapter.ts"],"sourcesContent":["import { Context, Data, Effect } from \"effect\";\nimport type { AuthSession, EpochSeconds, JwtToken } from \"@capxul/types\";\n\n/**\n * AuthCachePort (TA4) — replaces `SessionStoragePort` in the rebuild slice's\n * consumer-facing wiring. Stores the user-snapshot Session AND the cached\n * Convex JWT (W7 bridge endpoint). The two slots are independent so a session\n * refresh doesn't invalidate the JWT and vice versa.\n *\n * Three adapters (TA7):\n * - `BrowserAuthCacheAdapter` — backed by `localStorage`\n * - `FileSystemAuthCacheAdapter` — mode-0600 JSON file in `~/.config/capxul/`\n * - `InMemoryAuthCacheAdapter` — for tests\n *\n * `SessionStoragePort` was retired by the Stage 4 rebuild; session and JWT\n * persistence now share this cache boundary.\n */\nexport interface AuthCachePort {\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\n /**\n * JWT cache for the `/api/auth/convex/token` bridge endpoint (W7).\n * Stored separately from the session so a session refresh doesn't\n * invalidate cached JWT.\n */\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\n/**\n * Cached Convex JWT shape (TA4). `expEpochSeconds` is decoded from the JWT's\n * `exp` claim at fetch time so the `tokenProvider` cache eviction logic can\n * proactively refresh at `exp - 30s` per TA3.\n */\nexport interface CachedJwt {\n readonly token: JwtToken;\n readonly expEpochSeconds: EpochSeconds;\n}\n\nexport class AuthCacheError extends Data.TaggedError(\"AuthCacheError\")<{\n readonly operation: string;\n readonly cause: unknown;\n}> {}\n\nexport class AuthCachePortTag extends Context.Tag(\"@capxul/sdk/ports/AuthCachePort\")<\n AuthCachePortTag,\n AuthCachePort\n>() {}\n","import {\n toAuthUserId,\n toEmail,\n toEpochMs,\n toEpochSeconds,\n toJwtToken,\n toSessionToken,\n type AuthSession,\n} from \"@capxul/types\";\n\nimport type { CachedJwt } from \"../../ports/auth-cache\";\n\nexport function parseAuthSession(raw: unknown): AuthSession | null {\n if (typeof raw !== \"object\" || raw === null) return null;\n const candidate = raw as {\n readonly authUserId?: unknown;\n readonly email?: unknown;\n readonly token?: unknown;\n readonly expiresAt?: unknown;\n };\n\n try {\n return {\n authUserId: toAuthUserId(candidate.authUserId),\n email: toEmail(candidate.email),\n token: toSessionToken(candidate.token),\n expiresAt: toEpochMs(candidate.expiresAt),\n };\n } catch {\n return null;\n }\n}\n\nexport function parseCachedJwt(raw: unknown): CachedJwt | null {\n if (typeof raw !== \"object\" || raw === null) return null;\n const candidate = raw as {\n readonly token?: unknown;\n readonly expEpochSeconds?: unknown;\n };\n\n try {\n return {\n token: toJwtToken(candidate.token),\n expEpochSeconds: toEpochSeconds(candidate.expEpochSeconds),\n };\n } catch {\n return null;\n }\n}\n","import { Effect, Layer } 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\nexport interface BrowserStorageShape {\n getItem(key: string): string | null;\n setItem(key: string, value: string): void;\n removeItem(key: string): void;\n}\n\nconst SESSION_KEY = \"capxul.session\";\nconst JWT_KEY = \"capxul.jwt\";\n\nexport class BrowserAuthCacheAdapter implements AuthCachePort {\n private readonly storage: BrowserStorageShape;\n\n constructor(storage: BrowserStorageShape) {\n this.storage = storage;\n }\n\n readonly getSession = authCacheTry(\"getSession\", () => {\n const raw = this.storage.getItem(SESSION_KEY);\n if (raw === null) return null;\n try {\n return parseAuthSession(JSON.parse(raw));\n } catch {\n return null;\n }\n });\n\n readonly setSession = (session: AuthSession) =>\n authCacheTry(\"setSession\", () => {\n this.storage.setItem(SESSION_KEY, JSON.stringify(session));\n });\n\n readonly clearSession = authCacheTry(\"clearSession\", () => {\n this.storage.removeItem(SESSION_KEY);\n });\n\n readonly getJwt = authCacheTry(\"getJwt\", () => {\n const raw = this.storage.getItem(JWT_KEY);\n if (raw === null) return null;\n try {\n return parseCachedJwt(JSON.parse(raw));\n } catch {\n return null;\n }\n });\n\n readonly setJwt = (jwt: CachedJwt) =>\n authCacheTry(\"setJwt\", () => {\n this.storage.setItem(JWT_KEY, JSON.stringify(jwt));\n });\n\n readonly clearJwt = authCacheTry(\"clearJwt\", () => {\n this.storage.removeItem(JWT_KEY);\n });\n}\n\nexport function BrowserAuthCacheLayer(input: {\n readonly storage: BrowserStorageShape;\n}): Layer.Layer<AuthCachePortTag, AuthCacheError> {\n return Layer.effect(\n AuthCachePortTag,\n Effect.sync(() => new BrowserAuthCacheAdapter(input.storage)).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\nfunction authCacheTry<T>(operation: string, run: () => T): Effect.Effect<T, AuthCacheError> {\n return Effect.try({\n try: run,\n catch: (cause) => toAuthCacheError(operation, cause),\n });\n}\n","import { Effect, Layer } 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\";\n\nexport class InMemoryAuthCacheAdapter implements AuthCachePort {\n private session: AuthSession | null = null;\n private jwt: CachedJwt | null = null;\n\n readonly getSession = Effect.sync(() => this.session);\n\n readonly setSession = (session: AuthSession) =>\n Effect.sync(() => {\n this.session = session;\n });\n\n readonly clearSession = Effect.sync(() => {\n this.session = null;\n });\n\n readonly getJwt = Effect.sync(() => this.jwt);\n\n readonly setJwt = (jwt: CachedJwt) =>\n Effect.sync(() => {\n this.jwt = jwt;\n });\n\n readonly clearJwt = Effect.sync(() => {\n this.jwt = null;\n });\n}\n\nexport const InMemoryAuthCacheLayer = Layer.effect(\n AuthCachePortTag,\n Effect.sync(() => new InMemoryAuthCacheAdapter()).pipe(\n Effect.mapError((cause) => new AuthCacheError({ operation: \"initialize\", cause })),\n ),\n);\n"],"mappings":";;;AA0CA,IAAa,iBAAb,cAAoC,KAAK,YAAY,gBAAgB,EAGlE,CAAC;AAEJ,IAAa,mBAAb,cAAsC,QAAQ,IAAI,iCAAiC,EAGjF,EAAE,CAAC;;;ACtCL,SAAgB,iBAAiB,KAAkC;CACjE,IAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM,OAAO;CACpD,MAAM,YAAY;CAOlB,IAAI;EACF,OAAO;GACL,YAAY,aAAa,UAAU,UAAU;GAC7C,OAAO,QAAQ,UAAU,KAAK;GAC9B,OAAO,eAAe,UAAU,KAAK;GACrC,WAAW,UAAU,UAAU,SAAS;EAC1C;CACF,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAgB,eAAe,KAAgC;CAC7D,IAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM,OAAO;CACpD,MAAM,YAAY;CAKlB,IAAI;EACF,OAAO;GACL,OAAO,WAAW,UAAU,KAAK;GACjC,iBAAiB,eAAe,UAAU,eAAe;EAC3D;CACF,QAAQ;EACN,OAAO;CACT;AACF;;;AC/BA,MAAM,cAAc;AACpB,MAAM,UAAU;AAEhB,IAAa,0BAAb,MAA8D;CAC5D;CAEA,YAAY,SAA8B;EACxC,KAAK,UAAU;CACjB;CAEA,aAAsB,aAAa,oBAAoB;EACrD,MAAM,MAAM,KAAK,QAAQ,QAAQ,WAAW;EAC5C,IAAI,QAAQ,MAAM,OAAO;EACzB,IAAI;GACF,OAAO,iBAAiB,KAAK,MAAM,GAAG,CAAC;EACzC,QAAQ;GACN,OAAO;EACT;CACF,CAAC;CAED,cAAuB,YACrB,aAAa,oBAAoB;EAC/B,KAAK,QAAQ,QAAQ,aAAa,KAAK,UAAU,OAAO,CAAC;CAC3D,CAAC;CAEH,eAAw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AAwB,mBAAA;EAnEF;;;;;;;EA4EvC,UAAA,CACE,KAAA,EAAO,2BAAA,GACN,MAAA,CAAO,MAAA,UAAgB,mBAAA;AAAA;AAAA,cAC3B,0BAAA;cAEY,qBAAA,SAA8B,0BAGxC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"signer-DEMJbpJ2.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;EAQpB;;;;;EAAA,SADd,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;;;KChCS,OAAA,GAAU,WAAW;AAAA,KACrB,SAAA,GAAU,OAAY;AAAA,KACtB,cAAA,GAAe,YAAiB;;ADH5C;;;;KCUY,YAAA;EAAA,SACG,EAAA;EAAA,SAAmB,KAAA,EAAO,CAAA;AAAA;EAAA,SAC1B,EAAA;EAAA,SAAoB,KAAA,EAAO,WAAW;AAAA;;;KCtBzC,qBAAA;AAAA,KAEA,kBAA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