@nulvless/nulvless-js 0.1.4 → 0.1.6

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.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  type SdkErrorCode = 'no_session' | 'request_timeout' | 'network_error' | 'invalid_path' | 'unknown_error';
2
2
  type GatewayErrorCode = 'rate_limit_exceeded' | 'service_not_enabled' | 'service_unavailable' | 'project_not_ready' | 'project_paused' | 'project_unavailable' | 'bad_gateway' | 'upstream_timeout' | 'idle_timeout' | 'deadline_exceeded' | 'internal_error';
3
- type AuthErrorCode = 'unauthorized' | 'not_allowed' | 'unavailable' | 'invalid_credentials' | 'mfa_required' | 'refresh_token_not_found' | 'refresh_token_already_used' | 'refresh_token_not_issued_here' | 'registration_closed' | 'user_not_confirmed' | 'user_already_confirmed' | 'user_banned' | 'user_already_banned' | 'user_not_banned' | 'user_missing_email' | 'user_missing_phone' | 'email_already_exists' | 'phone_already_exists' | 'username_already_exists' | 'password_weak' | 'password_leaked' | 'captcha_required' | 'captcha_verification_failed' | 'protected_action_denied' | 'action_verification_failed' | 'forbidden_resource_access' | 'forbidden_access_waiting_accept' | 'forbidden_special_role_required' | 'cannot_leave_owner_access' | 'permission_already_granted' | 'bad_oauth_state' | 'bad_oauth_callback' | 'redirect_uri_mismatch' | 'provider_unavailable' | 'provider_unsupported_method' | 'oauth_email_missing' | 'oauth_email_not_verified' | 'oauth_account_link_required' | 'rate_limit_exceeded';
3
+ type AuthErrorCode = 'unauthorized' | 'not_allowed' | 'unavailable' | 'invalid_credentials' | 'mfa_required' | 'mfa_factors_limit_reached' | 'mfa_phone_already_enrolled' | 'mfa_phone_not_supported' | 'refresh_token_not_found' | 'refresh_token_already_used' | 'refresh_token_not_issued_here' | 'registration_closed' | 'user_not_confirmed' | 'user_already_confirmed' | 'user_banned' | 'user_already_banned' | 'user_not_banned' | 'user_missing_email' | 'user_missing_phone' | 'email_already_exists' | 'phone_already_exists' | 'username_already_exists' | 'password_weak' | 'password_leaked' | 'captcha_required' | 'captcha_verification_failed' | 'protected_action_denied' | 'action_verification_failed' | 'forbidden_resource_access' | 'forbidden_access_waiting_accept' | 'forbidden_special_role_required' | 'cannot_leave_owner_access' | 'permission_already_granted' | 'bad_oauth_state' | 'bad_oauth_callback' | 'redirect_uri_mismatch' | 'provider_unavailable' | 'provider_unsupported_method' | 'oauth_email_missing' | 'oauth_email_not_verified' | 'oauth_account_link_required' | 'rate_limit_exceeded';
4
4
  type CommsErrorCode = 'unauthorized_platform' | 'rate_limit_exceeded';
5
5
  type EdgeFunctionErrorCode = 'function_not_found' | 'function_unavailable' | 'boot_failed' | 'execution_timeout' | 'cpu_time_limit_exceeded' | 'memory_limit_exceeded' | 'resource_unavailable' | 'internal_server_error';
6
6
  type ErrorCode = SdkErrorCode | GatewayErrorCode | AuthErrorCode | CommsErrorCode | (string & {});
@@ -343,6 +343,20 @@ interface ChangeChallengeParams {
343
343
  token: string;
344
344
  /** MFA method to switch to. */
345
345
  type: MFAMethod;
346
+ /**
347
+ * For `sms_otp`, which SMS factor receives the code — an `id` from
348
+ * `challenge.mfas`. Defaults to the oldest SMS factor.
349
+ */
350
+ factor_id?: string;
351
+ }
352
+ interface CreateChallengeParams {
353
+ /** MFA method to verify with. */
354
+ type: MFAMethod;
355
+ /**
356
+ * For `sms_otp`, which SMS factor receives the code — an `id` from
357
+ * `factors.list()`. Defaults to the oldest SMS factor.
358
+ */
359
+ factor_id?: string;
346
360
  }
347
361
  type AuthFactorStatus = 'configured' | 'not_configured';
348
362
  interface AuthMethod {
@@ -379,6 +393,11 @@ interface EnableFactorParams {
379
393
  interface EnrollFactorParams extends Nonce {
380
394
  type: MFAMethod;
381
395
  name?: string;
396
+ /**
397
+ * For `sms_otp`, the phone that receives the codes. Defaults to the user's
398
+ * phone. It may match the user's phone but not another SMS factor.
399
+ */
400
+ phone?: Phone;
382
401
  }
383
402
  interface UnenrollFactorParams extends Nonce {
384
403
  id: string;
@@ -471,11 +490,6 @@ interface ChangePasswordParams extends Nonce {
471
490
  password: string;
472
491
  new_password: string;
473
492
  }
474
- interface PlatformInfo {
475
- id: string;
476
- name: string;
477
- slug: string;
478
- }
479
493
  type PaginationSort = 'asc' | 'desc';
480
494
  interface Paginated<T> {
481
495
  items: T[];
@@ -906,6 +920,10 @@ declare class FactorsClient extends AuthSubClient {
906
920
  * the factor on the user's device.
907
921
  *
908
922
  * For TOTP: use `secret` for manual entry or `url` to generate a QR code.
923
+ * For SMS: pass `phone` to send the codes to a number other than the user's.
924
+ *
925
+ * A user holds up to 10 authenticator apps and SMS factors combined, and one
926
+ * email factor and one set of recovery codes.
909
927
  *
910
928
  * After the user configures their device, call `enable` with the `token` and
911
929
  * the first OTP code to activate the factor.
@@ -1142,10 +1160,14 @@ declare class ChallengesClient extends AuthSubClient {
1142
1160
  * Requires an authenticated session. Prompt the user for the code, then call
1143
1161
  * `verify({ token, code })`.
1144
1162
  *
1163
+ * A `totp` challenge accepts a code from any of the user's authenticator
1164
+ * apps. For `sms_otp`, pass `factor_id` to pick which phone receives it.
1165
+ *
1145
1166
  * @example
1146
- * const { data } = await nulvless.auth.challenges.create('totp')
1167
+ * const { data } = await nulvless.auth.challenges.create({ type: 'totp' })
1168
+ * const { data: sms } = await nulvless.auth.challenges.create({ type: 'sms_otp', factor_id })
1147
1169
  */
1148
- create(targetType: MFAMethod, options?: RequestOptions): Promise<NulvlessResult<{
1170
+ create(params: CreateChallengeParams, options?: RequestOptions): Promise<NulvlessResult<{
1149
1171
  challenge: Challenge;
1150
1172
  }>>;
1151
1173
  /**
@@ -1263,8 +1285,7 @@ declare class OAuthGrantsClient extends AuthSubClient {
1263
1285
  * The project's OAuth 2.1 / OpenID Connect provider surface — the project
1264
1286
  * acting as an identity provider for third-party applications.
1265
1287
  *
1266
- * Available with both public (`pk_`) and private (`sk_`) keys
1267
- * (`@SetPlatformGuardRoles([PUBLIC, PRIVATE])`).
1288
+ * Available with both public (`pk_`) and private (`sk_`) keys.
1268
1289
  *
1269
1290
  * Method scopes:
1270
1291
  * - `token`, `register` — platform key only (no bearer token).
@@ -1529,16 +1550,11 @@ declare class AdminClient {
1529
1550
  readonly grants: AdminGrantsClient;
1530
1551
  readonly oauthClients: AdminOAuthClientsClient;
1531
1552
  constructor(http: HttpClient);
1532
- /**
1533
- * Returns basic platform information (id, name, slug).
1534
- */
1535
- getPlatform(options?: RequestOptions): Promise<NulvlessResult<PlatformInfo>>;
1536
1553
  }
1537
1554
 
1538
1555
  interface AccountEntry {
1539
1556
  userId: string;
1540
1557
  access_token: string;
1541
- /** Seconds remaining until the token expires. May be negative if already expired. */
1542
1558
  expires_in: number;
1543
1559
  refresh_token?: string;
1544
1560
  user?: User;
@@ -1587,7 +1603,6 @@ declare class AuthEventEmitter {
1587
1603
 
1588
1604
  /**
1589
1605
  * Auth methods accessible with both public (`pk_`) and private (`sk_`) keys.
1590
- * Corresponds to endpoints decorated with `@SetPlatformGuardRoles([PUBLIC, PRIVATE])`.
1591
1606
  */
1592
1607
  declare class AuthClient {
1593
1608
  protected readonly http: HttpClient;
@@ -2331,4 +2346,4 @@ declare function createClient(url: string, publicKey: string, options?: ClientOp
2331
2346
  */
2332
2347
  declare function createServerClient(url: string, privateKey: string, options?: ServerClientOptions): NulvlessServerClient;
2333
2348
 
2334
- export { AUTH_CACHE_HEADERS, type AccountEntry, type AddEmailIdentityParams, type AddPhoneIdentityParams, AdminClient, type AdminCreateUserParams, type AdminUpdateUserParams, type AssuranceLevel, AuthBrowserClient, AuthClient, type AuthErrorCode, AuthEventEmitter, type AuthEvents, type AuthFactorStatus, type AuthMethod, type AuthMethods, type AuthOptions, AuthServerClient, type Authenticated, type BlockGrantParams, type Challenge, type ChallengeSubject, type ChangeChallengeParams, type ChangePasswordParams, type ClientOptions, CommsClient, type CommsErrorCode, type ConfirmationType, type CreateRoleParams, type CreateTemplateParams, type EdgeFunctionErrorCode, EmailClient, type EnableFactorParams, type EnrollFactorParams, type ErrorCode, type ExchangeOAuthCodeParams, type FactorEnrollment, FactorsClient, type GatewayErrorCode, type Grant, type GrantMembers, type GrantStatus, GrantsClient, HttpClient, type Identity, type IdentityType, type Invite, type InviteParams, type Language, type LeaveGrantParams, type LookupMatch, type LookupParams, type LookupResult, type MFAMethod, type Nonce, type NotificationChannel, NulvlessClient, type NulvlessError, NulvlessException, type NulvlessResult, NulvlessServerClient, type NulvlessStorage, type OAuthApp, type OAuthAppGrantType, type OAuthAppTokenEndpointAuthMethod, type OAuthAppType, type OAuthAuthorization, type OAuthAuthorizeParams, OAuthClient, type OAuthConsentAction, type OAuthConsentResult, type OAuthDiscovery, OAuthGrantsClient, type OAuthJWKS, type OAuthProvider, type OAuthTokenResponse, type OAuthUserGrant, type OAuthUserInfo, type PaginateGrantsParams, type PaginateUsersParams, type Paginated, type PaginatedTemplates, type PaginationSort, type Phone, type PlatformInfo, type RecoverParams, type RefreshOAuthTokenParams, type RefreshTokenParams, type RegisterOAuthAppParams, type RemoveIdentityParams, type RequestOptions, type ResetPasswordParams, type RevokeGrantParams, type RevokeSessionParams, type Role, type SdkErrorCode, SecurityClient, type SendEmailParams, type SendOTPToUpdateEmailParams, type SendOTPToUpdatePhoneParams, type SendSMSParams, type ServerClientOptions, type Session, type SessionFingerPrint, SessionManager, SessionsClient, type SetGrantParams, type SignInMethod, type SignInParams, type SignInWithOTPParams, type SignOutScope, type SignUpParams, SmsClient, Storage, type StoredSession, type SudoMethod, type Template, type TemplateFilters, type TemplateLanguage, TemplatesClient, type TokenType, type UnenrollFactorParams, type UpdateGrantParams, type UpdateIdentityParams, type UpdateOAuthAppParams, type UpdateRoleParams, type UpdateTemplateParams, type User, type UserGender, type UserProfile, UsersClient, type Verified, type VerifyChallengeParams, type VerifyParams, type VerifyReason, applyAuthCacheHeaders, createClient, createServerClient, forwardUserHeaders };
2349
+ export { AUTH_CACHE_HEADERS, type AccountEntry, type AddEmailIdentityParams, type AddPhoneIdentityParams, AdminClient, type AdminCreateUserParams, type AdminUpdateUserParams, type AssuranceLevel, AuthBrowserClient, AuthClient, type AuthErrorCode, AuthEventEmitter, type AuthEvents, type AuthFactorStatus, type AuthMethod, type AuthMethods, type AuthOptions, AuthServerClient, type Authenticated, type BlockGrantParams, type Challenge, type ChallengeSubject, type ChangeChallengeParams, type ChangePasswordParams, type ClientOptions, CommsClient, type CommsErrorCode, type ConfirmationType, type CreateChallengeParams, type CreateRoleParams, type CreateTemplateParams, type EdgeFunctionErrorCode, EmailClient, type EnableFactorParams, type EnrollFactorParams, type ErrorCode, type ExchangeOAuthCodeParams, type FactorEnrollment, FactorsClient, type GatewayErrorCode, type Grant, type GrantMembers, type GrantStatus, GrantsClient, HttpClient, type Identity, type IdentityType, type Invite, type InviteParams, type Language, type LeaveGrantParams, type LookupMatch, type LookupParams, type LookupResult, type MFAMethod, type Nonce, type NotificationChannel, NulvlessClient, type NulvlessError, NulvlessException, type NulvlessResult, NulvlessServerClient, type NulvlessStorage, type OAuthApp, type OAuthAppGrantType, type OAuthAppTokenEndpointAuthMethod, type OAuthAppType, type OAuthAuthorization, type OAuthAuthorizeParams, OAuthClient, type OAuthConsentAction, type OAuthConsentResult, type OAuthDiscovery, OAuthGrantsClient, type OAuthJWKS, type OAuthProvider, type OAuthTokenResponse, type OAuthUserGrant, type OAuthUserInfo, type PaginateGrantsParams, type PaginateUsersParams, type Paginated, type PaginatedTemplates, type PaginationSort, type Phone, type RecoverParams, type RefreshOAuthTokenParams, type RefreshTokenParams, type RegisterOAuthAppParams, type RemoveIdentityParams, type RequestOptions, type ResetPasswordParams, type RevokeGrantParams, type RevokeSessionParams, type Role, type SdkErrorCode, SecurityClient, type SendEmailParams, type SendOTPToUpdateEmailParams, type SendOTPToUpdatePhoneParams, type SendSMSParams, type ServerClientOptions, type Session, type SessionFingerPrint, SessionManager, SessionsClient, type SetGrantParams, type SignInMethod, type SignInParams, type SignInWithOTPParams, type SignOutScope, type SignUpParams, SmsClient, Storage, type StoredSession, type SudoMethod, type Template, type TemplateFilters, type TemplateLanguage, TemplatesClient, type TokenType, type UnenrollFactorParams, type UpdateGrantParams, type UpdateIdentityParams, type UpdateOAuthAppParams, type UpdateRoleParams, type UpdateTemplateParams, type User, type UserGender, type UserProfile, UsersClient, type Verified, type VerifyChallengeParams, type VerifyParams, type VerifyReason, applyAuthCacheHeaders, createClient, createServerClient, forwardUserHeaders };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  type SdkErrorCode = 'no_session' | 'request_timeout' | 'network_error' | 'invalid_path' | 'unknown_error';
2
2
  type GatewayErrorCode = 'rate_limit_exceeded' | 'service_not_enabled' | 'service_unavailable' | 'project_not_ready' | 'project_paused' | 'project_unavailable' | 'bad_gateway' | 'upstream_timeout' | 'idle_timeout' | 'deadline_exceeded' | 'internal_error';
3
- type AuthErrorCode = 'unauthorized' | 'not_allowed' | 'unavailable' | 'invalid_credentials' | 'mfa_required' | 'refresh_token_not_found' | 'refresh_token_already_used' | 'refresh_token_not_issued_here' | 'registration_closed' | 'user_not_confirmed' | 'user_already_confirmed' | 'user_banned' | 'user_already_banned' | 'user_not_banned' | 'user_missing_email' | 'user_missing_phone' | 'email_already_exists' | 'phone_already_exists' | 'username_already_exists' | 'password_weak' | 'password_leaked' | 'captcha_required' | 'captcha_verification_failed' | 'protected_action_denied' | 'action_verification_failed' | 'forbidden_resource_access' | 'forbidden_access_waiting_accept' | 'forbidden_special_role_required' | 'cannot_leave_owner_access' | 'permission_already_granted' | 'bad_oauth_state' | 'bad_oauth_callback' | 'redirect_uri_mismatch' | 'provider_unavailable' | 'provider_unsupported_method' | 'oauth_email_missing' | 'oauth_email_not_verified' | 'oauth_account_link_required' | 'rate_limit_exceeded';
3
+ type AuthErrorCode = 'unauthorized' | 'not_allowed' | 'unavailable' | 'invalid_credentials' | 'mfa_required' | 'mfa_factors_limit_reached' | 'mfa_phone_already_enrolled' | 'mfa_phone_not_supported' | 'refresh_token_not_found' | 'refresh_token_already_used' | 'refresh_token_not_issued_here' | 'registration_closed' | 'user_not_confirmed' | 'user_already_confirmed' | 'user_banned' | 'user_already_banned' | 'user_not_banned' | 'user_missing_email' | 'user_missing_phone' | 'email_already_exists' | 'phone_already_exists' | 'username_already_exists' | 'password_weak' | 'password_leaked' | 'captcha_required' | 'captcha_verification_failed' | 'protected_action_denied' | 'action_verification_failed' | 'forbidden_resource_access' | 'forbidden_access_waiting_accept' | 'forbidden_special_role_required' | 'cannot_leave_owner_access' | 'permission_already_granted' | 'bad_oauth_state' | 'bad_oauth_callback' | 'redirect_uri_mismatch' | 'provider_unavailable' | 'provider_unsupported_method' | 'oauth_email_missing' | 'oauth_email_not_verified' | 'oauth_account_link_required' | 'rate_limit_exceeded';
4
4
  type CommsErrorCode = 'unauthorized_platform' | 'rate_limit_exceeded';
5
5
  type EdgeFunctionErrorCode = 'function_not_found' | 'function_unavailable' | 'boot_failed' | 'execution_timeout' | 'cpu_time_limit_exceeded' | 'memory_limit_exceeded' | 'resource_unavailable' | 'internal_server_error';
6
6
  type ErrorCode = SdkErrorCode | GatewayErrorCode | AuthErrorCode | CommsErrorCode | (string & {});
@@ -343,6 +343,20 @@ interface ChangeChallengeParams {
343
343
  token: string;
344
344
  /** MFA method to switch to. */
345
345
  type: MFAMethod;
346
+ /**
347
+ * For `sms_otp`, which SMS factor receives the code — an `id` from
348
+ * `challenge.mfas`. Defaults to the oldest SMS factor.
349
+ */
350
+ factor_id?: string;
351
+ }
352
+ interface CreateChallengeParams {
353
+ /** MFA method to verify with. */
354
+ type: MFAMethod;
355
+ /**
356
+ * For `sms_otp`, which SMS factor receives the code — an `id` from
357
+ * `factors.list()`. Defaults to the oldest SMS factor.
358
+ */
359
+ factor_id?: string;
346
360
  }
347
361
  type AuthFactorStatus = 'configured' | 'not_configured';
348
362
  interface AuthMethod {
@@ -379,6 +393,11 @@ interface EnableFactorParams {
379
393
  interface EnrollFactorParams extends Nonce {
380
394
  type: MFAMethod;
381
395
  name?: string;
396
+ /**
397
+ * For `sms_otp`, the phone that receives the codes. Defaults to the user's
398
+ * phone. It may match the user's phone but not another SMS factor.
399
+ */
400
+ phone?: Phone;
382
401
  }
383
402
  interface UnenrollFactorParams extends Nonce {
384
403
  id: string;
@@ -471,11 +490,6 @@ interface ChangePasswordParams extends Nonce {
471
490
  password: string;
472
491
  new_password: string;
473
492
  }
474
- interface PlatformInfo {
475
- id: string;
476
- name: string;
477
- slug: string;
478
- }
479
493
  type PaginationSort = 'asc' | 'desc';
480
494
  interface Paginated<T> {
481
495
  items: T[];
@@ -906,6 +920,10 @@ declare class FactorsClient extends AuthSubClient {
906
920
  * the factor on the user's device.
907
921
  *
908
922
  * For TOTP: use `secret` for manual entry or `url` to generate a QR code.
923
+ * For SMS: pass `phone` to send the codes to a number other than the user's.
924
+ *
925
+ * A user holds up to 10 authenticator apps and SMS factors combined, and one
926
+ * email factor and one set of recovery codes.
909
927
  *
910
928
  * After the user configures their device, call `enable` with the `token` and
911
929
  * the first OTP code to activate the factor.
@@ -1142,10 +1160,14 @@ declare class ChallengesClient extends AuthSubClient {
1142
1160
  * Requires an authenticated session. Prompt the user for the code, then call
1143
1161
  * `verify({ token, code })`.
1144
1162
  *
1163
+ * A `totp` challenge accepts a code from any of the user's authenticator
1164
+ * apps. For `sms_otp`, pass `factor_id` to pick which phone receives it.
1165
+ *
1145
1166
  * @example
1146
- * const { data } = await nulvless.auth.challenges.create('totp')
1167
+ * const { data } = await nulvless.auth.challenges.create({ type: 'totp' })
1168
+ * const { data: sms } = await nulvless.auth.challenges.create({ type: 'sms_otp', factor_id })
1147
1169
  */
1148
- create(targetType: MFAMethod, options?: RequestOptions): Promise<NulvlessResult<{
1170
+ create(params: CreateChallengeParams, options?: RequestOptions): Promise<NulvlessResult<{
1149
1171
  challenge: Challenge;
1150
1172
  }>>;
1151
1173
  /**
@@ -1263,8 +1285,7 @@ declare class OAuthGrantsClient extends AuthSubClient {
1263
1285
  * The project's OAuth 2.1 / OpenID Connect provider surface — the project
1264
1286
  * acting as an identity provider for third-party applications.
1265
1287
  *
1266
- * Available with both public (`pk_`) and private (`sk_`) keys
1267
- * (`@SetPlatformGuardRoles([PUBLIC, PRIVATE])`).
1288
+ * Available with both public (`pk_`) and private (`sk_`) keys.
1268
1289
  *
1269
1290
  * Method scopes:
1270
1291
  * - `token`, `register` — platform key only (no bearer token).
@@ -1529,16 +1550,11 @@ declare class AdminClient {
1529
1550
  readonly grants: AdminGrantsClient;
1530
1551
  readonly oauthClients: AdminOAuthClientsClient;
1531
1552
  constructor(http: HttpClient);
1532
- /**
1533
- * Returns basic platform information (id, name, slug).
1534
- */
1535
- getPlatform(options?: RequestOptions): Promise<NulvlessResult<PlatformInfo>>;
1536
1553
  }
1537
1554
 
1538
1555
  interface AccountEntry {
1539
1556
  userId: string;
1540
1557
  access_token: string;
1541
- /** Seconds remaining until the token expires. May be negative if already expired. */
1542
1558
  expires_in: number;
1543
1559
  refresh_token?: string;
1544
1560
  user?: User;
@@ -1587,7 +1603,6 @@ declare class AuthEventEmitter {
1587
1603
 
1588
1604
  /**
1589
1605
  * Auth methods accessible with both public (`pk_`) and private (`sk_`) keys.
1590
- * Corresponds to endpoints decorated with `@SetPlatformGuardRoles([PUBLIC, PRIVATE])`.
1591
1606
  */
1592
1607
  declare class AuthClient {
1593
1608
  protected readonly http: HttpClient;
@@ -2331,4 +2346,4 @@ declare function createClient(url: string, publicKey: string, options?: ClientOp
2331
2346
  */
2332
2347
  declare function createServerClient(url: string, privateKey: string, options?: ServerClientOptions): NulvlessServerClient;
2333
2348
 
2334
- export { AUTH_CACHE_HEADERS, type AccountEntry, type AddEmailIdentityParams, type AddPhoneIdentityParams, AdminClient, type AdminCreateUserParams, type AdminUpdateUserParams, type AssuranceLevel, AuthBrowserClient, AuthClient, type AuthErrorCode, AuthEventEmitter, type AuthEvents, type AuthFactorStatus, type AuthMethod, type AuthMethods, type AuthOptions, AuthServerClient, type Authenticated, type BlockGrantParams, type Challenge, type ChallengeSubject, type ChangeChallengeParams, type ChangePasswordParams, type ClientOptions, CommsClient, type CommsErrorCode, type ConfirmationType, type CreateRoleParams, type CreateTemplateParams, type EdgeFunctionErrorCode, EmailClient, type EnableFactorParams, type EnrollFactorParams, type ErrorCode, type ExchangeOAuthCodeParams, type FactorEnrollment, FactorsClient, type GatewayErrorCode, type Grant, type GrantMembers, type GrantStatus, GrantsClient, HttpClient, type Identity, type IdentityType, type Invite, type InviteParams, type Language, type LeaveGrantParams, type LookupMatch, type LookupParams, type LookupResult, type MFAMethod, type Nonce, type NotificationChannel, NulvlessClient, type NulvlessError, NulvlessException, type NulvlessResult, NulvlessServerClient, type NulvlessStorage, type OAuthApp, type OAuthAppGrantType, type OAuthAppTokenEndpointAuthMethod, type OAuthAppType, type OAuthAuthorization, type OAuthAuthorizeParams, OAuthClient, type OAuthConsentAction, type OAuthConsentResult, type OAuthDiscovery, OAuthGrantsClient, type OAuthJWKS, type OAuthProvider, type OAuthTokenResponse, type OAuthUserGrant, type OAuthUserInfo, type PaginateGrantsParams, type PaginateUsersParams, type Paginated, type PaginatedTemplates, type PaginationSort, type Phone, type PlatformInfo, type RecoverParams, type RefreshOAuthTokenParams, type RefreshTokenParams, type RegisterOAuthAppParams, type RemoveIdentityParams, type RequestOptions, type ResetPasswordParams, type RevokeGrantParams, type RevokeSessionParams, type Role, type SdkErrorCode, SecurityClient, type SendEmailParams, type SendOTPToUpdateEmailParams, type SendOTPToUpdatePhoneParams, type SendSMSParams, type ServerClientOptions, type Session, type SessionFingerPrint, SessionManager, SessionsClient, type SetGrantParams, type SignInMethod, type SignInParams, type SignInWithOTPParams, type SignOutScope, type SignUpParams, SmsClient, Storage, type StoredSession, type SudoMethod, type Template, type TemplateFilters, type TemplateLanguage, TemplatesClient, type TokenType, type UnenrollFactorParams, type UpdateGrantParams, type UpdateIdentityParams, type UpdateOAuthAppParams, type UpdateRoleParams, type UpdateTemplateParams, type User, type UserGender, type UserProfile, UsersClient, type Verified, type VerifyChallengeParams, type VerifyParams, type VerifyReason, applyAuthCacheHeaders, createClient, createServerClient, forwardUserHeaders };
2349
+ export { AUTH_CACHE_HEADERS, type AccountEntry, type AddEmailIdentityParams, type AddPhoneIdentityParams, AdminClient, type AdminCreateUserParams, type AdminUpdateUserParams, type AssuranceLevel, AuthBrowserClient, AuthClient, type AuthErrorCode, AuthEventEmitter, type AuthEvents, type AuthFactorStatus, type AuthMethod, type AuthMethods, type AuthOptions, AuthServerClient, type Authenticated, type BlockGrantParams, type Challenge, type ChallengeSubject, type ChangeChallengeParams, type ChangePasswordParams, type ClientOptions, CommsClient, type CommsErrorCode, type ConfirmationType, type CreateChallengeParams, type CreateRoleParams, type CreateTemplateParams, type EdgeFunctionErrorCode, EmailClient, type EnableFactorParams, type EnrollFactorParams, type ErrorCode, type ExchangeOAuthCodeParams, type FactorEnrollment, FactorsClient, type GatewayErrorCode, type Grant, type GrantMembers, type GrantStatus, GrantsClient, HttpClient, type Identity, type IdentityType, type Invite, type InviteParams, type Language, type LeaveGrantParams, type LookupMatch, type LookupParams, type LookupResult, type MFAMethod, type Nonce, type NotificationChannel, NulvlessClient, type NulvlessError, NulvlessException, type NulvlessResult, NulvlessServerClient, type NulvlessStorage, type OAuthApp, type OAuthAppGrantType, type OAuthAppTokenEndpointAuthMethod, type OAuthAppType, type OAuthAuthorization, type OAuthAuthorizeParams, OAuthClient, type OAuthConsentAction, type OAuthConsentResult, type OAuthDiscovery, OAuthGrantsClient, type OAuthJWKS, type OAuthProvider, type OAuthTokenResponse, type OAuthUserGrant, type OAuthUserInfo, type PaginateGrantsParams, type PaginateUsersParams, type Paginated, type PaginatedTemplates, type PaginationSort, type Phone, type RecoverParams, type RefreshOAuthTokenParams, type RefreshTokenParams, type RegisterOAuthAppParams, type RemoveIdentityParams, type RequestOptions, type ResetPasswordParams, type RevokeGrantParams, type RevokeSessionParams, type Role, type SdkErrorCode, SecurityClient, type SendEmailParams, type SendOTPToUpdateEmailParams, type SendOTPToUpdatePhoneParams, type SendSMSParams, type ServerClientOptions, type Session, type SessionFingerPrint, SessionManager, SessionsClient, type SetGrantParams, type SignInMethod, type SignInParams, type SignInWithOTPParams, type SignOutScope, type SignUpParams, SmsClient, Storage, type StoredSession, type SudoMethod, type Template, type TemplateFilters, type TemplateLanguage, TemplatesClient, type TokenType, type UnenrollFactorParams, type UpdateGrantParams, type UpdateIdentityParams, type UpdateOAuthAppParams, type UpdateRoleParams, type UpdateTemplateParams, type User, type UserGender, type UserProfile, UsersClient, type Verified, type VerifyChallengeParams, type VerifyParams, type VerifyReason, applyAuthCacheHeaders, createClient, createServerClient, forwardUserHeaders };
package/dist/index.mjs CHANGED
@@ -315,6 +315,10 @@ var FactorsClient = class extends AuthSubClient {
315
315
  * the factor on the user's device.
316
316
  *
317
317
  * For TOTP: use `secret` for manual entry or `url` to generate a QR code.
318
+ * For SMS: pass `phone` to send the codes to a number other than the user's.
319
+ *
320
+ * A user holds up to 10 authenticator apps and SMS factors combined, and one
321
+ * email factor and one set of recovery codes.
318
322
  *
319
323
  * After the user configures their device, call `enable` with the `token` and
320
324
  * the first OTP code to activate the factor.
@@ -330,8 +334,9 @@ var FactorsClient = class extends AuthSubClient {
330
334
  async enroll(params, options) {
331
335
  const auth = await this.bearer(options);
332
336
  if (!auth.ok) return { data: null, error: auth.error };
333
- const { nonce, type, name } = params;
334
- return this.http.post(route`/factors/${type}`, name ? { name } : {}, {
337
+ const { nonce, type, name, phone } = params;
338
+ const body = { ...name ? { name } : {}, ...phone ? { phone } : {} };
339
+ return this.http.post(route`/factors/${type}`, body, {
335
340
  ...options,
336
341
  nonce,
337
342
  headers: { ...options?.headers, ...auth.headers }
@@ -377,7 +382,6 @@ var FactorsClient = class extends AuthSubClient {
377
382
 
378
383
  // src/auth/users/index.ts
379
384
  var UsersClient = class extends AuthSubClient {
380
- // ─── Profile ────────────────────────────────────────────────────────────────
381
385
  /**
382
386
  * Returns the authenticated user's full profile.
383
387
  */
@@ -402,7 +406,6 @@ var UsersClient = class extends AuthSubClient {
402
406
  headers: { ...options?.headers, ...auth.headers }
403
407
  });
404
408
  }
405
- // ─── Identities ─────────────────────────────────────────────────────────────
406
409
  /**
407
410
  * Lists all identities (email, phone, OAuth) linked to the authenticated user.
408
411
  *
@@ -493,7 +496,6 @@ var UsersClient = class extends AuthSubClient {
493
496
  headers: { ...options?.headers, ...auth.headers }
494
497
  });
495
498
  }
496
- // ─── Credential updates ──────────────────────────────────────────────────────
497
499
  /**
498
500
  * Sends an OTP to the new email address to initiate an email change.
499
501
  *
@@ -693,14 +695,19 @@ var ChallengesClient = class extends AuthSubClient {
693
695
  * Requires an authenticated session. Prompt the user for the code, then call
694
696
  * `verify({ token, code })`.
695
697
  *
698
+ * A `totp` challenge accepts a code from any of the user's authenticator
699
+ * apps. For `sms_otp`, pass `factor_id` to pick which phone receives it.
700
+ *
696
701
  * @example
697
- * const { data } = await nulvless.auth.challenges.create('totp')
702
+ * const { data } = await nulvless.auth.challenges.create({ type: 'totp' })
703
+ * const { data: sms } = await nulvless.auth.challenges.create({ type: 'sms_otp', factor_id })
698
704
  */
699
- async create(targetType, options) {
705
+ async create(params, options) {
700
706
  const auth = await this.bearer(options);
701
707
  if (!auth.ok) return { data: null, error: auth.error };
702
- return this.http.post(route`/challenges/${targetType}`, void 0, {
708
+ return this.http.post(route`/challenges/${params.type}`, void 0, {
703
709
  ...options,
710
+ ...params.factor_id ? { query: { factor_id: params.factor_id } } : {},
704
711
  headers: { ...options?.headers, ...auth.headers }
705
712
  });
706
713
  }
@@ -720,7 +727,7 @@ var ChallengesClient = class extends AuthSubClient {
720
727
  return this.http.patch(
721
728
  route`/challenges/${params.type}`,
722
729
  { token: params.token },
723
- options
730
+ params.factor_id ? { ...options, query: { factor_id: params.factor_id } } : options
724
731
  );
725
732
  }
726
733
  /**
@@ -920,7 +927,6 @@ var OAuthClient = class extends AuthSubClient {
920
927
  super(http, getToken);
921
928
  this.grants = new OAuthGrantsClient(http, getToken);
922
929
  }
923
- // ─── Authorization redirect (platform key) ──────────────────────────────────
924
930
  /**
925
931
  * Builds the OAuth authorization URL and, in the browser, redirects the user
926
932
  * agent to it. On the server the URL is returned for manual handling.
@@ -965,7 +971,6 @@ var OAuthClient = class extends AuthSubClient {
965
971
  }
966
972
  return { data: { url: url.toString() }, error: null };
967
973
  }
968
- // ─── Token endpoint (public) ────────────────────────────────────────────────
969
974
  /**
970
975
  * Exchanges an authorization code for tokens
971
976
  * (`POST /oauth/token`, `grant_type=authorization_code`).
@@ -995,7 +1000,6 @@ var OAuthClient = class extends AuthSubClient {
995
1000
  { ...options, skipApiKey: true }
996
1001
  );
997
1002
  }
998
- // ─── Dynamic registration (platform key) ────────────────────────────────────
999
1003
  /**
1000
1004
  * Dynamically registers a new OAuth app (RFC 7591, `POST /oauth/register`).
1001
1005
  *
@@ -1005,7 +1009,6 @@ var OAuthClient = class extends AuthSubClient {
1005
1009
  register(params, options) {
1006
1010
  return this.http.post("/oauth/register", params, { ...options, skipApiKey: true });
1007
1011
  }
1008
- // ─── Consent flow (authenticated user) ──────────────────────────────────────
1009
1012
  /**
1010
1013
  * Loads a pending authorization for the consent screen
1011
1014
  * (`GET /oauth/authorizations/:id`).
@@ -1040,7 +1043,6 @@ var OAuthClient = class extends AuthSubClient {
1040
1043
  headers: { ...options?.headers, ...auth.headers }
1041
1044
  });
1042
1045
  }
1043
- // ─── UserInfo (authenticated user) ──────────────────────────────────────────
1044
1046
  /**
1045
1047
  * Returns OIDC UserInfo claims for the access token (`GET /oauth/userinfo`).
1046
1048
  *
@@ -1056,7 +1058,6 @@ var OAuthClient = class extends AuthSubClient {
1056
1058
  headers: { ...options?.headers, ...auth.headers }
1057
1059
  });
1058
1060
  }
1059
- // ─── Public OIDC metadata (no auth) ─────────────────────────────────────────
1060
1061
  /**
1061
1062
  * Returns the OpenID Connect discovery document
1062
1063
  * (`GET /.well-known/openid-configuration`). Public — no auth required.
@@ -1281,12 +1282,6 @@ var AdminClient = class {
1281
1282
  roles;
1282
1283
  grants;
1283
1284
  oauthClients;
1284
- /**
1285
- * Returns basic platform information (id, name, slug).
1286
- */
1287
- getPlatform(options) {
1288
- return this.http.get("/admin/platform", options);
1289
- }
1290
1285
  };
1291
1286
 
1292
1287
  // src/session/stored.ts
@@ -1461,14 +1456,12 @@ var AuthClient = class {
1461
1456
  async getAccessToken() {
1462
1457
  return this.session?.getValidToken() ?? null;
1463
1458
  }
1464
- // ─── Helpers ──────────────────────────────────────────────────────────────
1465
1459
  async persistSession(result) {
1466
1460
  if (!result.error && result.data.access_token && this.session) {
1467
1461
  await this.session.save(result.data);
1468
1462
  }
1469
1463
  return result;
1470
1464
  }
1471
- // ─── Sign-up / Sign-in ─────────────────────────────────────────────────────
1472
1465
  /**
1473
1466
  * Creates a new user account.
1474
1467
  *
@@ -1629,7 +1622,6 @@ var AuthClient = class {
1629
1622
  headers: { ...options?.headers, ...auth.headers }
1630
1623
  });
1631
1624
  }
1632
- // ─── Challenge ─────────────────────────────────────────────────────────────
1633
1625
  /**
1634
1626
  * Looks up whether an identifier exists and which sign-in method applies.
1635
1627
  *
@@ -1656,7 +1648,6 @@ var AuthClient = class {
1656
1648
  async verifyChallenge(params, options) {
1657
1649
  return this.challenges.verify(params, options);
1658
1650
  }
1659
- // ─── Account lifecycle ─────────────────────────────────────────────────────
1660
1651
  /**
1661
1652
  * Activates an account via the confirmation link sent to the user's email/phone.
1662
1653
  */
@@ -1690,7 +1681,6 @@ var AuthClient = class {
1690
1681
  resetPassword(params, options) {
1691
1682
  return this.http.post("/recover/reset-password", params, options);
1692
1683
  }
1693
- // ─── Session ───────────────────────────────────────────────────────────────
1694
1684
  /**
1695
1685
  * Validates the current session and optionally checks a grant.
1696
1686
  *
@@ -1809,7 +1799,6 @@ var AuthBrowserClient = class extends AuthClient {
1809
1799
  on(event, handler) {
1810
1800
  return this.emitter.on(event, handler);
1811
1801
  }
1812
- // ─── Session persistence override ─────────────────────────────────────────
1813
1802
  async persistSession(result) {
1814
1803
  const out = await super.persistSession(result);
1815
1804
  if (!out.error) {
@@ -1824,7 +1813,6 @@ var AuthBrowserClient = class extends AuthClient {
1824
1813
  }
1825
1814
  return out;
1826
1815
  }
1827
- // ─── Active session helpers ────────────────────────────────────────────────
1828
1816
  /**
1829
1817
  * Returns the session currently stored in storage, or `null` if there is none.
1830
1818
  *
@@ -1856,7 +1844,6 @@ var AuthBrowserClient = class extends AuthClient {
1856
1844
  await this.session?.save(data);
1857
1845
  }
1858
1846
  }
1859
- // ─── Multi-account ─────────────────────────────────────────────────────────
1860
1847
  /**
1861
1848
  * Adds an account to the accounts store without switching the active session.
1862
1849
  *
@@ -1935,7 +1922,6 @@ var AuthBrowserClient = class extends AuthClient {
1935
1922
  }
1936
1923
  await this.session?.clear();
1937
1924
  }
1938
- // ─── signOut override ──────────────────────────────────────────────────────
1939
1925
  async signOut(scope, options) {
1940
1926
  const stored = await this.session?.get();
1941
1927
  const userId = stored ? stored.user?.id ?? extractUserId({ access_token: stored.access_token }) : null;
@@ -2457,7 +2443,7 @@ var NulvlessServerClient = class {
2457
2443
  constructor(baseUrl, privateKey, options) {
2458
2444
  const base = baseUrl.replace(/\/+$/, "");
2459
2445
  this.auth = new AuthServerClient(new HttpClient({ baseUrl: `${base}/auth`, apiKey: privateKey, ...options }));
2460
- this.comms = new CommsClient(new HttpClient({ baseUrl: `${base}/notifications`, apiKey: privateKey, ...options }));
2446
+ this.comms = new CommsClient(new HttpClient({ baseUrl: `${base}/comms`, apiKey: privateKey, ...options }));
2461
2447
  }
2462
2448
  };
2463
2449