@capxul/sdk 1.0.0-alpha.11 → 1.0.0-alpha.12
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/dist/InMemoryAuthCacheAdapter-EBzKEJmQ.mjs +113 -0
- package/dist/InMemoryAuthCacheAdapter-EBzKEJmQ.mjs.map +1 -0
- package/dist/index.d.mts +335 -459
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +583 -1467
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.d.mts +3 -3
- package/dist/node/index.mjs +2 -1
- package/dist/node/index.mjs.map +1 -1
- package/dist/ports/safe-deployment.d.mts +1 -1
- package/dist/{safe-deployment-D3k9yndM.d.mts → safe-deployment-DMGB1kEL.d.mts} +5 -4
- package/dist/safe-deployment-DMGB1kEL.d.mts.map +1 -0
- package/dist/{signer-D9fUJp8o.d.mts → signer-DEMJbpJ2.d.mts} +8 -7
- package/dist/signer-DEMJbpJ2.d.mts.map +1 -0
- package/package.json +8 -8
- package/dist/InMemoryAuthCacheAdapter-v5W-XB5M.mjs +0 -457
- package/dist/InMemoryAuthCacheAdapter-v5W-XB5M.mjs.map +0 -1
- package/dist/index-CTXgQ_xR.d.mts +0 -158
- package/dist/index-CTXgQ_xR.d.mts.map +0 -1
- package/dist/safe-deployment-D3k9yndM.d.mts.map +0 -1
- package/dist/signer-D9fUJp8o.d.mts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,181 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { n as BrowserAuthCacheAdapter, o as AuthCachePortTag, t as InMemoryAuthCacheAdapter } from "./InMemoryAuthCacheAdapter-EBzKEJmQ.mjs";
|
|
2
|
+
import { CapxulError, Errors, isCapxulError, isCapxulError as isCapxulError$1 } from "@capxul/errors";
|
|
3
|
+
import { CapxulError as CapxulError$2, Errors as Errors$1, USDX_CURRENCY, USDX_DECIMALS, compileOrgRoleDefinitions, decodeConvexError, isCapxulError as isCapxulError$2, normalizeBindingEmail, orgRoleKeyForLabel, orgRoleTemplateDefinitions } from "@capxul/config";
|
|
4
|
+
import { toAccountId, toAddress, toAllowedOrigin, toAnonymousDistinctId, toAppId, toAuthUserId, toChainId, toCountryCode, toCurrencyCode, toDurationMs, toEmail, toEpochMs, toEpochSeconds, toJwtToken, toKycTier, toOrgId, toPublishableKey, toPublishableKeyId, toRoleKey, toSessionToken, toSubAccountId } from "@capxul/types";
|
|
3
5
|
import { Context, Data, Deferred, Duration, Effect, Either, Exit, Layer, Ref, Request, Scope } from "effect";
|
|
4
6
|
import { getFunctionName, makeFunctionReference } from "convex/server";
|
|
5
7
|
import { privateKeyToAccount } from "viem/accounts";
|
|
8
|
+
import { formatUnits, keccak256, parseUnits, recoverAddress, stringToHex } from "viem";
|
|
6
9
|
import { Schema, TreeFormatter } from "@effect/schema";
|
|
10
|
+
import { BootstrapEnvelope } from "@capxul/wire";
|
|
7
11
|
import { ConvexClient } from "convex/browser";
|
|
12
|
+
import { redactTelemetryProps } from "@capxul/observability";
|
|
8
13
|
import { AccountTypeEnum, ChainTypeEnum, EmbeddedState, Openfort, RecoveryMethod, ThirdPartyOAuthProvider } from "@openfort/openfort-js";
|
|
9
14
|
import { Machine } from "@effect/experimental";
|
|
10
|
-
//#region ../config/src/tokens.ts
|
|
11
|
-
/** `TestUSDC` ("USDX") — Base Sepolia, 6 decimals, open `mint`. (Canon §1.) */
|
|
12
|
-
const USDX_ADDRESS_BASE_SEPOLIA = "0xf09fcbb6df9f8f918e58f9c8ab15a76ade862b77";
|
|
13
|
-
USDX_ADDRESS_BASE_SEPOLIA.toLowerCase();
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region ../config/src/safe.ts
|
|
16
|
-
const BASE_SEPOLIA_CHAIN_ID = 84532;
|
|
17
|
-
/**
|
|
18
|
-
* Normalize an email for use as a Capxul Safe salt input.
|
|
19
|
-
*
|
|
20
|
-
* Trims surrounding whitespace and lowercases the address so that
|
|
21
|
-
* `" User+Demo@Example.COM "` and `"user+demo@example.com"` derive
|
|
22
|
-
* the same `safeAddress`. This is the canonical normalization rule —
|
|
23
|
-
* any future change here would shift every existing user's Safe
|
|
24
|
-
* address, so the rule is pinned by the fixture matrix in
|
|
25
|
-
* `packages/config/tests/safe-address-conformance.test.ts`.
|
|
26
|
-
*
|
|
27
|
-
* @param email - The raw email address to normalize
|
|
28
|
-
* @returns The trimmed, lowercased email
|
|
29
|
-
*/
|
|
30
|
-
function normalizeSafeSaltEmail(email) {
|
|
31
|
-
return email.trim().toLowerCase();
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Normalize a raw email for binding id + Safe salt derivation.
|
|
35
|
-
* Delegates to {@link normalizeSafeSaltEmail} so binding resolution and
|
|
36
|
-
* `deriveCapxulSafeAddress` never drift apart.
|
|
37
|
-
*/
|
|
38
|
-
function normalizeBindingEmail(email) {
|
|
39
|
-
return normalizeSafeSaltEmail(email);
|
|
40
|
-
}
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region ../config/src/route.ts
|
|
43
|
-
/** USDX on Base Sepolia — the only settlement token in v1. */
|
|
44
|
-
const USDX_BASE_SEPOLIA_TOKEN = {
|
|
45
|
-
chainId: BASE_SEPOLIA_CHAIN_ID,
|
|
46
|
-
address: USDX_ADDRESS_BASE_SEPOLIA,
|
|
47
|
-
decimals: 6
|
|
48
|
-
};
|
|
49
|
-
USDX_BASE_SEPOLIA_TOKEN.chainId;
|
|
50
|
-
USDX_BASE_SEPOLIA_TOKEN.chainId;
|
|
51
|
-
//#endregion
|
|
52
|
-
//#region ../config/src/role-dsl.ts
|
|
53
|
-
const USD_DECIMALS = 6;
|
|
54
|
-
const USD_SCALE = 10n ** BigInt(USD_DECIMALS);
|
|
55
|
-
const USD_DISPLAY_RE = /^\d+(?:\.\d{1,6})?$/;
|
|
56
|
-
const USD_BASE_UNIT_RE = /^\d+$/;
|
|
57
|
-
const EXEC_TRANSACTION_WITH_ROLE = "zodiac.roles.execTransactionWithRole";
|
|
58
|
-
const ASSIGN_ROLES = "zodiac.roles.assignRoles";
|
|
59
|
-
const SCOPE_TARGET = "zodiac.roles.scopeTarget";
|
|
60
|
-
const OWNER_ROLE_LABEL = "Owner";
|
|
61
|
-
const MARKETING_SUB_ACCOUNT_ID = "subaccount_marketing";
|
|
62
|
-
const PAYROLL_SUB_ACCOUNT_ID = "subaccount_payroll";
|
|
63
|
-
function usd(value) {
|
|
64
|
-
return {
|
|
65
|
-
currency: "USD",
|
|
66
|
-
value: usdDisplayToBaseUnits(value),
|
|
67
|
-
decimals: USD_DECIMALS
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
function usdDisplayToBaseUnits(value) {
|
|
71
|
-
if (value.trim() !== value || !USD_DISPLAY_RE.test(value)) throw Errors.invalidInput("role.spend", "USD caps must be unsigned decimal strings with at most 6 fractional digits");
|
|
72
|
-
const parts = value.split(".");
|
|
73
|
-
const whole = parts[0] ?? "0";
|
|
74
|
-
const fraction = parts[1] ?? "";
|
|
75
|
-
return (BigInt(whole) * USD_SCALE + BigInt(fraction.padEnd(USD_DECIMALS, "0"))).toString();
|
|
76
|
-
}
|
|
77
|
-
function normalizeOrgRoleMoney(money, field) {
|
|
78
|
-
if (money.currency !== "USD" || money.decimals !== USD_DECIMALS || !USD_BASE_UNIT_RE.test(money.value)) throw Errors.invalidInput(field, `must be USD base units with ${USD_DECIMALS} decimals`);
|
|
79
|
-
return money;
|
|
80
|
-
}
|
|
81
|
-
function normalizeOrgRoleSpendCap(spend) {
|
|
82
|
-
if (spend === void 0) return void 0;
|
|
83
|
-
return {
|
|
84
|
-
...spend.perTx === void 0 ? {} : { perTx: normalizeOrgRoleMoney(spend.perTx, "roles.spend.perTx") },
|
|
85
|
-
...spend.perDay === void 0 ? {} : { perDay: normalizeOrgRoleMoney(spend.perDay, "roles.spend.perDay") },
|
|
86
|
-
...spend.toRecipients === void 0 ? {} : { toRecipients: spend.toRecipients }
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
function normalizeOrgRoleLabel(label) {
|
|
90
|
-
const normalized = label.trim().replace(/\s+/g, " ");
|
|
91
|
-
if (normalized.length === 0) throw Errors.invalidInput("role.label", "must be a non-empty role label");
|
|
92
|
-
return normalized;
|
|
93
|
-
}
|
|
94
|
-
function orgRoleKeyForLabel(label) {
|
|
95
|
-
return keccak256(toBytes(normalizeOrgRoleLabel(label).toLowerCase()));
|
|
96
|
-
}
|
|
97
|
-
function soloOrgRoleTemplate() {
|
|
98
|
-
return [{
|
|
99
|
-
label: "Owner",
|
|
100
|
-
subAccounts: { scope: "all" },
|
|
101
|
-
canManageMembers: true,
|
|
102
|
-
canManageRoles: true
|
|
103
|
-
}];
|
|
104
|
-
}
|
|
105
|
-
function startupOrgRoleTemplate() {
|
|
106
|
-
return [
|
|
107
|
-
...soloOrgRoleTemplate(),
|
|
108
|
-
{
|
|
109
|
-
label: "Finance Manager",
|
|
110
|
-
spend: {
|
|
111
|
-
perTx: usd("25000"),
|
|
112
|
-
perDay: usd("100000"),
|
|
113
|
-
toRecipients: "anyone"
|
|
114
|
-
},
|
|
115
|
-
subAccounts: { scope: [MARKETING_SUB_ACCOUNT_ID] }
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
label: "Team Lead",
|
|
119
|
-
spend: {
|
|
120
|
-
perTx: usd("5000"),
|
|
121
|
-
perDay: usd("15000"),
|
|
122
|
-
toRecipients: "anyone"
|
|
123
|
-
},
|
|
124
|
-
subAccounts: { scope: [PAYROLL_SUB_ACCOUNT_ID] }
|
|
125
|
-
}
|
|
126
|
-
];
|
|
127
|
-
}
|
|
128
|
-
function orgRoleTemplateDefinitions(template, customRoles = []) {
|
|
129
|
-
switch (template) {
|
|
130
|
-
case "Solo": return soloOrgRoleTemplate();
|
|
131
|
-
case "Startup": return startupOrgRoleTemplate();
|
|
132
|
-
case "Custom": return customRoles.length === 0 ? soloOrgRoleTemplate() : customRoles;
|
|
133
|
-
default: return template;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
function compileOrgRoleDefinitions(definitions) {
|
|
137
|
-
if (definitions.length === 0) throw Errors.invalidInput("roles", "must include at least one role");
|
|
138
|
-
const seen = /* @__PURE__ */ new Set();
|
|
139
|
-
const roles = definitions.map((definition) => {
|
|
140
|
-
const label = normalizeOrgRoleLabel(definition.label);
|
|
141
|
-
const roleKey = orgRoleKeyForLabel(label);
|
|
142
|
-
if (seen.has(roleKey)) throw Errors.invalidInput("roles", `duplicate role label: ${label}`);
|
|
143
|
-
seen.add(roleKey);
|
|
144
|
-
const spend = normalizeOrgRoleSpendCap(definition.spend);
|
|
145
|
-
const permissions = [];
|
|
146
|
-
if (spend !== void 0 || label === OWNER_ROLE_LABEL) permissions.push(EXEC_TRANSACTION_WITH_ROLE);
|
|
147
|
-
if (definition.canManageMembers === true) permissions.push(ASSIGN_ROLES);
|
|
148
|
-
if (definition.canManageRoles === true) permissions.push(SCOPE_TARGET);
|
|
149
|
-
return {
|
|
150
|
-
label,
|
|
151
|
-
roleKey,
|
|
152
|
-
definition: {
|
|
153
|
-
...definition,
|
|
154
|
-
label,
|
|
155
|
-
...spend === void 0 ? {} : { spend }
|
|
156
|
-
},
|
|
157
|
-
permissions,
|
|
158
|
-
allowance: spend ?? null
|
|
159
|
-
};
|
|
160
|
-
});
|
|
161
|
-
const manager = roles.find((role) => role.definition.canManageMembers === true);
|
|
162
|
-
if (manager === void 0) throw Errors.invalidInput("roles.canManageMembers", "at least one role must compile to the on-chain member-management permission");
|
|
163
|
-
return {
|
|
164
|
-
roles,
|
|
165
|
-
memberManagementRole: {
|
|
166
|
-
roleKey: manager.roleKey,
|
|
167
|
-
permission: ASSIGN_ROLES
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
padHex(stringToHex("FM_DAILY"), {
|
|
172
|
-
size: 32,
|
|
173
|
-
dir: "right"
|
|
174
|
-
}), padHex(stringToHex("TL_DAILY"), {
|
|
175
|
-
size: 32,
|
|
176
|
-
dir: "right"
|
|
177
|
-
});
|
|
178
|
-
//#endregion
|
|
179
15
|
//#region src/telemetry/stack-frame-parser.ts
|
|
180
16
|
/**
|
|
181
17
|
* Regex for V8/Chrome stack trace frame lines.
|
|
@@ -265,7 +101,7 @@ function isFailureMode(value) {
|
|
|
265
101
|
* unrecognised cause.
|
|
266
102
|
*/
|
|
267
103
|
function getFailureMode(error) {
|
|
268
|
-
if (!isCapxulError(error)) return void 0;
|
|
104
|
+
if (!isCapxulError$2(error)) return void 0;
|
|
269
105
|
const details = error.details;
|
|
270
106
|
if (details === void 0) return void 0;
|
|
271
107
|
return isFailureMode(details.failure_mode) ? details.failure_mode : void 0;
|
|
@@ -302,7 +138,7 @@ function resolveFailureMode(error, contextFailureMode) {
|
|
|
302
138
|
function captureException(telemetry, error, context) {
|
|
303
139
|
return Effect.catchAllDefect(Effect.sync(() => {
|
|
304
140
|
const exceptionList = buildExceptionList(error instanceof Error ? parseV8StackFrames(error) : []);
|
|
305
|
-
const capxulError = isCapxulError(error) ? error : null;
|
|
141
|
+
const capxulError = isCapxulError$2(error) ? error : null;
|
|
306
142
|
const props = {
|
|
307
143
|
capxul_error_code: capxulError?.code ?? context?.capxul_error_code ?? "UNKNOWN",
|
|
308
144
|
layer: capxulError?.layer ?? context?.layer,
|
|
@@ -409,7 +245,7 @@ const accountStatusProgram = Effect.gen(function* () {
|
|
|
409
245
|
};
|
|
410
246
|
const signerAddress = yield* Effect.tryPromise({
|
|
411
247
|
try: () => signer.getAddress(),
|
|
412
|
-
catch: (cause) => isCapxulError(cause) ? cause : Errors.providerError("signer", "getAddress", cause)
|
|
248
|
+
catch: (cause) => isCapxulError$2(cause) ? cause : Errors$1.providerError("signer", "getAddress", cause)
|
|
413
249
|
});
|
|
414
250
|
return {
|
|
415
251
|
status: "accountProviderReady",
|
|
@@ -1090,7 +926,7 @@ function refLabel(ref) {
|
|
|
1090
926
|
//#endregion
|
|
1091
927
|
//#region src/client/to-capxul-result.ts
|
|
1092
928
|
async function toCapxulResult(program, layer) {
|
|
1093
|
-
const result = await Effect.runPromise(program.pipe(Effect.provide(layer), Effect.catchAllDefect((defect) => Effect.fail(Errors.unknown(defect))), Effect.either));
|
|
929
|
+
const result = await Effect.runPromise(program.pipe(Effect.provide(layer), Effect.catchAllDefect((defect) => Effect.fail(Errors$1.unknown(defect))), Effect.either));
|
|
1094
930
|
if (Either.isLeft(result)) return {
|
|
1095
931
|
ok: false,
|
|
1096
932
|
error: result.left
|
|
@@ -1119,13 +955,13 @@ function makeAccountMethods(deps) {
|
|
|
1119
955
|
value: void 0
|
|
1120
956
|
};
|
|
1121
957
|
} catch (cause) {
|
|
1122
|
-
if (cause instanceof CapxulError) return {
|
|
958
|
+
if (cause instanceof CapxulError$2) return {
|
|
1123
959
|
ok: false,
|
|
1124
960
|
error: cause
|
|
1125
961
|
};
|
|
1126
962
|
return {
|
|
1127
963
|
ok: false,
|
|
1128
|
-
error: Errors.providerError("signer", "getAddress", cause)
|
|
964
|
+
error: Errors$1.providerError("signer", "getAddress", cause)
|
|
1129
965
|
};
|
|
1130
966
|
}
|
|
1131
967
|
};
|
|
@@ -1156,7 +992,7 @@ function makeAccountMethods(deps) {
|
|
|
1156
992
|
const session = await currentSession(deps.actor, deps.authCache);
|
|
1157
993
|
if (session === null) return {
|
|
1158
994
|
ok: false,
|
|
1159
|
-
error: Errors.notAuthenticated()
|
|
995
|
+
error: Errors$1.notAuthenticated()
|
|
1160
996
|
};
|
|
1161
997
|
const profileReady = await ensureIdentityProfile(session);
|
|
1162
998
|
if (!profileReady.ok) return {
|
|
@@ -1179,12 +1015,12 @@ function makeAccountMethods(deps) {
|
|
|
1179
1015
|
const session = await currentSession(deps.actor, deps.authCache);
|
|
1180
1016
|
if (session === null) return {
|
|
1181
1017
|
ok: false,
|
|
1182
|
-
error: Errors.notAuthenticated()
|
|
1018
|
+
error: Errors$1.notAuthenticated()
|
|
1183
1019
|
};
|
|
1184
1020
|
const signer = deps.signer;
|
|
1185
1021
|
if (signer === void 0) return {
|
|
1186
1022
|
ok: false,
|
|
1187
|
-
error: Errors.smartAccountMissing("deploySafe")
|
|
1023
|
+
error: Errors$1.smartAccountMissing("deploySafe")
|
|
1188
1024
|
};
|
|
1189
1025
|
const existing = await runPortEffect(deps.smartAccountPort.loadByAuthUserId(session.authUserId));
|
|
1190
1026
|
if (!existing.ok) return existing;
|
|
@@ -1257,7 +1093,7 @@ function makeAccountMethods(deps) {
|
|
|
1257
1093
|
let accountId;
|
|
1258
1094
|
if (status.value.status !== "notAuthenticated" && (phase.status === "ready" || isRequirementMet(status.value, requirement))) {
|
|
1259
1095
|
const accountReadPort = deps.accountReadPort;
|
|
1260
|
-
if (accountReadPort === void 0) return reportAndReturn(Errors.invalidInput("account", "accountReadPort is required to resolve ready lifecycle"));
|
|
1096
|
+
if (accountReadPort === void 0) return reportAndReturn(Errors$1.invalidInput("account", "accountReadPort is required to resolve ready lifecycle"));
|
|
1261
1097
|
const account = await runPortEffect(accountReadPort.readBalance({ chainId: toChainId(deps.chainId) }));
|
|
1262
1098
|
if (!account.ok) return reportAndReturn(account.error);
|
|
1263
1099
|
accountId = String(account.value.id);
|
|
@@ -1318,7 +1154,7 @@ async function runBackendClaim(input) {
|
|
|
1318
1154
|
} catch (cause) {
|
|
1319
1155
|
return {
|
|
1320
1156
|
ok: false,
|
|
1321
|
-
error: Errors.providerError("signer", "getAddress", cause)
|
|
1157
|
+
error: Errors$1.providerError("signer", "getAddress", cause)
|
|
1322
1158
|
};
|
|
1323
1159
|
}
|
|
1324
1160
|
const claimed = await runPortEffect(input.smartAccountPort.claim({
|
|
@@ -1367,7 +1203,7 @@ function eip1193AccountProvider(input) {
|
|
|
1367
1203
|
const first = firstAccount(await input.provider.request({ method: "eth_accounts" }));
|
|
1368
1204
|
if (first === null) return {
|
|
1369
1205
|
ok: false,
|
|
1370
|
-
error: Errors.smartAccountMissing("eip1193-account")
|
|
1206
|
+
error: Errors$1.smartAccountMissing("eip1193-account")
|
|
1371
1207
|
};
|
|
1372
1208
|
const address = toAddress(first);
|
|
1373
1209
|
cachedAddress = address;
|
|
@@ -1378,7 +1214,7 @@ function eip1193AccountProvider(input) {
|
|
|
1378
1214
|
} catch (err) {
|
|
1379
1215
|
return {
|
|
1380
1216
|
ok: false,
|
|
1381
|
-
error: Errors.providerError("eip1193", "eth_accounts", err)
|
|
1217
|
+
error: Errors$1.providerError("eip1193", "eth_accounts", err)
|
|
1382
1218
|
};
|
|
1383
1219
|
} finally {
|
|
1384
1220
|
inFlight = null;
|
|
@@ -1392,7 +1228,7 @@ function eip1193AccountProvider(input) {
|
|
|
1392
1228
|
async getDeployAccount() {
|
|
1393
1229
|
return {
|
|
1394
1230
|
ok: false,
|
|
1395
|
-
error: Errors.notImplemented("Eip1193AccountProvider", "getDeployAccount")
|
|
1231
|
+
error: Errors$1.notImplemented("Eip1193AccountProvider", "getDeployAccount")
|
|
1396
1232
|
};
|
|
1397
1233
|
}
|
|
1398
1234
|
};
|
|
@@ -1600,7 +1436,7 @@ async function recoverRawDigestSigner(input) {
|
|
|
1600
1436
|
}
|
|
1601
1437
|
//#endregion
|
|
1602
1438
|
//#region package.json
|
|
1603
|
-
var version = "1.0.0-alpha.
|
|
1439
|
+
var version = "1.0.0-alpha.12";
|
|
1604
1440
|
//#endregion
|
|
1605
1441
|
//#region src/ports/auth-client.ts
|
|
1606
1442
|
var AuthClientError = class extends Data.TaggedError("AuthClientError") {};
|
|
@@ -1687,18 +1523,18 @@ function mapBetterAuthError(operation, body) {
|
|
|
1687
1523
|
if (typeof body === "object" && body !== null) {
|
|
1688
1524
|
const errBody = body;
|
|
1689
1525
|
const code = typeof errBody.code === "string" ? errBody.code : "";
|
|
1690
|
-
if (code === "OTP_EXPIRED") return Errors.otpExpired();
|
|
1691
|
-
if (code === "INVALID_OTP") return Errors.invalidInput("otp", errBody.message ?? "invalid OTP");
|
|
1692
|
-
if (code === "VALIDATION_ERROR" || code === "INVALID_EMAIL") return Errors.invalidInput("email", errBody.message ?? "invalid email");
|
|
1526
|
+
if (code === "OTP_EXPIRED") return Errors$1.otpExpired();
|
|
1527
|
+
if (code === "INVALID_OTP") return Errors$1.invalidInput("otp", errBody.message ?? "invalid OTP");
|
|
1528
|
+
if (code === "VALIDATION_ERROR" || code === "INVALID_EMAIL") return Errors$1.invalidInput("email", errBody.message ?? "invalid email");
|
|
1693
1529
|
}
|
|
1694
|
-
return Errors.providerError("better-auth", operation, new Error(String(body)));
|
|
1530
|
+
return Errors$1.providerError("better-auth", operation, new Error(String(body)));
|
|
1695
1531
|
}
|
|
1696
1532
|
function isAbortError$1(err, signal) {
|
|
1697
1533
|
return signal?.aborted === true || err instanceof Error && err.name === "AbortError" || typeof DOMException !== "undefined" && err instanceof DOMException && err.name === "AbortError";
|
|
1698
1534
|
}
|
|
1699
1535
|
function mapFetchError$1(operation, err, signal) {
|
|
1700
|
-
if (isAbortError$1(err, signal)) return Errors.cancelled({ operation });
|
|
1701
|
-
return Errors.networkError(operation, err instanceof Error ? err : new Error(String(err)));
|
|
1536
|
+
if (isAbortError$1(err, signal)) return Errors$1.cancelled({ operation });
|
|
1537
|
+
return Errors$1.networkError(operation, err instanceof Error ? err : new Error(String(err)));
|
|
1702
1538
|
}
|
|
1703
1539
|
var BetterAuthBrowserAdapter = class {
|
|
1704
1540
|
authBaseUrl;
|
|
@@ -1713,7 +1549,7 @@ var BetterAuthBrowserAdapter = class {
|
|
|
1713
1549
|
async canSendOtp(_input, options) {
|
|
1714
1550
|
if (options?.signal?.aborted) return {
|
|
1715
1551
|
ok: false,
|
|
1716
|
-
error: Errors.cancelled({ operation: "canSendOtp" })
|
|
1552
|
+
error: Errors$1.cancelled({ operation: "canSendOtp" })
|
|
1717
1553
|
};
|
|
1718
1554
|
return {
|
|
1719
1555
|
ok: true,
|
|
@@ -1726,7 +1562,7 @@ var BetterAuthBrowserAdapter = class {
|
|
|
1726
1562
|
async sendOtp(input, options) {
|
|
1727
1563
|
if (options?.signal?.aborted) return {
|
|
1728
1564
|
ok: false,
|
|
1729
|
-
error: Errors.cancelled({ operation: "sendOtp" })
|
|
1565
|
+
error: Errors$1.cancelled({ operation: "sendOtp" })
|
|
1730
1566
|
};
|
|
1731
1567
|
try {
|
|
1732
1568
|
const res = await this.fetchImpl(this.url("/api/auth/email-otp/send-verification-otp"), withSignal$1({
|
|
@@ -1740,7 +1576,7 @@ var BetterAuthBrowserAdapter = class {
|
|
|
1740
1576
|
}, options?.signal));
|
|
1741
1577
|
if (options?.signal?.aborted) return {
|
|
1742
1578
|
ok: false,
|
|
1743
|
-
error: Errors.cancelled({ operation: "sendOtp" })
|
|
1579
|
+
error: Errors$1.cancelled({ operation: "sendOtp" })
|
|
1744
1580
|
};
|
|
1745
1581
|
if (res.ok) return {
|
|
1746
1582
|
ok: true,
|
|
@@ -1748,19 +1584,19 @@ var BetterAuthBrowserAdapter = class {
|
|
|
1748
1584
|
};
|
|
1749
1585
|
if (res.status === 429) return {
|
|
1750
1586
|
ok: false,
|
|
1751
|
-
error: Errors.rateLimited({ resource: "better-auth/sendOtp" })
|
|
1587
|
+
error: Errors$1.rateLimited({ resource: "better-auth/sendOtp" })
|
|
1752
1588
|
};
|
|
1753
1589
|
const body = await safeJson$1(res);
|
|
1754
1590
|
if (typeof body === "object" && body !== null) {
|
|
1755
1591
|
const errBody = body;
|
|
1756
1592
|
if (errBody.code === "INVALID_EMAIL" || errBody.code === "VALIDATION_ERROR") return {
|
|
1757
1593
|
ok: false,
|
|
1758
|
-
error: Errors.invalidInput("email", errBody.message ?? "invalid email")
|
|
1594
|
+
error: Errors$1.invalidInput("email", errBody.message ?? "invalid email")
|
|
1759
1595
|
};
|
|
1760
1596
|
}
|
|
1761
1597
|
return {
|
|
1762
1598
|
ok: false,
|
|
1763
|
-
error: Errors.providerError("better-auth", "sendOtp", /* @__PURE__ */ new Error(`HTTP ${res.status}`))
|
|
1599
|
+
error: Errors$1.providerError("better-auth", "sendOtp", /* @__PURE__ */ new Error(`HTTP ${res.status}`))
|
|
1764
1600
|
};
|
|
1765
1601
|
} catch (err) {
|
|
1766
1602
|
return {
|
|
@@ -1772,7 +1608,7 @@ var BetterAuthBrowserAdapter = class {
|
|
|
1772
1608
|
async verifyOtp(input, options) {
|
|
1773
1609
|
if (options?.signal?.aborted) return {
|
|
1774
1610
|
ok: false,
|
|
1775
|
-
error: Errors.cancelled({ operation: "verifyOtp" })
|
|
1611
|
+
error: Errors$1.cancelled({ operation: "verifyOtp" })
|
|
1776
1612
|
};
|
|
1777
1613
|
try {
|
|
1778
1614
|
const res = await this.fetchImpl(this.url("/api/auth/sign-in/email-otp"), withSignal$1({
|
|
@@ -1786,7 +1622,7 @@ var BetterAuthBrowserAdapter = class {
|
|
|
1786
1622
|
}, options?.signal));
|
|
1787
1623
|
if (options?.signal?.aborted) return {
|
|
1788
1624
|
ok: false,
|
|
1789
|
-
error: Errors.cancelled({ operation: "verifyOtp" })
|
|
1625
|
+
error: Errors$1.cancelled({ operation: "verifyOtp" })
|
|
1790
1626
|
};
|
|
1791
1627
|
const body = await safeJson$1(res);
|
|
1792
1628
|
if (res.ok) {
|
|
@@ -1799,7 +1635,7 @@ var BetterAuthBrowserAdapter = class {
|
|
|
1799
1635
|
}
|
|
1800
1636
|
return {
|
|
1801
1637
|
ok: false,
|
|
1802
|
-
error: Errors.providerError("better-auth", "verifyOtp", /* @__PURE__ */ new Error("unexpected 200 body"))
|
|
1638
|
+
error: Errors$1.providerError("better-auth", "verifyOtp", /* @__PURE__ */ new Error("unexpected 200 body"))
|
|
1803
1639
|
};
|
|
1804
1640
|
}
|
|
1805
1641
|
return {
|
|
@@ -1816,7 +1652,7 @@ var BetterAuthBrowserAdapter = class {
|
|
|
1816
1652
|
async getSession(options) {
|
|
1817
1653
|
if (options?.signal?.aborted) return {
|
|
1818
1654
|
ok: false,
|
|
1819
|
-
error: Errors.cancelled({ operation: "getSession" })
|
|
1655
|
+
error: Errors$1.cancelled({ operation: "getSession" })
|
|
1820
1656
|
};
|
|
1821
1657
|
try {
|
|
1822
1658
|
const res = await this.fetchImpl(this.url("/api/auth/get-session"), withSignal$1({
|
|
@@ -1825,11 +1661,11 @@ var BetterAuthBrowserAdapter = class {
|
|
|
1825
1661
|
}, options?.signal));
|
|
1826
1662
|
if (options?.signal?.aborted) return {
|
|
1827
1663
|
ok: false,
|
|
1828
|
-
error: Errors.cancelled({ operation: "getSession" })
|
|
1664
|
+
error: Errors$1.cancelled({ operation: "getSession" })
|
|
1829
1665
|
};
|
|
1830
1666
|
if (!res.ok) return {
|
|
1831
1667
|
ok: false,
|
|
1832
|
-
error: Errors.providerError("better-auth", "getSession", /* @__PURE__ */ new Error(`HTTP ${res.status}`))
|
|
1668
|
+
error: Errors$1.providerError("better-auth", "getSession", /* @__PURE__ */ new Error(`HTTP ${res.status}`))
|
|
1833
1669
|
};
|
|
1834
1670
|
const body = await safeJson$1(res);
|
|
1835
1671
|
if (body === null) return {
|
|
@@ -1857,7 +1693,7 @@ var BetterAuthBrowserAdapter = class {
|
|
|
1857
1693
|
async signOut(options) {
|
|
1858
1694
|
if (options?.signal?.aborted) return {
|
|
1859
1695
|
ok: false,
|
|
1860
|
-
error: Errors.cancelled({ operation: "signOut" })
|
|
1696
|
+
error: Errors$1.cancelled({ operation: "signOut" })
|
|
1861
1697
|
};
|
|
1862
1698
|
try {
|
|
1863
1699
|
const res = await this.fetchImpl(this.url("/api/auth/sign-out"), withSignal$1({
|
|
@@ -1868,7 +1704,7 @@ var BetterAuthBrowserAdapter = class {
|
|
|
1868
1704
|
}, options?.signal));
|
|
1869
1705
|
if (options?.signal?.aborted) return {
|
|
1870
1706
|
ok: false,
|
|
1871
|
-
error: Errors.cancelled({ operation: "signOut" })
|
|
1707
|
+
error: Errors$1.cancelled({ operation: "signOut" })
|
|
1872
1708
|
};
|
|
1873
1709
|
if (res.ok) return {
|
|
1874
1710
|
ok: true,
|
|
@@ -1876,7 +1712,7 @@ var BetterAuthBrowserAdapter = class {
|
|
|
1876
1712
|
};
|
|
1877
1713
|
return {
|
|
1878
1714
|
ok: false,
|
|
1879
|
-
error: Errors.providerError("better-auth", "signOut", /* @__PURE__ */ new Error(`HTTP ${res.status}`))
|
|
1715
|
+
error: Errors$1.providerError("better-auth", "signOut", /* @__PURE__ */ new Error(`HTTP ${res.status}`))
|
|
1880
1716
|
};
|
|
1881
1717
|
} catch (err) {
|
|
1882
1718
|
return {
|
|
@@ -1888,7 +1724,7 @@ var BetterAuthBrowserAdapter = class {
|
|
|
1888
1724
|
async getConvexJwt(options) {
|
|
1889
1725
|
if (options?.signal?.aborted) return {
|
|
1890
1726
|
ok: false,
|
|
1891
|
-
error: Errors.cancelled({ operation: "getConvexJwt" })
|
|
1727
|
+
error: Errors$1.cancelled({ operation: "getConvexJwt" })
|
|
1892
1728
|
};
|
|
1893
1729
|
try {
|
|
1894
1730
|
const res = await this.fetchImpl(this.url("/api/auth/convex/token"), withSignal$1({
|
|
@@ -1897,15 +1733,15 @@ var BetterAuthBrowserAdapter = class {
|
|
|
1897
1733
|
}, options?.signal));
|
|
1898
1734
|
if (options?.signal?.aborted) return {
|
|
1899
1735
|
ok: false,
|
|
1900
|
-
error: Errors.cancelled({ operation: "getConvexJwt" })
|
|
1736
|
+
error: Errors$1.cancelled({ operation: "getConvexJwt" })
|
|
1901
1737
|
};
|
|
1902
1738
|
if (res.status === 401) return {
|
|
1903
1739
|
ok: false,
|
|
1904
|
-
error: Errors.notAuthenticated()
|
|
1740
|
+
error: Errors$1.notAuthenticated()
|
|
1905
1741
|
};
|
|
1906
1742
|
if (!res.ok) return {
|
|
1907
1743
|
ok: false,
|
|
1908
|
-
error: Errors.providerError("better-auth", "getConvexJwt", /* @__PURE__ */ new Error(`HTTP ${res.status}`))
|
|
1744
|
+
error: Errors$1.providerError("better-auth", "getConvexJwt", /* @__PURE__ */ new Error(`HTTP ${res.status}`))
|
|
1909
1745
|
};
|
|
1910
1746
|
const body = await safeJson$1(res);
|
|
1911
1747
|
if (typeof body === "object" && body !== null) {
|
|
@@ -1920,7 +1756,7 @@ var BetterAuthBrowserAdapter = class {
|
|
|
1920
1756
|
}
|
|
1921
1757
|
return {
|
|
1922
1758
|
ok: false,
|
|
1923
|
-
error: Errors.providerError("better-auth", "getConvexJwt", /* @__PURE__ */ new Error("unexpected body"))
|
|
1759
|
+
error: Errors$1.providerError("better-auth", "getConvexJwt", /* @__PURE__ */ new Error("unexpected body"))
|
|
1924
1760
|
};
|
|
1925
1761
|
} catch (err) {
|
|
1926
1762
|
return {
|
|
@@ -2096,8 +1932,8 @@ function isAbortError(err, signal) {
|
|
|
2096
1932
|
return signal?.aborted === true || err instanceof Error && err.name === "AbortError" || typeof DOMException !== "undefined" && err instanceof DOMException && err.name === "AbortError";
|
|
2097
1933
|
}
|
|
2098
1934
|
function mapFetchError(operation, err, signal) {
|
|
2099
|
-
if (isAbortError(err, signal)) return Errors.cancelled({ operation });
|
|
2100
|
-
return Errors.networkError(operation, err instanceof Error ? err : new Error(String(err)));
|
|
1935
|
+
if (isAbortError(err, signal)) return Errors$1.cancelled({ operation });
|
|
1936
|
+
return Errors$1.networkError(operation, err instanceof Error ? err : new Error(String(err)));
|
|
2101
1937
|
}
|
|
2102
1938
|
var BetterAuthNodeAdapter = class {
|
|
2103
1939
|
authBaseUrl;
|
|
@@ -2125,7 +1961,7 @@ var BetterAuthNodeAdapter = class {
|
|
|
2125
1961
|
async canSendOtp(_input, options) {
|
|
2126
1962
|
if (options?.signal?.aborted) return {
|
|
2127
1963
|
ok: false,
|
|
2128
|
-
error: Errors.cancelled({ operation: "canSendOtp" })
|
|
1964
|
+
error: Errors$1.cancelled({ operation: "canSendOtp" })
|
|
2129
1965
|
};
|
|
2130
1966
|
return {
|
|
2131
1967
|
ok: true,
|
|
@@ -2138,7 +1974,7 @@ var BetterAuthNodeAdapter = class {
|
|
|
2138
1974
|
async sendOtp(input, options) {
|
|
2139
1975
|
if (options?.signal?.aborted) return {
|
|
2140
1976
|
ok: false,
|
|
2141
|
-
error: Errors.cancelled({ operation: "sendOtp" })
|
|
1977
|
+
error: Errors$1.cancelled({ operation: "sendOtp" })
|
|
2142
1978
|
};
|
|
2143
1979
|
try {
|
|
2144
1980
|
const res = await this.fetchImpl(this.url("/api/auth/email-otp/send-verification-otp"), withSignal({
|
|
@@ -2154,7 +1990,7 @@ var BetterAuthNodeAdapter = class {
|
|
|
2154
1990
|
}, options?.signal));
|
|
2155
1991
|
if (options?.signal?.aborted) return {
|
|
2156
1992
|
ok: false,
|
|
2157
|
-
error: Errors.cancelled({ operation: "sendOtp" })
|
|
1993
|
+
error: Errors$1.cancelled({ operation: "sendOtp" })
|
|
2158
1994
|
};
|
|
2159
1995
|
if (res.ok) return {
|
|
2160
1996
|
ok: true,
|
|
@@ -2162,19 +1998,19 @@ var BetterAuthNodeAdapter = class {
|
|
|
2162
1998
|
};
|
|
2163
1999
|
if (res.status === 429) return {
|
|
2164
2000
|
ok: false,
|
|
2165
|
-
error: Errors.rateLimited({ resource: "better-auth/sendOtp" })
|
|
2001
|
+
error: Errors$1.rateLimited({ resource: "better-auth/sendOtp" })
|
|
2166
2002
|
};
|
|
2167
2003
|
const body = await safeJson(res);
|
|
2168
2004
|
if (typeof body === "object" && body !== null) {
|
|
2169
2005
|
const errBody = body;
|
|
2170
2006
|
if (errBody.code === "INVALID_EMAIL" || errBody.code === "VALIDATION_ERROR") return {
|
|
2171
2007
|
ok: false,
|
|
2172
|
-
error: Errors.invalidInput("email", errBody.message ?? "invalid email")
|
|
2008
|
+
error: Errors$1.invalidInput("email", errBody.message ?? "invalid email")
|
|
2173
2009
|
};
|
|
2174
2010
|
}
|
|
2175
2011
|
return {
|
|
2176
2012
|
ok: false,
|
|
2177
|
-
error: Errors.providerError("better-auth", "sendOtp", /* @__PURE__ */ new Error(`HTTP ${res.status}`))
|
|
2013
|
+
error: Errors$1.providerError("better-auth", "sendOtp", /* @__PURE__ */ new Error(`HTTP ${res.status}`))
|
|
2178
2014
|
};
|
|
2179
2015
|
} catch (err) {
|
|
2180
2016
|
return {
|
|
@@ -2186,7 +2022,7 @@ var BetterAuthNodeAdapter = class {
|
|
|
2186
2022
|
async verifyOtp(input, options) {
|
|
2187
2023
|
if (options?.signal?.aborted) return {
|
|
2188
2024
|
ok: false,
|
|
2189
|
-
error: Errors.cancelled({ operation: "verifyOtp" })
|
|
2025
|
+
error: Errors$1.cancelled({ operation: "verifyOtp" })
|
|
2190
2026
|
};
|
|
2191
2027
|
try {
|
|
2192
2028
|
const res = await this.fetchImpl(this.url("/api/auth/sign-in/email-otp"), withSignal({
|
|
@@ -2202,7 +2038,7 @@ var BetterAuthNodeAdapter = class {
|
|
|
2202
2038
|
}, options?.signal));
|
|
2203
2039
|
if (options?.signal?.aborted) return {
|
|
2204
2040
|
ok: false,
|
|
2205
|
-
error: Errors.cancelled({ operation: "verifyOtp" })
|
|
2041
|
+
error: Errors$1.cancelled({ operation: "verifyOtp" })
|
|
2206
2042
|
};
|
|
2207
2043
|
setCookiesFromResponse(this.cookieJar, this.host, res);
|
|
2208
2044
|
const body = await safeJson(res);
|
|
@@ -2218,17 +2054,17 @@ var BetterAuthNodeAdapter = class {
|
|
|
2218
2054
|
const errBody = body;
|
|
2219
2055
|
if (errBody.code === "OTP_EXPIRED") return {
|
|
2220
2056
|
ok: false,
|
|
2221
|
-
error: Errors.otpExpired()
|
|
2057
|
+
error: Errors$1.otpExpired()
|
|
2222
2058
|
};
|
|
2223
2059
|
if (errBody.code === "INVALID_OTP") return {
|
|
2224
2060
|
ok: false,
|
|
2225
|
-
error: Errors.invalidInput("otp", errBody.message ?? "invalid OTP")
|
|
2061
|
+
error: Errors$1.invalidInput("otp", errBody.message ?? "invalid OTP")
|
|
2226
2062
|
};
|
|
2227
2063
|
}
|
|
2228
2064
|
}
|
|
2229
2065
|
return {
|
|
2230
2066
|
ok: false,
|
|
2231
|
-
error: Errors.providerError("better-auth", "verifyOtp", /* @__PURE__ */ new Error(`HTTP ${res.status}`))
|
|
2067
|
+
error: Errors$1.providerError("better-auth", "verifyOtp", /* @__PURE__ */ new Error(`HTTP ${res.status}`))
|
|
2232
2068
|
};
|
|
2233
2069
|
} catch (err) {
|
|
2234
2070
|
return {
|
|
@@ -2240,7 +2076,7 @@ var BetterAuthNodeAdapter = class {
|
|
|
2240
2076
|
async getSession(options) {
|
|
2241
2077
|
if (options?.signal?.aborted) return {
|
|
2242
2078
|
ok: false,
|
|
2243
|
-
error: Errors.cancelled({ operation: "getSession" })
|
|
2079
|
+
error: Errors$1.cancelled({ operation: "getSession" })
|
|
2244
2080
|
};
|
|
2245
2081
|
try {
|
|
2246
2082
|
const res = await this.fetchImpl(this.url("/api/auth/get-session"), withSignal({
|
|
@@ -2249,11 +2085,11 @@ var BetterAuthNodeAdapter = class {
|
|
|
2249
2085
|
}, options?.signal));
|
|
2250
2086
|
if (options?.signal?.aborted) return {
|
|
2251
2087
|
ok: false,
|
|
2252
|
-
error: Errors.cancelled({ operation: "getSession" })
|
|
2088
|
+
error: Errors$1.cancelled({ operation: "getSession" })
|
|
2253
2089
|
};
|
|
2254
2090
|
if (!res.ok) return {
|
|
2255
2091
|
ok: false,
|
|
2256
|
-
error: Errors.providerError("better-auth", "getSession", /* @__PURE__ */ new Error(`HTTP ${res.status}`))
|
|
2092
|
+
error: Errors$1.providerError("better-auth", "getSession", /* @__PURE__ */ new Error(`HTTP ${res.status}`))
|
|
2257
2093
|
};
|
|
2258
2094
|
const body = await safeJson(res);
|
|
2259
2095
|
if (body === null) return {
|
|
@@ -2281,7 +2117,7 @@ var BetterAuthNodeAdapter = class {
|
|
|
2281
2117
|
async signOut(options) {
|
|
2282
2118
|
if (options?.signal?.aborted) return {
|
|
2283
2119
|
ok: false,
|
|
2284
|
-
error: Errors.cancelled({ operation: "signOut" })
|
|
2120
|
+
error: Errors$1.cancelled({ operation: "signOut" })
|
|
2285
2121
|
};
|
|
2286
2122
|
try {
|
|
2287
2123
|
const signOutOrigin = originFromBaseUrl(this.authBaseUrl) ?? this.origin;
|
|
@@ -2295,7 +2131,7 @@ var BetterAuthNodeAdapter = class {
|
|
|
2295
2131
|
}, options?.signal));
|
|
2296
2132
|
if (options?.signal?.aborted) return {
|
|
2297
2133
|
ok: false,
|
|
2298
|
-
error: Errors.cancelled({ operation: "signOut" })
|
|
2134
|
+
error: Errors$1.cancelled({ operation: "signOut" })
|
|
2299
2135
|
};
|
|
2300
2136
|
setCookiesFromResponse(this.cookieJar, this.host, res);
|
|
2301
2137
|
if (res.ok) return {
|
|
@@ -2304,7 +2140,7 @@ var BetterAuthNodeAdapter = class {
|
|
|
2304
2140
|
};
|
|
2305
2141
|
return {
|
|
2306
2142
|
ok: false,
|
|
2307
|
-
error: Errors.providerError("better-auth", "signOut", /* @__PURE__ */ new Error(`HTTP ${res.status}`))
|
|
2143
|
+
error: Errors$1.providerError("better-auth", "signOut", /* @__PURE__ */ new Error(`HTTP ${res.status}`))
|
|
2308
2144
|
};
|
|
2309
2145
|
} catch (err) {
|
|
2310
2146
|
return {
|
|
@@ -2316,7 +2152,7 @@ var BetterAuthNodeAdapter = class {
|
|
|
2316
2152
|
async getConvexJwt(options) {
|
|
2317
2153
|
if (options?.signal?.aborted) return {
|
|
2318
2154
|
ok: false,
|
|
2319
|
-
error: Errors.cancelled({ operation: "getConvexJwt" })
|
|
2155
|
+
error: Errors$1.cancelled({ operation: "getConvexJwt" })
|
|
2320
2156
|
};
|
|
2321
2157
|
try {
|
|
2322
2158
|
const res = await this.fetchImpl(this.url("/api/auth/convex/token"), withSignal({
|
|
@@ -2325,15 +2161,15 @@ var BetterAuthNodeAdapter = class {
|
|
|
2325
2161
|
}, options?.signal));
|
|
2326
2162
|
if (options?.signal?.aborted) return {
|
|
2327
2163
|
ok: false,
|
|
2328
|
-
error: Errors.cancelled({ operation: "getConvexJwt" })
|
|
2164
|
+
error: Errors$1.cancelled({ operation: "getConvexJwt" })
|
|
2329
2165
|
};
|
|
2330
2166
|
if (res.status === 401) return {
|
|
2331
2167
|
ok: false,
|
|
2332
|
-
error: Errors.notAuthenticated()
|
|
2168
|
+
error: Errors$1.notAuthenticated()
|
|
2333
2169
|
};
|
|
2334
2170
|
if (!res.ok) return {
|
|
2335
2171
|
ok: false,
|
|
2336
|
-
error: Errors.providerError("better-auth", "getConvexJwt", /* @__PURE__ */ new Error(`HTTP ${res.status}`))
|
|
2172
|
+
error: Errors$1.providerError("better-auth", "getConvexJwt", /* @__PURE__ */ new Error(`HTTP ${res.status}`))
|
|
2337
2173
|
};
|
|
2338
2174
|
const body = await safeJson(res);
|
|
2339
2175
|
if (typeof body === "object" && body !== null) {
|
|
@@ -2348,7 +2184,7 @@ var BetterAuthNodeAdapter = class {
|
|
|
2348
2184
|
}
|
|
2349
2185
|
return {
|
|
2350
2186
|
ok: false,
|
|
2351
|
-
error: Errors.providerError("better-auth", "getConvexJwt", /* @__PURE__ */ new Error("unexpected body"))
|
|
2187
|
+
error: Errors$1.providerError("better-auth", "getConvexJwt", /* @__PURE__ */ new Error("unexpected body"))
|
|
2352
2188
|
};
|
|
2353
2189
|
} catch (err) {
|
|
2354
2190
|
return {
|
|
@@ -2362,377 +2198,6 @@ function BetterAuthNodeLayer(deps) {
|
|
|
2362
2198
|
return Layer.succeed(AuthClientPortTag, authClientPortFromPromiseAdapter(new BetterAuthNodeAdapter(deps)));
|
|
2363
2199
|
}
|
|
2364
2200
|
//#endregion
|
|
2365
|
-
//#region ../wire/src/brands.ts
|
|
2366
|
-
/**
|
|
2367
|
-
* `AppId` schema. Mirrors `toAppId` from `@capxul/types`:
|
|
2368
|
-
* `app_` + Crockford-base32 ULID (26 chars, first char in `[0-7]`).
|
|
2369
|
-
*/
|
|
2370
|
-
const AppIdSchema$1 = Schema.String.pipe(Schema.filter((s) => APP_ID_RE.test(s), { message: () => "must be app_ plus a ULID" }));
|
|
2371
|
-
/**
|
|
2372
|
-
* `ChainId` schema. Mirrors `toChainId`: positive safe integer.
|
|
2373
|
-
*/
|
|
2374
|
-
const ChainIdSchema$1 = Schema.Number.pipe(Schema.filter((n) => Number.isSafeInteger(n) && n > 0, { message: () => "must be a positive safe integer" }));
|
|
2375
|
-
/**
|
|
2376
|
-
* `CurrencyCode` schema. Mirrors `toCurrencyCode`: currently supported
|
|
2377
|
-
* consumer-facing ISO-ish currency code set.
|
|
2378
|
-
*/
|
|
2379
|
-
const CurrencyCodeSchema$1 = Schema.String.pipe(Schema.filter((s) => SUPPORTED_CURRENCY_CODES.includes(s), { message: () => "must be a supported currency code" }));
|
|
2380
|
-
const DOCUMENT_HASH_HEX_RE = /^[0-9a-fA-F]{64}$/;
|
|
2381
|
-
/**
|
|
2382
|
-
* `DocumentHash` schema. Mirrors `toDocumentHash`: bare or 0x-prefixed bytes32,
|
|
2383
|
-
* normalized to lowercase 0x-prefixed form.
|
|
2384
|
-
*/
|
|
2385
|
-
const DocumentHashSchema$1 = Schema.String.pipe(Schema.transform(Schema.String, {
|
|
2386
|
-
decode: (s) => {
|
|
2387
|
-
const stripped = s.startsWith("0x") || s.startsWith("0X") ? s.slice(2) : s;
|
|
2388
|
-
return DOCUMENT_HASH_HEX_RE.test(stripped) ? `0x${stripped.toLowerCase()}` : s;
|
|
2389
|
-
},
|
|
2390
|
-
encode: (s) => s
|
|
2391
|
-
}), Schema.filter((s) => BYTES32_RE.test(s), { message: () => "must be 32 bytes of hex" }));
|
|
2392
|
-
/**
|
|
2393
|
-
* `SessionToken` schema. Mirrors `toSessionToken`: non-empty string.
|
|
2394
|
-
* Issuance source distinguishes SDK-handshake tokens from auth-session
|
|
2395
|
-
* tokens; the brand itself is opaque.
|
|
2396
|
-
*/
|
|
2397
|
-
const SessionTokenSchema = Schema.String.pipe(Schema.filter((s) => s.length > 0, { message: () => "must be a non-empty string" }));
|
|
2398
|
-
/**
|
|
2399
|
-
* `EpochMs` schema. Mirrors `toEpochMs`: non-negative safe integer.
|
|
2400
|
-
*/
|
|
2401
|
-
const EpochMsSchema$1 = Schema.Number.pipe(Schema.filter((n) => Number.isSafeInteger(n) && n >= 0, { message: () => "must be a non-negative safe integer" }));
|
|
2402
|
-
/**
|
|
2403
|
-
* `DurationMs` schema. Mirrors `toDurationMs`: non-negative safe integer.
|
|
2404
|
-
*/
|
|
2405
|
-
const DurationMsSchema$1 = Schema.Number.pipe(Schema.filter((n) => Number.isSafeInteger(n) && n >= 0, { message: () => "must be a non-negative safe integer" }));
|
|
2406
|
-
//#endregion
|
|
2407
|
-
//#region ../wire/src/bootstrap.ts
|
|
2408
|
-
/**
|
|
2409
|
-
* `BootstrapEnvelope` v1.
|
|
2410
|
-
*
|
|
2411
|
-
* - `protocol`: discriminator that lets future protocols coexist on the
|
|
2412
|
-
* same endpoint without a wire-shape conflict.
|
|
2413
|
-
* - `version`: numeric version inside the protocol. Unknown versions MUST
|
|
2414
|
-
* fail decode with an INVALID_INPUT-class `CapxulError` at the SDK seam.
|
|
2415
|
-
* - `state`: the resolved bootstrap payload. Field shape matches the
|
|
2416
|
-
* `BootstrapResolution` port; the SDK consumer can pass `state`
|
|
2417
|
-
* directly (after `normalizeRuntimeUrl` on the two URL fields) into
|
|
2418
|
-
* the port without re-branding.
|
|
2419
|
-
*/
|
|
2420
|
-
const BootstrapEnvelope = Schema.Struct({
|
|
2421
|
-
protocol: Schema.Literal("capxul.bootstrap"),
|
|
2422
|
-
version: Schema.Literal(1),
|
|
2423
|
-
state: Schema.Struct({
|
|
2424
|
-
applicationId: AppIdSchema$1,
|
|
2425
|
-
chainId: ChainIdSchema$1,
|
|
2426
|
-
sessionToken: SessionTokenSchema,
|
|
2427
|
-
issuedAt: EpochMsSchema$1,
|
|
2428
|
-
expiresIn: DurationMsSchema$1,
|
|
2429
|
-
authBaseUrl: Schema.String,
|
|
2430
|
-
convexUrl: Schema.String,
|
|
2431
|
-
siteBaseUrl: Schema.String,
|
|
2432
|
-
openfortPublishableKey: Schema.String,
|
|
2433
|
-
shieldPublishableKey: Schema.String
|
|
2434
|
-
})
|
|
2435
|
-
});
|
|
2436
|
-
//#endregion
|
|
2437
|
-
//#region ../wire/src/financial-ops.ts
|
|
2438
|
-
const MINOR_UNIT_STRING_RE = /^[0-9]+$/;
|
|
2439
|
-
const DECIMAL_STRING_RE = /^[0-9]+(?:\.[0-9]+)?$/;
|
|
2440
|
-
const EVM_ADDRESS_RE = /^0x[a-fA-F0-9]{40}$/;
|
|
2441
|
-
/**
|
|
2442
|
-
* The canonical on-chain domain anchor for the v1 payment-document EIP-712
|
|
2443
|
-
* `domain` (payment-document-spec.md v1). The `PaymentDocumentDomain` schema
|
|
2444
|
-
* validates against this exact literal, and the backend's receipt builder mints
|
|
2445
|
-
* envelopes carrying it — so it MUST stay byte-identical across both. Exported
|
|
2446
|
-
* once here to remove the drift risk of a mirrored declaration.
|
|
2447
|
-
*/
|
|
2448
|
-
const PAYMENT_DOCUMENT_VERIFYING_CONTRACT = "0xe740ea65521edc9bef0ea75d30b5334711db99f4";
|
|
2449
|
-
const PAYMENT_ID_RE = /^payment_[0-9A-Za-z]+$/;
|
|
2450
|
-
const PAYEE_ID_RE = /^payee_[0-9A-Za-z]+$/;
|
|
2451
|
-
const ORG_ID_RE = /^org_[0-9A-Za-z]+$/;
|
|
2452
|
-
const USER_ID_RE = /^user_[0-9A-Za-z]+$/;
|
|
2453
|
-
const HANDLE_RE = /^@?[a-z0-9][a-z0-9-]{2,31}$/;
|
|
2454
|
-
const ORG_HANDLE_RE = /^[a-z0-9][a-z0-9-]{2,31}$/;
|
|
2455
|
-
const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
2456
|
-
const MinorUnitStringSchema = Schema.String.pipe(Schema.filter((value) => MINOR_UNIT_STRING_RE.test(value), { message: () => "must be a non-negative integer minor-unit string" }));
|
|
2457
|
-
const PaymentIdSchema = Schema.String.pipe(Schema.filter((value) => PAYMENT_ID_RE.test(value), { message: () => "must be payment_ plus an alphanumeric id" }));
|
|
2458
|
-
const PayeeIdSchema = Schema.String.pipe(Schema.filter((value) => PAYEE_ID_RE.test(value), { message: () => "must be payee_ plus an alphanumeric id" }));
|
|
2459
|
-
const OrgIdSchema = Schema.String.pipe(Schema.filter((value) => ORG_ID_RE.test(value), { message: () => "must be org_ plus an alphanumeric id" }));
|
|
2460
|
-
const UserIdSchema = Schema.String.pipe(Schema.filter((value) => USER_ID_RE.test(value), { message: () => "must be user_ plus an alphanumeric id" }));
|
|
2461
|
-
const DecimalStringSchema = Schema.String.pipe(Schema.filter((value) => DECIMAL_STRING_RE.test(value), { message: () => "must be a non-negative decimal string" }));
|
|
2462
|
-
const HandleValueSchema = Schema.String.pipe(Schema.filter((value) => !EVM_ADDRESS_RE.test(value) && HANDLE_RE.test(value), { message: () => "must be a handle; raw addresses are not accepted" }));
|
|
2463
|
-
const OrgHandleValueSchema = Schema.String.pipe(Schema.filter((value) => !EVM_ADDRESS_RE.test(value) && ORG_HANDLE_RE.test(value), { message: () => "must be an org handle; raw addresses are not accepted" }));
|
|
2464
|
-
const EmailValueSchema = Schema.String.pipe(Schema.filter((value) => !EVM_ADDRESS_RE.test(value) && EMAIL_RE.test(value), { message: () => "must be an email; raw addresses are not accepted" }));
|
|
2465
|
-
const Uint8Schema = Schema.Number.pipe(Schema.filter((value) => Number.isSafeInteger(value) && value >= 0 && value <= 255, { message: () => "must be a uint8" }));
|
|
2466
|
-
const Uint64Schema = Schema.Number.pipe(Schema.filter((value) => Number.isSafeInteger(value) && value >= 0, { message: () => "must be a non-negative safe integer" }));
|
|
2467
|
-
const PaymentDocumentDomain = Schema.Struct({
|
|
2468
|
-
name: Schema.Literal("CapxulPayments"),
|
|
2469
|
-
version: Schema.Literal("1"),
|
|
2470
|
-
chainId: ChainIdSchema$1,
|
|
2471
|
-
verifyingContract: Schema.Literal(PAYMENT_DOCUMENT_VERIFYING_CONTRACT)
|
|
2472
|
-
});
|
|
2473
|
-
const MemoDocument = Schema.Struct({
|
|
2474
|
-
kind: Schema.Literal(0),
|
|
2475
|
-
reference: Schema.String,
|
|
2476
|
-
note: Schema.String,
|
|
2477
|
-
issuedAt: Uint64Schema
|
|
2478
|
-
});
|
|
2479
|
-
const InvoiceDocument = Schema.Struct({
|
|
2480
|
-
kind: Schema.Literal(1),
|
|
2481
|
-
invoiceNumber: Schema.String,
|
|
2482
|
-
payerRef: Schema.String,
|
|
2483
|
-
payeeRef: Schema.String,
|
|
2484
|
-
amount: MinorUnitStringSchema,
|
|
2485
|
-
currency: CurrencyCodeSchema$1,
|
|
2486
|
-
decimals: Uint8Schema,
|
|
2487
|
-
issuedAt: Uint64Schema,
|
|
2488
|
-
dueAt: Uint64Schema,
|
|
2489
|
-
lineItemsHash: DocumentHashSchema$1
|
|
2490
|
-
});
|
|
2491
|
-
const PayslipDocument = Schema.Struct({
|
|
2492
|
-
kind: Schema.Literal(2),
|
|
2493
|
-
employerRef: Schema.String,
|
|
2494
|
-
employeeRef: Schema.String,
|
|
2495
|
-
period: Schema.String,
|
|
2496
|
-
gross: MinorUnitStringSchema,
|
|
2497
|
-
net: MinorUnitStringSchema,
|
|
2498
|
-
currency: CurrencyCodeSchema$1,
|
|
2499
|
-
decimals: Uint8Schema,
|
|
2500
|
-
issuedAt: Uint64Schema
|
|
2501
|
-
});
|
|
2502
|
-
const ReceiptDocument = Schema.Struct({
|
|
2503
|
-
kind: Schema.Literal(3),
|
|
2504
|
-
reference: Schema.String,
|
|
2505
|
-
amount: MinorUnitStringSchema,
|
|
2506
|
-
currency: CurrencyCodeSchema$1,
|
|
2507
|
-
decimals: Uint8Schema,
|
|
2508
|
-
paidAt: Uint64Schema,
|
|
2509
|
-
note: Schema.String
|
|
2510
|
-
});
|
|
2511
|
-
const WithdrawalDestAddressSchema = Schema.String.pipe(Schema.filter((value) => EVM_ADDRESS_RE.test(value), { message: () => "must be a 0x EVM address" }));
|
|
2512
|
-
const WithdrawalDocument = Schema.Struct({
|
|
2513
|
-
kind: Schema.Literal(4),
|
|
2514
|
-
reference: Schema.String,
|
|
2515
|
-
amount: MinorUnitStringSchema,
|
|
2516
|
-
currency: CurrencyCodeSchema$1,
|
|
2517
|
-
decimals: Uint8Schema,
|
|
2518
|
-
destChain: ChainIdSchema$1,
|
|
2519
|
-
destAddress: WithdrawalDestAddressSchema,
|
|
2520
|
-
settledAt: Uint64Schema,
|
|
2521
|
-
provider: Schema.String,
|
|
2522
|
-
note: Schema.String
|
|
2523
|
-
});
|
|
2524
|
-
const FinancialOpsMoney = Schema.Struct({
|
|
2525
|
-
currency: CurrencyCodeSchema$1,
|
|
2526
|
-
value: DecimalStringSchema,
|
|
2527
|
-
decimals: Schema.Number.pipe(Schema.filter((value) => Number.isSafeInteger(value) && value >= 0, { message: () => "must be a non-negative safe integer" }))
|
|
2528
|
-
});
|
|
2529
|
-
const PaymentDocument = Schema.Struct({
|
|
2530
|
-
documentHash: DocumentHashSchema$1,
|
|
2531
|
-
kind: Schema.Literal("invoice", "receipt", "payslip", "memo", "withdrawal"),
|
|
2532
|
-
title: Schema.optional(Schema.String),
|
|
2533
|
-
uri: Schema.optional(Schema.String),
|
|
2534
|
-
issuedAt: Schema.optional(EpochMsSchema$1)
|
|
2535
|
-
});
|
|
2536
|
-
const PaymentType = Schema.Literal("unspecified", "invoice", "payroll", "reimbursement");
|
|
2537
|
-
function paymentTypeForDocumentKind(kind) {
|
|
2538
|
-
switch (kind) {
|
|
2539
|
-
case "memo": return "unspecified";
|
|
2540
|
-
case "invoice": return "invoice";
|
|
2541
|
-
case "payslip": return "payroll";
|
|
2542
|
-
case "receipt": return "reimbursement";
|
|
2543
|
-
case "withdrawal": return "unspecified";
|
|
2544
|
-
}
|
|
2545
|
-
}
|
|
2546
|
-
const AttachablePaymentDocumentEnvelope = Schema.Union(Schema.Struct({
|
|
2547
|
-
protocol: Schema.Literal("capxul.payment-document"),
|
|
2548
|
-
version: Schema.Literal(1),
|
|
2549
|
-
domain: PaymentDocumentDomain,
|
|
2550
|
-
primaryType: Schema.Literal("Memo"),
|
|
2551
|
-
message: MemoDocument
|
|
2552
|
-
}), Schema.Struct({
|
|
2553
|
-
protocol: Schema.Literal("capxul.payment-document"),
|
|
2554
|
-
version: Schema.Literal(1),
|
|
2555
|
-
domain: PaymentDocumentDomain,
|
|
2556
|
-
primaryType: Schema.Literal("Invoice"),
|
|
2557
|
-
message: InvoiceDocument
|
|
2558
|
-
}), Schema.Struct({
|
|
2559
|
-
protocol: Schema.Literal("capxul.payment-document"),
|
|
2560
|
-
version: Schema.Literal(1),
|
|
2561
|
-
domain: PaymentDocumentDomain,
|
|
2562
|
-
primaryType: Schema.Literal("Payslip"),
|
|
2563
|
-
message: PayslipDocument
|
|
2564
|
-
}), Schema.Struct({
|
|
2565
|
-
protocol: Schema.Literal("capxul.payment-document"),
|
|
2566
|
-
version: Schema.Literal(1),
|
|
2567
|
-
domain: PaymentDocumentDomain,
|
|
2568
|
-
primaryType: Schema.Literal("Receipt"),
|
|
2569
|
-
message: ReceiptDocument
|
|
2570
|
-
}));
|
|
2571
|
-
const WithdrawalDocumentEnvelope = Schema.Struct({
|
|
2572
|
-
protocol: Schema.Literal("capxul.payment-document"),
|
|
2573
|
-
version: Schema.Literal(1),
|
|
2574
|
-
domain: PaymentDocumentDomain,
|
|
2575
|
-
primaryType: Schema.Literal("Withdrawal"),
|
|
2576
|
-
message: WithdrawalDocument
|
|
2577
|
-
});
|
|
2578
|
-
Schema.Union(AttachablePaymentDocumentEnvelope, WithdrawalDocumentEnvelope);
|
|
2579
|
-
Schema.Struct({
|
|
2580
|
-
payeeId: PayeeIdSchema,
|
|
2581
|
-
label: Schema.String,
|
|
2582
|
-
trustState: Schema.Literal("unverified", "trusted", "blocked"),
|
|
2583
|
-
destinationKind: Schema.Literal("handle", "email", "saved-payee", "org")
|
|
2584
|
-
});
|
|
2585
|
-
const PaymentRecipient = Schema.Struct({
|
|
2586
|
-
kind: Schema.Literal("handle", "email", "payee", "capxulUserId", "me", "org", "external_address"),
|
|
2587
|
-
label: Schema.String,
|
|
2588
|
-
payeeId: Schema.optional(PayeeIdSchema)
|
|
2589
|
-
});
|
|
2590
|
-
/**
|
|
2591
|
-
* A raw external EVM address for the B3 withdraw lane — the cash-out
|
|
2592
|
-
* destination. This is the ONE schema that ACCEPTS a bare 0x (the withdraw
|
|
2593
|
-
* mutation args use it), as opposed to `PaymentRecipientRefSchema` which
|
|
2594
|
-
* REJECTS bare addresses to protect the pay lane. The full address never
|
|
2595
|
-
* crosses the model wire; it lives on the kind:4 Withdrawal document only.
|
|
2596
|
-
*/
|
|
2597
|
-
const ExternalAddressSchema = Schema.String.pipe(Schema.filter((value) => EVM_ADDRESS_RE.test(value), { message: () => "must be a 0x EVM address (40 hex chars)" }));
|
|
2598
|
-
const PaymentTiming = Schema.Union(Schema.Struct({ kind: Schema.Literal("instant") }), Schema.Struct({
|
|
2599
|
-
kind: Schema.Literal("scheduled"),
|
|
2600
|
-
at: EpochMsSchema$1
|
|
2601
|
-
}), Schema.Struct({
|
|
2602
|
-
kind: Schema.Literal("stream"),
|
|
2603
|
-
startsAt: EpochMsSchema$1,
|
|
2604
|
-
endsAt: EpochMsSchema$1,
|
|
2605
|
-
cliffAt: Schema.optional(EpochMsSchema$1)
|
|
2606
|
-
}));
|
|
2607
|
-
const PaymentRef = Schema.Union(Schema.Struct({
|
|
2608
|
-
kind: Schema.Literal("handle"),
|
|
2609
|
-
handle: HandleValueSchema
|
|
2610
|
-
}), Schema.Struct({
|
|
2611
|
-
kind: Schema.Literal("email"),
|
|
2612
|
-
email: EmailValueSchema
|
|
2613
|
-
}), Schema.Struct({
|
|
2614
|
-
kind: Schema.Literal("orgHandle"),
|
|
2615
|
-
orgHandle: OrgHandleValueSchema
|
|
2616
|
-
}), Schema.Struct({
|
|
2617
|
-
kind: Schema.Literal("capxulUserId"),
|
|
2618
|
-
capxulUserId: UserIdSchema
|
|
2619
|
-
}), Schema.Struct({
|
|
2620
|
-
kind: Schema.Literal("payeeId"),
|
|
2621
|
-
payeeId: PayeeIdSchema
|
|
2622
|
-
}));
|
|
2623
|
-
const Payment = Schema.Struct({
|
|
2624
|
-
id: PaymentIdSchema,
|
|
2625
|
-
status: Schema.Literal("pending", "submitted", "pending_claim", "scheduled", "streaming", "settled", "cancelled", "redirected", "expired", "failed"),
|
|
2626
|
-
amount: FinancialOpsMoney,
|
|
2627
|
-
paymentType: PaymentType,
|
|
2628
|
-
recipient: PaymentRecipient,
|
|
2629
|
-
documents: Schema.Array(PaymentDocument),
|
|
2630
|
-
timing: PaymentTiming,
|
|
2631
|
-
released: FinancialOpsMoney,
|
|
2632
|
-
availableToClaim: FinancialOpsMoney,
|
|
2633
|
-
createdAt: EpochMsSchema$1,
|
|
2634
|
-
updatedAt: EpochMsSchema$1
|
|
2635
|
-
}).pipe(Schema.filter((payment) => payment.documents.every((document) => paymentTypeForDocumentKind(document.kind) === payment.paymentType), { message: () => "document kind must map to paymentType" }));
|
|
2636
|
-
const PaymentSource = Schema.Union(Schema.Struct({
|
|
2637
|
-
kind: Schema.Literal("me"),
|
|
2638
|
-
orgId: Schema.optional(Schema.Undefined)
|
|
2639
|
-
}), Schema.Struct({
|
|
2640
|
-
kind: Schema.Literal("org"),
|
|
2641
|
-
orgId: OrgIdSchema
|
|
2642
|
-
}));
|
|
2643
|
-
/**
|
|
2644
|
-
* #592 invoice line item. `quantity` is a positive integer; `unitMinor` is the
|
|
2645
|
-
* per-unit price in integer minor units. The list is canonically hashed by
|
|
2646
|
-
* `hashLineItems` (payment-document-hash.ts) into the Invoice `lineItemsHash`,
|
|
2647
|
-
* and Σ(quantity × unitMinor) MUST equal the invoice `amount`. The hash binds
|
|
2648
|
-
* the documentHash to the exact items; the sum-check makes the items add up to
|
|
2649
|
-
* the amount due. See the payment-document spec (canon/mcp/financial-ops.md).
|
|
2650
|
-
*/
|
|
2651
|
-
const LineItem = Schema.Struct({
|
|
2652
|
-
description: Schema.String,
|
|
2653
|
-
quantity: Schema.Number.pipe(Schema.filter((value) => Number.isSafeInteger(value) && value > 0, { message: () => "quantity must be a positive integer" })),
|
|
2654
|
-
unitMinor: MinorUnitStringSchema
|
|
2655
|
-
});
|
|
2656
|
-
Schema.Struct({
|
|
2657
|
-
from: Schema.optional(PaymentSource),
|
|
2658
|
-
to: PaymentRef,
|
|
2659
|
-
amount: FinancialOpsMoney,
|
|
2660
|
-
timing: Schema.optional(PaymentTiming),
|
|
2661
|
-
document: Schema.optional(AttachablePaymentDocumentEnvelope),
|
|
2662
|
-
lineItems: Schema.optional(Schema.Array(LineItem))
|
|
2663
|
-
});
|
|
2664
|
-
Schema.Struct({
|
|
2665
|
-
to: ExternalAddressSchema,
|
|
2666
|
-
amount: FinancialOpsMoney,
|
|
2667
|
-
document: WithdrawalDocumentEnvelope
|
|
2668
|
-
});
|
|
2669
|
-
Schema.Struct({
|
|
2670
|
-
protocol: Schema.Literal("capxul.me"),
|
|
2671
|
-
version: Schema.Literal(1),
|
|
2672
|
-
me: Schema.Struct({
|
|
2673
|
-
displayName: Schema.NullOr(Schema.String),
|
|
2674
|
-
handle: Schema.NullOr(Schema.String),
|
|
2675
|
-
defaultCurrency: CurrencyCodeSchema$1,
|
|
2676
|
-
depositInstructions: Schema.Array(Schema.Struct({
|
|
2677
|
-
network: Schema.String,
|
|
2678
|
-
asset: CurrencyCodeSchema$1,
|
|
2679
|
-
depositTarget: Schema.String,
|
|
2680
|
-
memo: Schema.optional(Schema.String)
|
|
2681
|
-
}))
|
|
2682
|
-
})
|
|
2683
|
-
});
|
|
2684
|
-
Schema.Struct({
|
|
2685
|
-
protocol: Schema.Literal("capxul.payments"),
|
|
2686
|
-
version: Schema.Literal(1),
|
|
2687
|
-
payments: Schema.Array(Payment)
|
|
2688
|
-
});
|
|
2689
|
-
`
|
|
2690
|
-
.capxul-doc{--ink:#1d1d1f;--muted:#6e6e73;--line:#e7e7ea;--accent:#0a7d4b;--bg:#fff;
|
|
2691
|
-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Inter,system-ui,sans-serif;
|
|
2692
|
-
color:var(--ink);background:var(--bg);max-width:44rem;margin:0 auto;padding:2.75rem 3rem;
|
|
2693
|
-
border:1px solid var(--line);border-radius:16px;box-shadow:0 1px 2px rgba(0,0,0,.04),0 12px 32px rgba(0,0,0,.06);
|
|
2694
|
-
line-height:1.5;font-size:15px;overflow-wrap:anywhere;word-break:break-word}
|
|
2695
|
-
.capxul-doc *{box-sizing:border-box;min-width:0}
|
|
2696
|
-
.capxul-doc .doc-header{display:flex;flex-direction:column;gap:1.25rem;padding-bottom:1.5rem;border-bottom:1px solid var(--line);margin-bottom:1.75rem}
|
|
2697
|
-
.capxul-doc .doc-brand{display:flex;align-items:center;gap:.5rem;color:var(--accent);font-weight:600}
|
|
2698
|
-
.capxul-doc .doc-brand-mark{font-size:1.1rem}
|
|
2699
|
-
.capxul-doc .doc-brand-name{letter-spacing:.02em}
|
|
2700
|
-
.capxul-doc .doc-headline{display:flex;align-items:baseline;justify-content:space-between;gap:1rem;flex-wrap:wrap}
|
|
2701
|
-
.capxul-doc .doc-title{font-size:1.9rem;font-weight:700;letter-spacing:-.02em;margin:0}
|
|
2702
|
-
.capxul-doc .doc-badge{font-size:.7rem;font-weight:700;text-transform:uppercase;letter-spacing:.08em;
|
|
2703
|
-
color:var(--accent);background:rgba(10,125,75,.1);padding:.3rem .6rem;border-radius:999px;max-width:100%;text-align:right}
|
|
2704
|
-
.capxul-doc .doc-parties{display:grid;grid-template-columns:1fr 1fr;gap:1.25rem;margin-bottom:1.75rem}
|
|
2705
|
-
.capxul-doc .doc-party{display:flex;flex-direction:column;gap:.15rem}
|
|
2706
|
-
.capxul-doc .doc-party-label{font-size:.72rem;text-transform:uppercase;letter-spacing:.06em;color:var(--muted)}
|
|
2707
|
-
.capxul-doc .doc-party-name{font-weight:600}
|
|
2708
|
-
.capxul-doc .doc-meta{display:flex;flex-direction:column;gap:.4rem;margin-bottom:1.75rem}
|
|
2709
|
-
.capxul-doc .doc-meta-row{display:flex;justify-content:space-between;gap:1rem;font-size:.92rem}
|
|
2710
|
-
.capxul-doc .doc-meta-label{color:var(--muted);flex-shrink:0}
|
|
2711
|
-
.capxul-doc .doc-meta-value{font-weight:500;text-align:right}
|
|
2712
|
-
.capxul-doc time{color:var(--ink);font-variant-numeric:tabular-nums}
|
|
2713
|
-
.capxul-doc .doc-line-items{width:100%;border-collapse:collapse;margin:.5rem 0 1.5rem;font-size:.92rem}
|
|
2714
|
-
.capxul-doc .doc-line-items th{text-align:left;font-size:.7rem;text-transform:uppercase;letter-spacing:.05em;
|
|
2715
|
-
color:var(--muted);font-weight:600;padding:.5rem .25rem;border-bottom:1px solid var(--line)}
|
|
2716
|
-
.capxul-doc .doc-line-items td{padding:.7rem .25rem;border-bottom:1px solid var(--line)}
|
|
2717
|
-
.capxul-doc .doc-li-qty,.capxul-doc .doc-li-unit,.capxul-doc .doc-li-total{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
|
|
2718
|
-
.capxul-doc .doc-li-desc{width:100%}
|
|
2719
|
-
.capxul-doc .doc-totals{display:flex;flex-direction:column;gap:.5rem;margin-top:.5rem}
|
|
2720
|
-
.capxul-doc .doc-total-line{display:flex;justify-content:space-between;align-items:baseline;gap:1rem}
|
|
2721
|
-
.capxul-doc .doc-total-label{color:var(--muted)}
|
|
2722
|
-
.capxul-doc .doc-total-deduction .doc-amount-value{color:var(--muted)}
|
|
2723
|
-
.capxul-doc .doc-total-grand{border-top:2px solid var(--ink);margin-top:.5rem;padding-top:.75rem;font-size:1.15rem}
|
|
2724
|
-
.capxul-doc .doc-total-grand .doc-amount-value{font-weight:700}
|
|
2725
|
-
.capxul-doc .doc-amount-value{font-variant-numeric:tabular-nums;font-weight:600}
|
|
2726
|
-
.capxul-doc .doc-hero{text-align:center;padding:1.5rem 0 2rem}
|
|
2727
|
-
.capxul-doc .doc-hero-label{font-size:.72rem;text-transform:uppercase;letter-spacing:.06em;color:var(--muted)}
|
|
2728
|
-
.capxul-doc .doc-hero-amount{font-size:2.6rem;font-weight:700;letter-spacing:-.02em;margin-top:.35rem}
|
|
2729
|
-
.capxul-doc .doc-note{color:var(--ink);background:#f7f7f8;border-radius:10px;padding:.9rem 1.1rem;margin:0}
|
|
2730
|
-
.capxul-doc .doc-dest-address{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.9rem}
|
|
2731
|
-
.capxul-doc .doc-footer{margin-top:1.75rem;padding-top:1.25rem;border-top:1px solid var(--line);color:var(--muted);font-size:.9rem}
|
|
2732
|
-
.capxul-doc code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.82rem;color:var(--muted);word-break:break-all}
|
|
2733
|
-
@media (max-width:540px){.capxul-doc{padding:1.75rem 1.25rem}.capxul-doc .doc-parties{grid-template-columns:1fr}}
|
|
2734
|
-
`.trim();
|
|
2735
|
-
//#endregion
|
|
2736
2201
|
//#region src/ports/bootstrap.ts
|
|
2737
2202
|
var BootstrapError = class extends Data.TaggedError("BootstrapError") {};
|
|
2738
2203
|
function bootstrapErrorFromCapxul(kind, error) {
|
|
@@ -2774,7 +2239,7 @@ var HttpBootstrapAdapter = class {
|
|
|
2774
2239
|
body: JSON.stringify({ publishableKey: input.publishableKey })
|
|
2775
2240
|
});
|
|
2776
2241
|
},
|
|
2777
|
-
catch: (cause) => bootstrapErrorFromCapxul("network", Errors.networkError("bootstrap", cause))
|
|
2242
|
+
catch: (cause) => bootstrapErrorFromCapxul("network", Errors$1.networkError("bootstrap", cause))
|
|
2778
2243
|
}).pipe(Effect.flatMap((res) => this.mapResponse(res)));
|
|
2779
2244
|
}
|
|
2780
2245
|
mapResponse(res) {
|
|
@@ -2782,7 +2247,7 @@ var HttpBootstrapAdapter = class {
|
|
|
2782
2247
|
try: async () => {
|
|
2783
2248
|
const body = await res.json();
|
|
2784
2249
|
const decoded = Schema.decodeUnknownEither(BootstrapEnvelope)(body);
|
|
2785
|
-
if (Either.isLeft(decoded)) throw Errors.invalidInput("bootstrapEnvelope", decoded.left.message);
|
|
2250
|
+
if (Either.isLeft(decoded)) throw Errors$1.invalidInput("bootstrapEnvelope", decoded.left.message);
|
|
2786
2251
|
const { state } = decoded.right;
|
|
2787
2252
|
return {
|
|
2788
2253
|
applicationId: state.applicationId,
|
|
@@ -2798,14 +2263,14 @@ var HttpBootstrapAdapter = class {
|
|
|
2798
2263
|
};
|
|
2799
2264
|
},
|
|
2800
2265
|
catch: (cause) => {
|
|
2801
|
-
if (cause instanceof CapxulError && cause.code === "INVALID_INPUT") return bootstrapErrorFromCapxul("invalidInput", cause);
|
|
2802
|
-
return bootstrapErrorFromCapxul("malformedBody", Errors.providerError("convex", "bootstrap", cause instanceof Error ? cause : new Error(String(cause))));
|
|
2266
|
+
if (cause instanceof CapxulError$2 && cause.code === "INVALID_INPUT") return bootstrapErrorFromCapxul("invalidInput", cause);
|
|
2267
|
+
return bootstrapErrorFromCapxul("malformedBody", Errors$1.providerError("convex", "bootstrap", cause instanceof Error ? cause : new Error(String(cause))));
|
|
2803
2268
|
}
|
|
2804
2269
|
});
|
|
2805
2270
|
return Effect.promise(() => safeText(res)).pipe(Effect.flatMap((body) => {
|
|
2806
|
-
if (res.status === 401 || body.startsWith("NOT_AUTHENTICATED")) return Effect.fail(bootstrapErrorFromCapxul("notAuthenticated", Errors.notAuthenticated()));
|
|
2807
|
-
if (res.status === 400 || body.startsWith("INVALID_INPUT")) return Effect.fail(bootstrapErrorFromCapxul("invalidInput", Errors.invalidInput("publishableKey", "rejected by bootstrap")));
|
|
2808
|
-
return Effect.fail(bootstrapErrorFromCapxul("provider", Errors.providerError("convex", "bootstrap", /* @__PURE__ */ new Error(`HTTP ${res.status}`))));
|
|
2271
|
+
if (res.status === 401 || body.startsWith("NOT_AUTHENTICATED")) return Effect.fail(bootstrapErrorFromCapxul("notAuthenticated", Errors$1.notAuthenticated()));
|
|
2272
|
+
if (res.status === 400 || body.startsWith("INVALID_INPUT")) return Effect.fail(bootstrapErrorFromCapxul("invalidInput", Errors$1.invalidInput("publishableKey", "rejected by bootstrap")));
|
|
2273
|
+
return Effect.fail(bootstrapErrorFromCapxul("provider", Errors$1.providerError("convex", "bootstrap", /* @__PURE__ */ new Error(`HTTP ${res.status}`))));
|
|
2809
2274
|
}));
|
|
2810
2275
|
}
|
|
2811
2276
|
};
|
|
@@ -2817,9 +2282,9 @@ function normalizeRuntimeUrl(field, raw) {
|
|
|
2817
2282
|
try {
|
|
2818
2283
|
parsed = new URL(raw);
|
|
2819
2284
|
} catch {
|
|
2820
|
-
throw Errors.invalidInput(field, "must be an http or https URL");
|
|
2285
|
+
throw Errors$1.invalidInput(field, "must be an http or https URL");
|
|
2821
2286
|
}
|
|
2822
|
-
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw Errors.invalidInput(field, "must be an http or https URL");
|
|
2287
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw Errors$1.invalidInput(field, "must be an http or https URL");
|
|
2823
2288
|
return parsed.toString().replace(/\/$/, "");
|
|
2824
2289
|
}
|
|
2825
2290
|
//#endregion
|
|
@@ -2923,12 +2388,12 @@ function ConvexCallLayer(deps) {
|
|
|
2923
2388
|
function mapToCapxulError(operation, err) {
|
|
2924
2389
|
const decoded = decodeConvexError(err);
|
|
2925
2390
|
if (decoded !== null) return decoded;
|
|
2926
|
-
if (err instanceof CapxulError) return err;
|
|
2391
|
+
if (err instanceof CapxulError$2) return err;
|
|
2927
2392
|
if (err instanceof Error) {
|
|
2928
|
-
if (isTransportError(err)) return Errors.networkError(operation, err);
|
|
2929
|
-
return Errors.providerError("convex", operation, err);
|
|
2393
|
+
if (isTransportError(err)) return Errors$1.networkError(operation, err);
|
|
2394
|
+
return Errors$1.providerError("convex", operation, err);
|
|
2930
2395
|
}
|
|
2931
|
-
return Errors.providerError("convex", operation, new Error(String(err)));
|
|
2396
|
+
return Errors$1.providerError("convex", operation, new Error(String(err)));
|
|
2932
2397
|
}
|
|
2933
2398
|
function mapToConvexCallError(operation, err) {
|
|
2934
2399
|
return convexCallErrorFromCapxul(operation, mapToCapxulError(operation, err));
|
|
@@ -3065,8 +2530,8 @@ function brandPublishableKeyRecord(row) {
|
|
|
3065
2530
|
};
|
|
3066
2531
|
}
|
|
3067
2532
|
function credentialsErrorFromUnknown(operation, cause) {
|
|
3068
|
-
if (cause instanceof CapxulError) return credentialsErrorFromCapxul(operation, cause);
|
|
3069
|
-
return credentialsErrorFromCapxul(operation, Errors.providerError("credentials", operation, cause instanceof Error ? cause : new Error(String(cause))), cause);
|
|
2533
|
+
if (cause instanceof CapxulError$2) return credentialsErrorFromCapxul(operation, cause);
|
|
2534
|
+
return credentialsErrorFromCapxul(operation, Errors$1.providerError("credentials", operation, cause instanceof Error ? cause : new Error(String(cause))), cause);
|
|
3070
2535
|
}
|
|
3071
2536
|
//#endregion
|
|
3072
2537
|
//#region src/ports/env.ts
|
|
@@ -3382,7 +2847,7 @@ function schemaFor(kind) {
|
|
|
3382
2847
|
}, { message: () => "Invalid url" }));
|
|
3383
2848
|
default: {
|
|
3384
2849
|
const unsupported = kind;
|
|
3385
|
-
throw Errors.invalidInput(String(unsupported), "unsupported environment field kind");
|
|
2850
|
+
throw Errors$1.invalidInput(String(unsupported), "unsupported environment field kind");
|
|
3386
2851
|
}
|
|
3387
2852
|
}
|
|
3388
2853
|
}
|
|
@@ -3391,14 +2856,14 @@ const envShapeSchema = Schema.Struct(envShapeFields);
|
|
|
3391
2856
|
Schema.partial(envShapeSchema);
|
|
3392
2857
|
function parseEnvValue$1(key, raw, required) {
|
|
3393
2858
|
const field = envFields[key];
|
|
3394
|
-
if (field === void 0) throw Errors.invalidInput(key, "unknown environment key");
|
|
2859
|
+
if (field === void 0) throw Errors$1.invalidInput(key, "unknown environment key");
|
|
3395
2860
|
const normalized = normalizeEnvRaw(raw);
|
|
3396
2861
|
if (normalized === void 0) {
|
|
3397
|
-
if (required) throw Errors.envMissing(key);
|
|
2862
|
+
if (required) throw Errors$1.envMissing(key);
|
|
3398
2863
|
return;
|
|
3399
2864
|
}
|
|
3400
2865
|
const result = Schema.decodeUnknownEither(schemaFor(field.kind))(normalized);
|
|
3401
|
-
if (Either.isLeft(result)) throw Errors.invalidInput(key, TreeFormatter.formatErrorSync(result.left));
|
|
2866
|
+
if (Either.isLeft(result)) throw Errors$1.invalidInput(key, TreeFormatter.formatErrorSync(result.left));
|
|
3402
2867
|
return result.right;
|
|
3403
2868
|
}
|
|
3404
2869
|
function normalizeEnvRaw(raw) {
|
|
@@ -3414,14 +2879,14 @@ function parseEnvValue(key, raw, required) {
|
|
|
3414
2879
|
return parseEnvValue$1(key, raw, required);
|
|
3415
2880
|
}
|
|
3416
2881
|
function hasEnvValue(key, raw) {
|
|
3417
|
-
if (envFields[key] === void 0) throw envErrorFromCapxul(key, Errors.invalidInput(key, "unknown environment key"));
|
|
2882
|
+
if (envFields[key] === void 0) throw envErrorFromCapxul(key, Errors$1.invalidInput(key, "unknown environment key"));
|
|
3418
2883
|
return normalizeEnvRaw(raw) !== void 0;
|
|
3419
2884
|
}
|
|
3420
2885
|
function catchEnvError(key, cause) {
|
|
3421
2886
|
if (cause instanceof EnvError) return cause;
|
|
3422
|
-
if (isCapxulError(cause)) return envErrorFromCapxul(key, cause, cause);
|
|
2887
|
+
if (isCapxulError$2(cause)) return envErrorFromCapxul(key, cause, cause);
|
|
3423
2888
|
const redactedCause = /* @__PURE__ */ new Error(`env ${key} read failed`);
|
|
3424
|
-
return envErrorFromCapxul(key, Errors.providerError("env", key, redactedCause), redactedCause);
|
|
2889
|
+
return envErrorFromCapxul(key, Errors$1.providerError("env", key, redactedCause), redactedCause);
|
|
3425
2890
|
}
|
|
3426
2891
|
//#endregion
|
|
3427
2892
|
//#region src/adapters/env/SystemEnvAdapter.ts
|
|
@@ -3510,8 +2975,8 @@ function brandProfile(raw) {
|
|
|
3510
2975
|
};
|
|
3511
2976
|
}
|
|
3512
2977
|
function identityErrorFromUnknown(operation, cause) {
|
|
3513
|
-
if (cause instanceof CapxulError) return identityErrorFromCapxul(operation, cause);
|
|
3514
|
-
return identityErrorFromCapxul(operation, Errors.providerError("convex", operation, cause), cause);
|
|
2978
|
+
if (cause instanceof CapxulError$2) return identityErrorFromCapxul(operation, cause);
|
|
2979
|
+
return identityErrorFromCapxul(operation, Errors$1.providerError("convex", operation, cause), cause);
|
|
3515
2980
|
}
|
|
3516
2981
|
//#endregion
|
|
3517
2982
|
//#region src/money/to-wei.ts
|
|
@@ -3600,8 +3065,8 @@ function brandAccount(wire) {
|
|
|
3600
3065
|
};
|
|
3601
3066
|
}
|
|
3602
3067
|
function accountReadErrorFromUnknown(operation, cause) {
|
|
3603
|
-
if (cause instanceof CapxulError) return accountReadErrorFromCapxul(operation, cause);
|
|
3604
|
-
return accountReadErrorFromCapxul(operation, Errors.providerError("convex", operation, cause), cause);
|
|
3068
|
+
if (cause instanceof CapxulError$2) return accountReadErrorFromCapxul(operation, cause);
|
|
3069
|
+
return accountReadErrorFromCapxul(operation, Errors$1.providerError("convex", operation, cause), cause);
|
|
3605
3070
|
}
|
|
3606
3071
|
//#endregion
|
|
3607
3072
|
//#region src/ports/sub-account.ts
|
|
@@ -3699,8 +3164,8 @@ function brandSubAccount(wire) {
|
|
|
3699
3164
|
};
|
|
3700
3165
|
}
|
|
3701
3166
|
function subAccountErrorFromUnknown(operation, cause) {
|
|
3702
|
-
if (cause instanceof CapxulError) return subAccountErrorFromCapxul(operation, cause);
|
|
3703
|
-
return subAccountErrorFromCapxul(operation, Errors.providerError("convex", operation, cause), cause);
|
|
3167
|
+
if (cause instanceof CapxulError$2) return subAccountErrorFromCapxul(operation, cause);
|
|
3168
|
+
return subAccountErrorFromCapxul(operation, Errors$1.providerError("convex", operation, cause), cause);
|
|
3704
3169
|
}
|
|
3705
3170
|
//#endregion
|
|
3706
3171
|
//#region src/ports/smart-account.ts
|
|
@@ -3794,705 +3259,16 @@ function brandNonNullSmartAccount(wire) {
|
|
|
3794
3259
|
};
|
|
3795
3260
|
}
|
|
3796
3261
|
function brandProvisionedSmartAccount(requestedAuthUserId, wire) {
|
|
3797
|
-
if (wire.authUserId !== String(requestedAuthUserId)) throw Errors.notAuthenticated();
|
|
3262
|
+
if (wire.authUserId !== String(requestedAuthUserId)) throw Errors$1.notAuthenticated();
|
|
3798
3263
|
return brandNonNullSmartAccount(wire);
|
|
3799
3264
|
}
|
|
3800
3265
|
function smartAccountErrorFromUnknown(operation, cause) {
|
|
3801
|
-
if (cause instanceof CapxulError) return smartAccountErrorFromCapxul(operation, cause);
|
|
3802
|
-
return smartAccountErrorFromCapxul(operation, Errors.providerError("convex", operation, cause), cause);
|
|
3266
|
+
if (cause instanceof CapxulError$2) return smartAccountErrorFromCapxul(operation, cause);
|
|
3267
|
+
return smartAccountErrorFromCapxul(operation, Errors$1.providerError("convex", operation, cause), cause);
|
|
3803
3268
|
}
|
|
3804
3269
|
toAddress("0xa6b71e26c5e0845f74c812102ca7114b6a896ab2");
|
|
3805
3270
|
keccak256("0x");
|
|
3806
3271
|
//#endregion
|
|
3807
|
-
//#region ../observability/src/index.ts
|
|
3808
|
-
const PII = Schema.String.pipe(Schema.brand("PII"));
|
|
3809
|
-
const OptionalString = Schema.optional(Schema.String);
|
|
3810
|
-
const AddressSchema = Schema.String.pipe(Schema.transform(Schema.String, {
|
|
3811
|
-
decode: (value) => value.toLowerCase(),
|
|
3812
|
-
encode: (value) => value
|
|
3813
|
-
}), Schema.filter((value) => EVM_ADDRESS_RE$1.test(value), { message: () => "must be 0x + 40 hex chars" }));
|
|
3814
|
-
const AppIdSchema = Schema.String.pipe(Schema.filter((value) => APP_ID_RE.test(value), { message: () => "must be app_ plus a ULID" }));
|
|
3815
|
-
const BlockNumberSchema = Schema.Number.pipe(Schema.filter((value) => Number.isSafeInteger(value) && value >= 0, { message: () => "must be a non-negative safe integer" }));
|
|
3816
|
-
const ChainIdSchema = Schema.Number.pipe(Schema.filter((value) => Number.isSafeInteger(value) && value > 0, { message: () => "must be a positive safe integer" }));
|
|
3817
|
-
const DurationMsSchema = Schema.Number.pipe(Schema.filter((value) => Number.isSafeInteger(value) && value >= 0, { message: () => "must be a non-negative safe integer" }));
|
|
3818
|
-
const EpochMsSchema = Schema.Number.pipe(Schema.filter((value) => Number.isSafeInteger(value) && value >= 0, { message: () => "must be a non-negative safe integer" }));
|
|
3819
|
-
const PublishableKeyIdSchema = Schema.String.pipe(Schema.filter((value) => value.length > 0, { message: () => "must be a non-empty string" }));
|
|
3820
|
-
const TxHashSchema = Schema.String.pipe(Schema.filter((value) => BYTES32_RE.test(value), { message: () => "must be 0x + 64 hex chars" }));
|
|
3821
|
-
const ACCOUNT_ID_TELEMETRY_RE = /^account_[0-9A-Za-z]+$/;
|
|
3822
|
-
const SUBACCOUNT_ID_TELEMETRY_RE = /^subaccount_[0-9A-Za-z]+$/;
|
|
3823
|
-
const WEI_AMOUNT_TELEMETRY_RE = /^[0-9]+$/;
|
|
3824
|
-
const AccountIdSchema = Schema.String.pipe(Schema.filter((value) => ACCOUNT_ID_TELEMETRY_RE.test(value), { message: () => "must be account_ plus an alphanumeric id" }));
|
|
3825
|
-
const SubAccountIdSchema = Schema.String.pipe(Schema.filter((value) => SUBACCOUNT_ID_TELEMETRY_RE.test(value), { message: () => "must be subaccount_ plus an alphanumeric id" }));
|
|
3826
|
-
const WeiAmountSchema = Schema.String.pipe(Schema.filter((value) => WEI_AMOUNT_TELEMETRY_RE.test(value), { message: () => "must be a non-negative integer string" }));
|
|
3827
|
-
const CurrencyCodeSchema = Schema.String.pipe(Schema.filter((value) => value.length > 0, { message: () => "must be a non-empty currency code" }));
|
|
3828
|
-
const BalanceBucketSchema = Schema.Literal("zero", "nonzero");
|
|
3829
|
-
const TransferDirectionSchema = Schema.Literal("add", "out", "between");
|
|
3830
|
-
const SubAccountOpSchema = Schema.Literal("create", "rename", "delete");
|
|
3831
|
-
const OptionalAccountId = Schema.optional(AccountIdSchema);
|
|
3832
|
-
const OptionalSubAccountId = Schema.optional(SubAccountIdSchema);
|
|
3833
|
-
const OptionalWeiAmount = Schema.optional(WeiAmountSchema);
|
|
3834
|
-
const OptionalCurrencyCode = Schema.optional(CurrencyCodeSchema);
|
|
3835
|
-
const OptionalBalanceBucket = Schema.optional(BalanceBucketSchema);
|
|
3836
|
-
const OptionalTransferDirection = Schema.optional(TransferDirectionSchema);
|
|
3837
|
-
const OptionalSubAccountOp = Schema.optional(SubAccountOpSchema);
|
|
3838
|
-
const OptionalTrue = Schema.optional(Schema.Literal(true));
|
|
3839
|
-
const OptionalAddress = Schema.optional(AddressSchema);
|
|
3840
|
-
const OptionalAppId = Schema.optional(AppIdSchema);
|
|
3841
|
-
const OptionalBlockNumber = Schema.optional(BlockNumberSchema);
|
|
3842
|
-
const OptionalChainId = Schema.optional(ChainIdSchema);
|
|
3843
|
-
const OptionalDurationMs = Schema.optional(DurationMsSchema);
|
|
3844
|
-
const OptionalEpochMs = Schema.optional(EpochMsSchema);
|
|
3845
|
-
const OptionalPublishableKeyId = Schema.optional(PublishableKeyIdSchema);
|
|
3846
|
-
const OptionalTxHash = Schema.optional(TxHashSchema);
|
|
3847
|
-
const PAYMENT_ID_TELEMETRY_RE = /^payment_[0-9A-Za-z]+$/;
|
|
3848
|
-
const PAYEE_ID_TELEMETRY_RE = /^payee_[0-9A-Za-z]+$/;
|
|
3849
|
-
const PaymentIdTelemetrySchema = Schema.String.pipe(Schema.filter((value) => PAYMENT_ID_TELEMETRY_RE.test(value), { message: () => "must be payment_ plus an alphanumeric id" }));
|
|
3850
|
-
const PayeeIdTelemetrySchema = Schema.String.pipe(Schema.filter((value) => PAYEE_ID_TELEMETRY_RE.test(value), { message: () => "must be payee_ plus an alphanumeric id" }));
|
|
3851
|
-
const DocumentHashSchema = Schema.String.pipe(Schema.filter((value) => BYTES32_RE.test(value), { message: () => "must be 0x + 64 hex chars" }));
|
|
3852
|
-
const TelemetryEnvelopeProps = {
|
|
3853
|
-
capxul_e2e_run_id: OptionalString,
|
|
3854
|
-
correlationId: OptionalString,
|
|
3855
|
-
capxulEnv: OptionalString,
|
|
3856
|
-
sdkVersion: OptionalString,
|
|
3857
|
-
producer: OptionalString
|
|
3858
|
-
};
|
|
3859
|
-
const AuthOtpRequestedProps = Schema.Struct({
|
|
3860
|
-
...TelemetryEnvelopeProps,
|
|
3861
|
-
email: Schema.optional(PII),
|
|
3862
|
-
email_domain: OptionalString
|
|
3863
|
-
});
|
|
3864
|
-
const AuthOtpDeliveredProps = Schema.Struct({
|
|
3865
|
-
...TelemetryEnvelopeProps,
|
|
3866
|
-
durationMs: OptionalDurationMs,
|
|
3867
|
-
email: Schema.optional(PII),
|
|
3868
|
-
email_domain: OptionalString,
|
|
3869
|
-
resendMessageId: OptionalString
|
|
3870
|
-
});
|
|
3871
|
-
const AuthOtpExpiredProps = Schema.Struct({
|
|
3872
|
-
...TelemetryEnvelopeProps,
|
|
3873
|
-
email: Schema.optional(PII),
|
|
3874
|
-
email_domain: OptionalString
|
|
3875
|
-
});
|
|
3876
|
-
const AuthVerifiedProps = Schema.Struct({
|
|
3877
|
-
...TelemetryEnvelopeProps,
|
|
3878
|
-
auth_type: OptionalString
|
|
3879
|
-
});
|
|
3880
|
-
const AuthFailedProps = Schema.Struct({
|
|
3881
|
-
...TelemetryEnvelopeProps,
|
|
3882
|
-
email: Schema.optional(PII),
|
|
3883
|
-
auth_type: OptionalString,
|
|
3884
|
-
reason: OptionalString
|
|
3885
|
-
});
|
|
3886
|
-
const AuthSignedOutProps = Schema.Struct(TelemetryEnvelopeProps);
|
|
3887
|
-
const ProvisioningSafeCreatedProps = Schema.Struct({
|
|
3888
|
-
...TelemetryEnvelopeProps,
|
|
3889
|
-
safe_address: OptionalAddress
|
|
3890
|
-
});
|
|
3891
|
-
const ProvisioningSafeConfirmedProps = Schema.Struct({
|
|
3892
|
-
...TelemetryEnvelopeProps,
|
|
3893
|
-
chainId: OptionalChainId,
|
|
3894
|
-
deployedAt: OptionalEpochMs,
|
|
3895
|
-
deployedAtBlock: OptionalBlockNumber,
|
|
3896
|
-
deployTxHash: OptionalTxHash,
|
|
3897
|
-
durationMs: OptionalDurationMs,
|
|
3898
|
-
safe_address: OptionalAddress,
|
|
3899
|
-
userOpHash: OptionalTxHash
|
|
3900
|
-
});
|
|
3901
|
-
const BootstrapResolvedProps = Schema.Struct({
|
|
3902
|
-
...TelemetryEnvelopeProps,
|
|
3903
|
-
applicationId: OptionalAppId,
|
|
3904
|
-
durationMs: OptionalDurationMs,
|
|
3905
|
-
env: OptionalString,
|
|
3906
|
-
keyId: OptionalPublishableKeyId,
|
|
3907
|
-
origin: OptionalString
|
|
3908
|
-
});
|
|
3909
|
-
const BootstrapFailedProps = Schema.Struct({
|
|
3910
|
-
...TelemetryEnvelopeProps,
|
|
3911
|
-
applicationId: OptionalAppId,
|
|
3912
|
-
durationMs: OptionalDurationMs,
|
|
3913
|
-
origin: OptionalString,
|
|
3914
|
-
reason: OptionalString
|
|
3915
|
-
});
|
|
3916
|
-
const AccountBalanceReadProps = Schema.Struct({
|
|
3917
|
-
...TelemetryEnvelopeProps,
|
|
3918
|
-
account_id: OptionalAccountId,
|
|
3919
|
-
currency: OptionalCurrencyCode,
|
|
3920
|
-
balance_bucket: OptionalBalanceBucket,
|
|
3921
|
-
durationMs: OptionalDurationMs
|
|
3922
|
-
});
|
|
3923
|
-
const AccountBalanceFailedProps = Schema.Struct({
|
|
3924
|
-
...TelemetryEnvelopeProps,
|
|
3925
|
-
reason: OptionalString
|
|
3926
|
-
});
|
|
3927
|
-
const FaucetRequestedProps = Schema.Struct({
|
|
3928
|
-
...TelemetryEnvelopeProps,
|
|
3929
|
-
amount: OptionalWeiAmount,
|
|
3930
|
-
chainId: OptionalChainId
|
|
3931
|
-
});
|
|
3932
|
-
const FaucetConfirmedProps = Schema.Struct({
|
|
3933
|
-
...TelemetryEnvelopeProps,
|
|
3934
|
-
amount: OptionalWeiAmount,
|
|
3935
|
-
chainId: OptionalChainId,
|
|
3936
|
-
txHash: OptionalTxHash,
|
|
3937
|
-
durationMs: OptionalDurationMs
|
|
3938
|
-
});
|
|
3939
|
-
const FaucetFailedProps = Schema.Struct({
|
|
3940
|
-
...TelemetryEnvelopeProps,
|
|
3941
|
-
reason: OptionalString
|
|
3942
|
-
});
|
|
3943
|
-
const SubaccountCreatedProps = Schema.Struct({
|
|
3944
|
-
...TelemetryEnvelopeProps,
|
|
3945
|
-
sub_account_id: OptionalSubAccountId,
|
|
3946
|
-
durationMs: OptionalDurationMs
|
|
3947
|
-
});
|
|
3948
|
-
const SubaccountRenamedProps = Schema.Struct({
|
|
3949
|
-
...TelemetryEnvelopeProps,
|
|
3950
|
-
sub_account_id: OptionalSubAccountId
|
|
3951
|
-
});
|
|
3952
|
-
const SubaccountDeletedProps = Schema.Struct({
|
|
3953
|
-
...TelemetryEnvelopeProps,
|
|
3954
|
-
sub_account_id: OptionalSubAccountId
|
|
3955
|
-
});
|
|
3956
|
-
const SubaccountOpFailedProps = Schema.Struct({
|
|
3957
|
-
...TelemetryEnvelopeProps,
|
|
3958
|
-
op: OptionalSubAccountOp,
|
|
3959
|
-
reason: OptionalString
|
|
3960
|
-
});
|
|
3961
|
-
const TransferRequestedProps = Schema.Struct({
|
|
3962
|
-
...TelemetryEnvelopeProps,
|
|
3963
|
-
amount: OptionalWeiAmount,
|
|
3964
|
-
direction: OptionalTransferDirection
|
|
3965
|
-
});
|
|
3966
|
-
const TransferConfirmedProps = Schema.Struct({
|
|
3967
|
-
...TelemetryEnvelopeProps,
|
|
3968
|
-
amount: OptionalWeiAmount,
|
|
3969
|
-
direction: OptionalTransferDirection,
|
|
3970
|
-
available_bucket: OptionalBalanceBucket,
|
|
3971
|
-
txless: OptionalTrue,
|
|
3972
|
-
durationMs: OptionalDurationMs
|
|
3973
|
-
});
|
|
3974
|
-
const TransferFailedProps = Schema.Struct({
|
|
3975
|
-
...TelemetryEnvelopeProps,
|
|
3976
|
-
reason: OptionalString
|
|
3977
|
-
});
|
|
3978
|
-
const ORG_ID_TELEMETRY_RE = /^org_[0-9A-Za-z]+$/;
|
|
3979
|
-
const OrgIdTelemetrySchema = Schema.String.pipe(Schema.filter((value) => ORG_ID_TELEMETRY_RE.test(value), { message: () => "must be org_ plus an alphanumeric id" }));
|
|
3980
|
-
const OptionalOrgId = Schema.optional(OrgIdTelemetrySchema);
|
|
3981
|
-
const OrgCreateStartedProps = Schema.Struct({
|
|
3982
|
-
...TelemetryEnvelopeProps,
|
|
3983
|
-
org_id: OptionalOrgId,
|
|
3984
|
-
email_domain: OptionalString,
|
|
3985
|
-
template: OptionalString
|
|
3986
|
-
});
|
|
3987
|
-
const OrgSafeCreatedProps = Schema.Struct({
|
|
3988
|
-
...TelemetryEnvelopeProps,
|
|
3989
|
-
org_id: OptionalOrgId,
|
|
3990
|
-
chainId: OptionalChainId,
|
|
3991
|
-
safe_address: OptionalAddress
|
|
3992
|
-
});
|
|
3993
|
-
const OrgSafeConfirmedProps = Schema.Struct({
|
|
3994
|
-
...TelemetryEnvelopeProps,
|
|
3995
|
-
org_id: OptionalOrgId,
|
|
3996
|
-
chainId: OptionalChainId,
|
|
3997
|
-
safe_address: OptionalAddress,
|
|
3998
|
-
durationMs: OptionalDurationMs
|
|
3999
|
-
});
|
|
4000
|
-
const OrgRolesSeededProps = Schema.Struct({
|
|
4001
|
-
...TelemetryEnvelopeProps,
|
|
4002
|
-
org_id: OptionalOrgId,
|
|
4003
|
-
chainId: OptionalChainId,
|
|
4004
|
-
role: OptionalString,
|
|
4005
|
-
txHash: OptionalTxHash
|
|
4006
|
-
});
|
|
4007
|
-
const OrgCreatedProps = Schema.Struct({
|
|
4008
|
-
...TelemetryEnvelopeProps,
|
|
4009
|
-
org_id: OptionalOrgId,
|
|
4010
|
-
chainId: OptionalChainId,
|
|
4011
|
-
safe_address: OptionalAddress,
|
|
4012
|
-
durationMs: OptionalDurationMs
|
|
4013
|
-
});
|
|
4014
|
-
const OrgCreateFailedProps = Schema.Struct({
|
|
4015
|
-
...TelemetryEnvelopeProps,
|
|
4016
|
-
org_id: OptionalOrgId,
|
|
4017
|
-
reason: OptionalString
|
|
4018
|
-
});
|
|
4019
|
-
const OrgInviteSentProps = Schema.Struct({
|
|
4020
|
-
...TelemetryEnvelopeProps,
|
|
4021
|
-
org_id: OptionalOrgId,
|
|
4022
|
-
email_domain: OptionalString,
|
|
4023
|
-
role: OptionalString,
|
|
4024
|
-
status: OptionalString
|
|
4025
|
-
});
|
|
4026
|
-
const OrgInviteAcceptedProps = Schema.Struct({
|
|
4027
|
-
...TelemetryEnvelopeProps,
|
|
4028
|
-
org_id: OptionalOrgId,
|
|
4029
|
-
role: OptionalString,
|
|
4030
|
-
status: OptionalString
|
|
4031
|
-
});
|
|
4032
|
-
const OrgRoleGrantedProps = Schema.Struct({
|
|
4033
|
-
...TelemetryEnvelopeProps,
|
|
4034
|
-
org_id: OptionalOrgId,
|
|
4035
|
-
role: OptionalString,
|
|
4036
|
-
status: OptionalString,
|
|
4037
|
-
txHash: OptionalTxHash
|
|
4038
|
-
});
|
|
4039
|
-
const OrgMemberActiveProps = Schema.Struct({
|
|
4040
|
-
...TelemetryEnvelopeProps,
|
|
4041
|
-
org_id: OptionalOrgId,
|
|
4042
|
-
role: OptionalString,
|
|
4043
|
-
status: OptionalString,
|
|
4044
|
-
durationMs: OptionalDurationMs
|
|
4045
|
-
});
|
|
4046
|
-
const OrgMemberRemovedProps = Schema.Struct({
|
|
4047
|
-
...TelemetryEnvelopeProps,
|
|
4048
|
-
org_id: OptionalOrgId,
|
|
4049
|
-
role: OptionalString,
|
|
4050
|
-
status: OptionalString,
|
|
4051
|
-
txHash: OptionalTxHash
|
|
4052
|
-
});
|
|
4053
|
-
const OrgInviteExpiredProps = Schema.Struct({
|
|
4054
|
-
...TelemetryEnvelopeProps,
|
|
4055
|
-
org_id: OptionalOrgId,
|
|
4056
|
-
email_domain: OptionalString,
|
|
4057
|
-
reason: OptionalString,
|
|
4058
|
-
role: OptionalString,
|
|
4059
|
-
status: OptionalString
|
|
4060
|
-
});
|
|
4061
|
-
const OrgRoleGrantFailedProps = Schema.Struct({
|
|
4062
|
-
...TelemetryEnvelopeProps,
|
|
4063
|
-
org_id: OptionalOrgId,
|
|
4064
|
-
reason: OptionalString,
|
|
4065
|
-
role: OptionalString
|
|
4066
|
-
});
|
|
4067
|
-
const OptionalPaymentId = Schema.optional(PaymentIdTelemetrySchema);
|
|
4068
|
-
const OptionalPayeeId = Schema.optional(PayeeIdTelemetrySchema);
|
|
4069
|
-
const OptionalDocumentHash = Schema.optional(DocumentHashSchema);
|
|
4070
|
-
const PaymentTargetTelemetryProps = Schema.Struct({
|
|
4071
|
-
...TelemetryEnvelopeProps,
|
|
4072
|
-
payment_id: OptionalPaymentId,
|
|
4073
|
-
payee_id: OptionalPayeeId,
|
|
4074
|
-
document_hash: OptionalDocumentHash,
|
|
4075
|
-
amount: OptionalWeiAmount,
|
|
4076
|
-
currency: OptionalCurrencyCode,
|
|
4077
|
-
status: OptionalString,
|
|
4078
|
-
reason: OptionalString,
|
|
4079
|
-
durationMs: OptionalDurationMs
|
|
4080
|
-
});
|
|
4081
|
-
const StreamTargetTelemetryProps = Schema.Struct({
|
|
4082
|
-
...TelemetryEnvelopeProps,
|
|
4083
|
-
payment_id: OptionalPaymentId,
|
|
4084
|
-
document_hash: OptionalDocumentHash,
|
|
4085
|
-
amount: OptionalWeiAmount,
|
|
4086
|
-
currency: OptionalCurrencyCode,
|
|
4087
|
-
status: OptionalString,
|
|
4088
|
-
available_bucket: OptionalBalanceBucket,
|
|
4089
|
-
reason: OptionalString,
|
|
4090
|
-
durationMs: OptionalDurationMs
|
|
4091
|
-
});
|
|
4092
|
-
const WithdrawalTargetTelemetryProps = Schema.Struct({
|
|
4093
|
-
...TelemetryEnvelopeProps,
|
|
4094
|
-
payment_id: OptionalPaymentId,
|
|
4095
|
-
document_hash: OptionalDocumentHash,
|
|
4096
|
-
amount: OptionalWeiAmount,
|
|
4097
|
-
currency: OptionalCurrencyCode,
|
|
4098
|
-
status: OptionalString,
|
|
4099
|
-
reason: OptionalString,
|
|
4100
|
-
durationMs: OptionalDurationMs
|
|
4101
|
-
});
|
|
4102
|
-
Schema.Struct({
|
|
4103
|
-
name: Schema.Literal("auth_otp_requested"),
|
|
4104
|
-
props: Schema.optional(AuthOtpRequestedProps)
|
|
4105
|
-
});
|
|
4106
|
-
Schema.Struct({
|
|
4107
|
-
name: Schema.Literal("auth_otp_delivered"),
|
|
4108
|
-
props: Schema.optional(AuthOtpDeliveredProps)
|
|
4109
|
-
});
|
|
4110
|
-
Schema.Struct({
|
|
4111
|
-
name: Schema.Literal("auth_otp_expired"),
|
|
4112
|
-
props: Schema.optional(AuthOtpExpiredProps)
|
|
4113
|
-
});
|
|
4114
|
-
Schema.Struct({
|
|
4115
|
-
name: Schema.Literal("auth_verified"),
|
|
4116
|
-
props: Schema.optional(AuthVerifiedProps)
|
|
4117
|
-
});
|
|
4118
|
-
Schema.Struct({
|
|
4119
|
-
name: Schema.Literal("auth_failed"),
|
|
4120
|
-
props: Schema.optional(AuthFailedProps)
|
|
4121
|
-
});
|
|
4122
|
-
Schema.Struct({
|
|
4123
|
-
name: Schema.Literal("auth_signed_out"),
|
|
4124
|
-
props: Schema.optional(AuthSignedOutProps)
|
|
4125
|
-
});
|
|
4126
|
-
Schema.Struct({
|
|
4127
|
-
name: Schema.Literal("provisioning_safe_created"),
|
|
4128
|
-
props: Schema.optional(ProvisioningSafeCreatedProps)
|
|
4129
|
-
});
|
|
4130
|
-
Schema.Struct({
|
|
4131
|
-
name: Schema.Literal("provisioning_safe_confirmed"),
|
|
4132
|
-
props: Schema.optional(ProvisioningSafeConfirmedProps)
|
|
4133
|
-
});
|
|
4134
|
-
Schema.Struct({
|
|
4135
|
-
name: Schema.Literal("bootstrap_resolved"),
|
|
4136
|
-
props: Schema.optional(BootstrapResolvedProps)
|
|
4137
|
-
});
|
|
4138
|
-
Schema.Struct({
|
|
4139
|
-
name: Schema.Literal("bootstrap_failed"),
|
|
4140
|
-
props: Schema.optional(BootstrapFailedProps)
|
|
4141
|
-
});
|
|
4142
|
-
Schema.Struct({
|
|
4143
|
-
name: Schema.Literal("account_balance_read"),
|
|
4144
|
-
props: Schema.optional(AccountBalanceReadProps)
|
|
4145
|
-
});
|
|
4146
|
-
Schema.Struct({
|
|
4147
|
-
name: Schema.Literal("account_balance_failed"),
|
|
4148
|
-
props: Schema.optional(AccountBalanceFailedProps)
|
|
4149
|
-
});
|
|
4150
|
-
Schema.Struct({
|
|
4151
|
-
name: Schema.Literal("faucet_requested"),
|
|
4152
|
-
props: Schema.optional(FaucetRequestedProps)
|
|
4153
|
-
});
|
|
4154
|
-
Schema.Struct({
|
|
4155
|
-
name: Schema.Literal("faucet_confirmed"),
|
|
4156
|
-
props: Schema.optional(FaucetConfirmedProps)
|
|
4157
|
-
});
|
|
4158
|
-
Schema.Struct({
|
|
4159
|
-
name: Schema.Literal("faucet_failed"),
|
|
4160
|
-
props: Schema.optional(FaucetFailedProps)
|
|
4161
|
-
});
|
|
4162
|
-
Schema.Struct({
|
|
4163
|
-
name: Schema.Literal("subaccount_created"),
|
|
4164
|
-
props: Schema.optional(SubaccountCreatedProps)
|
|
4165
|
-
});
|
|
4166
|
-
Schema.Struct({
|
|
4167
|
-
name: Schema.Literal("subaccount_renamed"),
|
|
4168
|
-
props: Schema.optional(SubaccountRenamedProps)
|
|
4169
|
-
});
|
|
4170
|
-
Schema.Struct({
|
|
4171
|
-
name: Schema.Literal("subaccount_deleted"),
|
|
4172
|
-
props: Schema.optional(SubaccountDeletedProps)
|
|
4173
|
-
});
|
|
4174
|
-
Schema.Struct({
|
|
4175
|
-
name: Schema.Literal("subaccount_op_failed"),
|
|
4176
|
-
props: Schema.optional(SubaccountOpFailedProps)
|
|
4177
|
-
});
|
|
4178
|
-
Schema.Struct({
|
|
4179
|
-
name: Schema.Literal("transfer_requested"),
|
|
4180
|
-
props: Schema.optional(TransferRequestedProps)
|
|
4181
|
-
});
|
|
4182
|
-
Schema.Struct({
|
|
4183
|
-
name: Schema.Literal("transfer_confirmed"),
|
|
4184
|
-
props: Schema.optional(TransferConfirmedProps)
|
|
4185
|
-
});
|
|
4186
|
-
Schema.Struct({
|
|
4187
|
-
name: Schema.Literal("transfer_failed"),
|
|
4188
|
-
props: Schema.optional(TransferFailedProps)
|
|
4189
|
-
});
|
|
4190
|
-
Schema.Struct({
|
|
4191
|
-
name: Schema.Literal("org_create_started"),
|
|
4192
|
-
props: Schema.optional(OrgCreateStartedProps)
|
|
4193
|
-
});
|
|
4194
|
-
Schema.Struct({
|
|
4195
|
-
name: Schema.Literal("org_safe_created"),
|
|
4196
|
-
props: Schema.optional(OrgSafeCreatedProps)
|
|
4197
|
-
});
|
|
4198
|
-
Schema.Struct({
|
|
4199
|
-
name: Schema.Literal("org_safe_confirmed"),
|
|
4200
|
-
props: Schema.optional(OrgSafeConfirmedProps)
|
|
4201
|
-
});
|
|
4202
|
-
Schema.Struct({
|
|
4203
|
-
name: Schema.Literal("org_roles_seeded"),
|
|
4204
|
-
props: Schema.optional(OrgRolesSeededProps)
|
|
4205
|
-
});
|
|
4206
|
-
Schema.Struct({
|
|
4207
|
-
name: Schema.Literal("org_created"),
|
|
4208
|
-
props: Schema.optional(OrgCreatedProps)
|
|
4209
|
-
});
|
|
4210
|
-
Schema.Struct({
|
|
4211
|
-
name: Schema.Literal("org_create_failed"),
|
|
4212
|
-
props: Schema.optional(OrgCreateFailedProps)
|
|
4213
|
-
});
|
|
4214
|
-
Schema.Struct({
|
|
4215
|
-
name: Schema.Literal("org_invite_sent"),
|
|
4216
|
-
props: Schema.optional(OrgInviteSentProps)
|
|
4217
|
-
});
|
|
4218
|
-
Schema.Struct({
|
|
4219
|
-
name: Schema.Literal("org_invite_accepted"),
|
|
4220
|
-
props: Schema.optional(OrgInviteAcceptedProps)
|
|
4221
|
-
});
|
|
4222
|
-
Schema.Struct({
|
|
4223
|
-
name: Schema.Literal("org_role_granted"),
|
|
4224
|
-
props: Schema.optional(OrgRoleGrantedProps)
|
|
4225
|
-
});
|
|
4226
|
-
Schema.Struct({
|
|
4227
|
-
name: Schema.Literal("org_member_active"),
|
|
4228
|
-
props: Schema.optional(OrgMemberActiveProps)
|
|
4229
|
-
});
|
|
4230
|
-
Schema.Struct({
|
|
4231
|
-
name: Schema.Literal("org_member_removed"),
|
|
4232
|
-
props: Schema.optional(OrgMemberRemovedProps)
|
|
4233
|
-
});
|
|
4234
|
-
Schema.Struct({
|
|
4235
|
-
name: Schema.Literal("org_invite_expired"),
|
|
4236
|
-
props: Schema.optional(OrgInviteExpiredProps)
|
|
4237
|
-
});
|
|
4238
|
-
Schema.Struct({
|
|
4239
|
-
name: Schema.Literal("org_role_grant_failed"),
|
|
4240
|
-
props: Schema.optional(OrgRoleGrantFailedProps)
|
|
4241
|
-
});
|
|
4242
|
-
Schema.Struct({
|
|
4243
|
-
name: Schema.Literal("payment_requested"),
|
|
4244
|
-
props: Schema.optional(PaymentTargetTelemetryProps)
|
|
4245
|
-
});
|
|
4246
|
-
Schema.Struct({
|
|
4247
|
-
name: Schema.Literal("payment_resolved"),
|
|
4248
|
-
props: Schema.optional(PaymentTargetTelemetryProps)
|
|
4249
|
-
});
|
|
4250
|
-
Schema.Struct({
|
|
4251
|
-
name: Schema.Literal("payment_document_attached"),
|
|
4252
|
-
props: Schema.optional(PaymentTargetTelemetryProps)
|
|
4253
|
-
});
|
|
4254
|
-
Schema.Struct({
|
|
4255
|
-
name: Schema.Literal("payment_submitted"),
|
|
4256
|
-
props: Schema.optional(PaymentTargetTelemetryProps)
|
|
4257
|
-
});
|
|
4258
|
-
Schema.Struct({
|
|
4259
|
-
name: Schema.Literal("payment_settled"),
|
|
4260
|
-
props: Schema.optional(PaymentTargetTelemetryProps)
|
|
4261
|
-
});
|
|
4262
|
-
Schema.Struct({
|
|
4263
|
-
name: Schema.Literal("payment_claimed"),
|
|
4264
|
-
props: Schema.optional(PaymentTargetTelemetryProps)
|
|
4265
|
-
});
|
|
4266
|
-
Schema.Struct({
|
|
4267
|
-
name: Schema.Literal("payment_cancelled"),
|
|
4268
|
-
props: Schema.optional(PaymentTargetTelemetryProps)
|
|
4269
|
-
});
|
|
4270
|
-
Schema.Struct({
|
|
4271
|
-
name: Schema.Literal("payment_redirected"),
|
|
4272
|
-
props: Schema.optional(PaymentTargetTelemetryProps)
|
|
4273
|
-
});
|
|
4274
|
-
Schema.Struct({
|
|
4275
|
-
name: Schema.Literal("payment_failed"),
|
|
4276
|
-
props: Schema.optional(PaymentTargetTelemetryProps)
|
|
4277
|
-
});
|
|
4278
|
-
Schema.Struct({
|
|
4279
|
-
name: Schema.Literal("stream_created"),
|
|
4280
|
-
props: Schema.optional(StreamTargetTelemetryProps)
|
|
4281
|
-
});
|
|
4282
|
-
Schema.Struct({
|
|
4283
|
-
name: Schema.Literal("stream_claimed"),
|
|
4284
|
-
props: Schema.optional(StreamTargetTelemetryProps)
|
|
4285
|
-
});
|
|
4286
|
-
Schema.Struct({
|
|
4287
|
-
name: Schema.Literal("stream_cancelled"),
|
|
4288
|
-
props: Schema.optional(StreamTargetTelemetryProps)
|
|
4289
|
-
});
|
|
4290
|
-
Schema.Struct({
|
|
4291
|
-
name: Schema.Literal("stream_completed"),
|
|
4292
|
-
props: Schema.optional(StreamTargetTelemetryProps)
|
|
4293
|
-
});
|
|
4294
|
-
Schema.Struct({
|
|
4295
|
-
name: Schema.Literal("stream_failed"),
|
|
4296
|
-
props: Schema.optional(StreamTargetTelemetryProps)
|
|
4297
|
-
});
|
|
4298
|
-
Schema.Struct({
|
|
4299
|
-
name: Schema.Literal("withdrawal_requested"),
|
|
4300
|
-
props: Schema.optional(WithdrawalTargetTelemetryProps)
|
|
4301
|
-
});
|
|
4302
|
-
Schema.Struct({
|
|
4303
|
-
name: Schema.Literal("withdrawal_submitted"),
|
|
4304
|
-
props: Schema.optional(WithdrawalTargetTelemetryProps)
|
|
4305
|
-
});
|
|
4306
|
-
Schema.Struct({
|
|
4307
|
-
name: Schema.Literal("withdrawal_settled"),
|
|
4308
|
-
props: Schema.optional(WithdrawalTargetTelemetryProps)
|
|
4309
|
-
});
|
|
4310
|
-
Schema.Struct({
|
|
4311
|
-
name: Schema.Literal("withdrawal_failed"),
|
|
4312
|
-
props: Schema.optional(WithdrawalTargetTelemetryProps)
|
|
4313
|
-
});
|
|
4314
|
-
function redactTelemetryProps(name, props, options = {}) {
|
|
4315
|
-
if (props === void 0) return void 0;
|
|
4316
|
-
const clone = cloneProps$1(props);
|
|
4317
|
-
if (options.rawMode === true) return clone;
|
|
4318
|
-
for (const key of PII_PROP_KEYS_BY_EVENT[name] ?? []) redactProperty(clone, key);
|
|
4319
|
-
return clone;
|
|
4320
|
-
}
|
|
4321
|
-
const PII_PROP_KEYS_BY_EVENT = {
|
|
4322
|
-
auth_otp_requested: ["email"],
|
|
4323
|
-
auth_otp_delivered: ["email"],
|
|
4324
|
-
auth_otp_expired: ["email"],
|
|
4325
|
-
auth_failed: ["email"]
|
|
4326
|
-
};
|
|
4327
|
-
function redactProperty(props, key) {
|
|
4328
|
-
const value = props[key];
|
|
4329
|
-
if (typeof value === "string") props[key] = sha256Hex(value).slice(0, 12);
|
|
4330
|
-
}
|
|
4331
|
-
function cloneProps$1(props) {
|
|
4332
|
-
const cloned = {};
|
|
4333
|
-
for (const [key, value] of Object.entries(props)) cloned[key] = cloneTelemetryValue$1(value);
|
|
4334
|
-
return cloned;
|
|
4335
|
-
}
|
|
4336
|
-
function cloneTelemetryValue$1(value) {
|
|
4337
|
-
if (Array.isArray(value)) return value.map(cloneTelemetryValue$1);
|
|
4338
|
-
if (value === null || typeof value !== "object") return value;
|
|
4339
|
-
if (Object.getPrototypeOf(value) !== Object.prototype) return value;
|
|
4340
|
-
const cloned = {};
|
|
4341
|
-
for (const [key, nested] of Object.entries(value)) cloned[key] = cloneTelemetryValue$1(nested);
|
|
4342
|
-
return cloned;
|
|
4343
|
-
}
|
|
4344
|
-
const SHA256_INITIAL_HASH = [
|
|
4345
|
-
1779033703,
|
|
4346
|
-
3144134277,
|
|
4347
|
-
1013904242,
|
|
4348
|
-
2773480762,
|
|
4349
|
-
1359893119,
|
|
4350
|
-
2600822924,
|
|
4351
|
-
528734635,
|
|
4352
|
-
1541459225
|
|
4353
|
-
];
|
|
4354
|
-
const SHA256_K = [
|
|
4355
|
-
1116352408,
|
|
4356
|
-
1899447441,
|
|
4357
|
-
3049323471,
|
|
4358
|
-
3921009573,
|
|
4359
|
-
961987163,
|
|
4360
|
-
1508970993,
|
|
4361
|
-
2453635748,
|
|
4362
|
-
2870763221,
|
|
4363
|
-
3624381080,
|
|
4364
|
-
310598401,
|
|
4365
|
-
607225278,
|
|
4366
|
-
1426881987,
|
|
4367
|
-
1925078388,
|
|
4368
|
-
2162078206,
|
|
4369
|
-
2614888103,
|
|
4370
|
-
3248222580,
|
|
4371
|
-
3835390401,
|
|
4372
|
-
4022224774,
|
|
4373
|
-
264347078,
|
|
4374
|
-
604807628,
|
|
4375
|
-
770255983,
|
|
4376
|
-
1249150122,
|
|
4377
|
-
1555081692,
|
|
4378
|
-
1996064986,
|
|
4379
|
-
2554220882,
|
|
4380
|
-
2821834349,
|
|
4381
|
-
2952996808,
|
|
4382
|
-
3210313671,
|
|
4383
|
-
3336571891,
|
|
4384
|
-
3584528711,
|
|
4385
|
-
113926993,
|
|
4386
|
-
338241895,
|
|
4387
|
-
666307205,
|
|
4388
|
-
773529912,
|
|
4389
|
-
1294757372,
|
|
4390
|
-
1396182291,
|
|
4391
|
-
1695183700,
|
|
4392
|
-
1986661051,
|
|
4393
|
-
2177026350,
|
|
4394
|
-
2456956037,
|
|
4395
|
-
2730485921,
|
|
4396
|
-
2820302411,
|
|
4397
|
-
3259730800,
|
|
4398
|
-
3345764771,
|
|
4399
|
-
3516065817,
|
|
4400
|
-
3600352804,
|
|
4401
|
-
4094571909,
|
|
4402
|
-
275423344,
|
|
4403
|
-
430227734,
|
|
4404
|
-
506948616,
|
|
4405
|
-
659060556,
|
|
4406
|
-
883997877,
|
|
4407
|
-
958139571,
|
|
4408
|
-
1322822218,
|
|
4409
|
-
1537002063,
|
|
4410
|
-
1747873779,
|
|
4411
|
-
1955562222,
|
|
4412
|
-
2024104815,
|
|
4413
|
-
2227730452,
|
|
4414
|
-
2361852424,
|
|
4415
|
-
2428436474,
|
|
4416
|
-
2756734187,
|
|
4417
|
-
3204031479,
|
|
4418
|
-
3329325298
|
|
4419
|
-
];
|
|
4420
|
-
function sha256Hex(input) {
|
|
4421
|
-
const padded = padSha256Message(new TextEncoder().encode(input));
|
|
4422
|
-
const view = new DataView(padded.buffer, padded.byteOffset, padded.byteLength);
|
|
4423
|
-
const words = new Uint32Array(64);
|
|
4424
|
-
let h0 = SHA256_INITIAL_HASH[0];
|
|
4425
|
-
let h1 = SHA256_INITIAL_HASH[1];
|
|
4426
|
-
let h2 = SHA256_INITIAL_HASH[2];
|
|
4427
|
-
let h3 = SHA256_INITIAL_HASH[3];
|
|
4428
|
-
let h4 = SHA256_INITIAL_HASH[4];
|
|
4429
|
-
let h5 = SHA256_INITIAL_HASH[5];
|
|
4430
|
-
let h6 = SHA256_INITIAL_HASH[6];
|
|
4431
|
-
let h7 = SHA256_INITIAL_HASH[7];
|
|
4432
|
-
for (let offset = 0; offset < padded.byteLength; offset += 64) {
|
|
4433
|
-
for (let i = 0; i < 16; i++) words[i] = view.getUint32(offset + i * 4);
|
|
4434
|
-
for (let i = 16; i < 64; i++) {
|
|
4435
|
-
const s0 = rotr(words[i - 15], 7) ^ rotr(words[i - 15], 18) ^ words[i - 15] >>> 3;
|
|
4436
|
-
const s1 = rotr(words[i - 2], 17) ^ rotr(words[i - 2], 19) ^ words[i - 2] >>> 10;
|
|
4437
|
-
words[i] = words[i - 16] + s0 + words[i - 7] + s1 >>> 0;
|
|
4438
|
-
}
|
|
4439
|
-
let a = h0;
|
|
4440
|
-
let b = h1;
|
|
4441
|
-
let c = h2;
|
|
4442
|
-
let d = h3;
|
|
4443
|
-
let e = h4;
|
|
4444
|
-
let f = h5;
|
|
4445
|
-
let g = h6;
|
|
4446
|
-
let h = h7;
|
|
4447
|
-
for (let i = 0; i < 64; i++) {
|
|
4448
|
-
const s1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
|
|
4449
|
-
const ch = e & f ^ ~e & g;
|
|
4450
|
-
const temp1 = h + s1 + ch + SHA256_K[i] + words[i] >>> 0;
|
|
4451
|
-
const temp2 = (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) + (a & b ^ a & c ^ b & c) >>> 0;
|
|
4452
|
-
h = g;
|
|
4453
|
-
g = f;
|
|
4454
|
-
f = e;
|
|
4455
|
-
e = d + temp1 >>> 0;
|
|
4456
|
-
d = c;
|
|
4457
|
-
c = b;
|
|
4458
|
-
b = a;
|
|
4459
|
-
a = temp1 + temp2 >>> 0;
|
|
4460
|
-
}
|
|
4461
|
-
h0 = h0 + a >>> 0;
|
|
4462
|
-
h1 = h1 + b >>> 0;
|
|
4463
|
-
h2 = h2 + c >>> 0;
|
|
4464
|
-
h3 = h3 + d >>> 0;
|
|
4465
|
-
h4 = h4 + e >>> 0;
|
|
4466
|
-
h5 = h5 + f >>> 0;
|
|
4467
|
-
h6 = h6 + g >>> 0;
|
|
4468
|
-
h7 = h7 + h >>> 0;
|
|
4469
|
-
}
|
|
4470
|
-
return [
|
|
4471
|
-
h0,
|
|
4472
|
-
h1,
|
|
4473
|
-
h2,
|
|
4474
|
-
h3,
|
|
4475
|
-
h4,
|
|
4476
|
-
h5,
|
|
4477
|
-
h6,
|
|
4478
|
-
h7
|
|
4479
|
-
].map((word) => word.toString(16).padStart(8, "0")).join("");
|
|
4480
|
-
}
|
|
4481
|
-
function padSha256Message(bytes) {
|
|
4482
|
-
const bitLength = bytes.byteLength * 8;
|
|
4483
|
-
const zeroPadLength = (64 - (bytes.byteLength + 1 + 8) % 64) % 64;
|
|
4484
|
-
const output = new Uint8Array(bytes.byteLength + 1 + zeroPadLength + 8);
|
|
4485
|
-
output.set(bytes);
|
|
4486
|
-
output[bytes.byteLength] = 128;
|
|
4487
|
-
const view = new DataView(output.buffer);
|
|
4488
|
-
view.setUint32(output.byteLength - 8, Math.floor(bitLength / 4294967296));
|
|
4489
|
-
view.setUint32(output.byteLength - 4, bitLength >>> 0);
|
|
4490
|
-
return output;
|
|
4491
|
-
}
|
|
4492
|
-
function rotr(value, bits) {
|
|
4493
|
-
return value >>> bits | value << 32 - bits;
|
|
4494
|
-
}
|
|
4495
|
-
//#endregion
|
|
4496
3272
|
//#region src/ports/telemetry.ts
|
|
4497
3273
|
var TelemetryPortTag = class extends Context.Tag("@capxul/sdk/ports/TelemetryPort")() {};
|
|
4498
3274
|
//#endregion
|
|
@@ -4632,7 +3408,7 @@ function asRecordArgs(args) {
|
|
|
4632
3408
|
return { value: args };
|
|
4633
3409
|
}
|
|
4634
3410
|
function transportErrorFromThrown(operation, request, cause) {
|
|
4635
|
-
return transportErrorFromCapxul(operation, request, cause instanceof Error ? Errors.providerError("transport", request.name, cause) : Errors.providerError("transport", request.name, new Error(String(cause))), cause);
|
|
3411
|
+
return transportErrorFromCapxul(operation, request, cause instanceof Error ? Errors$1.providerError("transport", request.name, cause) : Errors$1.providerError("transport", request.name, new Error(String(cause))), cause);
|
|
4636
3412
|
}
|
|
4637
3413
|
//#endregion
|
|
4638
3414
|
//#region src/openfort/create-openfort-browser-signer.ts
|
|
@@ -4688,7 +3464,7 @@ function createOpenfortBrowserSignerFromBootstrap(bootstrap, options = {}) {
|
|
|
4688
3464
|
ok: false,
|
|
4689
3465
|
failure_mode: "no-secure-context"
|
|
4690
3466
|
});
|
|
4691
|
-
const error = Errors.providerError("openfort", "configure", /* @__PURE__ */ new Error("Web Crypto unavailable: browser is not a secure context"), { failure_mode: "no-secure-context" });
|
|
3467
|
+
const error = Errors$1.providerError("openfort", "configure", /* @__PURE__ */ new Error("Web Crypto unavailable: browser is not a secure context"), { failure_mode: "no-secure-context" });
|
|
4692
3468
|
if (telemetry) captureExceptionSync(telemetry, error, {
|
|
4693
3469
|
layer: "openfort",
|
|
4694
3470
|
operation: "configure",
|
|
@@ -4734,7 +3510,7 @@ function createOpenfortBrowserSignerFromBootstrap(bootstrap, options = {}) {
|
|
|
4734
3510
|
if (isInsecureBrowserContext()) failNoSecureContext();
|
|
4735
3511
|
await openfort.waitForInitialization();
|
|
4736
3512
|
const accessToken = await fetchBetterAuthAccessToken();
|
|
4737
|
-
if (accessToken === null) throw Errors.notAuthenticated();
|
|
3513
|
+
if (accessToken === null) throw Errors$1.notAuthenticated();
|
|
4738
3514
|
const encryptionResponse = await fetch(encryptionSessionUrl(), {
|
|
4739
3515
|
method: "POST",
|
|
4740
3516
|
credentials: "include",
|
|
@@ -4747,10 +3523,10 @@ function createOpenfortBrowserSignerFromBootstrap(bootstrap, options = {}) {
|
|
|
4747
3523
|
diagnostic?.trace("openfort.encryptionSession", { httpStatus: encryptionResponse.status });
|
|
4748
3524
|
if (!encryptionResponse.ok) {
|
|
4749
3525
|
const detail = await encryptionResponse.text();
|
|
4750
|
-
throw Errors.providerError("openfort", "encryptionSession", /* @__PURE__ */ new Error(`Openfort encryption session failed (${encryptionResponse.status}): ${detail.slice(0, 200)}`));
|
|
3526
|
+
throw Errors$1.providerError("openfort", "encryptionSession", /* @__PURE__ */ new Error(`Openfort encryption session failed (${encryptionResponse.status}): ${detail.slice(0, 200)}`));
|
|
4751
3527
|
}
|
|
4752
3528
|
const encryptionBody = await encryptionResponse.json();
|
|
4753
|
-
if (typeof encryptionBody.sessionId !== "string" || encryptionBody.sessionId.length === 0) throw Errors.providerError("openfort", "encryptionSession", /* @__PURE__ */ new Error("Openfort encryption session response missing sessionId"));
|
|
3529
|
+
if (typeof encryptionBody.sessionId !== "string" || encryptionBody.sessionId.length === 0) throw Errors$1.providerError("openfort", "encryptionSession", /* @__PURE__ */ new Error("Openfort encryption session response missing sessionId"));
|
|
4754
3530
|
const embeddedState = await openfort.embeddedWallet.getEmbeddedState();
|
|
4755
3531
|
diagnostic?.trace("openfort.embeddedState", { state: embeddedState });
|
|
4756
3532
|
if (embeddedState !== EmbeddedState.READY) {
|
|
@@ -4939,7 +3715,7 @@ function createAuthFlowMachine() {
|
|
|
4939
3715
|
if (!/^\d{6}$/.test(context.request.otp)) return yield* Effect.fail(new AuthFlowError({
|
|
4940
3716
|
operation: "verifyOtp",
|
|
4941
3717
|
state: context.state.state,
|
|
4942
|
-
publicError: Errors.invalidInput("otp", "must be a six digit code"),
|
|
3718
|
+
publicError: Errors$1.invalidInput("otp", "must be a six digit code"),
|
|
4943
3719
|
publicCode: "INVALID_INPUT"
|
|
4944
3720
|
}));
|
|
4945
3721
|
if (!canTransition(context.state.state, "VerifyOtp")) return yield* Effect.fail(wrongState("VerifyOtp", context.state.state));
|
|
@@ -4948,7 +3724,7 @@ function createAuthFlowMachine() {
|
|
|
4948
3724
|
const now = yield* (yield* ClockPortTag).now.pipe(Effect.mapError((cause) => new AuthFlowError({
|
|
4949
3725
|
operation: "verifyOtp",
|
|
4950
3726
|
state: current.state,
|
|
4951
|
-
publicError: Errors.providerError("clock", "now", cause),
|
|
3727
|
+
publicError: Errors$1.providerError("clock", "now", cause),
|
|
4952
3728
|
publicCode: "PROVIDER_ERROR",
|
|
4953
3729
|
cause
|
|
4954
3730
|
})));
|
|
@@ -4956,7 +3732,7 @@ function createAuthFlowMachine() {
|
|
|
4956
3732
|
const failure = new AuthFlowError({
|
|
4957
3733
|
operation: "verifyOtp",
|
|
4958
3734
|
state: "otp_requested",
|
|
4959
|
-
publicError: Errors.otpExpired({ expiredAt: Number(current.otpRequestedAt) + normalized.otpTtlMs }),
|
|
3735
|
+
publicError: Errors$1.otpExpired({ expiredAt: Number(current.otpRequestedAt) + normalized.otpTtlMs }),
|
|
4960
3736
|
publicCode: "OTP_EXPIRED"
|
|
4961
3737
|
});
|
|
4962
3738
|
yield* emitTelemetry({
|
|
@@ -5017,7 +3793,7 @@ function createAuthFlowMachine() {
|
|
|
5017
3793
|
const now = yield* (yield* ClockPortTag).now.pipe(Effect.mapError((cause) => new AuthFlowError({
|
|
5018
3794
|
operation: "verifyOtp",
|
|
5019
3795
|
state: current.state,
|
|
5020
|
-
publicError: Errors.providerError("clock", "now", cause),
|
|
3796
|
+
publicError: Errors$1.providerError("clock", "now", cause),
|
|
5021
3797
|
publicCode: "PROVIDER_ERROR",
|
|
5022
3798
|
cause
|
|
5023
3799
|
})));
|
|
@@ -5025,7 +3801,7 @@ function createAuthFlowMachine() {
|
|
|
5025
3801
|
const failure = new AuthFlowError({
|
|
5026
3802
|
operation: "verifyOtp",
|
|
5027
3803
|
state: "error",
|
|
5028
|
-
publicError: Errors.otpExpired({ expiredAt: Number(current.otpRequestedAt) + normalized.otpTtlMs }),
|
|
3804
|
+
publicError: Errors$1.otpExpired({ expiredAt: Number(current.otpRequestedAt) + normalized.otpTtlMs }),
|
|
5029
3805
|
publicCode: "OTP_EXPIRED"
|
|
5030
3806
|
});
|
|
5031
3807
|
yield* emitTelemetry({
|
|
@@ -5078,12 +3854,12 @@ function bootAuthFlow(machine, input) {
|
|
|
5078
3854
|
return Ref.get(statusRef).pipe(Effect.flatMap((status) => status === "active" ? actor.send(toMachineRequest(request)).pipe(Effect.raceFirst(Deferred.await(stopDeferred).pipe(Effect.flatMap(() => Effect.fail(new AuthFlowError({
|
|
5079
3855
|
operation: "transition",
|
|
5080
3856
|
state: Effect.runSync(actor.get).state,
|
|
5081
|
-
publicError: Errors.cancelled({ operation: "authFlow.send" }),
|
|
3857
|
+
publicError: Errors$1.cancelled({ operation: "authFlow.send" }),
|
|
5082
3858
|
publicCode: "CANCELLED"
|
|
5083
3859
|
})))))) : Effect.fail(new AuthFlowError({
|
|
5084
3860
|
operation: "transition",
|
|
5085
3861
|
state: Effect.runSync(actor.get).state,
|
|
5086
|
-
publicError: Errors.cancelled({ operation: "authFlow.send" }),
|
|
3862
|
+
publicError: Errors$1.cancelled({ operation: "authFlow.send" }),
|
|
5087
3863
|
publicCode: "CANCELLED"
|
|
5088
3864
|
}))), Effect.tapError((failure) => failure.publicCode === "OTP_EXPIRED" ? Effect.void : emitTelemetry({
|
|
5089
3865
|
name: "auth_failed",
|
|
@@ -5130,7 +3906,7 @@ function requestOtpCompletion(email, anonDistinctId, options) {
|
|
|
5130
3906
|
const now = yield* (yield* ClockPortTag).now.pipe(Effect.mapError((cause) => new AuthFlowError({
|
|
5131
3907
|
operation: "requestOtp",
|
|
5132
3908
|
state: "sending_otp",
|
|
5133
|
-
publicError: Errors.providerError("clock", "now", cause),
|
|
3909
|
+
publicError: Errors$1.providerError("clock", "now", cause),
|
|
5134
3910
|
publicCode: "PROVIDER_ERROR",
|
|
5135
3911
|
cause
|
|
5136
3912
|
})));
|
|
@@ -5207,7 +3983,7 @@ function withAuthFlowTimeout(effect, operation, state, options) {
|
|
|
5207
3983
|
onTimeout: () => new AuthFlowError({
|
|
5208
3984
|
operation,
|
|
5209
3985
|
state,
|
|
5210
|
-
publicError: Errors.providerTimeout("auth-flow", operation, timeoutMs),
|
|
3986
|
+
publicError: Errors$1.providerTimeout("auth-flow", operation, timeoutMs),
|
|
5211
3987
|
publicCode: "PROVIDER_ERROR"
|
|
5212
3988
|
})
|
|
5213
3989
|
}));
|
|
@@ -5229,7 +4005,7 @@ function completeRequest(commit, deferred, input, control, effect, toFailureCont
|
|
|
5229
4005
|
const failure = new AuthFlowError({
|
|
5230
4006
|
operation: "transition",
|
|
5231
4007
|
state: "error",
|
|
5232
|
-
publicError: Errors.unknown(cause),
|
|
4008
|
+
publicError: Errors$1.unknown(cause),
|
|
5233
4009
|
publicCode: "UNKNOWN",
|
|
5234
4010
|
cause
|
|
5235
4011
|
});
|
|
@@ -5273,7 +4049,7 @@ function stoppedFailure() {
|
|
|
5273
4049
|
return new AuthFlowError({
|
|
5274
4050
|
operation: "transition",
|
|
5275
4051
|
state: "error",
|
|
5276
|
-
publicError: Errors.cancelled({ operation: "authFlow.request" }),
|
|
4052
|
+
publicError: Errors$1.cancelled({ operation: "authFlow.request" }),
|
|
5277
4053
|
publicCode: "CANCELLED"
|
|
5278
4054
|
});
|
|
5279
4055
|
}
|
|
@@ -5302,7 +4078,7 @@ function wrongState(request, state) {
|
|
|
5302
4078
|
return new AuthFlowError({
|
|
5303
4079
|
operation: "transition",
|
|
5304
4080
|
state,
|
|
5305
|
-
publicError: Errors.wrongState({
|
|
4081
|
+
publicError: Errors$1.wrongState({
|
|
5306
4082
|
method: request,
|
|
5307
4083
|
currentState: state,
|
|
5308
4084
|
validStates: AUTH_FLOW_TRANSITION_TABLE[state].valid
|
|
@@ -5321,9 +4097,9 @@ function toAuthFlowError(operation, state, error) {
|
|
|
5321
4097
|
});
|
|
5322
4098
|
}
|
|
5323
4099
|
function toCapxulError(operation, error) {
|
|
5324
|
-
if (error.cause instanceof CapxulError) return error.cause;
|
|
5325
|
-
if (operation === "requestOtp" && error.kind === "provider") return Errors.emailDeliveryFailed("provider rejected OTP request");
|
|
5326
|
-
return Errors.providerError("auth-client", operation, /* @__PURE__ */ new Error("auth-client provider failure"));
|
|
4100
|
+
if (error.cause instanceof CapxulError$2) return error.cause;
|
|
4101
|
+
if (operation === "requestOtp" && error.kind === "provider") return Errors$1.emailDeliveryFailed("provider rejected OTP request");
|
|
4102
|
+
return Errors$1.providerError("auth-client", operation, /* @__PURE__ */ new Error("auth-client provider failure"));
|
|
5327
4103
|
}
|
|
5328
4104
|
function emitTelemetry(event) {
|
|
5329
4105
|
return Effect.gen(function* () {
|
|
@@ -5389,7 +4165,7 @@ function hasMachineActor(actor) {
|
|
|
5389
4165
|
*/
|
|
5390
4166
|
const getSessionProgramWithOptions = (options) => Effect.gen(function* () {
|
|
5391
4167
|
const deps = yield* CapxulDepsTag;
|
|
5392
|
-
const cached = yield* deps.authCache.getSession.pipe(Effect.mapError((e) => Errors.providerError("auth-cache", "getSession", e)));
|
|
4168
|
+
const cached = yield* deps.authCache.getSession.pipe(Effect.mapError((e) => Errors$1.providerError("auth-cache", "getSession", e)));
|
|
5393
4169
|
const actorState = String(deps.actor.getSnapshot().value);
|
|
5394
4170
|
if (cached === null && (actorState === "otp_requested" || actorState === "sending_otp" || actorState === "verifying")) return null;
|
|
5395
4171
|
if (cached !== null && actorState !== "idle") return cached;
|
|
@@ -5429,25 +4205,25 @@ getSessionProgramWithOptions();
|
|
|
5429
4205
|
function verifyOtpProgram(input, options) {
|
|
5430
4206
|
return Effect.gen(function* () {
|
|
5431
4207
|
const deps = yield* CapxulDepsTag;
|
|
5432
|
-
if (!/^\d{6}$/.test(input.code)) return yield* Effect.fail(Errors.invalidInput("otp", "must be 6 digits"));
|
|
4208
|
+
if (!/^\d{6}$/.test(input.code)) return yield* Effect.fail(Errors$1.invalidInput("otp", "must be 6 digits"));
|
|
5433
4209
|
let email;
|
|
5434
4210
|
try {
|
|
5435
4211
|
email = toEmail(input.email);
|
|
5436
4212
|
} catch (err) {
|
|
5437
|
-
return yield* Effect.fail(err instanceof CapxulError ? err : Errors.invalidInput("email", "invalid email"));
|
|
4213
|
+
return yield* Effect.fail(err instanceof CapxulError$2 ? err : Errors$1.invalidInput("email", "invalid email"));
|
|
5438
4214
|
}
|
|
5439
4215
|
let value = String(deps.actor.getSnapshot().value);
|
|
5440
4216
|
if (value === "error") {
|
|
5441
4217
|
yield* sendAuthFlowRequest(deps.actor, { _tag: "ResumeOtpEntry" }).pipe(Effect.provide(authFlowLayer(deps)), Effect.mapError((failure) => failure.publicError));
|
|
5442
4218
|
value = "otp_requested";
|
|
5443
|
-
} else if (value !== "otp_requested") return yield* Effect.fail(Errors.wrongState({
|
|
4219
|
+
} else if (value !== "otp_requested") return yield* Effect.fail(Errors$1.wrongState({
|
|
5444
4220
|
method: "verifyOtp",
|
|
5445
4221
|
currentState: value,
|
|
5446
4222
|
validStates: ["otp_requested"]
|
|
5447
4223
|
}));
|
|
5448
4224
|
if (!hasMachineActor(deps.actor)) {
|
|
5449
4225
|
const next = deps.actor.getSnapshot();
|
|
5450
|
-
if (String(next.value) === "error") return yield* Effect.fail(next.context.error ?? Errors.unknown({ method: "verifyOtp" }));
|
|
4226
|
+
if (String(next.value) === "error") return yield* Effect.fail(next.context.error ?? Errors$1.unknown({ method: "verifyOtp" }));
|
|
5451
4227
|
}
|
|
5452
4228
|
const session = yield* sendAuthFlowRequest(deps.actor, {
|
|
5453
4229
|
_tag: "VerifyOtp",
|
|
@@ -5455,8 +4231,8 @@ function verifyOtpProgram(input, options) {
|
|
|
5455
4231
|
otp: input.code,
|
|
5456
4232
|
...depsRequestOptions(deps, options?.signal)
|
|
5457
4233
|
}).pipe(Effect.provide(authFlowLayer(deps)), Effect.map((snapshot) => snapshot[1].session), Effect.mapError((failure) => failure.publicError));
|
|
5458
|
-
if (session === null) return yield* Effect.fail(Errors.notAuthenticated());
|
|
5459
|
-
yield* deps.authCache.setSession(session).pipe(Effect.mapError((e) => Errors.providerError("auth-cache", "setSession", e)));
|
|
4234
|
+
if (session === null) return yield* Effect.fail(Errors$1.notAuthenticated());
|
|
4235
|
+
yield* deps.authCache.setSession(session).pipe(Effect.mapError((e) => Errors$1.providerError("auth-cache", "setSession", e)));
|
|
5460
4236
|
return session;
|
|
5461
4237
|
});
|
|
5462
4238
|
}
|
|
@@ -5480,7 +4256,7 @@ function depsRequestOptions(deps, signal) {
|
|
|
5480
4256
|
* JWT clear on failure, matching the original's sequential `if (!ok) return`.
|
|
5481
4257
|
*/
|
|
5482
4258
|
function clearAuthCacheEffect(authCache) {
|
|
5483
|
-
return authCache.clearSession.pipe(Effect.mapError((cause) => Errors.providerError("auth-cache", "clearSession", cause)), Effect.zipRight(authCache.clearJwt.pipe(Effect.mapError((cause) => Errors.providerError("auth-cache", "clearJwt", cause)))));
|
|
4259
|
+
return authCache.clearSession.pipe(Effect.mapError((cause) => Errors$1.providerError("auth-cache", "clearSession", cause)), Effect.zipRight(authCache.clearJwt.pipe(Effect.mapError((cause) => Errors$1.providerError("auth-cache", "clearJwt", cause)))));
|
|
5484
4260
|
}
|
|
5485
4261
|
function cryptoRandomId() {
|
|
5486
4262
|
const bytes = new Uint8Array(8);
|
|
@@ -5492,9 +4268,9 @@ const canSendOtpProgram = (input, options) => Effect.gen(function* () {
|
|
|
5492
4268
|
const deps = yield* CapxulDepsTag;
|
|
5493
4269
|
const email = yield* Effect.try({
|
|
5494
4270
|
try: () => toEmail(input.email),
|
|
5495
|
-
catch: (err) => err instanceof CapxulError ? err : Errors.invalidInput("email", "invalid email")
|
|
4271
|
+
catch: (err) => err instanceof CapxulError$2 ? err : Errors$1.invalidInput("email", "invalid email")
|
|
5496
4272
|
});
|
|
5497
|
-
return yield* deps.authClient.canSendOtp({ email }, options?.signal === void 0 ? void 0 : { signal: options.signal }).pipe(Effect.mapError((failure) => failure.cause instanceof CapxulError ? failure.cause : Errors.providerError("auth-client", "canSendOtp", failure.cause)));
|
|
4273
|
+
return yield* deps.authClient.canSendOtp({ email }, options?.signal === void 0 ? void 0 : { signal: options.signal }).pipe(Effect.mapError((failure) => failure.cause instanceof CapxulError$2 ? failure.cause : Errors$1.providerError("auth-client", "canSendOtp", failure.cause)));
|
|
5498
4274
|
});
|
|
5499
4275
|
/**
|
|
5500
4276
|
* `signIn` as a single Effect requiring ONLY `CapxulDepsTag`. Faithful
|
|
@@ -5507,10 +4283,10 @@ const signInProgram = (input, options) => Effect.gen(function* () {
|
|
|
5507
4283
|
const deps = yield* CapxulDepsTag;
|
|
5508
4284
|
const email = yield* Effect.try({
|
|
5509
4285
|
try: () => toEmail(input.email),
|
|
5510
|
-
catch: (err) => err instanceof CapxulError ? err : Errors.invalidInput("email", "invalid email")
|
|
4286
|
+
catch: (err) => err instanceof CapxulError$2 ? err : Errors$1.invalidInput("email", "invalid email")
|
|
5511
4287
|
});
|
|
5512
4288
|
const value = String(deps.actor.getSnapshot().value);
|
|
5513
|
-
if (value !== "idle" && value !== "otp_requested" && value !== "error") return yield* Effect.fail(Errors.wrongState({
|
|
4289
|
+
if (value !== "idle" && value !== "otp_requested" && value !== "error") return yield* Effect.fail(Errors$1.wrongState({
|
|
5514
4290
|
method: "signIn",
|
|
5515
4291
|
currentState: value,
|
|
5516
4292
|
validStates: [
|
|
@@ -5528,7 +4304,7 @@ const signInProgram = (input, options) => Effect.gen(function* () {
|
|
|
5528
4304
|
email,
|
|
5529
4305
|
...depsRequestOptions(deps, options?.signal)
|
|
5530
4306
|
}).pipe(Effect.provide(authFlowLayer(deps)), Effect.mapError((failure) => failure.publicError));
|
|
5531
|
-
const now = yield* deps.clock.now.pipe(Effect.mapError((cause) => Errors.providerError("clock", "now", cause)));
|
|
4307
|
+
const now = yield* deps.clock.now.pipe(Effect.mapError((cause) => Errors$1.providerError("clock", "now", cause)));
|
|
5532
4308
|
return {
|
|
5533
4309
|
sessionId: cryptoRandomId(),
|
|
5534
4310
|
expiresAt: now + (deps.otpTtlMs ?? 3e5)
|
|
@@ -5547,7 +4323,7 @@ const signOutProgramWithOptions = (options) => Effect.gen(function* () {
|
|
|
5547
4323
|
const deps = yield* CapxulDepsTag;
|
|
5548
4324
|
let value = String(deps.actor.getSnapshot().value);
|
|
5549
4325
|
if (value === "idle") {
|
|
5550
|
-
const cached = yield* deps.authCache.getSession.pipe(Effect.mapError((e) => Errors.providerError("auth-cache", "getSession", e)));
|
|
4326
|
+
const cached = yield* deps.authCache.getSession.pipe(Effect.mapError((e) => Errors$1.providerError("auth-cache", "getSession", e)));
|
|
5551
4327
|
if (cached !== null) {
|
|
5552
4328
|
yield* sendAuthFlowRequest(deps.actor, {
|
|
5553
4329
|
_tag: "RestoreCachedSession",
|
|
@@ -5555,7 +4331,7 @@ const signOutProgramWithOptions = (options) => Effect.gen(function* () {
|
|
|
5555
4331
|
}).pipe(Effect.provide(authFlowLayer(deps)), Effect.mapError((failure) => failure.publicError));
|
|
5556
4332
|
value = String(deps.actor.getSnapshot().value);
|
|
5557
4333
|
}
|
|
5558
|
-
if (value === "idle") return yield* Effect.fail(Errors.wrongState({
|
|
4334
|
+
if (value === "idle") return yield* Effect.fail(Errors$1.wrongState({
|
|
5559
4335
|
method: "signOut",
|
|
5560
4336
|
currentState: value,
|
|
5561
4337
|
validStates: [
|
|
@@ -5590,21 +4366,21 @@ function makeAuthMethods(deps) {
|
|
|
5590
4366
|
async canSendOtp(input, options) {
|
|
5591
4367
|
if (options?.signal?.aborted) return {
|
|
5592
4368
|
ok: false,
|
|
5593
|
-
error: Errors.cancelled({ operation: "canSendOtp" })
|
|
4369
|
+
error: Errors$1.cancelled({ operation: "canSendOtp" })
|
|
5594
4370
|
};
|
|
5595
4371
|
return toCapxulResult(canSendOtpProgram(input, options), capxulDepsLayer(deps));
|
|
5596
4372
|
},
|
|
5597
4373
|
async signIn(input, options) {
|
|
5598
4374
|
if (options?.signal?.aborted) return {
|
|
5599
4375
|
ok: false,
|
|
5600
|
-
error: Errors.cancelled({ operation: "signIn" })
|
|
4376
|
+
error: Errors$1.cancelled({ operation: "signIn" })
|
|
5601
4377
|
};
|
|
5602
4378
|
return toCapxulResult(signInProgram(input, options), capxulDepsLayer(deps));
|
|
5603
4379
|
},
|
|
5604
4380
|
async verifyOtp(input, options) {
|
|
5605
4381
|
if (options?.signal?.aborted) return {
|
|
5606
4382
|
ok: false,
|
|
5607
|
-
error: Errors.cancelled({ operation: "verifyOtp" })
|
|
4383
|
+
error: Errors$1.cancelled({ operation: "verifyOtp" })
|
|
5608
4384
|
};
|
|
5609
4385
|
const result = await toCapxulResult(verifyOtpProgram(input, options), capxulDepsLayer(deps));
|
|
5610
4386
|
if (!result.ok) return result;
|
|
@@ -5613,13 +4389,13 @@ function makeAuthMethods(deps) {
|
|
|
5613
4389
|
try {
|
|
5614
4390
|
await afterVerifyOtp();
|
|
5615
4391
|
} catch (cause) {
|
|
5616
|
-
if (cause instanceof CapxulError) return {
|
|
4392
|
+
if (cause instanceof CapxulError$2) return {
|
|
5617
4393
|
ok: false,
|
|
5618
4394
|
error: cause
|
|
5619
4395
|
};
|
|
5620
4396
|
return {
|
|
5621
4397
|
ok: false,
|
|
5622
|
-
error: Errors.providerError("sdk", "afterVerifyOtp", cause)
|
|
4398
|
+
error: Errors$1.providerError("sdk", "afterVerifyOtp", cause)
|
|
5623
4399
|
};
|
|
5624
4400
|
}
|
|
5625
4401
|
return result;
|
|
@@ -5627,14 +4403,14 @@ function makeAuthMethods(deps) {
|
|
|
5627
4403
|
async signOut(options) {
|
|
5628
4404
|
if (options?.signal?.aborted) return {
|
|
5629
4405
|
ok: false,
|
|
5630
|
-
error: Errors.cancelled({ operation: "signOut" })
|
|
4406
|
+
error: Errors$1.cancelled({ operation: "signOut" })
|
|
5631
4407
|
};
|
|
5632
4408
|
return toCapxulResult(signOutProgramWithOptions(options), capxulDepsLayer(deps));
|
|
5633
4409
|
},
|
|
5634
4410
|
async getSession(options) {
|
|
5635
4411
|
if (options?.signal?.aborted) return {
|
|
5636
4412
|
ok: false,
|
|
5637
|
-
error: Errors.cancelled({ operation: "getSession" })
|
|
4413
|
+
error: Errors$1.cancelled({ operation: "getSession" })
|
|
5638
4414
|
};
|
|
5639
4415
|
return toCapxulResult(getSessionProgramWithOptions(options), capxulDepsLayer(deps));
|
|
5640
4416
|
}
|
|
@@ -5682,13 +4458,13 @@ function provisionSmartAccountProgram() {
|
|
|
5682
4458
|
const deps = yield* SmartAccountDepsTag;
|
|
5683
4459
|
const snap = deps.actor.getSnapshot();
|
|
5684
4460
|
const value = snap.value;
|
|
5685
|
-
if (value !== "authenticated") return yield* Effect.fail(Errors.wrongState({
|
|
4461
|
+
if (value !== "authenticated") return yield* Effect.fail(Errors$1.wrongState({
|
|
5686
4462
|
method: "smartAccount.provision",
|
|
5687
4463
|
currentState: value,
|
|
5688
4464
|
validStates: ["authenticated"]
|
|
5689
4465
|
}));
|
|
5690
4466
|
const session = snap.context.session;
|
|
5691
|
-
if (session === null) return yield* Effect.fail(Errors.notAuthenticated());
|
|
4467
|
+
if (session === null) return yield* Effect.fail(Errors$1.notAuthenticated());
|
|
5692
4468
|
const provisioned = yield* deps.smartAccountPort.provision({
|
|
5693
4469
|
authUserId: session.authUserId,
|
|
5694
4470
|
chainId: deps.chainId
|
|
@@ -5704,7 +4480,7 @@ function makeSmartAccountMethods(deps) {
|
|
|
5704
4480
|
async loadCurrent(options) {
|
|
5705
4481
|
if (options?.signal?.aborted) return {
|
|
5706
4482
|
ok: false,
|
|
5707
|
-
error: Errors.cancelled({ operation: "smartAccount.loadCurrent" })
|
|
4483
|
+
error: Errors$1.cancelled({ operation: "smartAccount.loadCurrent" })
|
|
5708
4484
|
};
|
|
5709
4485
|
return toCapxulResult(loadSmartAccountProgram, smartAccountDepsLayer(deps));
|
|
5710
4486
|
},
|
|
@@ -5732,13 +4508,13 @@ function identityDepsLayer(deps) {
|
|
|
5732
4508
|
*/
|
|
5733
4509
|
const loadIdentityProgram = Effect.gen(function* () {
|
|
5734
4510
|
const deps = yield* IdentityDepsTag;
|
|
5735
|
-
if (deps.actor === void 0) return yield* Effect.fail(Errors.notAuthenticated());
|
|
4511
|
+
if (deps.actor === void 0) return yield* Effect.fail(Errors$1.notAuthenticated());
|
|
5736
4512
|
const snapshot = deps.actor.getSnapshot();
|
|
5737
4513
|
const existingError = snapshot.context.error;
|
|
5738
|
-
if (existingError instanceof CapxulError) return yield* Effect.fail(existingError);
|
|
4514
|
+
if (existingError instanceof CapxulError$2) return yield* Effect.fail(existingError);
|
|
5739
4515
|
const authUserId = snapshot.context.session?.authUserId;
|
|
5740
4516
|
if (authUserId === void 0) return null;
|
|
5741
|
-
return yield* deps.identityPort.loadByAuthUserId(authUserId).pipe(Effect.catchAllDefect((cause) => Effect.fail(identityErrorFromCapxul("loadByAuthUserId", cause instanceof CapxulError ? cause : Errors.unknown(cause), cause))), Effect.mapError((failure) => failure.publicError));
|
|
4517
|
+
return yield* deps.identityPort.loadByAuthUserId(authUserId).pipe(Effect.catchAllDefect((cause) => Effect.fail(identityErrorFromCapxul("loadByAuthUserId", cause instanceof CapxulError$2 ? cause : Errors$1.unknown(cause), cause))), Effect.mapError((failure) => failure.publicError));
|
|
5742
4518
|
});
|
|
5743
4519
|
//#endregion
|
|
5744
4520
|
//#region src/client/identity.ts
|
|
@@ -5746,7 +4522,7 @@ function makeIdentityMethods(deps) {
|
|
|
5746
4522
|
return { async loadCurrent(options) {
|
|
5747
4523
|
if (options?.signal?.aborted) return {
|
|
5748
4524
|
ok: false,
|
|
5749
|
-
error: Errors.cancelled({ operation: "identity.loadCurrent" })
|
|
4525
|
+
error: Errors$1.cancelled({ operation: "identity.loadCurrent" })
|
|
5750
4526
|
};
|
|
5751
4527
|
return toCapxulResult(loadIdentityProgram, identityDepsLayer(deps));
|
|
5752
4528
|
} };
|
|
@@ -5895,21 +4671,91 @@ function makeAccountsMethods(deps) {
|
|
|
5895
4671
|
async read(options) {
|
|
5896
4672
|
if (options?.signal?.aborted) return {
|
|
5897
4673
|
ok: false,
|
|
5898
|
-
error: Errors.cancelled({ operation: "accounts.read" })
|
|
4674
|
+
error: Errors$1.cancelled({ operation: "accounts.read" })
|
|
5899
4675
|
};
|
|
5900
4676
|
return toCapxulResult(readAccountProgram, accountsDepsLayer(deps));
|
|
5901
4677
|
},
|
|
5902
4678
|
async fund(amount, options) {
|
|
5903
4679
|
if (options?.signal?.aborted) return {
|
|
5904
4680
|
ok: false,
|
|
5905
|
-
error: Errors.cancelled({ operation: "accounts.fund" })
|
|
4681
|
+
error: Errors$1.cancelled({ operation: "accounts.fund" })
|
|
5906
4682
|
};
|
|
5907
4683
|
return toCapxulResult(fundFromFaucetProgram(amount), accountsDepsLayer(deps));
|
|
5908
4684
|
}
|
|
5909
4685
|
};
|
|
5910
4686
|
}
|
|
5911
4687
|
//#endregion
|
|
4688
|
+
//#region src/client/current-user.ts
|
|
4689
|
+
function makeCurrentUserMethods(deps) {
|
|
4690
|
+
return { async get(options) {
|
|
4691
|
+
if (options?.signal?.aborted) return {
|
|
4692
|
+
ok: false,
|
|
4693
|
+
error: Errors.cancelled({ operation: "currentUser.get" })
|
|
4694
|
+
};
|
|
4695
|
+
const user = await deps.me.get(options);
|
|
4696
|
+
if (!user.ok) return {
|
|
4697
|
+
ok: false,
|
|
4698
|
+
error: user.error
|
|
4699
|
+
};
|
|
4700
|
+
const [account, smartAccount, organizations] = await Promise.all([
|
|
4701
|
+
deps.accounts.read(options),
|
|
4702
|
+
deps.smartAccount.loadCurrent(options),
|
|
4703
|
+
deps.orgs(options)
|
|
4704
|
+
]);
|
|
4705
|
+
if (!account.ok) return {
|
|
4706
|
+
ok: false,
|
|
4707
|
+
error: account.error
|
|
4708
|
+
};
|
|
4709
|
+
if (!smartAccount.ok) return {
|
|
4710
|
+
ok: false,
|
|
4711
|
+
error: smartAccount.error
|
|
4712
|
+
};
|
|
4713
|
+
if (!organizations.ok) return {
|
|
4714
|
+
ok: false,
|
|
4715
|
+
error: organizations.error
|
|
4716
|
+
};
|
|
4717
|
+
return {
|
|
4718
|
+
ok: true,
|
|
4719
|
+
value: {
|
|
4720
|
+
user: {
|
|
4721
|
+
id: user.value.authUserId,
|
|
4722
|
+
email: user.value.email,
|
|
4723
|
+
displayName: user.value.displayName,
|
|
4724
|
+
handle: null,
|
|
4725
|
+
paymentLink: null
|
|
4726
|
+
},
|
|
4727
|
+
personalAccount: {
|
|
4728
|
+
id: account.value.id,
|
|
4729
|
+
address: smartAccount.value?.smartAccountAddress ?? null
|
|
4730
|
+
},
|
|
4731
|
+
organizations: organizations.value.map((organization) => ({
|
|
4732
|
+
id: organization.id,
|
|
4733
|
+
name: organization.name,
|
|
4734
|
+
handle: organization.handle,
|
|
4735
|
+
role: organization.role,
|
|
4736
|
+
account: {
|
|
4737
|
+
id: organization.treasury.id,
|
|
4738
|
+
address: organization.safeAddress
|
|
4739
|
+
}
|
|
4740
|
+
}))
|
|
4741
|
+
}
|
|
4742
|
+
};
|
|
4743
|
+
} };
|
|
4744
|
+
}
|
|
4745
|
+
//#endregion
|
|
5912
4746
|
//#region src/client/financial-ops.ts
|
|
4747
|
+
function actorReferenceToBackend(actor) {
|
|
4748
|
+
if (actor === void 0) return void 0;
|
|
4749
|
+
switch (actor.kind) {
|
|
4750
|
+
case "personal": return { kind: "account" };
|
|
4751
|
+
case "organization": return {
|
|
4752
|
+
kind: "org",
|
|
4753
|
+
orgId: actor.organizationId
|
|
4754
|
+
};
|
|
4755
|
+
case "account":
|
|
4756
|
+
case "org": return actor;
|
|
4757
|
+
}
|
|
4758
|
+
}
|
|
5913
4759
|
const DEFAULT_FUNCTIONS = {
|
|
5914
4760
|
me: makeFunctionReference("financialOps/queries:me"),
|
|
5915
4761
|
depositInstructions: makeFunctionReference("financialOps/queries:depositInstructions"),
|
|
@@ -5969,40 +4815,88 @@ function makeFinancialOpsMethods(deps) {
|
|
|
5969
4815
|
get: (payeeId, options) => runIfActive(options?.signal, "payees.get", () => deps.convexCall.query(fns.getPayee, { payeeId })),
|
|
5970
4816
|
resolve: (recipient, options) => runIfActive(options?.signal, "payees.resolve", () => deps.convexCall.query(fns.resolvePayee, { recipient }))
|
|
5971
4817
|
},
|
|
4818
|
+
targets: { resolve: async (reference, options) => {
|
|
4819
|
+
switch (reference.kind) {
|
|
4820
|
+
case "handle": return mapOk$1(await runIfActive(options?.signal, "targets.resolve.handle", () => deps.convexCall.query(fns.resolveHandle, { handle: reference.handle })), (target) => resolvedTargetFromResolution(reference, target));
|
|
4821
|
+
case "email": return mapOk$1(await runIfActive(options?.signal, "targets.resolve.email", () => deps.convexCall.query(fns.resolvePayee, { recipient: reference.email })), (target) => resolvedTargetFromResolution(reference, target));
|
|
4822
|
+
case "organization": {
|
|
4823
|
+
const resolved = await runIfActive(options?.signal, "targets.resolve.organization", () => deps.convexCall.query(fns.resolveHandle, { handle: reference.handle }));
|
|
4824
|
+
if (!resolved.ok) return {
|
|
4825
|
+
ok: false,
|
|
4826
|
+
error: resolved.error
|
|
4827
|
+
};
|
|
4828
|
+
if (resolved.value.kind !== "org") return {
|
|
4829
|
+
ok: false,
|
|
4830
|
+
error: Errors.invalidInput("reference", "organization handle could not be resolved")
|
|
4831
|
+
};
|
|
4832
|
+
return {
|
|
4833
|
+
ok: true,
|
|
4834
|
+
value: resolvedTargetFromResolution(reference, resolved.value)
|
|
4835
|
+
};
|
|
4836
|
+
}
|
|
4837
|
+
case "payee": {
|
|
4838
|
+
const payee = await runIfActive(options?.signal, "targets.resolve.payee", () => deps.convexCall.query(fns.getPayee, { payeeId: reference.id }));
|
|
4839
|
+
if (!payee.ok) return {
|
|
4840
|
+
ok: false,
|
|
4841
|
+
error: payee.error
|
|
4842
|
+
};
|
|
4843
|
+
if (payee.value === null) return {
|
|
4844
|
+
ok: false,
|
|
4845
|
+
error: Errors.invalidInput("reference", "payee not found")
|
|
4846
|
+
};
|
|
4847
|
+
return {
|
|
4848
|
+
ok: true,
|
|
4849
|
+
value: resolvedTargetFromPayee(reference, payee.value)
|
|
4850
|
+
};
|
|
4851
|
+
}
|
|
4852
|
+
case "destination": return Promise.resolve({
|
|
4853
|
+
ok: false,
|
|
4854
|
+
error: Errors.notImplemented("targets", "resolve.destination")
|
|
4855
|
+
});
|
|
4856
|
+
}
|
|
4857
|
+
} },
|
|
5972
4858
|
destinations: {
|
|
5973
4859
|
add: async (input, options) => {
|
|
5974
|
-
const ref =
|
|
4860
|
+
const ref = normalizeDestinationInputRef(input, "target");
|
|
5975
4861
|
if (!ref.ok) return {
|
|
5976
4862
|
ok: false,
|
|
5977
4863
|
error: ref.error
|
|
5978
4864
|
};
|
|
5979
|
-
|
|
5980
|
-
|
|
4865
|
+
if (ref.value === void 0) return {
|
|
4866
|
+
ok: false,
|
|
4867
|
+
error: Errors.invalidInput("target", "required for destinations.add")
|
|
4868
|
+
};
|
|
4869
|
+
return mapOk$1(await runIfActive(options?.signal, "destinations.add", () => deps.convexCall.mutation(fns.addDestination, {
|
|
4870
|
+
...input.actor === void 0 ? {} : { actor: actorReferenceToBackend(input.actor) },
|
|
5981
4871
|
ref: ref.value,
|
|
5982
|
-
kind: input.kind,
|
|
4872
|
+
kind: destinationKindToBackend(input.kind),
|
|
5983
4873
|
...input.label === void 0 ? {} : { label: input.label },
|
|
5984
4874
|
payload: input.payload
|
|
5985
|
-
}));
|
|
4875
|
+
})), destinationFromBackend);
|
|
5986
4876
|
},
|
|
5987
4877
|
list: async (input, options) => {
|
|
5988
|
-
const ref =
|
|
4878
|
+
const ref = normalizeDestinationInputRef(input, "target");
|
|
5989
4879
|
if (!ref.ok) return {
|
|
5990
4880
|
ok: false,
|
|
5991
4881
|
error: ref.error
|
|
5992
4882
|
};
|
|
5993
|
-
return runIfActive(options?.signal, "destinations.list", () => deps.convexCall.query(fns.listDestinations, {
|
|
5994
|
-
...input.actor === void 0 ? {} : { actor: input.actor },
|
|
5995
|
-
ref: ref.value
|
|
5996
|
-
}));
|
|
4883
|
+
return mapOk$1(await runIfActive(options?.signal, "destinations.list", () => deps.convexCall.query(fns.listDestinations, {
|
|
4884
|
+
...input.actor === void 0 ? {} : { actor: actorReferenceToBackend(input.actor) },
|
|
4885
|
+
...ref.value === void 0 ? {} : { ref: ref.value }
|
|
4886
|
+
})), (destinations) => destinations.map(destinationFromBackend).filter((destination) => input.kind === void 0 || destination.kind === input.kind));
|
|
5997
4887
|
},
|
|
5998
4888
|
remove: (input, options) => runIfActive(options?.signal, "destinations.remove", () => deps.convexCall.mutation(fns.removeDestination, {
|
|
5999
|
-
...input.actor === void 0 ? {} : { actor: input.actor },
|
|
4889
|
+
...input.actor === void 0 ? {} : { actor: actorReferenceToBackend(input.actor) },
|
|
6000
4890
|
destinationId: input.destinationId
|
|
6001
4891
|
}))
|
|
6002
4892
|
},
|
|
6003
4893
|
payments: {
|
|
6004
4894
|
pay: async (input, options) => {
|
|
6005
|
-
|
|
4895
|
+
if (actorReferenceToBackend(input.actor)?.kind === "org") return {
|
|
4896
|
+
ok: false,
|
|
4897
|
+
error: Errors.notImplemented("payments", "pay.organizationActor")
|
|
4898
|
+
};
|
|
4899
|
+
const to = normalizeTargetForBackend(input.to, "to");
|
|
6006
4900
|
if (!to.ok) return {
|
|
6007
4901
|
ok: false,
|
|
6008
4902
|
error: to.error
|
|
@@ -6010,13 +4904,14 @@ function makeFinancialOpsMethods(deps) {
|
|
|
6010
4904
|
return mapOk$1(await runIfActive(options?.signal, "payments.pay", () => deps.convexCall.mutation(fns.pay, {
|
|
6011
4905
|
to: to.value,
|
|
6012
4906
|
amount: input.amount,
|
|
4907
|
+
...input.paymentType === void 0 ? {} : { paymentType: input.paymentType },
|
|
6013
4908
|
...input.document === void 0 ? {} : { document: input.document },
|
|
6014
4909
|
...input.timing === void 0 ? {} : { timing: input.timing },
|
|
6015
4910
|
...input.lineItems === void 0 ? {} : { lineItems: input.lineItems }
|
|
6016
4911
|
})), normalizePaymentTiming$1);
|
|
6017
4912
|
},
|
|
6018
4913
|
payout: async (input, options) => mapOk$1(await runIfActive(options?.signal, "payments.payout", () => deps.convexCall.mutation(fns.payout, {
|
|
6019
|
-
...input.actor === void 0 ? {} : { actor: input.actor },
|
|
4914
|
+
...input.actor === void 0 ? {} : { actor: actorReferenceToBackend(input.actor) },
|
|
6020
4915
|
destinationId: input.destinationId,
|
|
6021
4916
|
amount: input.amount
|
|
6022
4917
|
})), normalizePaymentTiming$1),
|
|
@@ -6027,6 +4922,16 @@ function makeFinancialOpsMethods(deps) {
|
|
|
6027
4922
|
})),
|
|
6028
4923
|
list: async (options) => mapOk$1(await runIfActive(options?.signal, "payments.list", () => deps.convexCall.query(fns.listPayments, {})), (payments) => payments.map(normalizePaymentTiming$1)),
|
|
6029
4924
|
get: async (paymentId, options) => mapOk$1(await runIfActive(options?.signal, "payments.get", () => deps.convexCall.query(fns.getPayment, { paymentId })), (payment) => payment === null ? null : normalizePaymentTiming$1(payment)),
|
|
4925
|
+
cancel: (paymentId, options) => {
|
|
4926
|
+
if (options?.signal?.aborted) return Promise.resolve({
|
|
4927
|
+
ok: false,
|
|
4928
|
+
error: Errors.cancelled({ operation: "payments.cancel" })
|
|
4929
|
+
});
|
|
4930
|
+
return Promise.resolve({
|
|
4931
|
+
ok: false,
|
|
4932
|
+
error: Errors.notImplemented("payments", "cancel")
|
|
4933
|
+
});
|
|
4934
|
+
},
|
|
6030
4935
|
_internal: {
|
|
6031
4936
|
markSettled: (input, options) => runIfActive(options?.signal, "payments.markSettled", () => deps.convexCall.action(fns.markPaymentSettled, {
|
|
6032
4937
|
paymentId: input.paymentId,
|
|
@@ -6087,6 +4992,38 @@ function makeFinancialOpsMethods(deps) {
|
|
|
6087
4992
|
commitmentRef: (paymentId, options) => runIfActive(options?.signal, "payments.commitmentRef", () => deps.convexCall.query(fns.getCommitmentRef, { paymentId }))
|
|
6088
4993
|
}
|
|
6089
4994
|
},
|
|
4995
|
+
activity: { list: (params, options) => {
|
|
4996
|
+
if (options?.signal?.aborted) return Promise.resolve({
|
|
4997
|
+
ok: false,
|
|
4998
|
+
error: Errors.cancelled({ operation: "activity.list" })
|
|
4999
|
+
});
|
|
5000
|
+
return Promise.resolve({
|
|
5001
|
+
ok: false,
|
|
5002
|
+
error: Errors.notImplemented("activity", "list")
|
|
5003
|
+
});
|
|
5004
|
+
} },
|
|
5005
|
+
offramp: {
|
|
5006
|
+
quote: (input, options) => {
|
|
5007
|
+
if (options?.signal?.aborted) return Promise.resolve({
|
|
5008
|
+
ok: false,
|
|
5009
|
+
error: Errors.cancelled({ operation: "offramp.quote" })
|
|
5010
|
+
});
|
|
5011
|
+
return Promise.resolve({
|
|
5012
|
+
ok: false,
|
|
5013
|
+
error: Errors.notImplemented("offramp", "quote")
|
|
5014
|
+
});
|
|
5015
|
+
},
|
|
5016
|
+
status: (offrampId, options) => {
|
|
5017
|
+
if (options?.signal?.aborted) return Promise.resolve({
|
|
5018
|
+
ok: false,
|
|
5019
|
+
error: Errors.cancelled({ operation: "offramp.status" })
|
|
5020
|
+
});
|
|
5021
|
+
return Promise.resolve({
|
|
5022
|
+
ok: false,
|
|
5023
|
+
error: Errors.notImplemented("offramp", "status")
|
|
5024
|
+
});
|
|
5025
|
+
}
|
|
5026
|
+
},
|
|
6090
5027
|
paymentDocuments: {
|
|
6091
5028
|
verify: (documentHash, options) => runIfActive(options?.signal, "paymentDocuments.verify", () => deps.convexCall.query(fns.verifyPaymentDocument, { documentHash })),
|
|
6092
5029
|
render: (documentHash, options) => runIfActive(options?.signal, "paymentDocuments.render", () => deps.convexCall.query(fns.renderStoredDocument, { documentHash }))
|
|
@@ -6166,6 +5103,169 @@ function handleRefValue(value, field) {
|
|
|
6166
5103
|
const trimmed = nonEmptyRefValue(value, field);
|
|
6167
5104
|
return trimmed.startsWith("@") ? trimmed.slice(1) : trimmed;
|
|
6168
5105
|
}
|
|
5106
|
+
function refFromTargetReference(reference, field) {
|
|
5107
|
+
try {
|
|
5108
|
+
if (typeof reference === "string") throw Errors.invalidInput(field, "target must be a typed TargetReference variant");
|
|
5109
|
+
if (typeof reference !== "object" || reference === null || !("kind" in reference)) throw Errors.invalidInput(field, "target must be a typed TargetReference variant");
|
|
5110
|
+
switch (reference.kind) {
|
|
5111
|
+
case "handle": return {
|
|
5112
|
+
ok: true,
|
|
5113
|
+
value: {
|
|
5114
|
+
kind: "handle",
|
|
5115
|
+
handle: reference.handle
|
|
5116
|
+
}
|
|
5117
|
+
};
|
|
5118
|
+
case "email": return {
|
|
5119
|
+
ok: true,
|
|
5120
|
+
value: {
|
|
5121
|
+
kind: "email",
|
|
5122
|
+
email: reference.email
|
|
5123
|
+
}
|
|
5124
|
+
};
|
|
5125
|
+
case "organization": return {
|
|
5126
|
+
ok: true,
|
|
5127
|
+
value: {
|
|
5128
|
+
kind: "orgHandle",
|
|
5129
|
+
orgHandle: reference.handle
|
|
5130
|
+
}
|
|
5131
|
+
};
|
|
5132
|
+
case "payee": return {
|
|
5133
|
+
ok: true,
|
|
5134
|
+
value: {
|
|
5135
|
+
kind: "payeeId",
|
|
5136
|
+
payeeId: reference.id
|
|
5137
|
+
}
|
|
5138
|
+
};
|
|
5139
|
+
case "destination": return {
|
|
5140
|
+
ok: false,
|
|
5141
|
+
error: Errors.notImplemented("targets", "reference.destination")
|
|
5142
|
+
};
|
|
5143
|
+
default: throw Errors.invalidInput(field, "target must be a known TargetReference variant");
|
|
5144
|
+
}
|
|
5145
|
+
} catch (cause) {
|
|
5146
|
+
if (cause instanceof Error && "code" in cause) return {
|
|
5147
|
+
ok: false,
|
|
5148
|
+
error: cause
|
|
5149
|
+
};
|
|
5150
|
+
return {
|
|
5151
|
+
ok: false,
|
|
5152
|
+
error: Errors.invalidInput(field, "target must be a typed TargetReference variant")
|
|
5153
|
+
};
|
|
5154
|
+
}
|
|
5155
|
+
}
|
|
5156
|
+
function normalizeTargetForBackend(reference, field) {
|
|
5157
|
+
const ref = refFromTargetReference(reference, field);
|
|
5158
|
+
return ref.ok ? normalizeRefForBackend(ref.value, field) : ref;
|
|
5159
|
+
}
|
|
5160
|
+
function normalizeDestinationInputRef(input, field) {
|
|
5161
|
+
if (input.target !== void 0) return normalizeTargetForBackend(input.target, field);
|
|
5162
|
+
if (input.ref !== void 0) return normalizeDestinationRefForBackend(input.ref, "ref");
|
|
5163
|
+
return {
|
|
5164
|
+
ok: true,
|
|
5165
|
+
value: void 0
|
|
5166
|
+
};
|
|
5167
|
+
}
|
|
5168
|
+
function targetReferenceFromBackendRef(ref) {
|
|
5169
|
+
switch (ref.kind) {
|
|
5170
|
+
case "handle": return {
|
|
5171
|
+
kind: "handle",
|
|
5172
|
+
handle: ref.handle
|
|
5173
|
+
};
|
|
5174
|
+
case "email": return {
|
|
5175
|
+
kind: "email",
|
|
5176
|
+
email: ref.email
|
|
5177
|
+
};
|
|
5178
|
+
case "orgHandle": return {
|
|
5179
|
+
kind: "organization",
|
|
5180
|
+
handle: ref.orgHandle
|
|
5181
|
+
};
|
|
5182
|
+
case "payeeId": return {
|
|
5183
|
+
kind: "payee",
|
|
5184
|
+
id: ref.payeeId
|
|
5185
|
+
};
|
|
5186
|
+
case "capxulUserId": throw Errors.notImplemented("targets", "reference.capxulUserId");
|
|
5187
|
+
}
|
|
5188
|
+
}
|
|
5189
|
+
function resolvedTargetFromResolution(reference, resolution) {
|
|
5190
|
+
const kind = resolution.kind === "org" ? "organization" : resolution.kind === "payee" ? "payee" : "person";
|
|
5191
|
+
return {
|
|
5192
|
+
reference,
|
|
5193
|
+
label: resolution.label,
|
|
5194
|
+
kind,
|
|
5195
|
+
capabilities: {
|
|
5196
|
+
canPay: true,
|
|
5197
|
+
canRequest: true,
|
|
5198
|
+
canPayout: false
|
|
5199
|
+
}
|
|
5200
|
+
};
|
|
5201
|
+
}
|
|
5202
|
+
function resolvedTargetFromPayee(reference, payee) {
|
|
5203
|
+
return {
|
|
5204
|
+
reference,
|
|
5205
|
+
label: payee.label,
|
|
5206
|
+
kind: "payee",
|
|
5207
|
+
capabilities: {
|
|
5208
|
+
canPay: true,
|
|
5209
|
+
canRequest: true,
|
|
5210
|
+
canPayout: false
|
|
5211
|
+
}
|
|
5212
|
+
};
|
|
5213
|
+
}
|
|
5214
|
+
function destinationKindToBackend(kind) {
|
|
5215
|
+
switch (kind) {
|
|
5216
|
+
case "bank_account": return "bank";
|
|
5217
|
+
case "mobile_money": return "mobile-money";
|
|
5218
|
+
case "external_account": return "wallet";
|
|
5219
|
+
}
|
|
5220
|
+
}
|
|
5221
|
+
function destinationKindFromBackend(kind) {
|
|
5222
|
+
switch (kind) {
|
|
5223
|
+
case "bank": return "bank_account";
|
|
5224
|
+
case "mobile-money": return "mobile_money";
|
|
5225
|
+
case "wallet": return "external_account";
|
|
5226
|
+
}
|
|
5227
|
+
}
|
|
5228
|
+
function destinationRailFromBackend(destination) {
|
|
5229
|
+
switch (destination.kind) {
|
|
5230
|
+
case "bank": {
|
|
5231
|
+
const payload = destination.payload;
|
|
5232
|
+
return {
|
|
5233
|
+
kind: "bank",
|
|
5234
|
+
country: payload.country,
|
|
5235
|
+
currency: payload.currency
|
|
5236
|
+
};
|
|
5237
|
+
}
|
|
5238
|
+
case "mobile-money": {
|
|
5239
|
+
const payload = destination.payload;
|
|
5240
|
+
return {
|
|
5241
|
+
kind: "mobile_money",
|
|
5242
|
+
country: payload.country,
|
|
5243
|
+
currency: payload.currency,
|
|
5244
|
+
provider: payload.provider
|
|
5245
|
+
};
|
|
5246
|
+
}
|
|
5247
|
+
case "wallet": return {
|
|
5248
|
+
kind: "chain",
|
|
5249
|
+
network: destination.payload.network,
|
|
5250
|
+
asset: "USD"
|
|
5251
|
+
};
|
|
5252
|
+
}
|
|
5253
|
+
}
|
|
5254
|
+
function destinationFromBackend(destination) {
|
|
5255
|
+
return {
|
|
5256
|
+
...destination,
|
|
5257
|
+
target: targetReferenceFromBackendRef(destination.ref),
|
|
5258
|
+
kind: destinationKindFromBackend(destination.kind),
|
|
5259
|
+
rail: destinationRailFromBackend(destination)
|
|
5260
|
+
};
|
|
5261
|
+
}
|
|
5262
|
+
function normalizeDestinationRefForBackend(ref, field) {
|
|
5263
|
+
if (typeof ref === "object" && ref !== null && "kind" in ref && ref.kind === "capxulUserId") return {
|
|
5264
|
+
ok: false,
|
|
5265
|
+
error: Errors.notImplemented("targets", "reference.capxulUserId")
|
|
5266
|
+
};
|
|
5267
|
+
return normalizeRefForBackend(ref, field);
|
|
5268
|
+
}
|
|
6169
5269
|
function normalizeRefForBackend(ref, field) {
|
|
6170
5270
|
try {
|
|
6171
5271
|
if (typeof ref === "string") throw Errors.invalidInput(field, "recipient must be a typed Ref variant");
|
|
@@ -6228,10 +5328,18 @@ function normalizePaymentTiming$1(payment) {
|
|
|
6228
5328
|
}
|
|
6229
5329
|
function mapOk$1(result, f) {
|
|
6230
5330
|
if (!result.ok) return result;
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
5331
|
+
try {
|
|
5332
|
+
return {
|
|
5333
|
+
ok: true,
|
|
5334
|
+
value: f(result.value)
|
|
5335
|
+
};
|
|
5336
|
+
} catch (cause) {
|
|
5337
|
+
if (cause instanceof Error && "code" in cause) return {
|
|
5338
|
+
ok: false,
|
|
5339
|
+
error: cause
|
|
5340
|
+
};
|
|
5341
|
+
throw cause;
|
|
5342
|
+
}
|
|
6235
5343
|
}
|
|
6236
5344
|
async function runIfActive(signal, operation, effect) {
|
|
6237
5345
|
if (signal?.aborted === true) return {
|
|
@@ -6312,42 +5420,42 @@ function makeSubAccountsMethods(deps) {
|
|
|
6312
5420
|
async create(accountId, input, options) {
|
|
6313
5421
|
if (options?.signal?.aborted) return {
|
|
6314
5422
|
ok: false,
|
|
6315
|
-
error: Errors.cancelled({ operation: "subAccounts.create" })
|
|
5423
|
+
error: Errors$1.cancelled({ operation: "subAccounts.create" })
|
|
6316
5424
|
};
|
|
6317
5425
|
return toCapxulResult(createSubAccountProgram(accountId, input.name), layer);
|
|
6318
5426
|
},
|
|
6319
5427
|
async get(subAccountId, options) {
|
|
6320
5428
|
if (options?.signal?.aborted) return {
|
|
6321
5429
|
ok: false,
|
|
6322
|
-
error: Errors.cancelled({ operation: "subAccounts.get" })
|
|
5430
|
+
error: Errors$1.cancelled({ operation: "subAccounts.get" })
|
|
6323
5431
|
};
|
|
6324
5432
|
return toCapxulResult(getSubAccountProgram(subAccountId), layer);
|
|
6325
5433
|
},
|
|
6326
5434
|
async list(accountId, options) {
|
|
6327
5435
|
if (options?.signal?.aborted) return {
|
|
6328
5436
|
ok: false,
|
|
6329
|
-
error: Errors.cancelled({ operation: "subAccounts.list" })
|
|
5437
|
+
error: Errors$1.cancelled({ operation: "subAccounts.list" })
|
|
6330
5438
|
};
|
|
6331
5439
|
return toCapxulResult(listSubAccountsProgram(accountId), layer);
|
|
6332
5440
|
},
|
|
6333
5441
|
async rename(subAccountId, name, options) {
|
|
6334
5442
|
if (options?.signal?.aborted) return {
|
|
6335
5443
|
ok: false,
|
|
6336
|
-
error: Errors.cancelled({ operation: "subAccounts.rename" })
|
|
5444
|
+
error: Errors$1.cancelled({ operation: "subAccounts.rename" })
|
|
6337
5445
|
};
|
|
6338
5446
|
return toCapxulResult(renameSubAccountProgram(subAccountId, name), layer);
|
|
6339
5447
|
},
|
|
6340
5448
|
async delete(subAccountId, options) {
|
|
6341
5449
|
if (options?.signal?.aborted) return {
|
|
6342
5450
|
ok: false,
|
|
6343
|
-
error: Errors.cancelled({ operation: "subAccounts.delete" })
|
|
5451
|
+
error: Errors$1.cancelled({ operation: "subAccounts.delete" })
|
|
6344
5452
|
};
|
|
6345
5453
|
return toCapxulResult(deleteSubAccountProgram(subAccountId), layer);
|
|
6346
5454
|
},
|
|
6347
5455
|
async transfer(input, options) {
|
|
6348
5456
|
if (options?.signal?.aborted) return {
|
|
6349
5457
|
ok: false,
|
|
6350
|
-
error: Errors.cancelled({ operation: "subAccounts.transfer" })
|
|
5458
|
+
error: Errors$1.cancelled({ operation: "subAccounts.transfer" })
|
|
6351
5459
|
};
|
|
6352
5460
|
return toCapxulResult(transferSubAccountProgram(input), layer);
|
|
6353
5461
|
}
|
|
@@ -6451,18 +5559,18 @@ function isOrgTelemetryDebugEnabled() {
|
|
|
6451
5559
|
//#endregion
|
|
6452
5560
|
//#region src/client/org-spend-gate.ts
|
|
6453
5561
|
function evaluateSpendGate(input) {
|
|
6454
|
-
if (!input.activeMember) return reject("not_member", Errors.invalidInput("member", "you are not an active member"));
|
|
6455
|
-
if (!recipientAllowed(input.recipients, input.recipient)) return reject("invalid_recipient", Errors.invalidRecipient("recipient is not allowed by this role"));
|
|
6456
|
-
if (!subAccountAllowed(input.subAccounts, input.subAccountId)) return reject("wrong_envelope", Errors.invalidInput("subAccountId", "sub-account not in scope for this role"));
|
|
5562
|
+
if (!input.activeMember) return reject("not_member", Errors$1.invalidInput("member", "you are not an active member"));
|
|
5563
|
+
if (!recipientAllowed(input.recipients, input.recipient)) return reject("invalid_recipient", Errors$1.invalidRecipient("recipient is not allowed by this role"));
|
|
5564
|
+
if (!subAccountAllowed(input.subAccounts, input.subAccountId)) return reject("wrong_envelope", Errors$1.invalidInput("subAccountId", "sub-account not in scope for this role"));
|
|
6457
5565
|
const amount = parseRaw(input.amountRaw, "amountRaw");
|
|
6458
5566
|
const balance = parseRaw(input.subAccountBalanceRaw, "subAccountBalanceRaw");
|
|
6459
|
-
if (amount > balance) return reject("insufficient_subaccount_balance", Errors.insufficientBalance(input.currency, balance.toString(10), amount.toString(10)));
|
|
5567
|
+
if (amount > balance) return reject("insufficient_subaccount_balance", Errors$1.insufficientBalance(input.currency, balance.toString(10), amount.toString(10)));
|
|
6460
5568
|
const perTxCap = parseOptionalRaw(input.perTxCapRaw, "perTxCapRaw");
|
|
6461
|
-
if (perTxCap !== null && amount > perTxCap) return reject("over_cap", Errors.insufficientBalance("role per-transaction cap", perTxCap.toString(10), amount.toString(10)));
|
|
5569
|
+
if (perTxCap !== null && amount > perTxCap) return reject("over_cap", Errors$1.insufficientBalance("role per-transaction cap", perTxCap.toString(10), amount.toString(10)));
|
|
6462
5570
|
const perDayCap = parseOptionalRaw(input.perDayCapRaw, "perDayCapRaw");
|
|
6463
5571
|
if (perDayCap !== null) {
|
|
6464
5572
|
const remaining = perDayCap - (parseOptionalRaw(input.spentTodayRaw, "spentTodayRaw") ?? 0n);
|
|
6465
|
-
if (remaining < amount) return reject("daily_cap_exhausted", Errors.insufficientBalance("role daily cap", remaining.toString(10), amount.toString(10)));
|
|
5573
|
+
if (remaining < amount) return reject("daily_cap_exhausted", Errors$1.insufficientBalance("role daily cap", remaining.toString(10), amount.toString(10)));
|
|
6466
5574
|
}
|
|
6467
5575
|
return { ok: true };
|
|
6468
5576
|
}
|
|
@@ -6487,7 +5595,7 @@ function parseOptionalRaw(value, field) {
|
|
|
6487
5595
|
return parseRaw(value, field);
|
|
6488
5596
|
}
|
|
6489
5597
|
function parseRaw(value, field) {
|
|
6490
|
-
if (!/^[0-9]+$/.test(value)) throw Errors.invalidInput(field, "must be a non-negative integer string");
|
|
5598
|
+
if (!/^[0-9]+$/.test(value)) throw Errors$1.invalidInput(field, "must be a non-negative integer string");
|
|
6491
5599
|
return BigInt(value);
|
|
6492
5600
|
}
|
|
6493
5601
|
//#endregion
|
|
@@ -6504,7 +5612,7 @@ function missingLiveOrgDep(portName) {
|
|
|
6504
5612
|
}
|
|
6505
5613
|
/** Zero `Money` in the USDX-backed display currency (a fresh Org's treasury). */
|
|
6506
5614
|
function zeroMoney() {
|
|
6507
|
-
return fromWei("0",
|
|
5615
|
+
return fromWei("0", USDX_DECIMALS, USDX_CURRENCY);
|
|
6508
5616
|
}
|
|
6509
5617
|
/** A fresh Org's treasury Account: `$0` balance, `available === balance`. */
|
|
6510
5618
|
function zeroTreasury(orgId) {
|
|
@@ -6753,30 +5861,6 @@ function inviteMemberProgram(orgId, input) {
|
|
|
6753
5861
|
return member;
|
|
6754
5862
|
});
|
|
6755
5863
|
}
|
|
6756
|
-
function pendingMembersProgram(orgId) {
|
|
6757
|
-
return Effect.gen(function* () {
|
|
6758
|
-
const deps = yield* OrgDepsTag;
|
|
6759
|
-
if (deps.orgPort?.pendingMembers !== void 0) return yield* deps.orgPort.pendingMembers({ orgId }).pipe(Effect.mapError((error) => error.publicError));
|
|
6760
|
-
if (deps.orgPort !== void 0) return (yield* deps.orgPort.listMembers({ orgId }).pipe(Effect.mapError((error) => error.publicError))).filter((member) => member.status === "pending" || member.status === "pending_safe" || member.status === "pending_grant");
|
|
6761
|
-
return [];
|
|
6762
|
-
});
|
|
6763
|
-
}
|
|
6764
|
-
function resendInviteTokenProgram(orgId, email) {
|
|
6765
|
-
return Effect.gen(function* () {
|
|
6766
|
-
const deps = yield* OrgDepsTag;
|
|
6767
|
-
if (deps.orgPort?.resendInviteToken !== void 0) return yield* deps.orgPort.resendInviteToken({
|
|
6768
|
-
orgId,
|
|
6769
|
-
email
|
|
6770
|
-
}).pipe(Effect.mapError((error) => error.publicError));
|
|
6771
|
-
if (!isHermeticOrgDeps(deps)) return yield* Effect.fail(missingLiveOrgDep("orgPort.resendInviteToken"));
|
|
6772
|
-
return hermeticMember({
|
|
6773
|
-
orgId,
|
|
6774
|
-
email,
|
|
6775
|
-
role: "Member",
|
|
6776
|
-
status: "pending"
|
|
6777
|
-
});
|
|
6778
|
-
});
|
|
6779
|
-
}
|
|
6780
5864
|
function detectAndAcceptPendingInvitationsProgram() {
|
|
6781
5865
|
return Effect.gen(function* () {
|
|
6782
5866
|
const deps = yield* OrgDepsTag;
|
|
@@ -6880,7 +5964,7 @@ function gateOneRun(input) {
|
|
|
6880
5964
|
subAccountBalanceRaw: subtractNonNegative(baseGateInput.subAccountBalanceRaw, accumulated),
|
|
6881
5965
|
spentTodayRaw: (BigInt(authority.spentTodayRaw ?? "0") + accumulated).toString(10)
|
|
6882
5966
|
}),
|
|
6883
|
-
catch: (cause) => isCapxulError(cause) ? cause : Errors.unknown(cause)
|
|
5967
|
+
catch: (cause) => isCapxulError$1(cause) ? cause : Errors.unknown(cause)
|
|
6884
5968
|
});
|
|
6885
5969
|
if (!decision.ok) return yield* Effect.fail(decision.error);
|
|
6886
5970
|
return {
|
|
@@ -6900,7 +5984,7 @@ function spendViaPaymentsProgram(orgId, input) {
|
|
|
6900
5984
|
if (deps.orgSpendPort === void 0 && !isHermeticOrgDeps(deps)) return yield* Effect.fail(missingLiveOrgDep("orgSpendPort"));
|
|
6901
5985
|
const to = yield* Effect.try({
|
|
6902
5986
|
try: () => refToRecipientString(input.to),
|
|
6903
|
-
catch: (cause) => isCapxulError(cause) ? cause : Errors.invalidInput("to", "invalid Ref")
|
|
5987
|
+
catch: (cause) => isCapxulError$1(cause) ? cause : Errors.invalidInput("to", "invalid Ref")
|
|
6904
5988
|
});
|
|
6905
5989
|
const gated = yield* gateOneRun({
|
|
6906
5990
|
deps,
|
|
@@ -6933,7 +6017,7 @@ function batchPayrollProgram(orgId, input) {
|
|
|
6933
6017
|
const gated = [];
|
|
6934
6018
|
const recipients = yield* Effect.try({
|
|
6935
6019
|
try: () => input.runs.map((run) => refToRecipientString(run.to)),
|
|
6936
|
-
catch: (cause) => isCapxulError(cause) ? cause : Errors.invalidInput("to", "invalid Ref")
|
|
6020
|
+
catch: (cause) => isCapxulError$1(cause) ? cause : Errors.invalidInput("to", "invalid Ref")
|
|
6937
6021
|
});
|
|
6938
6022
|
let accumulatedRaw = 0n;
|
|
6939
6023
|
for (const [index, run] of input.runs.entries()) {
|
|
@@ -7045,6 +6129,32 @@ function makeOrgMethods(deps) {
|
|
|
7045
6129
|
});
|
|
7046
6130
|
return toCapxulResult(readTreasuryProgram(orgId), layer);
|
|
7047
6131
|
},
|
|
6132
|
+
account: { async get(options) {
|
|
6133
|
+
if (options?.signal?.aborted) return {
|
|
6134
|
+
ok: false,
|
|
6135
|
+
error: Errors.cancelled({ operation: "org.account.get" })
|
|
6136
|
+
};
|
|
6137
|
+
const treasury = await toCapxulResult(readTreasuryProgram(orgId), layer);
|
|
6138
|
+
if (!treasury.ok) return {
|
|
6139
|
+
ok: false,
|
|
6140
|
+
error: treasury.error
|
|
6141
|
+
};
|
|
6142
|
+
const orgs = await toCapxulResult(listOrgsProgram(), layer);
|
|
6143
|
+
if (!orgs.ok) return {
|
|
6144
|
+
ok: false,
|
|
6145
|
+
error: orgs.error
|
|
6146
|
+
};
|
|
6147
|
+
const org = orgs.value.find((candidate) => candidate.id === orgId);
|
|
6148
|
+
return {
|
|
6149
|
+
ok: true,
|
|
6150
|
+
value: {
|
|
6151
|
+
id: treasury.value.id,
|
|
6152
|
+
address: org?.safeAddress ?? null,
|
|
6153
|
+
balance: treasury.value.balance,
|
|
6154
|
+
available: treasury.value.available
|
|
6155
|
+
}
|
|
6156
|
+
};
|
|
6157
|
+
} },
|
|
7048
6158
|
members(_options) {
|
|
7049
6159
|
if (_options?.signal?.aborted) return Promise.resolve({
|
|
7050
6160
|
ok: false,
|
|
@@ -7073,20 +6183,6 @@ function makeOrgMethods(deps) {
|
|
|
7073
6183
|
});
|
|
7074
6184
|
return toCapxulResult(inviteMemberProgram(orgId, _input), layer);
|
|
7075
6185
|
},
|
|
7076
|
-
pendingMembers(_options) {
|
|
7077
|
-
if (_options?.signal?.aborted) return Promise.resolve({
|
|
7078
|
-
ok: false,
|
|
7079
|
-
error: Errors.cancelled({ operation: "org.pendingMembers" })
|
|
7080
|
-
});
|
|
7081
|
-
return toCapxulResult(pendingMembersProgram(orgId), layer);
|
|
7082
|
-
},
|
|
7083
|
-
inviteToken: { resend(_input, _options) {
|
|
7084
|
-
if (_options?.signal?.aborted) return Promise.resolve({
|
|
7085
|
-
ok: false,
|
|
7086
|
-
error: Errors.cancelled({ operation: "org.inviteToken.resend" })
|
|
7087
|
-
});
|
|
7088
|
-
return toCapxulResult(resendInviteTokenProgram(orgId, String(_input.email)), layer);
|
|
7089
|
-
} },
|
|
7090
6186
|
removeMember(_input, _options) {
|
|
7091
6187
|
if (_options?.signal?.aborted) return Promise.resolve({
|
|
7092
6188
|
ok: false,
|
|
@@ -7115,6 +6211,16 @@ function makeOrgMethods(deps) {
|
|
|
7115
6211
|
});
|
|
7116
6212
|
return toCapxulResult(batchPayrollProgram(orgId, _input), layer);
|
|
7117
6213
|
},
|
|
6214
|
+
auditLog(_options) {
|
|
6215
|
+
if (_options?.signal?.aborted) return Promise.resolve({
|
|
6216
|
+
ok: false,
|
|
6217
|
+
error: Errors.cancelled({ operation: "org.auditLog" })
|
|
6218
|
+
});
|
|
6219
|
+
return Promise.resolve({
|
|
6220
|
+
ok: false,
|
|
6221
|
+
error: Errors.notImplemented("organizationAuditLog", "list")
|
|
6222
|
+
});
|
|
6223
|
+
},
|
|
7118
6224
|
payroll: convexCall === void 0 ? makeNotImplementedPayrollMethods() : makePayrollMethods({
|
|
7119
6225
|
orgId: String(orgId),
|
|
7120
6226
|
convexCall
|
|
@@ -7231,7 +6337,7 @@ async function runCompletePersonalOnboarding(ops, input) {
|
|
|
7231
6337
|
const validated = validatePersonalInput(input);
|
|
7232
6338
|
if (!validated.ok) return validated;
|
|
7233
6339
|
const session = await ops.currentSession();
|
|
7234
|
-
if (session === null) return fail(Errors.notAuthenticated());
|
|
6340
|
+
if (session === null) return fail(Errors$1.notAuthenticated());
|
|
7235
6341
|
const written = await ops.completeIdentityOnboarding({
|
|
7236
6342
|
authUserId: session.authUserId,
|
|
7237
6343
|
email: session.email,
|
|
@@ -7254,7 +6360,7 @@ async function runCompleteOrganizationOnboarding(ops, input) {
|
|
|
7254
6360
|
const validated = validateOrganizationInput(input);
|
|
7255
6361
|
if (!validated.ok) return validated;
|
|
7256
6362
|
const session = await ops.currentSession();
|
|
7257
|
-
if (session === null) return fail(Errors.notAuthenticated());
|
|
6363
|
+
if (session === null) return fail(Errors$1.notAuthenticated());
|
|
7258
6364
|
const written = await ops.completeIdentityOnboarding({
|
|
7259
6365
|
authUserId: session.authUserId,
|
|
7260
6366
|
email: session.email,
|
|
@@ -7326,7 +6432,7 @@ function validateOrganizationInput(input) {
|
|
|
7326
6432
|
}
|
|
7327
6433
|
function requireNonEmpty(value, field) {
|
|
7328
6434
|
const trimmed = typeof value === "string" ? value.trim() : "";
|
|
7329
|
-
if (trimmed.length === 0) return fail(Errors.invalidInput(field, "must be a non-empty string"));
|
|
6435
|
+
if (trimmed.length === 0) return fail(Errors$1.invalidInput(field, "must be a non-empty string"));
|
|
7330
6436
|
return {
|
|
7331
6437
|
ok: true,
|
|
7332
6438
|
value: trimmed
|
|
@@ -7354,12 +6460,12 @@ function parseAddress(value, field) {
|
|
|
7354
6460
|
}
|
|
7355
6461
|
function invalidFrom(field, cause, fallback) {
|
|
7356
6462
|
const message = cause instanceof Error && cause.message.length > 0 ? cause.message : fallback;
|
|
7357
|
-
return Errors.invalidInput(field, message);
|
|
6463
|
+
return Errors$1.invalidInput(field, message);
|
|
7358
6464
|
}
|
|
7359
6465
|
function fail(error) {
|
|
7360
6466
|
return {
|
|
7361
6467
|
ok: false,
|
|
7362
|
-
error: error instanceof CapxulError ? error : Errors.unknown(error)
|
|
6468
|
+
error: error instanceof CapxulError$2 ? error : Errors$1.unknown(error)
|
|
7363
6469
|
};
|
|
7364
6470
|
}
|
|
7365
6471
|
//#endregion
|
|
@@ -7376,14 +6482,14 @@ function makeOnboardingMethods(ops) {
|
|
|
7376
6482
|
completePersonal(input, options) {
|
|
7377
6483
|
if (options?.signal?.aborted) return Promise.resolve({
|
|
7378
6484
|
ok: false,
|
|
7379
|
-
error: Errors.cancelled({ operation: "onboarding.completePersonal" })
|
|
6485
|
+
error: Errors$1.cancelled({ operation: "onboarding.completePersonal" })
|
|
7380
6486
|
});
|
|
7381
6487
|
return runCompletePersonalOnboarding(ops, input);
|
|
7382
6488
|
},
|
|
7383
6489
|
completeOrganization(input, options) {
|
|
7384
6490
|
if (options?.signal?.aborted) return Promise.resolve({
|
|
7385
6491
|
ok: false,
|
|
7386
|
-
error: Errors.cancelled({ operation: "onboarding.completeOrganization" })
|
|
6492
|
+
error: Errors$1.cancelled({ operation: "onboarding.completeOrganization" })
|
|
7387
6493
|
});
|
|
7388
6494
|
return runCompleteOrganizationOnboarding(ops, input);
|
|
7389
6495
|
}
|
|
@@ -7469,6 +6575,12 @@ function assembleCapxulClient(input) {
|
|
|
7469
6575
|
if (selectedOrgPort !== void 0) detectPendingOrgInvitations = async () => {
|
|
7470
6576
|
await orgMethods.orgs.detectAndAcceptPendingInvitations();
|
|
7471
6577
|
};
|
|
6578
|
+
const currentUser = makeCurrentUserMethods({
|
|
6579
|
+
me: financialOps.me,
|
|
6580
|
+
accounts,
|
|
6581
|
+
smartAccount,
|
|
6582
|
+
orgs: orgMethods.orgs
|
|
6583
|
+
});
|
|
7472
6584
|
const onboarding = makeOnboardingMethods({
|
|
7473
6585
|
currentSession: async () => {
|
|
7474
6586
|
const session = await currentSession(actor, authCache);
|
|
@@ -7489,11 +6601,15 @@ function assembleCapxulClient(input) {
|
|
|
7489
6601
|
identity,
|
|
7490
6602
|
account,
|
|
7491
6603
|
accounts,
|
|
6604
|
+
currentUser,
|
|
7492
6605
|
me: financialOps.me,
|
|
7493
6606
|
handles: financialOps.handles,
|
|
7494
6607
|
payees: financialOps.payees,
|
|
6608
|
+
targets: financialOps.targets,
|
|
7495
6609
|
destinations: financialOps.destinations,
|
|
7496
6610
|
payments: financialOps.payments,
|
|
6611
|
+
activity: financialOps.activity,
|
|
6612
|
+
offramp: financialOps.offramp,
|
|
7497
6613
|
paymentDocuments: financialOps.paymentDocuments,
|
|
7498
6614
|
paymentRequests: financialOps.paymentRequests,
|
|
7499
6615
|
workbench: financialOps.workbench,
|
|
@@ -7834,7 +6950,7 @@ function validateCreateCapxulClientInput(input) {
|
|
|
7834
6950
|
const runtime = input.runtime ?? detectRuntime();
|
|
7835
6951
|
if ((input.requirement ?? "none") === "deployed" && input.signer === void 0 && runtime !== "browser") return {
|
|
7836
6952
|
ok: false,
|
|
7837
|
-
error: Errors.invalidInput("signer", "required when requirement is \"deployed\"")
|
|
6953
|
+
error: Errors$1.invalidInput("signer", "required when requirement is \"deployed\"")
|
|
7838
6954
|
};
|
|
7839
6955
|
return {
|
|
7840
6956
|
ok: true,
|
|
@@ -7867,10 +6983,10 @@ function detectRuntime() {
|
|
|
7867
6983
|
return globalAny.window !== void 0 || globalAny.document !== void 0 ? "browser" : "node";
|
|
7868
6984
|
}
|
|
7869
6985
|
function derivedBrowserOrigin(runtime) {
|
|
7870
|
-
if (runtime !== "browser") throw Errors.invalidInput("origin", "required outside browser runtime");
|
|
6986
|
+
if (runtime !== "browser") throw Errors$1.invalidInput("origin", "required outside browser runtime");
|
|
7871
6987
|
const globalAny = globalThis;
|
|
7872
6988
|
if (typeof globalAny.location?.origin === "string" && globalAny.location.origin.length > 0) return globalAny.location.origin;
|
|
7873
|
-
throw Errors.invalidInput("origin", "required when browser location is unavailable");
|
|
6989
|
+
throw Errors$1.invalidInput("origin", "required when browser location is unavailable");
|
|
7874
6990
|
}
|
|
7875
6991
|
/**
|
|
7876
6992
|
* Browser local dev serves `/api/auth` via the Vite proxy on `window.location.origin`
|
|
@@ -7939,20 +7055,20 @@ function normalizeHttpUrl(field, raw) {
|
|
|
7939
7055
|
try {
|
|
7940
7056
|
parsed = new URL(raw);
|
|
7941
7057
|
} catch {
|
|
7942
|
-
throw Errors.invalidInput(field, "must be an http or https URL");
|
|
7058
|
+
throw Errors$1.invalidInput(field, "must be an http or https URL");
|
|
7943
7059
|
}
|
|
7944
|
-
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw Errors.invalidInput(field, "must be an http or https URL");
|
|
7060
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw Errors$1.invalidInput(field, "must be an http or https URL");
|
|
7945
7061
|
return parsed.toString().replace(/\/$/, "");
|
|
7946
7062
|
}
|
|
7947
7063
|
function toPublicError(cause, operation) {
|
|
7948
|
-
if (cause instanceof CapxulError) return cause;
|
|
7064
|
+
if (cause instanceof CapxulError$2) return cause;
|
|
7949
7065
|
if (typeof cause === "object" && cause !== null) {
|
|
7950
7066
|
const publicError = cause.publicError;
|
|
7951
|
-
if (publicError instanceof CapxulError) return publicError;
|
|
7067
|
+
if (publicError instanceof CapxulError$2) return publicError;
|
|
7952
7068
|
const nestedCause = cause.cause;
|
|
7953
|
-
if (nestedCause instanceof CapxulError) return nestedCause;
|
|
7069
|
+
if (nestedCause instanceof CapxulError$2) return nestedCause;
|
|
7954
7070
|
}
|
|
7955
|
-
return Errors.providerError("sdk-production-adapters", operation, cause);
|
|
7071
|
+
return Errors$1.providerError("sdk-production-adapters", operation, cause);
|
|
7956
7072
|
}
|
|
7957
7073
|
function idempotentClose(close) {
|
|
7958
7074
|
let closed = false;
|
|
@@ -7969,6 +7085,6 @@ async function createCapxulClient(input) {
|
|
|
7969
7085
|
return createCapxulClient$1(input);
|
|
7970
7086
|
}
|
|
7971
7087
|
//#endregion
|
|
7972
|
-
export { captureException, captureExceptionSync, createCapxulClient, deriveDevPrivateKey, devPrivateKeySigner, eip1193AccountProvider, embeddedSigner, injectedWalletSigner, isSettingUpLifecycle, localPrivateKeyAccountProvider, openfortEmbeddedSigner, openfortEmbeddedSignerFromWallet, openfortEmbeddedWalletPort };
|
|
7088
|
+
export { CapxulError, captureException, captureExceptionSync, createCapxulClient, deriveDevPrivateKey, devPrivateKeySigner, eip1193AccountProvider, embeddedSigner, injectedWalletSigner, isCapxulError, isSettingUpLifecycle, localPrivateKeyAccountProvider, openfortEmbeddedSigner, openfortEmbeddedSignerFromWallet, openfortEmbeddedWalletPort };
|
|
7973
7089
|
|
|
7974
7090
|
//# sourceMappingURL=index.mjs.map
|