@capxul/sdk 4.20.0-beta.26 → 4.20.0-beta.28
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/{access-BEMUjtyy.mjs → access-SP-ur4Ku.mjs} +757 -112
- package/dist/{index-JnWL305d.d.mts → index-V6HIBbMr.d.mts} +866 -544
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/node/index.d.mts +1 -1
- package/dist/node/index.mjs +1 -1
- package/dist/{production-D3saI6ME.mjs → production-CoxgepCr.mjs} +80 -435
- package/dist/testing/index.d.mts +1 -1
- package/dist/testing/index.mjs +2 -2
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $n as
|
|
1
|
+
import { $n as hashPermissionReplacementPreview, $r as carryInvocationParentSpan, A as registerProductTelemetryInvocation, An as onboardings, Ar as isEvmAddress, At as safe4337MultiSendUserOpCallData, B as makeOrganizationPaymentsMethods, Bi as isRecord, Bn as invitations, Br as runPortEffect, C as AccountReadPortTag, Ci as globalLocalStorage, Cr as toRoleKey, Ct as SEND_SIGNATURE, D as convexCallErrorFromCapxul, Dn as normalizeCapxulOperation, Dt as deriveCapxulSafeAddress, E as ConvexCallPortTag, En as isCapxulOperation, Fi as Errors, Fn as PreparedPermissionExecutionSchema, Fr as reference, Ft as callOperation, G as makeActorRelationshipMethods, Gn as workspaces, Gr as awaitCapxulResult, Gt as withCapturedAttemptContext, H as makePaymentsMethods, Hn as roles, Hr as observationOnlyControls, Ht as observeFailedResult, Ii as CapxulError, In as PermissionCommandViewSchema, Ir as makeAuthMethods, It as asCapxulError, J as makeTargetsMethods, Jn as ORGANIZATION_SETUP_STATUSES, Jr as toCapxulResult, K as makeCheckoutMethods, Kn as OrganizationSetupSchema, Kr as defectAsCapxulError, L as makeAccountMethods, Li as isCapxulError, Lr as askIdentity, Lt as toPublicError, M as makeApprovalsMethods, Mi as toEmail, Mn as commands, Mt as BASE_SEPOLIA_CHAIN_ID, N as makePayrollMethods, Nn as configurations, Nt as MULTI_SEND_CALL_ONLY, O as retryIdempotentRead, On as OPERATIONS, Or as toExactAssetAmount, Ot as normalizeSafeSaltEmail, P as makeUnavailablePayrollMethods, Pn as replacements, Pr as absurd, Pt as SAFE_SENTINEL_OWNERS, Qn as InvitationViewSchema, Qr as ActorFailure, Qt as version$1, R as emitDepositInitiated, Ri as FAILURE_MODES, Rr as publicIdentityFailure, Rt as failureDetail, Si as detectAuthCacheAdapter, Sn as CLI_INVOCATION_KINDS, Sr as toPermissionId, St as SEND_BATCH_SIGNATURE, T as TelemetryPortTag, Tn as CAPXUL_OPERATIONS, Tt as CONFIGURED_MONEY_ASSETS, U as waitForPaymentSubmission, Ui as AuthCachePortTag, Un as setups, Ur as runCapxulEffect, Ut as observeSdkClient, V as makeOfframpMethods, Vi as readField, Vn as members, Vr as sessionFromActor, Vt as postHogFailureObservation, W as makeDestinationsMethods, Wn as treasuries, Wr as withVerifiedOrganizationScope, Wt as observationContextProps, Xn as decodeChainCause, Xr as CAPXUL_ERROR_CODES, Y as subscribeFreshQuery, Yr as formatTraceparent, Zn as toOrgId, _ as accountFromAccountPositions, _n as validateHandle, _t as ROLES_SET_ALLOWANCE_ABI, an as openfortSignerNotReadyCode, ar as roleKeyForPermission, b as MONEY_READ_RATES, bi as AuthClientError, bn as CLI_CAPABILITIES, br as toBudgetId, bt as ROLE_MANAGEMENT_SIGNATURES, c as makePaymentDocumentsMethods, ci as observationRequestHeaders, cr as images, ct as resolveOrgPermissionIdentity, d as SmartAccountPortTag, di as readInvocationObservation, dn as toCountryCode, dr as isBytes32, dt as MULTI_SEND_SELECTOR, ei as withInvocationParentSpan, en as UNOBSERVABLE_SIGNER_STATUS, er as decodePermissionIntent$1, fi as sanitizeObservationContext, fn as toKycTier, fr as toExactHex, ft as OPERATOR, g as ConvexAccountLayer, gi as toAllowedOrigin, gn as toPartyId, gt as ROLES_EXEC_TRANSACTION_WITH_ROLE_ABI, h as makeAccountsMethods, hi as isCredentialField, hn as toHandle, hr as toLowerHex, ht as ROLES_ASSIGN_ROLES_ABI, ii as ClockPortTag, in as isSignerNotReadySignal, ir as ORG_BUDGET_ACTIONS, it as canonicalJson, ji as toAuthUserId, jn as authorities, jr as toAddress, jt as buildSafeMultiSendExecTransactionCall, k as bindProductTelemetryInvocation, ki as toEpochMs, kn as details, kt as safe4337ExecuteUserOpCallData, l as makeSmartAccountMethods, li as attachInvocationObservation, ln as makeCurrentUserMethods, lr as toAccountId, lt as CREATE_COMMITMENT_SIGNATURE, m as PonderIndexerAdapter, mi as redactUrlSecrets, mr as toLowerBytes32, mt as PARAMETER_TYPE, n as bootIdentityFlow, ni as SystemClockLayer, nr as CurrentPolicySchema, oi as BetterAuthNodeLayer, on as recoverRawDigestSigner, or as diagnostics, ot as moneySafeOpDigest, p as makeHoldingsMethods, pi as redactSecrets, pn as toTesterKind, pr as toLowerAddress, pt as OWNER_COMMITMENT_SIGNATURES, qn as ORGANIZATION_SETUP_REASONS, qr as runIfActive, r as makeMeMethods, rn as isEcdsaSignatureHex, rr as MONTHLY_REFILL_PERIOD_SECONDS, s as makeActivityMethods, si as BetterAuthBrowserLayer, sn as signerFailure, sr as AppIdSchema, st as ZODIAC_MODULE_PROXY_FACTORY, t as executeIdentityProductObservation, tn as causeChain, tr as keepRefillOnChange, u as ConvexSmartAccountLayer, ui as copyInvocationObservation, un as makeClientRequestMethods, ut as MODULE_PROXY_FACTORY_ABI, v as accountPositionsFromWire, vi as toPublishableKey, vr as DurationMsSchema, vt as ROLES_SET_TRANSACTION_UNWRAPPER_ABI, wn as stampTelemetryEnvelope, wr as ChainIdSchema, wt as CAPXUL_PAYMENTS_V2_ADDRESS, xi as AuthClientPortTag, xn as CLI_COMMAND_NAMES, xr as toPermissionAssignmentId, xt as SAFE_ENABLE_MODULE_ABI, yn as redactTelemetryProps, yr as EpochMsSchema, yt as ROLES_SET_UP_ABI, z as logDroppedEvent, zi as isFailureMode, zr as runIdentityFacade, zt as failureEvidenceProps } from "./access-SP-ur4Ku.mjs";
|
|
2
2
|
import { Cause, Clock, Context, Data, Deferred, Duration, Effect, Exit, FiberSet, Layer, Logger, Metric, Option, Predicate, References, Result, Schedule, Schema, SchemaIssue, SchemaParser, Scope, Stream, Tracer } from "effect";
|
|
3
3
|
import { getFunctionName } from "convex/server";
|
|
4
4
|
import { BaseError, decodeFunctionData, encodeAbiParameters, encodeFunctionData, formatUnits, getContractAddress, keccak256, padHex, parseAbiParameters, stringToHex, toBytes, toFunctionSelector, toHex } from "viem";
|
|
@@ -76,14 +76,6 @@ function isPostHogUrlProperty(key) {
|
|
|
76
76
|
return normalized.includes("url") || normalized.includes("referrer") || normalized.includes("path") || normalized.includes("filename");
|
|
77
77
|
}
|
|
78
78
|
//#endregion
|
|
79
|
-
//#region ../protocol/src/payroll/model.ts
|
|
80
|
-
function toPayrollRunId(raw) {
|
|
81
|
-
return toNonEmptyStringBrand(raw, "payrollRunId", (value) => isNonEmptyString(value));
|
|
82
|
-
}
|
|
83
|
-
function toPayrollGroupId(raw) {
|
|
84
|
-
return toNonEmptyStringBrand(raw, "payrollGroupId", (value) => isNonEmptyString(value));
|
|
85
|
-
}
|
|
86
|
-
//#endregion
|
|
87
79
|
//#region src/permissions/command-decoding.ts
|
|
88
80
|
/** The caller's input as a command: ids branded and the intent decoded, or invalid input thrown. */
|
|
89
81
|
const buildCommand = {
|
|
@@ -9748,13 +9740,15 @@ function normalizeOrgBudgetPolicy(policy) {
|
|
|
9748
9740
|
if (actionSet.has(action)) throw Errors.invalidInput("policy.actions", `duplicate Budget action: ${action}`);
|
|
9749
9741
|
actionSet.add(action);
|
|
9750
9742
|
}
|
|
9743
|
+
if (policy.refill === "monthly" && limit.kind === "unlimited") throw Errors.invalidInput("policy.refill", "only a capped Budget can refill");
|
|
9751
9744
|
return {
|
|
9752
9745
|
assetId,
|
|
9753
9746
|
tokenAddress,
|
|
9754
9747
|
decimals: policy.asset.decimals,
|
|
9755
9748
|
limit,
|
|
9756
9749
|
recipients,
|
|
9757
|
-
actions: ORG_BUDGET_ACTIONS.filter((action) => actionSet.has(action))
|
|
9750
|
+
actions: ORG_BUDGET_ACTIONS.filter((action) => actionSet.has(action)),
|
|
9751
|
+
refillPeriod: policy.refill === "monthly" ? MONTHLY_REFILL_PERIOD_SECONDS : 0n
|
|
9758
9752
|
};
|
|
9759
9753
|
}
|
|
9760
9754
|
function resolvedBudgetApprovalPermission(tokenAddress) {
|
|
@@ -9829,8 +9823,8 @@ function buildOrgBudgetCallsWithEncoder(input, encodeRoles) {
|
|
|
9829
9823
|
allowanceKey,
|
|
9830
9824
|
BigInt(policy.limit.rawUnits),
|
|
9831
9825
|
BigInt(policy.limit.rawUnits),
|
|
9832
|
-
0n,
|
|
9833
|
-
|
|
9826
|
+
policy.refillPeriod === 0n ? 0n : BigInt(policy.limit.rawUnits),
|
|
9827
|
+
policy.refillPeriod,
|
|
9834
9828
|
0n
|
|
9835
9829
|
]
|
|
9836
9830
|
}),
|
|
@@ -10024,13 +10018,20 @@ function buildExplicitBootstrapRoleCalls(input, encodeRoles) {
|
|
|
10024
10018
|
roles: [{
|
|
10025
10019
|
key: managementRoleKey,
|
|
10026
10020
|
members: [input.ownerAddress],
|
|
10027
|
-
permissions: [
|
|
10028
|
-
|
|
10029
|
-
|
|
10030
|
-
|
|
10031
|
-
|
|
10032
|
-
signature
|
|
10033
|
-
|
|
10021
|
+
permissions: [
|
|
10022
|
+
{
|
|
10023
|
+
targetAddress: input.rolesModuleAddress,
|
|
10024
|
+
signature: "assignRoles(address,bytes32[],bool[])"
|
|
10025
|
+
},
|
|
10026
|
+
...ROLE_MANAGEMENT_SIGNATURES.map((signature) => ({
|
|
10027
|
+
targetAddress: input.rolesModuleAddress,
|
|
10028
|
+
signature
|
|
10029
|
+
})),
|
|
10030
|
+
...OWNER_COMMITMENT_SIGNATURES.map((signature) => ({
|
|
10031
|
+
targetAddress: CAPXUL_PAYMENTS_V2_ADDRESS,
|
|
10032
|
+
signature
|
|
10033
|
+
}))
|
|
10034
|
+
]
|
|
10034
10035
|
}]
|
|
10035
10036
|
}).map((call) => ({
|
|
10036
10037
|
to: toLowerHex(call.to, "setUpRoles.call.to"),
|
|
@@ -10498,7 +10499,7 @@ function matchesCurrentPolicy(intent, policy) {
|
|
|
10498
10499
|
asset: policy.asset,
|
|
10499
10500
|
value: policy.limit
|
|
10500
10501
|
}, CONFIGURED_MONEY_ASSETS).minorUnits;
|
|
10501
|
-
return policy.asset === intent.asset && raw === recorded && (intent.scope === void 0 || canonicalJson(intent.scope) === canonicalJson(policy.scope));
|
|
10502
|
+
return policy.asset === intent.asset && raw === recorded && intent.refill === "monthly" === (policy.refill === "monthly") && (intent.scope === void 0 || canonicalJson(intent.scope) === canonicalJson(policy.scope));
|
|
10502
10503
|
}
|
|
10503
10504
|
function previousPolicyForChange(effect, command) {
|
|
10504
10505
|
if (effect.previousIntent.type === "budget" && (effect.previousIntent.scope === void 0 || effect.previousRecipientBindings === void 0)) throw new EvidenceMismatch("Prior complete Budget proof is unavailable");
|
|
@@ -10516,8 +10517,9 @@ function policyCalls(evidence, context, command) {
|
|
|
10516
10517
|
const roleKey = effect.operation === "change" ? effect.roleKey : roleKeyForPermission(permissionId);
|
|
10517
10518
|
const revision = effect.operation === "change" ? effect.revision : 0;
|
|
10518
10519
|
if (effect.operation !== command.operation || effect.operation === "change" && effect.permissionId !== permissionId || evidence.expectedRevision !== revision) throw new EvidenceMismatch("Permission policy binding mismatch");
|
|
10520
|
+
const intent = effect.operation === "change" ? keepRefillOnChange(command.intent, effect.previousCurrentPolicy) : command.intent;
|
|
10519
10521
|
const value = evidence.value;
|
|
10520
|
-
if (Array.isArray(value) || !("type" in value) || !matchesCurrentPolicy(
|
|
10522
|
+
if (Array.isArray(value) || !("type" in value) || !matchesCurrentPolicy(intent, value.currentPolicy) || !permissionMatches(value, context.orgId, permissionId, command.operation === "create" ? 0 : revision + 1, intent, roleKey)) throw new EvidenceMismatch("Permission value mismatch");
|
|
10521
10523
|
const planned = compilePermissionPolicyCallsWithEncoder({
|
|
10522
10524
|
permissionId,
|
|
10523
10525
|
roleKey,
|
|
@@ -10525,7 +10527,7 @@ function policyCalls(evidence, context, command) {
|
|
|
10525
10527
|
actorSafe: evidence.userOpSenderSafe,
|
|
10526
10528
|
rolesModule: context.rolesModule,
|
|
10527
10529
|
managerRoleKey: context.managerRoleKey,
|
|
10528
|
-
nextIntent: encodingIntent(
|
|
10530
|
+
nextIntent: encodingIntent(intent, effect.recipientBindings),
|
|
10529
10531
|
...previous === void 0 ? {} : { previousIntent: previous },
|
|
10530
10532
|
...effect.operation !== "change" || effect.previousAllowanceKey === null ? {} : { previousAllowanceKey: effect.previousAllowanceKey }
|
|
10531
10533
|
}, encodeRoles);
|
|
@@ -10577,7 +10579,8 @@ function encodingIntent(intent, bindings) {
|
|
|
10577
10579
|
"send",
|
|
10578
10580
|
"sendBatch",
|
|
10579
10581
|
"createCommitment"
|
|
10580
|
-
].filter((action) => action === "createCommitment" ? intent.scope.actions.includes("commitments") : intent.scope.actions.includes("pay"))
|
|
10582
|
+
].filter((action) => action === "createCommitment" ? intent.scope.actions.includes("commitments") : intent.scope.actions.includes("pay")),
|
|
10583
|
+
...intent.refill === "monthly" ? { refill: intent.refill } : {}
|
|
10581
10584
|
}
|
|
10582
10585
|
};
|
|
10583
10586
|
}
|
|
@@ -11232,411 +11235,6 @@ function makePermissionMethods(deps, orgId) {
|
|
|
11232
11235
|
};
|
|
11233
11236
|
}
|
|
11234
11237
|
//#endregion
|
|
11235
|
-
//#region src/payroll/run-checks.ts
|
|
11236
|
-
/** Match the caller's compensation to the committed V3 Payslip. */
|
|
11237
|
-
function payslipIdentityMatches(message, item, index, runId, period) {
|
|
11238
|
-
return message.runId === runId && message.itemIndex === index && message.employeeRef === item.partyId && message.periodStart === period.start && message.periodEnd === period.end && message.adjustmentsHash === hashAdjustmentsV3(item.adjustments);
|
|
11239
|
-
}
|
|
11240
|
-
function payslipAmountMatches(message, item) {
|
|
11241
|
-
const exact = toExactAssetAmount(item.amount, CONFIGURED_MONEY_ASSETS);
|
|
11242
|
-
return message.gross.asset === exact.asset && message.gross.minorUnits === item.gross && message.gross.decimals === exact.decimals && message.net.asset === exact.asset && message.net.minorUnits === item.net && message.net.decimals === exact.decimals;
|
|
11243
|
-
}
|
|
11244
|
-
function isRunItem(prepared, item, evidence, index, runId, period) {
|
|
11245
|
-
if (prepared === void 0) return false;
|
|
11246
|
-
const bundle = evidence.preparedCommand?.documentBundles?.[index];
|
|
11247
|
-
const preparedItem = evidence.preparedCommand?.items[index];
|
|
11248
|
-
const payslip = bundle?.envelope;
|
|
11249
|
-
if (bundle === void 0 || payslip?.primaryType !== "Payslip") return false;
|
|
11250
|
-
return canonicalJson(prepared.to) === canonicalJson(item.to) && prepared.paymentType === "payroll" && canonicalJson(prepared.amount) === canonicalJson(item.amount) && bundle.adjustments !== void 0 && canonicalJson(bundle.adjustments) === canonicalJson(item.adjustments) && payslipIdentityMatches(payslip.message, item, index, runId, period) && payslipAmountMatches(payslip.message, item) && (preparedItem?.operation === "send" || preparedItem?.operation === "create_commitment") && preparedItem.documentHash === evidence.preparedCommand?.instructionDocuments?.[index]?.documentHash;
|
|
11251
|
-
}
|
|
11252
|
-
/**
|
|
11253
|
-
* The batch the backend derived from a payroll intent must be the batch this
|
|
11254
|
-
* caller asked for, checked before the digest is signed.
|
|
11255
|
-
*
|
|
11256
|
-
* The payslip envelope on each item is server-built and carries the run row's
|
|
11257
|
-
* own `issuedAt`, so the batch cannot be fingerprinted against a local copy
|
|
11258
|
-
* (`matchesIntent` is unavailable here). What CAN be verified is every field
|
|
11259
|
-
* the caller supplied — the org, the Budget, the request key, and per item the
|
|
11260
|
-
* recipient, the amount and the payslip figures — plus the lineage binding the
|
|
11261
|
-
* batch to the run just written. A prepared command that pays a different
|
|
11262
|
-
* person, a different amount, from a different Budget, or under a different
|
|
11263
|
-
* run never reaches the signer.
|
|
11264
|
-
*/
|
|
11265
|
-
function isRunBatch(input) {
|
|
11266
|
-
return (batch, evidence) => Promise.resolve(!("kind" in batch) && batch.orgId === input.orgId && batch.permissionId === input.permissionId && batch.requestKey === input.requestKey && batch.lineage?.kind === "payroll" && batch.lineage.runId === input.runId && batch.items.length === input.items.length && batch.items.every((item) => item.amount.asset === input.asset) && input.items.every((item, index) => isRunItem(batch.items[index], item, evidence, index, input.runId, input.period)));
|
|
11267
|
-
}
|
|
11268
|
-
/** A decoded detail is the run asked for, whole: its scope, membership and quantities agree. */
|
|
11269
|
-
function checkPayrollRunDetail(value, orgId, runId) {
|
|
11270
|
-
if (value === null) return {
|
|
11271
|
-
ok: true,
|
|
11272
|
-
value: null
|
|
11273
|
-
};
|
|
11274
|
-
if (value.orgId !== orgId || value.run.id !== runId || value.items.length === 0 || value.items.length !== value.run.recipientCount || new Set(value.items.map((item) => item.payment.id)).size !== value.items.length || value.items.some((item, index) => item.itemIndex !== index || item.amount.asset !== value.run.total.asset || item.payment.amount.asset !== item.amount.asset || item.payment.paymentType !== "payroll")) return {
|
|
11275
|
-
ok: false,
|
|
11276
|
-
error: Errors.invalidInput("run", "Payroll run scope or membership does not match")
|
|
11277
|
-
};
|
|
11278
|
-
try {
|
|
11279
|
-
const total = toExactAssetAmount(value.run.total, CONFIGURED_MONEY_ASSETS);
|
|
11280
|
-
let rawTotal = 0n;
|
|
11281
|
-
for (const item of value.items) {
|
|
11282
|
-
const amount = toExactAssetAmount(item.amount, CONFIGURED_MONEY_ASSETS);
|
|
11283
|
-
const payment = toExactAssetAmount(item.payment.amount, CONFIGURED_MONEY_ASSETS);
|
|
11284
|
-
if (amount.minorUnits !== payment.minorUnits) return {
|
|
11285
|
-
ok: false,
|
|
11286
|
-
error: Errors.invalidInput("run", "Payroll item quantity does not match its Payment")
|
|
11287
|
-
};
|
|
11288
|
-
rawTotal += BigInt(amount.minorUnits);
|
|
11289
|
-
}
|
|
11290
|
-
if (rawTotal !== BigInt(total.minorUnits)) return {
|
|
11291
|
-
ok: false,
|
|
11292
|
-
error: Errors.invalidInput("run", "Payroll run total does not match its items")
|
|
11293
|
-
};
|
|
11294
|
-
} catch {
|
|
11295
|
-
return {
|
|
11296
|
-
ok: false,
|
|
11297
|
-
error: Errors.invalidInput("run", "Payroll run quantities are invalid")
|
|
11298
|
-
};
|
|
11299
|
-
}
|
|
11300
|
-
return {
|
|
11301
|
-
ok: true,
|
|
11302
|
-
value
|
|
11303
|
-
};
|
|
11304
|
-
}
|
|
11305
|
-
//#endregion
|
|
11306
|
-
//#region src/payroll/run-decoding.ts
|
|
11307
|
-
function toPayrollRun(wire) {
|
|
11308
|
-
return {
|
|
11309
|
-
id: toPayrollRunId(wire.id),
|
|
11310
|
-
status: wire.status,
|
|
11311
|
-
periodStart: wire.periodStart,
|
|
11312
|
-
periodEnd: wire.periodEnd,
|
|
11313
|
-
total: wire.total,
|
|
11314
|
-
recipientCount: wire.recipientCount
|
|
11315
|
-
};
|
|
11316
|
-
}
|
|
11317
|
-
function toPayrollRuns(wire) {
|
|
11318
|
-
return {
|
|
11319
|
-
...mapPage(wire, toPayrollRun),
|
|
11320
|
-
settledThisMonth: wire.settledThisMonth
|
|
11321
|
-
};
|
|
11322
|
-
}
|
|
11323
|
-
function toPayrollGroup(wire) {
|
|
11324
|
-
return {
|
|
11325
|
-
id: toPayrollGroupId(wire.id),
|
|
11326
|
-
name: wire.name,
|
|
11327
|
-
tone: wire.tone,
|
|
11328
|
-
members: wire.members.map((member) => ({
|
|
11329
|
-
partyId: member.partyId,
|
|
11330
|
-
amount: member.amount,
|
|
11331
|
-
currency: member.currency
|
|
11332
|
-
}))
|
|
11333
|
-
};
|
|
11334
|
-
}
|
|
11335
|
-
function validateRunItems(input) {
|
|
11336
|
-
for (const [index, item] of input.items.entries()) {
|
|
11337
|
-
if (Schema.decodeResult(PayrollRunItemInputSchema, { onExcessProperty: "error" })(item)._tag === "Failure") return Errors.invalidInput(`items.${index}`, "invalid Payroll item");
|
|
11338
|
-
try {
|
|
11339
|
-
const exact = toExactAssetAmount(item.amount, CONFIGURED_MONEY_ASSETS);
|
|
11340
|
-
const net = BigInt(item.net);
|
|
11341
|
-
const gross = BigInt(item.gross);
|
|
11342
|
-
const adjustments = item.adjustments.reduce((sum, row) => sum + BigInt(row.amount), 0n);
|
|
11343
|
-
if (item.amount.asset !== input.asset || item.net !== exact.minorUnits || gross + adjustments !== net) return Errors.invalidInput(`items.${index}`, "invalid Payroll units");
|
|
11344
|
-
} catch {
|
|
11345
|
-
return Errors.invalidInput(`items.${index}`, "invalid Payroll units");
|
|
11346
|
-
}
|
|
11347
|
-
}
|
|
11348
|
-
return null;
|
|
11349
|
-
}
|
|
11350
|
-
const RunInputSchema = Schema.Struct({
|
|
11351
|
-
permissionId: AuthorizePayrollRunExecutionInputSchema.fields.permissionId,
|
|
11352
|
-
asset: AuthorizePayrollRunExecutionInputSchema.fields.asset,
|
|
11353
|
-
period: AuthorizePayrollRunExecutionInputSchema.fields.period,
|
|
11354
|
-
items: AuthorizePayrollRunExecutionInputSchema.fields.items,
|
|
11355
|
-
requestKey: Schema.optional(AuthorizePayrollRunExecutionInputSchema.fields.requestKey)
|
|
11356
|
-
});
|
|
11357
|
-
/** Decode caller input before session or signer work. Keep routing outside the input. */
|
|
11358
|
-
function decodePayrollRunInput(value) {
|
|
11359
|
-
try {
|
|
11360
|
-
const decoded = Schema.decodeUnknownSync(RunInputSchema, { onExcessProperty: "error" })(value);
|
|
11361
|
-
const input = {
|
|
11362
|
-
permissionId: decoded.permissionId,
|
|
11363
|
-
asset: decoded.asset,
|
|
11364
|
-
period: decoded.period,
|
|
11365
|
-
...decoded.requestKey === void 0 ? {} : { requestKey: decoded.requestKey },
|
|
11366
|
-
items: decoded.items.map((item) => ({
|
|
11367
|
-
amount: item.amount,
|
|
11368
|
-
gross: item.gross,
|
|
11369
|
-
net: item.net,
|
|
11370
|
-
adjustments: item.adjustments,
|
|
11371
|
-
partyId: toPartyId(item.partyId),
|
|
11372
|
-
to: item.to.kind === "party" ? {
|
|
11373
|
-
kind: "party",
|
|
11374
|
-
partyId: toPartyId(item.to.partyId)
|
|
11375
|
-
} : item.to.kind === "address" ? {
|
|
11376
|
-
kind: "address",
|
|
11377
|
-
address: toAddress(item.to.address)
|
|
11378
|
-
} : item.to
|
|
11379
|
-
}))
|
|
11380
|
-
};
|
|
11381
|
-
if (input.items.length === 0 || input.period.start > input.period.end) throw Errors.invalidInput("input", "Payroll requires items and an ordered period");
|
|
11382
|
-
const error = validateRunItems(input);
|
|
11383
|
-
if (error !== null) throw error;
|
|
11384
|
-
return input;
|
|
11385
|
-
} catch (cause) {
|
|
11386
|
-
throw cause instanceof CapxulError ? cause : Errors.invalidInput("input", "Invalid Payroll input");
|
|
11387
|
-
}
|
|
11388
|
-
}
|
|
11389
|
-
/** Read only the exact backend prepare receipt, never an arbitrary signer failure. */
|
|
11390
|
-
function payrollResolution(error, requestKey) {
|
|
11391
|
-
const details = error.details;
|
|
11392
|
-
if (error.code !== "WRONG_STATE" || details?.method !== runs.authorize.name || details.requestKey !== requestKey || typeof details.commandId !== "string" || typeof details.runId !== "string") return void 0;
|
|
11393
|
-
return details.payrollResolution === "failed" || details.payrollResolution === "settled" ? details.payrollResolution : void 0;
|
|
11394
|
-
}
|
|
11395
|
-
function validatePayrollRunLookup(orgId, runId) {
|
|
11396
|
-
return !Schema.is(PayrollRunIdSchema)(runId) || orgId.length === 0 ? {
|
|
11397
|
-
ok: false,
|
|
11398
|
-
error: Errors.invalidInput("runId", "Organization and run ID must be valid")
|
|
11399
|
-
} : {
|
|
11400
|
-
ok: true,
|
|
11401
|
-
value: void 0
|
|
11402
|
-
};
|
|
11403
|
-
}
|
|
11404
|
-
/** Strict saved detail decoder shared by the read and fresh stream. */
|
|
11405
|
-
function decodePayrollRunDetail(raw, orgId, runId) {
|
|
11406
|
-
const decoded = Schema.decodeUnknownResult(Schema.NullOr(PayrollRunDetailSchema), { onExcessProperty: "error" })(raw);
|
|
11407
|
-
if (decoded._tag === "Failure") return {
|
|
11408
|
-
ok: false,
|
|
11409
|
-
error: Errors.invalidInput("run", "Invalid Payroll run detail")
|
|
11410
|
-
};
|
|
11411
|
-
return checkPayrollRunDetail(decoded.success, orgId, runId);
|
|
11412
|
-
}
|
|
11413
|
-
//#endregion
|
|
11414
|
-
//#region src/payroll/run-subscription.ts
|
|
11415
|
-
function detailValue(result) {
|
|
11416
|
-
if (!result.ok) throw result.error;
|
|
11417
|
-
return result.value;
|
|
11418
|
-
}
|
|
11419
|
-
function subscribePayrollRun(deps, orgId, runId, listener, options) {
|
|
11420
|
-
const operation = CAPXUL_OPERATIONS.org.payroll.subscribeRun;
|
|
11421
|
-
const valid = deps.validate(orgId, runId);
|
|
11422
|
-
if (!valid.ok) return runCapxulEffect(Effect.fail(valid.error), observationOnlyControls(deps.invocationControls?.(options) ?? options), operation, deps.runPromise);
|
|
11423
|
-
const decode = (raw) => detailValue(deps.decode(raw, orgId, runId));
|
|
11424
|
-
return subscribeFreshQuery(deps, {
|
|
11425
|
-
orgId,
|
|
11426
|
-
runId
|
|
11427
|
-
}, listener, operation, {
|
|
11428
|
-
decode,
|
|
11429
|
-
validateCached: (raw) => {
|
|
11430
|
-
decode(raw);
|
|
11431
|
-
},
|
|
11432
|
-
invalidValue: (cause) => isCapxulError(cause) ? cause : Errors.invalidInput("run", "Invalid Payroll run detail"),
|
|
11433
|
-
invalidScope: () => Errors.invalidInput("run", "Payroll run subscription scope does not match"),
|
|
11434
|
-
lostValue: () => Errors.invalidInput("run", "Payroll run is no longer readable"),
|
|
11435
|
-
unavailable: () => Errors.notImplemented("payroll", "subscribeRun")
|
|
11436
|
-
}, options);
|
|
11437
|
-
}
|
|
11438
|
-
//#endregion
|
|
11439
|
-
//#region src/payroll/run-authorization.ts
|
|
11440
|
-
/**
|
|
11441
|
-
* Authorize one payroll run: a stable request key, the prepared batch checked
|
|
11442
|
-
* against the run the caller asked for, the signature, and the submission.
|
|
11443
|
-
*/
|
|
11444
|
-
async function authorizePayrollRun(scope, input, controls, onRequestKey, onResolved) {
|
|
11445
|
-
const { deps, orgId, requestKeyScope } = scope;
|
|
11446
|
-
const signal = controls?.signal;
|
|
11447
|
-
const execution = executionDependencies(deps);
|
|
11448
|
-
if (execution === null) return {
|
|
11449
|
-
ok: false,
|
|
11450
|
-
error: Errors.notImplemented("payroll", "executionComposition")
|
|
11451
|
-
};
|
|
11452
|
-
try {
|
|
11453
|
-
input = decodePayrollRunInput(input);
|
|
11454
|
-
} catch (cause) {
|
|
11455
|
-
return {
|
|
11456
|
-
ok: false,
|
|
11457
|
-
error: asCapxulError(cause)
|
|
11458
|
-
};
|
|
11459
|
-
}
|
|
11460
|
-
const { requestKey: provided, ...canonicalInput } = input;
|
|
11461
|
-
const actorId = onRequestKey === void 0 ? void 0 : execution.actor.authSession()?.authUserId;
|
|
11462
|
-
if (onRequestKey !== void 0 && actorId === void 0) return {
|
|
11463
|
-
ok: false,
|
|
11464
|
-
error: Errors.notAuthenticated()
|
|
11465
|
-
};
|
|
11466
|
-
const requestKey = await paymentRequestKeyLifecycle(`${requestKeyScope}:${AUTHORIZE_RUN}`, onRequestKey === void 0 ? {
|
|
11467
|
-
orgId,
|
|
11468
|
-
input
|
|
11469
|
-
} : {
|
|
11470
|
-
actorId,
|
|
11471
|
-
orgId,
|
|
11472
|
-
input: canonicalInput
|
|
11473
|
-
}, provided, onRequestKey === void 0 ? void 0 : { manageProvidedKey: true });
|
|
11474
|
-
try {
|
|
11475
|
-
await onRequestKey?.(requestKey.key);
|
|
11476
|
-
if (onRequestKey !== void 0 && execution.actor.authSession()?.authUserId !== actorId) {
|
|
11477
|
-
await requestKey.finish(false).catch(() => void 0);
|
|
11478
|
-
return {
|
|
11479
|
-
ok: false,
|
|
11480
|
-
error: Errors.notAuthenticated()
|
|
11481
|
-
};
|
|
11482
|
-
}
|
|
11483
|
-
} catch (cause) {
|
|
11484
|
-
await requestKey.finish(false).catch(() => void 0);
|
|
11485
|
-
return {
|
|
11486
|
-
ok: false,
|
|
11487
|
-
error: asCapxulError(cause)
|
|
11488
|
-
};
|
|
11489
|
-
}
|
|
11490
|
-
let authorized;
|
|
11491
|
-
let acceptedReplay;
|
|
11492
|
-
let preparedClosed = false;
|
|
11493
|
-
let terminalReplay;
|
|
11494
|
-
const submitted = await executePrepared(execution, async (signerAddress) => {
|
|
11495
|
-
const prepared = await runIfActive(signal, AUTHORIZE_RUN, () => withInvocationParentSpan(Effect.suspend(() => callOperation(deps.convexCall, runs.authorize, copyInvocationObservation(controls, {
|
|
11496
|
-
orgId,
|
|
11497
|
-
permissionId: input.permissionId,
|
|
11498
|
-
asset: input.asset,
|
|
11499
|
-
requestKey: requestKey.key,
|
|
11500
|
-
signerAddress,
|
|
11501
|
-
period: input.period,
|
|
11502
|
-
items: input.items
|
|
11503
|
-
}))).pipe(Effect.mapError((publicError) => ({ publicError }))), controls), deps.runPromise);
|
|
11504
|
-
if (!prepared.ok) {
|
|
11505
|
-
terminalReplay = payrollResolution(prepared.error, requestKey.key);
|
|
11506
|
-
return prepared;
|
|
11507
|
-
}
|
|
11508
|
-
authorized = prepared.value.run;
|
|
11509
|
-
acceptedReplay = prepared.value.replay.kind === "accepted" ? prepared.value.replay.submission : void 0;
|
|
11510
|
-
return {
|
|
11511
|
-
ok: true,
|
|
11512
|
-
value: prepared.value.execution
|
|
11513
|
-
};
|
|
11514
|
-
}, (request, evidence) => authorized === void 0 || authorized.periodStart !== input.period.start || authorized.periodEnd !== input.period.end ? Promise.resolve(false) : isRunBatch({
|
|
11515
|
-
orgId,
|
|
11516
|
-
permissionId: input.permissionId,
|
|
11517
|
-
requestKey: requestKey.key,
|
|
11518
|
-
runId: authorized.id,
|
|
11519
|
-
asset: input.asset,
|
|
11520
|
-
period: input.period,
|
|
11521
|
-
items: input.items
|
|
11522
|
-
})(request, evidence), true, () => preparedClosed = true, signal, controls, void 0, () => acceptedReplay);
|
|
11523
|
-
const resolution = preparedClosed ? "failed" : terminalReplay;
|
|
11524
|
-
if (resolution !== void 0) try {
|
|
11525
|
-
await onResolved?.(resolution);
|
|
11526
|
-
} catch {}
|
|
11527
|
-
try {
|
|
11528
|
-
await requestKey.finish(submitted.ok || resolution !== void 0);
|
|
11529
|
-
} catch {}
|
|
11530
|
-
if (!submitted.ok) return submitted;
|
|
11531
|
-
return authorized === void 0 ? {
|
|
11532
|
-
ok: false,
|
|
11533
|
-
error: Errors.unknown()
|
|
11534
|
-
} : {
|
|
11535
|
-
ok: true,
|
|
11536
|
-
value: toPayrollRun(authorized)
|
|
11537
|
-
};
|
|
11538
|
-
}
|
|
11539
|
-
const AUTHORIZE_RUN = runs.authorize.name;
|
|
11540
|
-
function executionDependencies(deps) {
|
|
11541
|
-
return deps.actor === void 0 || deps.chainId === void 0 || deps.signer === void 0 ? null : {
|
|
11542
|
-
actor: deps.actor,
|
|
11543
|
-
chainId: deps.chainId,
|
|
11544
|
-
convexCall: deps.convexCall,
|
|
11545
|
-
runPromise: deps.runPromise,
|
|
11546
|
-
signer: deps.signer,
|
|
11547
|
-
...deps.telemetry === void 0 ? {} : { telemetry: deps.telemetry }
|
|
11548
|
-
};
|
|
11549
|
-
}
|
|
11550
|
-
//#endregion
|
|
11551
|
-
//#region src/payroll/runs.ts
|
|
11552
|
-
function makePayrollMethods(deps, orgId) {
|
|
11553
|
-
const requestKeyScope = deps.requestKeyScope ?? `client-${crypto.randomUUID()}`;
|
|
11554
|
-
/** One observed call of one payroll row, its reply projected inside the call, under the row's name. */
|
|
11555
|
-
const call = (row, args, options, project) => {
|
|
11556
|
-
const controls = deps.invocationControls?.(options) ?? options;
|
|
11557
|
-
return runPortEffect(callOperation(deps.convexCall, row, copyInvocationObservation(controls, args)).pipe(Effect.map(project), Effect.mapError((publicError) => ({ publicError }))), controls, row.name, deps.runPromise);
|
|
11558
|
-
};
|
|
11559
|
-
return {
|
|
11560
|
-
subscribeRun: (runId, listener, options) => subscribePayrollRun({
|
|
11561
|
-
actor: deps.actor,
|
|
11562
|
-
convexCall: deps.convexCall,
|
|
11563
|
-
query: reference(runs.get),
|
|
11564
|
-
runPromise: deps.runPromise,
|
|
11565
|
-
invocationControls: deps.invocationControls,
|
|
11566
|
-
decode: decodePayrollRunDetail,
|
|
11567
|
-
validate: validatePayrollRunLookup
|
|
11568
|
-
}, orgId, runId, listener, options),
|
|
11569
|
-
getRun: (runId, options) => {
|
|
11570
|
-
const controls = deps.invocationControls?.(options) ?? options;
|
|
11571
|
-
const lifetime = deps.actor?.authLifetime();
|
|
11572
|
-
const operation = runs.get.name;
|
|
11573
|
-
return runCapxulEffect(Effect.gen(function* () {
|
|
11574
|
-
const lookup = validatePayrollRunLookup(orgId, runId);
|
|
11575
|
-
if (!lookup.ok) return yield* Effect.fail(lookup.error);
|
|
11576
|
-
if (lifetime === void 0 || lifetime.authUserId === null || deps.actor === void 0) return yield* Effect.fail(Errors.notAuthenticated());
|
|
11577
|
-
const current = () => deps.actor?.matchesAuthLifetime(lifetime, lifetime.authUserId) === true;
|
|
11578
|
-
if (!current()) return yield* Effect.fail(Errors.notAuthenticated());
|
|
11579
|
-
const parent = yield* Effect.currentSpan.pipe(Effect.orDie);
|
|
11580
|
-
const captured = carryInvocationParentSpan(controls, parent);
|
|
11581
|
-
const run = yield* awaitCapxulResult(() => runIfActive(controls?.signal, operation, () => withInvocationParentSpan(Effect.suspend(() => callOperation(deps.convexCall, runs.get, copyInvocationObservation(captured, {
|
|
11582
|
-
orgId,
|
|
11583
|
-
runId
|
|
11584
|
-
}))).pipe(Effect.mapError((publicError) => ({ publicError }))), captured), deps.runPromise));
|
|
11585
|
-
if (!current()) return yield* Effect.fail(Errors.cancelled({ operation }));
|
|
11586
|
-
const checked = checkPayrollRunDetail(run, orgId, runId);
|
|
11587
|
-
return yield* checked.ok ? Effect.succeed(checked.value) : Effect.fail(checked.error);
|
|
11588
|
-
}), observationOnlyControls(controls), operation, deps.runPromise);
|
|
11589
|
-
},
|
|
11590
|
-
runs: (options) => call(runs.list, { orgId }, options, toPayrollRuns),
|
|
11591
|
-
authorizeRun: (input, options) => {
|
|
11592
|
-
const controls = deps.invocationControls?.(options) ?? options;
|
|
11593
|
-
return runCapxulEffect(Effect.gen(function* () {
|
|
11594
|
-
if (controls?.signal?.aborted === true) return yield* Effect.fail(Errors.cancelled({ operation: AUTHORIZE_RUN }));
|
|
11595
|
-
const parent = yield* Effect.currentSpan.pipe(Effect.orDie);
|
|
11596
|
-
return yield* awaitCapxulResult(() => authorizePayrollRun({
|
|
11597
|
-
deps,
|
|
11598
|
-
orgId,
|
|
11599
|
-
requestKeyScope
|
|
11600
|
-
}, input, carryInvocationParentSpan(controls, parent), options?.onRequestKey, options?.onResolved));
|
|
11601
|
-
}), observationOnlyControls(controls), AUTHORIZE_RUN, deps.runPromise);
|
|
11602
|
-
},
|
|
11603
|
-
terms: (options) => call(terms.list, { orgId }, options, (rates) => rates),
|
|
11604
|
-
groups: {
|
|
11605
|
-
list: (options) => call(groups.list, { orgId }, options, (saved) => mapPage(saved, toPayrollGroup)),
|
|
11606
|
-
save: (input, options) => call(groups.save, {
|
|
11607
|
-
orgId,
|
|
11608
|
-
...input.id === void 0 ? {} : { id: String(input.id) },
|
|
11609
|
-
name: input.name,
|
|
11610
|
-
tone: input.tone,
|
|
11611
|
-
members: input.members
|
|
11612
|
-
}, options, toPayrollGroup),
|
|
11613
|
-
remove: (id, options) => call(groups.remove, {
|
|
11614
|
-
orgId,
|
|
11615
|
-
id
|
|
11616
|
-
}, options, () => void 0)
|
|
11617
|
-
}
|
|
11618
|
-
};
|
|
11619
|
-
}
|
|
11620
|
-
const payrollUnavailable = () => Promise.resolve({
|
|
11621
|
-
ok: false,
|
|
11622
|
-
error: Errors.notImplemented("payroll", "executionComposition")
|
|
11623
|
-
});
|
|
11624
|
-
/** The bundle an unconfigured client exposes — every verb refuses, none throws. */
|
|
11625
|
-
function makeUnavailablePayrollMethods() {
|
|
11626
|
-
return {
|
|
11627
|
-
getRun: payrollUnavailable,
|
|
11628
|
-
subscribeRun: payrollUnavailable,
|
|
11629
|
-
runs: payrollUnavailable,
|
|
11630
|
-
authorizeRun: payrollUnavailable,
|
|
11631
|
-
terms: payrollUnavailable,
|
|
11632
|
-
groups: {
|
|
11633
|
-
list: payrollUnavailable,
|
|
11634
|
-
save: payrollUnavailable,
|
|
11635
|
-
remove: payrollUnavailable
|
|
11636
|
-
}
|
|
11637
|
-
};
|
|
11638
|
-
}
|
|
11639
|
-
//#endregion
|
|
11640
11238
|
//#region src/signing/embedded-wallet.ts
|
|
11641
11239
|
function openfortEmbeddedWalletPort(input) {
|
|
11642
11240
|
return {
|
|
@@ -12574,6 +12172,22 @@ function normalizeRuntimeUrl(field, raw) {
|
|
|
12574
12172
|
}
|
|
12575
12173
|
//#endregion
|
|
12576
12174
|
//#region src/applications/bootstrap-adapter.ts
|
|
12175
|
+
/** A cached envelope this close to its expiry is fetched again, so it cannot lapse mid-command. */
|
|
12176
|
+
const CACHE_EXPIRY_MARGIN_MS = 3e4;
|
|
12177
|
+
/**
|
|
12178
|
+
* The cached envelope, when it is still inside its own lifetime. It is decoded
|
|
12179
|
+
* as a fresh body is; anything that does not decode, or a store that fails,
|
|
12180
|
+
* is a miss.
|
|
12181
|
+
*/
|
|
12182
|
+
async function cachedEnvelope(cache, now) {
|
|
12183
|
+
try {
|
|
12184
|
+
const cached = decodeBootstrapBody(await cache.load());
|
|
12185
|
+
const expiresAt = cached.issuedAt + cached.expiresIn - CACHE_EXPIRY_MARGIN_MS;
|
|
12186
|
+
return cached.issuedAt <= now && now < expiresAt ? cached : null;
|
|
12187
|
+
} catch {
|
|
12188
|
+
return null;
|
|
12189
|
+
}
|
|
12190
|
+
}
|
|
12577
12191
|
const DEFAULT_RETRY = {
|
|
12578
12192
|
attempts: 2,
|
|
12579
12193
|
baseDelayMs: 400
|
|
@@ -12614,19 +12228,24 @@ var HttpBootstrapAdapter = class {
|
|
|
12614
12228
|
fetchImpl;
|
|
12615
12229
|
observation;
|
|
12616
12230
|
retry;
|
|
12231
|
+
cache;
|
|
12617
12232
|
constructor(deps) {
|
|
12618
12233
|
this.bootstrapBaseUrl = deps.bootstrapBaseUrl.replace(/\/$/, "");
|
|
12619
12234
|
this.bootstrapHost = hostOf(this.bootstrapBaseUrl);
|
|
12620
12235
|
this.observation = deps.observation;
|
|
12621
12236
|
this.retry = deps.retry ?? DEFAULT_RETRY;
|
|
12237
|
+
this.cache = deps.cache;
|
|
12622
12238
|
this.fetchImpl = deps.fetch ?? ((input, init) => globalThis.fetch(input, init));
|
|
12623
12239
|
}
|
|
12624
12240
|
resolve(input) {
|
|
12625
|
-
|
|
12241
|
+
const fetched = this.attempt(input).pipe(Effect.retry({
|
|
12626
12242
|
times: this.retry.attempts,
|
|
12627
12243
|
while: isTransientBootstrapFailure,
|
|
12628
12244
|
schedule: Schedule.exponential(Duration.millis(this.retry.baseDelayMs))
|
|
12629
12245
|
}));
|
|
12246
|
+
const cache = this.cache;
|
|
12247
|
+
if (cache === void 0) return fetched;
|
|
12248
|
+
return Effect.promise(() => cachedEnvelope(cache, Date.now())).pipe(Effect.filterOrElse((cached) => cached !== null, () => fetched));
|
|
12630
12249
|
}
|
|
12631
12250
|
attempt(input) {
|
|
12632
12251
|
return Effect.tryPromise({
|
|
@@ -12651,7 +12270,13 @@ var HttpBootstrapAdapter = class {
|
|
|
12651
12270
|
}
|
|
12652
12271
|
mapResponse(res, input) {
|
|
12653
12272
|
if (res.ok) return Effect.tryPromise({
|
|
12654
|
-
try: async () =>
|
|
12273
|
+
try: async () => {
|
|
12274
|
+
const body = await res.json();
|
|
12275
|
+
const resolution = decodeBootstrapBody(body);
|
|
12276
|
+
const cache = this.cache;
|
|
12277
|
+
if (cache !== void 0) await Promise.resolve().then(() => cache.save(body)).catch(() => void 0);
|
|
12278
|
+
return resolution;
|
|
12279
|
+
},
|
|
12655
12280
|
catch: (cause) => {
|
|
12656
12281
|
if (cause instanceof CapxulError && cause.code === "INVALID_INPUT") return bootstrapErrorFromCapxul("invalidInput", cause);
|
|
12657
12282
|
return bootstrapErrorFromCapxul("malformedBody", Errors.providerError("convex", "bootstrap", cause instanceof Error ? cause : new Error(String(cause))));
|
|
@@ -14320,7 +13945,9 @@ function makeNotImplementedOrganizationPaymentsMethods() {
|
|
|
14320
13945
|
subscribe: organizationPaymentExecutionUnavailable,
|
|
14321
13946
|
pay: organizationPaymentExecutionUnavailable,
|
|
14322
13947
|
payBatch: organizationPaymentExecutionUnavailable,
|
|
14323
|
-
retry: organizationPaymentExecutionUnavailable
|
|
13948
|
+
retry: organizationPaymentExecutionUnavailable,
|
|
13949
|
+
cancel: organizationPaymentExecutionUnavailable,
|
|
13950
|
+
redirect: organizationPaymentExecutionUnavailable
|
|
14324
13951
|
};
|
|
14325
13952
|
}
|
|
14326
13953
|
const orgMeUnavailable = () => Promise.resolve({
|
|
@@ -15223,6 +14850,23 @@ function subscribeConvexQuery(client, fn, args, callback, options) {
|
|
|
15223
14850
|
* ever needs a different one.
|
|
15224
14851
|
*/
|
|
15225
14852
|
const DEFAULT_CLOSE_TIMEOUT_MS = 5e3;
|
|
14853
|
+
/**
|
|
14854
|
+
* The fetcher the Convex client's auth handshake gets. Convex first asks for
|
|
14855
|
+
* "a possibly cached token" (`forceRefreshToken: false`) and, as soon as the
|
|
14856
|
+
* server accepts it, for a fresh one (`true`): the token whose `exp` it
|
|
14857
|
+
* schedules the next refresh from. The Better Auth clients keep no token: each
|
|
14858
|
+
* ask mints one over the network, so the cached ask was a second token fetch
|
|
14859
|
+
* and a second server verification (a JWKS read) on every session restore. It
|
|
14860
|
+
* answers "none" instead, and Convex makes its one fetch forced, as a fresh
|
|
14861
|
+
* token. Every forced ask still reaches the auth client: that first fetch, the
|
|
14862
|
+
* refresh before `exp`, and the retry after the server rejects a token.
|
|
14863
|
+
* ponytail: the OAuth bearer client can hold a cached exchange; it now pays one
|
|
14864
|
+
* exchange for the first authentication instead of reusing it (never more
|
|
14865
|
+
* fetches than before). Pass the cache through if that start ever matters.
|
|
14866
|
+
*/
|
|
14867
|
+
function freshTokenHandshake(fetchToken) {
|
|
14868
|
+
return async (args) => args.forceRefreshToken ? fetchToken(args) : null;
|
|
14869
|
+
}
|
|
15226
14870
|
/** Run a Convex call under the current trace parent, when there is one. */
|
|
15227
14871
|
const withTraceparent = (run) => Effect.flatMap(Effect.serviceOption(Tracer.ParentSpan), (parent) => run(parent._tag === "Some" ? formatTraceparent(parent.value) : void 0));
|
|
15228
14872
|
var ConvexCallAdapter = class {
|
|
@@ -15247,10 +14891,10 @@ var ConvexCallAdapter = class {
|
|
|
15247
14891
|
this.#tokenProvider = deps.tokenProvider;
|
|
15248
14892
|
this.#applicationId = deps.applicationId;
|
|
15249
14893
|
this.#observation = deps.observation;
|
|
15250
|
-
|
|
14894
|
+
this.refreshAuth();
|
|
15251
14895
|
}
|
|
15252
14896
|
refreshAuth() {
|
|
15253
|
-
if (this.#tokenProvider) this.#client.setAuth(this.#tokenProvider);
|
|
14897
|
+
if (this.#tokenProvider) this.#client.setAuth(freshTokenHandshake(this.#tokenProvider));
|
|
15254
14898
|
}
|
|
15255
14899
|
observeConnection(observer) {
|
|
15256
14900
|
return this.#connectionMonitor.observe(this.#client, observer);
|
|
@@ -16807,7 +16451,8 @@ async function createProductionAdapters(input) {
|
|
|
16807
16451
|
const bootstrapLayer = HttpBootstrapLayer({
|
|
16808
16452
|
bootstrapBaseUrl: resolvedInput.value.bootstrapBaseUrl,
|
|
16809
16453
|
...input.fetch === void 0 ? {} : { fetch: input.fetch },
|
|
16810
|
-
...invocationObservation === void 0 ? {} : { observation: invocationObservation }
|
|
16454
|
+
...invocationObservation === void 0 ? {} : { observation: invocationObservation },
|
|
16455
|
+
...input.bootstrapCache === void 0 ? {} : { cache: input.bootstrapCache }
|
|
16811
16456
|
});
|
|
16812
16457
|
try {
|
|
16813
16458
|
const bootstrapContext = await Effect.runPromise(Layer.buildWithScope(bootstrapLayer, scope));
|
|
@@ -17699,4 +17344,4 @@ async function createCapxulClient(input) {
|
|
|
17699
17344
|
return createCapxulClientWithSignerControls(input, {});
|
|
17700
17345
|
}
|
|
17701
17346
|
//#endregion
|
|
17702
|
-
export {
|
|
17347
|
+
export { cloneTelemetryEvent as a, identityErrorFromCapxul as c, devPrivateKeySigner as d, createOpenfortBrowserSigner as f, decodePermissionIntent as g, openfortEmbeddedWalletPort as h, postHogObservability as i, bootstrapErrorFromCapxul as l, openfortEmbeddedSignerFromWallet as m, createCapxulClientWithSignerControls as n, cloneTelemetryProps as o, embeddedSigner as p, assembleCapxulClient as r, IdentityPortTag as s, createCapxulClient as t, deriveDevPrivateKey as u };
|