@tstdl/base 0.93.1 → 0.93.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/server/api-request-token.provider.d.ts +5 -3
- package/api/server/api-request-token.provider.js +12 -4
- package/api/server/gateway.d.ts +1 -9
- package/api/server/gateway.js +67 -36
- package/api/types.d.ts +5 -1
- package/application/application.d.ts +2 -0
- package/application/application.js +3 -1
- package/application/providers.d.ts +1 -1
- package/application/providers.js +1 -1
- package/audit/audit.model.d.ts +106 -6
- package/audit/audit.model.js +156 -13
- package/audit/auditor.d.ts +115 -30
- package/audit/auditor.js +160 -19
- package/audit/drizzle/0000_bored_stick.sql +26 -0
- package/audit/drizzle/meta/0000_snapshot.json +195 -0
- package/audit/drizzle/meta/_journal.json +13 -0
- package/audit/drizzle.config.d.ts +2 -0
- package/audit/drizzle.config.js +11 -0
- package/audit/index.d.ts +3 -1
- package/audit/index.js +3 -1
- package/audit/module.d.ts +22 -0
- package/audit/module.js +33 -0
- package/audit/schemas.d.ts +6 -0
- package/audit/schemas.js +8 -0
- package/audit/types.d.ts +2 -1
- package/audit/types.js +2 -1
- package/authentication/models/authentication-credentials.model.js +1 -2
- package/authentication/models/authentication-session.model.d.ts +2 -2
- package/authentication/models/authentication-session.model.js +3 -5
- package/authentication/models/index.d.ts +0 -1
- package/authentication/models/index.js +0 -1
- package/authentication/server/authentication-api-request-token.provider.d.ts +2 -2
- package/authentication/server/authentication-api-request-token.provider.js +8 -5
- package/authentication/server/authentication.api-controller.d.ts +8 -8
- package/authentication/server/authentication.api-controller.js +16 -16
- package/authentication/server/authentication.audit.d.ts +34 -0
- package/authentication/server/authentication.audit.js +1 -0
- package/authentication/server/authentication.service.d.ts +19 -10
- package/authentication/server/authentication.service.js +158 -43
- package/authentication/server/drizzle.config.js +1 -1
- package/authentication/server/index.d.ts +1 -0
- package/authentication/server/index.js +1 -0
- package/authentication/server/module.d.ts +1 -1
- package/authentication/{models → server}/schemas.d.ts +2 -3
- package/authentication/{models → server}/schemas.js +2 -3
- package/constants.d.ts +1 -0
- package/constants.js +1 -0
- package/document-management/api/document-management.api.d.ts +74 -74
- package/document-management/models/document-assignment-scope.model.d.ts +1 -2
- package/document-management/models/document-assignment-scope.model.js +4 -6
- package/document-management/models/document-assignment-task.model.d.ts +1 -2
- package/document-management/models/document-assignment-task.model.js +3 -5
- package/document-management/models/document-category.model.d.ts +1 -2
- package/document-management/models/document-category.model.js +3 -4
- package/document-management/models/document-collection-assignment.model.d.ts +1 -2
- package/document-management/models/document-collection-assignment.model.js +5 -7
- package/document-management/models/document-collection.model.d.ts +1 -2
- package/document-management/models/document-collection.model.js +3 -4
- package/document-management/models/document-management-table.d.ts +1 -1
- package/document-management/models/document-management-table.js +1 -1
- package/document-management/models/document-property-value.model.d.ts +1 -2
- package/document-management/models/document-property-value.model.js +5 -8
- package/document-management/models/document-property.model.d.ts +1 -2
- package/document-management/models/document-property.model.js +2 -3
- package/document-management/models/document-request-collection-assignment.model.d.ts +1 -2
- package/document-management/models/document-request-collection-assignment.model.js +4 -6
- package/document-management/models/document-request-template.d.ts +1 -2
- package/document-management/models/document-request-template.js +4 -6
- package/document-management/models/document-request.model.d.ts +1 -1
- package/document-management/models/document-request.model.js +4 -5
- package/document-management/models/document-requests-template.d.ts +1 -1
- package/document-management/models/document-requests-template.js +2 -3
- package/document-management/models/document-tag-assignment.model.d.ts +1 -2
- package/document-management/models/document-tag-assignment.model.js +4 -6
- package/document-management/models/document-tag.model.d.ts +1 -1
- package/document-management/models/document-tag.model.js +2 -3
- package/document-management/models/document-type-property.model.d.ts +1 -2
- package/document-management/models/document-type-property.model.js +4 -6
- package/document-management/models/document-type-validation.model.d.ts +1 -2
- package/document-management/models/document-type-validation.model.js +4 -6
- package/document-management/models/document-type.model.d.ts +1 -2
- package/document-management/models/document-type.model.js +3 -5
- package/document-management/models/document-validation-definition.model.d.ts +1 -2
- package/document-management/models/document-validation-definition.model.js +3 -4
- package/document-management/models/document-validation-execution-related-document.model.d.ts +1 -2
- package/document-management/models/document-validation-execution-related-document.model.js +4 -6
- package/document-management/models/document-validation-execution.model.d.ts +1 -2
- package/document-management/models/document-validation-execution.model.js +6 -8
- package/document-management/models/document-workflow.model.d.ts +1 -2
- package/document-management/models/document-workflow.model.js +5 -7
- package/document-management/models/document.model.d.ts +1 -2
- package/document-management/models/document.model.js +5 -7
- package/document-management/server/api/document-management.api.js +1 -1
- package/document-management/server/module.d.ts +1 -1
- package/document-management/server/module.js +1 -1
- package/document-management/server/schemas.d.ts +1 -1
- package/document-management/server/schemas.js +1 -1
- package/document-management/server/services/document-category-type.service.d.ts +2 -2
- package/document-management/server/services/document-category-type.service.js +1 -2
- package/document-management/server/services/document-collection.service.d.ts +1 -1
- package/document-management/server/services/document-collection.service.js +1 -2
- package/document-management/server/services/document-management.service.js +6 -6
- package/document-management/server/services/document-property.service.d.ts +1 -1
- package/document-management/server/services/document-property.service.js +1 -2
- package/document-management/server/services/document-validation.service.js +2 -2
- package/document-management/server/services/document-workflow.service.d.ts +2 -2
- package/document-management/server/services/document-workflow.service.js +1 -2
- package/document-management/server/services/document.service.d.ts +1 -1
- package/document-management/server/services/document.service.js +1 -2
- package/document-management/server/services/singleton.js +1 -1
- package/document-management/service-models/document.service-model.d.ts +62 -62
- package/document-management/service-models/document.service-model.js +1 -1
- package/document-management/service-models/enriched/enriched-document-management-data.view.js +1 -1
- package/document-management/service-models/enriched/enriched-document.view.d.ts +1 -1
- package/examples/api/authentication.js +2 -2
- package/examples/api/basic-overview.js +2 -2
- package/examples/api/custom-authentication.js +2 -2
- package/examples/api/streaming.js +2 -2
- package/examples/browser/basic.js +2 -2
- package/examples/document-management/main.js +2 -2
- package/examples/http/client.js +2 -2
- package/examples/mail/basic.js +2 -2
- package/examples/pdf/basic.js +2 -2
- package/examples/template/basic.js +2 -2
- package/http/server/http-server-request.d.ts +3 -3
- package/key-value-store/postgres/key-value-store.service.js +1 -2
- package/key-value-store/postgres/models/key-value.model.d.ts +1 -2
- package/key-value-store/postgres/models/key-value.model.js +2 -4
- package/key-value-store/postgres/models/schemas.d.ts +1 -1
- package/key-value-store/postgres/models/schemas.js +1 -1
- package/lock/postgres/lock.js +1 -1
- package/lock/postgres/models/lock.model.d.ts +1 -2
- package/lock/postgres/models/lock.model.js +3 -5
- package/lock/postgres/models/schemas.d.ts +1 -1
- package/lock/postgres/models/schemas.js +1 -1
- package/lock/postgres/provider.js +1 -2
- package/mail/models/mail-log.model.d.ts +1 -1
- package/mail/models/mail-log.model.js +4 -5
- package/mail/models/schemas.d.ts +1 -1
- package/mail/models/schemas.js +1 -1
- package/openid-connect/oidc-state.model.d.ts +1 -1
- package/openid-connect/oidc-state.model.js +2 -3
- package/openid-connect/oidc.service.js +1 -1
- package/orm/data-types/bytea.js +1 -1
- package/orm/data-types/numeric-date.js +1 -1
- package/orm/decorators.d.ts +65 -72
- package/orm/decorators.js +42 -40
- package/orm/entity.d.ts +7 -1
- package/orm/entity.js +25 -11
- package/orm/index.d.ts +2 -1
- package/orm/index.js +2 -1
- package/orm/schemas/json.d.ts +1 -1
- package/orm/schemas/json.js +1 -1
- package/orm/schemas/numeric-date.d.ts +1 -1
- package/orm/schemas/numeric-date.js +1 -1
- package/orm/schemas/timestamp.d.ts +1 -1
- package/orm/schemas/timestamp.js +1 -1
- package/orm/schemas/uuid.d.ts +2 -2
- package/orm/schemas/uuid.js +1 -1
- package/orm/server/drizzle/schema-converter.ts +408 -0
- package/orm/server/repository.d.ts +1 -1
- package/orm/server/repository.js +12 -9
- package/orm/sqls.d.ts +1 -1
- package/orm/sqls.js +1 -1
- package/orm/types.d.ts +2 -6
- package/orm/types.js +1 -4
- package/package.json +15 -24
- package/queue/postgres/job.model.d.ts +3 -3
- package/queue/postgres/job.model.js +5 -6
- package/queue/postgres/queue.js +2 -2
- package/queue/postgres/schemas.d.ts +1 -1
- package/queue/postgres/schemas.js +1 -1
- package/supports.d.ts +1 -0
- package/supports.js +2 -1
- package/types/types.d.ts +12 -1
- package/utils/object/object.d.ts +3 -1
- package/utils/object/object.js +7 -1
- package/orm/server/drizzle/index.js +0 -1
- package/orm/server/drizzle/schema-converter.d.ts +0 -15
- package/orm/server/drizzle/schema-converter.js +0 -300
- /package/orm/server/drizzle/{index.d.ts → index.ts} +0 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "8f6c87f8-1692-49bd-9bd4-09dc9d0bdcd4",
|
|
3
|
+
"prevId": "00000000-0000-0000-0000-000000000000",
|
|
4
|
+
"version": "7",
|
|
5
|
+
"dialect": "postgresql",
|
|
6
|
+
"tables": {
|
|
7
|
+
"audit.event": {
|
|
8
|
+
"name": "event",
|
|
9
|
+
"schema": "audit",
|
|
10
|
+
"columns": {
|
|
11
|
+
"id": {
|
|
12
|
+
"name": "id",
|
|
13
|
+
"type": "uuid",
|
|
14
|
+
"primaryKey": true,
|
|
15
|
+
"notNull": true,
|
|
16
|
+
"default": "gen_random_uuid()"
|
|
17
|
+
},
|
|
18
|
+
"timestamp": {
|
|
19
|
+
"name": "timestamp",
|
|
20
|
+
"type": "timestamp with time zone",
|
|
21
|
+
"primaryKey": false,
|
|
22
|
+
"notNull": true
|
|
23
|
+
},
|
|
24
|
+
"tenant_id": {
|
|
25
|
+
"name": "tenant_id",
|
|
26
|
+
"type": "uuid",
|
|
27
|
+
"primaryKey": false,
|
|
28
|
+
"notNull": false
|
|
29
|
+
},
|
|
30
|
+
"correlation_id": {
|
|
31
|
+
"name": "correlation_id",
|
|
32
|
+
"type": "uuid",
|
|
33
|
+
"primaryKey": false,
|
|
34
|
+
"notNull": false
|
|
35
|
+
},
|
|
36
|
+
"module": {
|
|
37
|
+
"name": "module",
|
|
38
|
+
"type": "text",
|
|
39
|
+
"primaryKey": false,
|
|
40
|
+
"notNull": true
|
|
41
|
+
},
|
|
42
|
+
"action": {
|
|
43
|
+
"name": "action",
|
|
44
|
+
"type": "text",
|
|
45
|
+
"primaryKey": false,
|
|
46
|
+
"notNull": true
|
|
47
|
+
},
|
|
48
|
+
"outcome": {
|
|
49
|
+
"name": "outcome",
|
|
50
|
+
"type": "audit_outcome",
|
|
51
|
+
"typeSchema": "audit",
|
|
52
|
+
"primaryKey": false,
|
|
53
|
+
"notNull": true
|
|
54
|
+
},
|
|
55
|
+
"severity": {
|
|
56
|
+
"name": "severity",
|
|
57
|
+
"type": "audit_severity",
|
|
58
|
+
"typeSchema": "audit",
|
|
59
|
+
"primaryKey": false,
|
|
60
|
+
"notNull": true
|
|
61
|
+
},
|
|
62
|
+
"actor_type": {
|
|
63
|
+
"name": "actor_type",
|
|
64
|
+
"type": "actor_type",
|
|
65
|
+
"typeSchema": "audit",
|
|
66
|
+
"primaryKey": false,
|
|
67
|
+
"notNull": true
|
|
68
|
+
},
|
|
69
|
+
"actor": {
|
|
70
|
+
"name": "actor",
|
|
71
|
+
"type": "text",
|
|
72
|
+
"primaryKey": false,
|
|
73
|
+
"notNull": true
|
|
74
|
+
},
|
|
75
|
+
"impersonator_type": {
|
|
76
|
+
"name": "impersonator_type",
|
|
77
|
+
"type": "actor_type",
|
|
78
|
+
"typeSchema": "audit",
|
|
79
|
+
"primaryKey": false,
|
|
80
|
+
"notNull": false
|
|
81
|
+
},
|
|
82
|
+
"impersonator": {
|
|
83
|
+
"name": "impersonator",
|
|
84
|
+
"type": "text",
|
|
85
|
+
"primaryKey": false,
|
|
86
|
+
"notNull": false
|
|
87
|
+
},
|
|
88
|
+
"target_type": {
|
|
89
|
+
"name": "target_type",
|
|
90
|
+
"type": "text",
|
|
91
|
+
"primaryKey": false,
|
|
92
|
+
"notNull": true
|
|
93
|
+
},
|
|
94
|
+
"target_id": {
|
|
95
|
+
"name": "target_id",
|
|
96
|
+
"type": "uuid",
|
|
97
|
+
"primaryKey": false,
|
|
98
|
+
"notNull": true
|
|
99
|
+
},
|
|
100
|
+
"network_path": {
|
|
101
|
+
"name": "network_path",
|
|
102
|
+
"type": "text",
|
|
103
|
+
"primaryKey": false,
|
|
104
|
+
"notNull": true
|
|
105
|
+
},
|
|
106
|
+
"network_ip_address": {
|
|
107
|
+
"name": "network_ip_address",
|
|
108
|
+
"type": "text",
|
|
109
|
+
"primaryKey": false,
|
|
110
|
+
"notNull": false
|
|
111
|
+
},
|
|
112
|
+
"network_user_agent": {
|
|
113
|
+
"name": "network_user_agent",
|
|
114
|
+
"type": "text",
|
|
115
|
+
"primaryKey": false,
|
|
116
|
+
"notNull": false
|
|
117
|
+
},
|
|
118
|
+
"network_session_id": {
|
|
119
|
+
"name": "network_session_id",
|
|
120
|
+
"type": "uuid",
|
|
121
|
+
"primaryKey": false,
|
|
122
|
+
"notNull": false
|
|
123
|
+
},
|
|
124
|
+
"changes_before": {
|
|
125
|
+
"name": "changes_before",
|
|
126
|
+
"type": "jsonb",
|
|
127
|
+
"primaryKey": false,
|
|
128
|
+
"notNull": false
|
|
129
|
+
},
|
|
130
|
+
"changes_after": {
|
|
131
|
+
"name": "changes_after",
|
|
132
|
+
"type": "jsonb",
|
|
133
|
+
"primaryKey": false,
|
|
134
|
+
"notNull": false
|
|
135
|
+
},
|
|
136
|
+
"details": {
|
|
137
|
+
"name": "details",
|
|
138
|
+
"type": "jsonb",
|
|
139
|
+
"primaryKey": false,
|
|
140
|
+
"notNull": false
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
"indexes": {},
|
|
144
|
+
"foreignKeys": {},
|
|
145
|
+
"compositePrimaryKeys": {},
|
|
146
|
+
"uniqueConstraints": {},
|
|
147
|
+
"policies": {},
|
|
148
|
+
"checkConstraints": {},
|
|
149
|
+
"isRLSEnabled": false
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
"enums": {
|
|
153
|
+
"audit.actor_type": {
|
|
154
|
+
"name": "actor_type",
|
|
155
|
+
"schema": "audit",
|
|
156
|
+
"values": [
|
|
157
|
+
"anonymous",
|
|
158
|
+
"system",
|
|
159
|
+
"api-key",
|
|
160
|
+
"user"
|
|
161
|
+
]
|
|
162
|
+
},
|
|
163
|
+
"audit.audit_outcome": {
|
|
164
|
+
"name": "audit_outcome",
|
|
165
|
+
"schema": "audit",
|
|
166
|
+
"values": [
|
|
167
|
+
"pending",
|
|
168
|
+
"success",
|
|
169
|
+
"cancelled",
|
|
170
|
+
"failure",
|
|
171
|
+
"denied"
|
|
172
|
+
]
|
|
173
|
+
},
|
|
174
|
+
"audit.audit_severity": {
|
|
175
|
+
"name": "audit_severity",
|
|
176
|
+
"schema": "audit",
|
|
177
|
+
"values": [
|
|
178
|
+
"info",
|
|
179
|
+
"warn",
|
|
180
|
+
"error",
|
|
181
|
+
"critical"
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
"schemas": {},
|
|
186
|
+
"sequences": {},
|
|
187
|
+
"roles": {},
|
|
188
|
+
"policies": {},
|
|
189
|
+
"views": {},
|
|
190
|
+
"_meta": {
|
|
191
|
+
"columns": {},
|
|
192
|
+
"schemas": {},
|
|
193
|
+
"tables": {}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { relative, resolve } from 'node:path';
|
|
2
|
+
import { defineConfig } from 'drizzle-kit';
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
dialect: 'postgresql',
|
|
5
|
+
out: relative('./', resolve(__dirname, './drizzle/').replace('dist', 'source')),
|
|
6
|
+
schema: resolve(__dirname, './schemas.js'),
|
|
7
|
+
migrations: {
|
|
8
|
+
schema: 'audit',
|
|
9
|
+
table: '_migrations',
|
|
10
|
+
},
|
|
11
|
+
});
|
package/audit/index.d.ts
CHANGED
package/audit/index.js
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type DatabaseConfig } from '../orm/server/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for {@link configureAuditServer}.
|
|
4
|
+
*/
|
|
5
|
+
export declare class AuditModuleConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Database configuration for audit module.
|
|
8
|
+
* If not provided, the global database configuration is used.
|
|
9
|
+
*/
|
|
10
|
+
database?: DatabaseConfig;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Configures audit server services.
|
|
14
|
+
* @param config Configuration.
|
|
15
|
+
*/
|
|
16
|
+
export declare function configureAuditServer(config: AuditModuleConfig): void;
|
|
17
|
+
/**
|
|
18
|
+
* Migrates the audit database schema to the latest version.
|
|
19
|
+
* It uses the database connection provided with {@link configureAuditServer},
|
|
20
|
+
* or falls back to the globally configured database if no specific configuration is provided.
|
|
21
|
+
*/
|
|
22
|
+
export declare function migrateAuditSchema(): Promise<void>;
|
package/audit/module.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { inject, Injector } from '../injector/index.js';
|
|
2
|
+
import { Database, migrate } from '../orm/server/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for {@link configureAuditServer}.
|
|
5
|
+
*/
|
|
6
|
+
export class AuditModuleConfig {
|
|
7
|
+
/**
|
|
8
|
+
* Database configuration for audit module.
|
|
9
|
+
* If not provided, the global database configuration is used.
|
|
10
|
+
*/
|
|
11
|
+
database;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Configures audit server services.
|
|
15
|
+
* @param config Configuration.
|
|
16
|
+
*/
|
|
17
|
+
export function configureAuditServer(config) {
|
|
18
|
+
Injector.register(AuditModuleConfig, { useValue: config });
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Migrates the audit database schema to the latest version.
|
|
22
|
+
* It uses the database connection provided with {@link configureAuditServer},
|
|
23
|
+
* or falls back to the globally configured database if no specific configuration is provided.
|
|
24
|
+
*/
|
|
25
|
+
export async function migrateAuditSchema() {
|
|
26
|
+
const connection = inject(AuditModuleConfig, undefined, { optional: true })?.database?.connection;
|
|
27
|
+
const database = inject(Database, connection);
|
|
28
|
+
await migrate(database, {
|
|
29
|
+
migrationsSchema: 'audit',
|
|
30
|
+
migrationsTable: '_migrations',
|
|
31
|
+
migrationsFolder: import.meta.resolve('./drizzle').replace('file://', ''),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AuditEvent } from './audit.model.js';
|
|
2
|
+
export declare const auditSchema: import("../orm/server/index.js").DatabaseSchema<"audit">;
|
|
3
|
+
export declare const auditOutcome: import("drizzle-orm/pg-core").PgEnum<["pending", "success", "cancelled", "failure", "denied"]>;
|
|
4
|
+
export declare const auditSeverity: import("drizzle-orm/pg-core").PgEnum<["error", "warn", "info", "critical"]>;
|
|
5
|
+
export declare const actorType: import("drizzle-orm/pg-core").PgEnum<["user", "anonymous", "system", "api-key"]>;
|
|
6
|
+
export declare const auditEvent: import("../orm/server/types.js").PgTableFromType<typeof AuditEvent, "audit">;
|
package/audit/schemas.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { databaseSchema } from '../orm/server/index.js';
|
|
2
|
+
import { AuditEvent } from './audit.model.js';
|
|
3
|
+
import { ActorType, AuditOutcome, AuditSeverity } from './types.js';
|
|
4
|
+
export const auditSchema = databaseSchema('audit');
|
|
5
|
+
export const auditOutcome = auditSchema.getEnum(AuditOutcome);
|
|
6
|
+
export const auditSeverity = auditSchema.getEnum(AuditSeverity);
|
|
7
|
+
export const actorType = auditSchema.getEnum(ActorType);
|
|
8
|
+
export const auditEvent = auditSchema.getTable(AuditEvent);
|
package/audit/types.d.ts
CHANGED
|
@@ -15,8 +15,9 @@ export declare const AuditOutcome: {
|
|
|
15
15
|
};
|
|
16
16
|
export type AuditOutcome = EnumType<typeof AuditOutcome>;
|
|
17
17
|
export declare const ActorType: {
|
|
18
|
-
readonly
|
|
18
|
+
readonly Anonymous: "anonymous";
|
|
19
19
|
readonly System: "system";
|
|
20
20
|
readonly ApiKey: "api-key";
|
|
21
|
+
readonly User: "user";
|
|
21
22
|
};
|
|
22
23
|
export type ActorType = EnumType<typeof ActorType>;
|
package/audit/types.js
CHANGED
|
@@ -7,8 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import { Table } from '../../orm/
|
|
11
|
-
import { Entity, Unique } from '../../orm/index.js';
|
|
10
|
+
import { Entity, Table, Unique } from '../../orm/index.js';
|
|
12
11
|
import { Integer, StringProperty, Uint8ArrayProperty } from '../../schema/index.js';
|
|
13
12
|
let AuthenticationCredentials = class AuthenticationCredentials extends Entity {
|
|
14
13
|
subject;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Timestamp } from '../../orm/index.js';
|
|
2
|
+
import { Entity } from '../../orm/index.js';
|
|
3
3
|
export declare class AuthenticationSession extends Entity {
|
|
4
4
|
subject: string;
|
|
5
5
|
begin: Timestamp;
|
|
@@ -7,9 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import { Table } from '../../orm/
|
|
11
|
-
import { Entity } from '../../orm/entity.js';
|
|
12
|
-
import { Timestamp } from '../../orm/types.js';
|
|
10
|
+
import { Entity, Table, TimestampProperty } from '../../orm/index.js';
|
|
13
11
|
import { Integer, StringProperty, Uint8ArrayProperty } from '../../schema/index.js';
|
|
14
12
|
let AuthenticationSession = class AuthenticationSession extends Entity {
|
|
15
13
|
subject;
|
|
@@ -30,11 +28,11 @@ __decorate([
|
|
|
30
28
|
__metadata("design:type", String)
|
|
31
29
|
], AuthenticationSession.prototype, "subject", void 0);
|
|
32
30
|
__decorate([
|
|
33
|
-
|
|
31
|
+
TimestampProperty(),
|
|
34
32
|
__metadata("design:type", Number)
|
|
35
33
|
], AuthenticationSession.prototype, "begin", void 0);
|
|
36
34
|
__decorate([
|
|
37
|
-
|
|
35
|
+
TimestampProperty(),
|
|
38
36
|
__metadata("design:type", Number)
|
|
39
37
|
], AuthenticationSession.prototype, "end", void 0);
|
|
40
38
|
__decorate([
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from './authentication-credentials.model.js';
|
|
2
2
|
export * from './authentication-session.model.js';
|
|
3
3
|
export * from './init-secret-reset-data.model.js';
|
|
4
|
-
export * from './schemas.js';
|
|
5
4
|
export * from './secret-check-result.model.js';
|
|
6
5
|
export * from './token-payload-base.model.js';
|
|
7
6
|
export * from './token.model.js';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from './authentication-credentials.model.js';
|
|
2
2
|
export * from './authentication-session.model.js';
|
|
3
3
|
export * from './init-secret-reset-data.model.js';
|
|
4
|
-
export * from './schemas.js';
|
|
5
4
|
export * from './secret-check-result.model.js';
|
|
6
5
|
export * from './token-payload-base.model.js';
|
|
7
6
|
export * from './token.model.js';
|
|
@@ -2,10 +2,10 @@ import type { ApiRequestData } from '../../api/index.js';
|
|
|
2
2
|
import { ApiRequestTokenProvider } from '../../api/server/api-request-token.provider.js';
|
|
3
3
|
import { AuthenticationService } from './authentication.service.js';
|
|
4
4
|
/**
|
|
5
|
-
* Provides the
|
|
5
|
+
* Provides the info for an API request from the authorization header.
|
|
6
6
|
*/
|
|
7
7
|
export declare class AuthenticationApiRequestTokenProvider extends ApiRequestTokenProvider {
|
|
8
8
|
private readonly authenticationService;
|
|
9
9
|
constructor(authenticationService: AuthenticationService);
|
|
10
|
-
|
|
10
|
+
tryGetToken<T>(data: ApiRequestData): Promise<T | null>;
|
|
11
11
|
}
|
|
@@ -9,10 +9,11 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
};
|
|
10
10
|
import { ApiRequestTokenProvider } from '../../api/server/api-request-token.provider.js';
|
|
11
11
|
import { Singleton } from '../../injector/decorators.js';
|
|
12
|
+
import { isUndefined } from '../../utils/type-guards.js';
|
|
12
13
|
import { AuthenticationService } from './authentication.service.js';
|
|
13
14
|
import { tryGetAuthorizationTokenStringFromRequest } from './helper.js';
|
|
14
15
|
/**
|
|
15
|
-
* Provides the
|
|
16
|
+
* Provides the info for an API request from the authorization header.
|
|
16
17
|
*/
|
|
17
18
|
let AuthenticationApiRequestTokenProvider = class AuthenticationApiRequestTokenProvider extends ApiRequestTokenProvider {
|
|
18
19
|
authenticationService;
|
|
@@ -20,10 +21,12 @@ let AuthenticationApiRequestTokenProvider = class AuthenticationApiRequestTokenP
|
|
|
20
21
|
super();
|
|
21
22
|
this.authenticationService = authenticationService;
|
|
22
23
|
}
|
|
23
|
-
async
|
|
24
|
-
const tokenString = tryGetAuthorizationTokenStringFromRequest(data.request)
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
async tryGetToken(data) {
|
|
25
|
+
const tokenString = tryGetAuthorizationTokenStringFromRequest(data.request);
|
|
26
|
+
if (isUndefined(tokenString)) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return await this.authenticationService.validateToken(tokenString);
|
|
27
30
|
}
|
|
28
31
|
};
|
|
29
32
|
AuthenticationApiRequestTokenProvider = __decorate([
|
|
@@ -20,47 +20,47 @@ export declare class AuthenticationApiController<AdditionalTokenPayload extends
|
|
|
20
20
|
* @param parameters The parameters for the request.
|
|
21
21
|
* @returns The token result.
|
|
22
22
|
*/
|
|
23
|
-
login({ parameters }: ApiRequestContext<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'login'>): Promise<ApiServerResult<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'login'>>;
|
|
23
|
+
login({ parameters, getAuditor }: ApiRequestContext<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'login'>): Promise<ApiServerResult<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'login'>>;
|
|
24
24
|
/**
|
|
25
25
|
* Refresh a token.
|
|
26
26
|
* @param request The request context.
|
|
27
27
|
* @param parameters The parameters for the request.
|
|
28
28
|
* @returns The token result.
|
|
29
29
|
*/
|
|
30
|
-
refresh({ request, parameters }: ApiRequestContext<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'refresh'>): Promise<ApiServerResult<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'refresh'>>;
|
|
30
|
+
refresh({ request, parameters, getAuditor }: ApiRequestContext<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'refresh'>): Promise<ApiServerResult<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'refresh'>>;
|
|
31
31
|
/**
|
|
32
32
|
* Impersonate a subject.
|
|
33
33
|
* @param request The request context.
|
|
34
34
|
* @param parameters The parameters for the request.
|
|
35
35
|
* @returns The token result.
|
|
36
36
|
*/
|
|
37
|
-
impersonate({ request, parameters }: ApiRequestContext<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'impersonate'>): Promise<ApiServerResult<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'impersonate'>>;
|
|
37
|
+
impersonate({ request, parameters, getAuditor }: ApiRequestContext<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'impersonate'>): Promise<ApiServerResult<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'impersonate'>>;
|
|
38
38
|
/**
|
|
39
39
|
* Unimpersonate a subject.
|
|
40
40
|
* @param request The request context.
|
|
41
41
|
* @param parameters The parameters for the request.
|
|
42
42
|
* @returns The token result.
|
|
43
43
|
*/
|
|
44
|
-
unimpersonate({ request, parameters }: ApiRequestContext<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'unimpersonate'>): Promise<ApiServerResult<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'unimpersonate'>>;
|
|
44
|
+
unimpersonate({ request, parameters, getAuditor }: ApiRequestContext<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'unimpersonate'>): Promise<ApiServerResult<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'unimpersonate'>>;
|
|
45
45
|
/**
|
|
46
46
|
* End a session.
|
|
47
47
|
* @param request The request context.
|
|
48
48
|
* @returns 'ok' if the session was ended.
|
|
49
49
|
*/
|
|
50
|
-
endSession({ request }: ApiRequestContext<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'endSession'>): Promise<ApiServerResult<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'endSession'>>;
|
|
51
|
-
changeSecret({ parameters }: ApiRequestContext<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'changeSecret'>): Promise<ApiServerResult<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'changeSecret'>>;
|
|
50
|
+
endSession({ request, getAuditor }: ApiRequestContext<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'endSession'>): Promise<ApiServerResult<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'endSession'>>;
|
|
51
|
+
changeSecret({ parameters, getAuditor }: ApiRequestContext<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'changeSecret'>): Promise<ApiServerResult<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'changeSecret'>>;
|
|
52
52
|
/**
|
|
53
53
|
* Initialize a secret reset.
|
|
54
54
|
* @param parameters The parameters for the request.
|
|
55
55
|
* @returns 'ok' if the secret reset was initialized.
|
|
56
56
|
*/
|
|
57
|
-
initSecretReset({ parameters }: ApiRequestContext<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'initSecretReset'>): Promise<ApiServerResult<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'initSecretReset'>>;
|
|
57
|
+
initSecretReset({ parameters, getAuditor }: ApiRequestContext<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'initSecretReset'>): Promise<ApiServerResult<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'initSecretReset'>>;
|
|
58
58
|
/**
|
|
59
59
|
* Reset a secret.
|
|
60
60
|
* @param parameters The parameters for the request.
|
|
61
61
|
* @returns 'ok' if the secret was reset.
|
|
62
62
|
*/
|
|
63
|
-
resetSecret({ parameters }: ApiRequestContext<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'resetSecret'>): Promise<ApiServerResult<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'resetSecret'>>;
|
|
63
|
+
resetSecret({ parameters, getAuditor }: ApiRequestContext<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'resetSecret'>): Promise<ApiServerResult<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>, 'resetSecret'>>;
|
|
64
64
|
/**
|
|
65
65
|
* Check a secret.
|
|
66
66
|
* @param parameters The parameters for the request.
|
|
@@ -33,8 +33,8 @@ let AuthenticationApiController = class AuthenticationApiController {
|
|
|
33
33
|
* @param parameters The parameters for the request.
|
|
34
34
|
* @returns The token result.
|
|
35
35
|
*/
|
|
36
|
-
async login({ parameters }) {
|
|
37
|
-
const result = await this.authenticationService.login(parameters.subject, parameters.secret, parameters.data);
|
|
36
|
+
async login({ parameters, getAuditor }) {
|
|
37
|
+
const result = await this.authenticationService.login(parameters.subject, parameters.secret, parameters.data, await getAuditor());
|
|
38
38
|
return this.getTokenResponse(result);
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
@@ -43,9 +43,9 @@ let AuthenticationApiController = class AuthenticationApiController {
|
|
|
43
43
|
* @param parameters The parameters for the request.
|
|
44
44
|
* @returns The token result.
|
|
45
45
|
*/
|
|
46
|
-
async refresh({ request, parameters }) {
|
|
46
|
+
async refresh({ request, parameters, getAuditor }) {
|
|
47
47
|
const refreshTokenString = tryGetAuthorizationTokenStringFromRequest(request, 'refreshToken') ?? '';
|
|
48
|
-
const result = await this.authenticationService.refresh(refreshTokenString, parameters.data);
|
|
48
|
+
const result = await this.authenticationService.refresh(refreshTokenString, parameters.data, undefined, await getAuditor());
|
|
49
49
|
return this.getTokenResponse(result);
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
@@ -54,10 +54,10 @@ let AuthenticationApiController = class AuthenticationApiController {
|
|
|
54
54
|
* @param parameters The parameters for the request.
|
|
55
55
|
* @returns The token result.
|
|
56
56
|
*/
|
|
57
|
-
async impersonate({ request, parameters }) {
|
|
57
|
+
async impersonate({ request, parameters, getAuditor }) {
|
|
58
58
|
const tokenString = tryGetAuthorizationTokenStringFromRequest(request) ?? '';
|
|
59
59
|
const refreshTokenString = tryGetAuthorizationTokenStringFromRequest(request, 'refreshToken') ?? '';
|
|
60
|
-
const impersonatorResult = await this.authenticationService.impersonate(tokenString, refreshTokenString, parameters.subject, parameters.data);
|
|
60
|
+
const impersonatorResult = await this.authenticationService.impersonate(tokenString, refreshTokenString, parameters.subject, parameters.data, await getAuditor());
|
|
61
61
|
return this.getTokenResponse(impersonatorResult);
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
@@ -66,9 +66,9 @@ let AuthenticationApiController = class AuthenticationApiController {
|
|
|
66
66
|
* @param parameters The parameters for the request.
|
|
67
67
|
* @returns The token result.
|
|
68
68
|
*/
|
|
69
|
-
async unimpersonate({ request, parameters }) {
|
|
69
|
+
async unimpersonate({ request, parameters, getAuditor }) {
|
|
70
70
|
const impersonatorRefreshTokenString = tryGetAuthorizationTokenStringFromRequest(request, 'impersonatorRefreshToken') ?? '';
|
|
71
|
-
const result = await this.authenticationService.
|
|
71
|
+
const result = await this.authenticationService.unimpersonate(impersonatorRefreshTokenString, parameters.data, await getAuditor());
|
|
72
72
|
return this.getTokenResponse(result);
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
@@ -76,7 +76,7 @@ let AuthenticationApiController = class AuthenticationApiController {
|
|
|
76
76
|
* @param request The request context.
|
|
77
77
|
* @returns 'ok' if the session was ended.
|
|
78
78
|
*/
|
|
79
|
-
async endSession({ request }) {
|
|
79
|
+
async endSession({ request, getAuditor }) {
|
|
80
80
|
let sessionId;
|
|
81
81
|
try {
|
|
82
82
|
const tokenString = tryGetAuthorizationTokenStringFromRequest(request) ?? '';
|
|
@@ -93,7 +93,7 @@ let AuthenticationApiController = class AuthenticationApiController {
|
|
|
93
93
|
throw error;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
await this.authenticationService.endSession(sessionId);
|
|
96
|
+
await this.authenticationService.endSession(sessionId, await getAuditor());
|
|
97
97
|
const result = 'ok';
|
|
98
98
|
return new HttpServerResponse({
|
|
99
99
|
cookies: {
|
|
@@ -106,8 +106,8 @@ let AuthenticationApiController = class AuthenticationApiController {
|
|
|
106
106
|
},
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
|
-
async changeSecret({ parameters }) {
|
|
110
|
-
await this.authenticationService.changeSecret(parameters.subject, parameters.currentSecret, parameters.newSecret);
|
|
109
|
+
async changeSecret({ parameters, getAuditor }) {
|
|
110
|
+
await this.authenticationService.changeSecret(parameters.subject, parameters.currentSecret, parameters.newSecret, await getAuditor());
|
|
111
111
|
return 'ok';
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
@@ -115,8 +115,8 @@ let AuthenticationApiController = class AuthenticationApiController {
|
|
|
115
115
|
* @param parameters The parameters for the request.
|
|
116
116
|
* @returns 'ok' if the secret reset was initialized.
|
|
117
117
|
*/
|
|
118
|
-
async initSecretReset({ parameters }) {
|
|
119
|
-
await this.authenticationService.initSecretReset(parameters.subject, parameters.data);
|
|
118
|
+
async initSecretReset({ parameters, getAuditor }) {
|
|
119
|
+
await this.authenticationService.initSecretReset(parameters.subject, parameters.data, await getAuditor());
|
|
120
120
|
return 'ok';
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
@@ -124,8 +124,8 @@ let AuthenticationApiController = class AuthenticationApiController {
|
|
|
124
124
|
* @param parameters The parameters for the request.
|
|
125
125
|
* @returns 'ok' if the secret was reset.
|
|
126
126
|
*/
|
|
127
|
-
async resetSecret({ parameters }) {
|
|
128
|
-
await this.authenticationService.resetSecret(parameters.token, parameters.newSecret);
|
|
127
|
+
async resetSecret({ parameters, getAuditor }) {
|
|
128
|
+
await this.authenticationService.resetSecret(parameters.token, parameters.newSecret, await getAuditor());
|
|
129
129
|
return 'ok';
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type AuthenticationAuditEvents = {
|
|
2
|
+
'login-success': {
|
|
3
|
+
sessionId: string;
|
|
4
|
+
};
|
|
5
|
+
'login-failure': {
|
|
6
|
+
providedSubject: string;
|
|
7
|
+
};
|
|
8
|
+
'logout': {
|
|
9
|
+
sessionId: string;
|
|
10
|
+
};
|
|
11
|
+
'refresh-success': {
|
|
12
|
+
sessionId: string;
|
|
13
|
+
};
|
|
14
|
+
'refresh-failure': {
|
|
15
|
+
reason: string;
|
|
16
|
+
};
|
|
17
|
+
'impersonate-success': {
|
|
18
|
+
impersonatedSubject: string;
|
|
19
|
+
};
|
|
20
|
+
'impersonate-failure': {
|
|
21
|
+
impersonatedSubject: string;
|
|
22
|
+
reason: string;
|
|
23
|
+
};
|
|
24
|
+
'unimpersonate-success': {};
|
|
25
|
+
'change-secret-success': {};
|
|
26
|
+
'change-secret-failure': {
|
|
27
|
+
providedSubject: string;
|
|
28
|
+
};
|
|
29
|
+
'init-secret-reset': {};
|
|
30
|
+
'reset-secret-success': {};
|
|
31
|
+
'reset-secret-failure': {
|
|
32
|
+
reason: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|