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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,157 @@
1
+ //#region ../errors/src/errors.d.ts
2
+ declare const CAPXUL_ERROR_CODES: readonly ["NOT_AUTHENTICATED", "EMAIL_DELIVERY_FAILED", "PROFILE_NOT_FOUND", "SMART_ACCOUNT_MISSING", "PLAYER_NOT_FOUND", "ACCOUNT_NOT_FOUND", "PROVIDER_ERROR", "INVALID_INPUT", "ENV_MISSING", "NOT_IMPLEMENTED", "VERIFICATION_REQUIRED", "INSUFFICIENT_BALANCE", "INVALID_RECIPIENT", "ROLE_PERMISSION_DENIED", "TRANSACTION_FAILED", "RATE_LIMITED", "NETWORK_ERROR", "UNKNOWN", "OTP_EXPIRED", "SIGNER_REJECTED", "CANCELLED", "WRONG_STATE"];
3
+ type CapxulErrorCode = (typeof CAPXUL_ERROR_CODES)[number];
4
+ /**
5
+ * Why an auth/provider call failed — a flat CAUSE enum. The *where* (which
6
+ * OpenFort operation) stays in the separate `operation` detail field; this
7
+ * names the root cause so a single `$exception` can be triaged without
8
+ * parsing the message. Five members, no free strings:
9
+ *
10
+ * - `auth-origin-mismatch`: OTP cookies live on `localhost:PORT` but OpenFort
11
+ * hits the Convex host → no session reaches the provider.
12
+ * - `stale-openfort-cache`: an old `userId` in scoped storage makes the SDK
13
+ * skip re-auth → 401 on `v2/accounts`.
14
+ * - `app-env-allowlist`: missing `VITE_CAPXUL_CONVEX_SITE_URL` / the origin is
15
+ * not allowlisted → 401.
16
+ * - `no-secure-context`: sandboxed/headless browser with no Web Crypto, so
17
+ * `getAddress`/`configure` can never produce an address. Previously vanished
18
+ * into `unknown`; the signer's secure-context probe now names it.
19
+ * - `unknown`: catch-all when no cause could be determined.
20
+ */
21
+ type FailureMode = "auth-origin-mismatch" | "stale-openfort-cache" | "app-env-allowlist" | "no-secure-context" | "unknown";
22
+ type CapxulErrorDetails = Record<string, unknown>;
23
+ type CapxulErrorOptions = {
24
+ readonly cause?: unknown;
25
+ readonly details?: CapxulErrorDetails;
26
+ readonly correlationId?: string;
27
+ readonly layer?: string;
28
+ };
29
+ declare class CapxulError extends Error {
30
+ readonly code: CapxulErrorCode;
31
+ readonly details?: CapxulErrorDetails;
32
+ readonly correlationId?: string;
33
+ readonly layer?: string;
34
+ constructor(code: CapxulErrorCode, message: string, options?: CapxulErrorOptions);
35
+ }
36
+ declare function isCapxulError(value: unknown): value is CapxulError;
37
+ //#endregion
38
+ //#region ../types/src/brand.d.ts
39
+ /**
40
+ * Nominal type helper. `Brand<T, B>` is structurally a `T` at runtime but
41
+ * distinct at compile time, preventing accidental swaps between primitives.
42
+ *
43
+ * @internal
44
+ */
45
+ declare const brand: unique symbol;
46
+ type Brand<T, B extends string> = T & {
47
+ readonly [brand]: B;
48
+ };
49
+ //#endregion
50
+ //#region ../types/src/index.d.ts
51
+ type Address = Brand<string, "Address">;
52
+ type Email = Brand<string, "Email">;
53
+ type Profile = {
54
+ readonly authUserId: AuthUserId;
55
+ readonly email: Email;
56
+ readonly displayName: string | null;
57
+ readonly country: CountryCode | null;
58
+ readonly kycTier: KycTier;
59
+ readonly createdAt: EpochMs;
60
+ readonly updatedAt: EpochMs;
61
+ };
62
+ type SmartAccount = {
63
+ readonly authUserId: AuthUserId;
64
+ readonly signerAddress: Address | null;
65
+ readonly smartAccountAddress: Address;
66
+ readonly chainId: ChainId;
67
+ readonly deployedAt: EpochMs | null;
68
+ readonly claimedAt: EpochMs | null;
69
+ readonly createdAt: EpochMs;
70
+ };
71
+ type Money = {
72
+ readonly currency: CurrencyCode;
73
+ readonly value: string;
74
+ readonly decimals: number;
75
+ };
76
+ type Account = {
77
+ readonly id: AccountId;
78
+ readonly balance: Money;
79
+ readonly available: Money;
80
+ };
81
+ /** Named bucket partitioning a logical Account (canon §9). */
82
+ type SubAccount = {
83
+ readonly id: SubAccountId;
84
+ readonly accountId: AccountId;
85
+ readonly name: string;
86
+ readonly balance: Money;
87
+ readonly createdAt: EpochMs;
88
+ };
89
+ type AuthUserId = Brand<string, "AuthUserId">;
90
+ type AnonymousDistinctId = Brand<string, "AnonymousDistinctId">;
91
+ type AccountId = Brand<string, "AccountId">;
92
+ type SubAccountId = Brand<string, "SubAccountId">;
93
+ type OrgId = Brand<string, "OrgId">;
94
+ type AppId = Brand<string, "AppId">;
95
+ type AllowedOrigin = Brand<string, "AllowedOrigin">;
96
+ type PublishableKey = Brand<string, "PublishableKey">;
97
+ type PublishableKeyId = Brand<string, "PublishableKeyId">;
98
+ type DurationMs = Brand<number, "DurationMs">;
99
+ type DeveloperApplication = {
100
+ readonly id: AppId;
101
+ readonly authUserId: AuthUserId;
102
+ readonly name: string;
103
+ readonly allowedOrigins: readonly AllowedOrigin[];
104
+ readonly createdAt: EpochMs;
105
+ readonly archivedAt: EpochMs | null;
106
+ };
107
+ type PublishableKeyRecord = {
108
+ readonly id: PublishableKeyId;
109
+ readonly applicationId: AppId;
110
+ readonly activeFromMs: EpochMs;
111
+ readonly gracePeriodEndsMs: EpochMs | null;
112
+ readonly revokedAt: EpochMs | null;
113
+ };
114
+ type TxHash = Brand<string, "TxHash">;
115
+ type DocumentHash = Brand<string, "DocumentHash">;
116
+ type EpochMs = Brand<number, "EpochMs">;
117
+ type EpochSeconds = Brand<number, "EpochSeconds">;
118
+ type ChainId = Brand<number, "ChainId">;
119
+ type CountryCode = Brand<string, "CountryCode">;
120
+ type CurrencyCode = Brand<SupportedCurrencyCode, "CurrencyCode">;
121
+ type KycTier = Brand<0 | 1 | 2 | 3, "KycTier">;
122
+ type BlockNumber = Brand<number, "BlockNumber">;
123
+ type RunId = Brand<string, "RunId">;
124
+ type RoleKey = Brand<string, "RoleKey">;
125
+ type SessionToken = Brand<string, "SessionToken">;
126
+ type JwtToken = Brand<string, "JwtToken">;
127
+ type AuthSession = {
128
+ readonly authUserId: AuthUserId;
129
+ readonly email: Email;
130
+ readonly token: SessionToken;
131
+ readonly expiresAt: EpochMs;
132
+ };
133
+ declare const SUPPORTED_CURRENCIES: readonly [{
134
+ readonly code: "USD";
135
+ readonly symbol: "$";
136
+ readonly name: "US Dollar";
137
+ }, {
138
+ readonly code: "NGN";
139
+ readonly symbol: "NGN";
140
+ readonly name: "Nigerian Naira";
141
+ }, {
142
+ readonly code: "GHS";
143
+ readonly symbol: "GHS";
144
+ readonly name: "Ghanaian Cedi";
145
+ }, {
146
+ readonly code: "KES";
147
+ readonly symbol: "KSh";
148
+ readonly name: "Kenyan Shilling";
149
+ }, {
150
+ readonly code: "UGX";
151
+ readonly symbol: "USh";
152
+ readonly name: "Ugandan Shilling";
153
+ }];
154
+ type SupportedCurrencyCode = (typeof SUPPORTED_CURRENCIES)[number]["code"];
155
+ //#endregion
156
+ export { SubAccount as A, PublishableKey as C, RunId as D, RoleKey as E, CapxulErrorDetails as F, FailureMode as I, isCapxulError as L, TxHash as M, CapxulError as N, SessionToken as O, CapxulErrorCode as P, Profile as S, PublishableKeyRecord as T, EpochMs as _, AnonymousDistinctId as a, Money as b, AuthUserId as c, CountryCode as d, CurrencyCode as f, Email as g, DurationMs as h, AllowedOrigin as i, SubAccountId as j, SmartAccount as k, BlockNumber as l, DocumentHash as m, AccountId as n, AppId as o, DeveloperApplication as p, Address as r, AuthSession as s, Account as t, ChainId as u, EpochSeconds as v, PublishableKeyId as w, OrgId as x, JwtToken as y };
157
+ //# sourceMappingURL=index-D0SflScT.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-D0SflScT.d.mts","names":[],"sources":["../../errors/src/errors.ts","../../types/src/brand.ts","../../types/src/index.ts"],"mappings":";cAKa,kBAAA;AAAA,KAyBD,eAAA,WAA0B,kBAAkB;;;;AAF9C;AAEV;;;;AAAwD;AAmBxD;;;;AAAuB;AAOvB;;;KAPY,WAAA;AAAA,KAOA,kBAAA,GAAqB,MAAM;AAAA,KAgB3B,kBAAA;EAAA,SACD,KAAA;EAAA,SACA,OAAA,GA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