@reauth-dev/sdk 0.1.0 → 0.3.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/chunk-5LFJ5PXQ.mjs +1042 -0
- package/dist/chunk-EY5LQCDG.mjs +6 -0
- package/dist/index.d.mts +201 -16
- package/dist/index.d.ts +201 -16
- package/dist/index.js +801 -29
- package/dist/index.mjs +2 -1
- package/dist/react/index.d.mts +75 -5
- package/dist/react/index.d.ts +75 -5
- package/dist/react/index.js +965 -44
- package/dist/react/index.mjs +160 -11
- package/dist/server.d.mts +20 -2
- package/dist/server.d.ts +20 -2
- package/dist/server.js +61 -12
- package/dist/server.mjs +57 -11
- package/dist/types-DKUKhCNE.d.mts +349 -0
- package/dist/types-DKUKhCNE.d.ts +349 -0
- package/dist/webhooks.js +7 -3
- package/dist/webhooks.mjs +7 -3
- package/package.json +5 -2
- package/dist/chunk-JX2J36FS.mjs +0 -269
- package/dist/types-D8oOYbeC.d.mts +0 -169
- package/dist/types-D8oOYbeC.d.ts +0 -169
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/** Response from GET /api/public/auth/session */
|
|
2
|
+
type ReauthSession = {
|
|
3
|
+
valid: boolean;
|
|
4
|
+
end_user_id: string | null;
|
|
5
|
+
email: string | null;
|
|
6
|
+
roles: string[] | null;
|
|
7
|
+
/** Active organization ID */
|
|
8
|
+
active_org_id: string | null;
|
|
9
|
+
/** User's role in the active organization ("owner" | "member") */
|
|
10
|
+
org_role: string | null;
|
|
11
|
+
waitlist_position: number | null;
|
|
12
|
+
/** Whether the user has linked their Google account */
|
|
13
|
+
google_linked: boolean | null;
|
|
14
|
+
/** Whether the user has linked their X (Twitter) account */
|
|
15
|
+
twitter_linked: boolean | null;
|
|
16
|
+
error: string | null;
|
|
17
|
+
/** Error code (e.g., "ACCOUNT_SUSPENDED", "SESSION_VERIFICATION_FAILED") */
|
|
18
|
+
error_code: string | null;
|
|
19
|
+
/** Subscription information (if billing is configured) */
|
|
20
|
+
subscription?: {
|
|
21
|
+
status: string;
|
|
22
|
+
plan_code: string | null;
|
|
23
|
+
plan_name: string | null;
|
|
24
|
+
current_period_end: number | null;
|
|
25
|
+
cancel_at_period_end: boolean | null;
|
|
26
|
+
trial_ends_at: number | null;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
/** Authenticated user object (basic) */
|
|
30
|
+
type User = {
|
|
31
|
+
id: string;
|
|
32
|
+
email: string;
|
|
33
|
+
roles: string[];
|
|
34
|
+
/** Active organization ID */
|
|
35
|
+
activeOrgId: string;
|
|
36
|
+
/** User's role in the active organization ("owner" | "member") */
|
|
37
|
+
orgRole: string;
|
|
38
|
+
};
|
|
39
|
+
/** Full user details (from Developer API) */
|
|
40
|
+
type UserDetails = {
|
|
41
|
+
id: string;
|
|
42
|
+
email: string;
|
|
43
|
+
roles: string[];
|
|
44
|
+
emailVerifiedAt: string | null;
|
|
45
|
+
lastLoginAt: string | null;
|
|
46
|
+
isFrozen: boolean;
|
|
47
|
+
isWhitelisted: boolean;
|
|
48
|
+
createdAt: string | null;
|
|
49
|
+
};
|
|
50
|
+
/** JWT claims for domain end-user tokens */
|
|
51
|
+
type DomainEndUserClaims = {
|
|
52
|
+
/** User ID (subject) */
|
|
53
|
+
sub: string;
|
|
54
|
+
/** Domain ID */
|
|
55
|
+
domain_id: string;
|
|
56
|
+
/** Root domain (e.g., "example.com") */
|
|
57
|
+
domain: string;
|
|
58
|
+
/** Active organization ID */
|
|
59
|
+
active_org_id: string;
|
|
60
|
+
/** User's role in the active organization ("owner" | "member") */
|
|
61
|
+
org_role: string;
|
|
62
|
+
/** User roles */
|
|
63
|
+
roles: string[];
|
|
64
|
+
/** Subscription information */
|
|
65
|
+
subscription: {
|
|
66
|
+
status: string;
|
|
67
|
+
plan_code: string | null;
|
|
68
|
+
plan_name: string | null;
|
|
69
|
+
current_period_end: number | null;
|
|
70
|
+
cancel_at_period_end: boolean | null;
|
|
71
|
+
trial_ends_at: number | null;
|
|
72
|
+
};
|
|
73
|
+
/** Token expiration (Unix timestamp) */
|
|
74
|
+
exp: number;
|
|
75
|
+
/** Token issued at (Unix timestamp) */
|
|
76
|
+
iat: number;
|
|
77
|
+
};
|
|
78
|
+
/** Configuration for browser-side reauth client */
|
|
79
|
+
type ReauthConfig = {
|
|
80
|
+
/** Your verified domain (e.g., "yourdomain.com") */
|
|
81
|
+
domain: string;
|
|
82
|
+
/** Request timeout in milliseconds. Defaults to 10 seconds if not specified. */
|
|
83
|
+
timeout?: number;
|
|
84
|
+
};
|
|
85
|
+
/** Configuration for server-side reauth client */
|
|
86
|
+
type ReauthServerConfig = ReauthConfig & {
|
|
87
|
+
/** API key for server-to-server authentication (required, e.g., "sk_live_...") */
|
|
88
|
+
apiKey: string;
|
|
89
|
+
};
|
|
90
|
+
/** Role within an organization */
|
|
91
|
+
type OrgRole = "owner" | "member";
|
|
92
|
+
/** Organization details */
|
|
93
|
+
type Organization = {
|
|
94
|
+
id: string;
|
|
95
|
+
name: string;
|
|
96
|
+
isPersonal: boolean;
|
|
97
|
+
createdAt: string | null;
|
|
98
|
+
};
|
|
99
|
+
/** Organization member */
|
|
100
|
+
type OrgMember = {
|
|
101
|
+
id: string;
|
|
102
|
+
orgId: string;
|
|
103
|
+
endUserId: string;
|
|
104
|
+
role: OrgRole;
|
|
105
|
+
joinedAt: string | null;
|
|
106
|
+
};
|
|
107
|
+
/** Email invitation to an organization */
|
|
108
|
+
type OrgInvitation = {
|
|
109
|
+
id: string;
|
|
110
|
+
orgId: string;
|
|
111
|
+
email: string;
|
|
112
|
+
token: string;
|
|
113
|
+
role: OrgRole;
|
|
114
|
+
status: "pending" | "accepted";
|
|
115
|
+
expiresAt: string;
|
|
116
|
+
acceptedAt: string | null;
|
|
117
|
+
createdAt: string | null;
|
|
118
|
+
};
|
|
119
|
+
/** Shareable invite link for an organization */
|
|
120
|
+
type OrgInviteLink = {
|
|
121
|
+
id: string;
|
|
122
|
+
orgId: string;
|
|
123
|
+
token: string;
|
|
124
|
+
role: OrgRole;
|
|
125
|
+
isActive: boolean;
|
|
126
|
+
expiresAt: string;
|
|
127
|
+
createdAt: string | null;
|
|
128
|
+
};
|
|
129
|
+
/** Result of accepting an invite or switching org */
|
|
130
|
+
type SwitchOrgResult = {
|
|
131
|
+
activeOrgId: string;
|
|
132
|
+
orgRole: OrgRole;
|
|
133
|
+
subscription: SubscriptionInfo;
|
|
134
|
+
};
|
|
135
|
+
/** Subscription status values */
|
|
136
|
+
type SubscriptionStatus = "active" | "past_due" | "canceled" | "trialing" | "incomplete" | "incomplete_expired" | "unpaid" | "paused" | "none";
|
|
137
|
+
/** Subscription info included in JWT claims */
|
|
138
|
+
type SubscriptionInfo = {
|
|
139
|
+
/** Current subscription status */
|
|
140
|
+
status: SubscriptionStatus;
|
|
141
|
+
/** Machine-readable plan identifier (e.g., "pro") */
|
|
142
|
+
planCode: string | null;
|
|
143
|
+
/** Human-readable plan name (e.g., "Pro Plan") */
|
|
144
|
+
planName: string | null;
|
|
145
|
+
/** Unix timestamp when current period ends */
|
|
146
|
+
currentPeriodEnd: number | null;
|
|
147
|
+
/** Whether subscription will cancel at period end */
|
|
148
|
+
cancelAtPeriodEnd: boolean | null;
|
|
149
|
+
/** Unix timestamp when trial ends (if applicable) */
|
|
150
|
+
trialEndsAt: number | null;
|
|
151
|
+
};
|
|
152
|
+
/** Authentication result from verifyToken/authenticate */
|
|
153
|
+
type AuthResult = {
|
|
154
|
+
valid: boolean;
|
|
155
|
+
user: {
|
|
156
|
+
id: string;
|
|
157
|
+
roles: string[];
|
|
158
|
+
/** Active organization ID */
|
|
159
|
+
activeOrgId: string;
|
|
160
|
+
/** User's role in the active organization ("owner" | "member") */
|
|
161
|
+
orgRole: string;
|
|
162
|
+
subscription: SubscriptionInfo;
|
|
163
|
+
} | null;
|
|
164
|
+
claims: DomainEndUserClaims | null;
|
|
165
|
+
error?: string;
|
|
166
|
+
};
|
|
167
|
+
/** Request-like object for extractToken/authenticate */
|
|
168
|
+
type RequestLike = {
|
|
169
|
+
headers?: {
|
|
170
|
+
authorization?: string;
|
|
171
|
+
cookie?: string;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
/** Response from GET /auth/token endpoint */
|
|
175
|
+
type TokenResponse = {
|
|
176
|
+
/** The JWT access token */
|
|
177
|
+
accessToken: string;
|
|
178
|
+
/** Token expiration time in seconds */
|
|
179
|
+
expiresIn: number;
|
|
180
|
+
/** Token type (always "Bearer") */
|
|
181
|
+
tokenType: string;
|
|
182
|
+
};
|
|
183
|
+
/** A single feature attached to a subscription plan */
|
|
184
|
+
type PlanFeature = {
|
|
185
|
+
code: string;
|
|
186
|
+
name: string;
|
|
187
|
+
featureType: "boolean" | "numeric";
|
|
188
|
+
numericValue: number | null;
|
|
189
|
+
unitLabel: string | null;
|
|
190
|
+
};
|
|
191
|
+
/** Plan type determines how a user subscribes */
|
|
192
|
+
type PlanType = "self_service" | "sales";
|
|
193
|
+
/** Subscription plan available for purchase */
|
|
194
|
+
type SubscriptionPlan = {
|
|
195
|
+
id: string;
|
|
196
|
+
code: string;
|
|
197
|
+
name: string;
|
|
198
|
+
description: string | null;
|
|
199
|
+
priceCents: number;
|
|
200
|
+
currency: string;
|
|
201
|
+
interval: "monthly" | "yearly" | "custom";
|
|
202
|
+
intervalCount: number;
|
|
203
|
+
trialDays: number;
|
|
204
|
+
features: PlanFeature[];
|
|
205
|
+
displayOrder: number;
|
|
206
|
+
creditsAmount: number;
|
|
207
|
+
planType: PlanType;
|
|
208
|
+
contactUrl: string | null;
|
|
209
|
+
};
|
|
210
|
+
/** Current subscription details */
|
|
211
|
+
type Subscription = {
|
|
212
|
+
id: string | null;
|
|
213
|
+
planCode: string | null;
|
|
214
|
+
planName: string | null;
|
|
215
|
+
status: SubscriptionStatus;
|
|
216
|
+
currentPeriodEnd: number | null;
|
|
217
|
+
trialEnd: number | null;
|
|
218
|
+
cancelAtPeriodEnd: boolean | null;
|
|
219
|
+
};
|
|
220
|
+
/** Checkout session response */
|
|
221
|
+
type CheckoutSession = {
|
|
222
|
+
checkoutUrl: string;
|
|
223
|
+
};
|
|
224
|
+
/** A single balance transaction record */
|
|
225
|
+
type BalanceTransaction = {
|
|
226
|
+
id: string;
|
|
227
|
+
amountDelta: number;
|
|
228
|
+
reason: Record<string, unknown>;
|
|
229
|
+
balanceAfter: number;
|
|
230
|
+
createdAt: string;
|
|
231
|
+
};
|
|
232
|
+
/** Options for charging a user's balance */
|
|
233
|
+
type ChargeOptions = {
|
|
234
|
+
amount: number;
|
|
235
|
+
requestUuid: string;
|
|
236
|
+
note?: string;
|
|
237
|
+
};
|
|
238
|
+
/** Options for depositing to a user's balance */
|
|
239
|
+
type DepositOptions = {
|
|
240
|
+
amount: number;
|
|
241
|
+
requestUuid: string;
|
|
242
|
+
note?: string;
|
|
243
|
+
};
|
|
244
|
+
/** Pagination options for transaction queries */
|
|
245
|
+
type TransactionsPaginationOptions = {
|
|
246
|
+
limit?: number;
|
|
247
|
+
offset?: number;
|
|
248
|
+
};
|
|
249
|
+
/** Symbol position for display formatting */
|
|
250
|
+
type SymbolPosition = "left" | "right";
|
|
251
|
+
/** Domain credits configuration (public subset) */
|
|
252
|
+
type CreditsConfig = {
|
|
253
|
+
creditsEnabled: boolean;
|
|
254
|
+
creditsPerDollar: number;
|
|
255
|
+
displayName: string;
|
|
256
|
+
displaySymbol: string | null;
|
|
257
|
+
displaySymbolPosition: SymbolPosition;
|
|
258
|
+
displayDecimals: number;
|
|
259
|
+
minPurchaseCents: number;
|
|
260
|
+
maxPurchaseCents: number;
|
|
261
|
+
manualTopUpAvailable: boolean;
|
|
262
|
+
autoTopUpAvailable: boolean;
|
|
263
|
+
overdrawEnabled: boolean;
|
|
264
|
+
};
|
|
265
|
+
/** A stored payment method */
|
|
266
|
+
type PaymentMethod = {
|
|
267
|
+
id: string;
|
|
268
|
+
provider: string;
|
|
269
|
+
methodType: string;
|
|
270
|
+
cardBrand: string | null;
|
|
271
|
+
cardLast4: string | null;
|
|
272
|
+
cardExpMonth: number | null;
|
|
273
|
+
cardExpYear: number | null;
|
|
274
|
+
priority: number;
|
|
275
|
+
createdAt: number;
|
|
276
|
+
};
|
|
277
|
+
/** Result of creating a SetupIntent for Stripe.js */
|
|
278
|
+
type SetupIntentResult = {
|
|
279
|
+
clientSecret: string;
|
|
280
|
+
setupIntentId: string;
|
|
281
|
+
};
|
|
282
|
+
/** Options for purchasing credits */
|
|
283
|
+
type PurchaseCreditsOptions = {
|
|
284
|
+
amountCents: number;
|
|
285
|
+
paymentMethodId: string;
|
|
286
|
+
idempotencyKey: string;
|
|
287
|
+
};
|
|
288
|
+
/** Result of a credit purchase */
|
|
289
|
+
type CreditPurchaseResult = {
|
|
290
|
+
creditsPurchased: number;
|
|
291
|
+
newBalance: number;
|
|
292
|
+
paymentIntentId: string;
|
|
293
|
+
};
|
|
294
|
+
/** Auto top-up configuration and status */
|
|
295
|
+
type AutoTopUpStatus = {
|
|
296
|
+
enabled: boolean;
|
|
297
|
+
thresholdCents: number;
|
|
298
|
+
purchaseAmountCents: number;
|
|
299
|
+
status: string;
|
|
300
|
+
lastFailureReason?: string;
|
|
301
|
+
retriesRemaining?: number;
|
|
302
|
+
nextRetryAt?: string;
|
|
303
|
+
};
|
|
304
|
+
/** Options for updating auto top-up configuration */
|
|
305
|
+
type UpdateAutoTopUpOptions = {
|
|
306
|
+
enabled: boolean;
|
|
307
|
+
thresholdCents: number;
|
|
308
|
+
purchaseAmountCents: number;
|
|
309
|
+
};
|
|
310
|
+
/** Public domain configuration (from GET /config) */
|
|
311
|
+
type DomainConfig = {
|
|
312
|
+
domain: string;
|
|
313
|
+
authMethods: {
|
|
314
|
+
magicLink: boolean;
|
|
315
|
+
googleOauth: boolean;
|
|
316
|
+
twitterOauth: boolean;
|
|
317
|
+
};
|
|
318
|
+
redirectUrl: string | null;
|
|
319
|
+
headlessEnabled: boolean;
|
|
320
|
+
};
|
|
321
|
+
/** Options for requesting a magic link */
|
|
322
|
+
type RequestMagicLinkOptions = {
|
|
323
|
+
email: string;
|
|
324
|
+
callbackUrl?: string;
|
|
325
|
+
};
|
|
326
|
+
/** Options for verifying a magic link */
|
|
327
|
+
type VerifyMagicLinkOptions = {
|
|
328
|
+
token: string;
|
|
329
|
+
};
|
|
330
|
+
/** Result of verifying a magic link */
|
|
331
|
+
type MagicLinkVerifyResult = {
|
|
332
|
+
success: boolean;
|
|
333
|
+
redirectUrl: string | null;
|
|
334
|
+
endUserId: string | null;
|
|
335
|
+
email: string | null;
|
|
336
|
+
waitlistPosition: number | null;
|
|
337
|
+
};
|
|
338
|
+
/** Result of starting Google OAuth */
|
|
339
|
+
type GoogleOAuthStartResult = {
|
|
340
|
+
authUrl: string;
|
|
341
|
+
state: string;
|
|
342
|
+
};
|
|
343
|
+
/** Result of starting X (Twitter) OAuth */
|
|
344
|
+
type TwitterOAuthStartResult = {
|
|
345
|
+
authUrl: string;
|
|
346
|
+
state: string;
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
export type { AutoTopUpStatus as A, BalanceTransaction as B, CheckoutSession as C, DomainConfig as D, GoogleOAuthStartResult as G, MagicLinkVerifyResult as M, Organization as O, PaymentMethod as P, ReauthConfig as R, SubscriptionPlan as S, TokenResponse as T, UpdateAutoTopUpOptions as U, VerifyMagicLinkOptions as V, ReauthSession as a, RequestMagicLinkOptions as b, TwitterOAuthStartResult as c, Subscription as d, TransactionsPaginationOptions as e, CreditsConfig as f, SetupIntentResult as g, PurchaseCreditsOptions as h, CreditPurchaseResult as i, OrgMember as j, OrgRole as k, SwitchOrgResult as l, OrgInvitation as m, OrgInviteLink as n, User as o, UserDetails as p, ReauthServerConfig as q, AuthResult as r, RequestLike as s, DomainEndUserClaims as t, SubscriptionInfo as u, SubscriptionStatus as v, PlanFeature as w, ChargeOptions as x, DepositOptions as y, SymbolPosition as z };
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/** Response from GET /api/public/auth/session */
|
|
2
|
+
type ReauthSession = {
|
|
3
|
+
valid: boolean;
|
|
4
|
+
end_user_id: string | null;
|
|
5
|
+
email: string | null;
|
|
6
|
+
roles: string[] | null;
|
|
7
|
+
/** Active organization ID */
|
|
8
|
+
active_org_id: string | null;
|
|
9
|
+
/** User's role in the active organization ("owner" | "member") */
|
|
10
|
+
org_role: string | null;
|
|
11
|
+
waitlist_position: number | null;
|
|
12
|
+
/** Whether the user has linked their Google account */
|
|
13
|
+
google_linked: boolean | null;
|
|
14
|
+
/** Whether the user has linked their X (Twitter) account */
|
|
15
|
+
twitter_linked: boolean | null;
|
|
16
|
+
error: string | null;
|
|
17
|
+
/** Error code (e.g., "ACCOUNT_SUSPENDED", "SESSION_VERIFICATION_FAILED") */
|
|
18
|
+
error_code: string | null;
|
|
19
|
+
/** Subscription information (if billing is configured) */
|
|
20
|
+
subscription?: {
|
|
21
|
+
status: string;
|
|
22
|
+
plan_code: string | null;
|
|
23
|
+
plan_name: string | null;
|
|
24
|
+
current_period_end: number | null;
|
|
25
|
+
cancel_at_period_end: boolean | null;
|
|
26
|
+
trial_ends_at: number | null;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
/** Authenticated user object (basic) */
|
|
30
|
+
type User = {
|
|
31
|
+
id: string;
|
|
32
|
+
email: string;
|
|
33
|
+
roles: string[];
|
|
34
|
+
/** Active organization ID */
|
|
35
|
+
activeOrgId: string;
|
|
36
|
+
/** User's role in the active organization ("owner" | "member") */
|
|
37
|
+
orgRole: string;
|
|
38
|
+
};
|
|
39
|
+
/** Full user details (from Developer API) */
|
|
40
|
+
type UserDetails = {
|
|
41
|
+
id: string;
|
|
42
|
+
email: string;
|
|
43
|
+
roles: string[];
|
|
44
|
+
emailVerifiedAt: string | null;
|
|
45
|
+
lastLoginAt: string | null;
|
|
46
|
+
isFrozen: boolean;
|
|
47
|
+
isWhitelisted: boolean;
|
|
48
|
+
createdAt: string | null;
|
|
49
|
+
};
|
|
50
|
+
/** JWT claims for domain end-user tokens */
|
|
51
|
+
type DomainEndUserClaims = {
|
|
52
|
+
/** User ID (subject) */
|
|
53
|
+
sub: string;
|
|
54
|
+
/** Domain ID */
|
|
55
|
+
domain_id: string;
|
|
56
|
+
/** Root domain (e.g., "example.com") */
|
|
57
|
+
domain: string;
|
|
58
|
+
/** Active organization ID */
|
|
59
|
+
active_org_id: string;
|
|
60
|
+
/** User's role in the active organization ("owner" | "member") */
|
|
61
|
+
org_role: string;
|
|
62
|
+
/** User roles */
|
|
63
|
+
roles: string[];
|
|
64
|
+
/** Subscription information */
|
|
65
|
+
subscription: {
|
|
66
|
+
status: string;
|
|
67
|
+
plan_code: string | null;
|
|
68
|
+
plan_name: string | null;
|
|
69
|
+
current_period_end: number | null;
|
|
70
|
+
cancel_at_period_end: boolean | null;
|
|
71
|
+
trial_ends_at: number | null;
|
|
72
|
+
};
|
|
73
|
+
/** Token expiration (Unix timestamp) */
|
|
74
|
+
exp: number;
|
|
75
|
+
/** Token issued at (Unix timestamp) */
|
|
76
|
+
iat: number;
|
|
77
|
+
};
|
|
78
|
+
/** Configuration for browser-side reauth client */
|
|
79
|
+
type ReauthConfig = {
|
|
80
|
+
/** Your verified domain (e.g., "yourdomain.com") */
|
|
81
|
+
domain: string;
|
|
82
|
+
/** Request timeout in milliseconds. Defaults to 10 seconds if not specified. */
|
|
83
|
+
timeout?: number;
|
|
84
|
+
};
|
|
85
|
+
/** Configuration for server-side reauth client */
|
|
86
|
+
type ReauthServerConfig = ReauthConfig & {
|
|
87
|
+
/** API key for server-to-server authentication (required, e.g., "sk_live_...") */
|
|
88
|
+
apiKey: string;
|
|
89
|
+
};
|
|
90
|
+
/** Role within an organization */
|
|
91
|
+
type OrgRole = "owner" | "member";
|
|
92
|
+
/** Organization details */
|
|
93
|
+
type Organization = {
|
|
94
|
+
id: string;
|
|
95
|
+
name: string;
|
|
96
|
+
isPersonal: boolean;
|
|
97
|
+
createdAt: string | null;
|
|
98
|
+
};
|
|
99
|
+
/** Organization member */
|
|
100
|
+
type OrgMember = {
|
|
101
|
+
id: string;
|
|
102
|
+
orgId: string;
|
|
103
|
+
endUserId: string;
|
|
104
|
+
role: OrgRole;
|
|
105
|
+
joinedAt: string | null;
|
|
106
|
+
};
|
|
107
|
+
/** Email invitation to an organization */
|
|
108
|
+
type OrgInvitation = {
|
|
109
|
+
id: string;
|
|
110
|
+
orgId: string;
|
|
111
|
+
email: string;
|
|
112
|
+
token: string;
|
|
113
|
+
role: OrgRole;
|
|
114
|
+
status: "pending" | "accepted";
|
|
115
|
+
expiresAt: string;
|
|
116
|
+
acceptedAt: string | null;
|
|
117
|
+
createdAt: string | null;
|
|
118
|
+
};
|
|
119
|
+
/** Shareable invite link for an organization */
|
|
120
|
+
type OrgInviteLink = {
|
|
121
|
+
id: string;
|
|
122
|
+
orgId: string;
|
|
123
|
+
token: string;
|
|
124
|
+
role: OrgRole;
|
|
125
|
+
isActive: boolean;
|
|
126
|
+
expiresAt: string;
|
|
127
|
+
createdAt: string | null;
|
|
128
|
+
};
|
|
129
|
+
/** Result of accepting an invite or switching org */
|
|
130
|
+
type SwitchOrgResult = {
|
|
131
|
+
activeOrgId: string;
|
|
132
|
+
orgRole: OrgRole;
|
|
133
|
+
subscription: SubscriptionInfo;
|
|
134
|
+
};
|
|
135
|
+
/** Subscription status values */
|
|
136
|
+
type SubscriptionStatus = "active" | "past_due" | "canceled" | "trialing" | "incomplete" | "incomplete_expired" | "unpaid" | "paused" | "none";
|
|
137
|
+
/** Subscription info included in JWT claims */
|
|
138
|
+
type SubscriptionInfo = {
|
|
139
|
+
/** Current subscription status */
|
|
140
|
+
status: SubscriptionStatus;
|
|
141
|
+
/** Machine-readable plan identifier (e.g., "pro") */
|
|
142
|
+
planCode: string | null;
|
|
143
|
+
/** Human-readable plan name (e.g., "Pro Plan") */
|
|
144
|
+
planName: string | null;
|
|
145
|
+
/** Unix timestamp when current period ends */
|
|
146
|
+
currentPeriodEnd: number | null;
|
|
147
|
+
/** Whether subscription will cancel at period end */
|
|
148
|
+
cancelAtPeriodEnd: boolean | null;
|
|
149
|
+
/** Unix timestamp when trial ends (if applicable) */
|
|
150
|
+
trialEndsAt: number | null;
|
|
151
|
+
};
|
|
152
|
+
/** Authentication result from verifyToken/authenticate */
|
|
153
|
+
type AuthResult = {
|
|
154
|
+
valid: boolean;
|
|
155
|
+
user: {
|
|
156
|
+
id: string;
|
|
157
|
+
roles: string[];
|
|
158
|
+
/** Active organization ID */
|
|
159
|
+
activeOrgId: string;
|
|
160
|
+
/** User's role in the active organization ("owner" | "member") */
|
|
161
|
+
orgRole: string;
|
|
162
|
+
subscription: SubscriptionInfo;
|
|
163
|
+
} | null;
|
|
164
|
+
claims: DomainEndUserClaims | null;
|
|
165
|
+
error?: string;
|
|
166
|
+
};
|
|
167
|
+
/** Request-like object for extractToken/authenticate */
|
|
168
|
+
type RequestLike = {
|
|
169
|
+
headers?: {
|
|
170
|
+
authorization?: string;
|
|
171
|
+
cookie?: string;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
/** Response from GET /auth/token endpoint */
|
|
175
|
+
type TokenResponse = {
|
|
176
|
+
/** The JWT access token */
|
|
177
|
+
accessToken: string;
|
|
178
|
+
/** Token expiration time in seconds */
|
|
179
|
+
expiresIn: number;
|
|
180
|
+
/** Token type (always "Bearer") */
|
|
181
|
+
tokenType: string;
|
|
182
|
+
};
|
|
183
|
+
/** A single feature attached to a subscription plan */
|
|
184
|
+
type PlanFeature = {
|
|
185
|
+
code: string;
|
|
186
|
+
name: string;
|
|
187
|
+
featureType: "boolean" | "numeric";
|
|
188
|
+
numericValue: number | null;
|
|
189
|
+
unitLabel: string | null;
|
|
190
|
+
};
|
|
191
|
+
/** Plan type determines how a user subscribes */
|
|
192
|
+
type PlanType = "self_service" | "sales";
|
|
193
|
+
/** Subscription plan available for purchase */
|
|
194
|
+
type SubscriptionPlan = {
|
|
195
|
+
id: string;
|
|
196
|
+
code: string;
|
|
197
|
+
name: string;
|
|
198
|
+
description: string | null;
|
|
199
|
+
priceCents: number;
|
|
200
|
+
currency: string;
|
|
201
|
+
interval: "monthly" | "yearly" | "custom";
|
|
202
|
+
intervalCount: number;
|
|
203
|
+
trialDays: number;
|
|
204
|
+
features: PlanFeature[];
|
|
205
|
+
displayOrder: number;
|
|
206
|
+
creditsAmount: number;
|
|
207
|
+
planType: PlanType;
|
|
208
|
+
contactUrl: string | null;
|
|
209
|
+
};
|
|
210
|
+
/** Current subscription details */
|
|
211
|
+
type Subscription = {
|
|
212
|
+
id: string | null;
|
|
213
|
+
planCode: string | null;
|
|
214
|
+
planName: string | null;
|
|
215
|
+
status: SubscriptionStatus;
|
|
216
|
+
currentPeriodEnd: number | null;
|
|
217
|
+
trialEnd: number | null;
|
|
218
|
+
cancelAtPeriodEnd: boolean | null;
|
|
219
|
+
};
|
|
220
|
+
/** Checkout session response */
|
|
221
|
+
type CheckoutSession = {
|
|
222
|
+
checkoutUrl: string;
|
|
223
|
+
};
|
|
224
|
+
/** A single balance transaction record */
|
|
225
|
+
type BalanceTransaction = {
|
|
226
|
+
id: string;
|
|
227
|
+
amountDelta: number;
|
|
228
|
+
reason: Record<string, unknown>;
|
|
229
|
+
balanceAfter: number;
|
|
230
|
+
createdAt: string;
|
|
231
|
+
};
|
|
232
|
+
/** Options for charging a user's balance */
|
|
233
|
+
type ChargeOptions = {
|
|
234
|
+
amount: number;
|
|
235
|
+
requestUuid: string;
|
|
236
|
+
note?: string;
|
|
237
|
+
};
|
|
238
|
+
/** Options for depositing to a user's balance */
|
|
239
|
+
type DepositOptions = {
|
|
240
|
+
amount: number;
|
|
241
|
+
requestUuid: string;
|
|
242
|
+
note?: string;
|
|
243
|
+
};
|
|
244
|
+
/** Pagination options for transaction queries */
|
|
245
|
+
type TransactionsPaginationOptions = {
|
|
246
|
+
limit?: number;
|
|
247
|
+
offset?: number;
|
|
248
|
+
};
|
|
249
|
+
/** Symbol position for display formatting */
|
|
250
|
+
type SymbolPosition = "left" | "right";
|
|
251
|
+
/** Domain credits configuration (public subset) */
|
|
252
|
+
type CreditsConfig = {
|
|
253
|
+
creditsEnabled: boolean;
|
|
254
|
+
creditsPerDollar: number;
|
|
255
|
+
displayName: string;
|
|
256
|
+
displaySymbol: string | null;
|
|
257
|
+
displaySymbolPosition: SymbolPosition;
|
|
258
|
+
displayDecimals: number;
|
|
259
|
+
minPurchaseCents: number;
|
|
260
|
+
maxPurchaseCents: number;
|
|
261
|
+
manualTopUpAvailable: boolean;
|
|
262
|
+
autoTopUpAvailable: boolean;
|
|
263
|
+
overdrawEnabled: boolean;
|
|
264
|
+
};
|
|
265
|
+
/** A stored payment method */
|
|
266
|
+
type PaymentMethod = {
|
|
267
|
+
id: string;
|
|
268
|
+
provider: string;
|
|
269
|
+
methodType: string;
|
|
270
|
+
cardBrand: string | null;
|
|
271
|
+
cardLast4: string | null;
|
|
272
|
+
cardExpMonth: number | null;
|
|
273
|
+
cardExpYear: number | null;
|
|
274
|
+
priority: number;
|
|
275
|
+
createdAt: number;
|
|
276
|
+
};
|
|
277
|
+
/** Result of creating a SetupIntent for Stripe.js */
|
|
278
|
+
type SetupIntentResult = {
|
|
279
|
+
clientSecret: string;
|
|
280
|
+
setupIntentId: string;
|
|
281
|
+
};
|
|
282
|
+
/** Options for purchasing credits */
|
|
283
|
+
type PurchaseCreditsOptions = {
|
|
284
|
+
amountCents: number;
|
|
285
|
+
paymentMethodId: string;
|
|
286
|
+
idempotencyKey: string;
|
|
287
|
+
};
|
|
288
|
+
/** Result of a credit purchase */
|
|
289
|
+
type CreditPurchaseResult = {
|
|
290
|
+
creditsPurchased: number;
|
|
291
|
+
newBalance: number;
|
|
292
|
+
paymentIntentId: string;
|
|
293
|
+
};
|
|
294
|
+
/** Auto top-up configuration and status */
|
|
295
|
+
type AutoTopUpStatus = {
|
|
296
|
+
enabled: boolean;
|
|
297
|
+
thresholdCents: number;
|
|
298
|
+
purchaseAmountCents: number;
|
|
299
|
+
status: string;
|
|
300
|
+
lastFailureReason?: string;
|
|
301
|
+
retriesRemaining?: number;
|
|
302
|
+
nextRetryAt?: string;
|
|
303
|
+
};
|
|
304
|
+
/** Options for updating auto top-up configuration */
|
|
305
|
+
type UpdateAutoTopUpOptions = {
|
|
306
|
+
enabled: boolean;
|
|
307
|
+
thresholdCents: number;
|
|
308
|
+
purchaseAmountCents: number;
|
|
309
|
+
};
|
|
310
|
+
/** Public domain configuration (from GET /config) */
|
|
311
|
+
type DomainConfig = {
|
|
312
|
+
domain: string;
|
|
313
|
+
authMethods: {
|
|
314
|
+
magicLink: boolean;
|
|
315
|
+
googleOauth: boolean;
|
|
316
|
+
twitterOauth: boolean;
|
|
317
|
+
};
|
|
318
|
+
redirectUrl: string | null;
|
|
319
|
+
headlessEnabled: boolean;
|
|
320
|
+
};
|
|
321
|
+
/** Options for requesting a magic link */
|
|
322
|
+
type RequestMagicLinkOptions = {
|
|
323
|
+
email: string;
|
|
324
|
+
callbackUrl?: string;
|
|
325
|
+
};
|
|
326
|
+
/** Options for verifying a magic link */
|
|
327
|
+
type VerifyMagicLinkOptions = {
|
|
328
|
+
token: string;
|
|
329
|
+
};
|
|
330
|
+
/** Result of verifying a magic link */
|
|
331
|
+
type MagicLinkVerifyResult = {
|
|
332
|
+
success: boolean;
|
|
333
|
+
redirectUrl: string | null;
|
|
334
|
+
endUserId: string | null;
|
|
335
|
+
email: string | null;
|
|
336
|
+
waitlistPosition: number | null;
|
|
337
|
+
};
|
|
338
|
+
/** Result of starting Google OAuth */
|
|
339
|
+
type GoogleOAuthStartResult = {
|
|
340
|
+
authUrl: string;
|
|
341
|
+
state: string;
|
|
342
|
+
};
|
|
343
|
+
/** Result of starting X (Twitter) OAuth */
|
|
344
|
+
type TwitterOAuthStartResult = {
|
|
345
|
+
authUrl: string;
|
|
346
|
+
state: string;
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
export type { AutoTopUpStatus as A, BalanceTransaction as B, CheckoutSession as C, DomainConfig as D, GoogleOAuthStartResult as G, MagicLinkVerifyResult as M, Organization as O, PaymentMethod as P, ReauthConfig as R, SubscriptionPlan as S, TokenResponse as T, UpdateAutoTopUpOptions as U, VerifyMagicLinkOptions as V, ReauthSession as a, RequestMagicLinkOptions as b, TwitterOAuthStartResult as c, Subscription as d, TransactionsPaginationOptions as e, CreditsConfig as f, SetupIntentResult as g, PurchaseCreditsOptions as h, CreditPurchaseResult as i, OrgMember as j, OrgRole as k, SwitchOrgResult as l, OrgInvitation as m, OrgInviteLink as n, User as o, UserDetails as p, ReauthServerConfig as q, AuthResult as r, RequestLike as s, DomainEndUserClaims as t, SubscriptionInfo as u, SubscriptionStatus as v, PlanFeature as w, ChargeOptions as x, DepositOptions as y, SymbolPosition as z };
|