@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
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as ReauthConfig, a as ReauthSession, T as TokenResponse, S as SubscriptionPlan,
|
|
2
|
-
export {
|
|
1
|
+
import { R as ReauthConfig, a as ReauthSession, T as TokenResponse, D as DomainConfig, b as RequestMagicLinkOptions, V as VerifyMagicLinkOptions, M as MagicLinkVerifyResult, G as GoogleOAuthStartResult, c as TwitterOAuthStartResult, S as SubscriptionPlan, d as Subscription, C as CheckoutSession, e as TransactionsPaginationOptions, B as BalanceTransaction, f as CreditsConfig, P as PaymentMethod, g as SetupIntentResult, h as PurchaseCreditsOptions, i as CreditPurchaseResult, A as AutoTopUpStatus, U as UpdateAutoTopUpOptions, O as Organization, j as OrgMember, k as OrgRole, l as SwitchOrgResult, m as OrgInvitation, n as OrgInviteLink } from './types-DKUKhCNE.mjs';
|
|
2
|
+
export { r as AuthResult, x as ChargeOptions, y as DepositOptions, t as DomainEndUserClaims, w as PlanFeature, q as ReauthServerConfig, s as RequestLike, u as SubscriptionInfo, v as SubscriptionStatus, z as SymbolPosition, o as User, p as UserDetails } from './types-DKUKhCNE.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Create a reauth client for browser-side authentication.
|
|
@@ -32,44 +32,83 @@ declare function createReauthClient(config: ReauthConfig): {
|
|
|
32
32
|
/**
|
|
33
33
|
* Refresh the access token using the refresh token.
|
|
34
34
|
* Call this when getSession() returns valid: false but no error_code.
|
|
35
|
-
* @
|
|
35
|
+
* @throws Error on failed refresh (401) or server error
|
|
36
36
|
*/
|
|
37
|
-
refresh(): Promise<
|
|
37
|
+
refresh(): Promise<void>;
|
|
38
38
|
/**
|
|
39
39
|
* Get an access token for Bearer authentication.
|
|
40
40
|
* Use this when calling your own API that uses local token verification.
|
|
41
41
|
*
|
|
42
|
-
* @returns TokenResponse with access token, or null if not authenticated
|
|
42
|
+
* @returns TokenResponse with access token, or null if not authenticated or network unreachable
|
|
43
|
+
* @throws Error on server errors (non-401 HTTP status codes) or request timeout
|
|
43
44
|
*
|
|
44
45
|
* @example
|
|
45
46
|
* ```typescript
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
47
|
+
* try {
|
|
48
|
+
* const tokenResponse = await reauth.getToken();
|
|
49
|
+
* if (tokenResponse) {
|
|
50
|
+
* fetch('/api/data', {
|
|
51
|
+
* headers: { Authorization: `Bearer ${tokenResponse.accessToken}` }
|
|
52
|
+
* });
|
|
53
|
+
* }
|
|
54
|
+
* } catch (err) {
|
|
55
|
+
* // Server error or timeout — do not log the user out
|
|
51
56
|
* }
|
|
52
57
|
* ```
|
|
53
58
|
*/
|
|
54
59
|
getToken(): Promise<TokenResponse | null>;
|
|
55
60
|
/**
|
|
56
61
|
* Log out the user by clearing all session cookies.
|
|
62
|
+
* @throws Error on server error
|
|
57
63
|
*/
|
|
58
64
|
logout(): Promise<void>;
|
|
59
65
|
/**
|
|
60
66
|
* Delete the user's own account (self-service).
|
|
61
|
-
* @
|
|
67
|
+
* @throws Error on permission denied or server error
|
|
62
68
|
*/
|
|
63
|
-
deleteAccount(): Promise<
|
|
69
|
+
deleteAccount(): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Get the domain's public auth configuration.
|
|
72
|
+
* Returns enabled auth methods and whether headless auth is available.
|
|
73
|
+
*/
|
|
74
|
+
getConfig(): Promise<DomainConfig>;
|
|
75
|
+
/**
|
|
76
|
+
* Request a magic link email for headless authentication.
|
|
77
|
+
* When callbackUrl is provided, the email link will point to your custom URL
|
|
78
|
+
* with the token as a query parameter.
|
|
79
|
+
* @param opts Options including email and optional callbackUrl
|
|
80
|
+
*/
|
|
81
|
+
requestMagicLink(opts: RequestMagicLinkOptions): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Verify a magic link token received from the email callback URL.
|
|
84
|
+
* On success, session cookies are set automatically.
|
|
85
|
+
* @param opts Options including the token from the callback URL
|
|
86
|
+
*/
|
|
87
|
+
verifyMagicLink(opts: VerifyMagicLinkOptions): Promise<MagicLinkVerifyResult>;
|
|
88
|
+
/**
|
|
89
|
+
* Start a Google OAuth flow for headless authentication.
|
|
90
|
+
* Returns the Google authorization URL to redirect the user to.
|
|
91
|
+
* After Google authentication, the portal handles the callback and
|
|
92
|
+
* redirects to the domain's configured redirect_url.
|
|
93
|
+
*/
|
|
94
|
+
startGoogleOAuth(): Promise<GoogleOAuthStartResult>;
|
|
95
|
+
/**
|
|
96
|
+
* Start an X (Twitter) OAuth flow for headless authentication.
|
|
97
|
+
* Returns the X authorization URL to redirect the user to.
|
|
98
|
+
* After X authentication, the portal handles the callback and
|
|
99
|
+
* redirects to the domain's configured redirect_url.
|
|
100
|
+
*/
|
|
101
|
+
startTwitterOAuth(): Promise<TwitterOAuthStartResult>;
|
|
64
102
|
/**
|
|
65
103
|
* Get available subscription plans for the domain.
|
|
66
104
|
* Only returns public plans sorted by display order.
|
|
105
|
+
* @throws Error on server error
|
|
67
106
|
*/
|
|
68
107
|
getPlans(): Promise<SubscriptionPlan[]>;
|
|
69
108
|
/**
|
|
70
109
|
* Get the current user's subscription status.
|
|
71
110
|
*/
|
|
72
|
-
getSubscription(): Promise<
|
|
111
|
+
getSubscription(): Promise<Subscription>;
|
|
73
112
|
/**
|
|
74
113
|
* Create a Stripe checkout session to subscribe to a plan.
|
|
75
114
|
* @param planCode The plan code to subscribe to
|
|
@@ -91,9 +130,9 @@ declare function createReauthClient(config: ReauthConfig): {
|
|
|
91
130
|
openBillingPortal(returnUrl?: string): Promise<void>;
|
|
92
131
|
/**
|
|
93
132
|
* Cancel the user's subscription at period end.
|
|
94
|
-
* @
|
|
133
|
+
* @throws Error on failure or server error
|
|
95
134
|
*/
|
|
96
|
-
cancelSubscription(): Promise<
|
|
135
|
+
cancelSubscription(): Promise<void>;
|
|
97
136
|
/**
|
|
98
137
|
* Get the current user's balance.
|
|
99
138
|
* @returns Object with the current balance
|
|
@@ -109,6 +148,152 @@ declare function createReauthClient(config: ReauthConfig): {
|
|
|
109
148
|
getTransactions(opts?: TransactionsPaginationOptions): Promise<{
|
|
110
149
|
transactions: BalanceTransaction[];
|
|
111
150
|
}>;
|
|
151
|
+
/**
|
|
152
|
+
* Get the domain's credits configuration.
|
|
153
|
+
* Returns exchange rate, display settings, and purchase limits.
|
|
154
|
+
*/
|
|
155
|
+
getCreditsConfig(): Promise<CreditsConfig>;
|
|
156
|
+
/**
|
|
157
|
+
* List the current user's stored payment methods.
|
|
158
|
+
* Sorted by priority (lower number = higher priority).
|
|
159
|
+
*/
|
|
160
|
+
getPaymentMethods(): Promise<PaymentMethod[]>;
|
|
161
|
+
/**
|
|
162
|
+
* Create a Stripe SetupIntent for adding a new payment method.
|
|
163
|
+
* Use the returned clientSecret with Stripe.js `confirmCardSetup()`.
|
|
164
|
+
*/
|
|
165
|
+
createSetupIntent(): Promise<SetupIntentResult>;
|
|
166
|
+
/**
|
|
167
|
+
* Delete a stored payment method.
|
|
168
|
+
* @param id UUID of the payment method to delete
|
|
169
|
+
*/
|
|
170
|
+
deletePaymentMethod(id: string): Promise<void>;
|
|
171
|
+
/**
|
|
172
|
+
* Reorder payment method priorities.
|
|
173
|
+
* @param paymentMethodIds Array of payment method UUIDs in desired priority order
|
|
174
|
+
*/
|
|
175
|
+
reorderPaymentMethods(paymentMethodIds: string[]): Promise<void>;
|
|
176
|
+
/**
|
|
177
|
+
* Purchase credits using a stored payment method.
|
|
178
|
+
* @param opts Purchase options (amount, payment method, idempotency key)
|
|
179
|
+
*/
|
|
180
|
+
purchaseCredits(opts: PurchaseCreditsOptions): Promise<CreditPurchaseResult>;
|
|
181
|
+
/**
|
|
182
|
+
* Get the current user's auto top-up configuration and status.
|
|
183
|
+
*/
|
|
184
|
+
getAutoTopUpStatus(): Promise<AutoTopUpStatus>;
|
|
185
|
+
/**
|
|
186
|
+
* Update the current user's auto top-up configuration.
|
|
187
|
+
* @param opts New auto top-up settings
|
|
188
|
+
*/
|
|
189
|
+
updateAutoTopUp(opts: UpdateAutoTopUpOptions): Promise<AutoTopUpStatus>;
|
|
190
|
+
/**
|
|
191
|
+
* Create a new organization.
|
|
192
|
+
* @param name The organization name
|
|
193
|
+
* @returns The created organization
|
|
194
|
+
*/
|
|
195
|
+
createOrg(name: string): Promise<Organization>;
|
|
196
|
+
/**
|
|
197
|
+
* List all organizations the current user belongs to.
|
|
198
|
+
*/
|
|
199
|
+
listOrgs(): Promise<Organization[]>;
|
|
200
|
+
/**
|
|
201
|
+
* Get organization details.
|
|
202
|
+
* @param orgId The organization ID
|
|
203
|
+
*/
|
|
204
|
+
getOrg(orgId: string): Promise<Organization>;
|
|
205
|
+
/**
|
|
206
|
+
* Update an organization's name. Requires owner role.
|
|
207
|
+
* @param orgId The organization ID
|
|
208
|
+
* @param name The new name
|
|
209
|
+
*/
|
|
210
|
+
updateOrg(orgId: string, name: string): Promise<Organization>;
|
|
211
|
+
/**
|
|
212
|
+
* Delete an organization. Requires owner role.
|
|
213
|
+
* @param orgId The organization ID
|
|
214
|
+
*/
|
|
215
|
+
deleteOrg(orgId: string): Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* List members of an organization. Requires membership.
|
|
218
|
+
* @param orgId The organization ID
|
|
219
|
+
*/
|
|
220
|
+
listOrgMembers(orgId: string): Promise<OrgMember[]>;
|
|
221
|
+
/**
|
|
222
|
+
* Remove a member from an organization. Requires owner role.
|
|
223
|
+
* @param orgId The organization ID
|
|
224
|
+
* @param userId The user ID to remove
|
|
225
|
+
*/
|
|
226
|
+
removeOrgMember(orgId: string, userId: string): Promise<void>;
|
|
227
|
+
/**
|
|
228
|
+
* Update a member's role. Requires owner role.
|
|
229
|
+
* @param orgId The organization ID
|
|
230
|
+
* @param userId The user ID to update
|
|
231
|
+
* @param role The new role
|
|
232
|
+
*/
|
|
233
|
+
updateMemberRole(orgId: string, userId: string, role: OrgRole): Promise<OrgMember>;
|
|
234
|
+
/**
|
|
235
|
+
* Switch the active organization. Re-issues session tokens with new org context.
|
|
236
|
+
* @param orgId The organization ID to switch to
|
|
237
|
+
* @returns The new active org context with subscription info
|
|
238
|
+
*/
|
|
239
|
+
switchOrg(orgId: string): Promise<SwitchOrgResult>;
|
|
240
|
+
/**
|
|
241
|
+
* Get the active organization from the current session.
|
|
242
|
+
* @returns Active org ID and role, or null if no active org
|
|
243
|
+
*/
|
|
244
|
+
getActiveOrg(): Promise<{
|
|
245
|
+
id: string;
|
|
246
|
+
role: OrgRole;
|
|
247
|
+
} | null>;
|
|
248
|
+
/**
|
|
249
|
+
* Send an email invite to join an organization. Requires owner role.
|
|
250
|
+
* @param orgId The organization ID
|
|
251
|
+
* @param email The email address to invite
|
|
252
|
+
* @param role Optional role (defaults to "member")
|
|
253
|
+
*/
|
|
254
|
+
inviteToOrg(orgId: string, email: string, role?: OrgRole): Promise<OrgInvitation>;
|
|
255
|
+
/**
|
|
256
|
+
* List pending invites for an organization. Requires owner role.
|
|
257
|
+
* @param orgId The organization ID
|
|
258
|
+
*/
|
|
259
|
+
listPendingInvites(orgId: string): Promise<OrgInvitation[]>;
|
|
260
|
+
/**
|
|
261
|
+
* Revoke a pending invite. Requires owner role.
|
|
262
|
+
* @param orgId The organization ID
|
|
263
|
+
* @param inviteId The invite ID to revoke
|
|
264
|
+
*/
|
|
265
|
+
revokeInvite(orgId: string, inviteId: string): Promise<void>;
|
|
266
|
+
/**
|
|
267
|
+
* Accept an email invite using the invite token.
|
|
268
|
+
* @param token The invite token from the email
|
|
269
|
+
* @returns The org ID and role assigned
|
|
270
|
+
*/
|
|
271
|
+
acceptInvite(token: string): Promise<{
|
|
272
|
+
orgId: string;
|
|
273
|
+
role: OrgRole;
|
|
274
|
+
}>;
|
|
275
|
+
/**
|
|
276
|
+
* Create a shareable invite link for an organization. Requires owner role.
|
|
277
|
+
* @param orgId The organization ID
|
|
278
|
+
* @param role Optional role for joiners (defaults to "member")
|
|
279
|
+
*/
|
|
280
|
+
createInviteLink(orgId: string, role?: OrgRole): Promise<OrgInviteLink>;
|
|
281
|
+
/**
|
|
282
|
+
* List invite links for an organization. Requires owner role.
|
|
283
|
+
* @param orgId The organization ID
|
|
284
|
+
*/
|
|
285
|
+
listInviteLinks(orgId: string): Promise<OrgInviteLink[]>;
|
|
286
|
+
/**
|
|
287
|
+
* Revoke an invite link. Requires owner role.
|
|
288
|
+
* @param orgId The organization ID
|
|
289
|
+
* @param linkId The invite link ID to revoke
|
|
290
|
+
*/
|
|
291
|
+
revokeInviteLink(orgId: string, linkId: string): Promise<void>;
|
|
292
|
+
/**
|
|
293
|
+
* Join an organization via an invite link token.
|
|
294
|
+
* @param token The invite link token
|
|
295
|
+
*/
|
|
296
|
+
joinViaLink(token: string): Promise<void>;
|
|
112
297
|
};
|
|
113
298
|
type ReauthClient = ReturnType<typeof createReauthClient>;
|
|
114
299
|
|
|
@@ -124,4 +309,4 @@ type ReauthError = {
|
|
|
124
309
|
};
|
|
125
310
|
declare function requiresOAuthRestart(error: ReauthError | null | undefined): boolean;
|
|
126
311
|
|
|
127
|
-
export { BalanceTransaction, type ReauthClient, ReauthConfig, type ReauthError, ReauthErrorCode, ReauthSession, TokenResponse, TransactionsPaginationOptions, createReauthClient, requiresOAuthRestart };
|
|
312
|
+
export { AutoTopUpStatus, BalanceTransaction, CreditPurchaseResult, CreditsConfig, DomainConfig, GoogleOAuthStartResult, MagicLinkVerifyResult, OrgInvitation, OrgInviteLink, OrgMember, OrgRole, Organization, PaymentMethod, PurchaseCreditsOptions, type ReauthClient, ReauthConfig, type ReauthError, ReauthErrorCode, ReauthSession, RequestMagicLinkOptions, SetupIntentResult, Subscription, SubscriptionPlan, SwitchOrgResult, TokenResponse, TransactionsPaginationOptions, TwitterOAuthStartResult, UpdateAutoTopUpOptions, VerifyMagicLinkOptions, createReauthClient, requiresOAuthRestart };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as ReauthConfig, a as ReauthSession, T as TokenResponse, S as SubscriptionPlan,
|
|
2
|
-
export {
|
|
1
|
+
import { R as ReauthConfig, a as ReauthSession, T as TokenResponse, D as DomainConfig, b as RequestMagicLinkOptions, V as VerifyMagicLinkOptions, M as MagicLinkVerifyResult, G as GoogleOAuthStartResult, c as TwitterOAuthStartResult, S as SubscriptionPlan, d as Subscription, C as CheckoutSession, e as TransactionsPaginationOptions, B as BalanceTransaction, f as CreditsConfig, P as PaymentMethod, g as SetupIntentResult, h as PurchaseCreditsOptions, i as CreditPurchaseResult, A as AutoTopUpStatus, U as UpdateAutoTopUpOptions, O as Organization, j as OrgMember, k as OrgRole, l as SwitchOrgResult, m as OrgInvitation, n as OrgInviteLink } from './types-DKUKhCNE.js';
|
|
2
|
+
export { r as AuthResult, x as ChargeOptions, y as DepositOptions, t as DomainEndUserClaims, w as PlanFeature, q as ReauthServerConfig, s as RequestLike, u as SubscriptionInfo, v as SubscriptionStatus, z as SymbolPosition, o as User, p as UserDetails } from './types-DKUKhCNE.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Create a reauth client for browser-side authentication.
|
|
@@ -32,44 +32,83 @@ declare function createReauthClient(config: ReauthConfig): {
|
|
|
32
32
|
/**
|
|
33
33
|
* Refresh the access token using the refresh token.
|
|
34
34
|
* Call this when getSession() returns valid: false but no error_code.
|
|
35
|
-
* @
|
|
35
|
+
* @throws Error on failed refresh (401) or server error
|
|
36
36
|
*/
|
|
37
|
-
refresh(): Promise<
|
|
37
|
+
refresh(): Promise<void>;
|
|
38
38
|
/**
|
|
39
39
|
* Get an access token for Bearer authentication.
|
|
40
40
|
* Use this when calling your own API that uses local token verification.
|
|
41
41
|
*
|
|
42
|
-
* @returns TokenResponse with access token, or null if not authenticated
|
|
42
|
+
* @returns TokenResponse with access token, or null if not authenticated or network unreachable
|
|
43
|
+
* @throws Error on server errors (non-401 HTTP status codes) or request timeout
|
|
43
44
|
*
|
|
44
45
|
* @example
|
|
45
46
|
* ```typescript
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
47
|
+
* try {
|
|
48
|
+
* const tokenResponse = await reauth.getToken();
|
|
49
|
+
* if (tokenResponse) {
|
|
50
|
+
* fetch('/api/data', {
|
|
51
|
+
* headers: { Authorization: `Bearer ${tokenResponse.accessToken}` }
|
|
52
|
+
* });
|
|
53
|
+
* }
|
|
54
|
+
* } catch (err) {
|
|
55
|
+
* // Server error or timeout — do not log the user out
|
|
51
56
|
* }
|
|
52
57
|
* ```
|
|
53
58
|
*/
|
|
54
59
|
getToken(): Promise<TokenResponse | null>;
|
|
55
60
|
/**
|
|
56
61
|
* Log out the user by clearing all session cookies.
|
|
62
|
+
* @throws Error on server error
|
|
57
63
|
*/
|
|
58
64
|
logout(): Promise<void>;
|
|
59
65
|
/**
|
|
60
66
|
* Delete the user's own account (self-service).
|
|
61
|
-
* @
|
|
67
|
+
* @throws Error on permission denied or server error
|
|
62
68
|
*/
|
|
63
|
-
deleteAccount(): Promise<
|
|
69
|
+
deleteAccount(): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Get the domain's public auth configuration.
|
|
72
|
+
* Returns enabled auth methods and whether headless auth is available.
|
|
73
|
+
*/
|
|
74
|
+
getConfig(): Promise<DomainConfig>;
|
|
75
|
+
/**
|
|
76
|
+
* Request a magic link email for headless authentication.
|
|
77
|
+
* When callbackUrl is provided, the email link will point to your custom URL
|
|
78
|
+
* with the token as a query parameter.
|
|
79
|
+
* @param opts Options including email and optional callbackUrl
|
|
80
|
+
*/
|
|
81
|
+
requestMagicLink(opts: RequestMagicLinkOptions): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Verify a magic link token received from the email callback URL.
|
|
84
|
+
* On success, session cookies are set automatically.
|
|
85
|
+
* @param opts Options including the token from the callback URL
|
|
86
|
+
*/
|
|
87
|
+
verifyMagicLink(opts: VerifyMagicLinkOptions): Promise<MagicLinkVerifyResult>;
|
|
88
|
+
/**
|
|
89
|
+
* Start a Google OAuth flow for headless authentication.
|
|
90
|
+
* Returns the Google authorization URL to redirect the user to.
|
|
91
|
+
* After Google authentication, the portal handles the callback and
|
|
92
|
+
* redirects to the domain's configured redirect_url.
|
|
93
|
+
*/
|
|
94
|
+
startGoogleOAuth(): Promise<GoogleOAuthStartResult>;
|
|
95
|
+
/**
|
|
96
|
+
* Start an X (Twitter) OAuth flow for headless authentication.
|
|
97
|
+
* Returns the X authorization URL to redirect the user to.
|
|
98
|
+
* After X authentication, the portal handles the callback and
|
|
99
|
+
* redirects to the domain's configured redirect_url.
|
|
100
|
+
*/
|
|
101
|
+
startTwitterOAuth(): Promise<TwitterOAuthStartResult>;
|
|
64
102
|
/**
|
|
65
103
|
* Get available subscription plans for the domain.
|
|
66
104
|
* Only returns public plans sorted by display order.
|
|
105
|
+
* @throws Error on server error
|
|
67
106
|
*/
|
|
68
107
|
getPlans(): Promise<SubscriptionPlan[]>;
|
|
69
108
|
/**
|
|
70
109
|
* Get the current user's subscription status.
|
|
71
110
|
*/
|
|
72
|
-
getSubscription(): Promise<
|
|
111
|
+
getSubscription(): Promise<Subscription>;
|
|
73
112
|
/**
|
|
74
113
|
* Create a Stripe checkout session to subscribe to a plan.
|
|
75
114
|
* @param planCode The plan code to subscribe to
|
|
@@ -91,9 +130,9 @@ declare function createReauthClient(config: ReauthConfig): {
|
|
|
91
130
|
openBillingPortal(returnUrl?: string): Promise<void>;
|
|
92
131
|
/**
|
|
93
132
|
* Cancel the user's subscription at period end.
|
|
94
|
-
* @
|
|
133
|
+
* @throws Error on failure or server error
|
|
95
134
|
*/
|
|
96
|
-
cancelSubscription(): Promise<
|
|
135
|
+
cancelSubscription(): Promise<void>;
|
|
97
136
|
/**
|
|
98
137
|
* Get the current user's balance.
|
|
99
138
|
* @returns Object with the current balance
|
|
@@ -109,6 +148,152 @@ declare function createReauthClient(config: ReauthConfig): {
|
|
|
109
148
|
getTransactions(opts?: TransactionsPaginationOptions): Promise<{
|
|
110
149
|
transactions: BalanceTransaction[];
|
|
111
150
|
}>;
|
|
151
|
+
/**
|
|
152
|
+
* Get the domain's credits configuration.
|
|
153
|
+
* Returns exchange rate, display settings, and purchase limits.
|
|
154
|
+
*/
|
|
155
|
+
getCreditsConfig(): Promise<CreditsConfig>;
|
|
156
|
+
/**
|
|
157
|
+
* List the current user's stored payment methods.
|
|
158
|
+
* Sorted by priority (lower number = higher priority).
|
|
159
|
+
*/
|
|
160
|
+
getPaymentMethods(): Promise<PaymentMethod[]>;
|
|
161
|
+
/**
|
|
162
|
+
* Create a Stripe SetupIntent for adding a new payment method.
|
|
163
|
+
* Use the returned clientSecret with Stripe.js `confirmCardSetup()`.
|
|
164
|
+
*/
|
|
165
|
+
createSetupIntent(): Promise<SetupIntentResult>;
|
|
166
|
+
/**
|
|
167
|
+
* Delete a stored payment method.
|
|
168
|
+
* @param id UUID of the payment method to delete
|
|
169
|
+
*/
|
|
170
|
+
deletePaymentMethod(id: string): Promise<void>;
|
|
171
|
+
/**
|
|
172
|
+
* Reorder payment method priorities.
|
|
173
|
+
* @param paymentMethodIds Array of payment method UUIDs in desired priority order
|
|
174
|
+
*/
|
|
175
|
+
reorderPaymentMethods(paymentMethodIds: string[]): Promise<void>;
|
|
176
|
+
/**
|
|
177
|
+
* Purchase credits using a stored payment method.
|
|
178
|
+
* @param opts Purchase options (amount, payment method, idempotency key)
|
|
179
|
+
*/
|
|
180
|
+
purchaseCredits(opts: PurchaseCreditsOptions): Promise<CreditPurchaseResult>;
|
|
181
|
+
/**
|
|
182
|
+
* Get the current user's auto top-up configuration and status.
|
|
183
|
+
*/
|
|
184
|
+
getAutoTopUpStatus(): Promise<AutoTopUpStatus>;
|
|
185
|
+
/**
|
|
186
|
+
* Update the current user's auto top-up configuration.
|
|
187
|
+
* @param opts New auto top-up settings
|
|
188
|
+
*/
|
|
189
|
+
updateAutoTopUp(opts: UpdateAutoTopUpOptions): Promise<AutoTopUpStatus>;
|
|
190
|
+
/**
|
|
191
|
+
* Create a new organization.
|
|
192
|
+
* @param name The organization name
|
|
193
|
+
* @returns The created organization
|
|
194
|
+
*/
|
|
195
|
+
createOrg(name: string): Promise<Organization>;
|
|
196
|
+
/**
|
|
197
|
+
* List all organizations the current user belongs to.
|
|
198
|
+
*/
|
|
199
|
+
listOrgs(): Promise<Organization[]>;
|
|
200
|
+
/**
|
|
201
|
+
* Get organization details.
|
|
202
|
+
* @param orgId The organization ID
|
|
203
|
+
*/
|
|
204
|
+
getOrg(orgId: string): Promise<Organization>;
|
|
205
|
+
/**
|
|
206
|
+
* Update an organization's name. Requires owner role.
|
|
207
|
+
* @param orgId The organization ID
|
|
208
|
+
* @param name The new name
|
|
209
|
+
*/
|
|
210
|
+
updateOrg(orgId: string, name: string): Promise<Organization>;
|
|
211
|
+
/**
|
|
212
|
+
* Delete an organization. Requires owner role.
|
|
213
|
+
* @param orgId The organization ID
|
|
214
|
+
*/
|
|
215
|
+
deleteOrg(orgId: string): Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* List members of an organization. Requires membership.
|
|
218
|
+
* @param orgId The organization ID
|
|
219
|
+
*/
|
|
220
|
+
listOrgMembers(orgId: string): Promise<OrgMember[]>;
|
|
221
|
+
/**
|
|
222
|
+
* Remove a member from an organization. Requires owner role.
|
|
223
|
+
* @param orgId The organization ID
|
|
224
|
+
* @param userId The user ID to remove
|
|
225
|
+
*/
|
|
226
|
+
removeOrgMember(orgId: string, userId: string): Promise<void>;
|
|
227
|
+
/**
|
|
228
|
+
* Update a member's role. Requires owner role.
|
|
229
|
+
* @param orgId The organization ID
|
|
230
|
+
* @param userId The user ID to update
|
|
231
|
+
* @param role The new role
|
|
232
|
+
*/
|
|
233
|
+
updateMemberRole(orgId: string, userId: string, role: OrgRole): Promise<OrgMember>;
|
|
234
|
+
/**
|
|
235
|
+
* Switch the active organization. Re-issues session tokens with new org context.
|
|
236
|
+
* @param orgId The organization ID to switch to
|
|
237
|
+
* @returns The new active org context with subscription info
|
|
238
|
+
*/
|
|
239
|
+
switchOrg(orgId: string): Promise<SwitchOrgResult>;
|
|
240
|
+
/**
|
|
241
|
+
* Get the active organization from the current session.
|
|
242
|
+
* @returns Active org ID and role, or null if no active org
|
|
243
|
+
*/
|
|
244
|
+
getActiveOrg(): Promise<{
|
|
245
|
+
id: string;
|
|
246
|
+
role: OrgRole;
|
|
247
|
+
} | null>;
|
|
248
|
+
/**
|
|
249
|
+
* Send an email invite to join an organization. Requires owner role.
|
|
250
|
+
* @param orgId The organization ID
|
|
251
|
+
* @param email The email address to invite
|
|
252
|
+
* @param role Optional role (defaults to "member")
|
|
253
|
+
*/
|
|
254
|
+
inviteToOrg(orgId: string, email: string, role?: OrgRole): Promise<OrgInvitation>;
|
|
255
|
+
/**
|
|
256
|
+
* List pending invites for an organization. Requires owner role.
|
|
257
|
+
* @param orgId The organization ID
|
|
258
|
+
*/
|
|
259
|
+
listPendingInvites(orgId: string): Promise<OrgInvitation[]>;
|
|
260
|
+
/**
|
|
261
|
+
* Revoke a pending invite. Requires owner role.
|
|
262
|
+
* @param orgId The organization ID
|
|
263
|
+
* @param inviteId The invite ID to revoke
|
|
264
|
+
*/
|
|
265
|
+
revokeInvite(orgId: string, inviteId: string): Promise<void>;
|
|
266
|
+
/**
|
|
267
|
+
* Accept an email invite using the invite token.
|
|
268
|
+
* @param token The invite token from the email
|
|
269
|
+
* @returns The org ID and role assigned
|
|
270
|
+
*/
|
|
271
|
+
acceptInvite(token: string): Promise<{
|
|
272
|
+
orgId: string;
|
|
273
|
+
role: OrgRole;
|
|
274
|
+
}>;
|
|
275
|
+
/**
|
|
276
|
+
* Create a shareable invite link for an organization. Requires owner role.
|
|
277
|
+
* @param orgId The organization ID
|
|
278
|
+
* @param role Optional role for joiners (defaults to "member")
|
|
279
|
+
*/
|
|
280
|
+
createInviteLink(orgId: string, role?: OrgRole): Promise<OrgInviteLink>;
|
|
281
|
+
/**
|
|
282
|
+
* List invite links for an organization. Requires owner role.
|
|
283
|
+
* @param orgId The organization ID
|
|
284
|
+
*/
|
|
285
|
+
listInviteLinks(orgId: string): Promise<OrgInviteLink[]>;
|
|
286
|
+
/**
|
|
287
|
+
* Revoke an invite link. Requires owner role.
|
|
288
|
+
* @param orgId The organization ID
|
|
289
|
+
* @param linkId The invite link ID to revoke
|
|
290
|
+
*/
|
|
291
|
+
revokeInviteLink(orgId: string, linkId: string): Promise<void>;
|
|
292
|
+
/**
|
|
293
|
+
* Join an organization via an invite link token.
|
|
294
|
+
* @param token The invite link token
|
|
295
|
+
*/
|
|
296
|
+
joinViaLink(token: string): Promise<void>;
|
|
112
297
|
};
|
|
113
298
|
type ReauthClient = ReturnType<typeof createReauthClient>;
|
|
114
299
|
|
|
@@ -124,4 +309,4 @@ type ReauthError = {
|
|
|
124
309
|
};
|
|
125
310
|
declare function requiresOAuthRestart(error: ReauthError | null | undefined): boolean;
|
|
126
311
|
|
|
127
|
-
export { BalanceTransaction, type ReauthClient, ReauthConfig, type ReauthError, ReauthErrorCode, ReauthSession, TokenResponse, TransactionsPaginationOptions, createReauthClient, requiresOAuthRestart };
|
|
312
|
+
export { AutoTopUpStatus, BalanceTransaction, CreditPurchaseResult, CreditsConfig, DomainConfig, GoogleOAuthStartResult, MagicLinkVerifyResult, OrgInvitation, OrgInviteLink, OrgMember, OrgRole, Organization, PaymentMethod, PurchaseCreditsOptions, type ReauthClient, ReauthConfig, type ReauthError, ReauthErrorCode, ReauthSession, RequestMagicLinkOptions, SetupIntentResult, Subscription, SubscriptionPlan, SwitchOrgResult, TokenResponse, TransactionsPaginationOptions, TwitterOAuthStartResult, UpdateAutoTopUpOptions, VerifyMagicLinkOptions, createReauthClient, requiresOAuthRestart };
|