@anarchitects/auth-nest 0.5.1 → 0.6.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/README.md +102 -61
- package/package.json +24 -4
- package/src/application/application.module.js +61 -36
- package/src/application/application.module.js.map +1 -1
- package/src/application/index.d.ts +0 -2
- package/src/application/index.js +0 -2
- package/src/application/index.js.map +1 -1
- package/src/application/ports/auth-account.repository.d.ts +18 -0
- package/src/application/ports/auth-account.repository.js +12 -0
- package/src/application/ports/auth-account.repository.js.map +1 -0
- package/src/{infrastructure-persistence/repositories → application/ports}/auth-user.repository.d.ts +1 -2
- package/src/application/ports/auth-user.repository.js.map +1 -0
- package/src/application/resource-authorization.types.d.ts +1 -16
- package/src/application/services/auth-engine.port.d.ts +22 -17
- package/src/application/services/auth-engine.port.js.map +1 -1
- package/src/application/services/auth-orchestration.service.d.ts +15 -10
- package/src/application/services/auth-orchestration.service.js +78 -61
- package/src/application/services/auth-orchestration.service.js.map +1 -1
- package/src/application/services/auth.service.d.ts +10 -7
- package/src/application/services/auth.service.js.map +1 -1
- package/src/application/services/better-auth-database.port.d.ts +3 -0
- package/src/application/services/better-auth-database.port.js +12 -0
- package/src/application/services/better-auth-database.port.js.map +1 -0
- package/src/application/services/policies.service.d.ts +1 -1
- package/src/application/services/policies.service.js +1 -1
- package/src/application/services/policies.service.js.map +1 -1
- package/src/application/services/resource-authorization.d.ts +1 -1
- package/src/auth.module.js +29 -3
- package/src/auth.module.js.map +1 -1
- package/src/config/auth.config.d.ts +62 -48
- package/src/config/auth.config.js +82 -76
- package/src/config/auth.config.js.map +1 -1
- package/src/config/index.d.ts +1 -0
- package/src/config/index.js +1 -0
- package/src/config/index.js.map +1 -1
- package/src/config/module-options.d.ts +69 -49
- package/src/config/module-options.js +79 -50
- package/src/config/module-options.js.map +1 -1
- package/src/config/resource-authorization.types.d.ts +16 -0
- package/src/config/resource-authorization.types.js +3 -0
- package/src/config/resource-authorization.types.js.map +1 -0
- package/src/infrastructure-engine/better-auth/better-auth-auth-engine.adapter.d.ts +32 -10
- package/src/infrastructure-engine/better-auth/better-auth-auth-engine.adapter.js +190 -90
- package/src/infrastructure-engine/better-auth/better-auth-auth-engine.adapter.js.map +1 -1
- package/src/infrastructure-engine/better-auth/better-auth-options.d.ts +21 -0
- package/src/infrastructure-engine/better-auth/better-auth-options.js +94 -0
- package/src/infrastructure-engine/better-auth/better-auth-options.js.map +1 -0
- package/src/infrastructure-engine/better-auth/better-auth-typeorm-adapter-persistence.adapter.d.ts +14 -0
- package/src/infrastructure-engine/better-auth/better-auth-typeorm-adapter-persistence.adapter.js +62 -0
- package/src/infrastructure-engine/better-auth/better-auth-typeorm-adapter-persistence.adapter.js.map +1 -0
- package/src/infrastructure-engine/better-auth/better-auth.module-loader.d.ts +6 -0
- package/src/infrastructure-engine/better-auth/better-auth.module-loader.js +9 -1
- package/src/infrastructure-engine/better-auth/better-auth.module-loader.js.map +1 -1
- package/src/infrastructure-engine/better-auth/plugins/jwt/better-auth-jwt-plugin.service.d.ts +21 -0
- package/src/infrastructure-engine/{legacy-jwt-auth-engine.adapter.js → better-auth/plugins/jwt/better-auth-jwt-plugin.service.js} +31 -63
- package/src/infrastructure-engine/better-auth/plugins/jwt/better-auth-jwt-plugin.service.js.map +1 -0
- package/src/infrastructure-engine/better-auth/plugins/jwt/better-auth-jwt-typeorm-support.module.d.ts +2 -0
- package/src/infrastructure-engine/better-auth/plugins/jwt/better-auth-jwt-typeorm-support.module.js +26 -0
- package/src/infrastructure-engine/better-auth/plugins/jwt/better-auth-jwt-typeorm-support.module.js.map +1 -0
- package/src/{infrastructure-persistence/entities → infrastructure-engine/better-auth/plugins/jwt}/invalidated-token.entity.js +1 -1
- package/src/infrastructure-engine/better-auth/plugins/jwt/invalidated-token.entity.js.map +1 -0
- package/src/infrastructure-engine/better-auth/plugins/jwt/jwt-auth-plugin.controller.d.ts +10 -0
- package/src/infrastructure-engine/better-auth/plugins/jwt/jwt-auth-plugin.controller.js +65 -0
- package/src/infrastructure-engine/better-auth/plugins/jwt/jwt-auth-plugin.controller.js.map +1 -0
- package/src/infrastructure-engine/better-auth/plugins/jwt/jwt-token-invalidation.repository.d.ts +4 -0
- package/src/infrastructure-engine/better-auth/plugins/jwt/jwt-token-invalidation.repository.js +12 -0
- package/src/infrastructure-engine/better-auth/plugins/jwt/jwt-token-invalidation.repository.js.map +1 -0
- package/src/infrastructure-engine/better-auth/plugins/jwt/typeorm-jwt-token-invalidation.repository.d.ts +9 -0
- package/src/infrastructure-engine/better-auth/plugins/jwt/typeorm-jwt-token-invalidation.repository.js +33 -0
- package/src/infrastructure-engine/better-auth/plugins/jwt/typeorm-jwt-token-invalidation.repository.js.map +1 -0
- package/src/infrastructure-engine/better-auth/plugins/passkeys/better-auth-passkeys-typeorm-support.module.d.ts +2 -0
- package/src/infrastructure-engine/better-auth/plugins/passkeys/better-auth-passkeys-typeorm-support.module.js +17 -0
- package/src/infrastructure-engine/better-auth/plugins/passkeys/better-auth-passkeys-typeorm-support.module.js.map +1 -0
- package/src/infrastructure-engine/better-auth/plugins/passkeys/migrations/1760200001000-create-better-auth-passkeys-table.d.ts +6 -0
- package/src/infrastructure-engine/better-auth/plugins/passkeys/migrations/1760200001000-create-better-auth-passkeys-table.js +83 -0
- package/src/infrastructure-engine/better-auth/plugins/passkeys/migrations/1760200001000-create-better-auth-passkeys-table.js.map +1 -0
- package/src/infrastructure-engine/better-auth/plugins/passkeys/passkey.entity.d.ts +14 -0
- package/src/infrastructure-engine/better-auth/plugins/passkeys/passkey.entity.js +71 -0
- package/src/infrastructure-engine/better-auth/plugins/passkeys/passkey.entity.js.map +1 -0
- package/src/infrastructure-persistence/entities/account.entity.d.ts +16 -0
- package/src/infrastructure-persistence/entities/account.entity.js +81 -0
- package/src/infrastructure-persistence/entities/account.entity.js.map +1 -0
- package/src/infrastructure-persistence/entities/session.entity.d.ts +11 -0
- package/src/infrastructure-persistence/entities/session.entity.js +58 -0
- package/src/infrastructure-persistence/entities/session.entity.js.map +1 -0
- package/src/infrastructure-persistence/entities/user.entity.d.ts +3 -4
- package/src/infrastructure-persistence/entities/user.entity.js +5 -9
- package/src/infrastructure-persistence/entities/user.entity.js.map +1 -1
- package/src/infrastructure-persistence/entities/verification.entity.d.ts +9 -0
- package/src/infrastructure-persistence/entities/verification.entity.js +50 -0
- package/src/infrastructure-persistence/entities/verification.entity.js.map +1 -0
- package/src/infrastructure-persistence/index.d.ts +1 -2
- package/src/infrastructure-persistence/index.js +1 -2
- package/src/infrastructure-persistence/index.js.map +1 -1
- package/src/infrastructure-persistence/migrations/1720200000000-create-auth-schema.js +189 -93
- package/src/infrastructure-persistence/migrations/1720200000000-create-auth-schema.js.map +1 -1
- package/src/infrastructure-persistence/persistence.module-definition.d.ts +1 -1
- package/src/infrastructure-persistence/persistence.module-definition.js +2 -2
- package/src/infrastructure-persistence/persistence.module-definition.js.map +1 -1
- package/src/infrastructure-persistence/persistence.module.js +34 -26
- package/src/infrastructure-persistence/persistence.module.js.map +1 -1
- package/src/infrastructure-persistence/repositories/typeorm-auth-account.repository.d.ts +14 -0
- package/src/infrastructure-persistence/repositories/typeorm-auth-account.repository.js +64 -0
- package/src/infrastructure-persistence/repositories/typeorm-auth-account.repository.js.map +1 -0
- package/src/infrastructure-persistence/repositories/typeorm-auth-user.repository.d.ts +6 -7
- package/src/infrastructure-persistence/repositories/typeorm-auth-user.repository.js +27 -17
- package/src/infrastructure-persistence/repositories/typeorm-auth-user.repository.js.map +1 -1
- package/src/presentation/controllers/auth.controller.d.ts +12 -7
- package/src/presentation/controllers/auth.controller.js +46 -26
- package/src/presentation/controllers/auth.controller.js.map +1 -1
- package/src/presentation/presentation.module.js +32 -3
- package/src/presentation/presentation.module.js.map +1 -1
- package/src/application/services/jwt-auth.service.d.ts +0 -11
- package/src/application/services/jwt-auth.service.js +0 -27
- package/src/application/services/jwt-auth.service.js.map +0 -1
- package/src/application/strategies/jwt-strategy.d.ts +0 -17
- package/src/application/strategies/jwt-strategy.js +0 -27
- package/src/application/strategies/jwt-strategy.js.map +0 -1
- package/src/infrastructure-engine/better-auth/better-auth-spike.harness.d.ts +0 -17
- package/src/infrastructure-engine/better-auth/better-auth-spike.harness.js +0 -32
- package/src/infrastructure-engine/better-auth/better-auth-spike.harness.js.map +0 -1
- package/src/infrastructure-engine/legacy-jwt-auth-engine.adapter.d.ts +0 -22
- package/src/infrastructure-engine/legacy-jwt-auth-engine.adapter.js.map +0 -1
- package/src/infrastructure-persistence/entities/invalidated-token.entity.js.map +0 -1
- package/src/infrastructure-persistence/repositories/auth-user.repository.js.map +0 -1
- /package/src/{infrastructure-persistence/repositories → application/ports}/auth-user.repository.js +0 -0
- /package/src/{infrastructure-persistence/entities → infrastructure-engine/better-auth/plugins/jwt}/invalidated-token.entity.d.ts +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TypeormAuthAccountRepository = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
7
|
+
const typeorm_2 = require("typeorm");
|
|
8
|
+
const account_entity_1 = require("../entities/account.entity");
|
|
9
|
+
const CREDENTIAL_PROVIDER_ID = 'credential';
|
|
10
|
+
let TypeormAuthAccountRepository = class TypeormAuthAccountRepository {
|
|
11
|
+
constructor(accountRepository) {
|
|
12
|
+
this.accountRepository = accountRepository;
|
|
13
|
+
}
|
|
14
|
+
async findCredentialAccountByUserId(userId) {
|
|
15
|
+
const account = await this.accountRepository.findOne({
|
|
16
|
+
where: {
|
|
17
|
+
accountId: userId,
|
|
18
|
+
providerId: CREDENTIAL_PROVIDER_ID,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
return account ? toCredentialAccount(account) : null;
|
|
22
|
+
}
|
|
23
|
+
async upsertCredentialAccount(input) {
|
|
24
|
+
const existingAccount = await this.accountRepository.findOne({
|
|
25
|
+
where: {
|
|
26
|
+
accountId: input.userId,
|
|
27
|
+
providerId: CREDENTIAL_PROVIDER_ID,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const account = existingAccount
|
|
31
|
+
? this.accountRepository.merge(existingAccount, {
|
|
32
|
+
password: input.passwordHash,
|
|
33
|
+
updatedAt: input.updatedAt ?? new Date(),
|
|
34
|
+
})
|
|
35
|
+
: this.accountRepository.create({
|
|
36
|
+
id: `${input.userId}-${CREDENTIAL_PROVIDER_ID}`,
|
|
37
|
+
accountId: input.userId,
|
|
38
|
+
providerId: CREDENTIAL_PROVIDER_ID,
|
|
39
|
+
userId: input.userId,
|
|
40
|
+
password: input.passwordHash,
|
|
41
|
+
createdAt: input.createdAt ?? new Date(),
|
|
42
|
+
updatedAt: input.updatedAt ?? new Date(),
|
|
43
|
+
});
|
|
44
|
+
return toCredentialAccount(await this.accountRepository.save(account));
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
exports.TypeormAuthAccountRepository = TypeormAuthAccountRepository;
|
|
48
|
+
exports.TypeormAuthAccountRepository = TypeormAuthAccountRepository = tslib_1.__decorate([
|
|
49
|
+
(0, common_1.Injectable)(),
|
|
50
|
+
tslib_1.__param(0, (0, typeorm_1.InjectRepository)(account_entity_1.AccountEntity)),
|
|
51
|
+
tslib_1.__metadata("design:paramtypes", [typeorm_2.Repository])
|
|
52
|
+
], TypeormAuthAccountRepository);
|
|
53
|
+
function toCredentialAccount(account) {
|
|
54
|
+
return {
|
|
55
|
+
id: account.id,
|
|
56
|
+
userId: account.userId,
|
|
57
|
+
accountId: account.accountId,
|
|
58
|
+
providerId: CREDENTIAL_PROVIDER_ID,
|
|
59
|
+
password: account.password,
|
|
60
|
+
createdAt: account.createdAt,
|
|
61
|
+
updatedAt: account.updatedAt,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=typeorm-auth-account.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeorm-auth-account.repository.js","sourceRoot":"","sources":["../../../../../../../libs/auth/nest/src/infrastructure-persistence/repositories/typeorm-auth-account.repository.ts"],"names":[],"mappings":";;;;AAAA,2CAA4C;AAC5C,6CAAmD;AACnD,qCAAqC;AAKrC,+DAA2D;AAE3D,MAAM,sBAAsB,GAAG,YAAqB,CAAC;AAG9C,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IACvC,YAEmB,iBAA4C;QAA5C,sBAAiB,GAAjB,iBAAiB,CAA2B;IAC5D,CAAC;IAEJ,KAAK,CAAC,6BAA6B,CACjC,MAAc;QAEd,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC;YACnD,KAAK,EAAE;gBACL,SAAS,EAAE,MAAM;gBACjB,UAAU,EAAE,sBAAsB;aACnC;SACF,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,uBAAuB,CAAC,KAK7B;QACC,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC;YAC3D,KAAK,EAAE;gBACL,SAAS,EAAE,KAAK,CAAC,MAAM;gBACvB,UAAU,EAAE,sBAAsB;aACnC;SACF,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,eAAe;YAC7B,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,eAAe,EAAE;gBAC5C,QAAQ,EAAE,KAAK,CAAC,YAAY;gBAC5B,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,IAAI,IAAI,EAAE;aACzC,CAAC;YACJ,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC;gBAC5B,EAAE,EAAE,GAAG,KAAK,CAAC,MAAM,IAAI,sBAAsB,EAAE;gBAC/C,SAAS,EAAE,KAAK,CAAC,MAAM;gBACvB,UAAU,EAAE,sBAAsB;gBAClC,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,QAAQ,EAAE,KAAK,CAAC,YAAY;gBAC5B,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,IAAI,IAAI,EAAE;gBACxC,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,IAAI,IAAI,EAAE;aACzC,CAAC,CAAC;QAEP,OAAO,mBAAmB,CAAC,MAAM,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IACzE,CAAC;CACF,CAAA;AAjDY,oEAA4B;uCAA5B,4BAA4B;IADxC,IAAA,mBAAU,GAAE;IAGR,mBAAA,IAAA,0BAAgB,EAAC,8BAAa,CAAC,CAAA;6CACI,oBAAU;GAHrC,4BAA4B,CAiDxC;AAED,SAAS,mBAAmB,CAAC,OAAsB;IACjD,OAAO;QACL,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,UAAU,EAAE,sBAAsB;QAClC,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC;AACJ,CAAC"}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
+
import { User } from '@anarchitects/auth-ts/models';
|
|
1
2
|
import { FindManyOptions, FindOneOptions, Repository } from 'typeorm';
|
|
3
|
+
import { AuthUserRepository } from '../../application/ports/auth-user.repository';
|
|
4
|
+
import { RoleEntity } from '../entities/role.entity';
|
|
2
5
|
import { UserEntity } from '../entities/user.entity';
|
|
3
|
-
import { AuthUserRepository } from './auth-user.repository';
|
|
4
|
-
import { User } from '@anarchitects/auth-ts/models';
|
|
5
|
-
import { InvalidatedTokenEntity } from '../entities/invalidated-token.entity';
|
|
6
6
|
export declare class TypeormAuthUserRepository implements AuthUserRepository {
|
|
7
7
|
private readonly userRepository;
|
|
8
|
-
private readonly
|
|
9
|
-
constructor(userRepository: Repository<UserEntity>,
|
|
8
|
+
private readonly roleRepository;
|
|
9
|
+
constructor(userRepository: Repository<UserEntity>, roleRepository: Repository<RoleEntity>);
|
|
10
10
|
find(conditions?: FindManyOptions<User>): Promise<User[]>;
|
|
11
11
|
findOne(conditions: FindOneOptions<User>): Promise<UserEntity>;
|
|
12
12
|
create(user: Partial<User>): Promise<User>;
|
|
13
|
+
ensureRole(userId: string, roleName: string): Promise<void>;
|
|
13
14
|
update(user: Partial<User>): Promise<User>;
|
|
14
15
|
delete(userId: string): Promise<UserEntity>;
|
|
15
|
-
invalidateTokens(tokens: string[], userId: string | null): Promise<void>;
|
|
16
|
-
isTokenInvalidated(tokenId: string): Promise<boolean>;
|
|
17
16
|
}
|
|
@@ -5,12 +5,12 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const common_1 = require("@nestjs/common");
|
|
6
6
|
const typeorm_1 = require("@nestjs/typeorm");
|
|
7
7
|
const typeorm_2 = require("typeorm");
|
|
8
|
+
const role_entity_1 = require("../entities/role.entity");
|
|
8
9
|
const user_entity_1 = require("../entities/user.entity");
|
|
9
|
-
const invalidated_token_entity_1 = require("../entities/invalidated-token.entity");
|
|
10
10
|
let TypeormAuthUserRepository = class TypeormAuthUserRepository {
|
|
11
|
-
constructor(userRepository,
|
|
11
|
+
constructor(userRepository, roleRepository) {
|
|
12
12
|
this.userRepository = userRepository;
|
|
13
|
-
this.
|
|
13
|
+
this.roleRepository = roleRepository;
|
|
14
14
|
}
|
|
15
15
|
async find(conditions = {}) {
|
|
16
16
|
return this.userRepository.find(conditions);
|
|
@@ -26,6 +26,29 @@ let TypeormAuthUserRepository = class TypeormAuthUserRepository {
|
|
|
26
26
|
const newUser = this.userRepository.create(user);
|
|
27
27
|
return this.userRepository.save(newUser);
|
|
28
28
|
}
|
|
29
|
+
async ensureRole(userId, roleName) {
|
|
30
|
+
let role = await this.roleRepository.findOne({ where: { name: roleName } });
|
|
31
|
+
if (!role) {
|
|
32
|
+
role = await this.roleRepository.save(this.roleRepository.create({
|
|
33
|
+
name: roleName,
|
|
34
|
+
description: null,
|
|
35
|
+
permissions: null,
|
|
36
|
+
users: null,
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
const user = await this.userRepository.findOne({
|
|
40
|
+
where: { id: userId },
|
|
41
|
+
relations: ['roles'],
|
|
42
|
+
});
|
|
43
|
+
if (!user) {
|
|
44
|
+
throw new common_1.NotFoundException(`User with id #${userId} not found`);
|
|
45
|
+
}
|
|
46
|
+
if (user.roles?.some((existingRole) => existingRole.name === roleName)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
user.roles = [...(user.roles ?? []), role];
|
|
50
|
+
await this.userRepository.save(user);
|
|
51
|
+
}
|
|
29
52
|
async update(user) {
|
|
30
53
|
const updatedUser = await this.userRepository.preload(user);
|
|
31
54
|
if (!updatedUser) {
|
|
@@ -37,25 +60,12 @@ let TypeormAuthUserRepository = class TypeormAuthUserRepository {
|
|
|
37
60
|
const user = await this.findOne({ where: { id: userId } });
|
|
38
61
|
return this.userRepository.remove(user);
|
|
39
62
|
}
|
|
40
|
-
async invalidateTokens(tokens, userId) {
|
|
41
|
-
const invalidatedTokens = tokens.map((token) => this.invalidatedTokenRepository.create({
|
|
42
|
-
tokenId: token,
|
|
43
|
-
userId,
|
|
44
|
-
}));
|
|
45
|
-
await this.invalidatedTokenRepository.save(invalidatedTokens);
|
|
46
|
-
}
|
|
47
|
-
async isTokenInvalidated(tokenId) {
|
|
48
|
-
const token = await this.invalidatedTokenRepository.findOne({
|
|
49
|
-
where: { tokenId },
|
|
50
|
-
});
|
|
51
|
-
return !!token;
|
|
52
|
-
}
|
|
53
63
|
};
|
|
54
64
|
exports.TypeormAuthUserRepository = TypeormAuthUserRepository;
|
|
55
65
|
exports.TypeormAuthUserRepository = TypeormAuthUserRepository = tslib_1.__decorate([
|
|
56
66
|
(0, common_1.Injectable)(),
|
|
57
67
|
tslib_1.__param(0, (0, typeorm_1.InjectRepository)(user_entity_1.UserEntity)),
|
|
58
|
-
tslib_1.__param(1, (0, typeorm_1.InjectRepository)(
|
|
68
|
+
tslib_1.__param(1, (0, typeorm_1.InjectRepository)(role_entity_1.RoleEntity)),
|
|
59
69
|
tslib_1.__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
60
70
|
typeorm_2.Repository])
|
|
61
71
|
], TypeormAuthUserRepository);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeorm-auth-user.repository.js","sourceRoot":"","sources":["../../../../../../../libs/auth/nest/src/infrastructure-persistence/repositories/typeorm-auth-user.repository.ts"],"names":[],"mappings":";;;;AAAA,2CAA+D;AAC/D,6CAAmD;
|
|
1
|
+
{"version":3,"file":"typeorm-auth-user.repository.js","sourceRoot":"","sources":["../../../../../../../libs/auth/nest/src/infrastructure-persistence/repositories/typeorm-auth-user.repository.ts"],"names":[],"mappings":";;;;AAAA,2CAA+D;AAC/D,6CAAmD;AAEnD,qCAAsE;AAEtE,yDAAqD;AACrD,yDAAqD;AAG9C,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IACpC,YAEmB,cAAsC,EAEtC,cAAsC;QAFtC,mBAAc,GAAd,cAAc,CAAwB;QAEtC,mBAAc,GAAd,cAAc,CAAwB;IACtD,CAAC;IACJ,KAAK,CAAC,IAAI,CAAC,aAAoC,EAAE;QAC/C,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC9C,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,UAAgC;QAC5C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAC3D,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,0BAAiB,CACzB,yBAAyB,IAAI,CAAC,SAAS,CAAC,UAAU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E,IAAI,CAAC,CAAC;QAC3C,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,IAAmB;QAC9B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC5D,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,0BAAiB,CAAC,iBAAiB,IAAI,CAAC,EAAE,YAAY,CAAC,CAAC;QACpE,CAAC;QACD,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/C,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,MAAc;QACzB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;QAC3D,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF,CAAA;AA9DY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,mBAAU,GAAE;IAGR,mBAAA,IAAA,0BAAgB,EAAC,wBAAU,CAAC,CAAA;IAE5B,mBAAA,IAAA,0BAAgB,EAAC,wBAAU,CAAC,CAAA;6CADI,oBAAU;QAEV,oBAAU;GALlC,yBAAyB,CA8DrC"}
|
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
import { ActivateUserRequestDTO, ChangePasswordRequestDTO, ForgotPasswordRequestDTO, LoginRequestDTO,
|
|
1
|
+
import { ActivateUserRequestDTO, ChangePasswordRequestDTO, ForgotPasswordRequestDTO, LoginRequestDTO, LoggedInUserInfoResponseDTO, LogoutRequestDTO, RegisterRequestDTO, RegisterResponseDTO, ResetPasswordRequestDTO, SuccessResponseDTO, UpdateEmailRequestDTO, VerifyEmailRequestDTO } from '@anarchitects/auth-ts/dtos';
|
|
2
2
|
import { AuthService } from '../../application/services/auth.service';
|
|
3
3
|
export declare class AuthController {
|
|
4
4
|
private readonly authService;
|
|
5
5
|
constructor(authService: AuthService);
|
|
6
6
|
registerUser(dto: RegisterRequestDTO): Promise<RegisterResponseDTO>;
|
|
7
7
|
activateUser(dto: ActivateUserRequestDTO): Promise<SuccessResponseDTO>;
|
|
8
|
-
login(dto: LoginRequestDTO
|
|
9
|
-
|
|
8
|
+
login(dto: LoginRequestDTO, req: {
|
|
9
|
+
headers: Record<string, string | string[] | undefined>;
|
|
10
|
+
}, reply: {
|
|
11
|
+
header(name: string, value: string | string[]): unknown;
|
|
12
|
+
}): Promise<LoggedInUserInfoResponseDTO>;
|
|
13
|
+
logout(dto: LogoutRequestDTO, req: {
|
|
14
|
+
headers: Record<string, string | string[] | undefined>;
|
|
15
|
+
}, reply: {
|
|
16
|
+
header(name: string, value: string | string[]): unknown;
|
|
17
|
+
}): Promise<SuccessResponseDTO>;
|
|
10
18
|
changePassword(userId: string, dto: ChangePasswordRequestDTO): Promise<SuccessResponseDTO>;
|
|
11
19
|
forgotPassword(dto: ForgotPasswordRequestDTO): Promise<SuccessResponseDTO>;
|
|
12
20
|
resetPassword(dto: ResetPasswordRequestDTO): Promise<SuccessResponseDTO>;
|
|
13
21
|
verifyEmail(dto: VerifyEmailRequestDTO): Promise<SuccessResponseDTO>;
|
|
14
22
|
updateEmail(userId: string, dto: UpdateEmailRequestDTO): Promise<SuccessResponseDTO>;
|
|
15
|
-
refreshTokens(userId: string, dto: RefreshTokenRequestDTO): Promise<LoginResponseDTO>;
|
|
16
23
|
getLoggedInUserInfo(req: {
|
|
17
|
-
|
|
18
|
-
sub: string;
|
|
19
|
-
};
|
|
24
|
+
headers: Record<string, string | string[] | undefined>;
|
|
20
25
|
}): Promise<LoggedInUserInfoResponseDTO>;
|
|
21
26
|
}
|
|
@@ -16,11 +16,15 @@ let AuthController = class AuthController {
|
|
|
16
16
|
async activateUser(dto) {
|
|
17
17
|
return this.authService.activateUser(dto);
|
|
18
18
|
}
|
|
19
|
-
async login(dto) {
|
|
20
|
-
|
|
19
|
+
async login(dto, req, reply) {
|
|
20
|
+
const result = await this.authService.login(dto, toHeaders(req.headers));
|
|
21
|
+
applyResponseHeaders(reply, result.headers);
|
|
22
|
+
return result.body;
|
|
21
23
|
}
|
|
22
|
-
async logout(dto) {
|
|
23
|
-
|
|
24
|
+
async logout(dto, req, reply) {
|
|
25
|
+
const result = await this.authService.logout(dto, toHeaders(req.headers));
|
|
26
|
+
applyResponseHeaders(reply, result.headers);
|
|
27
|
+
return result.body;
|
|
24
28
|
}
|
|
25
29
|
async changePassword(userId, dto) {
|
|
26
30
|
return this.authService.changePassword(userId, dto);
|
|
@@ -37,12 +41,9 @@ let AuthController = class AuthController {
|
|
|
37
41
|
async updateEmail(userId, dto) {
|
|
38
42
|
return this.authService.updateEmail(userId, dto);
|
|
39
43
|
}
|
|
40
|
-
async refreshTokens(userId, dto) {
|
|
41
|
-
return this.authService.refreshTokens(userId, dto);
|
|
42
|
-
}
|
|
43
44
|
async getLoggedInUserInfo(req) {
|
|
44
|
-
const
|
|
45
|
-
return
|
|
45
|
+
const result = await this.authService.getLoggedInUserInfo(toHeaders(req.headers));
|
|
46
|
+
return result.body;
|
|
46
47
|
}
|
|
47
48
|
};
|
|
48
49
|
exports.AuthController = AuthController;
|
|
@@ -74,11 +75,13 @@ tslib_1.__decorate([
|
|
|
74
75
|
(0, common_1.Post)('/login'),
|
|
75
76
|
(0, platform_fastify_1.RouteSchema)({
|
|
76
77
|
body: dtos_1.LoginRequestSchema,
|
|
77
|
-
response: { 200: dtos_1.
|
|
78
|
+
response: { 200: dtos_1.LoggedInUserInfoResponseSchema },
|
|
78
79
|
}),
|
|
79
80
|
tslib_1.__param(0, (0, common_1.Body)()),
|
|
81
|
+
tslib_1.__param(1, (0, common_1.Req)()),
|
|
82
|
+
tslib_1.__param(2, (0, common_1.Res)({ passthrough: true })),
|
|
80
83
|
tslib_1.__metadata("design:type", Function),
|
|
81
|
-
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
84
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object, Object]),
|
|
82
85
|
tslib_1.__metadata("design:returntype", Promise)
|
|
83
86
|
], AuthController.prototype, "login", null);
|
|
84
87
|
tslib_1.__decorate([
|
|
@@ -89,8 +92,10 @@ tslib_1.__decorate([
|
|
|
89
92
|
response: { 200: dtos_1.SuccessResponseSchema },
|
|
90
93
|
}),
|
|
91
94
|
tslib_1.__param(0, (0, common_1.Body)()),
|
|
95
|
+
tslib_1.__param(1, (0, common_1.Req)()),
|
|
96
|
+
tslib_1.__param(2, (0, common_1.Res)({ passthrough: true })),
|
|
92
97
|
tslib_1.__metadata("design:type", Function),
|
|
93
|
-
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
98
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object, Object]),
|
|
94
99
|
tslib_1.__metadata("design:returntype", Promise)
|
|
95
100
|
], AuthController.prototype, "logout", null);
|
|
96
101
|
tslib_1.__decorate([
|
|
@@ -155,20 +160,6 @@ tslib_1.__decorate([
|
|
|
155
160
|
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
156
161
|
tslib_1.__metadata("design:returntype", Promise)
|
|
157
162
|
], AuthController.prototype, "updateEmail", null);
|
|
158
|
-
tslib_1.__decorate([
|
|
159
|
-
(0, common_1.HttpCode)(200),
|
|
160
|
-
(0, common_1.Post)('/refresh-tokens/:userId'),
|
|
161
|
-
(0, platform_fastify_1.RouteSchema)({
|
|
162
|
-
body: dtos_1.RefreshTokenRequestSchema,
|
|
163
|
-
params: dtos_1.UserIdParamsSchema,
|
|
164
|
-
response: { 200: dtos_1.LoginResponseSchema },
|
|
165
|
-
}),
|
|
166
|
-
tslib_1.__param(0, (0, common_1.Param)('userId')),
|
|
167
|
-
tslib_1.__param(1, (0, common_1.Body)()),
|
|
168
|
-
tslib_1.__metadata("design:type", Function),
|
|
169
|
-
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
170
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
171
|
-
], AuthController.prototype, "refreshTokens", null);
|
|
172
163
|
tslib_1.__decorate([
|
|
173
164
|
(0, common_1.Get)('/me'),
|
|
174
165
|
(0, platform_fastify_1.RouteSchema)({
|
|
@@ -183,4 +174,33 @@ exports.AuthController = AuthController = tslib_1.__decorate([
|
|
|
183
174
|
(0, common_1.Controller)('auth'),
|
|
184
175
|
tslib_1.__metadata("design:paramtypes", [auth_service_1.AuthService])
|
|
185
176
|
], AuthController);
|
|
177
|
+
const toHeaders = (input) => {
|
|
178
|
+
const headers = new Headers();
|
|
179
|
+
Object.entries(input).forEach(([key, value]) => {
|
|
180
|
+
if (value === undefined) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (Array.isArray(value)) {
|
|
184
|
+
value.forEach((entry) => headers.append(key, entry));
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
headers.set(key, value);
|
|
188
|
+
});
|
|
189
|
+
return headers;
|
|
190
|
+
};
|
|
191
|
+
const applyResponseHeaders = (reply, headers) => {
|
|
192
|
+
if (!headers) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const setCookie = 'getSetCookie' in headers && typeof headers.getSetCookie === 'function'
|
|
196
|
+
? headers.getSetCookie()
|
|
197
|
+
: headers.get('set-cookie');
|
|
198
|
+
if (Array.isArray(setCookie) && setCookie.length > 0) {
|
|
199
|
+
reply.header('set-cookie', setCookie);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (typeof setCookie === 'string' && setCookie.length > 0) {
|
|
203
|
+
reply.header('set-cookie', setCookie);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
186
206
|
//# sourceMappingURL=auth.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.controller.js","sourceRoot":"","sources":["../../../../../../../libs/auth/nest/src/presentation/controllers/auth.controller.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"auth.controller.js","sourceRoot":"","sources":["../../../../../../../libs/auth/nest/src/presentation/controllers/auth.controller.ts"],"names":[],"mappings":";;;;AAAA,qDA0BoC;AACpC,2CAUwB;AACxB,+DAAuD;AACvD,0EAAsE;AAG/D,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,YAA6B,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAQnD,AAAN,KAAK,CAAC,YAAY,CACR,GAAuB;QAE/B,OAAO,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC;IAOK,AAAN,KAAK,CAAC,YAAY,CACR,GAA2B;QAEnC,OAAO,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC;IAQK,AAAN,KAAK,CAAC,KAAK,CACD,GAAoB,EACrB,GAA+D,EAEtE,KAAkE;QAElE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;QACzE,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QAC5C,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAQK,AAAN,KAAK,CAAC,MAAM,CACF,GAAqB,EACtB,GAA+D,EAEtE,KAAkE;QAElE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;QAC1E,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QAC5C,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAQK,AAAN,KAAK,CAAC,cAAc,CACD,MAAc,EACvB,GAA6B;QAErC,OAAO,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC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,EAAE;QAC7C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO;QACT,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;YACrD,OAAO;QACT,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAC3B,KAAkE,EAClE,OAAiB,EACX,EAAE;IACR,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;IACT,CAAC;IAED,MAAM,SAAS,GACb,cAAc,IAAI,OAAO,IAAI,OAAO,OAAO,CAAC,YAAY,KAAK,UAAU;QACrE,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE;QACxB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAEhC,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrD,KAAK,CAAC,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;QACtC,OAAO;IACT,CAAC;IAED,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1D,KAAK,CAAC,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;IACxC,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -9,12 +9,17 @@ const auth_controller_1 = require("./controllers/auth.controller");
|
|
|
9
9
|
const application_1 = require("../application");
|
|
10
10
|
const policies_guard_1 = require("./guards/policies.guard");
|
|
11
11
|
const resource_authorization_guard_1 = require("./guards/resource-authorization.guard");
|
|
12
|
+
const jwt_auth_plugin_controller_1 = require("../infrastructure-engine/better-auth/plugins/jwt/jwt-auth-plugin.controller");
|
|
12
13
|
const config_2 = require("../config");
|
|
13
14
|
let AuthPresentationModule = AuthPresentationModule_1 = class AuthPresentationModule {
|
|
14
15
|
static forRoot(options = {}) {
|
|
16
|
+
const jwtPluginController = options.application?.plugins?.jwt?.enabled
|
|
17
|
+
? [jwt_auth_plugin_controller_1.JwtAuthPluginController]
|
|
18
|
+
: [];
|
|
15
19
|
return {
|
|
16
20
|
module: AuthPresentationModule_1,
|
|
17
21
|
imports: [application_1.AuthApplicationModule.forRoot(options.application)],
|
|
22
|
+
controllers: jwtPluginController,
|
|
18
23
|
exports: [application_1.AuthApplicationModule],
|
|
19
24
|
};
|
|
20
25
|
}
|
|
@@ -26,13 +31,37 @@ let AuthPresentationModule = AuthPresentationModule_1 = class AuthPresentationMo
|
|
|
26
31
|
application: {
|
|
27
32
|
...configOptions.application,
|
|
28
33
|
...overrides.application,
|
|
34
|
+
betterAuth: {
|
|
35
|
+
...configOptions.application?.betterAuth,
|
|
36
|
+
...overrides.application?.betterAuth,
|
|
37
|
+
callbackUrls: {
|
|
38
|
+
...configOptions.application?.betterAuth?.callbackUrls,
|
|
39
|
+
...overrides.application?.betterAuth?.callbackUrls,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
29
42
|
encryption: {
|
|
30
43
|
...configOptions.application?.encryption,
|
|
31
44
|
...overrides.application?.encryption,
|
|
32
45
|
},
|
|
33
|
-
|
|
34
|
-
...configOptions.application?.
|
|
35
|
-
...overrides.application?.
|
|
46
|
+
plugins: {
|
|
47
|
+
...configOptions.application?.plugins,
|
|
48
|
+
...overrides.application?.plugins,
|
|
49
|
+
jwt: {
|
|
50
|
+
...configOptions.application?.plugins?.jwt,
|
|
51
|
+
...overrides.application?.plugins?.jwt,
|
|
52
|
+
},
|
|
53
|
+
passkeys: {
|
|
54
|
+
...configOptions.application?.plugins?.passkeys,
|
|
55
|
+
...overrides.application?.plugins?.passkeys,
|
|
56
|
+
},
|
|
57
|
+
social: {
|
|
58
|
+
...configOptions.application?.plugins?.social,
|
|
59
|
+
...overrides.application?.plugins?.social,
|
|
60
|
+
},
|
|
61
|
+
oidc: {
|
|
62
|
+
...configOptions.application?.plugins?.oidc,
|
|
63
|
+
...overrides.application?.plugins?.oidc,
|
|
64
|
+
},
|
|
36
65
|
},
|
|
37
66
|
},
|
|
38
67
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation.module.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/presentation/presentation.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAAuD;AACvD,2CAA8C;AAC9C,mEAA+D;AAC/D,gDAAuD;AACvD,4DAAwD;AACxD,wFAAmF;AACnF,sCAGmB;AAQZ,IAAM,sBAAsB,8BAA5B,MAAM,sBAAsB;IACjC,MAAM,CAAC,OAAO,CAAC,UAAyC,EAAE;QACxD,OAAO;YACL,MAAM,EAAE,wBAAsB;YAC9B,OAAO,EAAE,CAAC,mCAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAC7D,OAAO,EAAE,CAAC,mCAAqB,CAAC;SACjC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,iBAAiB,CACtB,YAA2C,EAAE;QAE7C,MAAM,aAAa,GACjB,IAAA,iDAAwC,EAAC,IAAA,mBAAU,GAAE,CAAC,CAAC;QACzD,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC;YACpC,GAAG,aAAa;YAChB,GAAG,SAAS;YACZ,WAAW,EAAE;gBACX,GAAG,aAAa,CAAC,WAAW;gBAC5B,GAAG,SAAS,CAAC,WAAW;gBACxB,UAAU,EAAE;oBACV,GAAG,aAAa,CAAC,WAAW,EAAE,UAAU;oBACxC,GAAG,SAAS,CAAC,WAAW,EAAE,UAAU;iBACrC;gBACD,WAAW,EAAE;
|
|
1
|
+
{"version":3,"file":"presentation.module.js","s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{ AuthUserRepository } from '../../infrastructure-persistence/repositories/auth-user.repository';
|
|
3
|
-
import { AuthOrchestrationService } from './auth-orchestration.service';
|
|
4
|
-
import { HashService } from './hash.service';
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated Use `AuthService` for controller-facing auth operations.
|
|
7
|
-
* JWT engine access is now an internal wiring concern behind `AuthEnginePort`.
|
|
8
|
-
*/
|
|
9
|
-
export declare class JwtAuthService extends AuthOrchestrationService {
|
|
10
|
-
constructor(hashService: HashService, authUserRepository: AuthUserRepository, jwtService: JwtService);
|
|
11
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JwtAuthService = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
const jwt_1 = require("@nestjs/jwt");
|
|
7
|
-
const legacy_jwt_auth_engine_adapter_1 = require("../../infrastructure-engine/legacy-jwt-auth-engine.adapter");
|
|
8
|
-
const auth_user_repository_1 = require("../../infrastructure-persistence/repositories/auth-user.repository");
|
|
9
|
-
const auth_orchestration_service_1 = require("./auth-orchestration.service");
|
|
10
|
-
const hash_service_1 = require("./hash.service");
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated Use `AuthService` for controller-facing auth operations.
|
|
13
|
-
* JWT engine access is now an internal wiring concern behind `AuthEnginePort`.
|
|
14
|
-
*/
|
|
15
|
-
let JwtAuthService = class JwtAuthService extends auth_orchestration_service_1.AuthOrchestrationService {
|
|
16
|
-
constructor(hashService, authUserRepository, jwtService) {
|
|
17
|
-
super(hashService, authUserRepository, new legacy_jwt_auth_engine_adapter_1.LegacyJwtAuthEngineAdapter(hashService, authUserRepository, jwtService));
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
exports.JwtAuthService = JwtAuthService;
|
|
21
|
-
exports.JwtAuthService = JwtAuthService = tslib_1.__decorate([
|
|
22
|
-
(0, common_1.Injectable)(),
|
|
23
|
-
tslib_1.__metadata("design:paramtypes", [hash_service_1.HashService,
|
|
24
|
-
auth_user_repository_1.AuthUserRepository,
|
|
25
|
-
jwt_1.JwtService])
|
|
26
|
-
], JwtAuthService);
|
|
27
|
-
//# sourceMappingURL=jwt-auth.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwt-auth.service.js","sourceRoot":"","sources":["../../../../../../../libs/auth/nest/src/application/services/jwt-auth.service.ts"],"names":[],"mappings":";;;;AAAA,2CAA4C;AAC5C,qCAAyC;AACzC,+GAAwG;AACxG,6GAAwG;AACxG,6EAAwE;AACxE,iDAA6C;AAE7C;;;GAGG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,qDAAwB;IAC1D,YACE,WAAwB,EACxB,kBAAsC,EACtC,UAAsB;QAEtB,KAAK,CACH,WAAW,EACX,kBAAkB,EAClB,IAAI,2DAA0B,CAC5B,WAAW,EACX,kBAAkB,EAClB,UAAU,CACX,CACF,CAAC;IACJ,CAAC;CACF,CAAA;AAhBY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;6CAGI,0BAAW;QACJ,yCAAkB;QAC1B,gBAAU;GAJb,cAAc,CAgB1B"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Role } from '@anarchitects/auth-ts/models';
|
|
2
|
-
import { Strategy } from 'passport-jwt';
|
|
3
|
-
import { AuthConfig } from '../../config';
|
|
4
|
-
declare const JwtStrategy_base: new (...args: [opt: import("passport-jwt").StrategyOptionsWithRequest] | [opt: import("passport-jwt").StrategyOptionsWithoutRequest]) => Strategy & {
|
|
5
|
-
validate(...args: any[]): unknown;
|
|
6
|
-
};
|
|
7
|
-
export declare class JwtStrategy extends JwtStrategy_base {
|
|
8
|
-
constructor(authConfig: AuthConfig);
|
|
9
|
-
validate(payload: {
|
|
10
|
-
sub: string;
|
|
11
|
-
roles: Role[];
|
|
12
|
-
}): Promise<{
|
|
13
|
-
userId: string;
|
|
14
|
-
roles: Role[];
|
|
15
|
-
}>;
|
|
16
|
-
}
|
|
17
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JwtStrategy = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
const passport_1 = require("@nestjs/passport");
|
|
7
|
-
const passport_jwt_1 = require("passport-jwt");
|
|
8
|
-
const config_1 = require("../../config");
|
|
9
|
-
let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(passport_jwt_1.Strategy) {
|
|
10
|
-
constructor(authConfig) {
|
|
11
|
-
super({
|
|
12
|
-
jwtFromRequest: passport_jwt_1.ExtractJwt.fromAuthHeaderAsBearerToken(),
|
|
13
|
-
ignoreExpiration: false,
|
|
14
|
-
secretOrKey: authConfig.jwtSecret,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
async validate(payload) {
|
|
18
|
-
return { userId: payload.sub, roles: payload.roles };
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
exports.JwtStrategy = JwtStrategy;
|
|
22
|
-
exports.JwtStrategy = JwtStrategy = tslib_1.__decorate([
|
|
23
|
-
(0, common_1.Injectable)(),
|
|
24
|
-
tslib_1.__param(0, (0, config_1.InjectAuthConfig)()),
|
|
25
|
-
tslib_1.__metadata("design:paramtypes", [Object])
|
|
26
|
-
], JwtStrategy);
|
|
27
|
-
//# sourceMappingURL=jwt-strategy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwt-strategy.js","sourceRoot":"","sources":["../../../../../../../libs/auth/nest/src/application/strategies/jwt-strategy.ts"],"names":[],"mappings":";;;;AACA,2CAA4C;AAC5C,+CAAoD;AACpD,+CAAoD;AACpD,yCAA4D;AAGrD,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,IAAA,2BAAgB,EAAC,uBAAQ,CAAC;IACzD,YAAgC,UAAsB;QACpD,KAAK,CAAC;YACJ,cAAc,EAAE,yBAAU,CAAC,2BAA2B,EAAE;YACxD,gBAAgB,EAAE,KAAK;YACvB,WAAW,EAAE,UAAU,CAAC,SAAS;SAClC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAuC;QACpD,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;IACvD,CAAC;CACF,CAAA;AAZY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;IAEE,mBAAA,IAAA,yBAAgB,GAAE,CAAA;;GADpB,WAAW,CAYvB"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ResolvedAuthApplicationModuleOptions } from '../../config';
|
|
2
|
-
import { AuthEngineCapabilityReport, AuthEnginePort } from '../../application/services/auth-engine.port';
|
|
3
|
-
export type BetterAuthSpikeFlowResult = {
|
|
4
|
-
flow: string;
|
|
5
|
-
status: 'ready' | 'blocked';
|
|
6
|
-
notes: string;
|
|
7
|
-
};
|
|
8
|
-
export declare class BetterAuthSpikeHarness {
|
|
9
|
-
private readonly authEnginePort;
|
|
10
|
-
private readonly options;
|
|
11
|
-
constructor(authEnginePort: AuthEnginePort, options: ResolvedAuthApplicationModuleOptions);
|
|
12
|
-
collectProofMatrix(): Promise<{
|
|
13
|
-
engine: AuthEngineCapabilityReport['engine'];
|
|
14
|
-
proofHarnessEnabled: boolean;
|
|
15
|
-
flows: BetterAuthSpikeFlowResult[];
|
|
16
|
-
}>;
|
|
17
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BetterAuthSpikeHarness = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
const application_module_definition_1 = require("../../application/application.module-definition");
|
|
7
|
-
const auth_engine_port_1 = require("../../application/services/auth-engine.port");
|
|
8
|
-
let BetterAuthSpikeHarness = class BetterAuthSpikeHarness {
|
|
9
|
-
constructor(authEnginePort, options) {
|
|
10
|
-
this.authEnginePort = authEnginePort;
|
|
11
|
-
this.options = options;
|
|
12
|
-
}
|
|
13
|
-
async collectProofMatrix() {
|
|
14
|
-
const report = await this.authEnginePort.describeCapabilities();
|
|
15
|
-
return {
|
|
16
|
-
engine: report.engine,
|
|
17
|
-
proofHarnessEnabled: this.options.spike.proofHarnessEnabled,
|
|
18
|
-
flows: report.flows.map((flow) => ({
|
|
19
|
-
flow: flow.flow,
|
|
20
|
-
status: flow.status === 'supported' ? 'ready' : 'blocked',
|
|
21
|
-
notes: flow.notes,
|
|
22
|
-
})),
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
exports.BetterAuthSpikeHarness = BetterAuthSpikeHarness;
|
|
27
|
-
exports.BetterAuthSpikeHarness = BetterAuthSpikeHarness = tslib_1.__decorate([
|
|
28
|
-
(0, common_1.Injectable)(),
|
|
29
|
-
tslib_1.__param(1, (0, common_1.Inject)(application_module_definition_1.AUTH_APPLICATION_MODULE_OPTIONS)),
|
|
30
|
-
tslib_1.__metadata("design:paramtypes", [auth_engine_port_1.AuthEnginePort, Object])
|
|
31
|
-
], BetterAuthSpikeHarness);
|
|
32
|
-
//# sourceMappingURL=better-auth-spike.harness.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"better-auth-spike.harness.js","sourceRoot":"","sources":["../../../../../../../libs/auth/nest/src/infrastructure-engine/better-auth/better-auth-spike.harness.ts"],"names":[],"mappings":";;;;AAAA,2CAAoD;AACpD,mGAAkG;AAElG,kFAGqD;AAS9C,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IACjC,YACmB,cAA8B,EAE9B,OAA6C;QAF7C,mBAAc,GAAd,cAAc,CAAgB;QAE9B,YAAO,GAAP,OAAO,CAAsC;IAC7D,CAAC;IAEJ,KAAK,CAAC,kBAAkB;QAKtB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,oBAAoB,EAAE,CAAC;QAEhE,OAAO;YACL,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,mBAAmB,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,mBAAmB;YAC3D,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACjC,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,MAAM,EAAE,IAAI,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;gBACzD,KAAK,EAAE,IAAI,CAAC,KAAK;aAClB,CAAC,CAAC;SACJ,CAAC;IACJ,CAAC;CACF,CAAA;AAxBY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;IAIR,mBAAA,IAAA,eAAM,EAAC,+DAA+B,CAAC,CAAA;6CADP,iCAAc;GAFtC,sBAAsB,CAwBlC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { JwtService } from '@nestjs/jwt';
|
|
2
|
-
import { LoginRequestDTO, LoginResponseDTO, LogoutRequestDTO, RefreshTokenRequestDTO } from '@anarchitects/auth-ts/dtos';
|
|
3
|
-
import { AuthEngineCapabilityReport, AuthEnginePort, AuthPasskeySignInInput, AuthSignOutOrRefreshInput, AuthSocialSignInInput } from '../application/services/auth-engine.port';
|
|
4
|
-
import { HashService } from '../application/services/hash.service';
|
|
5
|
-
import { AuthUserRepository } from '../infrastructure-persistence/repositories/auth-user.repository';
|
|
6
|
-
export declare class LegacyJwtAuthEngineAdapter implements AuthEnginePort {
|
|
7
|
-
private readonly hashService;
|
|
8
|
-
private readonly authUserRepository;
|
|
9
|
-
private readonly jwtService;
|
|
10
|
-
constructor(hashService: HashService, authUserRepository: AuthUserRepository, jwtService: JwtService);
|
|
11
|
-
login(dto: LoginRequestDTO): Promise<LoginResponseDTO>;
|
|
12
|
-
logout(dto: LogoutRequestDTO): Promise<{
|
|
13
|
-
success: boolean;
|
|
14
|
-
}>;
|
|
15
|
-
refreshTokens(userId: string, dto: RefreshTokenRequestDTO): Promise<LoginResponseDTO>;
|
|
16
|
-
describeCapabilities(): Promise<AuthEngineCapabilityReport>;
|
|
17
|
-
passwordSignIn(dto: LoginRequestDTO): Promise<LoginResponseDTO>;
|
|
18
|
-
passkeySignIn(_input: AuthPasskeySignInInput): Promise<unknown>;
|
|
19
|
-
socialSignIn(_input: AuthSocialSignInInput): Promise<unknown>;
|
|
20
|
-
signOutOrRefresh(input: AuthSignOutOrRefreshInput): Promise<unknown>;
|
|
21
|
-
private generateTokens;
|
|
22
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-jwt-auth-engine.adapter.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/infrastructure-engine/legacy-jwt-auth-engine.adapter.ts"],"names":[],"mappings":";;;;AAAA,2CAAiE;AACjE,qCAAyC;AAezC,uEAAmE;AACnE,0GAAqG;AAG9F,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IACrC,YACmB,WAAwB,EACxB,kBAAsC,EACtC,UAAsB;QAFtB,gBAAW,GAAX,WAAW,CAAa;QACxB,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,eAAU,GAAV,UAAU,CAAY;IACtC,CAAC;IAEJ,KAAK,CAAC,KAAK,CAAC,GAAoB;QAC9B,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC;QACrC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;YACjD,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,QAAQ,EAA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O,GAAG;YACd,GAAG,EAAE,IAAI,CAAC,EAAE;YACZ,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;SAC5C,CAAC;QACF,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAC7D,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAC9D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;IACvC,CAAC;CACF,CAAA;AA5JY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,mBAAU,GAAE;6CAGqB,0BAAW;QACJ,yCAAkB;QAC1B,gBAAU;GAJ9B,0BAA0B,CA4JtC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invalidated-token.entity.js","sourceRoot":"","sources":["../../../../../../../libs/auth/nest/src/infrastructure-persistence/entities/invalidated-token.entity.ts"],"names":[],"mappings":";;;;AAAA,qCAA+D;AAC/D,sCAAwC;AAQjC,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAiBjC,YAAY,UAA2C,EAAE;QACvD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC;CACF,CAAA;AApBY,wDAAsB;AAEjC;IADC,IAAA,uBAAa,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;;uDAC/B;AAGjB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sDAClB;AAGvB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;sCACxC,IAAI;yDAAC;AAOjB;IALC,IAAA,gBAAM,EAAC;QACN,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,GAAG,EAAE,CAAC,mBAAmB;KACnC,CAAC;sCACc,IAAI;6DAAC;iCAfV,sBAAsB;IANlC,IAAA,gBAAM,EAAC;QACN,MAAM,EAAE,oBAAW;QACnB,IAAI,EAAE,oBAAoB;QAC1B,WAAW,EAAE,KAAK;KACnB,CAAC;IACD,IAAA,eAAK,EAAC,mCAAmC,EAAE,CAAC,WAAW,CAAC,CAAC;;GAC7C,sBAAsB,CAoBlC"}
|