@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/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as ReauthConfig, a as ReauthSession, T as TokenResponse, S as SubscriptionPlan, U as UserSubscription, C as CheckoutSession, b as TransactionsPaginationOptions, B as BalanceTransaction } from './types-BqZzje-y.mjs';
2
- export { A as AuthResult, h as ChargeOptions, i as DepositOptions, D as DomainEndUserClaims, P as PlanFeature, e as ReauthServerConfig, f as RequestLike, g as SubscriptionInfo, c as User, d as UserDetails } from './types-BqZzje-y.mjs';
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.
@@ -67,6 +67,38 @@ declare function createReauthClient(config: ReauthConfig): {
67
67
  * @throws Error on permission denied or server error
68
68
  */
69
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>;
70
102
  /**
71
103
  * Get available subscription plans for the domain.
72
104
  * Only returns public plans sorted by display order.
@@ -76,7 +108,7 @@ declare function createReauthClient(config: ReauthConfig): {
76
108
  /**
77
109
  * Get the current user's subscription status.
78
110
  */
79
- getSubscription(): Promise<UserSubscription>;
111
+ getSubscription(): Promise<Subscription>;
80
112
  /**
81
113
  * Create a Stripe checkout session to subscribe to a plan.
82
114
  * @param planCode The plan code to subscribe to
@@ -116,6 +148,152 @@ declare function createReauthClient(config: ReauthConfig): {
116
148
  getTransactions(opts?: TransactionsPaginationOptions): Promise<{
117
149
  transactions: BalanceTransaction[];
118
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>;
119
297
  };
120
298
  type ReauthClient = ReturnType<typeof createReauthClient>;
121
299
 
@@ -131,4 +309,4 @@ type ReauthError = {
131
309
  };
132
310
  declare function requiresOAuthRestart(error: ReauthError | null | undefined): boolean;
133
311
 
134
- export { BalanceTransaction, type ReauthClient, ReauthConfig, type ReauthError, ReauthErrorCode, ReauthSession, SubscriptionPlan, 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, U as UserSubscription, C as CheckoutSession, b as TransactionsPaginationOptions, B as BalanceTransaction } from './types-BqZzje-y.js';
2
- export { A as AuthResult, h as ChargeOptions, i as DepositOptions, D as DomainEndUserClaims, P as PlanFeature, e as ReauthServerConfig, f as RequestLike, g as SubscriptionInfo, c as User, d as UserDetails } from './types-BqZzje-y.js';
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.
@@ -67,6 +67,38 @@ declare function createReauthClient(config: ReauthConfig): {
67
67
  * @throws Error on permission denied or server error
68
68
  */
69
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>;
70
102
  /**
71
103
  * Get available subscription plans for the domain.
72
104
  * Only returns public plans sorted by display order.
@@ -76,7 +108,7 @@ declare function createReauthClient(config: ReauthConfig): {
76
108
  /**
77
109
  * Get the current user's subscription status.
78
110
  */
79
- getSubscription(): Promise<UserSubscription>;
111
+ getSubscription(): Promise<Subscription>;
80
112
  /**
81
113
  * Create a Stripe checkout session to subscribe to a plan.
82
114
  * @param planCode The plan code to subscribe to
@@ -116,6 +148,152 @@ declare function createReauthClient(config: ReauthConfig): {
116
148
  getTransactions(opts?: TransactionsPaginationOptions): Promise<{
117
149
  transactions: BalanceTransaction[];
118
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>;
119
297
  };
120
298
  type ReauthClient = ReturnType<typeof createReauthClient>;
121
299
 
@@ -131,4 +309,4 @@ type ReauthError = {
131
309
  };
132
310
  declare function requiresOAuthRestart(error: ReauthError | null | undefined): boolean;
133
311
 
134
- export { BalanceTransaction, type ReauthClient, ReauthConfig, type ReauthError, ReauthErrorCode, ReauthSession, SubscriptionPlan, 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 };