@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,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.OrganizationEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
/** A company or team. Users join organizations with a role (owner, admin, member). */
|
|
15
|
+
let OrganizationEntity = class OrganizationEntity {
|
|
16
|
+
id;
|
|
17
|
+
name;
|
|
18
|
+
/** Unique handle, e.g. "acme-india". */
|
|
19
|
+
slug;
|
|
20
|
+
metadata;
|
|
21
|
+
createdByUserId;
|
|
22
|
+
createdAt;
|
|
23
|
+
updatedAt;
|
|
24
|
+
};
|
|
25
|
+
exports.OrganizationEntity = OrganizationEntity;
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], OrganizationEntity.prototype, "id", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.Column)({ type: 'text' }),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], OrganizationEntity.prototype, "name", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, typeorm_1.Index)({ unique: true }),
|
|
36
|
+
(0, typeorm_1.Column)({ type: 'text' }),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], OrganizationEntity.prototype, "slug", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, typeorm_1.Column)({ type: 'jsonb', default: {} }),
|
|
41
|
+
__metadata("design:type", Object)
|
|
42
|
+
], OrganizationEntity.prototype, "metadata", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, typeorm_1.Column)({ name: 'created_by_user_id', type: 'uuid', nullable: true }),
|
|
45
|
+
__metadata("design:type", Object)
|
|
46
|
+
], OrganizationEntity.prototype, "createdByUserId", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz' }),
|
|
49
|
+
__metadata("design:type", Date)
|
|
50
|
+
], OrganizationEntity.prototype, "createdAt", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, typeorm_1.UpdateDateColumn)({ name: 'updated_at', type: 'timestamptz' }),
|
|
53
|
+
__metadata("design:type", Date)
|
|
54
|
+
], OrganizationEntity.prototype, "updatedAt", void 0);
|
|
55
|
+
exports.OrganizationEntity = OrganizationEntity = __decorate([
|
|
56
|
+
(0, typeorm_1.Entity)('auth_organizations')
|
|
57
|
+
], OrganizationEntity);
|
|
58
|
+
//# sourceMappingURL=organization.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization.entity.js","sourceRoot":"","sources":["../../../src/database/entities/organization.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA4G;AAG5G,sFAAsF;AAE/E,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAE7B,EAAE,CAAS;IAGX,IAAI,CAAS;IAEb,wCAAwC;IAGxC,IAAI,CAAS;IAGb,QAAQ,CAAa;IAGrB,eAAe,CAAgB;IAG/B,SAAS,CAAO;IAGhB,SAAS,CAAO;CACjB,CAAA;AAvBY,gDAAkB;AAE7B;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;8CACpB;AAGX;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDACZ;AAKb;IAFC,IAAA,eAAK,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACvB,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDACZ;AAGb;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;oDAClB;AAGrB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2DACtC;AAG/B;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;8BACnD,IAAI;qDAAC;AAGhB;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;8BACnD,IAAI;qDAAC;6BAtBL,kBAAkB;IAD9B,IAAA,gBAAM,EAAC,oBAAoB,CAAC;GAChB,kBAAkB,CAuB9B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** A passkey (Face ID, Touch ID, Windows Hello, security key) registered by a user. */
|
|
2
|
+
export declare class PasskeyEntity {
|
|
3
|
+
id: string;
|
|
4
|
+
userId: string;
|
|
5
|
+
/** The id the device gave this passkey (base64url). */
|
|
6
|
+
credentialId: string;
|
|
7
|
+
/** The passkey's public key (base64url). The private key never leaves the user's device. */
|
|
8
|
+
publicKey: string;
|
|
9
|
+
/** Signature counter; if it goes backwards the passkey may have been cloned. */
|
|
10
|
+
signCount: number;
|
|
11
|
+
/** How the device talks to the browser, e.g. ["internal", "hybrid"]. */
|
|
12
|
+
transports: string[];
|
|
13
|
+
/** Name the user gave it, e.g. "My iPhone". */
|
|
14
|
+
name: string;
|
|
15
|
+
/** True when the passkey is synced (iCloud Keychain, Google Password Manager). */
|
|
16
|
+
isBackedUp: boolean;
|
|
17
|
+
createdAt: Date;
|
|
18
|
+
lastUsedAt: Date | null;
|
|
19
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PasskeyEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
/** A passkey (Face ID, Touch ID, Windows Hello, security key) registered by a user. */
|
|
15
|
+
let PasskeyEntity = class PasskeyEntity {
|
|
16
|
+
id;
|
|
17
|
+
userId;
|
|
18
|
+
/** The id the device gave this passkey (base64url). */
|
|
19
|
+
credentialId;
|
|
20
|
+
/** The passkey's public key (base64url). The private key never leaves the user's device. */
|
|
21
|
+
publicKey;
|
|
22
|
+
/** Signature counter; if it goes backwards the passkey may have been cloned. */
|
|
23
|
+
signCount;
|
|
24
|
+
/** How the device talks to the browser, e.g. ["internal", "hybrid"]. */
|
|
25
|
+
transports;
|
|
26
|
+
/** Name the user gave it, e.g. "My iPhone". */
|
|
27
|
+
name;
|
|
28
|
+
/** True when the passkey is synced (iCloud Keychain, Google Password Manager). */
|
|
29
|
+
isBackedUp;
|
|
30
|
+
createdAt;
|
|
31
|
+
lastUsedAt;
|
|
32
|
+
};
|
|
33
|
+
exports.PasskeyEntity = PasskeyEntity;
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], PasskeyEntity.prototype, "id", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typeorm_1.Column)({ name: 'user_id', type: 'uuid' }),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], PasskeyEntity.prototype, "userId", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, typeorm_1.Index)({ unique: true }),
|
|
44
|
+
(0, typeorm_1.Column)({ name: 'credential_id', type: 'text' }),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], PasskeyEntity.prototype, "credentialId", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, typeorm_1.Column)({ name: 'public_key', type: 'text' }),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], PasskeyEntity.prototype, "publicKey", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, typeorm_1.Column)({ name: 'sign_count', type: 'bigint', default: 0, transformer: { to: (v) => v, from: (v) => Number(v) } }),
|
|
53
|
+
__metadata("design:type", Number)
|
|
54
|
+
], PasskeyEntity.prototype, "signCount", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, typeorm_1.Column)({ type: 'text', array: true, default: '{}' }),
|
|
57
|
+
__metadata("design:type", Array)
|
|
58
|
+
], PasskeyEntity.prototype, "transports", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, typeorm_1.Column)({ type: 'text' }),
|
|
61
|
+
__metadata("design:type", String)
|
|
62
|
+
], PasskeyEntity.prototype, "name", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, typeorm_1.Column)({ name: 'is_backed_up', type: 'boolean', default: false }),
|
|
65
|
+
__metadata("design:type", Boolean)
|
|
66
|
+
], PasskeyEntity.prototype, "isBackedUp", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz' }),
|
|
69
|
+
__metadata("design:type", Date)
|
|
70
|
+
], PasskeyEntity.prototype, "createdAt", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
(0, typeorm_1.Column)({ name: 'last_used_at', type: 'timestamptz', nullable: true }),
|
|
73
|
+
__metadata("design:type", Object)
|
|
74
|
+
], PasskeyEntity.prototype, "lastUsedAt", void 0);
|
|
75
|
+
exports.PasskeyEntity = PasskeyEntity = __decorate([
|
|
76
|
+
(0, typeorm_1.Entity)('auth_passkeys')
|
|
77
|
+
], PasskeyEntity);
|
|
78
|
+
//# sourceMappingURL=passkey.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passkey.entity.js","sourceRoot":"","sources":["../../../src/database/entities/passkey.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA0F;AAE1F,uFAAuF;AAEhF,IAAM,aAAa,GAAnB,MAAM,aAAa;IAExB,EAAE,CAAS;IAGX,MAAM,CAAS;IAEf,uDAAuD;IAGvD,YAAY,CAAS;IAErB,4FAA4F;IAE5F,SAAS,CAAS;IAElB,gFAAgF;IAEhF,SAAS,CAAS;IAElB,wEAAwE;IAExE,UAAU,CAAW;IAErB,+CAA+C;IAE/C,IAAI,CAAS;IAEb,kFAAkF;IAElF,UAAU,CAAU;IAGpB,SAAS,CAAO;IAGhB,UAAU,CAAc;CACzB,CAAA;AArCY,sCAAa;AAExB;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;yCACpB;AAGX;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6CAC3B;AAKf;IAFC,IAAA,eAAK,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACvB,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mDAC3B;AAIrB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDAC3B;AAIlB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;;gDAChH;AAIlB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;iDAChC;AAIrB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;2CACZ;AAIb;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;iDAC9C;AAGpB;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;8BACnD,IAAI;gDAAC;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDAC9C;wBApCb,aAAa;IADzB,IAAA,gBAAM,EAAC,eAAe,CAAC;GACX,aAAa,CAqCzB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PasswordEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
/** A user's password, stored only as an Argon2id hash. */
|
|
15
|
+
let PasswordEntity = class PasswordEntity {
|
|
16
|
+
userId;
|
|
17
|
+
passwordHash;
|
|
18
|
+
updatedAt;
|
|
19
|
+
};
|
|
20
|
+
exports.PasswordEntity = PasswordEntity;
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, typeorm_1.PrimaryColumn)({ name: 'user_id', type: 'uuid' }),
|
|
23
|
+
__metadata("design:type", String)
|
|
24
|
+
], PasswordEntity.prototype, "userId", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, typeorm_1.Column)({ name: 'password_hash', type: 'text' }),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], PasswordEntity.prototype, "passwordHash", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.UpdateDateColumn)({ name: 'updated_at', type: 'timestamptz' }),
|
|
31
|
+
__metadata("design:type", Date)
|
|
32
|
+
], PasswordEntity.prototype, "updatedAt", void 0);
|
|
33
|
+
exports.PasswordEntity = PasswordEntity = __decorate([
|
|
34
|
+
(0, typeorm_1.Entity)('auth_passwords')
|
|
35
|
+
], PasswordEntity);
|
|
36
|
+
//# sourceMappingURL=password.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password.entity.js","sourceRoot":"","sources":["../../../src/database/entities/password.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA0E;AAE1E,0DAA0D;AAEnD,IAAM,cAAc,GAApB,MAAM,cAAc;IAEzB,MAAM,CAAS;IAGf,YAAY,CAAS;IAGrB,SAAS,CAAO;CACjB,CAAA;AATY,wCAAc;AAEzB;IADC,IAAA,uBAAa,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;8CAClC;AAGf;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDAC3B;AAGrB;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;8BACnD,IAAI;iDAAC;yBARL,cAAc;IAD1B,IAAA,gBAAM,EAAC,gBAAgB,CAAC;GACZ,cAAc,CAS1B"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RefreshTokenEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
/** Single-use refresh tokens. Each refresh marks the old one used and creates a new one. */
|
|
15
|
+
let RefreshTokenEntity = class RefreshTokenEntity {
|
|
16
|
+
id;
|
|
17
|
+
sessionId;
|
|
18
|
+
tokenHash;
|
|
19
|
+
expiresAt;
|
|
20
|
+
usedAt;
|
|
21
|
+
createdAt;
|
|
22
|
+
};
|
|
23
|
+
exports.RefreshTokenEntity = RefreshTokenEntity;
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], RefreshTokenEntity.prototype, "id", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, typeorm_1.Index)(),
|
|
30
|
+
(0, typeorm_1.Column)({ name: 'session_id', type: 'uuid' }),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], RefreshTokenEntity.prototype, "sessionId", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, typeorm_1.Index)({ unique: true }),
|
|
35
|
+
(0, typeorm_1.Column)({ name: 'token_hash', type: 'text' }),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], RefreshTokenEntity.prototype, "tokenHash", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typeorm_1.Column)({ name: 'expires_at', type: 'timestamptz' }),
|
|
40
|
+
__metadata("design:type", Date)
|
|
41
|
+
], RefreshTokenEntity.prototype, "expiresAt", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, typeorm_1.Column)({ name: 'used_at', type: 'timestamptz', nullable: true }),
|
|
44
|
+
__metadata("design:type", Object)
|
|
45
|
+
], RefreshTokenEntity.prototype, "usedAt", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz' }),
|
|
48
|
+
__metadata("design:type", Date)
|
|
49
|
+
], RefreshTokenEntity.prototype, "createdAt", void 0);
|
|
50
|
+
exports.RefreshTokenEntity = RefreshTokenEntity = __decorate([
|
|
51
|
+
(0, typeorm_1.Entity)('auth_refresh_tokens')
|
|
52
|
+
], RefreshTokenEntity);
|
|
53
|
+
//# sourceMappingURL=refresh-token.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refresh-token.entity.js","sourceRoot":"","sources":["../../../src/database/entities/refresh-token.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA0F;AAE1F,4FAA4F;AAErF,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAE7B,EAAE,CAAS;IAIX,SAAS,CAAS;IAIlB,SAAS,CAAS;IAGlB,SAAS,CAAO;IAGhB,MAAM,CAAc;IAGpB,SAAS,CAAO;CACjB,CAAA;AApBY,gDAAkB;AAE7B;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;8CACpB;AAIX;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;qDAC3B;AAIlB;IAFC,IAAA,eAAK,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACvB,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;qDAC3B;AAGlB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;8BACzC,IAAI;qDAAC;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDAC7C;AAGpB;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;8BACnD,IAAI;qDAAC;6BAnBL,kBAAkB;IAD9B,IAAA,gBAAM,EAAC,qBAAqB,CAAC;GACjB,kBAAkB,CAoB9B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** One signed-in device. Signing out ends the session and every refresh token in it. */
|
|
2
|
+
export declare class SessionEntity {
|
|
3
|
+
id: string;
|
|
4
|
+
userId: string;
|
|
5
|
+
/** How the user signed in: password, email_code, magic_link, phone_code, google, apple, facebook, passkey. */
|
|
6
|
+
signInMethod: string;
|
|
7
|
+
/** True when a 2FA code was also checked. */
|
|
8
|
+
usedTwoFactor: boolean;
|
|
9
|
+
/** The organization this device is currently working in (copied into the access token). */
|
|
10
|
+
activeOrganizationId: string | null;
|
|
11
|
+
ipAddress: string | null;
|
|
12
|
+
userAgent: string | null;
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
lastUsedAt: Date;
|
|
15
|
+
/** Hard limit: after this the user must sign in again, however often they refresh. */
|
|
16
|
+
expiresAt: Date;
|
|
17
|
+
revokedAt: Date | null;
|
|
18
|
+
/** Why it ended: signed_out, password_changed, refresh_token_reused, admin... */
|
|
19
|
+
revokedReason: string | null;
|
|
20
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SessionEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
/** One signed-in device. Signing out ends the session and every refresh token in it. */
|
|
15
|
+
let SessionEntity = class SessionEntity {
|
|
16
|
+
id;
|
|
17
|
+
userId;
|
|
18
|
+
/** How the user signed in: password, email_code, magic_link, phone_code, google, apple, facebook, passkey. */
|
|
19
|
+
signInMethod;
|
|
20
|
+
/** True when a 2FA code was also checked. */
|
|
21
|
+
usedTwoFactor;
|
|
22
|
+
/** The organization this device is currently working in (copied into the access token). */
|
|
23
|
+
activeOrganizationId;
|
|
24
|
+
ipAddress;
|
|
25
|
+
userAgent;
|
|
26
|
+
createdAt;
|
|
27
|
+
lastUsedAt;
|
|
28
|
+
/** Hard limit: after this the user must sign in again, however often they refresh. */
|
|
29
|
+
expiresAt;
|
|
30
|
+
revokedAt;
|
|
31
|
+
/** Why it ended: signed_out, password_changed, refresh_token_reused, admin... */
|
|
32
|
+
revokedReason;
|
|
33
|
+
};
|
|
34
|
+
exports.SessionEntity = SessionEntity;
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], SessionEntity.prototype, "id", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, typeorm_1.Index)(),
|
|
41
|
+
(0, typeorm_1.Column)({ name: 'user_id', type: 'uuid' }),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], SessionEntity.prototype, "userId", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, typeorm_1.Column)({ name: 'sign_in_method', type: 'text' }),
|
|
46
|
+
__metadata("design:type", String)
|
|
47
|
+
], SessionEntity.prototype, "signInMethod", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, typeorm_1.Column)({ name: 'used_two_factor', type: 'boolean', default: false }),
|
|
50
|
+
__metadata("design:type", Boolean)
|
|
51
|
+
], SessionEntity.prototype, "usedTwoFactor", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, typeorm_1.Column)({ name: 'active_organization_id', type: 'uuid', nullable: true }),
|
|
54
|
+
__metadata("design:type", Object)
|
|
55
|
+
], SessionEntity.prototype, "activeOrganizationId", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, typeorm_1.Column)({ name: 'ip_address', type: 'text', nullable: true }),
|
|
58
|
+
__metadata("design:type", Object)
|
|
59
|
+
], SessionEntity.prototype, "ipAddress", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
(0, typeorm_1.Column)({ name: 'user_agent', type: 'text', nullable: true }),
|
|
62
|
+
__metadata("design:type", Object)
|
|
63
|
+
], SessionEntity.prototype, "userAgent", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz' }),
|
|
66
|
+
__metadata("design:type", Date)
|
|
67
|
+
], SessionEntity.prototype, "createdAt", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
(0, typeorm_1.Column)({ name: 'last_used_at', type: 'timestamptz' }),
|
|
70
|
+
__metadata("design:type", Date)
|
|
71
|
+
], SessionEntity.prototype, "lastUsedAt", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, typeorm_1.Column)({ name: 'expires_at', type: 'timestamptz' }),
|
|
74
|
+
__metadata("design:type", Date)
|
|
75
|
+
], SessionEntity.prototype, "expiresAt", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
(0, typeorm_1.Column)({ name: 'revoked_at', type: 'timestamptz', nullable: true }),
|
|
78
|
+
__metadata("design:type", Object)
|
|
79
|
+
], SessionEntity.prototype, "revokedAt", void 0);
|
|
80
|
+
__decorate([
|
|
81
|
+
(0, typeorm_1.Column)({ name: 'revoked_reason', type: 'text', nullable: true }),
|
|
82
|
+
__metadata("design:type", Object)
|
|
83
|
+
], SessionEntity.prototype, "revokedReason", void 0);
|
|
84
|
+
exports.SessionEntity = SessionEntity = __decorate([
|
|
85
|
+
(0, typeorm_1.Entity)('auth_sessions')
|
|
86
|
+
], SessionEntity);
|
|
87
|
+
//# sourceMappingURL=session.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.entity.js","sourceRoot":"","sources":["../../../src/database/entities/session.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA0F;AAE1F,wFAAwF;AAEjF,IAAM,aAAa,GAAnB,MAAM,aAAa;IAExB,EAAE,CAAS;IAIX,MAAM,CAAS;IAEf,8GAA8G;IAE9G,YAAY,CAAS;IAErB,6CAA6C;IAE7C,aAAa,CAAU;IAEvB,2FAA2F;IAE3F,oBAAoB,CAAgB;IAGpC,SAAS,CAAgB;IAGzB,SAAS,CAAgB;IAGzB,SAAS,CAAO;IAGhB,UAAU,CAAO;IAEjB,sFAAsF;IAEtF,SAAS,CAAO;IAGhB,SAAS,CAAc;IAEvB,iFAAiF;IAEjF,aAAa,CAAgB;CAC9B,CAAA;AA1CY,sCAAa;AAExB;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;yCACpB;AAIX;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6CAC3B;AAIf;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mDAC5B;AAIrB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;oDAC9C;AAIvB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,wBAAwB,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2DACrC;AAGpC;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACpC;AAGzB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACpC;AAGzB;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;8BACnD,IAAI;gDAAC;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;8BAC1C,IAAI;iDAAC;AAIjB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;8BACzC,IAAI;gDAAC;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDAC7C;AAIvB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oDACpC;wBAzClB,aAAa;IADzB,IAAA,gBAAM,EAAC,eAAe,CAAC;GACX,aAAa,CA0CzB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SettingsEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
/** Settings changed at runtime by admins. One row (id = 1). No row = use the settings in code. */
|
|
15
|
+
let SettingsEntity = class SettingsEntity {
|
|
16
|
+
id;
|
|
17
|
+
changedValues;
|
|
18
|
+
changedBy;
|
|
19
|
+
updatedAt;
|
|
20
|
+
};
|
|
21
|
+
exports.SettingsEntity = SettingsEntity;
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, typeorm_1.PrimaryColumn)({ type: 'int', default: 1 }),
|
|
24
|
+
__metadata("design:type", Number)
|
|
25
|
+
], SettingsEntity.prototype, "id", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.Column)({ name: 'changed_values', type: 'jsonb' }),
|
|
28
|
+
__metadata("design:type", Object)
|
|
29
|
+
], SettingsEntity.prototype, "changedValues", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.Column)({ name: 'changed_by', type: 'text' }),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], SettingsEntity.prototype, "changedBy", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, typeorm_1.UpdateDateColumn)({ name: 'updated_at', type: 'timestamptz' }),
|
|
36
|
+
__metadata("design:type", Date)
|
|
37
|
+
], SettingsEntity.prototype, "updatedAt", void 0);
|
|
38
|
+
exports.SettingsEntity = SettingsEntity = __decorate([
|
|
39
|
+
(0, typeorm_1.Entity)('auth_settings')
|
|
40
|
+
], SettingsEntity);
|
|
41
|
+
//# sourceMappingURL=settings.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.entity.js","sourceRoot":"","sources":["../../../src/database/entities/settings.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA0E;AAE1E,kGAAkG;AAE3F,IAAM,cAAc,GAApB,MAAM,cAAc;IAEzB,EAAE,CAAS;IAGX,aAAa,CAAsB;IAGnC,SAAS,CAAS;IAGlB,SAAS,CAAO;CACjB,CAAA;AAZY,wCAAc;AAEzB;IADC,IAAA,uBAAa,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;0CAChC;AAGX;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;qDACf;AAGnC;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;iDAC3B;AAGlB;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;8BACnD,IAAI;iDAAC;yBAXL,cAAc;IAD1B,IAAA,gBAAM,EAAC,eAAe,CAAC;GACX,cAAc,CAY1B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ChallengePurpose } from '../../constants.js';
|
|
2
|
+
export type { ChallengePurpose };
|
|
3
|
+
/**
|
|
4
|
+
* A sign-in that is half done:
|
|
5
|
+
* - two_factor: the password (or code) was right, now we wait for the 2FA code.
|
|
6
|
+
* - reactivate_account: a DEACTIVATED user proved who they are; the token lets them reactivate.
|
|
7
|
+
* - passkey_*: we sent the device a random challenge and wait for it to sign it.
|
|
8
|
+
*/
|
|
9
|
+
export declare class SignInChallengeEntity {
|
|
10
|
+
id: string;
|
|
11
|
+
purpose: ChallengePurpose;
|
|
12
|
+
userId: string | null;
|
|
13
|
+
/** Hash of the token the client sends back to continue (for 2FA). */
|
|
14
|
+
challengeTokenHash: string | null;
|
|
15
|
+
/** The random WebAuthn challenge the device must sign (for passkeys). */
|
|
16
|
+
webauthnChallenge: string | null;
|
|
17
|
+
/** For 2FA: how the first step was done, kept for the session record. */
|
|
18
|
+
signInMethod: string | null;
|
|
19
|
+
failedAttempts: number;
|
|
20
|
+
expiresAt: Date;
|
|
21
|
+
usedAt: Date | null;
|
|
22
|
+
createdAt: Date;
|
|
23
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SignInChallengeEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
/**
|
|
15
|
+
* A sign-in that is half done:
|
|
16
|
+
* - two_factor: the password (or code) was right, now we wait for the 2FA code.
|
|
17
|
+
* - reactivate_account: a DEACTIVATED user proved who they are; the token lets them reactivate.
|
|
18
|
+
* - passkey_*: we sent the device a random challenge and wait for it to sign it.
|
|
19
|
+
*/
|
|
20
|
+
let SignInChallengeEntity = class SignInChallengeEntity {
|
|
21
|
+
id;
|
|
22
|
+
purpose;
|
|
23
|
+
userId;
|
|
24
|
+
/** Hash of the token the client sends back to continue (for 2FA). */
|
|
25
|
+
challengeTokenHash;
|
|
26
|
+
/** The random WebAuthn challenge the device must sign (for passkeys). */
|
|
27
|
+
webauthnChallenge;
|
|
28
|
+
/** For 2FA: how the first step was done, kept for the session record. */
|
|
29
|
+
signInMethod;
|
|
30
|
+
failedAttempts;
|
|
31
|
+
expiresAt;
|
|
32
|
+
usedAt;
|
|
33
|
+
createdAt;
|
|
34
|
+
};
|
|
35
|
+
exports.SignInChallengeEntity = SignInChallengeEntity;
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
38
|
+
__metadata("design:type", String)
|
|
39
|
+
], SignInChallengeEntity.prototype, "id", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, typeorm_1.Column)({ type: 'text' }),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], SignInChallengeEntity.prototype, "purpose", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, typeorm_1.Column)({ name: 'user_id', type: 'uuid', nullable: true }),
|
|
46
|
+
__metadata("design:type", Object)
|
|
47
|
+
], SignInChallengeEntity.prototype, "userId", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, typeorm_1.Index)({ unique: true, where: 'challenge_token_hash IS NOT NULL' }),
|
|
50
|
+
(0, typeorm_1.Column)({ name: 'challenge_token_hash', type: 'text', nullable: true }),
|
|
51
|
+
__metadata("design:type", Object)
|
|
52
|
+
], SignInChallengeEntity.prototype, "challengeTokenHash", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, typeorm_1.Column)({ name: 'webauthn_challenge', type: 'text', nullable: true }),
|
|
55
|
+
__metadata("design:type", Object)
|
|
56
|
+
], SignInChallengeEntity.prototype, "webauthnChallenge", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, typeorm_1.Column)({ name: 'sign_in_method', type: 'text', nullable: true }),
|
|
59
|
+
__metadata("design:type", Object)
|
|
60
|
+
], SignInChallengeEntity.prototype, "signInMethod", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, typeorm_1.Column)({ name: 'failed_attempts', type: 'int', default: 0 }),
|
|
63
|
+
__metadata("design:type", Number)
|
|
64
|
+
], SignInChallengeEntity.prototype, "failedAttempts", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, typeorm_1.Column)({ name: 'expires_at', type: 'timestamptz' }),
|
|
67
|
+
__metadata("design:type", Date)
|
|
68
|
+
], SignInChallengeEntity.prototype, "expiresAt", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, typeorm_1.Column)({ name: 'used_at', type: 'timestamptz', nullable: true }),
|
|
71
|
+
__metadata("design:type", Object)
|
|
72
|
+
], SignInChallengeEntity.prototype, "usedAt", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
(0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz' }),
|
|
75
|
+
__metadata("design:type", Date)
|
|
76
|
+
], SignInChallengeEntity.prototype, "createdAt", void 0);
|
|
77
|
+
exports.SignInChallengeEntity = SignInChallengeEntity = __decorate([
|
|
78
|
+
(0, typeorm_1.Entity)('auth_sign_in_challenges')
|
|
79
|
+
], SignInChallengeEntity);
|
|
80
|
+
//# sourceMappingURL=sign-in-challenge.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-in-challenge.entity.js","sourceRoot":"","sources":["../../../src/database/entities/sign-in-challenge.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA0F;AAK1F;;;;;GAKG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAEhC,EAAE,CAAS;IAGX,OAAO,CAAmB;IAG1B,MAAM,CAAgB;IAEtB,qEAAqE;IAGrE,kBAAkB,CAAgB;IAElC,yEAAyE;IAEzE,iBAAiB,CAAgB;IAEjC,yEAAyE;IAEzE,YAAY,CAAgB;IAG5B,cAAc,CAAS;IAGvB,SAAS,CAAO;IAGhB,MAAM,CAAc;IAGpB,SAAS,CAAO;CACjB,CAAA;AAlCY,sDAAqB;AAEhC;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;iDACpB;AAGX;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;sDACC;AAG1B;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACpC;AAKtB;IAFC,IAAA,eAAK,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,kCAAkC,EAAE,CAAC;IAClE,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iEACrC;AAIlC;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gEACpC;AAIjC;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2DACrC;AAG5B;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;6DACtC;AAGvB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;8BACzC,IAAI;wDAAC;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDAC7C;AAGpB;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;8BACnD,IAAI;wDAAC;gCAjCL,qBAAqB;IADjC,IAAA,gBAAM,EAAC,yBAAyB,CAAC;GACrB,qBAAqB,CAkCjC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Keys that sign tokens. The private half is stored encrypted (AWS KMS in production). */
|
|
2
|
+
export declare class SigningKeyEntity {
|
|
3
|
+
id: string;
|
|
4
|
+
/** Key id, put in every token header so verifiers know which public key to use. */
|
|
5
|
+
keyId: string;
|
|
6
|
+
publicKey: Record<string, string>;
|
|
7
|
+
encryptedPrivateKey: string;
|
|
8
|
+
createdAt: Date;
|
|
9
|
+
/** Null for the key in use. Retired keys stay published for a while so older tokens still verify. */
|
|
10
|
+
retiredAt: Date | null;
|
|
11
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SigningKeyEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
/** Keys that sign tokens. The private half is stored encrypted (AWS KMS in production). */
|
|
15
|
+
let SigningKeyEntity = class SigningKeyEntity {
|
|
16
|
+
id;
|
|
17
|
+
/** Key id, put in every token header so verifiers know which public key to use. */
|
|
18
|
+
keyId;
|
|
19
|
+
publicKey;
|
|
20
|
+
encryptedPrivateKey;
|
|
21
|
+
createdAt;
|
|
22
|
+
/** Null for the key in use. Retired keys stay published for a while so older tokens still verify. */
|
|
23
|
+
retiredAt;
|
|
24
|
+
};
|
|
25
|
+
exports.SigningKeyEntity = SigningKeyEntity;
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], SigningKeyEntity.prototype, "id", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.Index)({ unique: true }),
|
|
32
|
+
(0, typeorm_1.Column)({ name: 'key_id', type: 'text' }),
|
|
33
|
+
__metadata("design:type", String)
|
|
34
|
+
], SigningKeyEntity.prototype, "keyId", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, typeorm_1.Column)({ name: 'public_key', type: 'jsonb' }),
|
|
37
|
+
__metadata("design:type", Object)
|
|
38
|
+
], SigningKeyEntity.prototype, "publicKey", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, typeorm_1.Column)({ name: 'encrypted_private_key', type: 'text' }),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], SigningKeyEntity.prototype, "encryptedPrivateKey", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz' }),
|
|
45
|
+
__metadata("design:type", Date)
|
|
46
|
+
], SigningKeyEntity.prototype, "createdAt", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, typeorm_1.Column)({ name: 'retired_at', type: 'timestamptz', nullable: true }),
|
|
49
|
+
__metadata("design:type", Object)
|
|
50
|
+
], SigningKeyEntity.prototype, "retiredAt", void 0);
|
|
51
|
+
exports.SigningKeyEntity = SigningKeyEntity = __decorate([
|
|
52
|
+
(0, typeorm_1.Entity)('auth_signing_keys')
|
|
53
|
+
], SigningKeyEntity);
|
|
54
|
+
//# sourceMappingURL=signing-key.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signing-key.entity.js","sourceRoot":"","sources":["../../../src/database/entities/signing-key.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA0F;AAE1F,2FAA2F;AAEpF,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAE3B,EAAE,CAAS;IAEX,mFAAmF;IAGnF,KAAK,CAAS;IAGd,SAAS,CAAyB;IAGlC,mBAAmB,CAAS;IAG5B,SAAS,CAAO;IAEhB,qGAAqG;IAErG,SAAS,CAAc;CACxB,CAAA;AArBY,4CAAgB;AAE3B;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;4CACpB;AAKX;IAFC,IAAA,eAAK,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACvB,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;+CAC3B;AAGd;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;mDACZ;AAGlC;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6DAC5B;AAG5B;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;8BACnD,IAAI;mDAAC;AAIhB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mDAC7C;2BApBZ,gBAAgB;IAD5B,IAAA,gBAAM,EAAC,mBAAmB,CAAC;GACf,gBAAgB,CAqB5B"}
|