@capxul/sdk 3.1.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -90,14 +90,20 @@ governed PostHog ingest origin, public project token, and environment. The SDK
90
90
  derives endpoints, service, producer, and version. Missing or invalid policy
91
91
  disables engineering export without failing client creation.
92
92
 
93
- Onboarding uses explicit domain objects. Personal completion accepts
94
- `{ profile }`; Organization completion accepts independently validated
95
- `{ profile, organization }`. The latter makes the Member Profile and personal
96
- Account/Safe ready before the first Organization write, then returns the exact
97
- `orgId` and its `OrgLifecycle`. A failed lifecycle after creation is returned
98
- with that `orgId`; Organization-list timing is not a success gate.
99
- Public Profile reads include the durable `onboarded` flag and optional
100
- `withdrawalAddress`, and `toEvmAddress` validates form-sourced withdrawal values.
93
+ Person onboarding is one Core SDK journey. It requires a normalized, globally
94
+ unique handle before it writes the Profile or starts Account setup:
95
+
96
+ ```ts
97
+ const onboarded = await client.onboarding.completePerson({
98
+ displayName: "Ada Lovelace",
99
+ country: "GH",
100
+ handle: "ada_lovelace",
101
+ });
102
+ ```
103
+
104
+ The backend remains the authority for reserved names and global uniqueness.
105
+ The method returns only after the client requirement reaches a ready Account.
106
+ The React frontend does not use this journey yet.
101
107
 
102
108
  ## Published entry points
103
109
 
@@ -105,7 +111,7 @@ The packed npm package exposes only:
105
111
 
106
112
  - `@capxul/sdk` — the client factory, public method and value types, signers,
107
113
  host observability helper, and immutable Base Sepolia Payment contract
108
- identity.
114
+ identity. It also re-exports the canonical Capxul operation vocabulary.
109
115
  - `@capxul/sdk/node` — Node-only signer and runtime helpers.
110
116
  - `@capxul/sdk/testing` — the real identity runtime assembled over
111
117
  deterministic in-memory ports, with OTP, advance-only clock, transition,
@@ -1,4 +1,4 @@
1
- import { F as toEmail, I as toEpochMs, K as toSessionToken, L as toEpochSeconds, R as toJwtToken, Z as Errors, c as ClockError, k as toAuthUserId, l as ClockPortTag, t as readClockNow, u as authClientPortFromPromiseAdapter } from "./clock-m_aHLaNm.mjs";
1
+ import { A as toAuthUserId, B as toJwtToken, I as toEmail, J as toSessionToken, L as toEpochMs, R as toEpochSeconds, c as ClockError, l as ClockPortTag, t as readClockNow, tt as Errors, u as authClientPortFromPromiseAdapter } from "./clock-C2AUlq1V.mjs";
2
2
  import { Effect, Layer } from "effect";
3
3
  //#region src/adapters/clock/SystemClockAdapter.ts
4
4
  var SystemClockAdapter = class {
@@ -1,4 +1,4 @@
1
- import { _ as ClockPort, v as AuthClientPort } from "./signer-BpjdawiY.mjs";
1
+ import { _ as ClockPort, v as AuthClientPort } from "./signer-C0hZ6Kiy.mjs";
2
2
  //#region src/adapters/auth-client/OAuthBearerAuthClient.d.ts
3
3
  interface OAuthBearerAuthClientInput {
4
4
  /** The exchange endpoint: `{authBaseUrl}/api/auth/agent/exchange`. */
@@ -1,5 +1,5 @@
1
- import { concat, encodeAbiParameters, encodeFunctionData, encodePacked, getContractAddress, keccak256, padHex, stringToHex, toBytes, toEventSelector, toFunctionSelector, toFunctionSignature } from "viem";
2
1
  import { Context, Data, Effect, Layer, Result } from "effect";
2
+ import { concat, encodeAbiParameters, encodeFunctionData, encodePacked, getContractAddress, keccak256, padHex, stringToHex, toBytes, toEventSelector, toFunctionSelector, toFunctionSignature } from "viem";
3
3
  //#region ../errors/src/secret-material.ts
4
4
  const SENSITIVE_MATERIAL_PATTERNS = [
5
5
  /(?:^|[^a-fA-F0-9])(?<!0[xX])[a-fA-F0-9]{64}(?:$|[^a-fA-F0-9])/u,
@@ -601,6 +601,10 @@ function decodeConvexError(err) {
601
601
  return null;
602
602
  }
603
603
  //#endregion
604
+ //#region ../errors/src/index.ts
605
+ /** Canonical handle syntax shared by validation and branded constructors. */
606
+ const HANDLE_RE = /^[a-z0-9_-]{3,30}$/;
607
+ //#endregion
604
608
  //#region ../types/src/index.ts
605
609
  const EVM_ADDRESS_RE = /^0x[0-9a-f]{40}$/i;
606
610
  const BYTES32_RE = /^0x[0-9a-f]{64}$/i;
@@ -661,6 +665,10 @@ function toPartyId(raw) {
661
665
  if (typeof raw !== "string" || !PARTY_ID_RE.test(raw)) throw Errors.invalidInput("partyId", invalidValueReason("must be party_ plus an alphanumeric id", raw));
662
666
  return raw;
663
667
  }
668
+ function toHandle(raw) {
669
+ if (typeof raw !== "string" || !HANDLE_RE.test(raw)) throw Errors.invalidInput("handle", invalidValueReason("must be 3-30 characters of a-z, 0-9, underscore, or hyphen", raw));
670
+ return raw;
671
+ }
664
672
  function toBudgetId(raw) {
665
673
  return toNonEmptyStringBrand(raw, "budgetId");
666
674
  }
@@ -718,6 +726,10 @@ function currencySymbolFor(code) {
718
726
  if (symbol === void 0) throw Errors.invalidInput("currencyCode", `no symbol registered for "${String(code)}"`);
719
727
  return symbol;
720
728
  }
729
+ function toTesterKind(raw) {
730
+ if (raw !== "human" && raw !== "e2e" && raw !== "agent") throw Errors.invalidInput("testerKind", "must be human, e2e, or agent");
731
+ return raw;
732
+ }
721
733
  function toKycTier(raw) {
722
734
  if (typeof raw !== "number" || !Number.isInteger(raw) || raw < 0 || raw > 3) throw Errors.invalidInput("kycTier", invalidValueReason("must be an integer in [0, 3]", raw));
723
735
  return raw;
@@ -757,6 +769,27 @@ function invalidValueReason(prefix, raw) {
757
769
  return `${prefix}: ${String(raw)}`;
758
770
  }
759
771
  //#endregion
772
+ //#region ../config/src/handle.ts
773
+ const RESERVED_HANDLES = /* @__PURE__ */ new Set([
774
+ "admin",
775
+ "api",
776
+ "capxul",
777
+ "help",
778
+ "root",
779
+ "support",
780
+ "system",
781
+ "www"
782
+ ]);
783
+ function normalizeHandle(raw) {
784
+ return raw.trim().toLowerCase().replace(/^@/, "");
785
+ }
786
+ function validateHandle(raw) {
787
+ const handle = normalizeHandle(raw);
788
+ if (!HANDLE_RE.test(handle)) throw Errors.invalidInput("handle", "must be 3-30 characters of a-z, 0-9, underscore, or hyphen");
789
+ if (RESERVED_HANDLES.has(handle)) throw Errors.invalidInput("handle", "handle is reserved");
790
+ return handle;
791
+ }
792
+ //#endregion
760
793
  //#region ../config/src/tokens.ts
761
794
  /** `TestUSDC` ("USDX") — Base Sepolia, 6 decimals, open `mint`. (Canon §1.) */
762
795
  const USDX_ADDRESS_BASE_SEPOLIA = "0xf09fcbb6df9f8f918e58f9c8ab15a76ade862b77";
@@ -1857,4 +1890,4 @@ async function readClockNow(clock) {
1857
1890
  }
1858
1891
  }
1859
1892
  //#endregion
1860
- export { CHAIN_UPSTREAMS as $, toBudgetId as A, toOrgId as B, ZERO_BYTES32 as C, toAllowedOrigin as D, toAddress as E, toEmail as F, toRoleKey as G, toPayrollGroupId as H, toEpochMs as I, CAPXUL_ERROR_CODES as J, toSessionToken as K, toEpochSeconds as L, toCountryCode as M, toCurrencyCode as N, toAppId as O, toDurationMs as P, isCapxulError as Q, toJwtToken as R, WEI_RE as S, toAccountId as T, toPayrollRunId as U, toPartyId as V, toPublishableKey as W, EXPECTED_OPERATION_OUTCOMES as X, CapxulError as Y, Errors as Z, deriveCapxulSafeAddress as _, parseCachedJwt as a, failureFingerprint as at, EVM_ADDRESS_RE as b, ClockError as c, revertSummaryText as ct, AuthClientError as d, FAILURE_MODES as et, AuthClientPortTag as f, BASE_SEPOLIA_CHAIN_ID as g, normalizeBindingEmail as h, parseAuthSession as i, decodeChainCause as it, toChainId as j, toAuthUserId as k, ClockPortTag as l, containsSensitiveMaterial as lt, CAPXUL_PAYMENTS_V2_ADDRESS as m, InMemoryAuthCacheAdapter as n, chainCauseProperties as nt, AuthCacheError as o, isChainUpstream as ot, orgRoleKeyForLabel as p, decodeConvexError as q, BrowserAuthCacheAdapter as r, chainEvidenceLabel as rt, AuthCachePortTag as s, isFailureMode as st, readClockNow as t, boundedResponseHeaders as tt, authClientPortFromPromiseAdapter as u, redactSecrets as ut, APP_ID_RE as v, currencySymbolFor as w, SUPPORTED_CURRENCY_CODES as x, BYTES32_RE as y, toKycTier as z };
1893
+ export { CapxulError as $, toAuthUserId as A, toJwtToken as B, WEI_RE as C, toAddress as D, toAccountId as E, toDurationMs as F, toPayrollRunId as G, toOrgId as H, toEmail as I, toSessionToken as J, toPublishableKey as K, toEpochMs as L, toChainId as M, toCountryCode as N, toAllowedOrigin as O, toCurrencyCode as P, CAPXUL_ERROR_CODES as Q, toEpochSeconds as R, SUPPORTED_CURRENCY_CODES as S, currencySymbolFor as T, toPartyId as U, toKycTier as V, toPayrollGroupId as W, HANDLE_RE as X, toTesterKind as Y, decodeConvexError as Z, deriveCapxulSafeAddress as _, parseCachedJwt as a, boundedResponseHeaders as at, BYTES32_RE as b, ClockError as c, decodeChainCause as ct, AuthClientError as d, isFailureMode as dt, EXPECTED_OPERATION_OUTCOMES as et, AuthClientPortTag as f, revertSummaryText as ft, BASE_SEPOLIA_CHAIN_ID as g, normalizeBindingEmail as h, parseAuthSession as i, FAILURE_MODES as it, toBudgetId as j, toAppId as k, ClockPortTag as l, failureFingerprint as lt, CAPXUL_PAYMENTS_V2_ADDRESS as m, redactSecrets as mt, InMemoryAuthCacheAdapter as n, isCapxulError as nt, AuthCacheError as o, chainCauseProperties as ot, orgRoleKeyForLabel as p, containsSensitiveMaterial as pt, toRoleKey as q, BrowserAuthCacheAdapter as r, CHAIN_UPSTREAMS as rt, AuthCachePortTag as s, chainEvidenceLabel as st, readClockNow as t, Errors as tt, authClientPortFromPromiseAdapter as u, isChainUpstream as ut, validateHandle as v, ZERO_BYTES32 as w, EVM_ADDRESS_RE as x, APP_ID_RE as y, toHandle as z };