@nulvless/nulvless-js 0.1.1 → 0.1.4

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,3 +1,10 @@
1
+ type SdkErrorCode = 'no_session' | 'request_timeout' | 'network_error' | 'invalid_path' | 'unknown_error';
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';
4
+ type CommsErrorCode = 'unauthorized_platform' | 'rate_limit_exceeded';
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
+ type ErrorCode = SdkErrorCode | GatewayErrorCode | AuthErrorCode | CommsErrorCode | (string & {});
7
+
1
8
  /**
2
9
  * Storage adapter interface used by the SDK to persist session tokens.
3
10
  *
@@ -18,7 +25,7 @@ interface Phone {
18
25
  number: string;
19
26
  }
20
27
  interface NulvlessError {
21
- code: string;
28
+ code: ErrorCode;
22
29
  message: string | string[];
23
30
  status_code: number;
24
31
  }
@@ -261,6 +268,7 @@ interface User {
261
268
  last_sign_in_at?: string;
262
269
  identities?: Identity[];
263
270
  metadata?: Record<string, string | number>;
271
+ password_enabled?: boolean;
264
272
  created_at?: string;
265
273
  updated_at?: string;
266
274
  }
@@ -314,14 +322,14 @@ type ChallengeSubject = 'sign_in_with_otp' | 'verify_pending_user' | 'sign_up' |
314
322
  /** Methods accepted to elevate a session to sudo. Subset of `MFAMethod`. */
315
323
  type SudoMethod = 'totp' | 'email_otp' | 'sms_otp';
316
324
  interface Challenge {
317
- /** MFA method to present first to the user. */
318
- preferred: MFAMethod;
325
+ /** Method to present first to the user; `link` means a confirmation link was sent and there is no code to enter. */
326
+ preferred: MFAMethod | 'link';
319
327
  /** Masked identifier shown to the user — e.g. "u***@example.com". */
320
328
  identifier?: string;
321
329
  factors: AuthMethod[];
322
330
  subject: ChallengeSubject;
323
- /** Short-lived token used to continue the challenge flow. */
324
- token: string;
331
+ /** Short-lived token used to continue the challenge flow; `null` when there is nothing to continue, as with a link. */
332
+ token: string | null;
325
333
  expires_in: number;
326
334
  }
327
335
  interface VerifyChallengeParams {
@@ -2132,9 +2140,9 @@ declare class NulvlessServerClient {
2132
2140
  * }
2133
2141
  */
2134
2142
  declare class NulvlessException extends Error {
2135
- readonly code: string;
2143
+ readonly code: ErrorCode;
2136
2144
  readonly status_code: number;
2137
- constructor(message: string | string[], code: string, status_code: number);
2145
+ constructor(message: string | string[], code: ErrorCode, status_code: number);
2138
2146
  }
2139
2147
 
2140
2148
  /** Persists in `localStorage`. Data survives page reloads and browser restarts. */
@@ -2323,4 +2331,4 @@ declare function createClient(url: string, publicKey: string, options?: ClientOp
2323
2331
  */
2324
2332
  declare function createServerClient(url: string, privateKey: string, options?: ServerClientOptions): NulvlessServerClient;
2325
2333
 
2326
- export { AUTH_CACHE_HEADERS, type AccountEntry, type AddEmailIdentityParams, type AddPhoneIdentityParams, AdminClient, type AdminCreateUserParams, type AdminUpdateUserParams, type AssuranceLevel, AuthBrowserClient, AuthClient, 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 ConfirmationType, type CreateRoleParams, type CreateTemplateParams, EmailClient, type EnableFactorParams, type EnrollFactorParams, type ExchangeOAuthCodeParams, type FactorEnrollment, FactorsClient, 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, 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 };
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 };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,10 @@
1
+ type SdkErrorCode = 'no_session' | 'request_timeout' | 'network_error' | 'invalid_path' | 'unknown_error';
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';
4
+ type CommsErrorCode = 'unauthorized_platform' | 'rate_limit_exceeded';
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
+ type ErrorCode = SdkErrorCode | GatewayErrorCode | AuthErrorCode | CommsErrorCode | (string & {});
7
+
1
8
  /**
2
9
  * Storage adapter interface used by the SDK to persist session tokens.
3
10
  *
@@ -18,7 +25,7 @@ interface Phone {
18
25
  number: string;
19
26
  }
20
27
  interface NulvlessError {
21
- code: string;
28
+ code: ErrorCode;
22
29
  message: string | string[];
23
30
  status_code: number;
24
31
  }
@@ -261,6 +268,7 @@ interface User {
261
268
  last_sign_in_at?: string;
262
269
  identities?: Identity[];
263
270
  metadata?: Record<string, string | number>;
271
+ password_enabled?: boolean;
264
272
  created_at?: string;
265
273
  updated_at?: string;
266
274
  }
@@ -314,14 +322,14 @@ type ChallengeSubject = 'sign_in_with_otp' | 'verify_pending_user' | 'sign_up' |
314
322
  /** Methods accepted to elevate a session to sudo. Subset of `MFAMethod`. */
315
323
  type SudoMethod = 'totp' | 'email_otp' | 'sms_otp';
316
324
  interface Challenge {
317
- /** MFA method to present first to the user. */
318
- preferred: MFAMethod;
325
+ /** Method to present first to the user; `link` means a confirmation link was sent and there is no code to enter. */
326
+ preferred: MFAMethod | 'link';
319
327
  /** Masked identifier shown to the user — e.g. "u***@example.com". */
320
328
  identifier?: string;
321
329
  factors: AuthMethod[];
322
330
  subject: ChallengeSubject;
323
- /** Short-lived token used to continue the challenge flow. */
324
- token: string;
331
+ /** Short-lived token used to continue the challenge flow; `null` when there is nothing to continue, as with a link. */
332
+ token: string | null;
325
333
  expires_in: number;
326
334
  }
327
335
  interface VerifyChallengeParams {
@@ -2132,9 +2140,9 @@ declare class NulvlessServerClient {
2132
2140
  * }
2133
2141
  */
2134
2142
  declare class NulvlessException extends Error {
2135
- readonly code: string;
2143
+ readonly code: ErrorCode;
2136
2144
  readonly status_code: number;
2137
- constructor(message: string | string[], code: string, status_code: number);
2145
+ constructor(message: string | string[], code: ErrorCode, status_code: number);
2138
2146
  }
2139
2147
 
2140
2148
  /** Persists in `localStorage`. Data survives page reloads and browser restarts. */
@@ -2323,4 +2331,4 @@ declare function createClient(url: string, publicKey: string, options?: ClientOp
2323
2331
  */
2324
2332
  declare function createServerClient(url: string, privateKey: string, options?: ServerClientOptions): NulvlessServerClient;
2325
2333
 
2326
- export { AUTH_CACHE_HEADERS, type AccountEntry, type AddEmailIdentityParams, type AddPhoneIdentityParams, AdminClient, type AdminCreateUserParams, type AdminUpdateUserParams, type AssuranceLevel, AuthBrowserClient, AuthClient, 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 ConfirmationType, type CreateRoleParams, type CreateTemplateParams, EmailClient, type EnableFactorParams, type EnrollFactorParams, type ExchangeOAuthCodeParams, type FactorEnrollment, FactorsClient, 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, 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 };
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 };