@capxul/mcp 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.mjs +484 -445
- package/package.json +3 -3
package/dist/main.mjs
CHANGED
|
@@ -240,7 +240,7 @@ function normalizeEmail(email) {
|
|
|
240
240
|
}
|
|
241
241
|
//#endregion
|
|
242
242
|
//#region package.json
|
|
243
|
-
var version$2 = "2.
|
|
243
|
+
var version$2 = "2.2.0";
|
|
244
244
|
//#endregion
|
|
245
245
|
//#region ../../packages/errors/src/errors.ts
|
|
246
246
|
const CAPXUL_ERROR_CODES = [
|
|
@@ -2492,6 +2492,7 @@ Object.fromEntries(SUPPORTED_CURRENCIES.map((currency) => [currency.code, curren
|
|
|
2492
2492
|
const EMAIL_RE$1 = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
2493
2493
|
const COUNTRY_CODE_RE = /^[A-Z]{2}$/;
|
|
2494
2494
|
const ACCOUNT_ID_RE = /^account_[0-9A-Za-z]+$/;
|
|
2495
|
+
const PARTY_ID_RE$1 = /^party_[0-9A-Za-z]+$/;
|
|
2495
2496
|
const APP_ID_RE = /^app_[0-7][0-9A-HJKMNP-TV-Z]{25}$/;
|
|
2496
2497
|
const WEI_RE = /^[0-9]+$/;
|
|
2497
2498
|
Math.floor(Number.MAX_SAFE_INTEGER / 1e3);
|
|
@@ -2510,6 +2511,10 @@ function toAccountId(raw) {
|
|
|
2510
2511
|
if (typeof raw !== "string" || !ACCOUNT_ID_RE.test(raw)) throw Errors.invalidInput("accountId", invalidValueReason("must be account_ plus an alphanumeric id", raw));
|
|
2511
2512
|
return raw;
|
|
2512
2513
|
}
|
|
2514
|
+
function toPartyId(raw) {
|
|
2515
|
+
if (typeof raw !== "string" || !PARTY_ID_RE$1.test(raw)) throw Errors.invalidInput("partyId", invalidValueReason("must be party_ plus an alphanumeric id", raw));
|
|
2516
|
+
return raw;
|
|
2517
|
+
}
|
|
2513
2518
|
function toOrgId(raw) {
|
|
2514
2519
|
return toNonEmptyStringBrand(raw, "orgId");
|
|
2515
2520
|
}
|
|
@@ -2871,6 +2876,7 @@ const PAYMENT_ID_RE = /^payment_[0-9A-Za-z]+$/;
|
|
|
2871
2876
|
const PAYEE_ID_RE = /^payee_[0-9A-Za-z]+$/;
|
|
2872
2877
|
const ORG_ID_RE = /^org_[0-9A-Za-z]+$/;
|
|
2873
2878
|
const USER_ID_RE = /^user_[0-9A-Za-z]+$/;
|
|
2879
|
+
const PARTY_ID_RE = /^party_[0-9A-Za-z]+$/;
|
|
2874
2880
|
const HANDLE_RE = /^@?[a-z0-9][a-z0-9-]{2,31}$/;
|
|
2875
2881
|
const ORG_HANDLE_RE = /^[a-z0-9][a-z0-9-]{2,31}$/;
|
|
2876
2882
|
const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
@@ -2879,6 +2885,7 @@ const PaymentIdSchema$1 = Schema.String.pipe(Schema.check(Schema.makeFilter((val
|
|
|
2879
2885
|
const PayeeIdSchema = Schema.String.pipe(Schema.check(Schema.makeFilter((value) => PAYEE_ID_RE.test(value), { message: "must be payee_ plus an alphanumeric id" })));
|
|
2880
2886
|
const OrgIdSchema = Schema.String.pipe(Schema.check(Schema.makeFilter((value) => ORG_ID_RE.test(value), { message: "must be org_ plus an alphanumeric id" })));
|
|
2881
2887
|
const UserIdSchema = Schema.String.pipe(Schema.check(Schema.makeFilter((value) => USER_ID_RE.test(value), { message: "must be user_ plus an alphanumeric id" })));
|
|
2888
|
+
const PartyIdSchema = Schema.String.pipe(Schema.check(Schema.makeFilter((value) => PARTY_ID_RE.test(value), { message: "must be party_ plus an alphanumeric id" })));
|
|
2882
2889
|
const DecimalStringSchema = Schema.String.pipe(Schema.check(Schema.makeFilter((value) => DECIMAL_STRING_RE.test(value), { message: "must be a non-negative decimal string" })));
|
|
2883
2890
|
const HandleValueSchema = Schema.String.pipe(Schema.check(Schema.makeFilter((value) => !EVM_ADDRESS_RE.test(value) && HANDLE_RE.test(value), { message: "must be a handle; raw addresses are not accepted" })));
|
|
2884
2891
|
const OrgHandleValueSchema = Schema.String.pipe(Schema.check(Schema.makeFilter((value) => !EVM_ADDRESS_RE.test(value) && ORG_HANDLE_RE.test(value), { message: "must be an org handle; raw addresses are not accepted" })));
|
|
@@ -3025,6 +3032,7 @@ const PaymentRecipient = Schema.Struct({
|
|
|
3025
3032
|
"capxulUserId",
|
|
3026
3033
|
"me",
|
|
3027
3034
|
"org",
|
|
3035
|
+
"party",
|
|
3028
3036
|
"external_address"
|
|
3029
3037
|
]),
|
|
3030
3038
|
label: Schema.String,
|
|
@@ -3071,6 +3079,10 @@ const PaymentRef = Schema.Union([
|
|
|
3071
3079
|
Schema.Struct({
|
|
3072
3080
|
kind: Schema.Literal("payeeId"),
|
|
3073
3081
|
payeeId: PayeeIdSchema
|
|
3082
|
+
}),
|
|
3083
|
+
Schema.Struct({
|
|
3084
|
+
kind: Schema.Literal("party"),
|
|
3085
|
+
partyId: PartyIdSchema
|
|
3074
3086
|
})
|
|
3075
3087
|
]);
|
|
3076
3088
|
const Payment = Schema.Struct({
|
|
@@ -4501,6 +4513,7 @@ const PAYMENT_OUTPUT = {
|
|
|
4501
4513
|
"capxulUserId",
|
|
4502
4514
|
"me",
|
|
4503
4515
|
"org",
|
|
4516
|
+
"party",
|
|
4504
4517
|
"external_address"
|
|
4505
4518
|
]),
|
|
4506
4519
|
label: z.string(),
|
|
@@ -4594,6 +4607,10 @@ const REF = z.union([
|
|
|
4594
4607
|
z.object({
|
|
4595
4608
|
kind: z.literal("payeeId"),
|
|
4596
4609
|
payeeId: z.string()
|
|
4610
|
+
}),
|
|
4611
|
+
z.object({
|
|
4612
|
+
kind: z.literal("party"),
|
|
4613
|
+
partyId: z.string()
|
|
4597
4614
|
})
|
|
4598
4615
|
]);
|
|
4599
4616
|
const TIMING = z.union([
|
|
@@ -4616,11 +4633,14 @@ const ADDRESS_BOOK_ENTRY = z.object({
|
|
|
4616
4633
|
relationship: z.array(z.enum([
|
|
4617
4634
|
"paid",
|
|
4618
4635
|
"paidBy",
|
|
4619
|
-
"
|
|
4636
|
+
"invoiced",
|
|
4637
|
+
"invoicedBy",
|
|
4620
4638
|
"member",
|
|
4621
|
-
"
|
|
4639
|
+
"manual",
|
|
4640
|
+
"employed"
|
|
4622
4641
|
])),
|
|
4623
|
-
hidden: z.boolean()
|
|
4642
|
+
hidden: z.boolean(),
|
|
4643
|
+
lastActivityAt: z.number()
|
|
4624
4644
|
});
|
|
4625
4645
|
const ACTOR_REQUEST = z.object({
|
|
4626
4646
|
id: z.string(),
|
|
@@ -4698,6 +4718,9 @@ function actor(kind, orgId) {
|
|
|
4698
4718
|
function orgIdArg(args) {
|
|
4699
4719
|
return typeof args === "object" && args !== null && "orgId" in args && typeof args.orgId === "string" ? args.orgId : void 0;
|
|
4700
4720
|
}
|
|
4721
|
+
function permissionIdArg(args) {
|
|
4722
|
+
return typeof args === "object" && args !== null && "permissionId" in args && typeof args.permissionId === "string" ? args.permissionId : void 0;
|
|
4723
|
+
}
|
|
4701
4724
|
function requireMethod(handle, method, domain) {
|
|
4702
4725
|
const value = handle[method];
|
|
4703
4726
|
if (value === void 0) return {
|
|
@@ -4769,7 +4792,7 @@ function registerAddressBookTools(server, deps, scope) {
|
|
|
4769
4792
|
}, (args) => withSession(deps, args.sessionToken, `${prefix}.get`, async (handle) => {
|
|
4770
4793
|
const method = requireMethod(handle, "addressBookGet", prefix);
|
|
4771
4794
|
if (!method.ok) return methodNotImplemented(prefix, "get");
|
|
4772
|
-
const res = await method.value(actor(scope, orgIdArg(args)), args.entryId);
|
|
4795
|
+
const res = await method.value(actor(scope, orgIdArg(args)), toPartyId(args.entryId));
|
|
4773
4796
|
return res.ok ? okResult({ entry: res.value }) : errorResult(res.error);
|
|
4774
4797
|
}));
|
|
4775
4798
|
server.registerTool(`${prefix}.add`, {
|
|
@@ -4803,7 +4826,7 @@ function registerAddressBookTools(server, deps, scope) {
|
|
|
4803
4826
|
}, (args) => withSession(deps, args.sessionToken, `${prefix}.${action}`, async (handle) => {
|
|
4804
4827
|
const method = requireMethod(handle, action === "hide" ? "addressBookHide" : "addressBookUnhide", prefix);
|
|
4805
4828
|
if (!method.ok) return methodNotImplemented(prefix, action);
|
|
4806
|
-
return result(await method.value(actor(scope, orgIdArg(args)), args.entryId));
|
|
4829
|
+
return result(await method.value(actor(scope, orgIdArg(args)), toPartyId(args.entryId)));
|
|
4807
4830
|
}));
|
|
4808
4831
|
server.registerTool(`${prefix}.label`, {
|
|
4809
4832
|
title: `${scope} address book label`,
|
|
@@ -4820,7 +4843,7 @@ function registerAddressBookTools(server, deps, scope) {
|
|
|
4820
4843
|
if (!method.ok) return methodNotImplemented(prefix, "label");
|
|
4821
4844
|
return result(await method.value({
|
|
4822
4845
|
actor: actor(scope, orgIdArg(args)),
|
|
4823
|
-
entryId: args.entryId,
|
|
4846
|
+
entryId: toPartyId(args.entryId),
|
|
4824
4847
|
label: args.label
|
|
4825
4848
|
}));
|
|
4826
4849
|
}));
|
|
@@ -4909,13 +4932,14 @@ function registerInboxTools(server, deps, scope) {
|
|
|
4909
4932
|
sessionToken: z.string(),
|
|
4910
4933
|
...scopeInput,
|
|
4911
4934
|
requestId: z.string(),
|
|
4912
|
-
timing: TIMING.optional()
|
|
4935
|
+
timing: TIMING.optional(),
|
|
4936
|
+
...scope === "org" ? { permissionId: z.string() } : {}
|
|
4913
4937
|
},
|
|
4914
4938
|
outputSchema: PAYMENT_OUTPUT
|
|
4915
4939
|
}, (args) => withSession(deps, args.sessionToken, `${prefix}.approve`, async (handle) => {
|
|
4916
4940
|
const method = requireMethod(handle, "inboxApprove", prefix);
|
|
4917
4941
|
if (!method.ok) return methodNotImplemented(prefix, "approve");
|
|
4918
|
-
return paymentResult(await method.value(actor(scope, orgIdArg(args)), args.requestId, args.timing));
|
|
4942
|
+
return paymentResult(await method.value(actor(scope, orgIdArg(args)), args.requestId, args.timing, permissionIdArg(args)));
|
|
4919
4943
|
}));
|
|
4920
4944
|
server.registerTool(`${prefix}.decline`, {
|
|
4921
4945
|
title: `${scope} inbox decline`,
|
|
@@ -6000,86 +6024,24 @@ const transition = (state, event, config = DEFAULT_CONFIG) => {
|
|
|
6000
6024
|
const PRIVATE_TAGS = new Set(PRIVATE_EVENT_TAGS);
|
|
6001
6025
|
const isPrivate = (event) => PRIVATE_TAGS.has(event._tag);
|
|
6002
6026
|
//#endregion
|
|
6003
|
-
//#region ../../packages/sdk/src/
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
* `at new ClassName (url:line:col)`
|
|
6011
|
-
*/
|
|
6012
|
-
const V8_FRAME_RE = /^\s*at\s+(?:(.+?)\s+\()?(?:(.+?)(?::(\d+):(\d+))?|(.+?))\)?\s*$/;
|
|
6013
|
-
function isNonUrlName(name) {
|
|
6014
|
-
return name === "<anonymous>" || name.startsWith("eval") || name.startsWith("new ") || name.startsWith("async ");
|
|
6027
|
+
//#region ../../packages/sdk/src/surface/_shared/provisioning-telemetry.ts
|
|
6028
|
+
async function emitProvisioningTelemetry(telemetry, smartAccount) {
|
|
6029
|
+
if (telemetry === void 0) return;
|
|
6030
|
+
await Effect.runPromise(telemetry.emit({
|
|
6031
|
+
name: "provisioning_safe_created",
|
|
6032
|
+
props: { safe_address: smartAccount.smartAccountAddress }
|
|
6033
|
+
}).pipe(Effect.catch((cause) => Effect.sync(() => reportProvisioningTelemetryFailure("error", smartAccount, cause))), Effect.catchDefect((cause) => Effect.sync(() => reportProvisioningTelemetryFailure("defect", smartAccount, cause)))));
|
|
6015
6034
|
}
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
* - `at async functionName (url:line:col)`
|
|
6024
|
-
* - `at new ClassName (url:line:col)`
|
|
6025
|
-
* - Native frames: `at Array.forEach (<anonymous>)`
|
|
6026
|
-
*/
|
|
6027
|
-
function parseV8StackFrames(error) {
|
|
6028
|
-
const stack = error.stack;
|
|
6029
|
-
if (stack === void 0 || stack === null || stack === "") return [];
|
|
6030
|
-
const lines = stack.split("\n");
|
|
6031
|
-
const frames = [];
|
|
6032
|
-
for (const line of lines) {
|
|
6033
|
-
const trimmed = line.trim();
|
|
6034
|
-
if (!trimmed.startsWith("at ")) continue;
|
|
6035
|
-
const match = V8_FRAME_RE.exec(trimmed);
|
|
6036
|
-
if (match === null) continue;
|
|
6037
|
-
if (match[1] !== void 0) frames.push({
|
|
6038
|
-
function: match[1],
|
|
6039
|
-
filename: match[2],
|
|
6040
|
-
lineno: match[3] !== void 0 ? Number(match[3]) : null,
|
|
6041
|
-
colno: match[4] !== void 0 ? Number(match[4]) : null
|
|
6042
|
-
});
|
|
6043
|
-
else if (match[2] !== void 0 && !isNonUrlName(match[2])) frames.push({
|
|
6044
|
-
function: "<anonymous>",
|
|
6045
|
-
filename: match[2],
|
|
6046
|
-
lineno: match[3] !== void 0 ? Number(match[3]) : null,
|
|
6047
|
-
colno: match[4] !== void 0 ? Number(match[4]) : null
|
|
6048
|
-
});
|
|
6049
|
-
else frames.push({
|
|
6050
|
-
function: match[1] ?? match[2] ?? match[5] ?? "<anonymous>",
|
|
6051
|
-
filename: match[2] ?? match[5] ?? "<anonymous>",
|
|
6052
|
-
lineno: match[3] !== void 0 ? Number(match[3]) : null,
|
|
6053
|
-
colno: match[4] !== void 0 ? Number(match[4]) : null
|
|
6054
|
-
});
|
|
6055
|
-
}
|
|
6056
|
-
return frames;
|
|
6035
|
+
function reportProvisioningTelemetryFailure(kind, smartAccount, cause) {
|
|
6036
|
+
if (!isProvisioningTelemetryDebugEnabled()) return;
|
|
6037
|
+
globalThis.console?.warn?.("[capxul] provisioning telemetry dropped", {
|
|
6038
|
+
kind,
|
|
6039
|
+
safeAddress: smartAccount.smartAccountAddress,
|
|
6040
|
+
cause
|
|
6041
|
+
});
|
|
6057
6042
|
}
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
/**
|
|
6061
|
-
* Build PostHog's `$exception_list` (always a single entry). Error Tracking
|
|
6062
|
-
* groups on `type`, so it is ALWAYS present (the CapxulError code) — the
|
|
6063
|
-
* previous `[{ frames }]` shape omitted it and PostHog dropped the event as
|
|
6064
|
-
* "missing field `type`". When the error has no parseable stack, a synthetic
|
|
6065
|
-
* boundary frame stands in so the event still ingests as a real Issue (#1031).
|
|
6066
|
-
*/
|
|
6067
|
-
function buildExceptionList(input) {
|
|
6068
|
-
const frames = input.frames.length > 0 ? input.frames : [{
|
|
6069
|
-
filename: SDK_BOUNDARY_FILENAME,
|
|
6070
|
-
function: input.operation ?? "unknown",
|
|
6071
|
-
lineno: 1,
|
|
6072
|
-
colno: 1
|
|
6073
|
-
}];
|
|
6074
|
-
return [{
|
|
6075
|
-
type: input.type,
|
|
6076
|
-
value: input.value,
|
|
6077
|
-
mechanism: {
|
|
6078
|
-
handled: true,
|
|
6079
|
-
type: "capxul_sdk_boundary"
|
|
6080
|
-
},
|
|
6081
|
-
stacktrace: { frames }
|
|
6082
|
-
}];
|
|
6043
|
+
function isProvisioningTelemetryDebugEnabled() {
|
|
6044
|
+
return globalThis.process?.env?.CAPXUL_DEBUG_TELEMETRY === "1";
|
|
6083
6045
|
}
|
|
6084
6046
|
//#endregion
|
|
6085
6047
|
//#region ../../packages/sdk/src/telemetry/get-failure-mode.ts
|
|
@@ -6112,94 +6074,25 @@ function getFailureMode(error) {
|
|
|
6112
6074
|
if (details === void 0) return void 0;
|
|
6113
6075
|
return isFailureMode(details.failure_mode) ? details.failure_mode : void 0;
|
|
6114
6076
|
}
|
|
6115
|
-
/**
|
|
6116
|
-
* Resolve the canonical {@link FailureMode} for a `$exception`, guaranteeing a
|
|
6117
|
-
* taxonomy member is always returned — never `undefined`, never a free string.
|
|
6118
|
-
*
|
|
6119
|
-
* Resolution order:
|
|
6120
|
-
* 1. the structured mode on the error's `details.failure_mode` (already guarded);
|
|
6121
|
-
* 2. a caller-supplied `contextFailureMode`, but ONLY when it passes the same
|
|
6122
|
-
* runtime membership check — the static `FailureMode` type is erased at
|
|
6123
|
-
* runtime, so an operation string (e.g. `"signer-get-address"`) injected via
|
|
6124
|
-
* a JS caller or `as` cast is rejected here rather than leaking to telemetry;
|
|
6125
|
-
* 3. `"unknown"` otherwise, so an unclassifiable error is still tagged with a
|
|
6126
|
-
* canonical value instead of being emitted with no `failure_mode` at all.
|
|
6127
|
-
*/
|
|
6128
|
-
function resolveFailureMode(error, contextFailureMode) {
|
|
6129
|
-
return getFailureMode(error) ?? (isFailureMode(contextFailureMode) ? contextFailureMode : "unknown");
|
|
6130
|
-
}
|
|
6131
6077
|
//#endregion
|
|
6132
|
-
//#region ../../packages/sdk/src/
|
|
6133
|
-
/**
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
function captureException(telemetry, error, context) {
|
|
6147
|
-
return Effect.catchDefect(Effect.sync(() => {
|
|
6148
|
-
const frames = error instanceof Error ? parseV8StackFrames(error) : [];
|
|
6149
|
-
const capxulError = isCapxulError(error) ? error : null;
|
|
6150
|
-
const errorCode = capxulError?.code ?? context?.capxul_error_code ?? "UNKNOWN";
|
|
6151
|
-
const props = {
|
|
6152
|
-
capxul_error_code: errorCode,
|
|
6153
|
-
$exception_type: errorCode,
|
|
6154
|
-
$exception_message: EXCEPTION_MESSAGE,
|
|
6155
|
-
$exception_list: buildExceptionList({
|
|
6156
|
-
type: errorCode,
|
|
6157
|
-
value: EXCEPTION_MESSAGE,
|
|
6158
|
-
...context?.operation === void 0 ? {} : { operation: context.operation },
|
|
6159
|
-
frames
|
|
6160
|
-
}),
|
|
6161
|
-
layer: capxulError?.layer ?? context?.layer,
|
|
6162
|
-
operation: context?.operation,
|
|
6163
|
-
provider: context?.provider,
|
|
6164
|
-
failure_mode: resolveFailureMode(error, context?.failure_mode)
|
|
6165
|
-
};
|
|
6166
|
-
if (capxulError?.details !== void 0) props.details = JSON.stringify(capxulError.details);
|
|
6167
|
-
for (const key of Object.keys(props)) if (props[key] === void 0) delete props[key];
|
|
6168
|
-
return telemetry.emit({
|
|
6169
|
-
name: "$exception",
|
|
6170
|
-
props
|
|
6078
|
+
//#region ../../packages/sdk/src/signer.ts
|
|
6079
|
+
/** Fold a signer throw into the public error contract. */
|
|
6080
|
+
function signerFailure(source, operation, cause) {
|
|
6081
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6082
|
+
let failureMode;
|
|
6083
|
+
let current = cause;
|
|
6084
|
+
while (typeof current === "object" && current !== null && !seen.has(current)) {
|
|
6085
|
+
seen.add(current);
|
|
6086
|
+
if (current instanceof CapxulError && current.code === "SIGNER_REJECTED") return current;
|
|
6087
|
+
failureMode = getFailureMode(current) ?? failureMode;
|
|
6088
|
+
const error = current;
|
|
6089
|
+
if (error.code === 4001 || error.error === "passkey_user_cancelled") return Errors.signerRejected({
|
|
6090
|
+
source,
|
|
6091
|
+
cause
|
|
6171
6092
|
});
|
|
6172
|
-
|
|
6173
|
-
}
|
|
6174
|
-
|
|
6175
|
-
* Synchronous fire-and-forget capture. Runs the Effect inline with
|
|
6176
|
-
* `Effect.runSync` so callers outside an Effect context (e.g. React
|
|
6177
|
-
* hooks before throwing) can report errors without awaiting.
|
|
6178
|
-
*/
|
|
6179
|
-
function captureExceptionSync(telemetry, error, context) {
|
|
6180
|
-
try {
|
|
6181
|
-
Effect.runSync(captureException(telemetry, error, context));
|
|
6182
|
-
} catch {}
|
|
6183
|
-
}
|
|
6184
|
-
//#endregion
|
|
6185
|
-
//#region ../../packages/sdk/src/surface/_shared/provisioning-telemetry.ts
|
|
6186
|
-
async function emitProvisioningTelemetry(telemetry, smartAccount) {
|
|
6187
|
-
if (telemetry === void 0) return;
|
|
6188
|
-
await Effect.runPromise(telemetry.emit({
|
|
6189
|
-
name: "provisioning_safe_created",
|
|
6190
|
-
props: { safe_address: smartAccount.smartAccountAddress }
|
|
6191
|
-
}).pipe(Effect.catch((cause) => Effect.sync(() => reportProvisioningTelemetryFailure("error", smartAccount, cause))), Effect.catchDefect((cause) => Effect.sync(() => reportProvisioningTelemetryFailure("defect", smartAccount, cause)))));
|
|
6192
|
-
}
|
|
6193
|
-
function reportProvisioningTelemetryFailure(kind, smartAccount, cause) {
|
|
6194
|
-
if (!isProvisioningTelemetryDebugEnabled()) return;
|
|
6195
|
-
globalThis.console?.warn?.("[capxul] provisioning telemetry dropped", {
|
|
6196
|
-
kind,
|
|
6197
|
-
safeAddress: smartAccount.smartAccountAddress,
|
|
6198
|
-
cause
|
|
6199
|
-
});
|
|
6200
|
-
}
|
|
6201
|
-
function isProvisioningTelemetryDebugEnabled() {
|
|
6202
|
-
return globalThis.process?.env?.CAPXUL_DEBUG_TELEMETRY === "1";
|
|
6093
|
+
current = error.cause;
|
|
6094
|
+
}
|
|
6095
|
+
return Errors.providerError("signer", operation, cause, failureMode === void 0 ? void 0 : { failure_mode: failureMode });
|
|
6203
6096
|
}
|
|
6204
6097
|
//#endregion
|
|
6205
6098
|
//#region ../../packages/sdk/src/internal/invocation-observation.ts
|
|
@@ -6762,7 +6655,7 @@ const accountStatusProgram = Effect.gen(function* () {
|
|
|
6762
6655
|
};
|
|
6763
6656
|
const signerAddress = yield* Effect.tryPromise({
|
|
6764
6657
|
try: () => signer.getAddress(),
|
|
6765
|
-
catch: (cause) =>
|
|
6658
|
+
catch: (cause) => signerFailure(signer.source, "getAddress", cause)
|
|
6766
6659
|
});
|
|
6767
6660
|
return {
|
|
6768
6661
|
status: "accountProviderReady",
|
|
@@ -7265,55 +7158,42 @@ function makeActorRelationshipMethods(deps) {
|
|
|
7265
7158
|
const fns = actorScopeContract;
|
|
7266
7159
|
return {
|
|
7267
7160
|
addressBook: {
|
|
7268
|
-
list: (options) => mapOk$1(awaitableConvex(options?.signal, "addressBook.list", () => convexCall.query(fns.addressBookList, {
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
},
|
|
7161
|
+
list: (input, options) => mapOk$1("addressBook.list", awaitableConvex(options?.signal, "addressBook.list", () => convexCall.query(fns.addressBookList, {
|
|
7162
|
+
actor,
|
|
7163
|
+
...input?.includeHidden === void 0 ? {} : { includeHidden: input.includeHidden }
|
|
7164
|
+
})), (entries) => entries.map(mapAddressBookEntry)),
|
|
7165
|
+
get: (entryId, options) => mapOk$1("addressBook.get", awaitableConvex(options?.signal, "addressBook.get", () => convexCall.query(fns.addressBookGet, {
|
|
7166
|
+
actor,
|
|
7167
|
+
partyId: entryId
|
|
7168
|
+
})), (entry) => entry === null ? null : mapAddressBookEntry(entry)),
|
|
7277
7169
|
add: async (input, options) => {
|
|
7278
7170
|
const ref = normalizeRefForBackend$1(input.ref, "ref");
|
|
7279
7171
|
if (!ref.ok) return ref;
|
|
7280
|
-
return mapOk$1(await awaitableConvex(options?.signal, "addressBook.add", () => convexCall.mutation(fns.addressBookAdd, {
|
|
7172
|
+
return mapOk$1("addressBook.add", await awaitableConvex(options?.signal, "addressBook.add", () => convexCall.mutation(fns.addressBookAdd, {
|
|
7281
7173
|
actor,
|
|
7282
7174
|
ref: ref.value,
|
|
7283
7175
|
...input.label === void 0 ? {} : { label: input.label }
|
|
7284
7176
|
})), mapAddressBookEntry);
|
|
7285
7177
|
},
|
|
7286
|
-
hide:
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
},
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
ref: ref.value
|
|
7300
|
-
})), mapAddressBookEntry);
|
|
7301
|
-
},
|
|
7302
|
-
label: async (input, options) => {
|
|
7303
|
-
const ref = refFromEntryId(input.entryId);
|
|
7304
|
-
if (!ref.ok) return ref;
|
|
7305
|
-
return mapOk$1(await awaitableConvex(options?.signal, "addressBook.label", () => convexCall.mutation(fns.addressBookLabel, {
|
|
7306
|
-
actor,
|
|
7307
|
-
ref: ref.value,
|
|
7308
|
-
label: input.label
|
|
7309
|
-
})), mapAddressBookEntry);
|
|
7310
|
-
}
|
|
7178
|
+
hide: (entryId, options) => mapOk$1("addressBook.hide", awaitableConvex(options?.signal, "addressBook.hide", () => convexCall.mutation(fns.addressBookHide, {
|
|
7179
|
+
actor,
|
|
7180
|
+
partyId: entryId
|
|
7181
|
+
})), mapAddressBookEntry),
|
|
7182
|
+
unhide: (entryId, options) => mapOk$1("addressBook.unhide", awaitableConvex(options?.signal, "addressBook.unhide", () => convexCall.mutation(fns.addressBookUnhide, {
|
|
7183
|
+
actor,
|
|
7184
|
+
partyId: entryId
|
|
7185
|
+
})), mapAddressBookEntry),
|
|
7186
|
+
label: (input, options) => mapOk$1("addressBook.label", awaitableConvex(options?.signal, "addressBook.label", () => convexCall.mutation(fns.addressBookLabel, {
|
|
7187
|
+
actor,
|
|
7188
|
+
partyId: input.entryId,
|
|
7189
|
+
label: input.label
|
|
7190
|
+
})), mapAddressBookEntry)
|
|
7311
7191
|
},
|
|
7312
7192
|
requests: {
|
|
7313
7193
|
issue: async (input, options) => {
|
|
7314
7194
|
const payer = normalizeRefForBackend$1(input.payer, "payer");
|
|
7315
7195
|
if (!payer.ok) return payer;
|
|
7316
|
-
return mapOk$1(await awaitableConvex(options?.signal, "requests.issue", () => convexCall.mutation(fns.requestsIssue, {
|
|
7196
|
+
return mapOk$1("requests.issue", await awaitableConvex(options?.signal, "requests.issue", () => convexCall.mutation(fns.requestsIssue, {
|
|
7317
7197
|
actor,
|
|
7318
7198
|
payer: payer.value,
|
|
7319
7199
|
amount: input.amount,
|
|
@@ -7322,18 +7202,18 @@ function makeActorRelationshipMethods(deps) {
|
|
|
7322
7202
|
...input.expiresAt === void 0 ? {} : { expiresAt: input.expiresAt }
|
|
7323
7203
|
})), (request) => mapActorRequest(request, input.payer));
|
|
7324
7204
|
},
|
|
7325
|
-
list: (options) => mapOk$1(awaitableConvex(options?.signal, "requests.list", () => convexCall.query(fns.requestsList, { actor })), (requests) => requests.map((request) => mapActorRequest(request))),
|
|
7326
|
-
get: (requestId, options) => mapOk$1(awaitableConvex(options?.signal, "requests.get", () => convexCall.query(fns.requestsGet, {
|
|
7205
|
+
list: (options) => mapOk$1("requests.list", awaitableConvex(options?.signal, "requests.list", () => convexCall.query(fns.requestsList, { actor })), (requests) => requests.map((request) => mapActorRequest(request))),
|
|
7206
|
+
get: (requestId, options) => mapOk$1("requests.get", awaitableConvex(options?.signal, "requests.get", () => convexCall.query(fns.requestsGet, {
|
|
7327
7207
|
actor,
|
|
7328
7208
|
paymentRequestId: requestId
|
|
7329
7209
|
})), (request) => request === null ? null : mapActorRequest(request)),
|
|
7330
|
-
cancel: (requestId, options) => mapOk$1(awaitableConvex(options?.signal, "requests.cancel", () => convexCall.mutation(fns.requestsCancel, {
|
|
7210
|
+
cancel: (requestId, options) => mapOk$1("requests.cancel", awaitableConvex(options?.signal, "requests.cancel", () => convexCall.mutation(fns.requestsCancel, {
|
|
7331
7211
|
actor,
|
|
7332
7212
|
paymentRequestId: requestId
|
|
7333
7213
|
})), (request) => mapActorRequest(request))
|
|
7334
7214
|
},
|
|
7335
7215
|
inbox: {
|
|
7336
|
-
list: (options) => mapOk$1(awaitableConvex(options?.signal, "inbox.list", () => convexCall.query(fns.inboxList, { actor })), (items) => items.map(mapInboxItem)),
|
|
7216
|
+
list: (options) => mapOk$1("inbox.list", awaitableConvex(options?.signal, "inbox.list", () => convexCall.query(fns.inboxList, { actor })), (items) => items.map(mapInboxItem)),
|
|
7337
7217
|
approve: async (input, options) => {
|
|
7338
7218
|
const result = await awaitableConvex(options?.signal, "inbox.approve", () => convexCall.mutation(fns.inboxApprove, {
|
|
7339
7219
|
actor,
|
|
@@ -7344,7 +7224,7 @@ function makeActorRelationshipMethods(deps) {
|
|
|
7344
7224
|
if (!result.ok) return result;
|
|
7345
7225
|
return mapApprovedInboxPayment(result.value, input);
|
|
7346
7226
|
},
|
|
7347
|
-
decline: (requestId, options) => mapOk$1(awaitableConvex(options?.signal, "inbox.decline", () => convexCall.mutation(fns.inboxDecline, {
|
|
7227
|
+
decline: (requestId, options) => mapOk$1("inbox.decline", awaitableConvex(options?.signal, "inbox.decline", () => convexCall.mutation(fns.inboxDecline, {
|
|
7348
7228
|
actor,
|
|
7349
7229
|
paymentRequestId: requestId
|
|
7350
7230
|
})), mapInboxItem)
|
|
@@ -7412,30 +7292,52 @@ function missingConvexCall(operation) {
|
|
|
7412
7292
|
error: Errors.providerError("convex", operation, "ConvexCallPort is required")
|
|
7413
7293
|
});
|
|
7414
7294
|
}
|
|
7415
|
-
|
|
7295
|
+
/**
|
|
7296
|
+
* Project a successful backend reply, WITHOUT leaving the result boundary.
|
|
7297
|
+
*
|
|
7298
|
+
* The projection can refuse: `mapAddressBookEntry` proves the entry id is a
|
|
7299
|
+
* `PartyId` rather than trusting the wire, and `toPartyId` throws on a
|
|
7300
|
+
* malformed one. Every verb on this surface returns `CapxulResult`, so that
|
|
7301
|
+
* throw has to become a value here — otherwise a malformed reply rejects the
|
|
7302
|
+
* promise and the caller's `if (!result.ok)` never runs (ADR-0023: errors are
|
|
7303
|
+
* values, and a code crosses the seam).
|
|
7304
|
+
*/
|
|
7305
|
+
async function mapOk$1(operation, resultOrPromise, f) {
|
|
7416
7306
|
const result = await resultOrPromise;
|
|
7417
7307
|
if (!result.ok) return result;
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7308
|
+
try {
|
|
7309
|
+
return {
|
|
7310
|
+
ok: true,
|
|
7311
|
+
value: f(result.value)
|
|
7312
|
+
};
|
|
7313
|
+
} catch (cause) {
|
|
7314
|
+
return {
|
|
7315
|
+
ok: false,
|
|
7316
|
+
error: cause instanceof CapxulError ? cause : Errors.providerError("convex", operation, cause)
|
|
7317
|
+
};
|
|
7318
|
+
}
|
|
7422
7319
|
}
|
|
7423
7320
|
const awaitableConvex = runIfActive;
|
|
7321
|
+
const ADDRESS_BOOK_RELATIONSHIPS = [
|
|
7322
|
+
"paid",
|
|
7323
|
+
"paidBy",
|
|
7324
|
+
"invoiced",
|
|
7325
|
+
"invoicedBy",
|
|
7326
|
+
"member",
|
|
7327
|
+
"manual",
|
|
7328
|
+
"employed"
|
|
7329
|
+
];
|
|
7330
|
+
function isAddressBookRelationship(value) {
|
|
7331
|
+
return ADDRESS_BOOK_RELATIONSHIPS.includes(value);
|
|
7332
|
+
}
|
|
7424
7333
|
function mapAddressBookEntry(entry) {
|
|
7425
|
-
const relationship = /* @__PURE__ */ new Set();
|
|
7426
|
-
for (const edge of entry.edges) {
|
|
7427
|
-
if (edge === "paid") relationship.add("paid");
|
|
7428
|
-
if (edge === "paidBy") relationship.add("paidBy");
|
|
7429
|
-
if (edge === "requested" || edge === "requestedBy") relationship.add("requested");
|
|
7430
|
-
if (edge === "member") relationship.add("member");
|
|
7431
|
-
if (edge === "employee") relationship.add("employee");
|
|
7432
|
-
}
|
|
7433
7334
|
return {
|
|
7434
|
-
id: entry.id,
|
|
7335
|
+
id: toPartyId(entry.id),
|
|
7435
7336
|
ref: entry.ref,
|
|
7436
|
-
label: entry.label
|
|
7437
|
-
relationship:
|
|
7438
|
-
hidden: entry.hidden
|
|
7337
|
+
label: entry.label,
|
|
7338
|
+
relationship: entry.relationship.filter(isAddressBookRelationship),
|
|
7339
|
+
hidden: entry.hidden,
|
|
7340
|
+
lastActivityAt: entry.lastActivityAt
|
|
7439
7341
|
};
|
|
7440
7342
|
}
|
|
7441
7343
|
function mapActorRequest(request, payer) {
|
|
@@ -7529,8 +7431,14 @@ function mapInboxStatus(status) {
|
|
|
7529
7431
|
}
|
|
7530
7432
|
function normalizeRefForBackend$1(ref, field) {
|
|
7531
7433
|
try {
|
|
7532
|
-
if (typeof ref === "string")
|
|
7533
|
-
|
|
7434
|
+
if (typeof ref === "string") return {
|
|
7435
|
+
ok: false,
|
|
7436
|
+
error: Errors.invalidInput(field, "recipient must be a typed Ref variant")
|
|
7437
|
+
};
|
|
7438
|
+
if (typeof ref !== "object" || ref === null || !("kind" in ref)) return {
|
|
7439
|
+
ok: false,
|
|
7440
|
+
error: Errors.invalidInput(field, "recipient must be a typed Ref variant")
|
|
7441
|
+
};
|
|
7534
7442
|
switch (ref.kind) {
|
|
7535
7443
|
case "handle": return {
|
|
7536
7444
|
ok: true,
|
|
@@ -7567,55 +7475,22 @@ function normalizeRefForBackend$1(ref, field) {
|
|
|
7567
7475
|
payeeId: nonEmptyRefValue$1(ref.payeeId, "payeeId")
|
|
7568
7476
|
}
|
|
7569
7477
|
};
|
|
7570
|
-
|
|
7478
|
+
case "party": return {
|
|
7479
|
+
ok: true,
|
|
7480
|
+
value: {
|
|
7481
|
+
kind: "party",
|
|
7482
|
+
partyId: toPartyId(ref.partyId)
|
|
7483
|
+
}
|
|
7484
|
+
};
|
|
7485
|
+
default: return {
|
|
7486
|
+
ok: false,
|
|
7487
|
+
error: Errors.invalidInput(field, "recipient must be a known Ref variant")
|
|
7488
|
+
};
|
|
7571
7489
|
}
|
|
7572
7490
|
} catch (cause) {
|
|
7573
|
-
if (cause instanceof Error && "code" in cause) return {
|
|
7574
|
-
ok: false,
|
|
7575
|
-
error: cause
|
|
7576
|
-
};
|
|
7577
7491
|
return {
|
|
7578
7492
|
ok: false,
|
|
7579
|
-
error: Errors.invalidInput(field, "recipient must be a typed Ref variant")
|
|
7580
|
-
};
|
|
7581
|
-
}
|
|
7582
|
-
}
|
|
7583
|
-
function refFromEntryId(entryId) {
|
|
7584
|
-
try {
|
|
7585
|
-
const parsed = JSON.parse(entryId);
|
|
7586
|
-
if (typeof parsed === "object" && parsed !== null && "kind" in parsed) return normalizeRefForBackend$1(parsed, "entryId");
|
|
7587
|
-
} catch {}
|
|
7588
|
-
const separator = entryId.indexOf(":");
|
|
7589
|
-
if (separator === -1) return {
|
|
7590
|
-
ok: false,
|
|
7591
|
-
error: Errors.invalidInput("entryId", "must be an address-book entry id")
|
|
7592
|
-
};
|
|
7593
|
-
const prefix = entryId.slice(0, separator);
|
|
7594
|
-
const value = entryId.slice(separator + 1);
|
|
7595
|
-
switch (prefix) {
|
|
7596
|
-
case "email": return normalizeRefForBackend$1({
|
|
7597
|
-
kind: "email",
|
|
7598
|
-
email: value
|
|
7599
|
-
}, "entryId");
|
|
7600
|
-
case "user": return normalizeRefForBackend$1({
|
|
7601
|
-
kind: "capxulUserId",
|
|
7602
|
-
capxulUserId: value
|
|
7603
|
-
}, "entryId");
|
|
7604
|
-
case "org": return normalizeRefForBackend$1({
|
|
7605
|
-
kind: "orgHandle",
|
|
7606
|
-
orgHandle: value
|
|
7607
|
-
}, "entryId");
|
|
7608
|
-
case "payee": return normalizeRefForBackend$1({
|
|
7609
|
-
kind: "payeeId",
|
|
7610
|
-
payeeId: value
|
|
7611
|
-
}, "entryId");
|
|
7612
|
-
case "handle": return normalizeRefForBackend$1({
|
|
7613
|
-
kind: "handle",
|
|
7614
|
-
handle: value
|
|
7615
|
-
}, "entryId");
|
|
7616
|
-
default: return {
|
|
7617
|
-
ok: false,
|
|
7618
|
-
error: Errors.invalidInput("entryId", "must be an address-book entry id")
|
|
7493
|
+
error: cause instanceof CapxulError ? cause : Errors.invalidInput(field, "recipient must be a typed Ref variant")
|
|
7619
7494
|
};
|
|
7620
7495
|
}
|
|
7621
7496
|
}
|
|
@@ -7629,15 +7504,6 @@ function handleRefValue$1(value, field) {
|
|
|
7629
7504
|
const trimmed = nonEmptyRefValue$1(value, field);
|
|
7630
7505
|
return trimmed.startsWith("@") ? trimmed.slice(1) : trimmed;
|
|
7631
7506
|
}
|
|
7632
|
-
function refLabel(ref) {
|
|
7633
|
-
switch (ref.kind) {
|
|
7634
|
-
case "handle": return ref.handle;
|
|
7635
|
-
case "email": return ref.email;
|
|
7636
|
-
case "orgHandle": return ref.orgHandle;
|
|
7637
|
-
case "capxulUserId": return ref.capxulUserId;
|
|
7638
|
-
case "payeeId": return ref.payeeId;
|
|
7639
|
-
}
|
|
7640
|
-
}
|
|
7641
7507
|
//#endregion
|
|
7642
7508
|
//#region ../../packages/sdk/src/surface/account.ts
|
|
7643
7509
|
const provisioningPhase = (state) => {
|
|
@@ -7660,6 +7526,10 @@ const actorFailure = (failure) => new CapxulError(failure.reason === "WORK_DIED"
|
|
|
7660
7526
|
...failure.details === void 0 ? {} : { details: failure.details },
|
|
7661
7527
|
layer: "identity"
|
|
7662
7528
|
});
|
|
7529
|
+
const accountFailureResult = (error) => ({
|
|
7530
|
+
ok: false,
|
|
7531
|
+
error
|
|
7532
|
+
});
|
|
7663
7533
|
function makeAccountMethods(deps) {
|
|
7664
7534
|
toChainId(deps.chainId);
|
|
7665
7535
|
const requirement = deps.requirement;
|
|
@@ -7802,26 +7672,16 @@ function makeAccountMethods(deps) {
|
|
|
7802
7672
|
value: provisioningPhase(deps.actor.snapshot())
|
|
7803
7673
|
};
|
|
7804
7674
|
};
|
|
7805
|
-
const reportAndReturn = (error, operation = "getLifecycle") => {
|
|
7806
|
-
if (deps.telemetry) captureExceptionSync(deps.telemetry, error, {
|
|
7807
|
-
layer: "account",
|
|
7808
|
-
operation
|
|
7809
|
-
});
|
|
7810
|
-
return {
|
|
7811
|
-
ok: false,
|
|
7812
|
-
error
|
|
7813
|
-
};
|
|
7814
|
-
};
|
|
7815
7675
|
const resolveLifecycle = async () => {
|
|
7816
7676
|
const phase = provisioningPhase(deps.actor.snapshot());
|
|
7817
7677
|
const status = await getStatus();
|
|
7818
|
-
if (!status.ok) return
|
|
7678
|
+
if (!status.ok) return accountFailureResult(status.error);
|
|
7819
7679
|
let accountId;
|
|
7820
7680
|
if (status.value.status !== "notAuthenticated" && (phase.status === "ready" || isRequirementMet(status.value, requirement))) {
|
|
7821
7681
|
const accountReadPort = deps.accountReadPort;
|
|
7822
|
-
if (accountReadPort === void 0) return
|
|
7682
|
+
if (accountReadPort === void 0) return accountFailureResult(Errors.invalidInput("account", "accountReadPort is required to resolve ready lifecycle"));
|
|
7823
7683
|
const account = await runPortEffect(accountReadPort.readBalance({ chainId: toChainId(deps.chainId) }));
|
|
7824
|
-
if (!account.ok) return
|
|
7684
|
+
if (!account.ok) return accountFailureResult(account.error);
|
|
7825
7685
|
accountId = String(account.value.id);
|
|
7826
7686
|
}
|
|
7827
7687
|
return {
|
|
@@ -7840,10 +7700,10 @@ function makeAccountMethods(deps) {
|
|
|
7840
7700
|
if (typeof resetSession === "function") try {
|
|
7841
7701
|
resetSession.call(deps.signer);
|
|
7842
7702
|
} catch (cause) {
|
|
7843
|
-
return
|
|
7703
|
+
return accountFailureResult(signerFailure(deps.signer.source, "resetSession", cause));
|
|
7844
7704
|
}
|
|
7845
7705
|
const retried = await drive({ _tag: "RetryAccount" });
|
|
7846
|
-
if (!retried.ok) return
|
|
7706
|
+
if (!retried.ok) return accountFailureResult(retried.error);
|
|
7847
7707
|
return resolveLifecycle();
|
|
7848
7708
|
};
|
|
7849
7709
|
return {
|
|
@@ -7996,7 +7856,7 @@ function cancelled(operation) {
|
|
|
7996
7856
|
function isAborted$2(signal) {
|
|
7997
7857
|
return signal?.aborted === true;
|
|
7998
7858
|
}
|
|
7999
|
-
async function signerCall(operation, run) {
|
|
7859
|
+
async function signerCall(source, operation, run) {
|
|
8000
7860
|
try {
|
|
8001
7861
|
return {
|
|
8002
7862
|
ok: true,
|
|
@@ -8005,7 +7865,7 @@ async function signerCall(operation, run) {
|
|
|
8005
7865
|
} catch (cause) {
|
|
8006
7866
|
return {
|
|
8007
7867
|
ok: false,
|
|
8008
|
-
error:
|
|
7868
|
+
error: signerFailure(source, operation, cause)
|
|
8009
7869
|
};
|
|
8010
7870
|
}
|
|
8011
7871
|
}
|
|
@@ -8017,7 +7877,7 @@ async function executePersonalPayment(deps, payment, signal, requestKey) {
|
|
|
8017
7877
|
ok: false,
|
|
8018
7878
|
error: Errors.notAuthenticated()
|
|
8019
7879
|
};
|
|
8020
|
-
const signerAddress = await signerCall("getAddress", () => deps.signer.getAddress());
|
|
7880
|
+
const signerAddress = await signerCall(deps.signer.source, "getAddress", () => deps.signer.getAddress());
|
|
8021
7881
|
if (!signerAddress.ok) return signerAddress;
|
|
8022
7882
|
const expectedSafe = deriveCapxulSafeAddress({ email: session.email });
|
|
8023
7883
|
const resolvedRequestKey = requestKey ?? `pay_${crypto.randomUUID()}`;
|
|
@@ -8036,7 +7896,7 @@ async function executePersonalPayment(deps, payment, signal, requestKey) {
|
|
|
8036
7896
|
paymentId: prepared.value.paymentId
|
|
8037
7897
|
});
|
|
8038
7898
|
if (isAborted$2(signal)) return cancelled("payments.pay");
|
|
8039
|
-
const signature = await signerCall("signUserOpHash", () => deps.signer.signUserOpHash(prepared.value.digest));
|
|
7899
|
+
const signature = await signerCall(deps.signer.source, "signUserOpHash", () => deps.signer.signUserOpHash(prepared.value.digest));
|
|
8040
7900
|
if (!signature.ok) return signature;
|
|
8041
7901
|
if (isAborted$2(signal)) return cancelled("payments.pay");
|
|
8042
7902
|
return runIfActive(void 0, "payments.submitExecution", () => deps.convexCall.action(deps.functions.submitPaymentExecution, { input: {
|
|
@@ -8049,12 +7909,6 @@ async function executePersonalPayment(deps, payment, signal, requestKey) {
|
|
|
8049
7909
|
function isAborted$1(signal) {
|
|
8050
7910
|
return signal?.aborted === true;
|
|
8051
7911
|
}
|
|
8052
|
-
function signerFailure(operation, cause) {
|
|
8053
|
-
return {
|
|
8054
|
-
ok: false,
|
|
8055
|
-
error: cause instanceof CapxulError ? cause : Errors.providerError("wallet-signer", operation, cause)
|
|
8056
|
-
};
|
|
8057
|
-
}
|
|
8058
7912
|
/** Return one stable fingerprint for one JSON payment intent. */
|
|
8059
7913
|
async function fingerprintPaymentIntent(intent) {
|
|
8060
7914
|
const canonical = JSON.stringify(intent, (_key, value) => value !== null && typeof value === "object" && !Array.isArray(value) ? Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right))) : value);
|
|
@@ -8075,7 +7929,10 @@ async function executePrepared(deps, prepare, expectedRequest, signal) {
|
|
|
8075
7929
|
try {
|
|
8076
7930
|
signerAddress = await deps.signer.getAddress();
|
|
8077
7931
|
} catch (cause) {
|
|
8078
|
-
return
|
|
7932
|
+
return {
|
|
7933
|
+
ok: false,
|
|
7934
|
+
error: signerFailure(deps.signer.source, "getAddress", cause)
|
|
7935
|
+
};
|
|
8079
7936
|
}
|
|
8080
7937
|
const prepared = await prepare(signerAddress);
|
|
8081
7938
|
if (!prepared.ok) return prepared;
|
|
@@ -8096,7 +7953,10 @@ async function executePrepared(deps, prepare, expectedRequest, signal) {
|
|
|
8096
7953
|
try {
|
|
8097
7954
|
signature = await deps.signer.signUserOpHash(prepared.value.digest);
|
|
8098
7955
|
} catch (cause) {
|
|
8099
|
-
return
|
|
7956
|
+
return {
|
|
7957
|
+
ok: false,
|
|
7958
|
+
error: signerFailure(deps.signer.source, "signUserOpHash", cause)
|
|
7959
|
+
};
|
|
8100
7960
|
}
|
|
8101
7961
|
if (isAborted$1(signal)) return {
|
|
8102
7962
|
ok: false,
|
|
@@ -8195,36 +8055,36 @@ async function paymentRequestKeyLifecycle(operation, intent, provided) {
|
|
|
8195
8055
|
key: provided,
|
|
8196
8056
|
finish: async () => void 0
|
|
8197
8057
|
};
|
|
8198
|
-
const slot = `capxul.payment.request-key.v3:${await fingerprintPaymentIntent({
|
|
8199
|
-
operation,
|
|
8200
|
-
intent
|
|
8201
|
-
})}`;
|
|
8202
|
-
if (typeof window === "undefined") {
|
|
8203
|
-
const attemptId = randomPaymentRequestKey();
|
|
8204
|
-
const state = memoryPaymentRequestKeys.get(slot) ?? {
|
|
8205
|
-
key: randomPaymentRequestKey(),
|
|
8206
|
-
active: [],
|
|
8207
|
-
resolved: false
|
|
8208
|
-
};
|
|
8209
|
-
state.active.push(attemptId);
|
|
8210
|
-
memoryPaymentRequestKeys.set(slot, state);
|
|
8211
|
-
let finished = false;
|
|
8212
|
-
return {
|
|
8213
|
-
key: state.key,
|
|
8214
|
-
finish: async (succeeded) => {
|
|
8215
|
-
if (finished) return;
|
|
8216
|
-
finished = true;
|
|
8217
|
-
const attemptIndex = state.active.indexOf(attemptId);
|
|
8218
|
-
if (attemptIndex < 0) return;
|
|
8219
|
-
state.active.splice(attemptIndex, 1);
|
|
8220
|
-
state.resolved = succeeded;
|
|
8221
|
-
if (state.active.length === 0 && state.resolved) memoryPaymentRequestKeys.delete(slot);
|
|
8222
|
-
}
|
|
8223
|
-
};
|
|
8224
|
-
}
|
|
8225
8058
|
let releaseAttemptLock;
|
|
8226
8059
|
let forgetPagehideRelease;
|
|
8227
8060
|
try {
|
|
8061
|
+
const slot = `capxul.payment.request-key.v3:${await fingerprintPaymentIntent({
|
|
8062
|
+
operation,
|
|
8063
|
+
intent
|
|
8064
|
+
})}`;
|
|
8065
|
+
if (typeof window === "undefined") {
|
|
8066
|
+
const attemptId = randomPaymentRequestKey();
|
|
8067
|
+
const state = memoryPaymentRequestKeys.get(slot) ?? {
|
|
8068
|
+
key: randomPaymentRequestKey(),
|
|
8069
|
+
active: [],
|
|
8070
|
+
resolved: false
|
|
8071
|
+
};
|
|
8072
|
+
state.active.push(attemptId);
|
|
8073
|
+
memoryPaymentRequestKeys.set(slot, state);
|
|
8074
|
+
let finished = false;
|
|
8075
|
+
return {
|
|
8076
|
+
key: state.key,
|
|
8077
|
+
finish: async (succeeded) => {
|
|
8078
|
+
if (finished) return;
|
|
8079
|
+
finished = true;
|
|
8080
|
+
const attemptIndex = state.active.indexOf(attemptId);
|
|
8081
|
+
if (attemptIndex < 0) return;
|
|
8082
|
+
state.active.splice(attemptIndex, 1);
|
|
8083
|
+
state.resolved = succeeded;
|
|
8084
|
+
if (state.active.length === 0 && state.resolved) memoryPaymentRequestKeys.delete(slot);
|
|
8085
|
+
}
|
|
8086
|
+
};
|
|
8087
|
+
}
|
|
8228
8088
|
const attemptId = randomPaymentRequestKey();
|
|
8229
8089
|
releaseAttemptLock = await holdPaymentAttemptLock(paymentAttemptLockName(slot, attemptId));
|
|
8230
8090
|
forgetPagehideRelease = releasePaymentAttemptOnPagehide(releaseAttemptLock);
|
|
@@ -8279,13 +8139,20 @@ async function paymentRequestKeyLifecycle(operation, intent, provided) {
|
|
|
8279
8139
|
throw Errors.providerError("sdk", "paymentRequestKey", cause);
|
|
8280
8140
|
}
|
|
8281
8141
|
}
|
|
8142
|
+
function paymentSubmissionFailure(cause) {
|
|
8143
|
+
return {
|
|
8144
|
+
ok: false,
|
|
8145
|
+
error: cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
8146
|
+
};
|
|
8147
|
+
}
|
|
8282
8148
|
async function waitForPaymentSubmission(submission, signal, operation, onCancel = () => false) {
|
|
8283
|
-
|
|
8284
|
-
if (signal
|
|
8149
|
+
const foldedSubmission = submission.catch((cause) => paymentSubmissionFailure(cause));
|
|
8150
|
+
if (signal === void 0) return foldedSubmission;
|
|
8151
|
+
if (signal.aborted) return onCancel() ? foldedSubmission : {
|
|
8285
8152
|
ok: false,
|
|
8286
8153
|
error: Errors.cancelled({ operation })
|
|
8287
8154
|
};
|
|
8288
|
-
return new Promise((resolve
|
|
8155
|
+
return new Promise((resolve) => {
|
|
8289
8156
|
const onAbort = () => {
|
|
8290
8157
|
signal.removeEventListener("abort", onAbort);
|
|
8291
8158
|
if (!onCancel()) resolve({
|
|
@@ -8294,12 +8161,9 @@ async function waitForPaymentSubmission(submission, signal, operation, onCancel
|
|
|
8294
8161
|
});
|
|
8295
8162
|
};
|
|
8296
8163
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
8297
|
-
|
|
8164
|
+
foldedSubmission.then((result) => {
|
|
8298
8165
|
signal.removeEventListener("abort", onAbort);
|
|
8299
8166
|
resolve(result);
|
|
8300
|
-
}, (cause) => {
|
|
8301
|
-
signal.removeEventListener("abort", onAbort);
|
|
8302
|
-
reject(cause instanceof Error ? cause : new Error(String(cause)));
|
|
8303
8167
|
});
|
|
8304
8168
|
});
|
|
8305
8169
|
}
|
|
@@ -8344,7 +8208,7 @@ function makeFinancialOpsMethods(deps) {
|
|
|
8344
8208
|
} catch (cause) {
|
|
8345
8209
|
return {
|
|
8346
8210
|
ok: false,
|
|
8347
|
-
error: cause instanceof CapxulError ? cause : Errors.
|
|
8211
|
+
error: cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
8348
8212
|
};
|
|
8349
8213
|
}
|
|
8350
8214
|
const sharedKey = `${requestKeyScope}:${requestKey.key}`;
|
|
@@ -8392,7 +8256,10 @@ function makeFinancialOpsMethods(deps) {
|
|
|
8392
8256
|
try {
|
|
8393
8257
|
await requestKey.finish(false);
|
|
8394
8258
|
} catch {}
|
|
8395
|
-
|
|
8259
|
+
return {
|
|
8260
|
+
ok: false,
|
|
8261
|
+
error: cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
8262
|
+
};
|
|
8396
8263
|
}
|
|
8397
8264
|
release(false);
|
|
8398
8265
|
try {
|
|
@@ -8416,11 +8283,25 @@ function makeFinancialOpsMethods(deps) {
|
|
|
8416
8283
|
const runLifecycle = async (intent, signal) => {
|
|
8417
8284
|
const execution = lifecycleDependencies();
|
|
8418
8285
|
if (!execution.ok) return execution;
|
|
8419
|
-
|
|
8420
|
-
const
|
|
8421
|
-
if (
|
|
8422
|
-
|
|
8423
|
-
|
|
8286
|
+
try {
|
|
8287
|
+
const submitted = await executePaymentLifecycle(execution.value, intent, signal);
|
|
8288
|
+
if (!submitted.ok) return submitted;
|
|
8289
|
+
const payments = submitted.value.payments;
|
|
8290
|
+
const payment = payments[0];
|
|
8291
|
+
if (payment === void 0 || payments.length !== 1) return {
|
|
8292
|
+
ok: false,
|
|
8293
|
+
error: Errors.unknown()
|
|
8294
|
+
};
|
|
8295
|
+
return {
|
|
8296
|
+
ok: true,
|
|
8297
|
+
value: normalizePaymentTiming(payment)
|
|
8298
|
+
};
|
|
8299
|
+
} catch (cause) {
|
|
8300
|
+
return {
|
|
8301
|
+
ok: false,
|
|
8302
|
+
error: cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
8303
|
+
};
|
|
8304
|
+
}
|
|
8424
8305
|
};
|
|
8425
8306
|
return {
|
|
8426
8307
|
me: {
|
|
@@ -8471,9 +8352,10 @@ function makeFinancialOpsMethods(deps) {
|
|
|
8471
8352
|
value: resolvedTargetFromPayee(reference, payee.value)
|
|
8472
8353
|
};
|
|
8473
8354
|
}
|
|
8355
|
+
case "party":
|
|
8474
8356
|
case "destination": return Promise.resolve({
|
|
8475
8357
|
ok: false,
|
|
8476
|
-
error: Errors.notImplemented("targets",
|
|
8358
|
+
error: Errors.notImplemented("targets", `resolve.${reference.kind}`)
|
|
8477
8359
|
});
|
|
8478
8360
|
}
|
|
8479
8361
|
} },
|
|
@@ -8607,8 +8489,14 @@ function handleRefValue(value, field) {
|
|
|
8607
8489
|
}
|
|
8608
8490
|
function refFromTargetReference(reference, field) {
|
|
8609
8491
|
try {
|
|
8610
|
-
if (typeof reference === "string")
|
|
8611
|
-
|
|
8492
|
+
if (typeof reference === "string") return {
|
|
8493
|
+
ok: false,
|
|
8494
|
+
error: Errors.invalidInput(field, "target must be a typed TargetReference variant")
|
|
8495
|
+
};
|
|
8496
|
+
if (typeof reference !== "object" || reference === null || !("kind" in reference)) return {
|
|
8497
|
+
ok: false,
|
|
8498
|
+
error: Errors.invalidInput(field, "target must be a typed TargetReference variant")
|
|
8499
|
+
};
|
|
8612
8500
|
switch (reference.kind) {
|
|
8613
8501
|
case "handle": return {
|
|
8614
8502
|
ok: true,
|
|
@@ -8638,20 +8526,26 @@ function refFromTargetReference(reference, field) {
|
|
|
8638
8526
|
payeeId: reference.id
|
|
8639
8527
|
}
|
|
8640
8528
|
};
|
|
8529
|
+
case "party": return {
|
|
8530
|
+
ok: true,
|
|
8531
|
+
value: {
|
|
8532
|
+
kind: "party",
|
|
8533
|
+
partyId: reference.partyId
|
|
8534
|
+
}
|
|
8535
|
+
};
|
|
8641
8536
|
case "destination": return {
|
|
8642
8537
|
ok: false,
|
|
8643
8538
|
error: Errors.notImplemented("targets", "reference.destination")
|
|
8644
8539
|
};
|
|
8645
|
-
default:
|
|
8540
|
+
default: return {
|
|
8541
|
+
ok: false,
|
|
8542
|
+
error: Errors.invalidInput(field, "target must be a known TargetReference variant")
|
|
8543
|
+
};
|
|
8646
8544
|
}
|
|
8647
8545
|
} catch (cause) {
|
|
8648
|
-
if (cause instanceof Error && "code" in cause) return {
|
|
8649
|
-
ok: false,
|
|
8650
|
-
error: cause
|
|
8651
|
-
};
|
|
8652
8546
|
return {
|
|
8653
8547
|
ok: false,
|
|
8654
|
-
error: Errors.invalidInput(field, "target must be a typed TargetReference variant")
|
|
8548
|
+
error: cause instanceof CapxulError ? cause : Errors.invalidInput(field, "target must be a typed TargetReference variant")
|
|
8655
8549
|
};
|
|
8656
8550
|
}
|
|
8657
8551
|
}
|
|
@@ -8705,6 +8599,10 @@ function targetReferenceFromBackendRef(ref) {
|
|
|
8705
8599
|
kind: "payee",
|
|
8706
8600
|
id: ref.payeeId
|
|
8707
8601
|
};
|
|
8602
|
+
case "party": return {
|
|
8603
|
+
kind: "party",
|
|
8604
|
+
partyId: ref.partyId
|
|
8605
|
+
};
|
|
8708
8606
|
case "capxulUserId": throw Errors.notImplemented("targets", "reference.capxulUserId");
|
|
8709
8607
|
}
|
|
8710
8608
|
}
|
|
@@ -8791,8 +8689,14 @@ function normalizeDestinationRefForBackend(ref, field) {
|
|
|
8791
8689
|
}
|
|
8792
8690
|
function normalizeRefForBackend(ref, field) {
|
|
8793
8691
|
try {
|
|
8794
|
-
if (typeof ref === "string")
|
|
8795
|
-
|
|
8692
|
+
if (typeof ref === "string") return {
|
|
8693
|
+
ok: false,
|
|
8694
|
+
error: Errors.invalidInput(field, "recipient must be a typed Ref variant")
|
|
8695
|
+
};
|
|
8696
|
+
if (typeof ref !== "object" || ref === null || !("kind" in ref)) return {
|
|
8697
|
+
ok: false,
|
|
8698
|
+
error: Errors.invalidInput(field, "recipient must be a typed Ref variant")
|
|
8699
|
+
};
|
|
8796
8700
|
switch (ref.kind) {
|
|
8797
8701
|
case "handle": return {
|
|
8798
8702
|
ok: true,
|
|
@@ -8829,16 +8733,22 @@ function normalizeRefForBackend(ref, field) {
|
|
|
8829
8733
|
payeeId: nonEmptyRefValue(ref.payeeId, "payeeId")
|
|
8830
8734
|
}
|
|
8831
8735
|
};
|
|
8832
|
-
|
|
8736
|
+
case "party": return {
|
|
8737
|
+
ok: true,
|
|
8738
|
+
value: {
|
|
8739
|
+
kind: "party",
|
|
8740
|
+
partyId: toPartyId(ref.partyId)
|
|
8741
|
+
}
|
|
8742
|
+
};
|
|
8743
|
+
default: return {
|
|
8744
|
+
ok: false,
|
|
8745
|
+
error: Errors.invalidInput(field, "recipient must be a known Ref variant")
|
|
8746
|
+
};
|
|
8833
8747
|
}
|
|
8834
8748
|
} catch (cause) {
|
|
8835
|
-
if (cause instanceof Error && "code" in cause) return {
|
|
8836
|
-
ok: false,
|
|
8837
|
-
error: cause
|
|
8838
|
-
};
|
|
8839
8749
|
return {
|
|
8840
8750
|
ok: false,
|
|
8841
|
-
error: Errors.invalidInput(field, "recipient must be a typed Ref variant")
|
|
8751
|
+
error: cause instanceof CapxulError ? cause : Errors.invalidInput(field, "recipient must be a typed Ref variant")
|
|
8842
8752
|
};
|
|
8843
8753
|
}
|
|
8844
8754
|
}
|
|
@@ -8857,11 +8767,10 @@ function mapOk(result, f) {
|
|
|
8857
8767
|
value: f(result.value)
|
|
8858
8768
|
};
|
|
8859
8769
|
} catch (cause) {
|
|
8860
|
-
|
|
8770
|
+
return {
|
|
8861
8771
|
ok: false,
|
|
8862
|
-
error: cause
|
|
8772
|
+
error: cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
8863
8773
|
};
|
|
8864
|
-
throw cause;
|
|
8865
8774
|
}
|
|
8866
8775
|
}
|
|
8867
8776
|
//#endregion
|
|
@@ -9029,7 +8938,7 @@ async function recoverRawDigestSigner(input) {
|
|
|
9029
8938
|
}
|
|
9030
8939
|
//#endregion
|
|
9031
8940
|
//#region ../../packages/sdk/package.json
|
|
9032
|
-
var version = "2.
|
|
8941
|
+
var version = "2.2.0";
|
|
9033
8942
|
//#endregion
|
|
9034
8943
|
//#region ../../packages/observability/src/engineering.ts
|
|
9035
8944
|
const SAFE_TRACED_HEADER_NAMES = [
|
|
@@ -13126,9 +13035,27 @@ function mapToCapxulError(operation, err) {
|
|
|
13126
13035
|
function mapToConvexCallError(operation, err) {
|
|
13127
13036
|
return convexCallErrorFromCapxul(operation, mapToCapxulError(operation, err));
|
|
13128
13037
|
}
|
|
13038
|
+
const TRANSPORT_ERROR_CODES = new Set([
|
|
13039
|
+
"EAI_AGAIN",
|
|
13040
|
+
"ECONNREFUSED",
|
|
13041
|
+
"ECONNRESET",
|
|
13042
|
+
"ENOTFOUND",
|
|
13043
|
+
"EPIPE",
|
|
13044
|
+
"ETIMEDOUT",
|
|
13045
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
13046
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
13047
|
+
"UND_ERR_SOCKET"
|
|
13048
|
+
]);
|
|
13129
13049
|
function isTransportError(err) {
|
|
13130
|
-
const
|
|
13131
|
-
|
|
13050
|
+
const seen = /* @__PURE__ */ new Set();
|
|
13051
|
+
let current = err;
|
|
13052
|
+
while (current !== void 0 && !seen.has(current)) {
|
|
13053
|
+
seen.add(current);
|
|
13054
|
+
const code = current.code;
|
|
13055
|
+
if (current.name === "FetchError" || current.name === "NetworkError" || typeof code === "string" && TRANSPORT_ERROR_CODES.has(code)) return true;
|
|
13056
|
+
current = current.cause instanceof Error ? current.cause : void 0;
|
|
13057
|
+
}
|
|
13058
|
+
return false;
|
|
13132
13059
|
}
|
|
13133
13060
|
//#endregion
|
|
13134
13061
|
//#region ../../packages/sdk/src/ports/identity.ts
|
|
@@ -13619,7 +13546,7 @@ var ConvexOrganizationSetupAdapter = class {
|
|
|
13619
13546
|
if (!lifecycle.ok) return lifecycle;
|
|
13620
13547
|
const orgId = parseOrgId("startOrResume", result.value.orgId);
|
|
13621
13548
|
if (!orgId.ok) return orgId;
|
|
13622
|
-
if (String(orgId.value) !== String(lifecycle.value.orgId)) return fail$
|
|
13549
|
+
if (String(orgId.value) !== String(lifecycle.value.orgId)) return fail$1(Errors.invalidInput("orgId", "Organization lifecycle scope does not match"));
|
|
13623
13550
|
return {
|
|
13624
13551
|
ok: true,
|
|
13625
13552
|
value: {
|
|
@@ -13637,7 +13564,7 @@ var ConvexOrganizationSetupAdapter = class {
|
|
|
13637
13564
|
async authorizeAndSubmitBootstrap(input) {
|
|
13638
13565
|
const cancelled = cancellation(input.signal);
|
|
13639
13566
|
if (cancelled !== void 0) return cancelled;
|
|
13640
|
-
const signerAddress = await signerResult("getAddress", () => this.#signer.getAddress());
|
|
13567
|
+
const signerAddress = await signerResult(this.#signer.source, "getAddress", () => this.#signer.getAddress());
|
|
13641
13568
|
if (!signerAddress.ok) return signerAddress;
|
|
13642
13569
|
const prepared = await runCall("prepareBootstrap", this.#convex.action(this.#fns.prepareBootstrap, copyInvocationObservation(input, {
|
|
13643
13570
|
orgId: input.orgId,
|
|
@@ -13649,7 +13576,7 @@ var ConvexOrganizationSetupAdapter = class {
|
|
|
13649
13576
|
if (!authority.ok) return authority;
|
|
13650
13577
|
const cancelledAfterPrepare = cancellation(input.signal);
|
|
13651
13578
|
if (cancelledAfterPrepare !== void 0) return cancelledAfterPrepare;
|
|
13652
|
-
const signature = await signerResult("signUserOpHash", () => this.#signer.signUserOpHash(prepared.value.digest));
|
|
13579
|
+
const signature = await signerResult(this.#signer.source, "signUserOpHash", () => this.#signer.signUserOpHash(prepared.value.digest));
|
|
13653
13580
|
if (!signature.ok) return signature;
|
|
13654
13581
|
const cancelledAfterSign = cancellation(input.signal);
|
|
13655
13582
|
if (cancelledAfterSign !== void 0) return cancelledAfterSign;
|
|
@@ -13693,7 +13620,7 @@ var ConvexOrganizationSetupAdapter = class {
|
|
|
13693
13620
|
async loadLifecycle(input) {
|
|
13694
13621
|
const result = await runCall("loadLifecycle", this.#convex.query(this.#fns.load, input));
|
|
13695
13622
|
if (!result.ok) return result;
|
|
13696
|
-
if (result.value === null) return fail$
|
|
13623
|
+
if (result.value === null) return fail$1(Errors.invalidInput("orgId", "Organization lifecycle was not found"));
|
|
13697
13624
|
return parseLifecycle("loadLifecycle", result.value);
|
|
13698
13625
|
}
|
|
13699
13626
|
async retry(input) {
|
|
@@ -13738,7 +13665,7 @@ function resetSignerSession(signer) {
|
|
|
13738
13665
|
value: void 0
|
|
13739
13666
|
};
|
|
13740
13667
|
} catch (cause) {
|
|
13741
|
-
return fail$
|
|
13668
|
+
return fail$1(signerFailure(signer.source, "resetSession", cause));
|
|
13742
13669
|
}
|
|
13743
13670
|
}
|
|
13744
13671
|
async function runCall(operation, effect) {
|
|
@@ -13747,9 +13674,9 @@ async function runCall(operation, effect) {
|
|
|
13747
13674
|
return Result.isSuccess(result) ? {
|
|
13748
13675
|
ok: true,
|
|
13749
13676
|
value: result.success
|
|
13750
|
-
} : fail$
|
|
13677
|
+
} : fail$1(publicError(operation, result.failure));
|
|
13751
13678
|
} catch (cause) {
|
|
13752
|
-
return fail$
|
|
13679
|
+
return fail$1(publicError(operation, cause));
|
|
13753
13680
|
}
|
|
13754
13681
|
}
|
|
13755
13682
|
function publicError(operation, cause) {
|
|
@@ -13760,14 +13687,14 @@ function publicError(operation, cause) {
|
|
|
13760
13687
|
}
|
|
13761
13688
|
return Errors.providerError("convex-organization", operation, cause);
|
|
13762
13689
|
}
|
|
13763
|
-
async function signerResult(operation, run) {
|
|
13690
|
+
async function signerResult(source, operation, run) {
|
|
13764
13691
|
try {
|
|
13765
13692
|
return {
|
|
13766
13693
|
ok: true,
|
|
13767
13694
|
value: await run()
|
|
13768
13695
|
};
|
|
13769
13696
|
} catch (cause) {
|
|
13770
|
-
return fail$
|
|
13697
|
+
return fail$1(signerFailure(source, operation, cause));
|
|
13771
13698
|
}
|
|
13772
13699
|
}
|
|
13773
13700
|
function validatePreparedAuthorities(prepared, signerAddress) {
|
|
@@ -13776,10 +13703,10 @@ function validatePreparedAuthorities(prepared, signerAddress) {
|
|
|
13776
13703
|
const founder = prepared.founderPersonalAccount.toLowerCase();
|
|
13777
13704
|
const organization = prepared.organizationAccountAddress.toLowerCase();
|
|
13778
13705
|
const sender = prepared.userOp.sender.toLowerCase();
|
|
13779
|
-
if (preparedSigner !== signer) return fail$
|
|
13780
|
-
if (founder === signer || organization === signer || organization === founder) return fail$
|
|
13781
|
-
if (sender !== founder) return fail$
|
|
13782
|
-
if (!/^0x[0-9a-fA-F]{64}$/u.test(prepared.digest)) return fail$
|
|
13706
|
+
if (preparedSigner !== signer) return fail$1(Errors.invalidInput("signerAddress", "Prepared signer does not match configured signer"));
|
|
13707
|
+
if (founder === signer || organization === signer || organization === founder) return fail$1(Errors.invalidInput("organizationAuthority", "Signer EOA, founder Account, and Organization Account must be distinct"));
|
|
13708
|
+
if (sender !== founder) return fail$1(Errors.invalidInput("userOp.sender", "Bootstrap sender must be the founder Account"));
|
|
13709
|
+
if (!/^0x[0-9a-fA-F]{64}$/u.test(prepared.digest)) return fail$1(Errors.invalidInput("digest", "Prepared bootstrap digest must be 32-byte hex"));
|
|
13783
13710
|
return {
|
|
13784
13711
|
ok: true,
|
|
13785
13712
|
value: void 0
|
|
@@ -13804,7 +13731,7 @@ function parseLifecycle(operation, wire) {
|
|
|
13804
13731
|
}
|
|
13805
13732
|
};
|
|
13806
13733
|
if (wire.status === "failed") {
|
|
13807
|
-
if (!isSetupStep(wire.at)) return fail$
|
|
13734
|
+
if (!isSetupStep(wire.at)) return fail$1(Errors.invalidInput("lifecycle.at", "Unknown setup step"));
|
|
13808
13735
|
return {
|
|
13809
13736
|
ok: true,
|
|
13810
13737
|
value: {
|
|
@@ -13816,7 +13743,7 @@ function parseLifecycle(operation, wire) {
|
|
|
13816
13743
|
}
|
|
13817
13744
|
};
|
|
13818
13745
|
}
|
|
13819
|
-
if (!isSetupStep(wire.step)) return fail$
|
|
13746
|
+
if (!isSetupStep(wire.step)) return fail$1(Errors.invalidInput("lifecycle.step", `Unknown setup step from ${operation}`));
|
|
13820
13747
|
return {
|
|
13821
13748
|
ok: true,
|
|
13822
13749
|
value: {
|
|
@@ -13833,16 +13760,16 @@ function parseOrgId(operation, value) {
|
|
|
13833
13760
|
value: toOrgId(value)
|
|
13834
13761
|
};
|
|
13835
13762
|
} catch (cause) {
|
|
13836
|
-
return fail$
|
|
13763
|
+
return fail$1(Errors.providerError("convex-organization", operation, cause));
|
|
13837
13764
|
}
|
|
13838
13765
|
}
|
|
13839
13766
|
function isSetupStep(value) {
|
|
13840
13767
|
return value === "preparingFounderAccount" || value === "awaitingFounderAuthorization" || value === "submittingBootstrap" || value === "confirmingBootstrap";
|
|
13841
13768
|
}
|
|
13842
13769
|
function cancellation(signal) {
|
|
13843
|
-
return signal?.aborted ? fail$
|
|
13770
|
+
return signal?.aborted ? fail$1(Errors.cancelled({ operation: "organization.setup" })) : void 0;
|
|
13844
13771
|
}
|
|
13845
|
-
function fail$
|
|
13772
|
+
function fail$1(error) {
|
|
13846
13773
|
return {
|
|
13847
13774
|
ok: false,
|
|
13848
13775
|
error
|
|
@@ -37233,28 +37160,20 @@ function clearStaleOpenfortBrowserStorage(publishableKey) {
|
|
|
37233
37160
|
}
|
|
37234
37161
|
function createOpenfortBrowserSignerFromBootstrap(bootstrap, options = {}) {
|
|
37235
37162
|
const diagnostic = options.diagnostic;
|
|
37236
|
-
const telemetry = options.telemetry;
|
|
37237
37163
|
const authBaseUrl = normalizeBetterAuthBaseUrl(bootstrap.authBaseUrl);
|
|
37238
37164
|
/**
|
|
37239
37165
|
* Closes the black hole: when the browser has no Web Crypto, OpenFort's
|
|
37240
37166
|
* `configure` would resolve to no address and the failure would be reported
|
|
37241
37167
|
* as `unknown`. Detect it before any network/wallet work, tag it
|
|
37242
37168
|
* `no-secure-context` on a PROVIDER_ERROR scoped to `configure`, breadcrumb
|
|
37243
|
-
* it via DiagnosticPort
|
|
37169
|
+
* it via DiagnosticPort. The assembled Core SDK boundary reports the error.
|
|
37244
37170
|
*/
|
|
37245
37171
|
function failNoSecureContext() {
|
|
37246
37172
|
diagnostic?.trace("openfort.configure", {
|
|
37247
37173
|
ok: false,
|
|
37248
37174
|
failure_mode: "no-secure-context"
|
|
37249
37175
|
});
|
|
37250
|
-
|
|
37251
|
-
if (telemetry) captureExceptionSync(telemetry, error, {
|
|
37252
|
-
layer: "openfort",
|
|
37253
|
-
operation: "configure",
|
|
37254
|
-
provider: "openfort",
|
|
37255
|
-
failure_mode: "no-secure-context"
|
|
37256
|
-
});
|
|
37257
|
-
throw error;
|
|
37176
|
+
throw Errors.providerError("openfort", "configure", /* @__PURE__ */ new Error("Web Crypto unavailable: browser is not a secure context"), { failure_mode: "no-secure-context" });
|
|
37258
37177
|
}
|
|
37259
37178
|
function betterAuthSessionUrl() {
|
|
37260
37179
|
return `${authBaseUrl}/get-session`;
|
|
@@ -37513,7 +37432,7 @@ const modelSession = (session) => ({
|
|
|
37513
37432
|
});
|
|
37514
37433
|
const claimAccount = (input, authUserId, signer) => call("smart-account.claim", Effect.tryPromise({
|
|
37515
37434
|
try: () => signer.getAddress(),
|
|
37516
|
-
catch: (cause) =>
|
|
37435
|
+
catch: (cause) => signerFailure(signer.source, "getAddress", cause)
|
|
37517
37436
|
}).pipe(Effect.flatMap((signerAddress) => input.ports.smartAccount.claim({
|
|
37518
37437
|
authUserId: toAuthUserId(authUserId),
|
|
37519
37438
|
chainId: toChainId(input.chainId),
|
|
@@ -38448,12 +38367,6 @@ const permissionContract = { read: makeFunctionReference(CAPXUL_FUNCTIONS["permi
|
|
|
38448
38367
|
function isAborted(signal) {
|
|
38449
38368
|
return signal?.aborted === true;
|
|
38450
38369
|
}
|
|
38451
|
-
function fail$1(cause, operation) {
|
|
38452
|
-
return {
|
|
38453
|
-
ok: false,
|
|
38454
|
-
error: cause instanceof CapxulError ? cause : Errors.providerError("wallet-signer", operation, cause)
|
|
38455
|
-
};
|
|
38456
|
-
}
|
|
38457
38370
|
async function execute(deps, orgId, command, signal) {
|
|
38458
38371
|
if (isAborted(signal)) return {
|
|
38459
38372
|
ok: false,
|
|
@@ -38472,7 +38385,10 @@ async function execute(deps, orgId, command, signal) {
|
|
|
38472
38385
|
try {
|
|
38473
38386
|
signerAddress = await deps.signer.getAddress();
|
|
38474
38387
|
} catch (cause) {
|
|
38475
|
-
return
|
|
38388
|
+
return {
|
|
38389
|
+
ok: false,
|
|
38390
|
+
error: signerFailure(deps.signer.source, "getAddress", cause)
|
|
38391
|
+
};
|
|
38476
38392
|
}
|
|
38477
38393
|
const executionFns = deps.executionFunctions ?? moneyExecutionContract;
|
|
38478
38394
|
const prepared = await runIfActive(signal, "permissions.prepareExecution", () => deps.convexCall.action(executionFns.preparePermissionExecution, { input: {
|
|
@@ -38494,7 +38410,10 @@ async function execute(deps, orgId, command, signal) {
|
|
|
38494
38410
|
try {
|
|
38495
38411
|
signature = await deps.signer.signUserOpHash(prepared.value.digest);
|
|
38496
38412
|
} catch (cause) {
|
|
38497
|
-
return
|
|
38413
|
+
return {
|
|
38414
|
+
ok: false,
|
|
38415
|
+
error: signerFailure(deps.signer.source, "signUserOpHash", cause)
|
|
38416
|
+
};
|
|
38498
38417
|
}
|
|
38499
38418
|
if (isAborted(signal)) return {
|
|
38500
38419
|
ok: false,
|
|
@@ -38572,7 +38491,7 @@ function makeOrganizationPaymentsMethods(deps, orgId) {
|
|
|
38572
38491
|
} catch (cause) {
|
|
38573
38492
|
return {
|
|
38574
38493
|
ok: false,
|
|
38575
|
-
error: cause instanceof CapxulError ? cause : Errors.
|
|
38494
|
+
error: cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
38576
38495
|
};
|
|
38577
38496
|
}
|
|
38578
38497
|
const flightKey = `${requestKeyScope}:${operation}:${requestKey.key}`;
|
|
@@ -38619,16 +38538,16 @@ function makeOrganizationPaymentsMethods(deps, orgId) {
|
|
|
38619
38538
|
try {
|
|
38620
38539
|
await requestKey.finish(false);
|
|
38621
38540
|
} catch {}
|
|
38622
|
-
|
|
38541
|
+
return {
|
|
38542
|
+
ok: false,
|
|
38543
|
+
error: cause instanceof CapxulError ? cause : Errors.unknown(cause)
|
|
38544
|
+
};
|
|
38623
38545
|
}
|
|
38624
38546
|
release(false);
|
|
38625
38547
|
try {
|
|
38626
38548
|
await requestKey.finish(result.ok);
|
|
38627
38549
|
} catch {}
|
|
38628
|
-
return result.
|
|
38629
|
-
ok: true,
|
|
38630
|
-
value: result.value.payments.map((payment) => normalizePaymentTiming(payment))
|
|
38631
|
-
} : result;
|
|
38550
|
+
return mapOk(result, (value) => value.payments.map((payment) => normalizePaymentTiming(payment)));
|
|
38632
38551
|
};
|
|
38633
38552
|
return {
|
|
38634
38553
|
pay: async (input, options) => {
|
|
@@ -39379,18 +39298,104 @@ function detectAuthCacheAdapter() {
|
|
|
39379
39298
|
return new InMemoryAuthCacheAdapter();
|
|
39380
39299
|
}
|
|
39381
39300
|
//#endregion
|
|
39301
|
+
//#region ../../packages/sdk/src/telemetry/capture-exception.ts
|
|
39302
|
+
/** Fixed, leak-safe message — the raw error message may carry PII and never ships. */
|
|
39303
|
+
const EXCEPTION_MESSAGE = "Capxul SDK operation failed";
|
|
39304
|
+
//#endregion
|
|
39382
39305
|
//#region ../../packages/sdk/src/observation.ts
|
|
39383
39306
|
const SDK_VERSION$1 = version;
|
|
39307
|
+
/** @internal Observe public result methods at the assembled Core SDK boundary. */
|
|
39308
|
+
function observeSdkClient(client, adapter, snapshot) {
|
|
39309
|
+
if (adapter === void 0) return client;
|
|
39310
|
+
const objectProxies = /* @__PURE__ */ new WeakMap();
|
|
39311
|
+
const proxyTargets = /* @__PURE__ */ new WeakMap();
|
|
39312
|
+
const functionWrappers = /* @__PURE__ */ new WeakMap();
|
|
39313
|
+
const wrapObject = (target, path, internal = false) => {
|
|
39314
|
+
const cacheKey = `${internal ? "internal" : "public"}:${path.join(".")}`;
|
|
39315
|
+
let targetProxies = objectProxies.get(target);
|
|
39316
|
+
const cached = targetProxies?.get(cacheKey);
|
|
39317
|
+
if (cached !== void 0) return cached;
|
|
39318
|
+
const proxy = new Proxy(target, { get(currentTarget, property, receiver) {
|
|
39319
|
+
const value = Reflect.get(currentTarget, property, receiver);
|
|
39320
|
+
if (typeof property !== "string") return value;
|
|
39321
|
+
if (path.length === 0 && property === "_internal" && isPlainObject(value)) return wrapObject(value, ["_internal"], true);
|
|
39322
|
+
if (internal && property !== "accounts") return value;
|
|
39323
|
+
return wrapValue(value, [...path, property], currentTarget);
|
|
39324
|
+
} });
|
|
39325
|
+
proxyTargets.set(proxy, target);
|
|
39326
|
+
if (targetProxies === void 0) {
|
|
39327
|
+
targetProxies = /* @__PURE__ */ new Map();
|
|
39328
|
+
objectProxies.set(target, targetProxies);
|
|
39329
|
+
}
|
|
39330
|
+
targetProxies.set(cacheKey, proxy);
|
|
39331
|
+
return proxy;
|
|
39332
|
+
};
|
|
39333
|
+
const wrapValue = (value, path, owner) => {
|
|
39334
|
+
if (typeof value === "function") {
|
|
39335
|
+
const callable = value;
|
|
39336
|
+
const operation = path.join(".");
|
|
39337
|
+
let ownerWrappers = functionWrappers.get(owner);
|
|
39338
|
+
if (ownerWrappers === void 0) {
|
|
39339
|
+
ownerWrappers = /* @__PURE__ */ new Map();
|
|
39340
|
+
functionWrappers.set(owner, ownerWrappers);
|
|
39341
|
+
}
|
|
39342
|
+
const cached = ownerWrappers.get(operation);
|
|
39343
|
+
if (cached !== void 0) return cached;
|
|
39344
|
+
let wrapped;
|
|
39345
|
+
wrapped = new Proxy(callable, {
|
|
39346
|
+
apply(currentTarget, thisArg, args) {
|
|
39347
|
+
const invocation = resolveInvocationSnapshot(adapter, snapshot);
|
|
39348
|
+
let output;
|
|
39349
|
+
try {
|
|
39350
|
+
output = Reflect.apply(currentTarget, unwrapReceiver(thisArg), args);
|
|
39351
|
+
} catch (cause) {
|
|
39352
|
+
report(adapter, "exception", operation, cause, invocation);
|
|
39353
|
+
throw cause;
|
|
39354
|
+
}
|
|
39355
|
+
if (isPromiseLike(output)) return Promise.resolve(output).then((result) => processOutput(result, path, invocation), (cause) => {
|
|
39356
|
+
report(adapter, "exception", operation, cause, invocation);
|
|
39357
|
+
throw cause;
|
|
39358
|
+
});
|
|
39359
|
+
return processOutput(output, path, invocation);
|
|
39360
|
+
},
|
|
39361
|
+
get(currentTarget, property) {
|
|
39362
|
+
if (property === "bind") return Function.prototype.bind.bind(wrapped);
|
|
39363
|
+
if (property === "call") return Function.prototype.call.bind(wrapped);
|
|
39364
|
+
if (property === "apply") return Function.prototype.apply.bind(wrapped);
|
|
39365
|
+
const attached = Reflect.get(currentTarget, property, currentTarget);
|
|
39366
|
+
if (typeof property !== "string") return attached;
|
|
39367
|
+
return wrapValue(attached, [...path, property], currentTarget);
|
|
39368
|
+
}
|
|
39369
|
+
});
|
|
39370
|
+
proxyTargets.set(wrapped, callable);
|
|
39371
|
+
ownerWrappers.set(operation, wrapped);
|
|
39372
|
+
return wrapped;
|
|
39373
|
+
}
|
|
39374
|
+
return isPlainObject(value) ? wrapObject(value, path) : value;
|
|
39375
|
+
};
|
|
39376
|
+
const processOutput = (output, path, invocation) => {
|
|
39377
|
+
if (isFailedResult(output)) {
|
|
39378
|
+
report(adapter, "operation", path.join("."), output.error, invocation);
|
|
39379
|
+
return output;
|
|
39380
|
+
}
|
|
39381
|
+
if (isCapxulResult(output)) return output;
|
|
39382
|
+
return isPlainObject(output) ? wrapObject(output, path) : output;
|
|
39383
|
+
};
|
|
39384
|
+
return wrapObject(client, []);
|
|
39385
|
+
function unwrapReceiver(receiver) {
|
|
39386
|
+
return (typeof receiver === "object" || typeof receiver === "function") && receiver !== null ? proxyTargets.get(receiver) ?? receiver : receiver;
|
|
39387
|
+
}
|
|
39388
|
+
}
|
|
39384
39389
|
/** @internal Reports a factory-level typed failure without changing its identity. */
|
|
39385
39390
|
function observeFailedResult(result, adapter, operation) {
|
|
39386
|
-
if (adapter !== void 0 && isFailedResult(result)) report(adapter, "operation", operation, result.error,
|
|
39391
|
+
if (adapter !== void 0 && isFailedResult(result)) report(adapter, "operation", operation, result.error, resolveAdapterSnapshot(adapter));
|
|
39387
39392
|
return result;
|
|
39388
39393
|
}
|
|
39389
|
-
function report(adapter, kind, operation, cause,
|
|
39394
|
+
function report(adapter, kind, operation, cause, invocation) {
|
|
39390
39395
|
const operationName = normalizeOperation(operation);
|
|
39391
39396
|
const kindName = normalizeErrorKind(errorKind(cause));
|
|
39392
39397
|
const context = sanitizeObservationContext({
|
|
39393
|
-
...
|
|
39398
|
+
...invocation.context,
|
|
39394
39399
|
...isCapxulError(cause) && cause.correlationId !== void 0 ? { correlationId: cause.correlationId } : {}
|
|
39395
39400
|
});
|
|
39396
39401
|
const failure = markFailureInvocationSnapshot({
|
|
@@ -39400,13 +39405,27 @@ function report(adapter, kind, operation, cause, invocationContext) {
|
|
|
39400
39405
|
errorKind: kindName,
|
|
39401
39406
|
...context === void 0 ? {} : { context }
|
|
39402
39407
|
}, {
|
|
39403
|
-
active:
|
|
39408
|
+
active: invocation.active,
|
|
39404
39409
|
...context === void 0 ? {} : { context }
|
|
39405
39410
|
});
|
|
39406
39411
|
try {
|
|
39407
39412
|
ignoreDeliveryFailure(kind === "operation" ? adapter.captureOperationFailure(failure) : adapter.captureException(failure));
|
|
39408
39413
|
} catch {}
|
|
39409
39414
|
}
|
|
39415
|
+
function resolveInvocationSnapshot(adapter, snapshot) {
|
|
39416
|
+
if (snapshot !== void 0) try {
|
|
39417
|
+
const captured = snapshot();
|
|
39418
|
+
if (captured !== void 0) return captured;
|
|
39419
|
+
} catch {}
|
|
39420
|
+
return resolveAdapterSnapshot(adapter);
|
|
39421
|
+
}
|
|
39422
|
+
function resolveAdapterSnapshot(adapter) {
|
|
39423
|
+
const context = resolveAdapterContext(adapter);
|
|
39424
|
+
return context === void 0 ? { active: false } : {
|
|
39425
|
+
active: true,
|
|
39426
|
+
context
|
|
39427
|
+
};
|
|
39428
|
+
}
|
|
39410
39429
|
function resolveAdapterContext(adapter) {
|
|
39411
39430
|
try {
|
|
39412
39431
|
return adapter.resolveContext?.();
|
|
@@ -39574,6 +39593,7 @@ function withAdapterClose(client, closeAdapter) {
|
|
|
39574
39593
|
};
|
|
39575
39594
|
}
|
|
39576
39595
|
function assembleCapxulClient(input) {
|
|
39596
|
+
const observation = input;
|
|
39577
39597
|
const authCache = input.authCache ?? detectAuthCacheAdapter();
|
|
39578
39598
|
const effectRunner = input.effectRunner ?? {
|
|
39579
39599
|
runSync: Effect.runSync,
|
|
@@ -39587,7 +39607,7 @@ function assembleCapxulClient(input) {
|
|
|
39587
39607
|
...input.signer === void 0 ? {} : { signer: input.signer },
|
|
39588
39608
|
...input.organizationSetup === void 0 ? {} : { organizationSetup: input.organizationSetup },
|
|
39589
39609
|
...input.otpTtlMs === void 0 ? {} : { otpTtlMs: input.otpTtlMs }
|
|
39590
|
-
}), scope)),
|
|
39610
|
+
}), scope)), observation.hostObservationSnapshot);
|
|
39591
39611
|
const unsubscribeProductTelemetry = actor.subscribeTransitions((record) => {
|
|
39592
39612
|
effectRunner.runPromise(executeIdentityProductObservation(input.ports.telemetry, record, actor.snapshot())).catch(() => {});
|
|
39593
39613
|
});
|
|
@@ -39636,7 +39656,11 @@ function assembleCapxulClient(input) {
|
|
|
39636
39656
|
...input.invokeTimeoutMs === void 0 ? {} : { invokeTimeoutMs: input.invokeTimeoutMs },
|
|
39637
39657
|
afterVerifyOtp: async () => {
|
|
39638
39658
|
const browserSigner = input.signer;
|
|
39639
|
-
if (browserSigner !== void 0 && "resetSession" in browserSigner && typeof browserSigner.resetSession === "function")
|
|
39659
|
+
if (browserSigner !== void 0 && "resetSession" in browserSigner && typeof browserSigner.resetSession === "function") try {
|
|
39660
|
+
browserSigner.resetSession();
|
|
39661
|
+
} catch (cause) {
|
|
39662
|
+
throw signerFailure(browserSigner.source, "resetSession", cause);
|
|
39663
|
+
}
|
|
39640
39664
|
await detectPendingOrgInvitations?.();
|
|
39641
39665
|
kickProvisioning?.();
|
|
39642
39666
|
}
|
|
@@ -39742,7 +39766,7 @@ function assembleCapxulClient(input) {
|
|
|
39742
39766
|
};
|
|
39743
39767
|
}
|
|
39744
39768
|
};
|
|
39745
|
-
return {
|
|
39769
|
+
return observeSdkClient({
|
|
39746
39770
|
auth,
|
|
39747
39771
|
smartAccount,
|
|
39748
39772
|
identity,
|
|
@@ -39772,7 +39796,7 @@ function assembleCapxulClient(input) {
|
|
|
39772
39796
|
telemetry: input.ports.telemetry,
|
|
39773
39797
|
close: stopActor
|
|
39774
39798
|
}
|
|
39775
|
-
};
|
|
39799
|
+
}, observation.failureObservation, observation.hostObservationSnapshot);
|
|
39776
39800
|
}
|
|
39777
39801
|
function withHostObservation(actor, snapshot) {
|
|
39778
39802
|
if (snapshot === void 0) return actor;
|
|
@@ -40090,16 +40114,24 @@ function refreshConvexAuthOnSession(authClient, refresh) {
|
|
|
40090
40114
|
* particular object rather than on the auth seam itself. Here it wraps
|
|
40091
40115
|
* `AuthClientPort.signOut`, so it holds for every route to a sign-out.
|
|
40092
40116
|
*
|
|
40093
|
-
*
|
|
40094
|
-
*
|
|
40095
|
-
* to `tap` would silently strand an Openfort session on the error path.
|
|
40117
|
+
* Capture the sign-out exit before reset. This preserves the old `try/finally`
|
|
40118
|
+
* order and keeps a reset failure in the typed error channel.
|
|
40096
40119
|
*/
|
|
40097
40120
|
function resetSignerSessionOnSignOut(authClient, resetRef) {
|
|
40098
40121
|
return {
|
|
40099
40122
|
...authClient,
|
|
40100
|
-
signOut: (options) =>
|
|
40101
|
-
|
|
40102
|
-
|
|
40123
|
+
signOut: (options) => Effect.gen(function* () {
|
|
40124
|
+
const exit = yield* Effect.exit(authClient.signOut(options));
|
|
40125
|
+
yield* Effect.try({
|
|
40126
|
+
try: () => resetRef.current?.(),
|
|
40127
|
+
catch: (cause) => new AuthClientError({
|
|
40128
|
+
operation: "signOut",
|
|
40129
|
+
kind: "signer",
|
|
40130
|
+
cause
|
|
40131
|
+
})
|
|
40132
|
+
});
|
|
40133
|
+
return yield* exit;
|
|
40134
|
+
})
|
|
40103
40135
|
};
|
|
40104
40136
|
}
|
|
40105
40137
|
async function createCapxulClient(input) {
|
|
@@ -40125,14 +40157,15 @@ async function createCapxulClient(input) {
|
|
|
40125
40157
|
if (signer === void 0 && runtime === "browser") signer = createOpenfortBrowserSignerFromBootstrap({
|
|
40126
40158
|
...adapters.value.bootstrap,
|
|
40127
40159
|
authBaseUrl: resolvedAuthBaseUrl
|
|
40128
|
-
}, {
|
|
40129
|
-
diagnostic: new ConsoleDiagnosticAdapter(),
|
|
40130
|
-
telemetry: adapters.value.ports.telemetry
|
|
40131
|
-
});
|
|
40160
|
+
}, { diagnostic: new ConsoleDiagnosticAdapter() });
|
|
40132
40161
|
if (signer !== void 0 && "resetSession" in signer) {
|
|
40133
|
-
const { resetSession } = signer;
|
|
40162
|
+
const { resetSession, source } = signer;
|
|
40134
40163
|
resetSignerSession.current = () => {
|
|
40135
|
-
|
|
40164
|
+
try {
|
|
40165
|
+
resetSession();
|
|
40166
|
+
} catch (cause) {
|
|
40167
|
+
throw signerFailure(source, "resetSession", cause);
|
|
40168
|
+
}
|
|
40136
40169
|
};
|
|
40137
40170
|
}
|
|
40138
40171
|
const client = assembleCapxulClient({
|
|
@@ -40150,6 +40183,7 @@ async function createCapxulClient(input) {
|
|
|
40150
40183
|
...input.signal === void 0 ? {} : { signal: input.signal },
|
|
40151
40184
|
...input.otpTtlMs === void 0 ? {} : { otpTtlMs: input.otpTtlMs },
|
|
40152
40185
|
invokeTimeoutMs: input.invokeTimeoutMs ?? 3e4,
|
|
40186
|
+
...input.observability?.failures === void 0 && input.observation === void 0 ? {} : { failureObservation: input.observability?.failures ?? input.observation },
|
|
40153
40187
|
...input.observability === void 0 ? {} : { hostObservationSnapshot: () => snapshotHostObservability(input.observability) },
|
|
40154
40188
|
effectRunner: {
|
|
40155
40189
|
runSync: Effect.runSyncWith(adapters.value.context),
|
|
@@ -40159,7 +40193,11 @@ async function createCapxulClient(input) {
|
|
|
40159
40193
|
const upstreamClose = adapters.value.close;
|
|
40160
40194
|
const close = idempotentClose(async () => {
|
|
40161
40195
|
try {
|
|
40162
|
-
if ("resetSession" in
|
|
40196
|
+
if (signer !== void 0 && "resetSession" in signer) try {
|
|
40197
|
+
signer.resetSession();
|
|
40198
|
+
} catch (cause) {
|
|
40199
|
+
throw signerFailure(signer.source, "resetSession", cause);
|
|
40200
|
+
}
|
|
40163
40201
|
} finally {
|
|
40164
40202
|
await Promise.all([client._internal.close?.(), upstreamClose()]);
|
|
40165
40203
|
}
|
|
@@ -43593,9 +43631,10 @@ function makeSdkClientFactory(config, options = { mode: { mode: "live" } }) {
|
|
|
43593
43631
|
actorRequestsGet: (actor, requestId) => actorBundle(client, actor).requests.get(requestId),
|
|
43594
43632
|
actorRequestsCancel: (actor, requestId) => actorBundle(client, actor).requests.cancel(requestId),
|
|
43595
43633
|
inboxList: (actor) => actorBundle(client, actor).inbox.list(),
|
|
43596
|
-
inboxApprove: (actor, requestId, timing) => actorBundle(client, actor).inbox.approve({
|
|
43634
|
+
inboxApprove: (actor, requestId, timing, permissionId) => actorBundle(client, actor).inbox.approve({
|
|
43597
43635
|
requestId,
|
|
43598
|
-
...timing === void 0 ? {} : { timing }
|
|
43636
|
+
...timing === void 0 ? {} : { timing },
|
|
43637
|
+
...permissionId === void 0 ? {} : { permissionId }
|
|
43599
43638
|
}),
|
|
43600
43639
|
inboxDecline: (actor, requestId) => actorBundle(client, actor).inbox.decline(requestId),
|
|
43601
43640
|
addDestination: (input) => client.destinations.add({
|