@reauth-dev/sdk 0.2.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/index.d.mts +182 -4
- package/dist/index.d.ts +182 -4
- package/dist/index.js +706 -0
- package/dist/index.mjs +1 -1
- package/dist/react/index.d.mts +62 -2
- package/dist/react/index.d.ts +62 -2
- package/dist/react/index.js +848 -11
- package/dist/react/index.mjs +134 -4
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +4 -0
- package/dist/server.mjs +4 -0
- package/dist/{types-BqZzje-y.d.mts → types-DKUKhCNE.d.mts} +165 -3
- package/dist/{types-BqZzje-y.d.ts → types-DKUKhCNE.d.ts} +165 -3
- package/package.json +1 -1
- package/dist/chunk-DMNMTW2C.mjs +0 -336
package/dist/react/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createReauthClient
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-5LFJ5PXQ.mjs";
|
|
4
4
|
import "../chunk-EY5LQCDG.mjs";
|
|
5
5
|
|
|
6
6
|
// src/react/useAuth.ts
|
|
@@ -44,7 +44,9 @@ function useAuth(config) {
|
|
|
44
44
|
user: {
|
|
45
45
|
id: session.end_user_id,
|
|
46
46
|
email: session.email,
|
|
47
|
-
roles: session.roles || []
|
|
47
|
+
roles: session.roles || [],
|
|
48
|
+
activeOrgId: session.active_org_id || "",
|
|
49
|
+
orgRole: session.org_role || ""
|
|
48
50
|
},
|
|
49
51
|
loading: false,
|
|
50
52
|
error: null,
|
|
@@ -58,7 +60,9 @@ function useAuth(config) {
|
|
|
58
60
|
user: {
|
|
59
61
|
id: session.end_user_id,
|
|
60
62
|
email: session.email,
|
|
61
|
-
roles: session.roles || []
|
|
63
|
+
roles: session.roles || [],
|
|
64
|
+
activeOrgId: session.active_org_id || "",
|
|
65
|
+
orgRole: session.org_role || ""
|
|
62
66
|
},
|
|
63
67
|
loading: false,
|
|
64
68
|
error: null,
|
|
@@ -114,6 +118,131 @@ function useAuth(config) {
|
|
|
114
118
|
};
|
|
115
119
|
}
|
|
116
120
|
|
|
121
|
+
// src/react/useHeadlessAuth.ts
|
|
122
|
+
import { useState as useState2, useCallback as useCallback2, useMemo as useMemo2 } from "react";
|
|
123
|
+
function useHeadlessAuth(options) {
|
|
124
|
+
const client = useMemo2(
|
|
125
|
+
() => createReauthClient({ domain: options.domain, timeout: options.timeout }),
|
|
126
|
+
[options.domain, options.timeout]
|
|
127
|
+
);
|
|
128
|
+
const [state, setState] = useState2({
|
|
129
|
+
loading: false,
|
|
130
|
+
error: null,
|
|
131
|
+
step: "idle",
|
|
132
|
+
config: null,
|
|
133
|
+
verifyResult: null
|
|
134
|
+
});
|
|
135
|
+
const getConfig = useCallback2(async () => {
|
|
136
|
+
setState((s) => ({ ...s, loading: true, error: null }));
|
|
137
|
+
try {
|
|
138
|
+
const config = await client.getConfig();
|
|
139
|
+
setState((s) => ({ ...s, loading: false, config }));
|
|
140
|
+
return config;
|
|
141
|
+
} catch (err) {
|
|
142
|
+
const message = err instanceof Error ? err.message : "Failed to get config";
|
|
143
|
+
setState((s) => ({ ...s, loading: false, error: message }));
|
|
144
|
+
throw err;
|
|
145
|
+
}
|
|
146
|
+
}, [client]);
|
|
147
|
+
const requestMagicLink = useCallback2(
|
|
148
|
+
async (email) => {
|
|
149
|
+
setState((s) => ({ ...s, loading: true, error: null }));
|
|
150
|
+
try {
|
|
151
|
+
await client.requestMagicLink({
|
|
152
|
+
email,
|
|
153
|
+
callbackUrl: options.callbackUrl
|
|
154
|
+
});
|
|
155
|
+
setState((s) => ({
|
|
156
|
+
...s,
|
|
157
|
+
loading: false,
|
|
158
|
+
step: "magic_link_sent"
|
|
159
|
+
}));
|
|
160
|
+
} catch (err) {
|
|
161
|
+
const message = err instanceof Error ? err.message : "Failed to send magic link";
|
|
162
|
+
setState((s) => ({ ...s, loading: false, error: message }));
|
|
163
|
+
throw err;
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
[client, options.callbackUrl]
|
|
167
|
+
);
|
|
168
|
+
const verifyMagicLink = useCallback2(
|
|
169
|
+
async (token) => {
|
|
170
|
+
setState((s) => ({ ...s, loading: true, error: null }));
|
|
171
|
+
try {
|
|
172
|
+
const result = await client.verifyMagicLink({ token });
|
|
173
|
+
setState((s) => ({
|
|
174
|
+
...s,
|
|
175
|
+
loading: false,
|
|
176
|
+
step: "completed",
|
|
177
|
+
verifyResult: result
|
|
178
|
+
}));
|
|
179
|
+
return result;
|
|
180
|
+
} catch (err) {
|
|
181
|
+
const message = err instanceof Error ? err.message : "Failed to verify magic link";
|
|
182
|
+
setState((s) => ({ ...s, loading: false, error: message }));
|
|
183
|
+
throw err;
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
[client]
|
|
187
|
+
);
|
|
188
|
+
const startGoogleOAuth = useCallback2(async () => {
|
|
189
|
+
setState((s) => ({ ...s, loading: true, error: null }));
|
|
190
|
+
try {
|
|
191
|
+
const result = await client.startGoogleOAuth();
|
|
192
|
+
setState((s) => ({
|
|
193
|
+
...s,
|
|
194
|
+
loading: false,
|
|
195
|
+
step: "google_started"
|
|
196
|
+
}));
|
|
197
|
+
if (typeof window !== "undefined") {
|
|
198
|
+
window.location.href = result.authUrl;
|
|
199
|
+
}
|
|
200
|
+
return result;
|
|
201
|
+
} catch (err) {
|
|
202
|
+
const message = err instanceof Error ? err.message : "Failed to start Google OAuth";
|
|
203
|
+
setState((s) => ({ ...s, loading: false, error: message }));
|
|
204
|
+
throw err;
|
|
205
|
+
}
|
|
206
|
+
}, [client]);
|
|
207
|
+
const startTwitterOAuth = useCallback2(async () => {
|
|
208
|
+
setState((s) => ({ ...s, loading: true, error: null }));
|
|
209
|
+
try {
|
|
210
|
+
const result = await client.startTwitterOAuth();
|
|
211
|
+
setState((s) => ({
|
|
212
|
+
...s,
|
|
213
|
+
loading: false,
|
|
214
|
+
step: "twitter_started"
|
|
215
|
+
}));
|
|
216
|
+
if (typeof window !== "undefined") {
|
|
217
|
+
window.location.href = result.authUrl;
|
|
218
|
+
}
|
|
219
|
+
return result;
|
|
220
|
+
} catch (err) {
|
|
221
|
+
const message = err instanceof Error ? err.message : "Failed to start Twitter OAuth";
|
|
222
|
+
setState((s) => ({ ...s, loading: false, error: message }));
|
|
223
|
+
throw err;
|
|
224
|
+
}
|
|
225
|
+
}, [client]);
|
|
226
|
+
const reset = useCallback2(() => {
|
|
227
|
+
setState({
|
|
228
|
+
loading: false,
|
|
229
|
+
error: null,
|
|
230
|
+
step: "idle",
|
|
231
|
+
config: null,
|
|
232
|
+
verifyResult: null
|
|
233
|
+
});
|
|
234
|
+
}, []);
|
|
235
|
+
return {
|
|
236
|
+
...state,
|
|
237
|
+
getConfig,
|
|
238
|
+
requestMagicLink,
|
|
239
|
+
verifyMagicLink,
|
|
240
|
+
startGoogleOAuth,
|
|
241
|
+
startTwitterOAuth,
|
|
242
|
+
reset
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
117
246
|
// src/react/AuthProvider.tsx
|
|
118
247
|
import { createContext, useContext } from "react";
|
|
119
248
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -169,5 +298,6 @@ export {
|
|
|
169
298
|
AuthProvider,
|
|
170
299
|
ProtectedRoute,
|
|
171
300
|
useAuth,
|
|
172
|
-
useAuthContext
|
|
301
|
+
useAuthContext,
|
|
302
|
+
useHeadlessAuth
|
|
173
303
|
};
|
package/dist/server.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { q as ReauthServerConfig, r as AuthResult, s as RequestLike, p as UserDetails, x as ChargeOptions, y as DepositOptions, e as TransactionsPaginationOptions, B as BalanceTransaction } from './types-DKUKhCNE.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Derives a JWT signing secret from an API key using HKDF-SHA256.
|
package/dist/server.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { q as ReauthServerConfig, r as AuthResult, s as RequestLike, p as UserDetails, x as ChargeOptions, y as DepositOptions, e as TransactionsPaginationOptions, B as BalanceTransaction } from './types-DKUKhCNE.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Derives a JWT signing secret from an API key using HKDF-SHA256.
|
package/dist/server.js
CHANGED
|
@@ -67,6 +67,8 @@ function isValidClaims(payload) {
|
|
|
67
67
|
if (typeof payload.sub !== "string") return false;
|
|
68
68
|
if (typeof payload.domain_id !== "string") return false;
|
|
69
69
|
if (typeof payload.domain !== "string") return false;
|
|
70
|
+
if (typeof payload.active_org_id !== "string") return false;
|
|
71
|
+
if (typeof payload.org_role !== "string") return false;
|
|
70
72
|
if (!Array.isArray(payload.roles) || !payload.roles.every((r) => typeof r === "string")) return false;
|
|
71
73
|
const subscription = payload.subscription;
|
|
72
74
|
if (typeof subscription !== "object" || subscription === null || Array.isArray(subscription)) return false;
|
|
@@ -164,6 +166,8 @@ function createServerClient(config) {
|
|
|
164
166
|
user: {
|
|
165
167
|
id: claims.sub,
|
|
166
168
|
roles: claims.roles,
|
|
169
|
+
activeOrgId: claims.active_org_id,
|
|
170
|
+
orgRole: claims.org_role,
|
|
167
171
|
subscription: transformSubscription(claims.subscription)
|
|
168
172
|
},
|
|
169
173
|
claims
|
package/dist/server.mjs
CHANGED
|
@@ -30,6 +30,8 @@ function isValidClaims(payload) {
|
|
|
30
30
|
if (typeof payload.sub !== "string") return false;
|
|
31
31
|
if (typeof payload.domain_id !== "string") return false;
|
|
32
32
|
if (typeof payload.domain !== "string") return false;
|
|
33
|
+
if (typeof payload.active_org_id !== "string") return false;
|
|
34
|
+
if (typeof payload.org_role !== "string") return false;
|
|
33
35
|
if (!Array.isArray(payload.roles) || !payload.roles.every((r) => typeof r === "string")) return false;
|
|
34
36
|
const subscription = payload.subscription;
|
|
35
37
|
if (typeof subscription !== "object" || subscription === null || Array.isArray(subscription)) return false;
|
|
@@ -127,6 +129,8 @@ function createServerClient(config) {
|
|
|
127
129
|
user: {
|
|
128
130
|
id: claims.sub,
|
|
129
131
|
roles: claims.roles,
|
|
132
|
+
activeOrgId: claims.active_org_id,
|
|
133
|
+
orgRole: claims.org_role,
|
|
130
134
|
subscription: transformSubscription(claims.subscription)
|
|
131
135
|
},
|
|
132
136
|
claims
|
|
@@ -4,9 +4,15 @@ type ReauthSession = {
|
|
|
4
4
|
end_user_id: string | null;
|
|
5
5
|
email: string | null;
|
|
6
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;
|
|
7
11
|
waitlist_position: number | null;
|
|
8
12
|
/** Whether the user has linked their Google account */
|
|
9
13
|
google_linked: boolean | null;
|
|
14
|
+
/** Whether the user has linked their X (Twitter) account */
|
|
15
|
+
twitter_linked: boolean | null;
|
|
10
16
|
error: string | null;
|
|
11
17
|
/** Error code (e.g., "ACCOUNT_SUSPENDED", "SESSION_VERIFICATION_FAILED") */
|
|
12
18
|
error_code: string | null;
|
|
@@ -25,6 +31,10 @@ type User = {
|
|
|
25
31
|
id: string;
|
|
26
32
|
email: string;
|
|
27
33
|
roles: string[];
|
|
34
|
+
/** Active organization ID */
|
|
35
|
+
activeOrgId: string;
|
|
36
|
+
/** User's role in the active organization ("owner" | "member") */
|
|
37
|
+
orgRole: string;
|
|
28
38
|
};
|
|
29
39
|
/** Full user details (from Developer API) */
|
|
30
40
|
type UserDetails = {
|
|
@@ -45,6 +55,10 @@ type DomainEndUserClaims = {
|
|
|
45
55
|
domain_id: string;
|
|
46
56
|
/** Root domain (e.g., "example.com") */
|
|
47
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;
|
|
48
62
|
/** User roles */
|
|
49
63
|
roles: string[];
|
|
50
64
|
/** Subscription information */
|
|
@@ -73,6 +87,51 @@ type ReauthServerConfig = ReauthConfig & {
|
|
|
73
87
|
/** API key for server-to-server authentication (required, e.g., "sk_live_...") */
|
|
74
88
|
apiKey: string;
|
|
75
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
|
+
};
|
|
76
135
|
/** Subscription status values */
|
|
77
136
|
type SubscriptionStatus = "active" | "past_due" | "canceled" | "trialing" | "incomplete" | "incomplete_expired" | "unpaid" | "paused" | "none";
|
|
78
137
|
/** Subscription info included in JWT claims */
|
|
@@ -96,6 +155,10 @@ type AuthResult = {
|
|
|
96
155
|
user: {
|
|
97
156
|
id: string;
|
|
98
157
|
roles: string[];
|
|
158
|
+
/** Active organization ID */
|
|
159
|
+
activeOrgId: string;
|
|
160
|
+
/** User's role in the active organization ("owner" | "member") */
|
|
161
|
+
orgRole: string;
|
|
99
162
|
subscription: SubscriptionInfo;
|
|
100
163
|
} | null;
|
|
101
164
|
claims: DomainEndUserClaims | null;
|
|
@@ -144,8 +207,8 @@ type SubscriptionPlan = {
|
|
|
144
207
|
planType: PlanType;
|
|
145
208
|
contactUrl: string | null;
|
|
146
209
|
};
|
|
147
|
-
/**
|
|
148
|
-
type
|
|
210
|
+
/** Current subscription details */
|
|
211
|
+
type Subscription = {
|
|
149
212
|
id: string | null;
|
|
150
213
|
planCode: string | null;
|
|
151
214
|
planName: string | null;
|
|
@@ -183,5 +246,104 @@ type TransactionsPaginationOptions = {
|
|
|
183
246
|
limit?: number;
|
|
184
247
|
offset?: number;
|
|
185
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
|
+
};
|
|
186
348
|
|
|
187
|
-
export type {
|
|
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 };
|
|
@@ -4,9 +4,15 @@ type ReauthSession = {
|
|
|
4
4
|
end_user_id: string | null;
|
|
5
5
|
email: string | null;
|
|
6
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;
|
|
7
11
|
waitlist_position: number | null;
|
|
8
12
|
/** Whether the user has linked their Google account */
|
|
9
13
|
google_linked: boolean | null;
|
|
14
|
+
/** Whether the user has linked their X (Twitter) account */
|
|
15
|
+
twitter_linked: boolean | null;
|
|
10
16
|
error: string | null;
|
|
11
17
|
/** Error code (e.g., "ACCOUNT_SUSPENDED", "SESSION_VERIFICATION_FAILED") */
|
|
12
18
|
error_code: string | null;
|
|
@@ -25,6 +31,10 @@ type User = {
|
|
|
25
31
|
id: string;
|
|
26
32
|
email: string;
|
|
27
33
|
roles: string[];
|
|
34
|
+
/** Active organization ID */
|
|
35
|
+
activeOrgId: string;
|
|
36
|
+
/** User's role in the active organization ("owner" | "member") */
|
|
37
|
+
orgRole: string;
|
|
28
38
|
};
|
|
29
39
|
/** Full user details (from Developer API) */
|
|
30
40
|
type UserDetails = {
|
|
@@ -45,6 +55,10 @@ type DomainEndUserClaims = {
|
|
|
45
55
|
domain_id: string;
|
|
46
56
|
/** Root domain (e.g., "example.com") */
|
|
47
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;
|
|
48
62
|
/** User roles */
|
|
49
63
|
roles: string[];
|
|
50
64
|
/** Subscription information */
|
|
@@ -73,6 +87,51 @@ type ReauthServerConfig = ReauthConfig & {
|
|
|
73
87
|
/** API key for server-to-server authentication (required, e.g., "sk_live_...") */
|
|
74
88
|
apiKey: string;
|
|
75
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
|
+
};
|
|
76
135
|
/** Subscription status values */
|
|
77
136
|
type SubscriptionStatus = "active" | "past_due" | "canceled" | "trialing" | "incomplete" | "incomplete_expired" | "unpaid" | "paused" | "none";
|
|
78
137
|
/** Subscription info included in JWT claims */
|
|
@@ -96,6 +155,10 @@ type AuthResult = {
|
|
|
96
155
|
user: {
|
|
97
156
|
id: string;
|
|
98
157
|
roles: string[];
|
|
158
|
+
/** Active organization ID */
|
|
159
|
+
activeOrgId: string;
|
|
160
|
+
/** User's role in the active organization ("owner" | "member") */
|
|
161
|
+
orgRole: string;
|
|
99
162
|
subscription: SubscriptionInfo;
|
|
100
163
|
} | null;
|
|
101
164
|
claims: DomainEndUserClaims | null;
|
|
@@ -144,8 +207,8 @@ type SubscriptionPlan = {
|
|
|
144
207
|
planType: PlanType;
|
|
145
208
|
contactUrl: string | null;
|
|
146
209
|
};
|
|
147
|
-
/**
|
|
148
|
-
type
|
|
210
|
+
/** Current subscription details */
|
|
211
|
+
type Subscription = {
|
|
149
212
|
id: string | null;
|
|
150
213
|
planCode: string | null;
|
|
151
214
|
planName: string | null;
|
|
@@ -183,5 +246,104 @@ type TransactionsPaginationOptions = {
|
|
|
183
246
|
limit?: number;
|
|
184
247
|
offset?: number;
|
|
185
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
|
+
};
|
|
186
348
|
|
|
187
|
-
export type {
|
|
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 };
|