@nauth-toolkit/database-typeorm-postgres 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/entities/api-key.entity.d.ts +31 -0
- package/dist/entities/api-key.entity.d.ts.map +1 -0
- package/dist/entities/api-key.entity.js +115 -0
- package/dist/entities/api-key.entity.js.map +1 -0
- package/dist/entities/index.d.ts +1 -0
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/entities/index.js +3 -0
- package/dist/entities/index.js.map +1 -1
- package/dist/migrations/1769300000000-AddApiKeys.d.ts +10 -0
- package/dist/migrations/1769300000000-AddApiKeys.d.ts.map +1 -0
- package/dist/migrations/1769300000000-AddApiKeys.js +51 -0
- package/dist/migrations/1769300000000-AddApiKeys.js.map +1 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +2 -0
- package/dist/migrations/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BaseApiKey } from '@nauth-toolkit/core';
|
|
2
|
+
import { User } from './user.entity';
|
|
3
|
+
/**
|
|
4
|
+
* TypeORM PostgreSQL API Key Entity
|
|
5
|
+
*
|
|
6
|
+
* Extends BaseApiKey from core and adds PostgreSQL-specific TypeORM decorators.
|
|
7
|
+
* All field definitions and business logic are in the base class.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ApiKey extends BaseApiKey {
|
|
10
|
+
id: number;
|
|
11
|
+
keyId: string;
|
|
12
|
+
userId: number;
|
|
13
|
+
user: User;
|
|
14
|
+
lookupId: string;
|
|
15
|
+
keyHash: string;
|
|
16
|
+
name?: string | null;
|
|
17
|
+
lastFour?: string | null;
|
|
18
|
+
allowedIps?: string[] | null;
|
|
19
|
+
expiresAt?: Date | null;
|
|
20
|
+
isActive: boolean;
|
|
21
|
+
revokedAt?: Date | null;
|
|
22
|
+
revokeReason?: string | null;
|
|
23
|
+
createdByAdmin: boolean;
|
|
24
|
+
lastUsedAt?: Date | null;
|
|
25
|
+
lastUsedIp?: string | null;
|
|
26
|
+
usageCount: number;
|
|
27
|
+
metadata?: Record<string, unknown> | null;
|
|
28
|
+
createdAt: Date;
|
|
29
|
+
updatedAt: Date;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=api-key.entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key.entity.d.ts","sourceRoot":"","sources":["../../src/entities/api-key.entity.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC;;;;;GAKG;AACH,qBAMa,MAAO,SAAQ,UAAU;IAE5B,EAAE,EAAE,MAAM,CAAC;IAGX,KAAK,EAAE,MAAM,CAAC;IAGd,MAAM,EAAE,MAAM,CAAC;IAIvB,IAAI,EAAG,IAAI,CAAC;IAGJ,QAAQ,EAAE,MAAM,CAAC;IAGjB,OAAO,EAAE,MAAM,CAAC;IAGhB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAGrB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAGzB,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAG7B,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAGxB,QAAQ,EAAE,OAAO,CAAC;IAGlB,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAGxB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAG7B,cAAc,EAAE,OAAO,CAAC;IAGxB,UAAU,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAGzB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAG3B,UAAU,EAAE,MAAM,CAAC;IAGnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAG1C,SAAS,EAAE,IAAI,CAAC;IAGhB,SAAS,EAAE,IAAI,CAAC;CACzB"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ApiKey = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const core_1 = require("@nauth-toolkit/core");
|
|
15
|
+
const user_entity_1 = require("./user.entity");
|
|
16
|
+
/**
|
|
17
|
+
* TypeORM PostgreSQL API Key Entity
|
|
18
|
+
*
|
|
19
|
+
* Extends BaseApiKey from core and adds PostgreSQL-specific TypeORM decorators.
|
|
20
|
+
* All field definitions and business logic are in the base class.
|
|
21
|
+
*/
|
|
22
|
+
let ApiKey = class ApiKey extends core_1.BaseApiKey {
|
|
23
|
+
user;
|
|
24
|
+
};
|
|
25
|
+
exports.ApiKey = ApiKey;
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
|
28
|
+
__metadata("design:type", Number)
|
|
29
|
+
], ApiKey.prototype, "id", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.Column)({ type: 'uuid' }),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], ApiKey.prototype, "keyId", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, typeorm_1.Column)({ type: 'int' }),
|
|
36
|
+
__metadata("design:type", Number)
|
|
37
|
+
], ApiKey.prototype, "userId", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typeorm_1.ManyToOne)(() => user_entity_1.User, { onDelete: 'CASCADE' }),
|
|
40
|
+
(0, typeorm_1.JoinColumn)({ name: 'userId' }),
|
|
41
|
+
__metadata("design:type", user_entity_1.User)
|
|
42
|
+
], ApiKey.prototype, "user", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 64 }),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], ApiKey.prototype, "lookupId", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 128 }),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], ApiKey.prototype, "keyHash", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 255, nullable: true }),
|
|
53
|
+
__metadata("design:type", Object)
|
|
54
|
+
], ApiKey.prototype, "name", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 8, nullable: true }),
|
|
57
|
+
__metadata("design:type", Object)
|
|
58
|
+
], ApiKey.prototype, "lastFour", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, typeorm_1.Column)({ type: 'simple-array', nullable: true }),
|
|
61
|
+
__metadata("design:type", Object)
|
|
62
|
+
], ApiKey.prototype, "allowedIps", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, typeorm_1.Column)({ type: 'timestamptz', nullable: true }),
|
|
65
|
+
__metadata("design:type", Object)
|
|
66
|
+
], ApiKey.prototype, "expiresAt", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, typeorm_1.Column)({ type: 'boolean', default: true }),
|
|
69
|
+
__metadata("design:type", Boolean)
|
|
70
|
+
], ApiKey.prototype, "isActive", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
(0, typeorm_1.Column)({ type: 'timestamptz', nullable: true }),
|
|
73
|
+
__metadata("design:type", Object)
|
|
74
|
+
], ApiKey.prototype, "revokedAt", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 255, nullable: true }),
|
|
77
|
+
__metadata("design:type", Object)
|
|
78
|
+
], ApiKey.prototype, "revokeReason", void 0);
|
|
79
|
+
__decorate([
|
|
80
|
+
(0, typeorm_1.Column)({ type: 'boolean', default: false }),
|
|
81
|
+
__metadata("design:type", Boolean)
|
|
82
|
+
], ApiKey.prototype, "createdByAdmin", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, typeorm_1.Column)({ type: 'timestamptz', nullable: true }),
|
|
85
|
+
__metadata("design:type", Object)
|
|
86
|
+
], ApiKey.prototype, "lastUsedAt", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 45, nullable: true }),
|
|
89
|
+
__metadata("design:type", Object)
|
|
90
|
+
], ApiKey.prototype, "lastUsedIp", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
(0, typeorm_1.Column)({ type: 'int', default: 0 }),
|
|
93
|
+
__metadata("design:type", Number)
|
|
94
|
+
], ApiKey.prototype, "usageCount", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
(0, typeorm_1.Column)({ type: 'jsonb', nullable: true }),
|
|
97
|
+
__metadata("design:type", Object)
|
|
98
|
+
], ApiKey.prototype, "metadata", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
(0, typeorm_1.CreateDateColumn)({ type: 'timestamptz' }),
|
|
101
|
+
__metadata("design:type", Date)
|
|
102
|
+
], ApiKey.prototype, "createdAt", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
(0, typeorm_1.UpdateDateColumn)({ type: 'timestamptz' }),
|
|
105
|
+
__metadata("design:type", Date)
|
|
106
|
+
], ApiKey.prototype, "updatedAt", void 0);
|
|
107
|
+
exports.ApiKey = ApiKey = __decorate([
|
|
108
|
+
(0, typeorm_1.Entity)('nauth_api_keys'),
|
|
109
|
+
(0, typeorm_1.Index)(['keyId'], { unique: true }),
|
|
110
|
+
(0, typeorm_1.Index)(['lookupId'], { unique: true }),
|
|
111
|
+
(0, typeorm_1.Index)(['userId']),
|
|
112
|
+
(0, typeorm_1.Index)(['isActive']),
|
|
113
|
+
(0, typeorm_1.Index)(['expiresAt'])
|
|
114
|
+
], ApiKey);
|
|
115
|
+
//# sourceMappingURL=api-key.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key.entity.js","sourceRoot":"","sources":["../../src/entities/api-key.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCASiB;AACjB,8CAAiD;AACjD,+CAAqC;AAErC;;;;;GAKG;AAOI,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,iBAAU;IAYpC,IAAI,CAAQ;CAiDb,CAAA;AA7DY,wBAAM;AAET;IADP,IAAA,gCAAsB,GAAE;;kCACN;AAGX;IADP,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;qCACH;AAGd;IADP,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;sCACD;AAIvB;IAFC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,kBAAI,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IAC9C,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;8BACxB,kBAAI;oCAAC;AAGJ;IADP,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,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AA,gBAAM,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;0CACT;AAGnB;IADP,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wCACQ;AAG1C;IADP,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;8BACvB,IAAI;yCAAC;AAGhB;IADP,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;8BACvB,IAAI;yCAAC;iBA5Db,MAAM;IANlB,IAAA,gBAAM,EAAC,gBAAgB,CAAC;IACxB,IAAA,eAAK,EAAC,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAClC,IAAA,eAAK,EAAC,CAAC,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACrC,IAAA,eAAK,EAAC,CAAC,QAAQ,CAAC,CAAC;IACjB,IAAA,eAAK,EAAC,CAAC,UAAU,CAAC,CAAC;IACnB,IAAA,eAAK,EAAC,CAAC,WAAW,CAAC,CAAC;GACR,MAAM,CA6DlB"}
|
package/dist/entities/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from './trusted-device.entity';
|
|
|
10
10
|
export * from './rate-limit.entity';
|
|
11
11
|
export * from './storage-lock.entity';
|
|
12
12
|
export * from './social-provider-secret.entity';
|
|
13
|
+
export * from './api-key.entity';
|
|
13
14
|
/**
|
|
14
15
|
* Get all nauth-toolkit entities for TypeORM configuration (excluding storage entities)
|
|
15
16
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,kBAAkB,CAAC;AAiBjC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,IAAI,QAAQ,EAAE,CAc7C;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gCAAgC,IAAI,QAAQ,EAAE,CAE7D"}
|
package/dist/entities/index.js
CHANGED
|
@@ -28,6 +28,7 @@ __exportStar(require("./trusted-device.entity"), exports);
|
|
|
28
28
|
__exportStar(require("./rate-limit.entity"), exports);
|
|
29
29
|
__exportStar(require("./storage-lock.entity"), exports);
|
|
30
30
|
__exportStar(require("./social-provider-secret.entity"), exports);
|
|
31
|
+
__exportStar(require("./api-key.entity"), exports);
|
|
31
32
|
// Import all entities for the helper function
|
|
32
33
|
const user_entity_1 = require("./user.entity");
|
|
33
34
|
const session_entity_1 = require("./session.entity");
|
|
@@ -41,6 +42,7 @@ const trusted_device_entity_1 = require("./trusted-device.entity");
|
|
|
41
42
|
const rate_limit_entity_1 = require("./rate-limit.entity");
|
|
42
43
|
const storage_lock_entity_1 = require("./storage-lock.entity");
|
|
43
44
|
const social_provider_secret_entity_1 = require("./social-provider-secret.entity");
|
|
45
|
+
const api_key_entity_1 = require("./api-key.entity");
|
|
44
46
|
/**
|
|
45
47
|
* Get all nauth-toolkit entities for TypeORM configuration (excluding storage entities)
|
|
46
48
|
*
|
|
@@ -76,6 +78,7 @@ function getNAuthEntities() {
|
|
|
76
78
|
auth_audit_entity_1.AuthAudit,
|
|
77
79
|
trusted_device_entity_1.TrustedDevice,
|
|
78
80
|
social_provider_secret_entity_1.SocialProviderSecret,
|
|
81
|
+
api_key_entity_1.ApiKey,
|
|
79
82
|
];
|
|
80
83
|
}
|
|
81
84
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAoDA,4CAcC;AAwBD,4EAEC;AA5FD,gDAA8B;AAC9B,mDAAiC;AACjC,yDAAuC;AACvC,8DAA4C;AAC5C,0DAAwC;AACxC,6DAA2C;AAC3C,sDAAoC;AACpC,sDAAoC;AACpC,0DAAwC;AACxC,sDAAoC;AACpC,wDAAsC;AACtC,kEAAgD;AAChD,mDAAiC;AAEjC,8CAA8C;AAC9C,+CAAqC;AACrC,qDAA2C;AAC3C,iEAAsD;AACtD,2EAAgE;AAChE,mEAAwD;AACxD,yEAA8D;AAC9D,2DAAgD;AAChD,2DAAgD;AAChD,mEAAwD;AACxD,2DAAgD;AAChD,+DAAoD;AACpD,mFAAuE;AACvE,qDAA0C;AAE1C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,gBAAgB;IAC9B,OAAO;QACL,kBAAI;QACJ,wBAAO;QACP,mCAAY;QACZ,6CAAiB;QACjB,qCAAa;QACb,2CAAgB;QAChB,6BAAS;QACT,6BAAS;QACT,qCAAa;QACb,oDAAoB;QACpB,uBAAM;KACP,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,gCAAgC;IAC9C,OAAO,CAAC,6BAAS,EAAE,iCAAW,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
2
|
+
/**
|
|
3
|
+
* Adds the nauth_api_keys table for API key authentication.
|
|
4
|
+
*/
|
|
5
|
+
export declare class AddApiKeys1769300000000 implements MigrationInterface {
|
|
6
|
+
name: string;
|
|
7
|
+
up(queryRunner: QueryRunner): Promise<void>;
|
|
8
|
+
down(queryRunner: QueryRunner): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=1769300000000-AddApiKeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"1769300000000-AddApiKeys.d.ts","sourceRoot":"","sources":["../../src/migrations/1769300000000-AddApiKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE1D;;GAEG;AACH,qBAAa,uBAAwB,YAAW,kBAAkB;IAChE,IAAI,SAA6B;IAEpB,EAAE,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAoC3C,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAS3D"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AddApiKeys1769300000000 = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Adds the nauth_api_keys table for API key authentication.
|
|
6
|
+
*/
|
|
7
|
+
class AddApiKeys1769300000000 {
|
|
8
|
+
name = 'AddApiKeys1769300000000';
|
|
9
|
+
async up(queryRunner) {
|
|
10
|
+
await queryRunner.query(`CREATE TABLE "nauth_api_keys" (` +
|
|
11
|
+
`"id" SERIAL NOT NULL, ` +
|
|
12
|
+
`"keyId" uuid NOT NULL, ` +
|
|
13
|
+
`"userId" integer NOT NULL, ` +
|
|
14
|
+
`"lookupId" character varying(64) NOT NULL, ` +
|
|
15
|
+
`"keyHash" character varying(128) NOT NULL, ` +
|
|
16
|
+
`"name" character varying(255), ` +
|
|
17
|
+
`"lastFour" character varying(8), ` +
|
|
18
|
+
`"allowedIps" text, ` +
|
|
19
|
+
`"expiresAt" TIMESTAMP WITH TIME ZONE, ` +
|
|
20
|
+
`"isActive" boolean NOT NULL DEFAULT true, ` +
|
|
21
|
+
`"revokedAt" TIMESTAMP WITH TIME ZONE, ` +
|
|
22
|
+
`"revokeReason" character varying(255), ` +
|
|
23
|
+
`"createdByAdmin" boolean NOT NULL DEFAULT false, ` +
|
|
24
|
+
`"lastUsedAt" TIMESTAMP WITH TIME ZONE, ` +
|
|
25
|
+
`"lastUsedIp" character varying(45), ` +
|
|
26
|
+
`"usageCount" integer NOT NULL DEFAULT 0, ` +
|
|
27
|
+
`"metadata" jsonb, ` +
|
|
28
|
+
`"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), ` +
|
|
29
|
+
`"updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), ` +
|
|
30
|
+
`CONSTRAINT "PK_nauth_api_keys" PRIMARY KEY ("id"))`);
|
|
31
|
+
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_nauth_api_keys_keyId" ON "nauth_api_keys" ("keyId")`);
|
|
32
|
+
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_nauth_api_keys_lookupId" ON "nauth_api_keys" ("lookupId")`);
|
|
33
|
+
await queryRunner.query(`CREATE INDEX "IDX_nauth_api_keys_userId" ON "nauth_api_keys" ("userId")`);
|
|
34
|
+
await queryRunner.query(`CREATE INDEX "IDX_nauth_api_keys_isActive" ON "nauth_api_keys" ("isActive")`);
|
|
35
|
+
await queryRunner.query(`CREATE INDEX "IDX_nauth_api_keys_expiresAt" ON "nauth_api_keys" ("expiresAt")`);
|
|
36
|
+
// Cascade delete keys when the owning user is removed (matches other user-owned tables).
|
|
37
|
+
await queryRunner.query(`ALTER TABLE "nauth_api_keys" ADD CONSTRAINT "FK_nauth_api_keys_userId" ` +
|
|
38
|
+
`FOREIGN KEY ("userId") REFERENCES "nauth_users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
39
|
+
}
|
|
40
|
+
async down(queryRunner) {
|
|
41
|
+
await queryRunner.query(`ALTER TABLE "nauth_api_keys" DROP CONSTRAINT "FK_nauth_api_keys_userId"`);
|
|
42
|
+
await queryRunner.query(`DROP INDEX "IDX_nauth_api_keys_expiresAt"`);
|
|
43
|
+
await queryRunner.query(`DROP INDEX "IDX_nauth_api_keys_isActive"`);
|
|
44
|
+
await queryRunner.query(`DROP INDEX "IDX_nauth_api_keys_userId"`);
|
|
45
|
+
await queryRunner.query(`DROP INDEX "IDX_nauth_api_keys_lookupId"`);
|
|
46
|
+
await queryRunner.query(`DROP INDEX "IDX_nauth_api_keys_keyId"`);
|
|
47
|
+
await queryRunner.query(`DROP TABLE "nauth_api_keys"`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.AddApiKeys1769300000000 = AddApiKeys1769300000000;
|
|
51
|
+
//# sourceMappingURL=1769300000000-AddApiKeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"1769300000000-AddApiKeys.js","sourceRoot":"","sources":["../../src/migrations/1769300000000-AddApiKeys.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAa,uBAAuB;IAClC,IAAI,GAAG,yBAAyB,CAAC;IAE1B,KAAK,CAAC,EAAE,CAAC,WAAwB;QACtC,MAAM,WAAW,CAAC,KAAK,CACrB,iCAAiC;YAC/B,wBAAwB;YACxB,yBAAyB;YACzB,6BAA6B;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EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAMlD,MAAM,MAAM,oBAAoB,GAAG;IAAE,QAAQ,kBAAkB,CAAA;CAAE,CAAC;AAElE;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,oBAAoB,EAK5C,CAAC"}
|
package/dist/migrations/index.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.migrations = void 0;
|
|
|
4
4
|
const _1734600000000_Initial_1 = require("./1734600000000-Initial");
|
|
5
5
|
const _1766480775000_AddSocialProviderSecrets_1 = require("./1766480775000-AddSocialProviderSecrets");
|
|
6
6
|
const _1769212800000_AllowMultipleMFADevices_1 = require("./1769212800000-AllowMultipleMFADevices");
|
|
7
|
+
const _1769300000000_AddApiKeys_1 = require("./1769300000000-AddApiKeys");
|
|
7
8
|
/**
|
|
8
9
|
* Adapter-owned migrations for @nauth-toolkit/database-typeorm-postgres
|
|
9
10
|
*/
|
|
@@ -11,5 +12,6 @@ exports.migrations = [
|
|
|
11
12
|
_1734600000000_Initial_1.Initial1734600000000,
|
|
12
13
|
_1766480775000_AddSocialProviderSecrets_1.AddSocialProviderSecrets1766480775000,
|
|
13
14
|
_1769212800000_AllowMultipleMFADevices_1.AllowMultipleMFADevices1769212800000,
|
|
15
|
+
_1769300000000_AddApiKeys_1.AddApiKeys1769300000000,
|
|
14
16
|
];
|
|
15
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":";;;AACA,oEAA+D;AAC/D,sGAAiG;AACjG,oGAA+F;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":";;;AACA,oEAA+D;AAC/D,sGAAiG;AACjG,oGAA+F;AAC/F,0EAAqE;AAIrE;;GAEG;AACU,QAAA,UAAU,GAA2B;IAChD,6CAAoB;IACpB,+EAAqC;IACrC,6EAAoC;IACpC,mDAAuB;CACxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nauth-toolkit/database-typeorm-postgres",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "PostgreSQL storage adapter for nauth-toolkit via TypeORM",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"format:check": "prettier --check \"src/**/*.ts\""
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@nauth-toolkit/core": "^0.3.
|
|
17
|
+
"@nauth-toolkit/core": "^0.3.1",
|
|
18
18
|
"typeorm": "^0.3.20",
|
|
19
19
|
"pg": "^8.0.0"
|
|
20
20
|
},
|