@nauth-toolkit/database-typeorm-postgres 0.1.3
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/LICENSE +90 -0
- package/README.md +63 -0
- package/dist/entities/auth-audit.entity.d.ts +32 -0
- package/dist/entities/auth-audit.entity.d.ts.map +1 -0
- package/dist/entities/auth-audit.entity.js +141 -0
- package/dist/entities/auth-audit.entity.js.map +1 -0
- package/dist/entities/challenge-session.entity.d.ts +20 -0
- package/dist/entities/challenge-session.entity.d.ts.map +1 -0
- package/dist/entities/challenge-session.entity.js +88 -0
- package/dist/entities/challenge-session.entity.js.map +1 -0
- package/dist/entities/index.d.ts +14 -0
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/index.js +57 -0
- package/dist/entities/index.js.map +1 -0
- package/dist/entities/login-attempt.entity.d.ts +16 -0
- package/dist/entities/login-attempt.entity.d.ts.map +1 -0
- package/dist/entities/login-attempt.entity.js +70 -0
- package/dist/entities/login-attempt.entity.js.map +1 -0
- package/dist/entities/mfa-device.entity.d.ts +23 -0
- package/dist/entities/mfa-device.entity.d.ts.map +1 -0
- package/dist/entities/mfa-device.entity.js +100 -0
- package/dist/entities/mfa-device.entity.js.map +1 -0
- package/dist/entities/rate-limit.entity.d.ts +10 -0
- package/dist/entities/rate-limit.entity.d.ts.map +1 -0
- package/dist/entities/rate-limit.entity.js +47 -0
- package/dist/entities/rate-limit.entity.js.map +1 -0
- package/dist/entities/session.entity.d.ts +35 -0
- package/dist/entities/session.entity.d.ts.map +1 -0
- package/dist/entities/session.entity.js +158 -0
- package/dist/entities/session.entity.js.map +1 -0
- package/dist/entities/social-account.entity.d.ts +16 -0
- package/dist/entities/social-account.entity.d.ts.map +1 -0
- package/dist/entities/social-account.entity.js +71 -0
- package/dist/entities/social-account.entity.js.map +1 -0
- package/dist/entities/storage-lock.entity.d.ts +9 -0
- package/dist/entities/storage-lock.entity.d.ts.map +1 -0
- package/dist/entities/storage-lock.entity.js +43 -0
- package/dist/entities/storage-lock.entity.js.map +1 -0
- package/dist/entities/trusted-device.entity.d.ts +20 -0
- package/dist/entities/trusted-device.entity.d.ts.map +1 -0
- package/dist/entities/trusted-device.entity.js +89 -0
- package/dist/entities/trusted-device.entity.js.map +1 -0
- package/dist/entities/user.entity.d.ts +42 -0
- package/dist/entities/user.entity.d.ts.map +1 -0
- package/dist/entities/user.entity.js +180 -0
- package/dist/entities/user.entity.js.map +1 -0
- package/dist/entities/verification-token.entity.d.ts +21 -0
- package/dist/entities/verification-token.entity.d.ts.map +1 -0
- package/dist/entities/verification-token.entity.js +90 -0
- package/dist/entities/verification-token.entity.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations/1734600000000-Initial.d.ts +7 -0
- package/dist/migrations/1734600000000-Initial.d.ts.map +1 -0
- package/dist/migrations/1734600000000-Initial.js +157 -0
- package/dist/migrations/1734600000000-Initial.js.map +1 -0
- package/dist/migrations/index.d.ts +6 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +6 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/typeorm-cli.datasource.d.ts +5 -0
- package/dist/typeorm-cli.datasource.d.ts.map +1 -0
- package/dist/typeorm-cli.datasource.js +19 -0
- package/dist/typeorm-cli.datasource.js.map +1 -0
- package/dist/utils/run-migrations.d.ts +4 -0
- package/dist/utils/run-migrations.d.ts.map +1 -0
- package/dist/utils/run-migrations.js +28 -0
- package/dist/utils/run-migrations.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Initial1734600000000 = void 0;
|
|
4
|
+
class Initial1734600000000 {
|
|
5
|
+
name = 'Initial1734600000000';
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`CREATE EXTENSION IF NOT EXISTS "uuid-ossp"`);
|
|
8
|
+
await queryRunner.query(`CREATE TABLE "nauth_users" ("id" SERIAL NOT NULL, "sub" uuid NOT NULL DEFAULT uuid_generate_v4(), "username" character varying(255), "firstName" character varying(100), "lastName" character varying(100), "email" character varying(255) NOT NULL, "phone" character varying(20), "passwordHash" character varying(255), "passwordChangedAt" TIMESTAMP WITH TIME ZONE, "passwordHistory" text, "mustChangePassword" boolean NOT NULL DEFAULT false, "isEmailVerified" boolean NOT NULL DEFAULT false, "isPhoneVerified" boolean NOT NULL DEFAULT false, "isActive" boolean NOT NULL DEFAULT true, "isLocked" boolean NOT NULL DEFAULT false, "lockReason" character varying(100), "lockedAt" TIMESTAMP WITH TIME ZONE, "lockedUntil" TIMESTAMP WITH TIME ZONE, "failedLoginAttempts" integer NOT NULL DEFAULT '0', "lastFailedLoginAt" TIMESTAMP WITH TIME ZONE, "lastLoginAt" TIMESTAMP WITH TIME ZONE, "lastLoginIp" character varying(45), "mfaEnabled" boolean NOT NULL DEFAULT false, "mfaMethods" text, "mfaEnforcedAt" TIMESTAMP WITH TIME ZONE, "totpSecret" text, "backupCodes" text, "preferredMfaMethod" character varying(20), "mfaExempt" boolean NOT NULL DEFAULT false, "mfaExemptReason" character varying(500), "mfaExemptGrantedAt" TIMESTAMP WITH TIME ZONE, "mfaExemptGrantedBy" character varying(255), "hasSocialAuth" boolean NOT NULL DEFAULT false, "socialProviders" text, "metadata" jsonb, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP WITH TIME ZONE, CONSTRAINT "UQ_55109e088d372ba04b3c2868efa" UNIQUE ("sub"), CONSTRAINT "UQ_def83cb63b4ad43b92d4244a8e1" UNIQUE ("username"), CONSTRAINT "UQ_06127de246f8855cfa2b04a4e52" UNIQUE ("email"), CONSTRAINT "PK_d8137f7679293cbbdfa21f1250b" PRIMARY KEY ("id"))`);
|
|
9
|
+
await queryRunner.query(`CREATE INDEX "IDX_545148d3ac52c29568490ff064" ON "nauth_users" ("hasSocialAuth") `);
|
|
10
|
+
await queryRunner.query(`CREATE INDEX "IDX_79f6834c0c66979cb09b62473b" ON "nauth_users" ("isActive") `);
|
|
11
|
+
await queryRunner.query(`CREATE INDEX "IDX_e7f7b3f18dfd026b8fe3ea08c2" ON "nauth_users" ("phone") `);
|
|
12
|
+
await queryRunner.query(`CREATE INDEX "IDX_def83cb63b4ad43b92d4244a8e" ON "nauth_users" ("username") `);
|
|
13
|
+
await queryRunner.query(`CREATE INDEX "IDX_06127de246f8855cfa2b04a4e5" ON "nauth_users" ("email") `);
|
|
14
|
+
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_55109e088d372ba04b3c2868ef" ON "nauth_users" ("sub") `);
|
|
15
|
+
await queryRunner.query(`CREATE TABLE "nauth_sessions" ("id" SERIAL NOT NULL, "version" integer NOT NULL, "userId" integer NOT NULL, "accessTokenHash" character varying(255) NOT NULL, "refreshTokenHash" character varying(255) NOT NULL, "tokenFamily" character varying(255), "deviceId" character varying(255), "deviceName" character varying(255), "deviceType" character varying(50), "deviceFingerprint" character varying(255), "ipAddress" character varying(45), "ipCountry" character varying(100), "ipCity" character varying(100), "ipLatitude" numeric(10,6), "ipLongitude" numeric(10,6), "ipIsp" character varying(255), "userAgent" text, "platform" character varying(50), "browser" character varying(50), "authMethod" character varying(50), "isRemembered" boolean NOT NULL DEFAULT false, "isTrustedDevice" boolean NOT NULL DEFAULT false, "expiresAt" TIMESTAMP WITH TIME ZONE NOT NULL, "lastActivityAt" TIMESTAMP WITH TIME ZONE, "isRevoked" boolean NOT NULL DEFAULT false, "revokedAt" TIMESTAMP WITH TIME ZONE, "revokeReason" character varying(100), "metadata" jsonb, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), CONSTRAINT "PK_60132e1342212a029ef50ac8c97" PRIMARY KEY ("id"))`);
|
|
16
|
+
await queryRunner.query(`CREATE INDEX "IDX_5889ec53efe12d4c0861540351" ON "nauth_sessions" ("tokenFamily", "isRevoked") `);
|
|
17
|
+
await queryRunner.query(`CREATE INDEX "IDX_abfe290f316aaec23c6ab8fe4c" ON "nauth_sessions" ("userId", "ipCountry") `);
|
|
18
|
+
await queryRunner.query(`CREATE INDEX "IDX_82dea1b621a55c1d46f9431c6d" ON "nauth_sessions" ("userId", "ipAddress") `);
|
|
19
|
+
await queryRunner.query(`CREATE INDEX "IDX_f1025cfeb0a432699b35cc9b5a" ON "nauth_sessions" ("userId", "deviceId") `);
|
|
20
|
+
await queryRunner.query(`CREATE INDEX "IDX_394e04ff686168d6b794faab32" ON "nauth_sessions" ("userId", "isRevoked", "expiresAt") `);
|
|
21
|
+
await queryRunner.query(`CREATE INDEX "IDX_640b8b4fb5e34cc462b26c32c7" ON "nauth_sessions" ("userId", "isRevoked", "createdAt") `);
|
|
22
|
+
await queryRunner.query(`CREATE INDEX "IDX_e1116f1740b6f598e409f9b8c8" ON "nauth_sessions" ("userId", "isRevoked") `);
|
|
23
|
+
await queryRunner.query(`CREATE INDEX "IDX_a256330403ded68e658351ea6d" ON "nauth_sessions" ("refreshTokenHash", "isRevoked") `);
|
|
24
|
+
await queryRunner.query(`CREATE INDEX "IDX_d346547e35ce945120bce8d28e" ON "nauth_sessions" ("isRevoked") `);
|
|
25
|
+
await queryRunner.query(`CREATE INDEX "IDX_f7d5f2b5e7d0ed7630f1494a49" ON "nauth_sessions" ("expiresAt") `);
|
|
26
|
+
await queryRunner.query(`CREATE INDEX "IDX_e11df8864e07aa20e0ad54e9a2" ON "nauth_sessions" ("deviceId") `);
|
|
27
|
+
await queryRunner.query(`CREATE INDEX "IDX_83cb51e5982dd6ea8b01de3707" ON "nauth_sessions" ("refreshTokenHash") `);
|
|
28
|
+
await queryRunner.query(`CREATE INDEX "IDX_7b945889632b425fd83e00627c" ON "nauth_sessions" ("accessTokenHash") `);
|
|
29
|
+
await queryRunner.query(`CREATE INDEX "IDX_29a306abd7483eb7e50bfea13d" ON "nauth_sessions" ("userId") `);
|
|
30
|
+
await queryRunner.query(`CREATE TABLE "nauth_login_attempts" ("id" SERIAL NOT NULL, "email" character varying(255), "userId" integer, "ipAddress" character varying(45), "userAgent" text, "success" boolean NOT NULL, "failureReason" character varying(100), "mfaRequired" boolean NOT NULL DEFAULT false, "metadata" jsonb, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), CONSTRAINT "PK_d2e5ffaf4001fd44e62a3520c15" PRIMARY KEY ("id"))`);
|
|
31
|
+
await queryRunner.query(`CREATE INDEX "IDX_1f72b23ca82eecae26227fe8b4" ON "nauth_login_attempts" ("ipAddress", "createdAt") `);
|
|
32
|
+
await queryRunner.query(`CREATE INDEX "IDX_ad332e5ca8b7c4f6f4cc7bd39c" ON "nauth_login_attempts" ("email", "createdAt") `);
|
|
33
|
+
await queryRunner.query(`CREATE TABLE "nauth_challenge_sessions" ("id" SERIAL NOT NULL, "userId" integer NOT NULL, "challengeName" character varying(50) NOT NULL, "sessionToken" character varying(255) NOT NULL, "expiresAt" TIMESTAMP WITH TIME ZONE NOT NULL, "isCompleted" boolean NOT NULL DEFAULT false, "completedAt" TIMESTAMP WITH TIME ZONE, "attempts" integer NOT NULL DEFAULT '0', "maxAttempts" integer NOT NULL DEFAULT '3', "challengeParameters" jsonb, "metadata" jsonb, "ipAddress" character varying(45), "userAgent" text, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), CONSTRAINT "UQ_f439ccf58d5844f715f9eec9cd4" UNIQUE ("sessionToken"), CONSTRAINT "PK_d428df595af0e50c3af8c090bca" PRIMARY KEY ("id"))`);
|
|
34
|
+
await queryRunner.query(`CREATE INDEX "IDX_e360f85f65e26bedc85eaf4d0d" ON "nauth_challenge_sessions" ("userId", "isCompleted") `);
|
|
35
|
+
await queryRunner.query(`CREATE INDEX "IDX_1d8693434fa20d7f7630487f15" ON "nauth_challenge_sessions" ("challengeName") `);
|
|
36
|
+
await queryRunner.query(`CREATE INDEX "IDX_12ae307de0750a4dd32471f4e0" ON "nauth_challenge_sessions" ("expiresAt") `);
|
|
37
|
+
await queryRunner.query(`CREATE INDEX "IDX_6fc21f5b74c04518123ad1287c" ON "nauth_challenge_sessions" ("userId") `);
|
|
38
|
+
await queryRunner.query(`CREATE TABLE "nauth_verification_tokens" ("id" SERIAL NOT NULL, "userId" integer NOT NULL, "challengeSessionId" integer, "type" character varying(20) NOT NULL, "token" character varying(255) NOT NULL, "code" character varying(10), "expiresAt" TIMESTAMP WITH TIME ZONE NOT NULL, "attempts" integer NOT NULL DEFAULT '0', "usedAt" TIMESTAMP WITH TIME ZONE, "ipAddress" character varying(45), "userAgent" text, "metadata" jsonb, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), CONSTRAINT "PK_aba0fc0da872c0599fcea723067" PRIMARY KEY ("id"))`);
|
|
39
|
+
await queryRunner.query(`CREATE INDEX "IDX_b643b4dde1e5b2a7bccab9af7e" ON "nauth_verification_tokens" ("expiresAt") `);
|
|
40
|
+
await queryRunner.query(`CREATE INDEX "IDX_c5812e0d5be495c141912c9fc3" ON "nauth_verification_tokens" ("token") `);
|
|
41
|
+
await queryRunner.query(`CREATE INDEX "IDX_4e9020601dede5c4350a7694e3" ON "nauth_verification_tokens" ("userId", "type") `);
|
|
42
|
+
await queryRunner.query(`CREATE TABLE "nauth_social_accounts" ("id" SERIAL NOT NULL, "userId" integer NOT NULL, "provider" character varying(50) NOT NULL, "providerId" character varying(255) NOT NULL, "providerEmail" character varying(255), "linkedAt" TIMESTAMP WITH TIME ZONE NOT NULL, "lastUsedAt" TIMESTAMP WITH TIME ZONE, "metadata" jsonb, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), CONSTRAINT "UQ_850038b86ca465318d5267cec45" UNIQUE ("provider", "providerId"), CONSTRAINT "PK_ec9b84f29493f4c3cb84dd92f9b" PRIMARY KEY ("id"))`);
|
|
43
|
+
await queryRunner.query(`CREATE INDEX "IDX_bebad32f44dd2f2a373fd609a6" ON "nauth_social_accounts" ("providerEmail") `);
|
|
44
|
+
await queryRunner.query(`CREATE INDEX "IDX_bcf231c8bee2c37f7713dcbcb8" ON "nauth_social_accounts" ("userId") `);
|
|
45
|
+
await queryRunner.query(`CREATE TABLE "nauth_mfa_devices" ("id" SERIAL NOT NULL, "userId" integer NOT NULL, "type" character varying(20) NOT NULL, "name" character varying(255) NOT NULL, "secret" text, "phoneNumber" character varying(20), "credentialId" text, "publicKey" text, "counter" integer, "transports" text, "isActive" boolean NOT NULL DEFAULT true, "isPrimary" boolean NOT NULL DEFAULT false, "lastUsedAt" TIMESTAMP WITH TIME ZONE, "usageCount" integer NOT NULL DEFAULT '0', "metadata" jsonb, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), CONSTRAINT "uq_mfa_device_user_type" UNIQUE ("userId", "type"), CONSTRAINT "PK_f6896a302bdbbbdf6bbcffa445d" PRIMARY KEY ("id"))`);
|
|
46
|
+
await queryRunner.query(`CREATE INDEX "IDX_bb95066fbbcbb404d8a329607f" ON "nauth_mfa_devices" ("isActive") `);
|
|
47
|
+
await queryRunner.query(`CREATE INDEX "IDX_54097fe7cdef07b08b3866934c" ON "nauth_mfa_devices" ("type") `);
|
|
48
|
+
await queryRunner.query(`CREATE INDEX "IDX_7850b00d043a63657522249b81" ON "nauth_mfa_devices" ("userId") `);
|
|
49
|
+
await queryRunner.query(`CREATE TABLE "nauth_auth_audit" ("id" SERIAL NOT NULL, "userId" integer NOT NULL, "eventType" character varying(50) NOT NULL, "eventStatus" character varying(20) NOT NULL, "riskFactor" integer, "riskFactors" text array, "adaptiveMfaTriggered" boolean, "ipAddress" character varying(45), "ipCountry" character varying(100), "ipCity" character varying(100), "ipLatitude" numeric(10,6), "ipLongitude" numeric(10,6), "userAgent" text, "platform" character varying(50), "browser" character varying(50), "deviceId" character varying(255), "deviceName" character varying(255), "deviceType" character varying(50), "sessionId" integer, "challengeSessionId" integer, "authMethod" character varying(50), "performedBy" character varying(255), "reason" character varying(500), "description" text, "metadata" jsonb, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), CONSTRAINT "PK_1bfa7ce5b870836679a850a4227" PRIMARY KEY ("id"))`);
|
|
50
|
+
await queryRunner.query(`CREATE INDEX "IDX_58c758ac01b0b9628dcd8da13e" ON "nauth_auth_audit" ("userId", "ipAddress") `);
|
|
51
|
+
await queryRunner.query(`CREATE INDEX "IDX_9aac36f5d60c47085006e14c86" ON "nauth_auth_audit" ("userId", "eventType", "createdAt") `);
|
|
52
|
+
await queryRunner.query(`CREATE INDEX "IDX_2a3142225b10cbb2d61c3d7670" ON "nauth_auth_audit" ("authMethod", "createdAt") `);
|
|
53
|
+
await queryRunner.query(`CREATE INDEX "IDX_9d34a4ba3b16763ba96373bd60" ON "nauth_auth_audit" ("adaptiveMfaTriggered", "createdAt") `);
|
|
54
|
+
await queryRunner.query(`CREATE INDEX "IDX_efc809a946b92cca2791ad900d" ON "nauth_auth_audit" ("riskFactor", "createdAt") `);
|
|
55
|
+
await queryRunner.query(`CREATE INDEX "IDX_8ad1870f1c47bc4aea6bf069be" ON "nauth_auth_audit" ("createdAt") `);
|
|
56
|
+
await queryRunner.query(`CREATE INDEX "IDX_8f3e679bbcea9a0c54cb7fc138" ON "nauth_auth_audit" ("eventStatus", "createdAt") `);
|
|
57
|
+
await queryRunner.query(`CREATE INDEX "IDX_aee5b503e165b59225e6004bb3" ON "nauth_auth_audit" ("eventType", "createdAt") `);
|
|
58
|
+
await queryRunner.query(`CREATE INDEX "IDX_d5a6e9fdcb66f2b33bb1420b62" ON "nauth_auth_audit" ("userId", "createdAt") `);
|
|
59
|
+
await queryRunner.query(`CREATE TABLE "nauth_trusted_devices" ("id" SERIAL NOT NULL, "userId" integer NOT NULL, "deviceTokenHash" character varying(255) NOT NULL, "deviceId" character varying(255), "deviceName" character varying(255), "deviceType" character varying(50), "ipAddress" character varying(45), "userAgent" text, "platform" character varying(50), "browser" character varying(50), "trustedUntil" TIMESTAMP WITH TIME ZONE NOT NULL, "lastUsedAt" TIMESTAMP WITH TIME ZONE, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), CONSTRAINT "PK_a3e388d947e0b5b07efc6ae308d" PRIMARY KEY ("id"))`);
|
|
60
|
+
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_e1eadc45b91af58ad18626de36" ON "nauth_trusted_devices" ("userId", "deviceTokenHash") `);
|
|
61
|
+
await queryRunner.query(`CREATE INDEX "IDX_7ec93fcdd969044b56966d5b8f" ON "nauth_trusted_devices" ("trustedUntil") `);
|
|
62
|
+
await queryRunner.query(`CREATE INDEX "IDX_4be50a51f46a2110415882ebae" ON "nauth_trusted_devices" ("deviceId") `);
|
|
63
|
+
await queryRunner.query(`CREATE INDEX "IDX_96d642dfb86b07683970edb383" ON "nauth_trusted_devices" ("deviceTokenHash") `);
|
|
64
|
+
await queryRunner.query(`CREATE INDEX "IDX_6b1ebaf31bc726f6c40020a0d2" ON "nauth_trusted_devices" ("userId") `);
|
|
65
|
+
await queryRunner.query(`CREATE TABLE "nauth_rate_limits" ("id" SERIAL NOT NULL, "key" character varying(255) NOT NULL, "value" text NOT NULL, "expiresAt" TIMESTAMP WITH TIME ZONE, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), CONSTRAINT "PK_2e84e65556919eb0ea56a4c2ac7" PRIMARY KEY ("id"))`);
|
|
66
|
+
await queryRunner.query(`CREATE INDEX "IDX_f97c41c9a490f252b1d0c9367d" ON "nauth_rate_limits" ("expiresAt") `);
|
|
67
|
+
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_90d96c7c013510b358d30d8144" ON "nauth_rate_limits" ("key") `);
|
|
68
|
+
await queryRunner.query(`CREATE TABLE "nauth_storage_locks" ("id" SERIAL NOT NULL, "key" character varying(255) NOT NULL, "value" text NOT NULL, "expiresAt" TIMESTAMP WITH TIME ZONE, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), CONSTRAINT "PK_5137ad1e6a473acd622a2fedd66" PRIMARY KEY ("id"))`);
|
|
69
|
+
await queryRunner.query(`CREATE INDEX "IDX_61474f43e24de2af1d8bf88ee1" ON "nauth_storage_locks" ("expiresAt") `);
|
|
70
|
+
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_24b2bef3e4cfafcecc2ad09df4" ON "nauth_storage_locks" ("key") `);
|
|
71
|
+
await queryRunner.query(`ALTER TABLE "nauth_sessions" ADD CONSTRAINT "FK_29a306abd7483eb7e50bfea13d8" FOREIGN KEY ("userId") REFERENCES "nauth_users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
72
|
+
await queryRunner.query(`ALTER TABLE "nauth_login_attempts" ADD CONSTRAINT "FK_21b1aa08d1cb4c6c5dda7f6fac0" FOREIGN KEY ("userId") REFERENCES "nauth_users"("id") ON DELETE SET NULL ON UPDATE NO ACTION`);
|
|
73
|
+
await queryRunner.query(`ALTER TABLE "nauth_challenge_sessions" ADD CONSTRAINT "FK_6fc21f5b74c04518123ad1287cb" FOREIGN KEY ("userId") REFERENCES "nauth_users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
74
|
+
await queryRunner.query(`ALTER TABLE "nauth_verification_tokens" ADD CONSTRAINT "FK_8ff39e7ffb5e4ffb734ee9e57c5" FOREIGN KEY ("userId") REFERENCES "nauth_users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
75
|
+
await queryRunner.query(`ALTER TABLE "nauth_verification_tokens" ADD CONSTRAINT "FK_5e34b085fd0bc42216849e53aa3" FOREIGN KEY ("challengeSessionId") REFERENCES "nauth_challenge_sessions"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
76
|
+
await queryRunner.query(`ALTER TABLE "nauth_social_accounts" ADD CONSTRAINT "FK_bcf231c8bee2c37f7713dcbcb8a" FOREIGN KEY ("userId") REFERENCES "nauth_users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
77
|
+
await queryRunner.query(`ALTER TABLE "nauth_mfa_devices" ADD CONSTRAINT "FK_7850b00d043a63657522249b816" FOREIGN KEY ("userId") REFERENCES "nauth_users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
78
|
+
await queryRunner.query(`ALTER TABLE "nauth_auth_audit" ADD CONSTRAINT "FK_af799e756285b8639985dd09f50" FOREIGN KEY ("userId") REFERENCES "nauth_users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
79
|
+
await queryRunner.query(`ALTER TABLE "nauth_trusted_devices" ADD CONSTRAINT "FK_6b1ebaf31bc726f6c40020a0d2a" FOREIGN KEY ("userId") REFERENCES "nauth_users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
80
|
+
}
|
|
81
|
+
async down(queryRunner) {
|
|
82
|
+
await queryRunner.query(`ALTER TABLE "nauth_trusted_devices" DROP CONSTRAINT "FK_6b1ebaf31bc726f6c40020a0d2a"`);
|
|
83
|
+
await queryRunner.query(`ALTER TABLE "nauth_auth_audit" DROP CONSTRAINT "FK_af799e756285b8639985dd09f50"`);
|
|
84
|
+
await queryRunner.query(`ALTER TABLE "nauth_mfa_devices" DROP CONSTRAINT "FK_7850b00d043a63657522249b816"`);
|
|
85
|
+
await queryRunner.query(`ALTER TABLE "nauth_social_accounts" DROP CONSTRAINT "FK_bcf231c8bee2c37f7713dcbcb8a"`);
|
|
86
|
+
await queryRunner.query(`ALTER TABLE "nauth_verification_tokens" DROP CONSTRAINT "FK_5e34b085fd0bc42216849e53aa3"`);
|
|
87
|
+
await queryRunner.query(`ALTER TABLE "nauth_verification_tokens" DROP CONSTRAINT "FK_8ff39e7ffb5e4ffb734ee9e57c5"`);
|
|
88
|
+
await queryRunner.query(`ALTER TABLE "nauth_challenge_sessions" DROP CONSTRAINT "FK_6fc21f5b74c04518123ad1287cb"`);
|
|
89
|
+
await queryRunner.query(`ALTER TABLE "nauth_login_attempts" DROP CONSTRAINT "FK_21b1aa08d1cb4c6c5dda7f6fac0"`);
|
|
90
|
+
await queryRunner.query(`ALTER TABLE "nauth_sessions" DROP CONSTRAINT "FK_29a306abd7483eb7e50bfea13d8"`);
|
|
91
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_24b2bef3e4cfafcecc2ad09df4"`);
|
|
92
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_61474f43e24de2af1d8bf88ee1"`);
|
|
93
|
+
await queryRunner.query(`DROP TABLE "nauth_storage_locks"`);
|
|
94
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_90d96c7c013510b358d30d8144"`);
|
|
95
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_f97c41c9a490f252b1d0c9367d"`);
|
|
96
|
+
await queryRunner.query(`DROP TABLE "nauth_rate_limits"`);
|
|
97
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_6b1ebaf31bc726f6c40020a0d2"`);
|
|
98
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_96d642dfb86b07683970edb383"`);
|
|
99
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_4be50a51f46a2110415882ebae"`);
|
|
100
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_7ec93fcdd969044b56966d5b8f"`);
|
|
101
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_e1eadc45b91af58ad18626de36"`);
|
|
102
|
+
await queryRunner.query(`DROP TABLE "nauth_trusted_devices"`);
|
|
103
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_d5a6e9fdcb66f2b33bb1420b62"`);
|
|
104
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_aee5b503e165b59225e6004bb3"`);
|
|
105
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_8f3e679bbcea9a0c54cb7fc138"`);
|
|
106
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_8ad1870f1c47bc4aea6bf069be"`);
|
|
107
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_efc809a946b92cca2791ad900d"`);
|
|
108
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_9d34a4ba3b16763ba96373bd60"`);
|
|
109
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_2a3142225b10cbb2d61c3d7670"`);
|
|
110
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_9aac36f5d60c47085006e14c86"`);
|
|
111
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_58c758ac01b0b9628dcd8da13e"`);
|
|
112
|
+
await queryRunner.query(`DROP TABLE "nauth_auth_audit"`);
|
|
113
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_7850b00d043a63657522249b81"`);
|
|
114
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_54097fe7cdef07b08b3866934c"`);
|
|
115
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_bb95066fbbcbb404d8a329607f"`);
|
|
116
|
+
await queryRunner.query(`DROP TABLE "nauth_mfa_devices"`);
|
|
117
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_bcf231c8bee2c37f7713dcbcb8"`);
|
|
118
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_bebad32f44dd2f2a373fd609a6"`);
|
|
119
|
+
await queryRunner.query(`DROP TABLE "nauth_social_accounts"`);
|
|
120
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_4e9020601dede5c4350a7694e3"`);
|
|
121
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_c5812e0d5be495c141912c9fc3"`);
|
|
122
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_b643b4dde1e5b2a7bccab9af7e"`);
|
|
123
|
+
await queryRunner.query(`DROP TABLE "nauth_verification_tokens"`);
|
|
124
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_6fc21f5b74c04518123ad1287c"`);
|
|
125
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_12ae307de0750a4dd32471f4e0"`);
|
|
126
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_1d8693434fa20d7f7630487f15"`);
|
|
127
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_e360f85f65e26bedc85eaf4d0d"`);
|
|
128
|
+
await queryRunner.query(`DROP TABLE "nauth_challenge_sessions"`);
|
|
129
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_ad332e5ca8b7c4f6f4cc7bd39c"`);
|
|
130
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_1f72b23ca82eecae26227fe8b4"`);
|
|
131
|
+
await queryRunner.query(`DROP TABLE "nauth_login_attempts"`);
|
|
132
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_29a306abd7483eb7e50bfea13d"`);
|
|
133
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_7b945889632b425fd83e00627c"`);
|
|
134
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_83cb51e5982dd6ea8b01de3707"`);
|
|
135
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_e11df8864e07aa20e0ad54e9a2"`);
|
|
136
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_f7d5f2b5e7d0ed7630f1494a49"`);
|
|
137
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_d346547e35ce945120bce8d28e"`);
|
|
138
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_a256330403ded68e658351ea6d"`);
|
|
139
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_e1116f1740b6f598e409f9b8c8"`);
|
|
140
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_640b8b4fb5e34cc462b26c32c7"`);
|
|
141
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_394e04ff686168d6b794faab32"`);
|
|
142
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_f1025cfeb0a432699b35cc9b5a"`);
|
|
143
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_82dea1b621a55c1d46f9431c6d"`);
|
|
144
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_abfe290f316aaec23c6ab8fe4c"`);
|
|
145
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_5889ec53efe12d4c0861540351"`);
|
|
146
|
+
await queryRunner.query(`DROP TABLE "nauth_sessions"`);
|
|
147
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_55109e088d372ba04b3c2868ef"`);
|
|
148
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_06127de246f8855cfa2b04a4e5"`);
|
|
149
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_def83cb63b4ad43b92d4244a8e"`);
|
|
150
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_e7f7b3f18dfd026b8fe3ea08c2"`);
|
|
151
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_79f6834c0c66979cb09b62473b"`);
|
|
152
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_545148d3ac52c29568490ff064"`);
|
|
153
|
+
await queryRunner.query(`DROP TABLE "nauth_users"`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.Initial1734600000000 = Initial1734600000000;
|
|
157
|
+
//# sourceMappingURL=1734600000000-Initial.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"1734600000000-Initial.js","sourceRoot":"","sources":["../../src/migrations/1734600000000-Initial.ts"],"names":[],"mappings":";;;AAEA,MAAa,oBAAoB;IAC/B,IAAI,GAAG,sBAAsB,CAAC;IAEvB,KAAK,CAAC,EAAE,CAAC,WAAwB;QAEtC,MAAM,WAAW,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAEtE,MAAM,WAAW,CAAC,KAAK,CACrB,qvDAAqvD,CACtvD,CAAC;QACF,MAAM,WAAW,CAAC,KAAK,CAAC,mFAAmF,CAAC,CAAC;QAC7G,MAAM,WAAW,CAAC,KAAK,CA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AsD,CAAC,CAAC;QAChF,MAAM,WAAW,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAChF,MAAM,WAAW,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAChF,MAAM,WAAW,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAChF,MAAM,WAAW,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAChF,MAAM,WAAW,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACvD,MAAM,WAAW,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAChF,MAAM,WAAW,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAChF,MAAM,WAAW,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAChF,MAAM,WAAW,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAChF,MAAM,WAAW,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAChF,MAAM,WAAW,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAChF,MAAM,WAAW,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;IACtD,CAAC;CACF;AAnMD,oDAmMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGlD,MAAM,MAAM,oBAAoB,GAAG;IAAE,QAAQ,kBAAkB,CAAA;CAAE,CAAC;AAKlE,eAAO,MAAM,UAAU,EAAE,oBAAoB,EAA2B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.migrations = void 0;
|
|
4
|
+
const _1734600000000_Initial_1 = require("./1734600000000-Initial");
|
|
5
|
+
exports.migrations = [_1734600000000_Initial_1.Initial1734600000000];
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":";;;AACA,oEAA+D;AAOlD,QAAA,UAAU,GAA2B,CAAC,6CAAoB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeorm-cli.datasource.d.ts","sourceRoot":"","sources":["../src/typeorm-cli.datasource.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;;AAUrC,wBAWG"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("reflect-metadata");
|
|
4
|
+
const typeorm_1 = require("typeorm");
|
|
5
|
+
const entities_1 = require("./entities");
|
|
6
|
+
const migrations_1 = require("./migrations");
|
|
7
|
+
exports.default = new typeorm_1.DataSource({
|
|
8
|
+
type: 'postgres',
|
|
9
|
+
host: process.env.DB_HOST,
|
|
10
|
+
port: parseInt(process.env.DB_PORT || '5432', 10),
|
|
11
|
+
username: process.env.DB_USERNAME,
|
|
12
|
+
password: process.env.DB_PASSWORD,
|
|
13
|
+
database: process.env.DB_DATABASE,
|
|
14
|
+
entities: [...(0, entities_1.getNAuthEntities)(), ...(0, entities_1.getNAuthTransientStorageEntities)()],
|
|
15
|
+
migrations: migrations_1.migrations,
|
|
16
|
+
synchronize: false,
|
|
17
|
+
logging: false,
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=typeorm-cli.datasource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeorm-cli.datasource.js","sourceRoot":"","sources":["../src/typeorm-cli.datasource.ts"],"names":[],"mappings":";;AAAA,4BAA0B;AAC1B,qCAAqC;AACrC,yCAAgF;AAChF,6CAA0C;AAQ1C,kBAAe,IAAI,oBAAU,CAAC;IAC5B,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO;IACzB,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,MAAM,EAAE,EAAE,CAAC;IACjD,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW;IACjC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW;IACjC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW;IACjC,QAAQ,EAAE,CAAC,GAAG,IAAA,2BAAgB,GAAE,EAAE,GAAG,IAAA,2CAAgC,GAAE,CAAC;IACxE,UAAU,EAAV,uBAAU;IACV,WAAW,EAAE,KAAK;IAClB,OAAO,EAAE,KAAK;CACf,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DataSource } from 'typeorm';
|
|
2
|
+
import type { NAuthConfig, NAuthLogger } from '@nauth-toolkit/core';
|
|
3
|
+
export declare function runNAuthMigrations(dataSource: DataSource, logger: NAuthLogger, config: NAuthConfig): Promise<void>;
|
|
4
|
+
//# sourceMappingURL=run-migrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-migrations.d.ts","sourceRoot":"","sources":["../../src/utils/run-migrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAgBpE,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,CA8Bf"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runNAuthMigrations = runNAuthMigrations;
|
|
4
|
+
const migrations_1 = require("../migrations");
|
|
5
|
+
function getMigrationsTableName(config) {
|
|
6
|
+
const tablePrefix = config.tablePrefix ?? 'nauth_';
|
|
7
|
+
return `${tablePrefix}migrations`;
|
|
8
|
+
}
|
|
9
|
+
async function runNAuthMigrations(dataSource, logger, config) {
|
|
10
|
+
const migrationsTableName = getMigrationsTableName(config);
|
|
11
|
+
logger.log(`[nauth-toolkit] Ensuring database schema via migrations (@nauth-toolkit/database-typeorm-postgres)...`);
|
|
12
|
+
const existing = Array.isArray(dataSource.options.migrations) ? dataSource.options.migrations : [];
|
|
13
|
+
const merged = [...existing, ...migrations_1.migrations];
|
|
14
|
+
dataSource.options.migrations = merged;
|
|
15
|
+
dataSource.options.migrationsTableName = migrationsTableName;
|
|
16
|
+
await dataSource.buildMetadatas();
|
|
17
|
+
logger.log(`[nauth-toolkit] Injecting ${migrations_1.migrations.length} NAuth migration(s) into DataSource (existing runtime: ${existing.length})`);
|
|
18
|
+
logger.log('[nauth-toolkit] Checking for pending migrations...');
|
|
19
|
+
const executed = (await dataSource.runMigrations({ transaction: 'all' }));
|
|
20
|
+
if (!executed.length) {
|
|
21
|
+
logger.log('[nauth-toolkit] No pending migrations.');
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
logger.log(`[nauth-toolkit] Executed ${executed.length} migration(s):`);
|
|
25
|
+
for (const m of executed)
|
|
26
|
+
logger.log(` ✓ ${m.name}`);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=run-migrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-migrations.js","sourceRoot":"","sources":["../../src/utils/run-migrations.ts"],"names":[],"mappings":";;AAiBA,gDAkCC;AAjDD,8CAA2C;AAI3C,SAAS,sBAAsB,CAAC,MAAmB;IACjD,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,QAAQ,CAAC;IACnD,OAAO,GAAG,WAAW,YAAY,CAAC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
+
{
|
|
2
|
+
"name": "@nauth-toolkit/database-typeorm-postgres",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "PostgreSQL TypeORM adapter for nauth-toolkit",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc -b",
|
|
9
|
+
"clean": "rm -rf dist *.tsbuildinfo",
|
|
10
|
+
"test": "jest --passWithNoTests",
|
|
11
|
+
"lint": "eslint src --ext .ts",
|
|
12
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
13
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
14
|
+
"format:check": "prettier --check \"src/**/*.ts\""
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"@nauth-toolkit/core": "^0.1.3",
|
|
18
|
+
"typeorm": "^0.3.20",
|
|
19
|
+
"pg": "^8.0.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/jest": "^29.5.0",
|
|
23
|
+
"@types/node": "^22.0.0",
|
|
24
|
+
"jest": "^29.7.0",
|
|
25
|
+
"ts-jest": "^29.2.0",
|
|
26
|
+
"typescript": "^5.5.0"
|
|
27
|
+
},
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=22.0.0"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public",
|
|
33
|
+
"tag": "preview"
|
|
34
|
+
},
|
|
35
|
+
"license": "UNLICENSED",
|
|
36
|
+
"keywords": [
|
|
37
|
+
"nestjs",
|
|
38
|
+
"authentication",
|
|
39
|
+
"typeorm",
|
|
40
|
+
"postgresql",
|
|
41
|
+
"database"
|
|
42
|
+
],
|
|
43
|
+
"files": [
|
|
44
|
+
"dist",
|
|
45
|
+
"LICENSE",
|
|
46
|
+
"README.md"
|
|
47
|
+
]
|
|
48
|
+
}
|