@nathapp/nestjs-oauth-prisma 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/README.md +249 -0
- package/dist/abstract-prisma-public-client.repository.d.ts +20 -0
- package/dist/abstract-prisma-public-client.repository.js +54 -0
- package/dist/abstract-prisma-public-client.repository.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/oauth-prisma.module.d.ts +7 -0
- package/dist/oauth-prisma.module.js +75 -0
- package/dist/oauth-prisma.module.js.map +1 -0
- package/dist/oauth-prisma.types.d.ts +189 -0
- package/dist/oauth-prisma.types.js +43 -0
- package/dist/oauth-prisma.types.js.map +1 -0
- package/dist/prisma-consent-logout-target.resolver.d.ts +12 -0
- package/dist/prisma-consent-logout-target.resolver.js +43 -0
- package/dist/prisma-consent-logout-target.resolver.js.map +1 -0
- package/dist/prisma-oauth-access-token.repository.d.ts +41 -0
- package/dist/prisma-oauth-access-token.repository.js +124 -0
- package/dist/prisma-oauth-access-token.repository.js.map +1 -0
- package/dist/prisma-oauth-authorization-code.repository.d.ts +41 -0
- package/dist/prisma-oauth-authorization-code.repository.js +118 -0
- package/dist/prisma-oauth-authorization-code.repository.js.map +1 -0
- package/dist/prisma-oauth-client.repository.d.ts +50 -0
- package/dist/prisma-oauth-client.repository.js +193 -0
- package/dist/prisma-oauth-client.repository.js.map +1 -0
- package/dist/prisma-oauth-consent.repository.d.ts +36 -0
- package/dist/prisma-oauth-consent.repository.js +95 -0
- package/dist/prisma-oauth-consent.repository.js.map +1 -0
- package/dist/prisma-oauth-device-code.repository.d.ts +36 -0
- package/dist/prisma-oauth-device-code.repository.js +124 -0
- package/dist/prisma-oauth-device-code.repository.js.map +1 -0
- package/dist/prisma-oauth-pushed-request.repository.d.ts +16 -0
- package/dist/prisma-oauth-pushed-request.repository.js +104 -0
- package/dist/prisma-oauth-pushed-request.repository.js.map +1 -0
- package/dist/prisma-oauth-refresh-token.repository.d.ts +28 -0
- package/dist/prisma-oauth-refresh-token.repository.js +100 -0
- package/dist/prisma-oauth-refresh-token.repository.js.map +1 -0
- package/dist/prisma-oauth-scope.repository.d.ts +25 -0
- package/dist/prisma-oauth-scope.repository.js +87 -0
- package/dist/prisma-oauth-scope.repository.js.map +1 -0
- package/dist/prisma-oauth-signing-key.repository.d.ts +24 -0
- package/dist/prisma-oauth-signing-key.repository.js +110 -0
- package/dist/prisma-oauth-signing-key.repository.js.map +1 -0
- package/dist/prisma-signing-key.provider.d.ts +22 -0
- package/dist/prisma-signing-key.provider.js +133 -0
- package/dist/prisma-signing-key.provider.js.map +1 -0
- package/package.json +45 -0
- package/prisma/migrations/20260608_oauth_signing_keys_one_active/migration.mysql.sql +8 -0
- package/prisma/migrations/20260608_oauth_signing_keys_one_active/migration.sql +3 -0
- package/prisma/migrations/20260724_oauth_client_advanced_auth_fields/migration.mysql.sql +10 -0
- package/prisma/migrations/20260724_oauth_client_advanced_auth_fields/migration.sql +9 -0
- package/prisma/migrations/20260725_oauth_resource_indicator/migration.mysql.sql +10 -0
- package/prisma/migrations/20260725_oauth_resource_indicator/migration.sql +15 -0
- package/prisma/migrations/20260725_oauth_token_exchange_actor/migration.mysql.sql +2 -0
- package/prisma/migrations/20260725_oauth_token_exchange_actor/migration.sql +2 -0
- package/prisma/migrations/20261003_oauth_access_token_mtls_binding/migration.mysql.sql +2 -0
- package/prisma/migrations/20261003_oauth_access_token_mtls_binding/migration.sql +2 -0
- package/prisma/migrations/20261004_oauth_signing_keys_one_active_per_tenant/migration.mysql.sql +13 -0
- package/prisma/migrations/20261004_oauth_signing_keys_one_active_per_tenant/migration.sql +14 -0
- package/prisma/oauth.prisma +287 -0
- package/prisma/sql/long-text-columns.mysql.sql +29 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asJsonObject = asJsonObject;
|
|
4
|
+
exports.getOAuthPrismaDelegate = getOAuthPrismaDelegate;
|
|
5
|
+
class CheckedOAuthPrismaDelegate {
|
|
6
|
+
constructor(delegate, modelName) {
|
|
7
|
+
this.delegate = delegate;
|
|
8
|
+
this.modelName = modelName;
|
|
9
|
+
}
|
|
10
|
+
invoke(methodName, args) {
|
|
11
|
+
const method = this.delegate[methodName];
|
|
12
|
+
if (typeof method !== 'function') {
|
|
13
|
+
throw new TypeError(`OAuth Prisma model "${this.modelName}" does not implement ${methodName}()`);
|
|
14
|
+
}
|
|
15
|
+
return method.call(this.delegate, args);
|
|
16
|
+
}
|
|
17
|
+
findUnique(args) { return this.invoke('findUnique', args); }
|
|
18
|
+
findFirst(args) { return this.invoke('findFirst', args); }
|
|
19
|
+
findMany(args) { return this.invoke('findMany', args); }
|
|
20
|
+
count(args) { return this.invoke('count', args); }
|
|
21
|
+
create(args) { return this.invoke('create', args); }
|
|
22
|
+
update(args) { return this.invoke('update', args); }
|
|
23
|
+
delete(args) { return this.invoke('delete', args); }
|
|
24
|
+
updateMany(args) { return this.invoke('updateMany', args); }
|
|
25
|
+
deleteMany(args) { return this.invoke('deleteMany', args); }
|
|
26
|
+
createMany(args) { return this.invoke('createMany', args); }
|
|
27
|
+
}
|
|
28
|
+
function isRecord(value) {
|
|
29
|
+
return typeof value === 'object' && value !== null;
|
|
30
|
+
}
|
|
31
|
+
function asJsonObject(value) {
|
|
32
|
+
return isRecord(value) && !Array.isArray(value) ? value : undefined;
|
|
33
|
+
}
|
|
34
|
+
function getOAuthPrismaDelegate(client, modelName) {
|
|
35
|
+
if (!isRecord(client))
|
|
36
|
+
throw new TypeError('OAuth Prisma client must be an object');
|
|
37
|
+
const candidate = client[modelName];
|
|
38
|
+
if (!isRecord(candidate)) {
|
|
39
|
+
throw new TypeError(`OAuth Prisma client is missing model delegate "${modelName}"`);
|
|
40
|
+
}
|
|
41
|
+
return new CheckedOAuthPrismaDelegate(candidate, modelName);
|
|
42
|
+
}
|
|
43
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outTargetResolver, type IOAuthConsentRepository } from '@nathapp/nestjs-oauth';
|
|
2
|
+
export declare class PrismaConsentLogoutTargetResolver implements ILogoutTargetResolver {
|
|
3
|
+
protected readonly consentRepo: IOAuthConsentRepository;
|
|
4
|
+
constructor(consentRepo: IOAuthConsentRepository);
|
|
5
|
+
resolve(input: {
|
|
6
|
+
userId: string;
|
|
7
|
+
sid?: string;
|
|
8
|
+
tenantId?: string | null;
|
|
9
|
+
}): Promise<Array<{
|
|
10
|
+
clientId: string;
|
|
11
|
+
}>>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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.PrismaConsentLogoutTargetResolver = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const nestjs_oauth_1 = require("@nathapp/nestjs-oauth");
|
|
18
|
+
let PrismaConsentLogoutTargetResolver = class PrismaConsentLogoutTargetResolver {
|
|
19
|
+
constructor(consentRepo) {
|
|
20
|
+
this.consentRepo = consentRepo;
|
|
21
|
+
}
|
|
22
|
+
async resolve(input) {
|
|
23
|
+
var _a;
|
|
24
|
+
const tenantId = (_a = input.tenantId) !== null && _a !== void 0 ? _a : null;
|
|
25
|
+
const publicIds = await this.consentRepo.findActiveClientPublicIds(input.userId, tenantId);
|
|
26
|
+
const seen = new Set();
|
|
27
|
+
const deduped = [];
|
|
28
|
+
for (const clientId of publicIds) {
|
|
29
|
+
if (seen.has(clientId))
|
|
30
|
+
continue;
|
|
31
|
+
seen.add(clientId);
|
|
32
|
+
deduped.push({ clientId });
|
|
33
|
+
}
|
|
34
|
+
return deduped;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
exports.PrismaConsentLogoutTargetResolver = PrismaConsentLogoutTargetResolver;
|
|
38
|
+
exports.PrismaConsentLogoutTargetResolver = PrismaConsentLogoutTargetResolver = __decorate([
|
|
39
|
+
(0, common_1.Injectable)(),
|
|
40
|
+
__param(0, (0, common_1.Inject)(nestjs_oauth_1.OAUTH_CONSENT_REPOSITORY)),
|
|
41
|
+
__metadata("design:paramtypes", [Object])
|
|
42
|
+
], PrismaConsentLogoutTargetResolver);
|
|
43
|
+
//# sourceMappingURL=prisma-consent-logout-target.resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma-consent-logout-target.resolver.js","sourceRoot":"","sources":["../lib/prisma-consent-logout-target.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,wDAI+B;AAGxB,IAAM,iCAAiC,GAAvC,MAAM,iCAAiC;IAC5C,YAEqB,WAAoC;QAApC,gBAAW,GAAX,WAAW,CAAyB;IACtD,CAAC;IAEJ,KAAK,CAAC,OAAO,CAAC,KAIb;;QACC,MAAM,QAAQ,GAAG,MAAA,KAAK,CAAC,QAAQ,mCAAI,IAAI,CAAC;QACxC,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,yBAAyB,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC3F,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;QAC/B,MAAM,OAAO,GAAgC,EAAE,CAAC;QAChD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YACjC,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC;gBAAE,SAAS;YACjC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACnB,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAA;AAtBY,8EAAiC;4CAAjC,iCAAiC;IAD7C,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,uCAAwB,CAAC,CAAA;;GAFxB,iCAAiC,CAsB7C"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AbstractPrismaRepository, type PrismaClientLike } from '@nathapp/nestjs-prisma';
|
|
2
|
+
import { ITransactionManager } from '@nathapp/nestjs-data';
|
|
3
|
+
import { type IOAuthAccessTokenRepository, type IOAuthAccessToken } from '@nathapp/nestjs-oauth';
|
|
4
|
+
import { type OAuthAccessTokenRow, type OAuthPrismaDelegate } from './oauth-prisma.types';
|
|
5
|
+
export declare class PrismaOAuthAccessTokenRepository extends AbstractPrismaRepository<IOAuthAccessToken, OAuthAccessTokenRow, string> implements IOAuthAccessTokenRepository {
|
|
6
|
+
constructor(tx: ITransactionManager);
|
|
7
|
+
protected modelDelegate(client: PrismaClientLike): OAuthPrismaDelegate<OAuthAccessTokenRow>;
|
|
8
|
+
private get oauthModel();
|
|
9
|
+
protected toDomain(e: OAuthAccessTokenRow): IOAuthAccessToken;
|
|
10
|
+
protected toPersistenceCreate(d: IOAuthAccessToken): {
|
|
11
|
+
id: string;
|
|
12
|
+
tenantId: string | null;
|
|
13
|
+
tokenHash: string;
|
|
14
|
+
clientId: string;
|
|
15
|
+
userId: string | null;
|
|
16
|
+
refreshTokenId: string | null;
|
|
17
|
+
tokenType: string;
|
|
18
|
+
expiresAt: Date;
|
|
19
|
+
cnfJkt: string | null;
|
|
20
|
+
cnfX5tS256: string | null;
|
|
21
|
+
resource: string | null;
|
|
22
|
+
actorClientId: string | null;
|
|
23
|
+
scopes: {
|
|
24
|
+
create: {
|
|
25
|
+
scope: {
|
|
26
|
+
connect: {
|
|
27
|
+
code: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
}[];
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
protected toPersistenceUpdate(p: Partial<IOAuthAccessToken>): Record<string, unknown>;
|
|
34
|
+
create(d: IOAuthAccessToken): Promise<IOAuthAccessToken>;
|
|
35
|
+
findById(id: string): Promise<IOAuthAccessToken | null>;
|
|
36
|
+
findByTokenHash(tokenHash: string): Promise<IOAuthAccessToken | null>;
|
|
37
|
+
revoke(id: string, revokedAt: Date): Promise<void>;
|
|
38
|
+
revokeIfActive(id: string, revokedAt: Date): Promise<boolean>;
|
|
39
|
+
revokeByRefreshTokenId(refreshTokenId: string, revokedAt: Date): Promise<void>;
|
|
40
|
+
deleteExpired(now: Date): Promise<number>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
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.PrismaOAuthAccessTokenRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const nestjs_prisma_1 = require("@nathapp/nestjs-prisma");
|
|
18
|
+
const nestjs_data_1 = require("@nathapp/nestjs-data");
|
|
19
|
+
const oauth_prisma_types_1 = require("./oauth-prisma.types");
|
|
20
|
+
let PrismaOAuthAccessTokenRepository = class PrismaOAuthAccessTokenRepository extends nestjs_prisma_1.AbstractPrismaRepository {
|
|
21
|
+
constructor(tx) { super(tx); }
|
|
22
|
+
modelDelegate(client) {
|
|
23
|
+
return (0, oauth_prisma_types_1.getOAuthPrismaDelegate)(client, 'oAuthAccessToken');
|
|
24
|
+
}
|
|
25
|
+
get oauthModel() {
|
|
26
|
+
return this.modelDelegate(this.tx.getClient());
|
|
27
|
+
}
|
|
28
|
+
toDomain(e) {
|
|
29
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
30
|
+
return {
|
|
31
|
+
id: e.id,
|
|
32
|
+
tenantId: (_a = e.tenantId) !== null && _a !== void 0 ? _a : undefined,
|
|
33
|
+
tokenHash: e.tokenHash,
|
|
34
|
+
clientId: e.clientId,
|
|
35
|
+
userId: (_b = e.userId) !== null && _b !== void 0 ? _b : undefined,
|
|
36
|
+
refreshTokenId: (_c = e.refreshTokenId) !== null && _c !== void 0 ? _c : undefined,
|
|
37
|
+
scopes: ((_d = e.scopes) !== null && _d !== void 0 ? _d : []).map((scope) => scope.scope.code),
|
|
38
|
+
tokenType: e.tokenType,
|
|
39
|
+
expiresAt: e.expiresAt,
|
|
40
|
+
revokedAt: (_e = e.revokedAt) !== null && _e !== void 0 ? _e : undefined,
|
|
41
|
+
cnf: e.cnfJkt || e.cnfX5tS256 ? {
|
|
42
|
+
...(e.cnfJkt ? { jkt: e.cnfJkt } : {}),
|
|
43
|
+
...(e.cnfX5tS256 ? { 'x5t#S256': e.cnfX5tS256 } : {}),
|
|
44
|
+
} : undefined,
|
|
45
|
+
resource: (_f = e.resource) !== null && _f !== void 0 ? _f : undefined,
|
|
46
|
+
actorClientId: (_g = e.actorClientId) !== null && _g !== void 0 ? _g : undefined,
|
|
47
|
+
createdAt: e.createdAt,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
toPersistenceCreate(d) {
|
|
51
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
52
|
+
return {
|
|
53
|
+
id: d.id,
|
|
54
|
+
tenantId: (_a = d.tenantId) !== null && _a !== void 0 ? _a : null,
|
|
55
|
+
tokenHash: d.tokenHash,
|
|
56
|
+
clientId: d.clientId,
|
|
57
|
+
userId: (_b = d.userId) !== null && _b !== void 0 ? _b : null,
|
|
58
|
+
refreshTokenId: (_c = d.refreshTokenId) !== null && _c !== void 0 ? _c : null,
|
|
59
|
+
tokenType: d.tokenType,
|
|
60
|
+
expiresAt: d.expiresAt,
|
|
61
|
+
cnfJkt: (_e = (_d = d.cnf) === null || _d === void 0 ? void 0 : _d.jkt) !== null && _e !== void 0 ? _e : null,
|
|
62
|
+
cnfX5tS256: (_g = (_f = d.cnf) === null || _f === void 0 ? void 0 : _f['x5t#S256']) !== null && _g !== void 0 ? _g : null,
|
|
63
|
+
resource: (_h = d.resource) !== null && _h !== void 0 ? _h : null,
|
|
64
|
+
actorClientId: (_j = d.actorClientId) !== null && _j !== void 0 ? _j : null,
|
|
65
|
+
scopes: {
|
|
66
|
+
create: d.scopes.map((code) => ({ scope: { connect: { code } } })),
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
toPersistenceUpdate(p) {
|
|
71
|
+
const out = {};
|
|
72
|
+
if (p.revokedAt !== undefined)
|
|
73
|
+
out.revokedAt = p.revokedAt;
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
async create(d) {
|
|
77
|
+
const e = await this.oauthModel.create({
|
|
78
|
+
data: this.toPersistenceCreate(d),
|
|
79
|
+
include: { scopes: { include: { scope: true } } },
|
|
80
|
+
});
|
|
81
|
+
return this.toDomain(e);
|
|
82
|
+
}
|
|
83
|
+
async findById(id) {
|
|
84
|
+
const e = await this.oauthModel.findUnique({
|
|
85
|
+
where: { id },
|
|
86
|
+
include: { scopes: { include: { scope: true } } },
|
|
87
|
+
});
|
|
88
|
+
return e ? this.toDomain(e) : null;
|
|
89
|
+
}
|
|
90
|
+
async findByTokenHash(tokenHash) {
|
|
91
|
+
const e = await this.oauthModel.findUnique({
|
|
92
|
+
where: { tokenHash },
|
|
93
|
+
include: { scopes: { include: { scope: true } } },
|
|
94
|
+
});
|
|
95
|
+
return e ? this.toDomain(e) : null;
|
|
96
|
+
}
|
|
97
|
+
async revoke(id, revokedAt) {
|
|
98
|
+
await this.model.update({ where: { id }, data: { revokedAt } });
|
|
99
|
+
}
|
|
100
|
+
async revokeIfActive(id, revokedAt) {
|
|
101
|
+
const res = await this.oauthModel.updateMany({
|
|
102
|
+
where: { id, revokedAt: null },
|
|
103
|
+
data: { revokedAt },
|
|
104
|
+
});
|
|
105
|
+
return res.count === 1;
|
|
106
|
+
}
|
|
107
|
+
async revokeByRefreshTokenId(refreshTokenId, revokedAt) {
|
|
108
|
+
await this.oauthModel.updateMany({
|
|
109
|
+
where: { refreshTokenId, revokedAt: null },
|
|
110
|
+
data: { revokedAt },
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
async deleteExpired(now) {
|
|
114
|
+
const res = await this.oauthModel.deleteMany({ where: { expiresAt: { lt: now } } });
|
|
115
|
+
return res.count;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
exports.PrismaOAuthAccessTokenRepository = PrismaOAuthAccessTokenRepository;
|
|
119
|
+
exports.PrismaOAuthAccessTokenRepository = PrismaOAuthAccessTokenRepository = __decorate([
|
|
120
|
+
(0, common_1.Injectable)(),
|
|
121
|
+
__param(0, (0, common_1.Inject)(nestjs_data_1.TRANSACTION_MANAGER)),
|
|
122
|
+
__metadata("design:paramtypes", [Object])
|
|
123
|
+
], PrismaOAuthAccessTokenRepository);
|
|
124
|
+
//# sourceMappingURL=prisma-oauth-access-token.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma-oauth-access-token.repository.js","sourceRoot":"","sources":["../lib/prisma-oauth-access-token.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,0DAAyF;AACzF,sDAAgF;AAKhF,6DAAkH;AAG3G,IAAM,gCAAgC,GAAtC,MAAM,gCACX,SAAQ,wCAAwE;IAGhF,YAAyC,EAAuB,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAEtE,aAAa,CAAC,MAAwB;QAC9C,OAAO,IAAA,2CAAsB,EAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC5D,CAAC;IAED,IAAY,UAAU;QACpB,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,EAAoB,CAAC,CAAC;IACnE,CAAC;IAES,QAAQ,CAAC,CAAsB;;QACvC,OAAO;YACL,EAAE,EAAE,CAAC,CAAC,EAAE;YACR,QAAQ,EAAE,MAAA,CAAC,CAAC,QAAQ,mCAAI,SAAS;YACjC,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,QAAQ,EAAE,CAAC,CAAC,QAAQ;YACpB,MAAM,EAAE,MAAA,CAAC,CAAC,MAAM,mCAAI,SAAS;YAC7B,cAAc,EAAE,MAAA,CAAC,CAAC,cAAc,mCAAI,SAAS;YAC7C,MAAM,EAAE,CAAC,MAAA,CAAC,CAAC,MAAM,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CA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E,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;QACpF,OAAO,GAAG,CAAC,KAAK,CAAC;IACnB,CAAC;CACF,CAAA;AA7GY,4EAAgC;2CAAhC,gCAAgC;IAD5C,IAAA,mBAAU,GAAE;IAKE,WAAA,IAAA,eAAM,EAAC,iCAAmB,CAAC,CAAA;;GAJ7B,gCAAgC,CA6G5C"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AbstractPrismaRepository, type PrismaClientLike } from '@nathapp/nestjs-prisma';
|
|
2
|
+
import { ITransactionManager } from '@nathapp/nestjs-data';
|
|
3
|
+
import { type IOAuthAuthorizationCodeRepository, type IOAuthAuthorizationCode, type CodeChallengeMethod } from '@nathapp/nestjs-oauth';
|
|
4
|
+
import { type OAuthAuthorizationCodeRow, type OAuthPrismaDelegate } from './oauth-prisma.types';
|
|
5
|
+
export declare class PrismaOAuthAuthorizationCodeRepository extends AbstractPrismaRepository<IOAuthAuthorizationCode, OAuthAuthorizationCodeRow, string> implements IOAuthAuthorizationCodeRepository {
|
|
6
|
+
constructor(tx: ITransactionManager);
|
|
7
|
+
protected modelDelegate(client: PrismaClientLike): OAuthPrismaDelegate<OAuthAuthorizationCodeRow>;
|
|
8
|
+
private get oauthModel();
|
|
9
|
+
protected toDomain(e: OAuthAuthorizationCodeRow): IOAuthAuthorizationCode;
|
|
10
|
+
protected toPersistenceCreate(d: IOAuthAuthorizationCode): {
|
|
11
|
+
id: string;
|
|
12
|
+
tenantId: string | null;
|
|
13
|
+
code: string;
|
|
14
|
+
clientId: string;
|
|
15
|
+
userId: string;
|
|
16
|
+
codeChallenge: string | null;
|
|
17
|
+
codeChallengeMethod: CodeChallengeMethod | null;
|
|
18
|
+
redirectUri: string;
|
|
19
|
+
state: string | null;
|
|
20
|
+
nonce: string | null;
|
|
21
|
+
authTime: Date | null;
|
|
22
|
+
sid: string | null;
|
|
23
|
+
resource: string | null;
|
|
24
|
+
expiresAt: Date;
|
|
25
|
+
scopes: {
|
|
26
|
+
create: {
|
|
27
|
+
scope: {
|
|
28
|
+
connect: {
|
|
29
|
+
code: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}[];
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
protected toPersistenceUpdate(p: Partial<IOAuthAuthorizationCode>): Record<string, unknown>;
|
|
36
|
+
create(d: IOAuthAuthorizationCode): Promise<IOAuthAuthorizationCode>;
|
|
37
|
+
findById(id: string): Promise<IOAuthAuthorizationCode | null>;
|
|
38
|
+
findByCode(code: string): Promise<IOAuthAuthorizationCode | null>;
|
|
39
|
+
consume(id: string, usedAt: Date): Promise<boolean>;
|
|
40
|
+
deleteExpired(now: Date): Promise<number>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
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.PrismaOAuthAuthorizationCodeRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const nestjs_prisma_1 = require("@nathapp/nestjs-prisma");
|
|
18
|
+
const nestjs_data_1 = require("@nathapp/nestjs-data");
|
|
19
|
+
const oauth_prisma_types_1 = require("./oauth-prisma.types");
|
|
20
|
+
let PrismaOAuthAuthorizationCodeRepository = class PrismaOAuthAuthorizationCodeRepository extends nestjs_prisma_1.AbstractPrismaRepository {
|
|
21
|
+
constructor(tx) { super(tx); }
|
|
22
|
+
modelDelegate(client) {
|
|
23
|
+
return (0, oauth_prisma_types_1.getOAuthPrismaDelegate)(client, 'oAuthAuthorizationCode');
|
|
24
|
+
}
|
|
25
|
+
get oauthModel() {
|
|
26
|
+
return this.modelDelegate(this.tx.getClient());
|
|
27
|
+
}
|
|
28
|
+
toDomain(e) {
|
|
29
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
30
|
+
const domain = {
|
|
31
|
+
id: e.id,
|
|
32
|
+
tenantId: (_a = e.tenantId) !== null && _a !== void 0 ? _a : undefined,
|
|
33
|
+
code: e.code,
|
|
34
|
+
clientId: e.clientId,
|
|
35
|
+
userId: e.userId,
|
|
36
|
+
scopes: ((_b = e.scopes) !== null && _b !== void 0 ? _b : []).map((scope) => scope.scope.code),
|
|
37
|
+
codeChallenge: (_c = e.codeChallenge) !== null && _c !== void 0 ? _c : undefined,
|
|
38
|
+
codeChallengeMethod: ((_d = e.codeChallengeMethod) !== null && _d !== void 0 ? _d : undefined),
|
|
39
|
+
redirectUri: e.redirectUri,
|
|
40
|
+
state: (_e = e.state) !== null && _e !== void 0 ? _e : undefined,
|
|
41
|
+
nonce: (_f = e.nonce) !== null && _f !== void 0 ? _f : undefined,
|
|
42
|
+
expiresAt: e.expiresAt,
|
|
43
|
+
usedAt: (_g = e.usedAt) !== null && _g !== void 0 ? _g : undefined,
|
|
44
|
+
authTime: (_h = e.authTime) !== null && _h !== void 0 ? _h : undefined,
|
|
45
|
+
sid: (_j = e.sid) !== null && _j !== void 0 ? _j : undefined,
|
|
46
|
+
resource: (_k = e.resource) !== null && _k !== void 0 ? _k : undefined,
|
|
47
|
+
createdAt: e.createdAt,
|
|
48
|
+
};
|
|
49
|
+
return domain;
|
|
50
|
+
}
|
|
51
|
+
toPersistenceCreate(d) {
|
|
52
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
53
|
+
return {
|
|
54
|
+
id: d.id,
|
|
55
|
+
tenantId: (_a = d.tenantId) !== null && _a !== void 0 ? _a : null,
|
|
56
|
+
code: d.code,
|
|
57
|
+
clientId: d.clientId,
|
|
58
|
+
userId: d.userId,
|
|
59
|
+
codeChallenge: (_b = d.codeChallenge) !== null && _b !== void 0 ? _b : null,
|
|
60
|
+
codeChallengeMethod: (_c = d.codeChallengeMethod) !== null && _c !== void 0 ? _c : null,
|
|
61
|
+
redirectUri: d.redirectUri,
|
|
62
|
+
state: (_d = d.state) !== null && _d !== void 0 ? _d : null,
|
|
63
|
+
nonce: (_e = d.nonce) !== null && _e !== void 0 ? _e : null,
|
|
64
|
+
authTime: (_f = d.authTime) !== null && _f !== void 0 ? _f : null,
|
|
65
|
+
sid: (_g = d.sid) !== null && _g !== void 0 ? _g : null,
|
|
66
|
+
resource: (_h = d.resource) !== null && _h !== void 0 ? _h : null,
|
|
67
|
+
expiresAt: d.expiresAt,
|
|
68
|
+
scopes: {
|
|
69
|
+
create: d.scopes.map((code) => ({ scope: { connect: { code } } })),
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
toPersistenceUpdate(p) {
|
|
74
|
+
const out = {};
|
|
75
|
+
if (p.usedAt !== undefined)
|
|
76
|
+
out.usedAt = p.usedAt;
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
async create(d) {
|
|
80
|
+
const e = await this.oauthModel.create({
|
|
81
|
+
data: this.toPersistenceCreate(d),
|
|
82
|
+
include: { scopes: { include: { scope: true } } },
|
|
83
|
+
});
|
|
84
|
+
return this.toDomain(e);
|
|
85
|
+
}
|
|
86
|
+
async findById(id) {
|
|
87
|
+
const e = await this.oauthModel.findUnique({
|
|
88
|
+
where: { id },
|
|
89
|
+
include: { scopes: { include: { scope: true } } },
|
|
90
|
+
});
|
|
91
|
+
return e ? this.toDomain(e) : null;
|
|
92
|
+
}
|
|
93
|
+
async findByCode(code) {
|
|
94
|
+
const e = await this.oauthModel.findUnique({
|
|
95
|
+
where: { code },
|
|
96
|
+
include: { scopes: { include: { scope: true } } },
|
|
97
|
+
});
|
|
98
|
+
return e ? this.toDomain(e) : null;
|
|
99
|
+
}
|
|
100
|
+
async consume(id, usedAt) {
|
|
101
|
+
const res = await this.oauthModel.updateMany({
|
|
102
|
+
where: { id, usedAt: null },
|
|
103
|
+
data: { usedAt },
|
|
104
|
+
});
|
|
105
|
+
return res.count === 1;
|
|
106
|
+
}
|
|
107
|
+
async deleteExpired(now) {
|
|
108
|
+
const res = await this.oauthModel.deleteMany({ where: { expiresAt: { lt: now } } });
|
|
109
|
+
return res.count;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
exports.PrismaOAuthAuthorizationCodeRepository = PrismaOAuthAuthorizationCodeRepository;
|
|
113
|
+
exports.PrismaOAuthAuthorizationCodeRepository = PrismaOAuthAuthorizationCodeRepository = __decorate([
|
|
114
|
+
(0, common_1.Injectable)(),
|
|
115
|
+
__param(0, (0, common_1.Inject)(nestjs_data_1.TRANSACTION_MANAGER)),
|
|
116
|
+
__metadata("design:paramtypes", [Object])
|
|
117
|
+
], PrismaOAuthAuthorizationCodeRepository);
|
|
118
|
+
//# sourceMappingURL=prisma-oauth-authorization-code.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma-oauth-authorization-code.repository.js","sourceRoot":"","sources":["../lib/prisma-oauth-authorization-code.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,0DAAyF;AACzF,sDAAgF;AAMhF,6DAAwH;AAGjH,IAAM,sC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E,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;YAC3B,IAAI,EAAE,EAAE,MAAM,EAAE;SACjB,CAAC,CAAC;QACH,OAAO,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,GAAS;QAC3B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;QACpF,OAAO,GAAG,CAAC,KAAK,CAAC;IACnB,CAAC;CACF,CAAA;AArGY,wFAAsC;iDAAtC,sCAAsC;IADlD,IAAA,mBAAU,GAAE;IAKE,WAAA,IAAA,eAAM,EAAC,iCAAmB,CAAC,CAAA;;GAJ7B,sCAAsC,CAqGlD"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { AbstractPrismaRepository, type PrismaClientLike } from '@nathapp/nestjs-prisma';
|
|
2
|
+
import { ITransactionManager } from '@nathapp/nestjs-data';
|
|
3
|
+
import type { IPageResult } from '@nathapp/nestjs-data';
|
|
4
|
+
import { type IOAuthClientRepository, type IOAuthClient, type OAuthClientType, type PkceRequirement, OAuthClientStatus, ListClientsQuery } from '@nathapp/nestjs-oauth';
|
|
5
|
+
import { type OAuthClientRow, type OAuthPrismaDelegate } from './oauth-prisma.types';
|
|
6
|
+
export declare class PrismaOAuthClientRepository extends AbstractPrismaRepository<IOAuthClient, OAuthClientRow, string> implements IOAuthClientRepository {
|
|
7
|
+
constructor(tx: ITransactionManager);
|
|
8
|
+
protected modelDelegate(client: PrismaClientLike): OAuthPrismaDelegate<OAuthClientRow>;
|
|
9
|
+
private get oauthModel();
|
|
10
|
+
protected toDomain(e: OAuthClientRow): IOAuthClient;
|
|
11
|
+
protected toPersistenceCreate(d: IOAuthClient): {
|
|
12
|
+
id: string;
|
|
13
|
+
tenantId: string | null;
|
|
14
|
+
clientId: string;
|
|
15
|
+
clientSecretHash: string | null;
|
|
16
|
+
name: string;
|
|
17
|
+
description: string | null;
|
|
18
|
+
clientType: OAuthClientType;
|
|
19
|
+
redirectUris: string[];
|
|
20
|
+
postLogoutRedirectUris: string[];
|
|
21
|
+
grantTypes: string[];
|
|
22
|
+
responseTypes: string[];
|
|
23
|
+
accessTokenTtl: number;
|
|
24
|
+
refreshTokenTtl: number;
|
|
25
|
+
authCodeTtl: number;
|
|
26
|
+
pkceRequired: PkceRequirement;
|
|
27
|
+
requireConsent: boolean;
|
|
28
|
+
dpopBoundAccessTokens: boolean;
|
|
29
|
+
backchannelLogoutUri: string | null;
|
|
30
|
+
backchannelLogoutSessionRequired: boolean | null;
|
|
31
|
+
frontchannelLogoutUri: string | null;
|
|
32
|
+
frontchannelLogoutSessionRequired: boolean | null;
|
|
33
|
+
tokenEndpointAuthMethod: string | null;
|
|
34
|
+
jwks: Record<string, unknown> | null;
|
|
35
|
+
jwksUri: string | null;
|
|
36
|
+
tlsClientAuthSubjectDn: string | null;
|
|
37
|
+
tlsClientAuthSanDns: string[] | null;
|
|
38
|
+
tlsClientAuthSelfSignedThumbprint: string | null;
|
|
39
|
+
clientSecretHashPrevious: string | null;
|
|
40
|
+
previousSecretExpiresAt: Date | null;
|
|
41
|
+
allowedResources: string[];
|
|
42
|
+
requireResource: boolean;
|
|
43
|
+
status: OAuthClientStatus;
|
|
44
|
+
};
|
|
45
|
+
protected toPersistenceUpdate(p: Partial<IOAuthClient>): Record<string, unknown>;
|
|
46
|
+
update(idOrClientId: string, patch: Partial<IOAuthClient>): Promise<IOAuthClient>;
|
|
47
|
+
findByClientId(clientId: string): Promise<IOAuthClient | null>;
|
|
48
|
+
findByClientIds(clientIds: string[]): Promise<IOAuthClient[]>;
|
|
49
|
+
findPage(query: ListClientsQuery): Promise<IPageResult<IOAuthClient>>;
|
|
50
|
+
}
|