@bunbase-ae/js 3.1.1-next.408.4c3055e → 3.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunbase-ae/js",
3
- "version": "3.1.1-next.408.4c3055e",
3
+ "version": "3.2.0",
4
4
  "type": "module",
5
5
  "description": "TypeScript/JavaScript SDK for BunBase",
6
6
  "license": "UNLICENSED",
package/src/admin.ts CHANGED
@@ -257,6 +257,18 @@ export interface ServerSettings {
257
257
  auth_totp_enabled?: boolean;
258
258
  auth_oauth_enabled?: boolean;
259
259
  auth_api_keys_enabled?: boolean;
260
+ // Phone / SMS OTP auth method (issue #680).
261
+ auth_phone_otp_enabled?: boolean;
262
+ auth_phone_otp_code_length?: number;
263
+ auth_phone_otp_ttl_seconds?: number;
264
+ auth_phone_otp_max_attempts?: number;
265
+ auth_phone_otp_resend_cooldown_seconds?: number;
266
+ auth_phone_otp_rate_limit_per_phone?: number;
267
+ auth_phone_otp_rate_limit_per_ip?: number;
268
+ auth_phone_otp_auto_provision?: boolean;
269
+ auth_phone_otp_sms_provider?: string;
270
+ auth_phone_otp_sms_webhook_url?: string;
271
+ auth_phone_otp_sms_webhook_secret?: string;
260
272
  oauth_github_client_id?: string;
261
273
  oauth_github_client_secret?: string;
262
274
  oauth_google_client_id?: string;
package/src/auth.ts CHANGED
@@ -181,6 +181,36 @@ export class AuthClient {
181
181
  return result;
182
182
  }
183
183
 
184
+ // Request an SMS one-time code for a phone number (issue #680). The response
185
+ // never reveals whether the number maps to an account. Pass the returned
186
+ // `request_id` plus the received code to verifyPhoneOtp() to complete sign-in.
187
+ async requestPhoneOtp(phone: string): Promise<{
188
+ request_id: string;
189
+ expires_in: number;
190
+ resend_after: number;
191
+ }> {
192
+ return await this.http.request<{
193
+ request_id: string;
194
+ expires_in: number;
195
+ resend_after: number;
196
+ }>("POST", "/api/v1/auth/phone-otp/request", {
197
+ body: { phone },
198
+ skipAuth: true,
199
+ });
200
+ }
201
+
202
+ // Complete phone-OTP sign-in by exchanging the code for the token pair.
203
+ async verifyPhoneOtp(requestId: string, code: string): Promise<AuthResult> {
204
+ const result = await this.http.request<AuthResult>("POST", "/api/v1/auth/phone-otp/verify", {
205
+ body: { request_id: requestId, code },
206
+ skipAuth: true,
207
+ });
208
+ this.cachedUser = result.user;
209
+ this.patchSnapshot({ user: result.user });
210
+ this.http.setTokens(result.access_token, result.refresh_token);
211
+ return result;
212
+ }
213
+
184
214
  // Redeem an OAuth handoff code for the token pair.
185
215
  //
186
216
  // The OAuth callback redirects to `{APP_URL}/auth/callback?handoff=<code>`.