@techelusive/nest-auth 0.0.0-stage → 0.2.1
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/CHANGELOG.md +71 -0
- package/LICENSE +21 -0
- package/README.md +204 -2
- package/api/openapi.json +4399 -0
- package/api/techelusive-authentication.postman_collection.json +3178 -0
- package/dist/auth-options.d.ts +156 -0
- package/dist/auth-options.js +3 -0
- package/dist/auth-options.js.map +1 -0
- package/dist/auth-options.validation.d.ts +9 -0
- package/dist/auth-options.validation.js +74 -0
- package/dist/auth-options.validation.js.map +1 -0
- package/dist/auth.module.d.ts +38 -0
- package/dist/auth.module.js +173 -0
- package/dist/auth.module.js.map +1 -0
- package/dist/common/auth-error.d.ts +16 -0
- package/dist/common/auth-error.js +23 -0
- package/dist/common/auth-error.js.map +1 -0
- package/dist/common/auth-exception.filter.d.ts +24 -0
- package/dist/common/auth-exception.filter.js +66 -0
- package/dist/common/auth-exception.filter.js.map +1 -0
- package/dist/common/crypto/jwt.d.ts +89 -0
- package/dist/common/crypto/jwt.js +144 -0
- package/dist/common/crypto/jwt.js.map +1 -0
- package/dist/common/crypto/random-secrets.d.ts +78 -0
- package/dist/common/crypto/random-secrets.js +113 -0
- package/dist/common/crypto/random-secrets.js.map +1 -0
- package/dist/common/crypto/remote-public-keys.d.ts +49 -0
- package/dist/common/crypto/remote-public-keys.js +105 -0
- package/dist/common/crypto/remote-public-keys.js.map +1 -0
- package/dist/common/crypto/totp.d.ts +68 -0
- package/dist/common/crypto/totp.js +148 -0
- package/dist/common/crypto/totp.js.map +1 -0
- package/dist/common/encryption.service.d.ts +36 -0
- package/dist/common/encryption.service.js +111 -0
- package/dist/common/encryption.service.js.map +1 -0
- package/dist/common/identifiers.d.ts +48 -0
- package/dist/common/identifiers.js +89 -0
- package/dist/common/identifiers.js.map +1 -0
- package/dist/common/network-safety.d.ts +19 -0
- package/dist/common/network-safety.js +72 -0
- package/dist/common/network-safety.js.map +1 -0
- package/dist/common/rate-limiter.service.d.ts +63 -0
- package/dist/common/rate-limiter.service.js +158 -0
- package/dist/common/rate-limiter.service.js.map +1 -0
- package/dist/common/refresh-token-cookie.d.ts +78 -0
- package/dist/common/refresh-token-cookie.js +185 -0
- package/dist/common/refresh-token-cookie.js.map +1 -0
- package/dist/common/request-context.d.ts +14 -0
- package/dist/common/request-context.js +22 -0
- package/dist/common/request-context.js.map +1 -0
- package/dist/common/strict-validation.pipe.d.ts +8 -0
- package/dist/common/strict-validation.pipe.js +16 -0
- package/dist/common/strict-validation.pipe.js.map +1 -0
- package/dist/common/time.d.ts +15 -0
- package/dist/common/time.js +34 -0
- package/dist/common/time.js.map +1 -0
- package/dist/constants.d.ts +1326 -0
- package/dist/constants.js +1142 -0
- package/dist/constants.js.map +1 -0
- package/dist/database/create-auth-tables.migration.d.ts +26 -0
- package/dist/database/create-auth-tables.migration.js +291 -0
- package/dist/database/create-auth-tables.migration.js.map +1 -0
- package/dist/database/email-change-and-retention.migration.d.ts +25 -0
- package/dist/database/email-change-and-retention.migration.js +54 -0
- package/dist/database/email-change-and-retention.migration.js.map +1 -0
- package/dist/database/entities/api-key.entity.d.ts +17 -0
- package/dist/database/entities/api-key.entity.js +80 -0
- package/dist/database/entities/api-key.entity.js.map +1 -0
- package/dist/database/entities/audit-log.entity.d.ts +13 -0
- package/dist/database/entities/audit-log.entity.js +64 -0
- package/dist/database/entities/audit-log.entity.js.map +1 -0
- package/dist/database/entities/backup-code.entity.d.ts +9 -0
- package/dist/database/entities/backup-code.entity.js +52 -0
- package/dist/database/entities/backup-code.entity.js.map +1 -0
- package/dist/database/entities/index.d.ts +43 -0
- package/dist/database/entities/index.js +82 -0
- package/dist/database/entities/index.js.map +1 -0
- package/dist/database/entities/json-object.d.ts +12 -0
- package/dist/database/entities/json-object.js +3 -0
- package/dist/database/entities/json-object.js.map +1 -0
- package/dist/database/entities/link-token.entity.d.ts +15 -0
- package/dist/database/entities/link-token.entity.js +64 -0
- package/dist/database/entities/link-token.entity.js.map +1 -0
- package/dist/database/entities/one-time-code.entity.d.ts +16 -0
- package/dist/database/entities/one-time-code.entity.js +69 -0
- package/dist/database/entities/one-time-code.entity.js.map +1 -0
- package/dist/database/entities/organization-invitation.entity.d.ts +14 -0
- package/dist/database/entities/organization-invitation.entity.js +73 -0
- package/dist/database/entities/organization-invitation.entity.js.map +1 -0
- package/dist/database/entities/organization-member.entity.d.ts +9 -0
- package/dist/database/entities/organization-member.entity.js +48 -0
- package/dist/database/entities/organization-member.entity.js.map +1 -0
- package/dist/database/entities/organization.entity.d.ts +12 -0
- package/dist/database/entities/organization.entity.js +58 -0
- package/dist/database/entities/organization.entity.js.map +1 -0
- package/dist/database/entities/passkey.entity.d.ts +19 -0
- package/dist/database/entities/passkey.entity.js +78 -0
- package/dist/database/entities/passkey.entity.js.map +1 -0
- package/dist/database/entities/password.entity.d.ts +6 -0
- package/dist/database/entities/password.entity.js +36 -0
- package/dist/database/entities/password.entity.js.map +1 -0
- package/dist/database/entities/refresh-token.entity.d.ts +9 -0
- package/dist/database/entities/refresh-token.entity.js +53 -0
- package/dist/database/entities/refresh-token.entity.js.map +1 -0
- package/dist/database/entities/session.entity.d.ts +20 -0
- package/dist/database/entities/session.entity.js +87 -0
- package/dist/database/entities/session.entity.js.map +1 -0
- package/dist/database/entities/settings.entity.d.ts +7 -0
- package/dist/database/entities/settings.entity.js +41 -0
- package/dist/database/entities/settings.entity.js.map +1 -0
- package/dist/database/entities/sign-in-challenge.entity.d.ts +23 -0
- package/dist/database/entities/sign-in-challenge.entity.js +80 -0
- package/dist/database/entities/sign-in-challenge.entity.js.map +1 -0
- package/dist/database/entities/signing-key.entity.d.ts +11 -0
- package/dist/database/entities/signing-key.entity.js +54 -0
- package/dist/database/entities/signing-key.entity.js.map +1 -0
- package/dist/database/entities/social-account.entity.d.ts +13 -0
- package/dist/database/entities/social-account.entity.js +54 -0
- package/dist/database/entities/social-account.entity.js.map +1 -0
- package/dist/database/entities/two-factor-secret.entity.d.ts +10 -0
- package/dist/database/entities/two-factor-secret.entity.js +48 -0
- package/dist/database/entities/two-factor-secret.entity.js.map +1 -0
- package/dist/database/entities/user.entity.d.ts +34 -0
- package/dist/database/entities/user.entity.js +129 -0
- package/dist/database/entities/user.entity.js.map +1 -0
- package/dist/database/entities/webhook-delivery.entity.d.ts +17 -0
- package/dist/database/entities/webhook-delivery.entity.js +79 -0
- package/dist/database/entities/webhook-delivery.entity.js.map +1 -0
- package/dist/database/entities/webhook.entity.d.ts +12 -0
- package/dist/database/entities/webhook.entity.js +58 -0
- package/dist/database/entities/webhook.entity.js.map +1 -0
- package/dist/database/typeorm-row.d.ts +21 -0
- package/dist/database/typeorm-row.js +29 -0
- package/dist/database/typeorm-row.js.map +1 -0
- package/dist/features/account/account.controller.d.ts +259 -0
- package/dist/features/account/account.controller.js +372 -0
- package/dist/features/account/account.controller.js.map +1 -0
- package/dist/features/account/account.dto.d.ts +16 -0
- package/dist/features/account/account.dto.js +61 -0
- package/dist/features/account/account.dto.js.map +1 -0
- package/dist/features/account/data-export.service.d.ts +85 -0
- package/dist/features/account/data-export.service.js +125 -0
- package/dist/features/account/data-export.service.js.map +1 -0
- package/dist/features/account/health.service.d.ts +30 -0
- package/dist/features/account/health.service.js +59 -0
- package/dist/features/account/health.service.js.map +1 -0
- package/dist/features/admin/admin.controller.d.ts +382 -0
- package/dist/features/admin/admin.controller.js +623 -0
- package/dist/features/admin/admin.controller.js.map +1 -0
- package/dist/features/admin/admin.dto.d.ts +61 -0
- package/dist/features/admin/admin.dto.js +253 -0
- package/dist/features/admin/admin.dto.js.map +1 -0
- package/dist/features/admin/admin.service.d.ts +142 -0
- package/dist/features/admin/admin.service.js +227 -0
- package/dist/features/admin/admin.service.js.map +1 -0
- package/dist/features/api-keys/api-keys.service.d.ts +67 -0
- package/dist/features/api-keys/api-keys.service.js +144 -0
- package/dist/features/api-keys/api-keys.service.js.map +1 -0
- package/dist/features/email-change/email-change.controller.d.ts +38 -0
- package/dist/features/email-change/email-change.controller.js +85 -0
- package/dist/features/email-change/email-change.controller.js.map +1 -0
- package/dist/features/email-change/email-change.dto.d.ts +10 -0
- package/dist/features/email-change/email-change.dto.js +43 -0
- package/dist/features/email-change/email-change.dto.js.map +1 -0
- package/dist/features/email-change/email-change.service.d.ts +74 -0
- package/dist/features/email-change/email-change.service.js +179 -0
- package/dist/features/email-change/email-change.service.js.map +1 -0
- package/dist/features/email-links/email-verification.service.d.ts +46 -0
- package/dist/features/email-links/email-verification.service.js +94 -0
- package/dist/features/email-links/email-verification.service.js.map +1 -0
- package/dist/features/email-links/link-tokens.service.d.ts +44 -0
- package/dist/features/email-links/link-tokens.service.js +122 -0
- package/dist/features/email-links/link-tokens.service.js.map +1 -0
- package/dist/features/events/auth-events.service.d.ts +52 -0
- package/dist/features/events/auth-events.service.js +117 -0
- package/dist/features/events/auth-events.service.js.map +1 -0
- package/dist/features/maintenance/data-retention.service.d.ts +60 -0
- package/dist/features/maintenance/data-retention.service.js +182 -0
- package/dist/features/maintenance/data-retention.service.js.map +1 -0
- package/dist/features/notifications/notifications.service.d.ts +40 -0
- package/dist/features/notifications/notifications.service.js +94 -0
- package/dist/features/notifications/notifications.service.js.map +1 -0
- package/dist/features/one-time-codes/one-time-codes.service.d.ts +40 -0
- package/dist/features/one-time-codes/one-time-codes.service.js +102 -0
- package/dist/features/one-time-codes/one-time-codes.service.js.map +1 -0
- package/dist/features/organizations/organizations.controller.d.ts +220 -0
- package/dist/features/organizations/organizations.controller.js +337 -0
- package/dist/features/organizations/organizations.controller.js.map +1 -0
- package/dist/features/organizations/organizations.dto.d.ts +31 -0
- package/dist/features/organizations/organizations.dto.js +100 -0
- package/dist/features/organizations/organizations.dto.js.map +1 -0
- package/dist/features/organizations/organizations.service.d.ts +274 -0
- package/dist/features/organizations/organizations.service.js +481 -0
- package/dist/features/organizations/organizations.service.js.map +1 -0
- package/dist/features/passkeys/passkeys.controller.d.ts +92 -0
- package/dist/features/passkeys/passkeys.controller.js +183 -0
- package/dist/features/passkeys/passkeys.controller.js.map +1 -0
- package/dist/features/passkeys/passkeys.dto.d.ts +13 -0
- package/dist/features/passkeys/passkeys.dto.js +50 -0
- package/dist/features/passkeys/passkeys.dto.js.map +1 -0
- package/dist/features/passkeys/passkeys.service.d.ts +159 -0
- package/dist/features/passkeys/passkeys.service.js +350 -0
- package/dist/features/passkeys/passkeys.service.js.map +1 -0
- package/dist/features/passwordless/passwordless-auth.service.d.ts +152 -0
- package/dist/features/passwordless/passwordless-auth.service.js +304 -0
- package/dist/features/passwordless/passwordless-auth.service.js.map +1 -0
- package/dist/features/passwordless/passwordless.controller.d.ts +75 -0
- package/dist/features/passwordless/passwordless.controller.js +163 -0
- package/dist/features/passwordless/passwordless.controller.js.map +1 -0
- package/dist/features/passwordless/passwordless.dto.d.ts +29 -0
- package/dist/features/passwordless/passwordless.dto.js +101 -0
- package/dist/features/passwordless/passwordless.dto.js.map +1 -0
- package/dist/features/passwords/password-auth.service.d.ts +154 -0
- package/dist/features/passwords/password-auth.service.js +317 -0
- package/dist/features/passwords/password-auth.service.js.map +1 -0
- package/dist/features/passwords/password-policy.service.d.ts +63 -0
- package/dist/features/passwords/password-policy.service.js +175 -0
- package/dist/features/passwords/password-policy.service.js.map +1 -0
- package/dist/features/passwords/password.controller.d.ts +95 -0
- package/dist/features/passwords/password.controller.js +193 -0
- package/dist/features/passwords/password.controller.js.map +1 -0
- package/dist/features/passwords/password.dto.d.ts +36 -0
- package/dist/features/passwords/password.dto.js +140 -0
- package/dist/features/passwords/password.dto.js.map +1 -0
- package/dist/features/sessions/session.service.d.ts +132 -0
- package/dist/features/sessions/session.service.js +308 -0
- package/dist/features/sessions/session.service.js.map +1 -0
- package/dist/features/sessions/session.types.d.ts +34 -0
- package/dist/features/sessions/session.types.js +3 -0
- package/dist/features/sessions/session.types.js.map +1 -0
- package/dist/features/settings/settings.defaults.d.ts +2 -0
- package/dist/features/settings/settings.defaults.js +7 -0
- package/dist/features/settings/settings.defaults.js.map +1 -0
- package/dist/features/settings/settings.service.d.ts +44 -0
- package/dist/features/settings/settings.service.js +112 -0
- package/dist/features/settings/settings.service.js.map +1 -0
- package/dist/features/settings/settings.types.d.ts +133 -0
- package/dist/features/settings/settings.types.js +3 -0
- package/dist/features/settings/settings.types.js.map +1 -0
- package/dist/features/settings/settings.validation.d.ts +33 -0
- package/dist/features/settings/settings.validation.js +614 -0
- package/dist/features/settings/settings.validation.js.map +1 -0
- package/dist/features/sign-in/sign-in-challenges.service.d.ts +54 -0
- package/dist/features/sign-in/sign-in-challenges.service.js +104 -0
- package/dist/features/sign-in/sign-in-challenges.service.js.map +1 -0
- package/dist/features/sign-in/sign-in.service.d.ts +127 -0
- package/dist/features/sign-in/sign-in.service.js +248 -0
- package/dist/features/sign-in/sign-in.service.js.map +1 -0
- package/dist/features/sign-in/sign-in.types.d.ts +22 -0
- package/dist/features/sign-in/sign-in.types.js +3 -0
- package/dist/features/sign-in/sign-in.types.js.map +1 -0
- package/dist/features/signing-keys/jwks.controller.d.ts +17 -0
- package/dist/features/signing-keys/jwks.controller.js +51 -0
- package/dist/features/signing-keys/jwks.controller.js.map +1 -0
- package/dist/features/signing-keys/signing-keys.service.d.ts +67 -0
- package/dist/features/signing-keys/signing-keys.service.js +142 -0
- package/dist/features/signing-keys/signing-keys.service.js.map +1 -0
- package/dist/features/social/social-auth.service.d.ts +100 -0
- package/dist/features/social/social-auth.service.js +232 -0
- package/dist/features/social/social-auth.service.js.map +1 -0
- package/dist/features/social/social-providers.service.d.ts +97 -0
- package/dist/features/social/social-providers.service.js +214 -0
- package/dist/features/social/social-providers.service.js.map +1 -0
- package/dist/features/social/social.controller.d.ts +54 -0
- package/dist/features/social/social.controller.js +124 -0
- package/dist/features/social/social.controller.js.map +1 -0
- package/dist/features/social/social.dto.d.ts +11 -0
- package/dist/features/social/social.dto.js +38 -0
- package/dist/features/social/social.dto.js.map +1 -0
- package/dist/features/two-factor/two-factor.controller.d.ts +84 -0
- package/dist/features/two-factor/two-factor.controller.js +174 -0
- package/dist/features/two-factor/two-factor.controller.js.map +1 -0
- package/dist/features/two-factor/two-factor.dto.d.ts +10 -0
- package/dist/features/two-factor/two-factor.dto.js +37 -0
- package/dist/features/two-factor/two-factor.dto.js.map +1 -0
- package/dist/features/two-factor/two-factor.service.d.ts +171 -0
- package/dist/features/two-factor/two-factor.service.js +348 -0
- package/dist/features/two-factor/two-factor.service.js.map +1 -0
- package/dist/features/users/sign-in-methods.service.d.ts +40 -0
- package/dist/features/users/sign-in-methods.service.js +81 -0
- package/dist/features/users/sign-in-methods.service.js.map +1 -0
- package/dist/features/users/sign-up-rules.d.ts +12 -0
- package/dist/features/users/sign-up-rules.js +29 -0
- package/dist/features/users/sign-up-rules.js.map +1 -0
- package/dist/features/users/users.service.d.ts +246 -0
- package/dist/features/users/users.service.js +509 -0
- package/dist/features/users/users.service.js.map +1 -0
- package/dist/features/users/users.types.d.ts +24 -0
- package/dist/features/users/users.types.js +3 -0
- package/dist/features/users/users.types.js.map +1 -0
- package/dist/features/webhooks/webhook-delivery.worker.d.ts +55 -0
- package/dist/features/webhooks/webhook-delivery.worker.js +175 -0
- package/dist/features/webhooks/webhook-delivery.worker.js.map +1 -0
- package/dist/features/webhooks/webhook-signature.d.ts +28 -0
- package/dist/features/webhooks/webhook-signature.js +85 -0
- package/dist/features/webhooks/webhook-signature.js.map +1 -0
- package/dist/features/webhooks/webhooks.service.d.ts +144 -0
- package/dist/features/webhooks/webhooks.service.js +238 -0
- package/dist/features/webhooks/webhooks.service.js.map +1 -0
- package/dist/guards/auth.decorators.d.ts +65 -0
- package/dist/guards/auth.decorators.js +68 -0
- package/dist/guards/auth.decorators.js.map +1 -0
- package/dist/guards/auth.guard.d.ts +47 -0
- package/dist/guards/auth.guard.js +132 -0
- package/dist/guards/auth.guard.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +95 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/console-email-sender.d.ts +15 -0
- package/dist/integrations/console-email-sender.js +26 -0
- package/dist/integrations/console-email-sender.js.map +1 -0
- package/dist/integrations/msg91-sms-sender.d.ts +28 -0
- package/dist/integrations/msg91-sms-sender.js +46 -0
- package/dist/integrations/msg91-sms-sender.js.map +1 -0
- package/docs/README.md +39 -0
- package/docs/admin-api-keys-webhooks.md +147 -0
- package/docs/api-reference.md +175 -0
- package/docs/architecture.md +119 -0
- package/docs/client-integration.md +192 -0
- package/docs/code-walkthrough.md +273 -0
- package/docs/configuration.md +229 -0
- package/docs/endpoints/README.md +151 -0
- package/docs/endpoints/account.md +363 -0
- package/docs/endpoints/admin.md +422 -0
- package/docs/endpoints/email-password.md +261 -0
- package/docs/endpoints/organizations.md +192 -0
- package/docs/endpoints/passkeys.md +195 -0
- package/docs/endpoints/passwordless.md +214 -0
- package/docs/endpoints/social.md +116 -0
- package/docs/endpoints/two-factor.md +146 -0
- package/docs/error-codes.md +100 -0
- package/docs/events.md +83 -0
- package/docs/getting-started.md +139 -0
- package/docs/manual-testing.md +215 -0
- package/docs/organizations.md +86 -0
- package/docs/production-checklist.md +60 -0
- package/docs/protecting-routes.md +147 -0
- package/docs/security.md +61 -0
- package/docs/sign-in-flows.md +294 -0
- package/package.json +92 -4
|
@@ -0,0 +1,1326 @@
|
|
|
1
|
+
import type { AuthSettings } from './features/settings/settings.types';
|
|
2
|
+
/**
|
|
3
|
+
* Every fixed number, name and limit used by the library lives in this file.
|
|
4
|
+
*
|
|
5
|
+
* Values that an app may want to change at runtime (password length, token lifetimes, which
|
|
6
|
+
* sign-in methods are on) are NOT here: they are settings, see `features/settings/settings.defaults.ts`.
|
|
7
|
+
* What stays here are security limits that should only change with a code review.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SECOND_IN_MILLISECONDS = 1000;
|
|
10
|
+
export declare const MINUTE_IN_SECONDS = 60;
|
|
11
|
+
export declare const HOUR_IN_SECONDS: number;
|
|
12
|
+
export declare const DAY_IN_SECONDS: number;
|
|
13
|
+
/** Postgres error code for "a unique index would be broken", e.g. an email that is already used. */
|
|
14
|
+
export declare const POSTGRES_UNIQUE_VIOLATION_CODE = "23505";
|
|
15
|
+
/** Size of the development-only local encryption key (AES-256). */
|
|
16
|
+
export declare const LOCAL_ENCRYPTION_KEY_BYTES = 32;
|
|
17
|
+
/** AES-GCM: 12-byte random IV per value, 16-byte authentication tag. */
|
|
18
|
+
export declare const AES_GCM_INITIALIZATION_VECTOR_BYTES = 12;
|
|
19
|
+
export declare const AES_GCM_AUTH_TAG_BYTES = 16;
|
|
20
|
+
export declare const AUTH_OPTIONS_TOKEN = "TECHELUSIVE_AUTH_OPTIONS";
|
|
21
|
+
export declare const TOKEN_PREFIX: {
|
|
22
|
+
readonly refreshToken: "rt";
|
|
23
|
+
readonly emailVerificationLink: "ev";
|
|
24
|
+
readonly passwordResetLink: "pr";
|
|
25
|
+
readonly magicSignInLink: "ml";
|
|
26
|
+
readonly emailChangeLink: "ec";
|
|
27
|
+
readonly organizationInvitation: "oi";
|
|
28
|
+
readonly signInChallenge: "ch";
|
|
29
|
+
readonly apiKey: "ak";
|
|
30
|
+
};
|
|
31
|
+
export type TokenPrefix = (typeof TOKEN_PREFIX)[keyof typeof TOKEN_PREFIX];
|
|
32
|
+
/** Random bytes in every token above: 32 bytes = 256 bits, impossible to guess. */
|
|
33
|
+
export declare const RANDOM_TOKEN_BYTES = 32;
|
|
34
|
+
/** Access tokens use the JWT "typ" from RFC 9068, so an access token can't be confused with other JWTs. */
|
|
35
|
+
export declare const ACCESS_TOKEN_JWT_TYPE = "at+jwt";
|
|
36
|
+
/** The only algorithm we sign with: ECDSA P-256 + SHA-256. */
|
|
37
|
+
/** JWT signature algorithms: ES256 for our own tokens, RS256 for Google and Apple ID tokens. */
|
|
38
|
+
export declare const JWT_ALGORITHM: {
|
|
39
|
+
readonly es256: "ES256";
|
|
40
|
+
readonly rs256: "RS256";
|
|
41
|
+
};
|
|
42
|
+
export type JwtAlgorithm = (typeof JWT_ALGORITHM)[keyof typeof JWT_ALGORITHM];
|
|
43
|
+
export declare const SIGNING_ALGORITHM: "ES256";
|
|
44
|
+
/** Algorithm Google and Apple sign their ID tokens with. */
|
|
45
|
+
export declare const PROVIDER_ID_TOKEN_ALGORITHM: "RS256";
|
|
46
|
+
/** Allowed difference between our clock and the token's timestamps. */
|
|
47
|
+
export declare const CLOCK_SKEW_TOLERANCE_SECONDS = 30;
|
|
48
|
+
/** For each kind of emailed link: the prefix of its token. */
|
|
49
|
+
export declare const LINK_TOKEN_KINDS: {
|
|
50
|
+
readonly verify_email: {
|
|
51
|
+
readonly prefix: "ev";
|
|
52
|
+
};
|
|
53
|
+
readonly reset_password: {
|
|
54
|
+
readonly prefix: "pr";
|
|
55
|
+
};
|
|
56
|
+
readonly magic_sign_in: {
|
|
57
|
+
readonly prefix: "ml";
|
|
58
|
+
};
|
|
59
|
+
readonly change_email: {
|
|
60
|
+
readonly prefix: "ec";
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* An account whose email is still unverified after this long is treated as possibly created by
|
|
65
|
+
* someone else; if the real owner then proves the email by code, link or Google, any password set
|
|
66
|
+
* on it is removed (see UsersService.removeUnprovenPassword).
|
|
67
|
+
*/
|
|
68
|
+
export declare const UNVERIFIED_ACCOUNT_GRACE_SECONDS: number;
|
|
69
|
+
/**
|
|
70
|
+
* Users without a password must have signed in this recently to change their email (proof that
|
|
71
|
+
* the person holding the session is the owner, not someone who found an unlocked device).
|
|
72
|
+
*/
|
|
73
|
+
export declare const RECENT_SIGN_IN_SECONDS: number;
|
|
74
|
+
/** A passkey ceremony (browser prompt) must finish within this time. */
|
|
75
|
+
export declare const PASSKEY_CHALLENGE_LIFETIME_SECONDS: number;
|
|
76
|
+
/** How long a deactivated user has, after proving who they are, to confirm reactivation. */
|
|
77
|
+
export declare const REACTIVATION_CHALLENGE_LIFETIME_SECONDS: number;
|
|
78
|
+
/** Wrong guesses allowed per code before it stops working. 5 guesses of a 6-digit code = 1 in 200,000 chance. */
|
|
79
|
+
export declare const ONE_TIME_CODE_MAX_ATTEMPTS = 5;
|
|
80
|
+
/** Wrong 2FA codes allowed per sign-in attempt before the user must start again. */
|
|
81
|
+
export declare const TWO_FACTOR_MAX_ATTEMPTS = 5;
|
|
82
|
+
/** Longer passwords are refused so nobody can make the server hash megabytes of text. */
|
|
83
|
+
export declare const PASSWORD_MAX_LENGTH = 128;
|
|
84
|
+
/** The lowest minimum length an app may configure (NIST SP 800-63B). */
|
|
85
|
+
export declare const PASSWORD_MIN_LENGTH_FLOOR = 8;
|
|
86
|
+
/** Argon2id settings recommended by OWASP: 64 MB of memory, 3 passes, 1 thread. */
|
|
87
|
+
export declare const ARGON2_HASHING_OPTIONS: {
|
|
88
|
+
readonly memoryCost: number;
|
|
89
|
+
readonly timeCost: 3;
|
|
90
|
+
readonly parallelism: 1;
|
|
91
|
+
};
|
|
92
|
+
/** Have I Been Pwned range API. Only the first 5 characters of the password's SHA-1 are sent. */
|
|
93
|
+
export declare const BREACHED_PASSWORD_API_URL = "https://api.pwnedpasswords.com/range/";
|
|
94
|
+
/** If the breach check is slower than this, skip it rather than block the user. */
|
|
95
|
+
export declare const BREACHED_PASSWORD_CHECK_TIMEOUT_MS = 2000;
|
|
96
|
+
/** Characters of the password's SHA-1 hash sent to the breach service (its "k-anonymity" range). */
|
|
97
|
+
export declare const BREACHED_PASSWORD_HASH_PREFIX_LENGTH = 5;
|
|
98
|
+
/** What counts as a "symbol" when settings.password.requireSymbol is on: anything not a letter, digit or space. */
|
|
99
|
+
export declare const PASSWORD_SYMBOL_PATTERN: RegExp;
|
|
100
|
+
/** RFC 4648 base32 alphabet, used for authenticator-app secrets. */
|
|
101
|
+
export declare const BASE32_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
102
|
+
export declare const TOTP_DIGITS = 6;
|
|
103
|
+
export declare const TOTP_PERIOD_SECONDS = 30;
|
|
104
|
+
/** Accept codes from one 30-second step before or after now, for phones with slightly wrong clocks. */
|
|
105
|
+
export declare const TOTP_ALLOWED_DRIFT_STEPS = 1;
|
|
106
|
+
/** 20 random bytes = 160 bits, the size RFC 4226 recommends. */
|
|
107
|
+
export declare const TOTP_SECRET_BYTES = 20;
|
|
108
|
+
/** Name shown in the user's authenticator app next to the code. Apps can override it. */
|
|
109
|
+
export declare const TOTP_DEFAULT_ISSUER_NAME = "Techelusive";
|
|
110
|
+
export declare const BACKUP_CODE_COUNT = 10;
|
|
111
|
+
/** Backup codes look like "k7m2-x9p4": 8 characters from an alphabet without look-alikes (no 0/o, 1/l/i). */
|
|
112
|
+
export declare const BACKUP_CODE_LENGTH = 8;
|
|
113
|
+
/** Backup codes are shown split in two for readability: "k7m2-x9p4". */
|
|
114
|
+
export declare const BACKUP_CODE_DISPLAY_GROUP_LENGTH: number;
|
|
115
|
+
export declare const BACKUP_CODE_ALPHABET = "abcdefghjkmnpqrstuvwxyz23456789";
|
|
116
|
+
export interface RateLimitRule {
|
|
117
|
+
maximumAttempts: number;
|
|
118
|
+
windowSeconds: number;
|
|
119
|
+
}
|
|
120
|
+
export declare const RATE_LIMITS: {
|
|
121
|
+
readonly signUpPerIp: {
|
|
122
|
+
readonly maximumAttempts: 10;
|
|
123
|
+
readonly windowSeconds: number;
|
|
124
|
+
};
|
|
125
|
+
readonly signInPerIp: {
|
|
126
|
+
readonly maximumAttempts: 30;
|
|
127
|
+
readonly windowSeconds: number;
|
|
128
|
+
};
|
|
129
|
+
readonly signInPerAccount: {
|
|
130
|
+
readonly maximumAttempts: 10;
|
|
131
|
+
readonly windowSeconds: number;
|
|
132
|
+
};
|
|
133
|
+
readonly sendCodePerIp: {
|
|
134
|
+
readonly maximumAttempts: 10;
|
|
135
|
+
readonly windowSeconds: number;
|
|
136
|
+
};
|
|
137
|
+
readonly sendCodePerDestination: {
|
|
138
|
+
readonly maximumAttempts: 5;
|
|
139
|
+
readonly windowSeconds: number;
|
|
140
|
+
};
|
|
141
|
+
readonly sendEmailLinkPerIp: {
|
|
142
|
+
readonly maximumAttempts: 10;
|
|
143
|
+
readonly windowSeconds: number;
|
|
144
|
+
};
|
|
145
|
+
readonly sendEmailLinkPerEmail: {
|
|
146
|
+
readonly maximumAttempts: 3;
|
|
147
|
+
readonly windowSeconds: number;
|
|
148
|
+
};
|
|
149
|
+
readonly refreshPerIp: {
|
|
150
|
+
readonly maximumAttempts: 120;
|
|
151
|
+
readonly windowSeconds: 60;
|
|
152
|
+
};
|
|
153
|
+
readonly twoFactorPerUser: {
|
|
154
|
+
readonly maximumAttempts: 10;
|
|
155
|
+
readonly windowSeconds: number;
|
|
156
|
+
};
|
|
157
|
+
readonly changePasswordPerUser: {
|
|
158
|
+
readonly maximumAttempts: 5;
|
|
159
|
+
readonly windowSeconds: number;
|
|
160
|
+
};
|
|
161
|
+
readonly changeEmailPerUser: {
|
|
162
|
+
readonly maximumAttempts: 5;
|
|
163
|
+
readonly windowSeconds: number;
|
|
164
|
+
};
|
|
165
|
+
readonly exportDataPerUser: {
|
|
166
|
+
readonly maximumAttempts: 5;
|
|
167
|
+
readonly windowSeconds: number;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
/** Passkeys: no attestation (privacy), discoverable credentials, and fingerprint/face/PIN always required. */
|
|
171
|
+
export declare const PASSKEY_ATTESTATION_TYPE = "none";
|
|
172
|
+
export declare const PASSKEY_RESIDENT_KEY = "required";
|
|
173
|
+
export declare const PASSKEY_USER_VERIFICATION = "required";
|
|
174
|
+
/** Name given to a passkey when the user doesn't type one. */
|
|
175
|
+
export declare const DEFAULT_PASSKEY_NAME = "Passkey";
|
|
176
|
+
/** Most passkeys one user may register. */
|
|
177
|
+
export declare const MAXIMUM_PASSKEYS_PER_USER = 20;
|
|
178
|
+
/** Longest passkey name. */
|
|
179
|
+
export declare const PASSKEY_NAME_MAX_LENGTH = 60;
|
|
180
|
+
/** Prefix for rate-limit counters in Redis, so they never clash with the app's own keys. */
|
|
181
|
+
export declare const RATE_LIMIT_REDIS_KEY_PREFIX = "auth:rate-limit:";
|
|
182
|
+
/** The settings table holds exactly one row, with this id. */
|
|
183
|
+
export declare const SETTINGS_ROW_ID = 1;
|
|
184
|
+
/** Signing keys are re-read this often, so a key rotation reaches every server quickly. */
|
|
185
|
+
export declare const SIGNING_KEYS_CACHE_SECONDS = 60;
|
|
186
|
+
/** Settings are re-read this often, so an admin's change reaches every server quickly. */
|
|
187
|
+
export declare const SETTINGS_CACHE_SECONDS = 10;
|
|
188
|
+
/**
|
|
189
|
+
* How long the guard trusts its last "session still active and user still ACTIVE" check.
|
|
190
|
+
* Signing out a device or suspending a user takes effect within this time.
|
|
191
|
+
*/
|
|
192
|
+
export declare const SESSION_CHECK_CACHE_SECONDS = 5;
|
|
193
|
+
/** Retired signing keys stay published this long, so tokens they signed keep verifying until they expire. */
|
|
194
|
+
export declare const RETIRED_SIGNING_KEY_PUBLISH_SECONDS: number;
|
|
195
|
+
/** Social providers this library supports (Instagram has no consumer sign-in API since Dec 2024). */
|
|
196
|
+
export declare const SOCIAL_PROVIDER: {
|
|
197
|
+
readonly google: "google";
|
|
198
|
+
readonly apple: "apple";
|
|
199
|
+
readonly facebook: "facebook";
|
|
200
|
+
};
|
|
201
|
+
export type SocialProvider = (typeof SOCIAL_PROVIDER)[keyof typeof SOCIAL_PROVIDER];
|
|
202
|
+
export declare const SOCIAL_PROVIDERS: SocialProvider[];
|
|
203
|
+
export declare const GOOGLE_PUBLIC_KEYS_URL = "https://www.googleapis.com/oauth2/v3/certs";
|
|
204
|
+
export declare const GOOGLE_TOKEN_ISSUERS: string[];
|
|
205
|
+
export declare const APPLE_PUBLIC_KEYS_URL = "https://appleid.apple.com/auth/keys";
|
|
206
|
+
export declare const APPLE_TOKEN_ISSUER = "https://appleid.apple.com";
|
|
207
|
+
/** Graph API version 26 (July 2026). Meta retires versions about two years after release; bump when needed. */
|
|
208
|
+
export declare const FACEBOOK_GRAPH_API_URL = "https://graph.facebook.com/v26.0";
|
|
209
|
+
/** Provider public keys are cached this long (providers rotate them rarely and announce them early). */
|
|
210
|
+
export declare const SOCIAL_PUBLIC_KEYS_CACHE_SECONDS: number;
|
|
211
|
+
/** Give up on a provider API call after this long. */
|
|
212
|
+
export declare const SOCIAL_PROVIDER_TIMEOUT_MS = 5000;
|
|
213
|
+
/** A token signed by a key we don't know triggers a fresh key download at most this often. */
|
|
214
|
+
export declare const UNKNOWN_KEY_REFETCH_WAIT_SECONDS = 60;
|
|
215
|
+
/** Longest ID / access token accepted from a social provider. */
|
|
216
|
+
export declare const SOCIAL_TOKEN_INPUT_MAX_LENGTH = 8192;
|
|
217
|
+
/** Longest nonce accepted with an Apple / Google ID token. */
|
|
218
|
+
export declare const NONCE_INPUT_MAX_LENGTH = 256;
|
|
219
|
+
/** Facebook profile fields requested after sign-in. */
|
|
220
|
+
export declare const FACEBOOK_PROFILE_FIELDS = "id,email,first_name,last_name";
|
|
221
|
+
/** MSG91 v5 Flow API: sends an SMS from a DLT-approved template. */
|
|
222
|
+
export declare const MSG91_FLOW_API_URL = "https://control.msg91.com/api/v5/flow";
|
|
223
|
+
export declare const MSG91_REQUEST_TIMEOUT_MS = 10000;
|
|
224
|
+
/** Header carrying the signature: "t=<unix time>,v1=<hex HMAC-SHA256 of '<t>.<body>'>". */
|
|
225
|
+
export declare const WEBHOOK_SIGNATURE_HEADER = "X-Techelusive-Signature";
|
|
226
|
+
export declare const WEBHOOK_EVENT_HEADER = "X-Techelusive-Event";
|
|
227
|
+
export declare const WEBHOOK_DELIVERY_ID_HEADER = "X-Techelusive-Delivery";
|
|
228
|
+
/** Receivers should reject signatures older than this (stops replays). */
|
|
229
|
+
export declare const WEBHOOK_SIGNATURE_TOLERANCE_SECONDS: number;
|
|
230
|
+
export declare const WEBHOOK_REQUEST_TIMEOUT_MS = 10000;
|
|
231
|
+
/** Failed deliveries are retried with growing waits: 1 min, 5 min, 30 min, 2 h, 6 h, 12 h, 24 h. */
|
|
232
|
+
export declare const WEBHOOK_RETRY_DELAYS_SECONDS: number[];
|
|
233
|
+
/** How often the delivery worker looks for webhooks to send. */
|
|
234
|
+
export declare const WEBHOOK_WORKER_INTERVAL_MS = 5000;
|
|
235
|
+
/** Deliveries handled per worker run. */
|
|
236
|
+
export declare const WEBHOOK_WORKER_BATCH_SIZE = 20;
|
|
237
|
+
export declare const WEBHOOK_SECRET_BYTES = 32;
|
|
238
|
+
/** Prefix of webhook signing secrets, so they are easy to recognise (e.g. in secret scanners). */
|
|
239
|
+
export declare const WEBHOOK_SECRET_PREFIX = "whsec_";
|
|
240
|
+
/** A delivery claimed by a worker is retried after this long if that worker crashes mid-send. */
|
|
241
|
+
export declare const WEBHOOK_CLAIM_TIMEOUT_SECONDS = 60;
|
|
242
|
+
/** Longest error text / response kept for a failed delivery. */
|
|
243
|
+
export declare const WEBHOOK_ERROR_MAX_LENGTH = 500;
|
|
244
|
+
/** Most webhooks one app may register. */
|
|
245
|
+
export declare const MAXIMUM_WEBHOOKS = 50;
|
|
246
|
+
export declare const WEBHOOK_URL_MAX_LENGTH = 2048;
|
|
247
|
+
export declare const WEBHOOK_DESCRIPTION_MAX_LENGTH = 200;
|
|
248
|
+
/** Webhook delivery requests carry this User-Agent. */
|
|
249
|
+
export declare const WEBHOOK_USER_AGENT = "techelusive-nest-auth-webhooks/1.0";
|
|
250
|
+
/**
|
|
251
|
+
* Addresses webhooks may never be sent to (blocks SSRF: tricking the server into calling its own
|
|
252
|
+
* private network or the cloud metadata service at 169.254.169.254).
|
|
253
|
+
*/
|
|
254
|
+
export declare const BLOCKED_IPV4_RANGES: ReadonlyArray<[network: string, prefixLength: number]>;
|
|
255
|
+
export declare const BLOCKED_IPV6_RANGES: ReadonlyArray<[network: string, prefixLength: number]>;
|
|
256
|
+
export declare const ACCOUNT_STATUS: {
|
|
257
|
+
readonly pendingVerification: "PENDING_VERIFICATION";
|
|
258
|
+
readonly active: "ACTIVE";
|
|
259
|
+
readonly suspended: "SUSPENDED";
|
|
260
|
+
readonly deactivated: "DEACTIVATED";
|
|
261
|
+
readonly deleted: "DELETED";
|
|
262
|
+
};
|
|
263
|
+
export type AccountStatus = (typeof ACCOUNT_STATUS)[keyof typeof ACCOUNT_STATUS];
|
|
264
|
+
export declare const ACCOUNT_STATUSES: AccountStatus[];
|
|
265
|
+
/** Roles inside an organization, from most to least powerful. */
|
|
266
|
+
export declare const ORGANIZATION_ROLE: {
|
|
267
|
+
readonly owner: "owner";
|
|
268
|
+
readonly admin: "admin";
|
|
269
|
+
readonly member: "member";
|
|
270
|
+
};
|
|
271
|
+
export type OrganizationRole = (typeof ORGANIZATION_ROLE)[keyof typeof ORGANIZATION_ROLE];
|
|
272
|
+
export declare const ORGANIZATION_ROLES: OrganizationRole[];
|
|
273
|
+
/** Higher number = more power. An admin can manage members and admins; only owners can manage owners. */
|
|
274
|
+
export declare const ORGANIZATION_ROLE_RANK: Record<OrganizationRole, number>;
|
|
275
|
+
/** Most organizations one user may belong to. */
|
|
276
|
+
export declare const MAXIMUM_ORGANIZATIONS_PER_USER = 100;
|
|
277
|
+
/** Role names: letters, digits, "_", "-", ":" (e.g. "user", "seller", "orders:read"). */
|
|
278
|
+
export declare const ROLE_NAME_PATTERN: RegExp;
|
|
279
|
+
/** Role every new user gets unless the app's settings say otherwise. */
|
|
280
|
+
export declare const DEFAULT_USER_ROLE = "user";
|
|
281
|
+
/** Role allowed to use the /auth/admin endpoints unless the app's settings say otherwise. */
|
|
282
|
+
export declare const DEFAULT_ADMIN_ROLE = "admin";
|
|
283
|
+
export declare const MAXIMUM_ROLES_PER_USER = 20;
|
|
284
|
+
/** Longest suspension reason an admin may record. */
|
|
285
|
+
export declare const SUSPENSION_REASON_MAX_LENGTH = 500;
|
|
286
|
+
/** Phone numbers must be in international E.164 form, e.g. +919876543210. */
|
|
287
|
+
export declare const PHONE_NUMBER_PATTERN: RegExp;
|
|
288
|
+
export declare const EMAIL_MAX_LENGTH = 254;
|
|
289
|
+
/**
|
|
290
|
+
* A practical email check: something@domain.tld with no spaces. Real proof that an address works
|
|
291
|
+
* is the verification email, not a regular expression.
|
|
292
|
+
*/
|
|
293
|
+
export declare const EMAIL_PATTERN: RegExp;
|
|
294
|
+
export declare const DISPLAY_NAME_MAX_LENGTH = 100;
|
|
295
|
+
/** Longest phone number accepted as typed (spaces and dashes are removed afterwards). */
|
|
296
|
+
export declare const PHONE_NUMBER_INPUT_MAX_LENGTH = 32;
|
|
297
|
+
/** Longest token accepted in a request body; real tokens are much shorter, this just blocks junk. */
|
|
298
|
+
export declare const RANDOM_TOKEN_INPUT_MAX_LENGTH = 128;
|
|
299
|
+
/** Longest one-time or 2FA code accepted in a request body. */
|
|
300
|
+
export declare const CODE_INPUT_MAX_LENGTH = 16;
|
|
301
|
+
export declare const ORGANIZATION_NAME_MAX_LENGTH = 100;
|
|
302
|
+
/** Organization handles such as "acme-india". */
|
|
303
|
+
export declare const ORGANIZATION_SLUG_PATTERN: RegExp;
|
|
304
|
+
/** User agent strings are cut to this length before saving. */
|
|
305
|
+
export declare const USER_AGENT_MAX_LENGTH = 300;
|
|
306
|
+
export declare const DEFAULT_PAGE_SIZE = 50;
|
|
307
|
+
export declare const MAXIMUM_PAGE_SIZE = 200;
|
|
308
|
+
export declare const SETTINGS_LIMITS: {
|
|
309
|
+
readonly maximumRolesInList: 10;
|
|
310
|
+
readonly maximumAllowedEmailDomains: 100;
|
|
311
|
+
readonly maximumCountryCodes: 250;
|
|
312
|
+
readonly maximumClientIds: 10;
|
|
313
|
+
readonly facebookAppIdMaxLength: 50;
|
|
314
|
+
readonly codeLength: {
|
|
315
|
+
readonly minimum: 6;
|
|
316
|
+
readonly maximum: 8;
|
|
317
|
+
};
|
|
318
|
+
readonly codeExpiresInMinutes: {
|
|
319
|
+
readonly minimum: 1;
|
|
320
|
+
readonly maximum: 15;
|
|
321
|
+
};
|
|
322
|
+
readonly accessTokenMinutes: {
|
|
323
|
+
readonly minimum: 5;
|
|
324
|
+
readonly maximum: 60;
|
|
325
|
+
};
|
|
326
|
+
readonly refreshTokenDays: {
|
|
327
|
+
readonly minimum: 1;
|
|
328
|
+
readonly maximum: 90;
|
|
329
|
+
};
|
|
330
|
+
readonly sessionDays: {
|
|
331
|
+
readonly minimum: 1;
|
|
332
|
+
readonly maximum: 365;
|
|
333
|
+
};
|
|
334
|
+
readonly resendAfterSeconds: {
|
|
335
|
+
readonly minimum: 30;
|
|
336
|
+
readonly maximum: 300;
|
|
337
|
+
};
|
|
338
|
+
readonly emailVerificationLinkHours: {
|
|
339
|
+
readonly minimum: 1;
|
|
340
|
+
readonly maximum: 72;
|
|
341
|
+
};
|
|
342
|
+
readonly passwordResetLinkMinutes: {
|
|
343
|
+
readonly minimum: 10;
|
|
344
|
+
readonly maximum: 180;
|
|
345
|
+
};
|
|
346
|
+
readonly magicLinkMinutes: {
|
|
347
|
+
readonly minimum: 5;
|
|
348
|
+
readonly maximum: 60;
|
|
349
|
+
};
|
|
350
|
+
readonly emailChangeLinkMinutes: {
|
|
351
|
+
readonly minimum: 10;
|
|
352
|
+
readonly maximum: 240;
|
|
353
|
+
};
|
|
354
|
+
readonly invitationDays: {
|
|
355
|
+
readonly minimum: 1;
|
|
356
|
+
readonly maximum: 30;
|
|
357
|
+
};
|
|
358
|
+
readonly twoFactorChallengeMinutes: {
|
|
359
|
+
readonly minimum: 2;
|
|
360
|
+
readonly maximum: 15;
|
|
361
|
+
};
|
|
362
|
+
readonly expiredRecordDays: {
|
|
363
|
+
readonly minimum: 1;
|
|
364
|
+
readonly maximum: 90;
|
|
365
|
+
};
|
|
366
|
+
readonly webhookDeliveryDays: {
|
|
367
|
+
readonly minimum: 1;
|
|
368
|
+
readonly maximum: 365;
|
|
369
|
+
};
|
|
370
|
+
/** 0 keeps the audit log forever. */
|
|
371
|
+
readonly auditLogDays: {
|
|
372
|
+
readonly minimum: 0;
|
|
373
|
+
readonly maximum: 3650;
|
|
374
|
+
};
|
|
375
|
+
};
|
|
376
|
+
/** An email domain such as "myapp.com". */
|
|
377
|
+
export declare const EMAIL_DOMAIN_PATTERN: RegExp;
|
|
378
|
+
/** A country calling code such as "+91". */
|
|
379
|
+
export declare const COUNTRY_CALLING_CODE_PATTERN: RegExp;
|
|
380
|
+
/** An OAuth client id (Google client id, Apple bundle / services id). */
|
|
381
|
+
export declare const OAUTH_CLIENT_ID_PATTERN: RegExp;
|
|
382
|
+
/** How a user proved who they are. Stored on the session and in the token's "amr" claim. */
|
|
383
|
+
export declare const SIGN_IN_METHOD: {
|
|
384
|
+
readonly password: "password";
|
|
385
|
+
readonly emailOtp: "email_otp";
|
|
386
|
+
readonly magicLink: "magic_link";
|
|
387
|
+
readonly phoneOtp: "phone_otp";
|
|
388
|
+
readonly google: "google";
|
|
389
|
+
readonly apple: "apple";
|
|
390
|
+
readonly facebook: "facebook";
|
|
391
|
+
readonly passkey: "passkey";
|
|
392
|
+
};
|
|
393
|
+
export type SignInMethod = (typeof SIGN_IN_METHOD)[keyof typeof SIGN_IN_METHOD];
|
|
394
|
+
/** Added to "amr" when the user also passed two-factor authentication. */
|
|
395
|
+
export declare const TWO_FACTOR_AMR_VALUE = "two_factor";
|
|
396
|
+
/** The "status" field of sign-in and register responses. */
|
|
397
|
+
export declare const SIGN_IN_STATUS: {
|
|
398
|
+
readonly signedIn: "signed_in";
|
|
399
|
+
readonly twoFactorRequired: "two_factor_required";
|
|
400
|
+
readonly verificationRequired: "verification_required";
|
|
401
|
+
};
|
|
402
|
+
/** Details a new account may need, listed in VALIDATION_ERROR's `missingSignUpDetails`. */
|
|
403
|
+
export declare const SIGN_UP_DETAIL: {
|
|
404
|
+
readonly firstName: "firstName";
|
|
405
|
+
readonly lastName: "lastName";
|
|
406
|
+
readonly acceptTerms: "acceptTerms";
|
|
407
|
+
readonly acceptPrivacyPolicy: "acceptPrivacyPolicy";
|
|
408
|
+
readonly email: "email";
|
|
409
|
+
};
|
|
410
|
+
/** What a user may still have to verify before the account becomes ACTIVE. */
|
|
411
|
+
export declare const PENDING_VERIFICATION: {
|
|
412
|
+
readonly email: "email";
|
|
413
|
+
readonly phone: "phone";
|
|
414
|
+
};
|
|
415
|
+
export type PendingVerification = (typeof PENDING_VERIFICATION)[keyof typeof PENDING_VERIFICATION];
|
|
416
|
+
/** Half-finished sign-ins (auth_sign_in_challenges.purpose). */
|
|
417
|
+
export declare const CHALLENGE_PURPOSE: {
|
|
418
|
+
readonly twoFactor: "two_factor";
|
|
419
|
+
readonly passkeyRegistration: "passkey_registration";
|
|
420
|
+
readonly passkeySignIn: "passkey_sign_in";
|
|
421
|
+
readonly reactivateAccount: "reactivate_account";
|
|
422
|
+
};
|
|
423
|
+
export type ChallengePurpose = (typeof CHALLENGE_PURPOSE)[keyof typeof CHALLENGE_PURPOSE];
|
|
424
|
+
/** Emailed single-use links (auth_link_tokens.purpose). */
|
|
425
|
+
export declare const LINK_PURPOSE: {
|
|
426
|
+
readonly verifyEmail: "verify_email";
|
|
427
|
+
readonly resetPassword: "reset_password";
|
|
428
|
+
readonly magicSignIn: "magic_sign_in";
|
|
429
|
+
readonly changeEmail: "change_email";
|
|
430
|
+
};
|
|
431
|
+
export type LinkTokenPurpose = (typeof LINK_PURPOSE)[keyof typeof LINK_PURPOSE];
|
|
432
|
+
/** Where a one-time code is sent (auth_one_time_codes.channel). */
|
|
433
|
+
export declare const CODE_CHANNEL: {
|
|
434
|
+
readonly email: "email";
|
|
435
|
+
readonly sms: "sms";
|
|
436
|
+
};
|
|
437
|
+
export type CodeChannel = (typeof CODE_CHANNEL)[keyof typeof CODE_CHANNEL];
|
|
438
|
+
/** State of one webhook delivery. */
|
|
439
|
+
export declare const WEBHOOK_DELIVERY_STATUS: {
|
|
440
|
+
readonly pending: "pending";
|
|
441
|
+
readonly delivered: "delivered";
|
|
442
|
+
readonly failed: "failed";
|
|
443
|
+
};
|
|
444
|
+
export type WebhookDeliveryStatus = (typeof WEBHOOK_DELIVERY_STATUS)[keyof typeof WEBHOOK_DELIVERY_STATUS];
|
|
445
|
+
/** Event name of the delivery sent by "test webhook". */
|
|
446
|
+
export declare const WEBHOOK_TEST_EVENT_NAME = "webhook.test";
|
|
447
|
+
/** The `type` of each email the library asks the app to send. */
|
|
448
|
+
export declare const EMAIL_TYPE: {
|
|
449
|
+
readonly verifyEmail: "verify_email";
|
|
450
|
+
readonly resetPassword: "reset_password";
|
|
451
|
+
readonly magicSignIn: "magic_sign_in";
|
|
452
|
+
readonly signInCode: "sign_in_code";
|
|
453
|
+
readonly organizationInvitation: "organization_invitation";
|
|
454
|
+
readonly passwordChanged: "password_changed";
|
|
455
|
+
readonly newSignIn: "new_sign_in";
|
|
456
|
+
/** To the NEW address: a link that confirms the change. */
|
|
457
|
+
readonly confirmEmailChange: "confirm_email_change";
|
|
458
|
+
/** To the OLD address after the change, so the owner notices an unwanted change. */
|
|
459
|
+
readonly emailChanged: "email_changed";
|
|
460
|
+
};
|
|
461
|
+
/** Why a session ended (auth_sessions.revoked_reason, "session.revoked" event). */
|
|
462
|
+
export declare const SESSION_END_REASON: {
|
|
463
|
+
readonly signedOut: "signed_out";
|
|
464
|
+
readonly signedOutEverywhere: "signed_out_everywhere";
|
|
465
|
+
readonly signedOutByUser: "signed_out_by_user";
|
|
466
|
+
readonly signedOutByAdmin: "signed_out_by_admin";
|
|
467
|
+
readonly refreshTokenReused: "refresh_token_reused";
|
|
468
|
+
readonly accountNotActive: "account_not_active";
|
|
469
|
+
readonly accountSuspended: "account_suspended";
|
|
470
|
+
readonly accountDeactivated: "account_deactivated";
|
|
471
|
+
readonly accountDeleted: "account_deleted";
|
|
472
|
+
readonly passwordReset: "password_reset";
|
|
473
|
+
readonly passwordChanged: "password_changed";
|
|
474
|
+
readonly twoFactorEnabled: "two_factor_enabled";
|
|
475
|
+
readonly emailProvenByOwner: "email_proven_by_owner";
|
|
476
|
+
};
|
|
477
|
+
export type SessionEndReason = (typeof SESSION_END_REASON)[keyof typeof SESSION_END_REASON];
|
|
478
|
+
/** Why a sign-in failed ("user.sign_in_failed" event). */
|
|
479
|
+
export declare const SIGN_IN_FAILURE_REASON: {
|
|
480
|
+
readonly wrongEmailOrPassword: "wrong_email_or_password";
|
|
481
|
+
readonly wrongTwoFactorCode: "wrong_two_factor_code";
|
|
482
|
+
readonly passkeySignatureInvalid: "passkey_signature_invalid";
|
|
483
|
+
readonly accountNotVerified: "account_not_verified";
|
|
484
|
+
readonly accountSuspended: "account_suspended";
|
|
485
|
+
};
|
|
486
|
+
export type SignInFailureReason = (typeof SIGN_IN_FAILURE_REASON)[keyof typeof SIGN_IN_FAILURE_REASON];
|
|
487
|
+
/** How a password changed ("user.password_changed" event, `how`). */
|
|
488
|
+
export declare const PASSWORD_CHANGE_KIND: {
|
|
489
|
+
readonly reset: "reset";
|
|
490
|
+
readonly changed: "changed";
|
|
491
|
+
readonly firstSet: "set";
|
|
492
|
+
readonly removedUnverified: "removed_unverified_password";
|
|
493
|
+
};
|
|
494
|
+
export type PasswordChangeKind = (typeof PASSWORD_CHANGE_KIND)[keyof typeof PASSWORD_CHANGE_KIND];
|
|
495
|
+
/** A sign-in method a user may remove (checked so they always keep at least one). */
|
|
496
|
+
export declare const REMOVABLE_SIGN_IN_METHOD: {
|
|
497
|
+
readonly password: "password";
|
|
498
|
+
readonly social: "social";
|
|
499
|
+
readonly passkey: "passkey";
|
|
500
|
+
};
|
|
501
|
+
export type RemovableSignInMethod = (typeof REMOVABLE_SIGN_IN_METHOD)[keyof typeof REMOVABLE_SIGN_IN_METHOD];
|
|
502
|
+
/** Who did something, in the audit log's performedBy: "admin:<id>", "user:<id>". */
|
|
503
|
+
export declare const PERFORMED_BY_PREFIX: {
|
|
504
|
+
readonly admin: "admin:";
|
|
505
|
+
readonly user: "user:";
|
|
506
|
+
};
|
|
507
|
+
/** Encryption context "purpose" values: an encrypted value only decrypts for the same purpose and row. */
|
|
508
|
+
export declare const ENCRYPTION_PURPOSE: {
|
|
509
|
+
readonly signingKey: "signing_key";
|
|
510
|
+
readonly totpSecret: "totp_secret";
|
|
511
|
+
readonly webhookSigningSecret: "webhook_signing_secret";
|
|
512
|
+
};
|
|
513
|
+
/** Stored encrypted values start with "<method>:", telling which method encrypted them. */
|
|
514
|
+
export declare const ENCRYPTED_VALUE_METHOD: {
|
|
515
|
+
readonly kms: "kms";
|
|
516
|
+
readonly local: "local";
|
|
517
|
+
};
|
|
518
|
+
/** Sort orders used in queries. */
|
|
519
|
+
export declare const SORT_ORDER: {
|
|
520
|
+
readonly newestFirst: "DESC";
|
|
521
|
+
readonly oldestFirst: "ASC";
|
|
522
|
+
};
|
|
523
|
+
/** Smallest page number in paged lists. */
|
|
524
|
+
export declare const FIRST_PAGE = 1;
|
|
525
|
+
/** Value of NODE_ENV in production. */
|
|
526
|
+
export declare const PRODUCTION_ENVIRONMENT = "production";
|
|
527
|
+
/** Text encodings used with Buffer. */
|
|
528
|
+
export declare const TEXT_ENCODING: {
|
|
529
|
+
readonly utf8: "utf8";
|
|
530
|
+
readonly base64: "base64";
|
|
531
|
+
readonly base64Url: "base64url";
|
|
532
|
+
readonly hex: "hex";
|
|
533
|
+
};
|
|
534
|
+
/** Hash functions. SHA-1 appears only where a standard requires it (TOTP, breached-password API). */
|
|
535
|
+
export declare const HASH_ALGORITHM: {
|
|
536
|
+
readonly sha256: "sha256";
|
|
537
|
+
readonly sha1: "sha1";
|
|
538
|
+
};
|
|
539
|
+
/** Cipher for the development-only local encryption key. */
|
|
540
|
+
export declare const LOCAL_ENCRYPTION_CIPHER = "aes-256-gcm";
|
|
541
|
+
/** JWT ECDSA signatures use the raw r||s form, not DER. */
|
|
542
|
+
export declare const ECDSA_SIGNATURE_ENCODING = "ieee-p1363";
|
|
543
|
+
/** Token-signing key pair: an elliptic-curve key on P-256 (what ES256 means). */
|
|
544
|
+
export declare const SIGNING_KEY_PAIR_TYPE = "ec";
|
|
545
|
+
export declare const SIGNING_KEY_CURVE = "P-256";
|
|
546
|
+
/** JSON Web Key fields and values. */
|
|
547
|
+
export declare const JWK_EXPORT_FORMAT = "jwk";
|
|
548
|
+
export declare const JWK_KEY_TYPE: {
|
|
549
|
+
readonly ellipticCurve: "EC";
|
|
550
|
+
readonly rsa: "RSA";
|
|
551
|
+
};
|
|
552
|
+
export declare const JWK_USE_SIGNATURE = "sig";
|
|
553
|
+
/** Separator between an encrypted value's method prefix and its data ("kms:..."). */
|
|
554
|
+
export declare const ENCRYPTED_VALUE_SEPARATOR = ":";
|
|
555
|
+
/** Random salt size for hashed short codes. */
|
|
556
|
+
export declare const SHORT_CODE_SALT_BYTES = 16;
|
|
557
|
+
/** Authenticator apps read QR codes holding "otpauth://totp/<label>?<parameters>". */
|
|
558
|
+
export declare const AUTHENTICATOR_APP_URL_PREFIX = "otpauth://totp/";
|
|
559
|
+
export declare const URL_QUERY_SEPARATOR = "?";
|
|
560
|
+
/** Name of the TOTP hash in authenticator-app URLs (otpauth://...&algorithm=SHA1). */
|
|
561
|
+
export declare const TOTP_URL_ALGORITHM_NAME = "SHA1";
|
|
562
|
+
export declare const ROUTE_PARAM: {
|
|
563
|
+
readonly provider: "provider";
|
|
564
|
+
readonly sessionId: "sessionId";
|
|
565
|
+
readonly passkeyId: "passkeyId";
|
|
566
|
+
readonly organizationId: "organizationId";
|
|
567
|
+
readonly memberUserId: "memberUserId";
|
|
568
|
+
readonly invitationId: "invitationId";
|
|
569
|
+
readonly userId: "userId";
|
|
570
|
+
readonly apiKeyId: "apiKeyId";
|
|
571
|
+
readonly webhookId: "webhookId";
|
|
572
|
+
readonly deliveryId: "deliveryId";
|
|
573
|
+
};
|
|
574
|
+
export declare const ROUTES: {
|
|
575
|
+
/** Email + password, email verification, passwordless and account routes share this prefix. */
|
|
576
|
+
readonly auth: {
|
|
577
|
+
readonly prefix: "auth";
|
|
578
|
+
readonly register: "register";
|
|
579
|
+
readonly login: "login";
|
|
580
|
+
readonly emailSendVerification: "email/send-verification";
|
|
581
|
+
readonly emailVerify: "email/verify";
|
|
582
|
+
readonly emailSendOtp: "email/send-otp";
|
|
583
|
+
readonly emailVerifyOtp: "email/verify-otp";
|
|
584
|
+
readonly magicLinkSend: "magic-link/send";
|
|
585
|
+
readonly magicLinkVerify: "magic-link/verify";
|
|
586
|
+
readonly phoneSendOtp: "phone/send-otp";
|
|
587
|
+
readonly phoneVerifyOtp: "phone/verify-otp";
|
|
588
|
+
readonly passwordForgot: "password/forgot";
|
|
589
|
+
readonly passwordReset: "password/reset";
|
|
590
|
+
readonly passwordChange: "password/change";
|
|
591
|
+
readonly refresh: "refresh";
|
|
592
|
+
readonly logout: "logout";
|
|
593
|
+
readonly logoutAll: "logout-all";
|
|
594
|
+
readonly me: "me";
|
|
595
|
+
readonly signInMethods: "sign-in-methods";
|
|
596
|
+
readonly sessions: "sessions";
|
|
597
|
+
readonly session: "sessions/:sessionId";
|
|
598
|
+
readonly deactivate: "deactivate";
|
|
599
|
+
readonly reactivate: "reactivate";
|
|
600
|
+
readonly emailChange: "email/change";
|
|
601
|
+
readonly emailChangeConfirm: "email/change/confirm";
|
|
602
|
+
readonly exportMyData: "me/export";
|
|
603
|
+
readonly health: "health";
|
|
604
|
+
};
|
|
605
|
+
readonly social: {
|
|
606
|
+
readonly prefix: "auth/social";
|
|
607
|
+
readonly signIn: ":provider";
|
|
608
|
+
readonly link: ":provider/link";
|
|
609
|
+
readonly unlink: ":provider";
|
|
610
|
+
};
|
|
611
|
+
readonly passkeys: {
|
|
612
|
+
readonly prefix: "auth/passkeys";
|
|
613
|
+
readonly registerOptions: "register/options";
|
|
614
|
+
readonly registerVerify: "register/verify";
|
|
615
|
+
readonly signInOptions: "sign-in/options";
|
|
616
|
+
readonly signInVerify: "sign-in/verify";
|
|
617
|
+
readonly passkey: ":passkeyId";
|
|
618
|
+
};
|
|
619
|
+
readonly twoFactor: {
|
|
620
|
+
readonly prefix: "auth/2fa";
|
|
621
|
+
readonly setup: "setup";
|
|
622
|
+
readonly enable: "enable";
|
|
623
|
+
readonly disable: "disable";
|
|
624
|
+
readonly backupCodes: "backup-codes";
|
|
625
|
+
readonly verify: "verify";
|
|
626
|
+
};
|
|
627
|
+
readonly organizations: {
|
|
628
|
+
readonly prefix: "auth/organizations";
|
|
629
|
+
readonly switch: "switch";
|
|
630
|
+
readonly acceptInvitation: "invitations/accept";
|
|
631
|
+
readonly organization: ":organizationId";
|
|
632
|
+
readonly members: ":organizationId/members";
|
|
633
|
+
readonly member: ":organizationId/members/:memberUserId";
|
|
634
|
+
readonly invitations: ":organizationId/invitations";
|
|
635
|
+
readonly invitation: ":organizationId/invitations/:invitationId";
|
|
636
|
+
};
|
|
637
|
+
readonly admin: {
|
|
638
|
+
readonly prefix: "auth/admin";
|
|
639
|
+
readonly users: "users";
|
|
640
|
+
readonly user: "users/:userId";
|
|
641
|
+
readonly userRoles: "users/:userId/roles";
|
|
642
|
+
readonly userSuspend: "users/:userId/suspend";
|
|
643
|
+
readonly userUnsuspend: "users/:userId/unsuspend";
|
|
644
|
+
readonly userVerifyEmail: "users/:userId/verify-email";
|
|
645
|
+
readonly userResetTwoFactor: "users/:userId/reset-2fa";
|
|
646
|
+
readonly userLogoutAll: "users/:userId/logout-all";
|
|
647
|
+
readonly settings: "settings";
|
|
648
|
+
readonly auditLog: "audit-log";
|
|
649
|
+
readonly rotateSigningKey: "signing-keys/rotate";
|
|
650
|
+
readonly apiKeys: "api-keys";
|
|
651
|
+
readonly apiKey: "api-keys/:apiKeyId";
|
|
652
|
+
readonly webhooks: "webhooks";
|
|
653
|
+
readonly webhook: "webhooks/:webhookId";
|
|
654
|
+
readonly webhookRotateSecret: "webhooks/:webhookId/rotate-secret";
|
|
655
|
+
readonly webhookTest: "webhooks/:webhookId/test";
|
|
656
|
+
readonly webhookDeliveries: "webhooks/:webhookId/deliveries";
|
|
657
|
+
readonly webhookRetryDelivery: "webhooks/:webhookId/deliveries/:deliveryId/retry";
|
|
658
|
+
readonly stats: "stats";
|
|
659
|
+
readonly runCleanup: "maintenance/cleanup";
|
|
660
|
+
};
|
|
661
|
+
readonly wellKnown: {
|
|
662
|
+
readonly prefix: ".well-known";
|
|
663
|
+
readonly jwks: "jwks.json";
|
|
664
|
+
};
|
|
665
|
+
};
|
|
666
|
+
/** HTTP header names and values the library reads or sends. */
|
|
667
|
+
export declare const HTTP_HEADER: {
|
|
668
|
+
readonly authorization: "authorization";
|
|
669
|
+
readonly userAgent: "user-agent";
|
|
670
|
+
readonly contentType: "Content-Type";
|
|
671
|
+
readonly accept: "accept";
|
|
672
|
+
readonly cacheControl: "Cache-Control";
|
|
673
|
+
readonly retryAfter: "Retry-After";
|
|
674
|
+
readonly outgoingUserAgent: "User-Agent";
|
|
675
|
+
readonly cookie: "cookie";
|
|
676
|
+
readonly setCookie: "Set-Cookie";
|
|
677
|
+
readonly origin: "origin";
|
|
678
|
+
};
|
|
679
|
+
export declare const JSON_CONTENT_TYPE = "application/json";
|
|
680
|
+
/** Requests of other kinds (WebSockets, microservices) are not checked by AuthGuard. */
|
|
681
|
+
export declare const HTTP_CONTEXT_TYPE = "http";
|
|
682
|
+
/** The JWKS document may be cached by clients for 5 minutes. */
|
|
683
|
+
export declare const JWKS_CACHE_CONTROL = "public, max-age=300";
|
|
684
|
+
export declare const RATE_LIMIT_KEY: {
|
|
685
|
+
readonly signUpPerIp: (ipAddress: string | null) => string;
|
|
686
|
+
readonly signInPerIp: (ipAddress: string | null) => string;
|
|
687
|
+
readonly signInPerAccount: (email: string) => string;
|
|
688
|
+
readonly sendCodePerIp: (ipAddress: string | null) => string;
|
|
689
|
+
readonly sendCodePerDestination: (destination: string) => string;
|
|
690
|
+
readonly sendEmailLinkPerIp: (ipAddress: string | null) => string;
|
|
691
|
+
readonly sendEmailLinkPerEmail: (email: string) => string;
|
|
692
|
+
readonly refreshPerIp: (ipAddress: string | null) => string;
|
|
693
|
+
readonly twoFactorPerUser: (userId: string) => string;
|
|
694
|
+
readonly changePasswordPerUser: (userId: string) => string;
|
|
695
|
+
readonly changeEmailPerUser: (userId: string) => string;
|
|
696
|
+
readonly exportDataPerUser: (userId: string) => string;
|
|
697
|
+
};
|
|
698
|
+
/** Builds the audit log's performedBy value. */
|
|
699
|
+
export declare const PERFORMED_BY: {
|
|
700
|
+
readonly admin: (adminUserId: string) => string;
|
|
701
|
+
readonly user: (userId: string) => string;
|
|
702
|
+
};
|
|
703
|
+
/** User agent recorded for actions taken by scripts and jobs (SYSTEM_REQUEST). */
|
|
704
|
+
export declare const SYSTEM_USER_AGENT = "system";
|
|
705
|
+
/** Names shown in log lines, one per component. */
|
|
706
|
+
export declare const LOG_CONTEXT: {
|
|
707
|
+
readonly exceptionFilter: "AuthExceptionFilter";
|
|
708
|
+
readonly rateLimiter: "RateLimiter";
|
|
709
|
+
readonly apiKeys: "ApiKeys";
|
|
710
|
+
readonly events: "AuthEvents";
|
|
711
|
+
readonly notifications: "Notifications";
|
|
712
|
+
readonly passwordPolicy: "PasswordPolicy";
|
|
713
|
+
readonly sessions: "Sessions";
|
|
714
|
+
readonly signingKeys: "SigningKeys";
|
|
715
|
+
readonly socialProviders: "SocialProviders";
|
|
716
|
+
readonly webhookDelivery: "WebhookDelivery";
|
|
717
|
+
readonly consoleEmailSender: "ConsoleEmailSender";
|
|
718
|
+
readonly dataRetention: "DataRetention";
|
|
719
|
+
};
|
|
720
|
+
/** In-process caches are emptied when they grow past these sizes (protects memory under attack). */
|
|
721
|
+
export declare const SESSION_CHECK_CACHE_MAX_ENTRIES = 100000;
|
|
722
|
+
export declare const IN_MEMORY_RATE_LIMIT_MAX_ENTRIES = 50000;
|
|
723
|
+
export declare const PASSWORD_REQUIREMENT: {
|
|
724
|
+
readonly minimumLength: (minimumLength: number) => string;
|
|
725
|
+
readonly maximumLength: (maximumLength: number) => string;
|
|
726
|
+
readonly uppercaseLetter: "an uppercase letter";
|
|
727
|
+
readonly lowercaseLetter: "a lowercase letter";
|
|
728
|
+
readonly number: "a number";
|
|
729
|
+
readonly symbol: "a symbol";
|
|
730
|
+
readonly differentFromCurrent: "different from your current password";
|
|
731
|
+
};
|
|
732
|
+
/** Trailing slashes removed from the issuer URL ("https://api.myapp.com/" -> "https://api.myapp.com"). */
|
|
733
|
+
export declare const TRAILING_SLASHES_PATTERN: RegExp;
|
|
734
|
+
/** Characters removed from typed input before it is checked. */
|
|
735
|
+
export declare const PHONE_FORMATTING_CHARACTERS_PATTERN: RegExp;
|
|
736
|
+
export declare const BACKUP_CODE_FORMATTING_CHARACTERS_PATTERN: RegExp;
|
|
737
|
+
export declare const WHITESPACE_PATTERN: RegExp;
|
|
738
|
+
export declare const BASE32_PADDING_PATTERN: RegExp;
|
|
739
|
+
export declare const LEADING_PLUS_PATTERN: RegExp;
|
|
740
|
+
/** Only base64url characters (the body of a random token). */
|
|
741
|
+
export declare const BASE64URL_TEXT_PATTERN: RegExp;
|
|
742
|
+
/** Only digits (a typed TOTP code). */
|
|
743
|
+
export declare const DIGITS_ONLY_PATTERN: RegExp;
|
|
744
|
+
/** Characters with special meaning in SQL LIKE patterns, escaped in admin user search. */
|
|
745
|
+
export declare const SQL_LIKE_SPECIAL_CHARACTERS_PATTERN: RegExp;
|
|
746
|
+
export declare const SQL_LIKE_ESCAPE_CHARACTER = "\\";
|
|
747
|
+
export declare const SQL_LIKE_ANY_TEXT = "%";
|
|
748
|
+
/** Joins nested settings field names: "password.minimumLength". */
|
|
749
|
+
export declare const SETTINGS_PATH_SEPARATOR = ".";
|
|
750
|
+
/** Patterns for the character rules above. */
|
|
751
|
+
export declare const UPPERCASE_LETTER_PATTERN: RegExp;
|
|
752
|
+
export declare const LOWERCASE_LETTER_PATTERN: RegExp;
|
|
753
|
+
export declare const DIGIT_PATTERN: RegExp;
|
|
754
|
+
export declare const VALIDATION_PROBLEM: {
|
|
755
|
+
readonly namesRequired: "firstName and lastName are required";
|
|
756
|
+
readonly tooManyOrganizations: "too many organizations";
|
|
757
|
+
readonly tooManyPasskeys: "too many passkeys";
|
|
758
|
+
readonly tooManyWebhooks: "too many webhooks";
|
|
759
|
+
readonly unknownEventNames: (unknownNames: string[]) => string;
|
|
760
|
+
readonly settingsNotAnObject: "settings must be an object";
|
|
761
|
+
readonly refreshLongerThanSession: "tokens.refreshTokenDays cannot be more than tokens.sessionDays";
|
|
762
|
+
readonly noSignInMethodEnabled: "at least one sign-in method must stay enabled";
|
|
763
|
+
readonly googleClientIdsRequired: "google.clientIds is required when Google is enabled";
|
|
764
|
+
readonly appleClientIdsRequired: "apple.clientIds is required when Apple is enabled";
|
|
765
|
+
readonly facebookAppIdRequired: "facebook.appId is required when Facebook is enabled";
|
|
766
|
+
readonly adminRolesRequired: "admin.adminRoles must name at least one role";
|
|
767
|
+
/** "password.minimumLength must not be less than 8" */
|
|
768
|
+
readonly atPath: (path: string, message: string) => string;
|
|
769
|
+
readonly emailDomainFormat: "each domain must look like example.com";
|
|
770
|
+
readonly countryCodeFormat: "each code must look like +91";
|
|
771
|
+
};
|
|
772
|
+
/** Problems found in AuthModule options at startup (the app refuses to start and lists them). */
|
|
773
|
+
export declare const OPTIONS_PROBLEM: {
|
|
774
|
+
readonly dataSourceRequired: "dataSource is required (your TypeORM DataSource)";
|
|
775
|
+
readonly emailSenderRequired: "emailSender with a send() method is required";
|
|
776
|
+
readonly issuerMustBeHttps: "issuer must be an https URL in production";
|
|
777
|
+
readonly issuerMustBeUrl: "issuer must be a full URL, e.g. https://api.myapp.com";
|
|
778
|
+
readonly encryptionRequired: "encryption is required: { awsKmsKeyId, awsRegion } or, for development, { localKey }";
|
|
779
|
+
readonly localKeyNotForProduction: "encryption.localKey is for development only; use AWS KMS in production";
|
|
780
|
+
readonly localKeyWrongSize: "encryption.localKey must be 32 random bytes in base64 (openssl rand -base64 32)";
|
|
781
|
+
readonly kmsDetailsRequired: "encryption needs both awsKmsKeyId and awsRegion";
|
|
782
|
+
readonly legacyLocalKeyWrongSize: "encryption.legacyLocalKey must be the old 32-byte base64 local key";
|
|
783
|
+
readonly relyingPartyIdMustBeDomain: "passkeys.relyingPartyId must be a bare domain such as \"myapp.com\"";
|
|
784
|
+
readonly relyingPartyNameRequired: "passkeys.relyingPartyName is required";
|
|
785
|
+
readonly allowedOriginsRequired: "passkeys.allowedOrigins needs at least one origin";
|
|
786
|
+
readonly cookieAllowedOriginsRequired: "refreshTokenCookie.allowedOrigins needs at least one origin, e.g. [\"https://app.myapp.com\"]";
|
|
787
|
+
readonly hostCookieRules: "refreshTokenCookie: a name starting with \"__Host-\" requires path \"/\" and no domain";
|
|
788
|
+
readonly redisRequiredInProduction: "redisUrl is required in production so rate limits are shared by every server (set singleServer: true if you really run one process)";
|
|
789
|
+
};
|
|
790
|
+
/** Why a webhook URL was refused (UNSAFE_WEBHOOK_URL `problem`). */
|
|
791
|
+
export declare const URL_SAFETY_PROBLEM: {
|
|
792
|
+
readonly invalidUrl: "not a valid URL";
|
|
793
|
+
readonly hasCredentials: "URL must not contain a username or password";
|
|
794
|
+
readonly notHttps: "URL must use https";
|
|
795
|
+
readonly doesNotResolve: "host name does not resolve";
|
|
796
|
+
readonly privateAddress: "URL points to a private network address";
|
|
797
|
+
};
|
|
798
|
+
/** lastError of a webhook delivery that could not be sent. */
|
|
799
|
+
export declare const WEBHOOK_DELIVERY_ERROR: {
|
|
800
|
+
readonly webhookUnavailable: "webhook removed or disabled";
|
|
801
|
+
readonly unsafeUrl: (problem: string) => string;
|
|
802
|
+
readonly httpStatus: (status: number) => string;
|
|
803
|
+
};
|
|
804
|
+
/** Message inside the "webhook.test" delivery. */
|
|
805
|
+
export declare const WEBHOOK_TEST_MESSAGE = "This is a test delivery.";
|
|
806
|
+
export declare const HTTP_METHOD: {
|
|
807
|
+
readonly post: "POST";
|
|
808
|
+
};
|
|
809
|
+
/** Outgoing webhook calls never follow redirects (a redirect could point at a private address). */
|
|
810
|
+
export declare const FETCH_REDIRECT_MODE_MANUAL = "manual";
|
|
811
|
+
/** Responses in this range count as success. */
|
|
812
|
+
export declare const SUCCESS_STATUS_RANGE: {
|
|
813
|
+
readonly from: 200;
|
|
814
|
+
readonly toExclusive: 300;
|
|
815
|
+
};
|
|
816
|
+
export declare const URL_PROTOCOL: {
|
|
817
|
+
readonly https: "https:";
|
|
818
|
+
readonly http: "http:";
|
|
819
|
+
};
|
|
820
|
+
/** Hosts allowed over plain http outside production, for local webhook testing. */
|
|
821
|
+
export declare const LOCAL_DEVELOPMENT_HOSTS: string[];
|
|
822
|
+
/** Node's names and numbers for IP versions. */
|
|
823
|
+
export declare const IP_FAMILY: {
|
|
824
|
+
readonly ipv4: "ipv4";
|
|
825
|
+
readonly ipv6: "ipv6";
|
|
826
|
+
};
|
|
827
|
+
export declare const IP_VERSION_6 = 6;
|
|
828
|
+
/** "::ffff:10.0.0.1" style IPv4-mapped IPv6 address; group 1 is the IPv4 part. */
|
|
829
|
+
export declare const IPV4_MAPPED_IPV6_PATTERN: RegExp;
|
|
830
|
+
/** Square brackets around IPv6 hosts in URLs ("[::1]"). */
|
|
831
|
+
export declare const URL_IPV6_BRACKETS_PATTERN: RegExp;
|
|
832
|
+
/** haveibeenpwned.com range API: padded responses hide which prefix was asked about. */
|
|
833
|
+
export declare const BREACHED_PASSWORD_API: {
|
|
834
|
+
readonly paddingHeader: "Add-Padding";
|
|
835
|
+
readonly paddingHeaderValue: "true";
|
|
836
|
+
readonly lineSeparator: "\n";
|
|
837
|
+
readonly countSeparator: ":";
|
|
838
|
+
};
|
|
839
|
+
/** Facebook Graph API paths and query parameters. */
|
|
840
|
+
export declare const FACEBOOK_API: {
|
|
841
|
+
readonly debugTokenPath: "/debug_token";
|
|
842
|
+
readonly profilePath: "/me";
|
|
843
|
+
readonly inputTokenParameter: "input_token";
|
|
844
|
+
readonly accessTokenParameter: "access_token";
|
|
845
|
+
readonly fieldsParameter: "fields";
|
|
846
|
+
readonly appSecretProofParameter: "appsecret_proof";
|
|
847
|
+
readonly appAccessToken: (appId: string, appSecret: string) => string;
|
|
848
|
+
};
|
|
849
|
+
/** Apple sends email_verified either as a boolean or as this string. */
|
|
850
|
+
export declare const APPLE_TRUE_STRING = "true";
|
|
851
|
+
/** MSG91 request details. */
|
|
852
|
+
export declare const MSG91_API: {
|
|
853
|
+
readonly authKeyHeader: "authkey";
|
|
854
|
+
readonly defaultCodeVariableName: "otp";
|
|
855
|
+
readonly errorResponseType: "error";
|
|
856
|
+
};
|
|
857
|
+
/** JWT: header.payload.signature */
|
|
858
|
+
export declare const JWT_PART_SEPARATOR = ".";
|
|
859
|
+
export declare const JWT_PART_COUNT = 3;
|
|
860
|
+
/** Random tokens look like "<prefix>_<43 base64url characters>". */
|
|
861
|
+
export declare const TOKEN_PREFIX_SEPARATOR = "_";
|
|
862
|
+
/** Length of 32 random bytes written in base64url. */
|
|
863
|
+
export declare const RANDOM_TOKEN_BASE64URL_LENGTH = 43;
|
|
864
|
+
/** Short codes are hashed as "<salt>:<code>". */
|
|
865
|
+
export declare const SALTED_CODE_SEPARATOR = ":";
|
|
866
|
+
/** Digits of a numeric code are chosen from 0 to 9. */
|
|
867
|
+
export declare const DECIMAL_BASE = 10;
|
|
868
|
+
/** TOTP: an 8-byte big-endian counter; codes are left-padded with zeros. */
|
|
869
|
+
export declare const TOTP_COUNTER_BYTES = 8;
|
|
870
|
+
export declare const TOTP_CODE_PAD_CHARACTER = "0";
|
|
871
|
+
/** Authenticator-app label "Issuer:account". */
|
|
872
|
+
export declare const TOTP_LABEL_SEPARATOR = ":";
|
|
873
|
+
/** Base32 packs 5 bits per character; bytes have 8 bits. */
|
|
874
|
+
export declare const BASE32_BITS_PER_CHARACTER = 5;
|
|
875
|
+
export declare const BITS_PER_BYTE = 8;
|
|
876
|
+
export declare const BASE32_CHARACTER_MASK = 31;
|
|
877
|
+
export declare const BYTE_MASK = 255;
|
|
878
|
+
/** Backup codes are shown as "k7m2-x9p4". */
|
|
879
|
+
export declare const BACKUP_CODE_DISPLAY_SEPARATOR = "-";
|
|
880
|
+
/** First and last name are joined with a space for display. */
|
|
881
|
+
export declare const DISPLAY_NAME_SEPARATOR = " ";
|
|
882
|
+
/** Email masking keeps the first character: "a***@mail.com". */
|
|
883
|
+
export declare const EMAIL_MASK: {
|
|
884
|
+
readonly visibleCharacters: 1;
|
|
885
|
+
readonly hiddenPart: "***";
|
|
886
|
+
readonly domainSeparator: "@";
|
|
887
|
+
};
|
|
888
|
+
/** Phone masking keeps the country code and the last 4 digits: "+91******3210". */
|
|
889
|
+
export declare const PHONE_MASK: {
|
|
890
|
+
readonly visibleStart: 3;
|
|
891
|
+
readonly visibleEnd: 4;
|
|
892
|
+
readonly maskCharacter: "*";
|
|
893
|
+
};
|
|
894
|
+
/** A bare passkey relying-party id is a domain, so it contains neither of these. */
|
|
895
|
+
export declare const RELYING_PARTY_ID_FORBIDDEN_CHARACTERS: string[];
|
|
896
|
+
/** Webhook signature header: "t=<unix time>,v1=<hex HMAC>" over "<t>.<raw body>". */
|
|
897
|
+
export declare const WEBHOOK_SIGNATURE_FORMAT: {
|
|
898
|
+
readonly timestampKey: "t";
|
|
899
|
+
readonly signatureKey: "v1";
|
|
900
|
+
readonly partSeparator: ",";
|
|
901
|
+
readonly keyValueSeparator: "=";
|
|
902
|
+
readonly signedContentSeparator: ".";
|
|
903
|
+
};
|
|
904
|
+
export declare const METADATA_KEY: {
|
|
905
|
+
readonly publicRoute: "techelusive-auth:public-route";
|
|
906
|
+
readonly requiredRoles: "techelusive-auth:required-roles";
|
|
907
|
+
readonly checkSessionInDatabase: "techelusive-auth:check-session";
|
|
908
|
+
readonly apiKeyScopes: "techelusive-auth:api-key-scopes";
|
|
909
|
+
readonly adminOnly: "techelusive-auth:admin-only";
|
|
910
|
+
readonly clearsRefreshTokenCookie: "techelusive-auth:clears-refresh-token-cookie";
|
|
911
|
+
readonly libraryController: "techelusive-auth:library-controller";
|
|
912
|
+
};
|
|
913
|
+
/** Name of the property the guard puts on the Express request (read by @CurrentUser). */
|
|
914
|
+
export declare const CALLER_REQUEST_PROPERTY = "techelusiveAuthCaller";
|
|
915
|
+
/** "Authorization: Bearer <token>" */
|
|
916
|
+
export declare const BEARER_TOKEN_PATTERN: RegExp;
|
|
917
|
+
/** Longest API key name. */
|
|
918
|
+
export declare const API_KEY_NAME_MAX_LENGTH = 100;
|
|
919
|
+
/** Most scopes on one API key. */
|
|
920
|
+
export declare const MAXIMUM_API_KEY_SCOPES = 50;
|
|
921
|
+
/** API key scopes look like "rides:read" or "admin". */
|
|
922
|
+
export declare const API_KEY_SCOPE_PATTERN: RegExp;
|
|
923
|
+
/** Characters of an API key (after "ak_") shown in lists so people can tell keys apart. */
|
|
924
|
+
export declare const API_KEY_PREVIEW_LENGTH = 6;
|
|
925
|
+
/** "Last used" on an API key is updated at most this often, to avoid a write on every request. */
|
|
926
|
+
export declare const API_KEY_LAST_USED_UPDATE_SECONDS = 60;
|
|
927
|
+
/** Header used by servers calling your API with an API key. */
|
|
928
|
+
export declare const API_KEY_HEADER = "x-api-key";
|
|
929
|
+
export declare const AUTH_EVENTS: {
|
|
930
|
+
readonly userCreated: "user.created";
|
|
931
|
+
readonly userUpdated: "user.updated";
|
|
932
|
+
readonly userDeleted: "user.deleted";
|
|
933
|
+
readonly userSignedIn: "user.signed_in";
|
|
934
|
+
readonly userSignInFailed: "user.sign_in_failed";
|
|
935
|
+
readonly userSignedOut: "user.signed_out";
|
|
936
|
+
readonly userActivated: "user.activated";
|
|
937
|
+
readonly userSuspended: "user.suspended";
|
|
938
|
+
readonly userDeactivated: "user.deactivated";
|
|
939
|
+
readonly userReactivated: "user.reactivated";
|
|
940
|
+
readonly userRolesChanged: "user.roles_changed";
|
|
941
|
+
readonly phoneVerified: "user.phone_verified";
|
|
942
|
+
readonly onboardingCompleted: "user.onboarding_completed";
|
|
943
|
+
readonly emailVerified: "user.email_verified";
|
|
944
|
+
readonly emailChangeRequested: "user.email_change_requested";
|
|
945
|
+
readonly emailChanged: "user.email_changed";
|
|
946
|
+
readonly passwordChanged: "user.password_changed";
|
|
947
|
+
readonly passwordResetRequested: "user.password_reset_requested";
|
|
948
|
+
readonly twoFactorEnabled: "user.two_factor_enabled";
|
|
949
|
+
readonly twoFactorDisabled: "user.two_factor_disabled";
|
|
950
|
+
readonly passkeyAdded: "user.passkey_added";
|
|
951
|
+
readonly passkeyRemoved: "user.passkey_removed";
|
|
952
|
+
readonly socialAccountLinked: "user.social_account_linked";
|
|
953
|
+
readonly socialAccountUnlinked: "user.social_account_unlinked";
|
|
954
|
+
readonly sessionRevoked: "session.revoked";
|
|
955
|
+
readonly refreshTokenReused: "session.refresh_token_reused";
|
|
956
|
+
readonly organizationCreated: "organization.created";
|
|
957
|
+
readonly organizationDeleted: "organization.deleted";
|
|
958
|
+
readonly organizationMemberAdded: "organization.member_added";
|
|
959
|
+
readonly organizationMemberRemoved: "organization.member_removed";
|
|
960
|
+
readonly organizationMemberRoleChanged: "organization.member_role_changed";
|
|
961
|
+
readonly organizationUpdated: "organization.updated";
|
|
962
|
+
readonly organizationInvitationSent: "organization.invitation_sent";
|
|
963
|
+
readonly apiKeyCreated: "api_key.created";
|
|
964
|
+
readonly apiKeyRevoked: "api_key.revoked";
|
|
965
|
+
readonly settingsChanged: "settings.changed";
|
|
966
|
+
};
|
|
967
|
+
export type AuthEventName = (typeof AUTH_EVENTS)[keyof typeof AUTH_EVENTS];
|
|
968
|
+
export declare const SUCCESS_MESSAGES: {
|
|
969
|
+
readonly registered: "Your account has been created. Please verify your details to continue.";
|
|
970
|
+
readonly verificationEmailSent: "If this email needs verifying, a verification link is on its way.";
|
|
971
|
+
readonly emailVerified: "Your email has been verified.";
|
|
972
|
+
readonly passwordResetEmailSent: "If an account exists for this email, a password reset link is on its way.";
|
|
973
|
+
readonly passwordReset: "Your password has been reset. Please sign in with your new password.";
|
|
974
|
+
readonly passwordChanged: "Your password has been changed. Other devices have been signed out.";
|
|
975
|
+
readonly codeSent: "If this destination can receive codes, a code is on its way.";
|
|
976
|
+
readonly magicLinkSent: "If this email can sign in, a sign-in link is on its way.";
|
|
977
|
+
readonly signedOut: "You have been signed out.";
|
|
978
|
+
readonly signedOutEverywhere: "You have been signed out on all devices.";
|
|
979
|
+
readonly accountDeactivated: "Your account has been deactivated. Sign in again at any time to reactivate it.";
|
|
980
|
+
readonly accountDeleted: "Your account has been deleted.";
|
|
981
|
+
readonly emailChangeRequested: "If this email can be used, a confirmation link is on its way to it.";
|
|
982
|
+
readonly emailChanged: "Your email has been changed.";
|
|
983
|
+
};
|
|
984
|
+
export declare const AUTH_ERRORS: {
|
|
985
|
+
readonly validationFailed: {
|
|
986
|
+
readonly status: 400;
|
|
987
|
+
readonly code: "VALIDATION_ERROR";
|
|
988
|
+
readonly message: "Some fields are missing or invalid.";
|
|
989
|
+
};
|
|
990
|
+
readonly invalidEmail: {
|
|
991
|
+
readonly status: 400;
|
|
992
|
+
readonly code: "INVALID_EMAIL";
|
|
993
|
+
readonly message: "Enter a valid email address.";
|
|
994
|
+
};
|
|
995
|
+
readonly invalidPhone: {
|
|
996
|
+
readonly status: 400;
|
|
997
|
+
readonly code: "INVALID_PHONE";
|
|
998
|
+
readonly message: "Enter a valid phone number with country code, e.g. +919876543210.";
|
|
999
|
+
};
|
|
1000
|
+
readonly invalidPassword: {
|
|
1001
|
+
readonly status: 400;
|
|
1002
|
+
readonly code: "INVALID_PASSWORD";
|
|
1003
|
+
readonly message: "This password does not meet the password rules.";
|
|
1004
|
+
};
|
|
1005
|
+
readonly breachedPassword: {
|
|
1006
|
+
readonly status: 400;
|
|
1007
|
+
readonly code: "INVALID_PASSWORD";
|
|
1008
|
+
readonly message: "This password has appeared in a data breach. Please choose a different one.";
|
|
1009
|
+
};
|
|
1010
|
+
readonly termsNotAccepted: {
|
|
1011
|
+
readonly status: 400;
|
|
1012
|
+
readonly code: "TERMS_NOT_ACCEPTED";
|
|
1013
|
+
readonly message: "Please accept the terms of service.";
|
|
1014
|
+
};
|
|
1015
|
+
readonly privacyPolicyNotAccepted: {
|
|
1016
|
+
readonly status: 400;
|
|
1017
|
+
readonly code: "PRIVACY_POLICY_NOT_ACCEPTED";
|
|
1018
|
+
readonly message: "Please accept the privacy policy.";
|
|
1019
|
+
};
|
|
1020
|
+
readonly emailDomainNotAllowed: {
|
|
1021
|
+
readonly status: 400;
|
|
1022
|
+
readonly code: "EMAIL_DOMAIN_NOT_ALLOWED";
|
|
1023
|
+
readonly message: "Sign up is limited to approved email domains.";
|
|
1024
|
+
};
|
|
1025
|
+
readonly phoneCountryNotAllowed: {
|
|
1026
|
+
readonly status: 400;
|
|
1027
|
+
readonly code: "PHONE_COUNTRY_NOT_ALLOWED";
|
|
1028
|
+
readonly message: "Phone numbers from this country are not supported.";
|
|
1029
|
+
};
|
|
1030
|
+
readonly invalidCredentials: {
|
|
1031
|
+
readonly status: 401;
|
|
1032
|
+
readonly code: "INVALID_CREDENTIALS";
|
|
1033
|
+
readonly message: "Invalid email or password.";
|
|
1034
|
+
};
|
|
1035
|
+
readonly invalidOtp: {
|
|
1036
|
+
readonly status: 400;
|
|
1037
|
+
readonly code: "INVALID_OTP";
|
|
1038
|
+
readonly message: "This code is incorrect.";
|
|
1039
|
+
};
|
|
1040
|
+
readonly otpExpired: {
|
|
1041
|
+
readonly status: 400;
|
|
1042
|
+
readonly code: "OTP_EXPIRED";
|
|
1043
|
+
readonly message: "This code has expired or was used too many times. Please request a new one.";
|
|
1044
|
+
};
|
|
1045
|
+
readonly invalidOrExpiredLink: {
|
|
1046
|
+
readonly status: 400;
|
|
1047
|
+
readonly code: "INVALID_TOKEN";
|
|
1048
|
+
readonly message: "This link is invalid, expired or already used.";
|
|
1049
|
+
};
|
|
1050
|
+
readonly unauthorized: {
|
|
1051
|
+
readonly status: 401;
|
|
1052
|
+
readonly code: "UNAUTHORIZED";
|
|
1053
|
+
readonly message: "Please sign in to continue.";
|
|
1054
|
+
};
|
|
1055
|
+
readonly invalidAccessToken: {
|
|
1056
|
+
readonly status: 401;
|
|
1057
|
+
readonly code: "INVALID_TOKEN";
|
|
1058
|
+
readonly message: "Your session has expired. Please sign in again.";
|
|
1059
|
+
};
|
|
1060
|
+
readonly invalidRefreshToken: {
|
|
1061
|
+
readonly status: 401;
|
|
1062
|
+
readonly code: "INVALID_TOKEN";
|
|
1063
|
+
readonly message: "Your session has expired. Please sign in again.";
|
|
1064
|
+
};
|
|
1065
|
+
readonly invalidApiKey: {
|
|
1066
|
+
readonly status: 401;
|
|
1067
|
+
readonly code: "INVALID_API_KEY";
|
|
1068
|
+
readonly message: "The API key is missing, invalid or revoked.";
|
|
1069
|
+
};
|
|
1070
|
+
readonly invalidSocialToken: {
|
|
1071
|
+
readonly status: 401;
|
|
1072
|
+
readonly code: "INVALID_SOCIAL_TOKEN";
|
|
1073
|
+
readonly message: "We could not confirm your sign-in with this provider.";
|
|
1074
|
+
};
|
|
1075
|
+
readonly invalidPasskey: {
|
|
1076
|
+
readonly status: 401;
|
|
1077
|
+
readonly code: "INVALID_PASSKEY";
|
|
1078
|
+
readonly message: "We could not confirm this passkey.";
|
|
1079
|
+
};
|
|
1080
|
+
readonly invalidTwoFactorCode: {
|
|
1081
|
+
readonly status: 401;
|
|
1082
|
+
readonly code: "INVALID_OTP";
|
|
1083
|
+
readonly message: "This code is incorrect.";
|
|
1084
|
+
};
|
|
1085
|
+
readonly accountNotVerified: {
|
|
1086
|
+
readonly status: 403;
|
|
1087
|
+
readonly code: "ACCOUNT_NOT_VERIFIED";
|
|
1088
|
+
readonly message: "Please finish verifying your account.";
|
|
1089
|
+
};
|
|
1090
|
+
readonly accountSuspended: {
|
|
1091
|
+
readonly status: 403;
|
|
1092
|
+
readonly code: "ACCOUNT_SUSPENDED";
|
|
1093
|
+
readonly message: "This account has been suspended. Please contact support.";
|
|
1094
|
+
};
|
|
1095
|
+
readonly accountDeactivated: {
|
|
1096
|
+
readonly status: 403;
|
|
1097
|
+
readonly code: "ACCOUNT_DEACTIVATED";
|
|
1098
|
+
readonly message: "This account is deactivated. Reactivate it to continue.";
|
|
1099
|
+
};
|
|
1100
|
+
readonly forbidden: {
|
|
1101
|
+
readonly status: 403;
|
|
1102
|
+
readonly code: "FORBIDDEN";
|
|
1103
|
+
readonly message: "You do not have permission to do this.";
|
|
1104
|
+
};
|
|
1105
|
+
readonly missingApiKeyScope: {
|
|
1106
|
+
readonly status: 403;
|
|
1107
|
+
readonly code: "FORBIDDEN";
|
|
1108
|
+
readonly message: "This API key is not allowed to do this.";
|
|
1109
|
+
};
|
|
1110
|
+
readonly signUpClosed: {
|
|
1111
|
+
readonly status: 403;
|
|
1112
|
+
readonly code: "SIGN_UP_CLOSED";
|
|
1113
|
+
readonly message: "Sign up is currently closed.";
|
|
1114
|
+
};
|
|
1115
|
+
readonly signInMethodDisabled: {
|
|
1116
|
+
readonly status: 403;
|
|
1117
|
+
readonly code: "SIGN_IN_METHOD_DISABLED";
|
|
1118
|
+
readonly message: "This sign-in method is not available.";
|
|
1119
|
+
};
|
|
1120
|
+
readonly featureDisabled: {
|
|
1121
|
+
readonly status: 403;
|
|
1122
|
+
readonly code: "FEATURE_DISABLED";
|
|
1123
|
+
readonly message: "This feature is not turned on.";
|
|
1124
|
+
};
|
|
1125
|
+
readonly notFound: {
|
|
1126
|
+
readonly status: 404;
|
|
1127
|
+
readonly code: "NOT_FOUND";
|
|
1128
|
+
readonly message: "Not found.";
|
|
1129
|
+
};
|
|
1130
|
+
readonly accountAlreadyExists: {
|
|
1131
|
+
readonly status: 409;
|
|
1132
|
+
readonly code: "ACCOUNT_ALREADY_EXISTS";
|
|
1133
|
+
readonly message: "An account with these details already exists.";
|
|
1134
|
+
};
|
|
1135
|
+
readonly accountExistsWithOtherMethod: {
|
|
1136
|
+
readonly status: 409;
|
|
1137
|
+
readonly code: "ACCOUNT_EXISTS_WITH_OTHER_METHOD";
|
|
1138
|
+
readonly message: "An account with this email already exists. Sign in your usual way, then link this account from your profile.";
|
|
1139
|
+
};
|
|
1140
|
+
readonly socialAccountAlreadyLinked: {
|
|
1141
|
+
readonly status: 409;
|
|
1142
|
+
readonly code: "SOCIAL_ACCOUNT_IN_USE";
|
|
1143
|
+
readonly message: "This account is already linked to another user.";
|
|
1144
|
+
};
|
|
1145
|
+
readonly cannotRemoveLastSignInMethod: {
|
|
1146
|
+
readonly status: 409;
|
|
1147
|
+
readonly code: "LAST_SIGN_IN_METHOD";
|
|
1148
|
+
readonly message: "Add another way to sign in before removing this one.";
|
|
1149
|
+
};
|
|
1150
|
+
readonly twoFactorAlreadyEnabled: {
|
|
1151
|
+
readonly status: 409;
|
|
1152
|
+
readonly code: "TWO_FACTOR_ALREADY_ENABLED";
|
|
1153
|
+
readonly message: "Two-factor authentication is already on.";
|
|
1154
|
+
};
|
|
1155
|
+
readonly twoFactorNotEnabled: {
|
|
1156
|
+
readonly status: 409;
|
|
1157
|
+
readonly code: "TWO_FACTOR_NOT_ENABLED";
|
|
1158
|
+
readonly message: "Two-factor authentication is not on.";
|
|
1159
|
+
};
|
|
1160
|
+
readonly twoFactorSetupNotStarted: {
|
|
1161
|
+
readonly status: 409;
|
|
1162
|
+
readonly code: "TWO_FACTOR_SETUP_NOT_STARTED";
|
|
1163
|
+
readonly message: "Start two-factor setup first.";
|
|
1164
|
+
};
|
|
1165
|
+
readonly organizationSlugTaken: {
|
|
1166
|
+
readonly status: 409;
|
|
1167
|
+
readonly code: "ORGANIZATION_SLUG_TAKEN";
|
|
1168
|
+
readonly message: "This organization handle is already taken.";
|
|
1169
|
+
};
|
|
1170
|
+
readonly alreadyOrganizationMember: {
|
|
1171
|
+
readonly status: 409;
|
|
1172
|
+
readonly code: "ALREADY_MEMBER";
|
|
1173
|
+
readonly message: "This person is already a member.";
|
|
1174
|
+
};
|
|
1175
|
+
readonly lastOrganizationOwner: {
|
|
1176
|
+
readonly status: 409;
|
|
1177
|
+
readonly code: "LAST_OWNER";
|
|
1178
|
+
readonly message: "An organization needs at least one owner.";
|
|
1179
|
+
};
|
|
1180
|
+
readonly accountNotDeactivated: {
|
|
1181
|
+
readonly status: 409;
|
|
1182
|
+
readonly code: "ACCOUNT_NOT_DEACTIVATED";
|
|
1183
|
+
readonly message: "This account is not deactivated.";
|
|
1184
|
+
};
|
|
1185
|
+
readonly emailInUse: {
|
|
1186
|
+
readonly status: 409;
|
|
1187
|
+
readonly code: "EMAIL_IN_USE";
|
|
1188
|
+
readonly message: "This email is already used by another account.";
|
|
1189
|
+
};
|
|
1190
|
+
readonly emailUnchanged: {
|
|
1191
|
+
readonly status: 400;
|
|
1192
|
+
readonly code: "EMAIL_UNCHANGED";
|
|
1193
|
+
readonly message: "This is already your email.";
|
|
1194
|
+
};
|
|
1195
|
+
readonly recentSignInRequired: {
|
|
1196
|
+
readonly status: 403;
|
|
1197
|
+
readonly code: "RECENT_SIGN_IN_REQUIRED";
|
|
1198
|
+
readonly message: "For your security, please sign in again and then retry.";
|
|
1199
|
+
};
|
|
1200
|
+
readonly originNotAllowed: {
|
|
1201
|
+
readonly status: 403;
|
|
1202
|
+
readonly code: "FORBIDDEN";
|
|
1203
|
+
readonly message: "This request did not come from an allowed website.";
|
|
1204
|
+
};
|
|
1205
|
+
readonly tooManyRequests: {
|
|
1206
|
+
readonly status: 429;
|
|
1207
|
+
readonly code: "TOO_MANY_REQUESTS";
|
|
1208
|
+
readonly message: "Too many attempts. Please try again later.";
|
|
1209
|
+
};
|
|
1210
|
+
readonly resendTooSoon: {
|
|
1211
|
+
readonly status: 429;
|
|
1212
|
+
readonly code: "TOO_MANY_REQUESTS";
|
|
1213
|
+
readonly message: "Please wait a minute before requesting another code.";
|
|
1214
|
+
};
|
|
1215
|
+
readonly invalidSettings: {
|
|
1216
|
+
readonly status: 400;
|
|
1217
|
+
readonly code: "INVALID_SETTINGS";
|
|
1218
|
+
readonly message: "Some settings are not valid.";
|
|
1219
|
+
};
|
|
1220
|
+
readonly unsafeWebhookUrl: {
|
|
1221
|
+
readonly status: 400;
|
|
1222
|
+
readonly code: "UNSAFE_WEBHOOK_URL";
|
|
1223
|
+
readonly message: "Webhook URLs must be public https addresses.";
|
|
1224
|
+
};
|
|
1225
|
+
readonly notConfigured: {
|
|
1226
|
+
readonly status: 501;
|
|
1227
|
+
readonly code: "NOT_CONFIGURED";
|
|
1228
|
+
readonly message: "This feature is not set up on the server.";
|
|
1229
|
+
};
|
|
1230
|
+
readonly internalError: {
|
|
1231
|
+
readonly status: 500;
|
|
1232
|
+
readonly code: "INTERNAL_SERVER_ERROR";
|
|
1233
|
+
readonly message: "Something went wrong. Please try again.";
|
|
1234
|
+
};
|
|
1235
|
+
};
|
|
1236
|
+
export type AuthErrorName = keyof typeof AUTH_ERRORS;
|
|
1237
|
+
/** Codes for Nest HTTP errors that are not AuthErrors (e.g. thrown by your own code or by Nest itself). */
|
|
1238
|
+
export declare const ERROR_CODE_BY_HTTP_STATUS: Record<number, string>;
|
|
1239
|
+
/** One entry of AUTH_ERRORS. */
|
|
1240
|
+
export interface AuthErrorDefinition {
|
|
1241
|
+
status: number;
|
|
1242
|
+
code: string;
|
|
1243
|
+
message: string;
|
|
1244
|
+
}
|
|
1245
|
+
/**
|
|
1246
|
+
* The settings used when neither your code nor an admin has changed them.
|
|
1247
|
+
* Secure by default: only email + password is on, verification is required, short-lived tokens.
|
|
1248
|
+
*/
|
|
1249
|
+
export declare const DEFAULT_SETTINGS: AuthSettings;
|
|
1250
|
+
/** How often each server runs the cleanup, and how long after start the first run waits. */
|
|
1251
|
+
export declare const DATA_RETENTION_INTERVAL_MS: number;
|
|
1252
|
+
export declare const DATA_RETENTION_FIRST_RUN_DELAY_MS: number;
|
|
1253
|
+
/** Rows deleted per statement, so a cleanup never holds locks for long. */
|
|
1254
|
+
export declare const DATA_RETENTION_BATCH_SIZE = 5000;
|
|
1255
|
+
/** Most batches per table per run; the rest waits for the next run. */
|
|
1256
|
+
export declare const DATA_RETENTION_MAX_BATCHES_PER_TABLE = 100;
|
|
1257
|
+
/** Names of the cleanup steps, used as keys in the cleanup report. */
|
|
1258
|
+
export declare const DATA_RETENTION_STEP: {
|
|
1259
|
+
readonly endedSessions: "endedSessions";
|
|
1260
|
+
readonly expiredRefreshTokens: "expiredRefreshTokens";
|
|
1261
|
+
readonly linkTokens: "linkTokens";
|
|
1262
|
+
readonly oneTimeCodes: "oneTimeCodes";
|
|
1263
|
+
readonly signInChallenges: "signInChallenges";
|
|
1264
|
+
readonly organizationInvitations: "organizationInvitations";
|
|
1265
|
+
readonly webhookDeliveries: "webhookDeliveries";
|
|
1266
|
+
readonly auditLog: "auditLog";
|
|
1267
|
+
};
|
|
1268
|
+
export type DataRetentionStep = (typeof DATA_RETENTION_STEP)[keyof typeof DATA_RETENTION_STEP];
|
|
1269
|
+
/** SQL condition marking a row of each step as old (`:cutoff` = now minus the days to keep). */
|
|
1270
|
+
export declare const DATA_RETENTION_OLD_ROW_CONDITION: Record<DataRetentionStep, string>;
|
|
1271
|
+
/**
|
|
1272
|
+
* One batch of old rows (by primary key), so each DELETE statement stays short.
|
|
1273
|
+
*
|
|
1274
|
+
* @param tableName - The table to clean (from TypeORM metadata, never user input).
|
|
1275
|
+
* @param oldRowCondition - Which rows count as old, from DATA_RETENTION_OLD_ROW_CONDITION.
|
|
1276
|
+
* @returns A WHERE clause using the :cutoff and :batchSize parameters.
|
|
1277
|
+
*/
|
|
1278
|
+
export declare const DATA_RETENTION_BATCH_CONDITION: (tableName: string, oldRowCondition: string) => string;
|
|
1279
|
+
/** Cookies named "__Host-..." are locked by the browser to Secure, path "/" and no domain. */
|
|
1280
|
+
export declare const HOST_COOKIE_PREFIX = "__Host-";
|
|
1281
|
+
export declare const COOKIE_SAME_SITE: {
|
|
1282
|
+
readonly strict: "Strict";
|
|
1283
|
+
readonly lax: "Lax";
|
|
1284
|
+
readonly none: "None";
|
|
1285
|
+
};
|
|
1286
|
+
export type CookieSameSite = (typeof COOKIE_SAME_SITE)[keyof typeof COOKIE_SAME_SITE];
|
|
1287
|
+
export declare const REFRESH_TOKEN_COOKIE_DEFAULTS: {
|
|
1288
|
+
readonly name: "__Host-refresh_token";
|
|
1289
|
+
/** "__Host-" cookies must use path "/" and no domain; with a custom name you may narrow it. */
|
|
1290
|
+
readonly path: "/";
|
|
1291
|
+
readonly sameSite: "Strict";
|
|
1292
|
+
};
|
|
1293
|
+
/** Cookie attribute names, written by serializeCookie(). */
|
|
1294
|
+
export declare const COOKIE_ATTRIBUTE: {
|
|
1295
|
+
readonly maxAge: "Max-Age";
|
|
1296
|
+
readonly path: "Path";
|
|
1297
|
+
readonly domain: "Domain";
|
|
1298
|
+
readonly sameSite: "SameSite";
|
|
1299
|
+
readonly httpOnly: "HttpOnly";
|
|
1300
|
+
readonly secure: "Secure";
|
|
1301
|
+
};
|
|
1302
|
+
export declare const COOKIE_PAIR_SEPARATOR = ";";
|
|
1303
|
+
/** Between a cookie's attributes in a Set-Cookie header. */
|
|
1304
|
+
export declare const COOKIE_ATTRIBUTE_SEPARATOR = "; ";
|
|
1305
|
+
export declare const COOKIE_NAME_VALUE_SEPARATOR = "=";
|
|
1306
|
+
/** Response fields holding the refresh token; moved into the cookie when cookie mode is on. */
|
|
1307
|
+
export declare const REFRESH_TOKEN_RESPONSE_FIELD = "refreshToken";
|
|
1308
|
+
/** Response field saying the refresh token is in the cookie instead of the body. */
|
|
1309
|
+
export declare const REFRESH_TOKEN_IN_COOKIE_FIELD = "refreshTokenInCookie";
|
|
1310
|
+
/** Response field with the refresh token's expiry time (sets the cookie's lifetime). */
|
|
1311
|
+
export declare const REFRESH_TOKEN_EXPIRES_AT_RESPONSE_FIELD = "refreshTokenExpiresAt";
|
|
1312
|
+
export declare const HEALTH_STATUS: {
|
|
1313
|
+
readonly ok: "ok";
|
|
1314
|
+
readonly error: "error";
|
|
1315
|
+
readonly notUsed: "not_used";
|
|
1316
|
+
};
|
|
1317
|
+
export type HealthStatus = (typeof HEALTH_STATUS)[keyof typeof HEALTH_STATUS];
|
|
1318
|
+
/** A health check that takes longer than this counts as failed. */
|
|
1319
|
+
export declare const HEALTH_CHECK_TIMEOUT_MS = 2000;
|
|
1320
|
+
/** The cheapest query that proves PostgreSQL answers. */
|
|
1321
|
+
export declare const HEALTH_CHECK_QUERY = "SELECT 1";
|
|
1322
|
+
export declare const HEALTH_SERVICE_UNAVAILABLE_STATUS = 503;
|
|
1323
|
+
/** Most audit-log entries included in "download my data" (newest first). */
|
|
1324
|
+
export declare const DATA_EXPORT_AUDIT_LOG_LIMIT = 1000;
|
|
1325
|
+
/** Window of the admin stats endpoint ("sign-ins in the last 24 hours"). */
|
|
1326
|
+
export declare const ADMIN_STATS_WINDOW_SECONDS: number;
|