@vynelix/nestjs-multi-auth 0.3.2 → 1.0.0
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 +10 -0
- package/README.md +309 -18
- package/dist/auth/auth.controller.d.ts +3 -2
- package/dist/auth/auth.controller.js +32 -5
- package/dist/auth/auth.controller.js.map +1 -1
- package/dist/auth/auth.module.js +116 -68
- package/dist/auth/auth.module.js.map +1 -1
- package/dist/auth/auth.service.d.ts +52 -25
- package/dist/auth/auth.service.js +238 -327
- package/dist/auth/auth.service.js.map +1 -1
- package/dist/auth/core/auth-mapper.d.ts +1 -1
- package/dist/auth/core/database-otp.provider.d.ts +12 -0
- package/dist/auth/core/database-otp.provider.js +122 -0
- package/dist/auth/core/database-otp.provider.js.map +1 -0
- package/dist/auth/dto/requests/magic-link.dto.d.ts +1 -0
- package/dist/auth/dto/requests/magic-link.dto.js +6 -0
- package/dist/auth/dto/requests/magic-link.dto.js.map +1 -1
- package/dist/auth/dto/requests/mfa.dto.d.ts +5 -1
- package/dist/auth/dto/requests/mfa.dto.js +29 -8
- package/dist/auth/dto/requests/mfa.dto.js.map +1 -1
- package/dist/auth/enums/identifier-type.enum.d.ts +11 -0
- package/dist/auth/enums/identifier-type.enum.js +17 -0
- package/dist/auth/enums/identifier-type.enum.js.map +1 -0
- package/dist/auth/enums/mfa-type.enum.d.ts +5 -0
- package/dist/auth/enums/mfa-type.enum.js +10 -0
- package/dist/auth/enums/mfa-type.enum.js.map +1 -0
- package/dist/auth/enums/otp-purpose.enum.d.ts +8 -0
- package/dist/auth/enums/otp-purpose.enum.js +13 -0
- package/dist/auth/enums/otp-purpose.enum.js.map +1 -0
- package/dist/auth/enums/session-event.enum.d.ts +7 -0
- package/dist/auth/enums/session-event.enum.js +12 -0
- package/dist/auth/enums/session-event.enum.js.map +1 -0
- package/dist/auth/interfaces/auth-module-options.interface.d.ts +36 -1
- package/dist/auth/interfaces/auth-notification-provider.interface.d.ts +7 -1
- package/dist/auth/interfaces/auth-otp-provider.interface.d.ts +60 -0
- package/dist/auth/interfaces/auth-otp-provider.interface.js +7 -0
- package/dist/auth/interfaces/auth-otp-provider.interface.js.map +1 -0
- package/dist/auth/interfaces/models.interface.d.ts +91 -0
- package/dist/auth/interfaces/models.interface.js +3 -0
- package/dist/auth/interfaces/models.interface.js.map +1 -0
- package/dist/auth/interfaces/oauth-strategy.interface.d.ts +2 -2
- package/dist/auth/interfaces/repositories.interface.d.ts +70 -0
- package/dist/auth/interfaces/repositories.interface.js +3 -0
- package/dist/auth/interfaces/repositories.interface.js.map +1 -0
- package/dist/auth/interfaces/repository-tokens.d.ts +7 -0
- package/dist/auth/interfaces/repository-tokens.js +11 -0
- package/dist/auth/interfaces/repository-tokens.js.map +1 -0
- package/dist/auth/interfaces/signup-event-body.interface.d.ts +1 -1
- package/dist/auth/strategies/local-auth.strategy.d.ts +3 -5
- package/dist/auth/strategies/local-auth.strategy.js +64 -99
- package/dist/auth/strategies/local-auth.strategy.js.map +1 -1
- package/dist/auth/strategies/oauth/apple.strategy.d.ts +4 -6
- package/dist/auth/strategies/oauth/apple.strategy.js +57 -70
- package/dist/auth/strategies/oauth/apple.strategy.js.map +1 -1
- package/dist/auth/strategies/oauth/facebook.strategy.d.ts +4 -6
- package/dist/auth/strategies/oauth/facebook.strategy.js +58 -71
- package/dist/auth/strategies/oauth/facebook.strategy.js.map +1 -1
- package/dist/auth/strategies/oauth/google.strategy.d.ts +4 -6
- package/dist/auth/strategies/oauth/google.strategy.js +84 -155
- package/dist/auth/strategies/oauth/google.strategy.js.map +1 -1
- package/dist/auth/strategies/oauth/oauth.strategy.d.ts +2 -2
- package/dist/database/prisma/prisma-auth.adapter.d.ts +11 -0
- package/dist/database/prisma/prisma-auth.adapter.js +64 -0
- package/dist/database/prisma/prisma-auth.adapter.js.map +1 -0
- package/dist/database/prisma/repositories/auth-identifier.repository.d.ts +16 -0
- package/dist/database/prisma/repositories/auth-identifier.repository.js +41 -0
- package/dist/database/prisma/repositories/auth-identifier.repository.js.map +1 -0
- package/dist/database/prisma/repositories/auth.repository.d.ts +19 -0
- package/dist/database/prisma/repositories/auth.repository.js +49 -0
- package/dist/database/prisma/repositories/auth.repository.js.map +1 -0
- package/dist/database/prisma/repositories/index.d.ts +7 -0
- package/dist/database/prisma/repositories/index.js +24 -0
- package/dist/database/prisma/repositories/index.js.map +1 -0
- package/dist/database/prisma/repositories/mfa-method.repository.d.ts +11 -0
- package/dist/database/prisma/repositories/mfa-method.repository.js +33 -0
- package/dist/database/prisma/repositories/mfa-method.repository.js.map +1 -0
- package/dist/database/prisma/repositories/oauth-provider.repository.d.ts +14 -0
- package/dist/database/prisma/repositories/oauth-provider.repository.js +39 -0
- package/dist/database/prisma/repositories/oauth-provider.repository.js.map +1 -0
- package/dist/database/prisma/repositories/otp-token.repository.d.ts +13 -0
- package/dist/database/prisma/repositories/otp-token.repository.js +52 -0
- package/dist/database/prisma/repositories/otp-token.repository.js.map +1 -0
- package/dist/database/prisma/repositories/session-log.repository.d.ts +12 -0
- package/dist/database/prisma/repositories/session-log.repository.js +42 -0
- package/dist/database/prisma/repositories/session-log.repository.js.map +1 -0
- package/dist/database/prisma/repositories/session.repository.d.ts +16 -0
- package/dist/database/prisma/repositories/session.repository.js +41 -0
- package/dist/database/prisma/repositories/session.repository.js.map +1 -0
- package/dist/database/typeorm/entities/auth-identify.entity.d.ts +23 -0
- package/dist/database/typeorm/entities/auth-identify.entity.js +61 -0
- package/dist/database/typeorm/entities/auth-identify.entity.js.map +1 -0
- package/dist/database/typeorm/entities/auth.entity.d.ts +45 -0
- package/dist/database/typeorm/entities/auth.entity.js +129 -0
- package/dist/database/typeorm/entities/auth.entity.js.map +1 -0
- package/dist/database/typeorm/entities/base.entity.d.ts +7 -0
- package/dist/database/typeorm/entities/base.entity.js +44 -0
- package/dist/database/typeorm/entities/base.entity.js.map +1 -0
- package/dist/database/typeorm/entities/entities.d.ts +7 -0
- package/dist/database/typeorm/entities/entities.js +18 -0
- package/dist/database/typeorm/entities/entities.js.map +1 -0
- package/dist/database/typeorm/entities/mfa-method.entity.d.ts +10 -0
- package/dist/database/typeorm/entities/mfa-method.entity.js +47 -0
- package/dist/database/typeorm/entities/mfa-method.entity.js.map +1 -0
- package/dist/database/typeorm/entities/oauth-provider.entity.d.ts +38 -0
- package/dist/database/typeorm/entities/oauth-provider.entity.js +88 -0
- package/dist/database/typeorm/entities/oauth-provider.entity.js.map +1 -0
- package/dist/database/typeorm/entities/otp-token.entity.d.ts +15 -0
- package/dist/database/typeorm/entities/otp-token.entity.js +53 -0
- package/dist/database/typeorm/entities/otp-token.entity.js.map +1 -0
- package/dist/database/typeorm/entities/session.entity.d.ts +21 -0
- package/dist/database/typeorm/entities/session.entity.js +71 -0
- package/dist/database/typeorm/entities/session.entity.js.map +1 -0
- package/dist/database/typeorm/entities/session_log.entity.d.ts +25 -0
- package/dist/database/typeorm/entities/session_log.entity.js +78 -0
- package/dist/database/typeorm/entities/session_log.entity.js.map +1 -0
- package/dist/database/typeorm/migrations/auth-entities.d.ts +7 -0
- package/dist/database/typeorm/migrations/auth-entities.js +18 -0
- package/dist/database/typeorm/migrations/auth-entities.js.map +1 -0
- package/dist/database/typeorm/migrations/auth-schema.initializer.d.ts +9 -0
- package/dist/database/typeorm/migrations/auth-schema.initializer.js +36 -0
- package/dist/database/typeorm/migrations/auth-schema.initializer.js.map +1 -0
- package/dist/database/typeorm/migrations/auth.migration.v1.d.ts +12 -0
- package/dist/database/typeorm/migrations/auth.migration.v1.js +157 -0
- package/dist/database/typeorm/migrations/auth.migration.v1.js.map +1 -0
- package/dist/database/typeorm/migrations/auth.migration.v2.d.ts +8 -0
- package/dist/database/typeorm/migrations/auth.migration.v2.js +23 -0
- package/dist/database/typeorm/migrations/auth.migration.v2.js.map +1 -0
- package/dist/database/typeorm/migrations/auth.migrations.d.ts +2 -0
- package/dist/database/typeorm/migrations/auth.migrations.js +10 -0
- package/dist/database/typeorm/migrations/auth.migrations.js.map +1 -0
- package/dist/database/typeorm/migrations/migration.service.d.ts +9 -0
- package/dist/database/typeorm/migrations/migration.service.js +75 -0
- package/dist/database/typeorm/migrations/migration.service.js.map +1 -0
- package/dist/database/typeorm/repositories/auth-identifier.repository.d.ts +18 -0
- package/dist/database/typeorm/repositories/auth-identifier.repository.js +64 -0
- package/dist/database/typeorm/repositories/auth-identifier.repository.js.map +1 -0
- package/dist/database/typeorm/repositories/auth.repository.d.ts +21 -0
- package/dist/database/typeorm/repositories/auth.repository.js +71 -0
- package/dist/database/typeorm/repositories/auth.repository.js.map +1 -0
- package/dist/database/typeorm/repositories/index.d.ts +7 -0
- package/dist/database/typeorm/repositories/index.js +24 -0
- package/dist/database/typeorm/repositories/index.js.map +1 -0
- package/dist/database/typeorm/repositories/mfa-method.repository.d.ts +13 -0
- package/dist/database/typeorm/repositories/mfa-method.repository.js +46 -0
- package/dist/database/typeorm/repositories/mfa-method.repository.js.map +1 -0
- package/dist/database/typeorm/repositories/oauth-provider.repository.d.ts +16 -0
- package/dist/database/typeorm/repositories/oauth-provider.repository.js +52 -0
- package/dist/database/typeorm/repositories/oauth-provider.repository.js.map +1 -0
- package/dist/database/typeorm/repositories/otp-token.repository.d.ts +13 -0
- package/dist/database/typeorm/repositories/otp-token.repository.js +52 -0
- package/dist/database/typeorm/repositories/otp-token.repository.js.map +1 -0
- package/dist/database/typeorm/repositories/session-log.repository.d.ts +12 -0
- package/dist/database/typeorm/repositories/session-log.repository.js +47 -0
- package/dist/database/typeorm/repositories/session-log.repository.js.map +1 -0
- package/dist/database/typeorm/repositories/session.repository.d.ts +18 -0
- package/dist/database/typeorm/repositories/session.repository.js +84 -0
- package/dist/database/typeorm/repositories/session.repository.js.map +1 -0
- package/dist/database/typeorm/typeorm-auth.adapter.d.ts +2 -0
- package/dist/database/typeorm/typeorm-auth.adapter.js +50 -0
- package/dist/database/typeorm/typeorm-auth.adapter.js.map +1 -0
- package/dist/index.d.ts +11 -9
- package/dist/index.js +18 -10
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/fix-imports.js +46 -0
- package/fix-syntax.js +66 -0
- package/package.json +22 -20
- package/patch-local-specs.js +52 -0
- package/patch-oauth-specs.js +41 -0
- package/patch-specs.js +36 -0
- package/prompts/database_adapter.md +157 -0
- package/prompts/otp_provider.md +292 -0
- package/scratch/create-prisma-repos-final.js +139 -0
- package/scratch/create-prisma-repos.js +280 -0
- package/scratch/fix-events-spec.js +12 -0
- package/scratch/fix-imports.js +53 -0
- package/scratch/fix-prisma-interfaces.js +41 -0
- package/scratch/fix-prisma-interfaces2.js +36 -0
- package/scratch/fix-prisma-interfaces3.js +26 -0
- package/scratch/fix-prisma.js +28 -0
- package/scratch/fix-test-imports.js +51 -0
- package/scratch/fix-tests-advanced.js +68 -0
- package/scratch/fix-tests-advanced2.js +23 -0
- package/scratch/fix-tests-concrete.js +40 -0
- package/scratch/fix-tests-final.js +35 -0
- package/scratch/fix-tests-final2.js +28 -0
- package/scratch/fix-tests-final3.js +26 -0
- package/scratch/fix-tests-methods.js +40 -0
- package/scratch/fix-tests-proxy.js +67 -0
- package/scratch/fix-tests-types.js +24 -0
- package/scratch/rewrite-tests.js +110 -0
- package/tsc_errors.txt +60 -0
- package/tsc_errors2.txt +93 -0
- package/tmp-cv-test/package-lock.json +0 -250
- package/tmp-cv-test/package.json +0 -17
- package/tmp-cv-test/test.ts +0 -11
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthMigrationV1 = void 0;
|
|
4
|
+
class AuthMigrationV1 {
|
|
5
|
+
down(queryRunner) {
|
|
6
|
+
throw new Error('Method not implemented.');
|
|
7
|
+
}
|
|
8
|
+
get version() { return AuthMigrationV1.version; }
|
|
9
|
+
async up(queryRunner) {
|
|
10
|
+
await queryRunner.query(`CREATE EXTENSION IF NOT EXISTS "uuid-ossp"`);
|
|
11
|
+
// Create Enum Types
|
|
12
|
+
await queryRunner.query(`
|
|
13
|
+
DO $$
|
|
14
|
+
BEGIN
|
|
15
|
+
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'auth_strategy_enum') THEN
|
|
16
|
+
CREATE TYPE "auth_strategy_enum" AS ENUM('EMAIL', 'PHONE', 'USERNAME', 'GOOGLE', 'FACEBOOK', 'APPLE', 'LOCAL', 'OAUTH');
|
|
17
|
+
END IF;
|
|
18
|
+
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'auth_identifier_type_enum') THEN
|
|
19
|
+
CREATE TYPE "auth_identifier_type_enum" AS ENUM('EMAIL', 'PHONE', 'USERNAME');
|
|
20
|
+
END IF;
|
|
21
|
+
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'oauth_provider_type_enum') THEN
|
|
22
|
+
CREATE TYPE "oauth_provider_type_enum" AS ENUM('GOOGLE', 'FACEBOOK', 'APPLE');
|
|
23
|
+
END IF;
|
|
24
|
+
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'mfa_method_type_enum') THEN
|
|
25
|
+
CREATE TYPE "mfa_method_type_enum" AS ENUM('TOTP', 'SMS', 'EMAIL');
|
|
26
|
+
END IF;
|
|
27
|
+
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'otp_token_purpose_enum') THEN
|
|
28
|
+
CREATE TYPE "otp_token_purpose_enum" AS ENUM('VERIFY_EMAIL', 'VERIFY_PHONE', 'PASSWORD_RESET', 'LOGIN_2FA');
|
|
29
|
+
END IF;
|
|
30
|
+
END $$;
|
|
31
|
+
`);
|
|
32
|
+
// 1. auth table
|
|
33
|
+
await queryRunner.query(`
|
|
34
|
+
CREATE TABLE IF NOT EXISTS "auth" (
|
|
35
|
+
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
|
|
36
|
+
"uid" character varying,
|
|
37
|
+
"strategy" "auth_strategy_enum" NOT NULL,
|
|
38
|
+
"secretHash" character varying,
|
|
39
|
+
"isPrimary" boolean NOT NULL DEFAULT false,
|
|
40
|
+
"isVerified" boolean NOT NULL DEFAULT false,
|
|
41
|
+
"isActive" boolean NOT NULL DEFAULT true,
|
|
42
|
+
"meta" jsonb,
|
|
43
|
+
"lastUsedAt" TIMESTAMP,
|
|
44
|
+
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
|
|
45
|
+
"updatedAt" TIMESTAMP NOT NULL DEFAULT now(),
|
|
46
|
+
"deletedAt" TIMESTAMP,
|
|
47
|
+
CONSTRAINT "PK_auth" PRIMARY KEY ("id")
|
|
48
|
+
)
|
|
49
|
+
`);
|
|
50
|
+
// 2. auth_identifiers table
|
|
51
|
+
await queryRunner.query(`
|
|
52
|
+
CREATE TABLE IF NOT EXISTS "auth_identifiers" (
|
|
53
|
+
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
|
|
54
|
+
"authId" uuid,
|
|
55
|
+
"type" "auth_identifier_type_enum" NOT NULL,
|
|
56
|
+
"value" character varying NOT NULL,
|
|
57
|
+
"source" "auth_strategy_enum" NOT NULL DEFAULT 'LOCAL',
|
|
58
|
+
"isVerified" boolean NOT NULL DEFAULT false,
|
|
59
|
+
"verifiedBy" character varying,
|
|
60
|
+
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
|
|
61
|
+
"updatedAt" TIMESTAMP NOT NULL DEFAULT now(),
|
|
62
|
+
"deletedAt" TIMESTAMP,
|
|
63
|
+
CONSTRAINT "PK_auth_identifiers" PRIMARY KEY ("id")
|
|
64
|
+
)
|
|
65
|
+
`);
|
|
66
|
+
// 3. oauth_providers table
|
|
67
|
+
await queryRunner.query(`
|
|
68
|
+
CREATE TABLE IF NOT EXISTS "oauth_providers" (
|
|
69
|
+
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
|
|
70
|
+
"authId" uuid,
|
|
71
|
+
"provider" "oauth_provider_type_enum" NOT NULL,
|
|
72
|
+
"providerUserId" character varying NOT NULL,
|
|
73
|
+
"accessToken" character varying,
|
|
74
|
+
"refreshToken" character varying,
|
|
75
|
+
"expiresAt" TIMESTAMP,
|
|
76
|
+
"displayName" character varying,
|
|
77
|
+
"avatarUrl" character varying,
|
|
78
|
+
"emailVerified" boolean,
|
|
79
|
+
"rawProfile" jsonb,
|
|
80
|
+
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
|
|
81
|
+
"updatedAt" TIMESTAMP NOT NULL DEFAULT now(),
|
|
82
|
+
"deletedAt" TIMESTAMP,
|
|
83
|
+
CONSTRAINT "PK_oauth_providers" PRIMARY KEY ("id")
|
|
84
|
+
)
|
|
85
|
+
`);
|
|
86
|
+
// 4. auth_mfa_methods table
|
|
87
|
+
await queryRunner.query(`
|
|
88
|
+
CREATE TABLE IF NOT EXISTS "auth_mfa_methods" (
|
|
89
|
+
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
|
|
90
|
+
"uid" character varying NOT NULL,
|
|
91
|
+
"type" "mfa_method_type_enum" NOT NULL,
|
|
92
|
+
"secret" character varying NOT NULL,
|
|
93
|
+
"isEnabled" boolean NOT NULL DEFAULT false,
|
|
94
|
+
"isDefault" boolean NOT NULL DEFAULT false,
|
|
95
|
+
"lastUsedAt" TIMESTAMP,
|
|
96
|
+
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
|
|
97
|
+
CONSTRAINT "PK_auth_mfa_methods" PRIMARY KEY ("id")
|
|
98
|
+
)
|
|
99
|
+
`);
|
|
100
|
+
// 5. otp_tokens table
|
|
101
|
+
await queryRunner.query(`
|
|
102
|
+
CREATE TABLE IF NOT EXISTS "otp_tokens" (
|
|
103
|
+
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
|
|
104
|
+
"identifier" character varying NOT NULL,
|
|
105
|
+
"purpose" "otp_token_purpose_enum" NOT NULL,
|
|
106
|
+
"codeHash" character varying NOT NULL,
|
|
107
|
+
"expiresAt" TIMESTAMP NOT NULL,
|
|
108
|
+
"isUsed" boolean NOT NULL DEFAULT false,
|
|
109
|
+
"requestUserId" character varying,
|
|
110
|
+
"requestAuthId" character varying,
|
|
111
|
+
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
|
|
112
|
+
"updatedAt" TIMESTAMP NOT NULL DEFAULT now(),
|
|
113
|
+
"deletedAt" TIMESTAMP,
|
|
114
|
+
CONSTRAINT "PK_otp_tokens" PRIMARY KEY ("id")
|
|
115
|
+
)
|
|
116
|
+
`);
|
|
117
|
+
// 6. sessions table
|
|
118
|
+
await queryRunner.query(`
|
|
119
|
+
CREATE TABLE IF NOT EXISTS "sessions" (
|
|
120
|
+
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
|
|
121
|
+
"uid" character varying NOT NULL,
|
|
122
|
+
"refreshTokenHash" character varying NOT NULL,
|
|
123
|
+
"userAgent" character varying,
|
|
124
|
+
"deviceFingerprint" character varying,
|
|
125
|
+
"ipAddress" character varying,
|
|
126
|
+
"expiresAt" TIMESTAMP NOT NULL,
|
|
127
|
+
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
|
|
128
|
+
CONSTRAINT "PK_sessions" PRIMARY KEY ("id")
|
|
129
|
+
)
|
|
130
|
+
`);
|
|
131
|
+
// Indexes
|
|
132
|
+
await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_auth_uid" ON "auth" ("uid")`);
|
|
133
|
+
await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_auth_strategy" ON "auth" ("strategy")`);
|
|
134
|
+
await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_auth_isActive" ON "auth" ("isActive")`);
|
|
135
|
+
await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_auth_identifiers_authId" ON "auth_identifiers" ("authId")`);
|
|
136
|
+
await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_auth_identifiers_value" ON "auth_identifiers" ("value")`);
|
|
137
|
+
await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_oauth_providers_authId" ON "oauth_providers" ("authId")`);
|
|
138
|
+
await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_auth_mfa_methods_uid" ON "auth_mfa_methods" ("uid")`);
|
|
139
|
+
await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_otp_tokens_identifier" ON "otp_tokens" ("identifier")`);
|
|
140
|
+
await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_sessions_uid" ON "sessions" ("uid")`);
|
|
141
|
+
// Foreign Keys
|
|
142
|
+
await queryRunner.query(`
|
|
143
|
+
DO $$
|
|
144
|
+
BEGIN
|
|
145
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'FK_auth_identifiers_authId') THEN
|
|
146
|
+
ALTER TABLE "auth_identifiers" ADD CONSTRAINT "FK_auth_identifiers_authId" FOREIGN KEY ("authId") REFERENCES "auth"("id") ON DELETE CASCADE ON UPDATE NO ACTION;
|
|
147
|
+
END IF;
|
|
148
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'FK_oauth_providers_authId') THEN
|
|
149
|
+
ALTER TABLE "oauth_providers" ADD CONSTRAINT "FK_oauth_providers_authId" FOREIGN KEY ("authId") REFERENCES "auth"("id") ON DELETE CASCADE ON UPDATE NO ACTION;
|
|
150
|
+
END IF;
|
|
151
|
+
END $$;
|
|
152
|
+
`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.AuthMigrationV1 = AuthMigrationV1;
|
|
156
|
+
AuthMigrationV1.version = 1;
|
|
157
|
+
//# sourceMappingURL=auth.migration.v1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.migration.v1.js","sourceRoot":"","sources":["../../../../src/database/typeorm/migrations/auth.migration.v1.ts"],"names":[],"mappings":";;;AAQA,MAAa,eAAe;IAC1B,IAAI,CAAC,WAAwB;QAC3B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,OAAO,KAAK,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;IAEjD,KAAK,CAAC,EAAE,CAAC,WAAwB;QAC/B,MAAM,WAAW,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAEtE,oBAAoB;QACpB,MAAM,WAAW,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;KAmBvB,CAAC,CAAC;QAEH,gBAAgB;QAChB,MAAM,WAAW,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;KAgBvB,CAAC,CAAC;QAEH,4BAA4B;QAC5B,MAAM,WAAW,CAAC,KAAK,CAAC;;;;;;;;;;;;;;KAcvB,CAAC,CAAC;QAEH,2BAA2B;QAC3B,MAAM,WAAW,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;KAkBvB,CAAC,CAAC;QAEH,4BAA4B;QAC5B,MAAM,WAAW,CAAC,KAAK,CAAC;;;;;;;;;;;;KAYvB,CAAC,CAAC;QAEH,sBAAsB;QACtB,MAAM,WAAW,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;KAevB,CAAC,CAAC;QAEH,oBAAoB;QACpB,MAAM,WAAW,CAAC,KAAK,CAAC;;;;;;;;;;;;KAYvB,CAAC,CAAC;QAEH,UAAU;QACV,MAAM,WAAW,CAAC,KAAK,CAAC,6DAA6D,CAAC,CAAC;QACvF,MAAM,WAAW,CAAC,KAAK,CAAC,uEAAuE,CAAC,CAAC;QACjG,MAAM,WAAW,CAAC,KAAK,CAAC,uEAAuE,CAAC,CAAC;QACjG,MAAM,WAAW,CAAC,KAAK,CAAC,2FAA2F,CAAC,CAAC;QACrH,MAAM,WAAW,CAAC,KAAK,CAAC,yFAAyF,CAAC,CAAC;QACnH,MAAM,WAAW,CAAC,KAAK,CAAC,yFAAyF,CAAC,CAAC;QACnH,MAAM,WAAW,CAAC,KAAK,CAAC,qFAAqF,CAAC,CAAC;QAC/G,MAAM,WAAW,CAAC,KAAK,CAAC,uFAAuF,CAAC,CAAC;QACjH,MAAM,WAAW,CAAC,KAAK,CAAC,qEAAqE,CAAC,CAAC;QAE/F,eAAe;QACf,MAAM,WAAW,CAAC,KAAK,CAAC;;;;;;;;;;KAUvB,CAAC,CAAC;IACL,CAAC;;AAhKH,0CAiKC;AA7JQ,uBAAO,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { QueryRunner } from 'typeorm';
|
|
2
|
+
import { AuthMigration } from './auth.migration.v1';
|
|
3
|
+
export declare class AuthMigrationV2 implements AuthMigration {
|
|
4
|
+
static version: number;
|
|
5
|
+
get version(): number;
|
|
6
|
+
up(queryRunner: QueryRunner): Promise<void>;
|
|
7
|
+
down(queryRunner: QueryRunner): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthMigrationV2 = void 0;
|
|
4
|
+
class AuthMigrationV2 {
|
|
5
|
+
get version() { return AuthMigrationV2.version; }
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.query(`
|
|
8
|
+
ALTER TABLE "auth_mfa_methods"
|
|
9
|
+
ADD COLUMN IF NOT EXISTS "updatedAt" TIMESTAMP NOT NULL DEFAULT now(),
|
|
10
|
+
ADD COLUMN IF NOT EXISTS "deletedAt" TIMESTAMP;
|
|
11
|
+
`);
|
|
12
|
+
}
|
|
13
|
+
async down(queryRunner) {
|
|
14
|
+
await queryRunner.query(`
|
|
15
|
+
ALTER TABLE "auth_mfa_methods"
|
|
16
|
+
DROP COLUMN IF EXISTS "updatedAt",
|
|
17
|
+
DROP COLUMN IF EXISTS "deletedAt";
|
|
18
|
+
`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.AuthMigrationV2 = AuthMigrationV2;
|
|
22
|
+
AuthMigrationV2.version = 2;
|
|
23
|
+
//# sourceMappingURL=auth.migration.v2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.migration.v2.js","sourceRoot":"","sources":["../../../../src/database/typeorm/migrations/auth.migration.v2.ts"],"names":[],"mappings":";;;AAGA,MAAa,eAAe;IAE1B,IAAI,OAAO,KAAK,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;IAEjD,KAAK,CAAC,EAAE,CAAC,WAAwB;QAC/B,MAAM,WAAW,CAAC,KAAK,CAAC;;;;KAIvB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,WAAwB;QACjC,MAAM,WAAW,CAAC,KAAK,CAAC;;;;KAIvB,CAAC,CAAC;IACL,CAAC;;AAlBH,0CAmBC;AAlBQ,uBAAO,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthMigrations = void 0;
|
|
4
|
+
const auth_migration_v1_1 = require("./auth.migration.v1");
|
|
5
|
+
const auth_migration_v2_1 = require("./auth.migration.v2");
|
|
6
|
+
exports.AuthMigrations = [
|
|
7
|
+
auth_migration_v1_1.AuthMigrationV1,
|
|
8
|
+
auth_migration_v2_1.AuthMigrationV2,
|
|
9
|
+
];
|
|
10
|
+
//# sourceMappingURL=auth.migrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.migrations.js","sourceRoot":"","sources":["../../../../src/database/typeorm/migrations/auth.migrations.ts"],"names":[],"mappings":";;;AAAA,2DAAsD;AACtD,2DAAsD;AAEzC,QAAA,cAAc,GAAG;IAC1B,mCAAe;IACf,mCAAe;CAClB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DataSource, QueryRunner } from "typeorm";
|
|
2
|
+
export declare class AuthMigrationService {
|
|
3
|
+
private dataSource;
|
|
4
|
+
constructor(dataSource: DataSource);
|
|
5
|
+
runMigrations(): Promise<void>;
|
|
6
|
+
ensureMetaTable(qr?: QueryRunner): Promise<void>;
|
|
7
|
+
getCurrentVersion(qr?: QueryRunner): Promise<number>;
|
|
8
|
+
updateVersion(qr?: QueryRunner, version?: number): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AuthMigrationService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const typeorm_1 = require("typeorm");
|
|
18
|
+
const auth_migrations_1 = require("./auth.migrations");
|
|
19
|
+
let AuthMigrationService = class AuthMigrationService {
|
|
20
|
+
constructor(dataSource) {
|
|
21
|
+
this.dataSource = dataSource;
|
|
22
|
+
}
|
|
23
|
+
async runMigrations() {
|
|
24
|
+
const queryRunner = this.dataSource.createQueryRunner();
|
|
25
|
+
await queryRunner.connect();
|
|
26
|
+
await this.ensureMetaTable(queryRunner);
|
|
27
|
+
const currentVersion = await this.getCurrentVersion(queryRunner);
|
|
28
|
+
const pendingMigrations = auth_migrations_1.AuthMigrations.filter((M) => M.version > currentVersion);
|
|
29
|
+
for (const MigrationClass of pendingMigrations) {
|
|
30
|
+
const migration = new MigrationClass();
|
|
31
|
+
await queryRunner.startTransaction();
|
|
32
|
+
try {
|
|
33
|
+
await migration.up(queryRunner);
|
|
34
|
+
await this.updateVersion(queryRunner, migration.version);
|
|
35
|
+
await queryRunner.commitTransaction();
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
await queryRunner.rollbackTransaction();
|
|
39
|
+
throw err;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
await queryRunner.release();
|
|
43
|
+
}
|
|
44
|
+
async ensureMetaTable(qr) {
|
|
45
|
+
const executor = qr || this.dataSource;
|
|
46
|
+
await executor.query(`
|
|
47
|
+
CREATE TABLE IF NOT EXISTS auth_schema_meta (
|
|
48
|
+
id SERIAL PRIMARY KEY,
|
|
49
|
+
version INT NOT NULL,
|
|
50
|
+
updated_at TIMESTAMP DEFAULT now()
|
|
51
|
+
)
|
|
52
|
+
`);
|
|
53
|
+
}
|
|
54
|
+
async getCurrentVersion(qr) {
|
|
55
|
+
await this.ensureMetaTable(qr);
|
|
56
|
+
const executor = qr || this.dataSource;
|
|
57
|
+
const result = await executor.query(`
|
|
58
|
+
SELECT version FROM auth_schema_meta ORDER BY version DESC LIMIT 1
|
|
59
|
+
`);
|
|
60
|
+
return result.length > 0 ? result[0].version : 0;
|
|
61
|
+
}
|
|
62
|
+
async updateVersion(qr, version) {
|
|
63
|
+
const executor = qr || this.dataSource;
|
|
64
|
+
await executor.query(`
|
|
65
|
+
INSERT INTO auth_schema_meta (version) VALUES ($1)
|
|
66
|
+
`, [version]);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
exports.AuthMigrationService = AuthMigrationService;
|
|
70
|
+
exports.AuthMigrationService = AuthMigrationService = __decorate([
|
|
71
|
+
(0, common_1.Injectable)(),
|
|
72
|
+
__param(0, (0, common_1.Optional)()),
|
|
73
|
+
__metadata("design:paramtypes", [typeorm_1.DataSource])
|
|
74
|
+
], AuthMigrationService);
|
|
75
|
+
//# sourceMappingURL=migration.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.service.js","sourceRoot":"","sources":["../../../../src/database/typeorm/migrations/migration.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAsD;AACtD,qCAAkD;AAClD,uDAAmD;AAG5C,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC7B,YAAgC,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAI,CAAC;IAE3D,KAAK,CAAC,aAAa;QACf,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC;QAExD,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;QAE5B,MAAM,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;QAExC,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;QAEjE,MAAM,iBAAiB,GAAG,gCAAc,CAAC,MAAM,CAC3C,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,cAAc,CACzC,CAAC;QAEF,KAAK,MAAM,cAAc,IAAI,iBAAiB,EAAE,CAAC;YAC7C,MAAM,SAAS,GAAG,IAAI,cAAc,EAAE,CAAC;YAEvC,MAAM,WAAW,CAAC,gBAAgB,EAAE,CAAC;YAErC,IAAI,CAAC;gBACD,MAAM,SAAS,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;gBAEhC,MAAM,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;gBAEzD,MAAM,WAAW,CAAC,iBAAiB,EAAE,CAAC;YAC1C,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACX,MAAM,WAAW,CAAC,mBAAmB,EAAE,CAAC;gBACxC,MAAM,GAAG,CAAC;YACd,CAAC;QACL,CAAC;QAED,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,EAAgB;QAClC,MAAM,QAAQ,GAAG,EAAE,IAAI,IAAI,CAAC,UAAU,CAAC;QACvC,MAAM,QAAQ,CAAC,KAAK,CAAC;;;;;;SAMpB,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,EAAgB;QACpC,MAAM,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAC/B,MAAM,QAAQ,GAAG,EAAE,IAAI,IAAI,CAAC,UAAU,CAAC;QACvC,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC;;SAEnC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,EAAgB,EAAE,OAAgB;QAClD,MAAM,QAAQ,GAAG,EAAE,IAAI,IAAI,CAAC,UAAU,CAAC;QACvC,MAAM,QAAQ,CAAC,KAAK,CAAC;;SAEpB,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAClB,CAAC;CACJ,CAAA;AA9DY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAEI,WAAA,IAAA,iBAAQ,GAAE,CAAA;qCAAqB,oBAAU;GAD7C,oBAAoB,CA8DhC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Repository } from 'typeorm';
|
|
2
|
+
import { AuthIdentifierRepository } from '../../../auth/interfaces/repositories.interface';
|
|
3
|
+
import { AuthIdentifier as CoreAuthIdentifier, Auth as CoreAuth } from '../../../auth/interfaces/models.interface';
|
|
4
|
+
import { AuthIdentifier } from '../entities/auth-identify.entity';
|
|
5
|
+
export declare class TypeOrmAuthIdentifierRepository implements AuthIdentifierRepository {
|
|
6
|
+
private readonly repo;
|
|
7
|
+
constructor(repo: Repository<AuthIdentifier>);
|
|
8
|
+
create(data: Partial<CoreAuthIdentifier>): Promise<CoreAuthIdentifier>;
|
|
9
|
+
findByValue(value: string): Promise<CoreAuthIdentifier | null>;
|
|
10
|
+
findByAuthId(authId: string): Promise<CoreAuthIdentifier[]>;
|
|
11
|
+
findByUidAndTypes(uid: string, types: string[]): Promise<CoreAuthIdentifier | null>;
|
|
12
|
+
findWithAuthByValue(value: string): Promise<{
|
|
13
|
+
identifier: CoreAuthIdentifier;
|
|
14
|
+
auth: CoreAuth;
|
|
15
|
+
} | null>;
|
|
16
|
+
save(identifier: CoreAuthIdentifier): Promise<CoreAuthIdentifier>;
|
|
17
|
+
markVerifiedByAuthId(authId: string): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.TypeOrmAuthIdentifierRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
18
|
+
const typeorm_2 = require("typeorm");
|
|
19
|
+
const auth_identify_entity_1 = require("../entities/auth-identify.entity");
|
|
20
|
+
let TypeOrmAuthIdentifierRepository = class TypeOrmAuthIdentifierRepository {
|
|
21
|
+
constructor(repo) {
|
|
22
|
+
this.repo = repo;
|
|
23
|
+
}
|
|
24
|
+
async create(data) {
|
|
25
|
+
return this.repo.create(data);
|
|
26
|
+
}
|
|
27
|
+
async findByValue(value) {
|
|
28
|
+
return this.repo.findOne({ where: { value } });
|
|
29
|
+
}
|
|
30
|
+
async findByAuthId(authId) {
|
|
31
|
+
return this.repo.find({ where: { auth: { id: authId } } });
|
|
32
|
+
}
|
|
33
|
+
async findByUidAndTypes(uid, types) {
|
|
34
|
+
const res = await this.repo.query(`SELECT ai.* FROM auth_identifiers ai
|
|
35
|
+
JOIN auth a ON ai."authId" = a.id
|
|
36
|
+
WHERE a.uid = $1 AND ai.type = ANY($2::auth_identifier_type_enum[])
|
|
37
|
+
ORDER BY ai."isVerified" DESC, ai."createdAt" ASC LIMIT 1`, [uid, types]);
|
|
38
|
+
return res[0] || null;
|
|
39
|
+
}
|
|
40
|
+
async findWithAuthByValue(value) {
|
|
41
|
+
const res = await this.repo.query(`SELECT ai.*, a.uid, a.id as "authId" FROM auth_identifiers ai
|
|
42
|
+
JOIN auth a ON ai."authId" = a.id
|
|
43
|
+
WHERE ai.value = $1 LIMIT 1`, [value.toLowerCase()]);
|
|
44
|
+
if (!res[0])
|
|
45
|
+
return null;
|
|
46
|
+
return {
|
|
47
|
+
identifier: res[0],
|
|
48
|
+
auth: { uid: res[0].uid, id: res[0].authId },
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
async save(identifier) {
|
|
52
|
+
return this.repo.save(identifier);
|
|
53
|
+
}
|
|
54
|
+
async markVerifiedByAuthId(authId) {
|
|
55
|
+
await this.repo.query(`UPDATE auth_identifiers SET "isVerified" = true WHERE "authId" = $1`, [authId]);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
exports.TypeOrmAuthIdentifierRepository = TypeOrmAuthIdentifierRepository;
|
|
59
|
+
exports.TypeOrmAuthIdentifierRepository = TypeOrmAuthIdentifierRepository = __decorate([
|
|
60
|
+
(0, common_1.Injectable)(),
|
|
61
|
+
__param(0, (0, typeorm_1.InjectRepository)(auth_identify_entity_1.AuthIdentifier)),
|
|
62
|
+
__metadata("design:paramtypes", [typeorm_2.Repository])
|
|
63
|
+
], TypeOrmAuthIdentifierRepository);
|
|
64
|
+
//# sourceMappingURL=auth-identifier.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-identifier.repository.js","sourceRoot":"","sources":["../../../../src/database/typeorm/repositories/auth-identifier.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAmD;AACnD,qCAAqC;AAGrC,2EAAkE;AAI3D,IAAM,+BAA+B,GAArC,MAAM,+BAA+B;IAC1C,YAEmB,IAAgC;QAAhC,SAAI,GAAJ,IAAI,CAA4B;IAChD,CAAC;IAEJ,KAAK,CAAC,MAAM,CAAC,IAAiC;QAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,KAAa;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,MAAc;QAC/B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,GAAW,EAAE,KAAe;QAClD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAC/B;;;iEAG2D,EAC3D,CAAC,GAAG,EAAE,KAAK,CAAC,CACb,CAAC;QACF,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,KAAa;QACrC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAC/B;;mCAE6B,EAC7B,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CACtB,CAAC;QACF,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;QACzB,OAAO;YACL,UAAU,EAAE,GAAG,CAAC,CAAC,CAAuB;YACxC,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,EAAc;SACzD,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,UAA8B;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,MAAc;QACvC,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CACnB,qEAAqE,EACrE,CAAC,MAAM,CAAC,CACT,CAAC;IACJ,CAAC;CACF,CAAA;AArDY,0EAA+B;0CAA/B,+BAA+B;IAD3C,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,qCAAc,CAAC,CAAA;qCACV,oBAAU;GAHxB,+BAA+B,CAqD3C"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Repository } from 'typeorm';
|
|
2
|
+
import { AuthRepository } from '../../../auth/interfaces/repositories.interface';
|
|
3
|
+
import { Auth as CoreAuth } from '../../../auth/interfaces/models.interface';
|
|
4
|
+
import { Auth } from '../entities/auth.entity';
|
|
5
|
+
import { AuthStrategy } from '../../../auth/enums/auth-type.enum';
|
|
6
|
+
export declare class TypeOrmAuthRepository implements AuthRepository {
|
|
7
|
+
private readonly repo;
|
|
8
|
+
constructor(repo: Repository<Auth>);
|
|
9
|
+
create(data: Partial<CoreAuth>): Promise<CoreAuth>;
|
|
10
|
+
findById(id: string): Promise<CoreAuth | null>;
|
|
11
|
+
findByUid(uid: string): Promise<CoreAuth | null>;
|
|
12
|
+
findByUidAndStrategy(uid: string, strategy: AuthStrategy): Promise<CoreAuth | null>;
|
|
13
|
+
findByUidAndStrategies(uid: string, strategies: AuthStrategy[]): Promise<CoreAuth | null>;
|
|
14
|
+
findAllByUid(uid: string): Promise<CoreAuth[]>;
|
|
15
|
+
findAll(): Promise<CoreAuth[]>;
|
|
16
|
+
save(auth: CoreAuth): Promise<CoreAuth>;
|
|
17
|
+
update(id: string, data: Partial<CoreAuth>): Promise<void>;
|
|
18
|
+
delete(id: string): Promise<void>;
|
|
19
|
+
deleteByUid(uid: string): Promise<void>;
|
|
20
|
+
findWithIdentifiers(id: string): Promise<CoreAuth | null>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.TypeOrmAuthRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
18
|
+
const typeorm_2 = require("typeorm");
|
|
19
|
+
const auth_entity_1 = require("../entities/auth.entity");
|
|
20
|
+
let TypeOrmAuthRepository = class TypeOrmAuthRepository {
|
|
21
|
+
constructor(repo) {
|
|
22
|
+
this.repo = repo;
|
|
23
|
+
}
|
|
24
|
+
async create(data) {
|
|
25
|
+
const entity = this.repo.create(data);
|
|
26
|
+
return entity;
|
|
27
|
+
}
|
|
28
|
+
async findById(id) {
|
|
29
|
+
return this.repo.findOne({ where: { id } });
|
|
30
|
+
}
|
|
31
|
+
async findByUid(uid) {
|
|
32
|
+
return this.repo.findOne({ where: { uid } });
|
|
33
|
+
}
|
|
34
|
+
async findByUidAndStrategy(uid, strategy) {
|
|
35
|
+
return this.repo.findOne({ where: { uid, strategy } });
|
|
36
|
+
}
|
|
37
|
+
async findByUidAndStrategies(uid, strategies) {
|
|
38
|
+
return this.repo.findOne({ where: { uid, strategy: (0, typeorm_2.In)(strategies) } });
|
|
39
|
+
}
|
|
40
|
+
async findAllByUid(uid) {
|
|
41
|
+
return this.repo.find({ where: { uid }, relations: ['identifiers', 'oauthProviders'] });
|
|
42
|
+
}
|
|
43
|
+
async findAll() {
|
|
44
|
+
return this.repo.find({ relations: ['identifiers', 'oauthProviders'] });
|
|
45
|
+
}
|
|
46
|
+
async save(auth) {
|
|
47
|
+
return this.repo.save(auth);
|
|
48
|
+
}
|
|
49
|
+
async update(id, data) {
|
|
50
|
+
await this.repo.update(id, data);
|
|
51
|
+
}
|
|
52
|
+
async delete(id) {
|
|
53
|
+
await this.repo.delete(id);
|
|
54
|
+
}
|
|
55
|
+
async deleteByUid(uid) {
|
|
56
|
+
await this.repo.delete({ uid });
|
|
57
|
+
}
|
|
58
|
+
async findWithIdentifiers(id) {
|
|
59
|
+
return this.repo.findOne({
|
|
60
|
+
where: { id },
|
|
61
|
+
relations: ['identifiers'],
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
exports.TypeOrmAuthRepository = TypeOrmAuthRepository;
|
|
66
|
+
exports.TypeOrmAuthRepository = TypeOrmAuthRepository = __decorate([
|
|
67
|
+
(0, common_1.Injectable)(),
|
|
68
|
+
__param(0, (0, typeorm_1.InjectRepository)(auth_entity_1.Auth)),
|
|
69
|
+
__metadata("design:paramtypes", [typeorm_2.Repository])
|
|
70
|
+
], TypeOrmAuthRepository);
|
|
71
|
+
//# sourceMappingURL=auth.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.repository.js","sourceRoot":"","sources":["../../../../src/database/typeorm/repositories/auth.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAmD;AACnD,qCAAyC;AAGzC,yDAA+C;AAIxC,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAChC,YAEmB,IAAsB;QAAtB,SAAI,GAAJ,IAAI,CAAkB;IACtC,CAAC;IAEJ,KAAK,CAAC,MAAM,CAAC,IAAuB;QAClC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,EAAU;QACvB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,GAAW;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,GAAW,EAAE,QAAsB;QAC5D,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,sBAAsB,CAAC,GAAW,EAAE,UAA0B;QAClE,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAA,YAAE,EAAC,UAAU,CAAC,EAAS,EAAE,CAAC,CAAC;IAChF,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,GAAW;QAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE,CAAC,aAAa,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAAC;IAC1F,CAAC;IAED,KAAK,CAAC,OAAO;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC,aAAa,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAc;QACvB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU,EAAE,IAAuB;QAC9C,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,GAAW;QAC3B,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,EAAU;QAClC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;YACvB,KAAK,EAAE,EAAE,EAAE,EAAE;YACb,SAAS,EAAE,CAAC,aAAa,CAAC;SAC3B,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAzDY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,kBAAI,CAAC,CAAA;qCACA,oBAAU;GAHxB,qBAAqB,CAyDjC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './auth.repository';
|
|
2
|
+
export * from './auth-identifier.repository';
|
|
3
|
+
export * from './oauth-provider.repository';
|
|
4
|
+
export * from './otp-token.repository';
|
|
5
|
+
export * from './mfa-method.repository';
|
|
6
|
+
export * from './session.repository';
|
|
7
|
+
export * from './session-log.repository';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./auth.repository"), exports);
|
|
18
|
+
__exportStar(require("./auth-identifier.repository"), exports);
|
|
19
|
+
__exportStar(require("./oauth-provider.repository"), exports);
|
|
20
|
+
__exportStar(require("./otp-token.repository"), exports);
|
|
21
|
+
__exportStar(require("./mfa-method.repository"), exports);
|
|
22
|
+
__exportStar(require("./session.repository"), exports);
|
|
23
|
+
__exportStar(require("./session-log.repository"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/database/typeorm/repositories/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,+DAA6C;AAC7C,8DAA4C;AAC5C,yDAAuC;AACvC,0DAAwC;AACxC,uDAAqC;AACrC,2DAAyC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Repository } from 'typeorm';
|
|
2
|
+
import { MfaMethodRepository } from '../../../auth/interfaces/repositories.interface';
|
|
3
|
+
import { MfaMethod as CoreMfaMethod } from '../../../auth/interfaces/models.interface';
|
|
4
|
+
import { MfaMethod } from '../entities/mfa-method.entity';
|
|
5
|
+
export declare class TypeOrmMfaMethodRepository implements MfaMethodRepository {
|
|
6
|
+
private readonly repo;
|
|
7
|
+
constructor(repo: Repository<MfaMethod>);
|
|
8
|
+
create(data: Partial<CoreMfaMethod>): Promise<CoreMfaMethod>;
|
|
9
|
+
findByUidAndEnabled(uid: string): Promise<CoreMfaMethod | null>;
|
|
10
|
+
findByUidAndType(uid: string, type: any): Promise<CoreMfaMethod | null>;
|
|
11
|
+
save(method: CoreMfaMethod): Promise<CoreMfaMethod>;
|
|
12
|
+
deleteByUid(uid: string): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.TypeOrmMfaMethodRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
18
|
+
const typeorm_2 = require("typeorm");
|
|
19
|
+
const mfa_method_entity_1 = require("../entities/mfa-method.entity");
|
|
20
|
+
let TypeOrmMfaMethodRepository = class TypeOrmMfaMethodRepository {
|
|
21
|
+
constructor(repo) {
|
|
22
|
+
this.repo = repo;
|
|
23
|
+
}
|
|
24
|
+
async create(data) {
|
|
25
|
+
return this.repo.create(data);
|
|
26
|
+
}
|
|
27
|
+
async findByUidAndEnabled(uid) {
|
|
28
|
+
return this.repo.findOne({ where: { uid, isEnabled: true } });
|
|
29
|
+
}
|
|
30
|
+
async findByUidAndType(uid, type) {
|
|
31
|
+
return this.repo.findOne({ where: { uid, type } });
|
|
32
|
+
}
|
|
33
|
+
async save(method) {
|
|
34
|
+
return this.repo.save(method);
|
|
35
|
+
}
|
|
36
|
+
async deleteByUid(uid) {
|
|
37
|
+
await this.repo.delete({ uid });
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.TypeOrmMfaMethodRepository = TypeOrmMfaMethodRepository;
|
|
41
|
+
exports.TypeOrmMfaMethodRepository = TypeOrmMfaMethodRepository = __decorate([
|
|
42
|
+
(0, common_1.Injectable)(),
|
|
43
|
+
__param(0, (0, typeorm_1.InjectRepository)(mfa_method_entity_1.MfaMethod)),
|
|
44
|
+
__metadata("design:paramtypes", [typeorm_2.Repository])
|
|
45
|
+
], TypeOrmMfaMethodRepository);
|
|
46
|
+
//# sourceMappingURL=mfa-method.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mfa-method.repository.js","sourceRoot":"","sources":["../../../../src/database/typeorm/repositories/mfa-method.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAmD;AACnD,qCAAqC;AAGrC,qEAA0D;AAGnD,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IACrC,YAEmB,IAA2B;QAA3B,SAAI,GAAJ,IAAI,CAAuB;IAC3C,CAAC;IAEJ,KAAK,CAAC,MAAM,CAAC,IAA4B;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,GAAW;QACnC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,GAAW,EAAE,IAAS;QAC3C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,MAAqB;QAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,GAAW;QAC3B,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IAClC,CAAC;CACF,CAAA;AAzBY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,6BAAS,CAAC,CAAA;qCACL,oBAAU;GAHxB,0BAA0B,CAyBtC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Repository } from 'typeorm';
|
|
2
|
+
import { OAuthProviderRepository } from '../../../auth/interfaces/repositories.interface';
|
|
3
|
+
import { OAuthProvider as CoreOAuthProvider } from '../../../auth/interfaces/models.interface';
|
|
4
|
+
import { OAuthProvider } from '../entities/oauth-provider.entity';
|
|
5
|
+
export declare class TypeOrmOAuthProviderRepository implements OAuthProviderRepository {
|
|
6
|
+
private readonly repo;
|
|
7
|
+
constructor(repo: Repository<OAuthProvider>);
|
|
8
|
+
create(data: Partial<CoreOAuthProvider>): Promise<CoreOAuthProvider>;
|
|
9
|
+
findByProviderUserId(provider: any, providerUserId: string): Promise<CoreOAuthProvider | null>;
|
|
10
|
+
findWithAuthByProviderUserId(provider: string, providerUserId: string): Promise<{
|
|
11
|
+
provider: CoreOAuthProvider;
|
|
12
|
+
auth: any;
|
|
13
|
+
} | null>;
|
|
14
|
+
save(provider: CoreOAuthProvider): Promise<CoreOAuthProvider>;
|
|
15
|
+
update(id: string, data: Partial<CoreOAuthProvider>): Promise<void>;
|
|
16
|
+
}
|