@memberjunction/core-entities 2.128.0 → 2.130.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/dist/custom/ResourcePermissions/ResourcePermissionEngine.d.ts.map +1 -1
- package/dist/custom/ResourcePermissions/ResourcePermissionEngine.js +14 -4
- package/dist/custom/ResourcePermissions/ResourcePermissionEngine.js.map +1 -1
- package/dist/engines/EncryptionEngineBase.d.ts +246 -0
- package/dist/engines/EncryptionEngineBase.d.ts.map +1 -0
- package/dist/engines/EncryptionEngineBase.js +355 -0
- package/dist/engines/EncryptionEngineBase.js.map +1 -0
- package/dist/engines/TypeTablesCache.d.ts.map +1 -1
- package/dist/engines/TypeTablesCache.js +2 -1
- package/dist/engines/TypeTablesCache.js.map +1 -1
- package/dist/engines/UserInfoEngine.d.ts +228 -0
- package/dist/engines/UserInfoEngine.d.ts.map +1 -0
- package/dist/engines/UserInfoEngine.js +599 -0
- package/dist/engines/UserInfoEngine.js.map +1 -0
- package/dist/engines/artifacts.d.ts.map +1 -1
- package/dist/engines/artifacts.js +2 -1
- package/dist/engines/artifacts.js.map +1 -1
- package/dist/engines/component-metadata.d.ts.map +1 -1
- package/dist/engines/component-metadata.js +10 -5
- package/dist/engines/component-metadata.js.map +1 -1
- package/dist/engines/dashboards.d.ts.map +1 -1
- package/dist/engines/dashboards.js +19 -6
- package/dist/engines/dashboards.js.map +1 -1
- package/dist/generated/entity_subclasses.d.ts +3124 -601
- package/dist/generated/entity_subclasses.d.ts.map +1 -1
- package/dist/generated/entity_subclasses.js +6048 -2271
- package/dist/generated/entity_subclasses.js.map +1 -1
- package/dist/index.d.ts +2 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -7
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/dist/custom/AIAgentExtended.d.ts +0 -13
- package/dist/custom/AIAgentExtended.d.ts.map +0 -1
- package/dist/custom/AIAgentExtended.js +0 -37
- package/dist/custom/AIAgentExtended.js.map +0 -1
- package/dist/custom/AIAgentRunExtended.d.ts +0 -32
- package/dist/custom/AIAgentRunExtended.d.ts.map +0 -1
- package/dist/custom/AIAgentRunExtended.js +0 -136
- package/dist/custom/AIAgentRunExtended.js.map +0 -1
- package/dist/custom/AIAgentRunStepExtended.d.ts +0 -48
- package/dist/custom/AIAgentRunStepExtended.d.ts.map +0 -1
- package/dist/custom/AIAgentRunStepExtended.js +0 -149
- package/dist/custom/AIAgentRunStepExtended.js.map +0 -1
- package/dist/custom/AIModelExtended.d.ts +0 -14
- package/dist/custom/AIModelExtended.d.ts.map +0 -1
- package/dist/custom/AIModelExtended.js +0 -36
- package/dist/custom/AIModelExtended.js.map +0 -1
- package/dist/custom/AIPromptCategoryExtended.d.ts +0 -7
- package/dist/custom/AIPromptCategoryExtended.d.ts.map +0 -1
- package/dist/custom/AIPromptCategoryExtended.js +0 -26
- package/dist/custom/AIPromptCategoryExtended.js.map +0 -1
- package/dist/custom/AIPromptExtended.d.ts +0 -51
- package/dist/custom/AIPromptExtended.d.ts.map +0 -1
- package/dist/custom/AIPromptExtended.js +0 -169
- package/dist/custom/AIPromptExtended.js.map +0 -1
- package/dist/custom/AIPromptRunEntityExtended.d.ts +0 -47
- package/dist/custom/AIPromptRunEntityExtended.d.ts.map +0 -1
- package/dist/custom/AIPromptRunEntityExtended.js +0 -156
- package/dist/custom/AIPromptRunEntityExtended.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourcePermissionEngine.d.ts","sourceRoot":"","sources":["../../../src/custom/ResourcePermissions/ResourcePermissionEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA4B,iBAAiB,
|
|
1
|
+
{"version":3,"file":"ResourcePermissionEngine.d.ts","sourceRoot":"","sources":["../../../src/custom/ResourcePermissions/ResourcePermissionEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA4B,iBAAiB,EAA8C,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrJ,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAEjG;;GAEG;AACH,qBACa,wBAAyB,SAAQ,UAAU,CAAC,wBAAwB,CAAC;IAC9E;;OAEG;IACH,WAAkB,QAAQ,IAAI,wBAAwB,CAErD;IAED,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,cAAc,CAEpB;IAEW,MAAM,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,iBAAiB;IAkBhG,IAAW,aAAa,IAAI,kBAAkB,EAAE,CAE/C;IAED,IAAW,WAAW,IAAI,wBAAwB,EAAE,CAEnD;IAGD;;;;;;OAMG;IACI,sBAAsB,CAAC,cAAc,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,wBAAwB,EAAE;IAI3G;;;;;;;;;;;;;;;;;;OAkBG;IACI,8BAA8B,CACjC,cAAc,EAAE,MAAM,EACtB,gBAAgB,EAAE,MAAM,EACxB,IAAI,EAAE,QAAQ,GACf,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI;IAiCnC;;;;;;OAMG;IACI,yBAAyB,CAAC,IAAI,EAAE,QAAQ,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,wBAAwB,EAAE;IAuCrG;;;;OAIG;IACI,yBAAyB,CAAC,cAAc,EAAE,MAAM,GAAG;QAAC,gBAAgB,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAC;QAAC,mBAAmB,EAAE,MAAM,CAAA;KAAC;CAoB3I"}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
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
|
+
};
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.ResourcePermissionEngine = void 0;
|
|
4
10
|
const core_1 = require("@memberjunction/core");
|
|
5
11
|
/**
|
|
6
12
|
* Resource Permission Engine is used for accessing metadata about permissions for resources and also determining if a user has access to a resource and at what level.
|
|
7
13
|
*/
|
|
8
|
-
class ResourcePermissionEngine extends core_1.BaseEngine {
|
|
14
|
+
let ResourcePermissionEngine = class ResourcePermissionEngine extends core_1.BaseEngine {
|
|
9
15
|
/**
|
|
10
16
|
* Returns the global instance of the class. This is a singleton class, so there is only one instance of it in the application. Do not directly create new instances of it, always use this method to get the instance.
|
|
11
17
|
*/
|
|
@@ -17,7 +23,8 @@ class ResourcePermissionEngine extends core_1.BaseEngine {
|
|
|
17
23
|
{
|
|
18
24
|
Type: 'entity',
|
|
19
25
|
EntityName: 'Resource Permissions',
|
|
20
|
-
PropertyName: "_Permissions"
|
|
26
|
+
PropertyName: "_Permissions",
|
|
27
|
+
CacheLocal: true
|
|
21
28
|
},
|
|
22
29
|
{
|
|
23
30
|
Type: 'dataset',
|
|
@@ -26,7 +33,7 @@ class ResourcePermissionEngine extends core_1.BaseEngine {
|
|
|
26
33
|
DatasetResultHandling: "single_property"
|
|
27
34
|
}
|
|
28
35
|
];
|
|
29
|
-
await
|
|
36
|
+
await super.Load(c, provider, forceRefresh, contextUser);
|
|
30
37
|
}
|
|
31
38
|
get ResourceTypes() {
|
|
32
39
|
return this._ResourceTypes.ResourceTypes;
|
|
@@ -160,6 +167,9 @@ class ResourcePermissionEngine extends core_1.BaseEngine {
|
|
|
160
167
|
PrimaryKeyFieldName: entity.FirstPrimaryKey.Name
|
|
161
168
|
};
|
|
162
169
|
}
|
|
163
|
-
}
|
|
170
|
+
};
|
|
164
171
|
exports.ResourcePermissionEngine = ResourcePermissionEngine;
|
|
172
|
+
exports.ResourcePermissionEngine = ResourcePermissionEngine = __decorate([
|
|
173
|
+
(0, core_1.RegisterForStartup)()
|
|
174
|
+
], ResourcePermissionEngine);
|
|
165
175
|
//# sourceMappingURL=ResourcePermissionEngine.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourcePermissionEngine.js","sourceRoot":"","sources":["../../../src/custom/ResourcePermissions/ResourcePermissionEngine.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ResourcePermissionEngine.js","sourceRoot":"","sources":["../../../src/custom/ResourcePermissions/ResourcePermissionEngine.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAAqJ;AAGrJ;;GAEG;AAEI,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,iBAAoC;IAC9E;;OAEG;IACI,MAAM,KAAK,QAAQ;QACvB,OAAO,KAAK,CAAC,WAAW,EAA4B,CAAC;IACxD,CAAC;IAOM,KAAK,CAAC,MAAM,CAAC,YAAsB,EAAE,WAAsB,EAAE,QAA4B;QAC5F,MAAM,CAAC,GAAwC;YAC3C;gBACI,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE,sBAAsB;gBAClC,YAAY,EAAE,cAAc;gBAC5B,UAAU,EAAE,IAAI;aACnB;YACD;gBACI,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,eAAe;gBAC5B,YAAY,EAAE,gBAAgB;gBAC9B,qBAAqB,EAAE,iBAAiB;aAC3C;SACJ,CAAA;QACD,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;IAC7D,CAAC;IAED,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC;IAC7C,CAAC;IAED,IAA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+
*
|
|
4
|
+
* The EncryptionEngineBase provides metadata caching for encryption-related entities
|
|
5
|
+
* (keys, algorithms, sources) and can be used by both client and server code.
|
|
6
|
+
* Server-side implementations should extend this class to add the actual
|
|
7
|
+
* encryption/decryption operations.
|
|
8
|
+
*
|
|
9
|
+
* ## Usage
|
|
10
|
+
*
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { EncryptionEngineBase } from '@memberjunction/core-entities';
|
|
13
|
+
*
|
|
14
|
+
* // Configure the engine (loads metadata)
|
|
15
|
+
* await EncryptionEngineBase.Instance.Config(false, contextUser);
|
|
16
|
+
*
|
|
17
|
+
* // Access cached metadata
|
|
18
|
+
* const key = EncryptionEngineBase.Instance.GetKeyByID(keyId);
|
|
19
|
+
* const algorithm = EncryptionEngineBase.Instance.GetAlgorithmByID(algoId);
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @module @memberjunction/core-entities
|
|
23
|
+
*/
|
|
24
|
+
import { BaseEngine, IMetadataProvider, UserInfo } from "@memberjunction/core";
|
|
25
|
+
import { EncryptionKeyEntity, EncryptionAlgorithmEntity, EncryptionKeySourceEntity } from "../generated/entity_subclasses";
|
|
26
|
+
/**
|
|
27
|
+
* Configuration for a loaded encryption key, combining key, algorithm, and source data.
|
|
28
|
+
* This is a convenience type that aggregates related encryption configuration.
|
|
29
|
+
*/
|
|
30
|
+
export interface EncryptionKeyConfiguration {
|
|
31
|
+
/** The encryption key entity */
|
|
32
|
+
key: EncryptionKeyEntity;
|
|
33
|
+
/** The encryption algorithm entity */
|
|
34
|
+
algorithm: EncryptionAlgorithmEntity;
|
|
35
|
+
/** The key source entity */
|
|
36
|
+
source: EncryptionKeySourceEntity;
|
|
37
|
+
/** The marker to use for encrypted values (from key or default) */
|
|
38
|
+
marker: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Base engine class for encryption metadata caching.
|
|
42
|
+
*
|
|
43
|
+
* This class extends BaseEngine to provide automatic caching of encryption-related
|
|
44
|
+
* entities with auto-refresh when those entities are modified. It can be used in
|
|
45
|
+
* both client and server contexts.
|
|
46
|
+
*
|
|
47
|
+
* ## Features
|
|
48
|
+
*
|
|
49
|
+
* - Caches all encryption keys, algorithms, and sources
|
|
50
|
+
* - Auto-refreshes when entity data changes
|
|
51
|
+
* - Provides convenient lookup methods
|
|
52
|
+
* - Works in both client and server environments
|
|
53
|
+
*
|
|
54
|
+
* ## For Server-Side Encryption
|
|
55
|
+
*
|
|
56
|
+
* For actual encryption/decryption operations, use or extend the EncryptionEngine
|
|
57
|
+
* class in the @memberjunction/encryption package, which extends this base class.
|
|
58
|
+
*/
|
|
59
|
+
export declare class EncryptionEngineBase extends BaseEngine<EncryptionEngineBase> {
|
|
60
|
+
/**
|
|
61
|
+
* Cached array of encryption keys loaded from the database.
|
|
62
|
+
* @private
|
|
63
|
+
*/
|
|
64
|
+
private _encryptionKeys;
|
|
65
|
+
/**
|
|
66
|
+
* Cached array of encryption algorithms loaded from the database.
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
private _encryptionAlgorithms;
|
|
70
|
+
/**
|
|
71
|
+
* Cached array of encryption key sources loaded from the database.
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
private _encryptionKeySources;
|
|
75
|
+
/**
|
|
76
|
+
* Gets the singleton instance of the encryption engine base.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const engine = EncryptionEngineBase.Instance;
|
|
81
|
+
* await engine.Config(false, contextUser);
|
|
82
|
+
* const keys = engine.EncryptionKeys;
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
static get Instance(): EncryptionEngineBase;
|
|
86
|
+
/**
|
|
87
|
+
* Configures the engine by loading encryption metadata from the database.
|
|
88
|
+
*
|
|
89
|
+
* This method should be called before accessing any cached data. It loads
|
|
90
|
+
* all encryption keys, algorithms, and key sources into memory.
|
|
91
|
+
*
|
|
92
|
+
* @param forceRefresh - If true, reloads data even if already loaded
|
|
93
|
+
* @param contextUser - User context for database access (required server-side)
|
|
94
|
+
* @param provider - Optional metadata provider override
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* // Initial load
|
|
99
|
+
* await EncryptionEngineBase.Instance.Config(false, contextUser);
|
|
100
|
+
*
|
|
101
|
+
* // Force refresh after external changes
|
|
102
|
+
* await EncryptionEngineBase.Instance.Config(true, contextUser);
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
Config(forceRefresh?: boolean, contextUser?: UserInfo, provider?: IMetadataProvider): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Gets all cached encryption keys.
|
|
108
|
+
*
|
|
109
|
+
* @returns Array of all encryption key entities
|
|
110
|
+
*/
|
|
111
|
+
get EncryptionKeys(): EncryptionKeyEntity[];
|
|
112
|
+
/**
|
|
113
|
+
* Gets only active encryption keys.
|
|
114
|
+
*
|
|
115
|
+
* @returns Array of encryption keys where IsActive is true
|
|
116
|
+
*/
|
|
117
|
+
get ActiveEncryptionKeys(): EncryptionKeyEntity[];
|
|
118
|
+
/**
|
|
119
|
+
* Gets all cached encryption algorithms.
|
|
120
|
+
*
|
|
121
|
+
* @returns Array of all encryption algorithm entities
|
|
122
|
+
*/
|
|
123
|
+
get EncryptionAlgorithms(): EncryptionAlgorithmEntity[];
|
|
124
|
+
/**
|
|
125
|
+
* Gets only active encryption algorithms.
|
|
126
|
+
*
|
|
127
|
+
* @returns Array of encryption algorithms where IsActive is true
|
|
128
|
+
*/
|
|
129
|
+
get ActiveEncryptionAlgorithms(): EncryptionAlgorithmEntity[];
|
|
130
|
+
/**
|
|
131
|
+
* Gets all cached encryption key sources.
|
|
132
|
+
*
|
|
133
|
+
* @returns Array of all encryption key source entities
|
|
134
|
+
*/
|
|
135
|
+
get EncryptionKeySources(): EncryptionKeySourceEntity[];
|
|
136
|
+
/**
|
|
137
|
+
* Gets only active encryption key sources.
|
|
138
|
+
*
|
|
139
|
+
* @returns Array of encryption key sources where IsActive is true
|
|
140
|
+
*/
|
|
141
|
+
get ActiveEncryptionKeySources(): EncryptionKeySourceEntity[];
|
|
142
|
+
/**
|
|
143
|
+
* Gets an encryption key by its ID.
|
|
144
|
+
*
|
|
145
|
+
* @param keyId - The UUID of the encryption key
|
|
146
|
+
* @returns The encryption key entity, or undefined if not found
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* const key = engine.GetKeyByID('550e8400-e29b-41d4-a716-446655440000');
|
|
151
|
+
* if (key) {
|
|
152
|
+
* console.log(`Key: ${key.Name}, Status: ${key.Status}`);
|
|
153
|
+
* }
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
GetKeyByID(keyId: string): EncryptionKeyEntity | undefined;
|
|
157
|
+
/**
|
|
158
|
+
* Gets an encryption key by its name.
|
|
159
|
+
*
|
|
160
|
+
* @param name - The name of the encryption key (case-insensitive)
|
|
161
|
+
* @returns The encryption key entity, or undefined if not found
|
|
162
|
+
*/
|
|
163
|
+
GetKeyByName(name: string): EncryptionKeyEntity | undefined;
|
|
164
|
+
/**
|
|
165
|
+
* Gets an encryption algorithm by its ID.
|
|
166
|
+
*
|
|
167
|
+
* @param algorithmId - The UUID of the encryption algorithm
|
|
168
|
+
* @returns The encryption algorithm entity, or undefined if not found
|
|
169
|
+
*/
|
|
170
|
+
GetAlgorithmByID(algorithmId: string): EncryptionAlgorithmEntity | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* Gets an encryption algorithm by its name.
|
|
173
|
+
*
|
|
174
|
+
* @param name - The name of the algorithm (e.g., 'AES-256-GCM')
|
|
175
|
+
* @returns The encryption algorithm entity, or undefined if not found
|
|
176
|
+
*/
|
|
177
|
+
GetAlgorithmByName(name: string): EncryptionAlgorithmEntity | undefined;
|
|
178
|
+
/**
|
|
179
|
+
* Gets an encryption key source by its ID.
|
|
180
|
+
*
|
|
181
|
+
* @param sourceId - The UUID of the key source
|
|
182
|
+
* @returns The encryption key source entity, or undefined if not found
|
|
183
|
+
*/
|
|
184
|
+
GetKeySourceByID(sourceId: string): EncryptionKeySourceEntity | undefined;
|
|
185
|
+
/**
|
|
186
|
+
* Gets an encryption key source by its driver class name.
|
|
187
|
+
*
|
|
188
|
+
* @param driverClass - The driver class name (e.g., 'EnvVarKeySource')
|
|
189
|
+
* @returns The encryption key source entity, or undefined if not found
|
|
190
|
+
*/
|
|
191
|
+
GetKeySourceByDriverClass(driverClass: string): EncryptionKeySourceEntity | undefined;
|
|
192
|
+
/**
|
|
193
|
+
* Gets the full configuration for an encryption key, including its algorithm and source.
|
|
194
|
+
*
|
|
195
|
+
* This method aggregates the key, its associated algorithm, and source into
|
|
196
|
+
* a single configuration object for convenience.
|
|
197
|
+
*
|
|
198
|
+
* @param keyId - The UUID of the encryption key
|
|
199
|
+
* @returns The full key configuration, or undefined if key not found
|
|
200
|
+
* @throws Error if the key's algorithm or source cannot be found
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```typescript
|
|
204
|
+
* const config = engine.GetKeyConfiguration(keyId);
|
|
205
|
+
* if (config) {
|
|
206
|
+
* console.log(`Algorithm: ${config.algorithm.Name}`);
|
|
207
|
+
* console.log(`Source: ${config.source.DriverClass}`);
|
|
208
|
+
* console.log(`Marker: ${config.marker}`);
|
|
209
|
+
* }
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
GetKeyConfiguration(keyId: string): EncryptionKeyConfiguration | undefined;
|
|
213
|
+
/**
|
|
214
|
+
* Validates that a key is usable for encryption operations.
|
|
215
|
+
*
|
|
216
|
+
* Checks that the key, its algorithm, and its source are all active and valid.
|
|
217
|
+
*
|
|
218
|
+
* @param keyId - The UUID of the encryption key to validate
|
|
219
|
+
* @returns Object with isValid boolean and optional error message
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```typescript
|
|
223
|
+
* const result = engine.ValidateKey(keyId);
|
|
224
|
+
* if (!result.isValid) {
|
|
225
|
+
* console.error(`Key validation failed: ${result.error}`);
|
|
226
|
+
* }
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
ValidateKey(keyId: string): {
|
|
230
|
+
isValid: boolean;
|
|
231
|
+
error?: string;
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Gets the marker prefix for a specific encryption key.
|
|
235
|
+
*
|
|
236
|
+
* @param keyId - The UUID of the encryption key
|
|
237
|
+
* @returns The marker string (from key or default ENCRYPTION_MARKER)
|
|
238
|
+
*/
|
|
239
|
+
GetKeyMarker(keyId: string): string;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Tree-shaking prevention function.
|
|
243
|
+
* Call this to ensure the EncryptionEngineBase class is included in the build.
|
|
244
|
+
*/
|
|
245
|
+
export declare function LoadEncryptionEngineBase(): void;
|
|
246
|
+
//# sourceMappingURL=EncryptionEngineBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EncryptionEngineBase.d.ts","sourceRoot":"","sources":["../../src/engines/EncryptionEngineBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,UAAU,EAA4B,iBAAiB,EAAE,QAAQ,EAAsB,MAAM,sBAAsB,CAAC;AAE7H,OAAO,EACH,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EAC5B,MAAM,gCAAgC,CAAC;AAExC;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACvC,gCAAgC;IAChC,GAAG,EAAE,mBAAmB,CAAC;IACzB,sCAAsC;IACtC,SAAS,EAAE,yBAAyB,CAAC;IACrC,4BAA4B;IAC5B,MAAM,EAAE,yBAAyB,CAAC;IAClC,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBACa,oBAAqB,SAAQ,UAAU,CAAC,oBAAoB,CAAC;I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S;IAS5F;;;;;;;;;;;;;;;;;;;OAmBG;IACI,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,0BAA0B,GAAG,SAAS;IA8BjF;;;;;;;;;;;;;;;OAeG;IACI,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;IAmCvE;;;;;OAKG;IACI,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;CAI7C;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C"}
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Base encryption engine for MemberJunction field-level encryption.
|
|
4
|
+
*
|
|
5
|
+
* The EncryptionEngineBase provides metadata caching for encryption-related entities
|
|
6
|
+
* (keys, algorithms, sources) and can be used by both client and server code.
|
|
7
|
+
* Server-side implementations should extend this class to add the actual
|
|
8
|
+
* encryption/decryption operations.
|
|
9
|
+
*
|
|
10
|
+
* ## Usage
|
|
11
|
+
*
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { EncryptionEngineBase } from '@memberjunction/core-entities';
|
|
14
|
+
*
|
|
15
|
+
* // Configure the engine (loads metadata)
|
|
16
|
+
* await EncryptionEngineBase.Instance.Config(false, contextUser);
|
|
17
|
+
*
|
|
18
|
+
* // Access cached metadata
|
|
19
|
+
* const key = EncryptionEngineBase.Instance.GetKeyByID(keyId);
|
|
20
|
+
* const algorithm = EncryptionEngineBase.Instance.GetAlgorithmByID(algoId);
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @module @memberjunction/core-entities
|
|
24
|
+
*/
|
|
25
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
26
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
27
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
28
|
+
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;
|
|
29
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.LoadEncryptionEngineBase = exports.EncryptionEngineBase = void 0;
|
|
33
|
+
const core_1 = require("@memberjunction/core");
|
|
34
|
+
const global_1 = require("@memberjunction/global");
|
|
35
|
+
/**
|
|
36
|
+
* Base engine class for encryption metadata caching.
|
|
37
|
+
*
|
|
38
|
+
* This class extends BaseEngine to provide automatic caching of encryption-related
|
|
39
|
+
* entities with auto-refresh when those entities are modified. It can be used in
|
|
40
|
+
* both client and server contexts.
|
|
41
|
+
*
|
|
42
|
+
* ## Features
|
|
43
|
+
*
|
|
44
|
+
* - Caches all encryption keys, algorithms, and sources
|
|
45
|
+
* - Auto-refreshes when entity data changes
|
|
46
|
+
* - Provides convenient lookup methods
|
|
47
|
+
* - Works in both client and server environments
|
|
48
|
+
*
|
|
49
|
+
* ## For Server-Side Encryption
|
|
50
|
+
*
|
|
51
|
+
* For actual encryption/decryption operations, use or extend the EncryptionEngine
|
|
52
|
+
* class in the @memberjunction/encryption package, which extends this base class.
|
|
53
|
+
*/
|
|
54
|
+
let EncryptionEngineBase = class EncryptionEngineBase extends core_1.BaseEngine {
|
|
55
|
+
constructor() {
|
|
56
|
+
super(...arguments);
|
|
57
|
+
/**
|
|
58
|
+
* Cached array of encryption keys loaded from the database.
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
61
|
+
this._encryptionKeys = [];
|
|
62
|
+
/**
|
|
63
|
+
* Cached array of encryption algorithms loaded from the database.
|
|
64
|
+
* @private
|
|
65
|
+
*/
|
|
66
|
+
this._encryptionAlgorithms = [];
|
|
67
|
+
/**
|
|
68
|
+
* Cached array of encryption key sources loaded from the database.
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
this._encryptionKeySources = [];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Gets the singleton instance of the encryption engine base.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const engine = EncryptionEngineBase.Instance;
|
|
79
|
+
* await engine.Config(false, contextUser);
|
|
80
|
+
* const keys = engine.EncryptionKeys;
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
static get Instance() {
|
|
84
|
+
return super.getInstance();
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Configures the engine by loading encryption metadata from the database.
|
|
88
|
+
*
|
|
89
|
+
* This method should be called before accessing any cached data. It loads
|
|
90
|
+
* all encryption keys, algorithms, and key sources into memory.
|
|
91
|
+
*
|
|
92
|
+
* @param forceRefresh - If true, reloads data even if already loaded
|
|
93
|
+
* @param contextUser - User context for database access (required server-side)
|
|
94
|
+
* @param provider - Optional metadata provider override
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* // Initial load
|
|
99
|
+
* await EncryptionEngineBase.Instance.Config(false, contextUser);
|
|
100
|
+
*
|
|
101
|
+
* // Force refresh after external changes
|
|
102
|
+
* await EncryptionEngineBase.Instance.Config(true, contextUser);
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
async Config(forceRefresh, contextUser, provider) {
|
|
106
|
+
const configs = [
|
|
107
|
+
{
|
|
108
|
+
PropertyName: '_encryptionKeys',
|
|
109
|
+
EntityName: 'MJ: Encryption Keys',
|
|
110
|
+
CacheLocal: true
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
PropertyName: '_encryptionAlgorithms',
|
|
114
|
+
EntityName: 'MJ: Encryption Algorithms',
|
|
115
|
+
CacheLocal: true
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
PropertyName: '_encryptionKeySources',
|
|
119
|
+
EntityName: 'MJ: Encryption Key Sources',
|
|
120
|
+
CacheLocal: true
|
|
121
|
+
}
|
|
122
|
+
];
|
|
123
|
+
await this.Load(configs, provider, forceRefresh, contextUser);
|
|
124
|
+
}
|
|
125
|
+
// ========================================================================
|
|
126
|
+
// GETTERS FOR CACHED DATA
|
|
127
|
+
// ========================================================================
|
|
128
|
+
/**
|
|
129
|
+
* Gets all cached encryption keys.
|
|
130
|
+
*
|
|
131
|
+
* @returns Array of all encryption key entities
|
|
132
|
+
*/
|
|
133
|
+
get EncryptionKeys() {
|
|
134
|
+
return this._encryptionKeys;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Gets only active encryption keys.
|
|
138
|
+
*
|
|
139
|
+
* @returns Array of encryption keys where IsActive is true
|
|
140
|
+
*/
|
|
141
|
+
get ActiveEncryptionKeys() {
|
|
142
|
+
return this._encryptionKeys.filter(k => k.IsActive);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Gets all cached encryption algorithms.
|
|
146
|
+
*
|
|
147
|
+
* @returns Array of all encryption algorithm entities
|
|
148
|
+
*/
|
|
149
|
+
get EncryptionAlgorithms() {
|
|
150
|
+
return this._encryptionAlgorithms;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Gets only active encryption algorithms.
|
|
154
|
+
*
|
|
155
|
+
* @returns Array of encryption algorithms where IsActive is true
|
|
156
|
+
*/
|
|
157
|
+
get ActiveEncryptionAlgorithms() {
|
|
158
|
+
return this._encryptionAlgorithms.filter(a => a.IsActive);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Gets all cached encryption key sources.
|
|
162
|
+
*
|
|
163
|
+
* @returns Array of all encryption key source entities
|
|
164
|
+
*/
|
|
165
|
+
get EncryptionKeySources() {
|
|
166
|
+
return this._encryptionKeySources;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Gets only active encryption key sources.
|
|
170
|
+
*
|
|
171
|
+
* @returns Array of encryption key sources where IsActive is true
|
|
172
|
+
*/
|
|
173
|
+
get ActiveEncryptionKeySources() {
|
|
174
|
+
return this._encryptionKeySources.filter(s => s.IsActive);
|
|
175
|
+
}
|
|
176
|
+
// ========================================================================
|
|
177
|
+
// LOOKUP METHODS
|
|
178
|
+
// ========================================================================
|
|
179
|
+
/**
|
|
180
|
+
* Gets an encryption key by its ID.
|
|
181
|
+
*
|
|
182
|
+
* @param keyId - The UUID of the encryption key
|
|
183
|
+
* @returns The encryption key entity, or undefined if not found
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* const key = engine.GetKeyByID('550e8400-e29b-41d4-a716-446655440000');
|
|
188
|
+
* if (key) {
|
|
189
|
+
* console.log(`Key: ${key.Name}, Status: ${key.Status}`);
|
|
190
|
+
* }
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
GetKeyByID(keyId) {
|
|
194
|
+
return this._encryptionKeys.find(k => k.ID === keyId);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Gets an encryption key by its name.
|
|
198
|
+
*
|
|
199
|
+
* @param name - The name of the encryption key (case-insensitive)
|
|
200
|
+
* @returns The encryption key entity, or undefined if not found
|
|
201
|
+
*/
|
|
202
|
+
GetKeyByName(name) {
|
|
203
|
+
const lowerName = name.trim().toLowerCase();
|
|
204
|
+
return this._encryptionKeys.find(k => k.Name.trim().toLowerCase() === lowerName);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Gets an encryption algorithm by its ID.
|
|
208
|
+
*
|
|
209
|
+
* @param algorithmId - The UUID of the encryption algorithm
|
|
210
|
+
* @returns The encryption algorithm entity, or undefined if not found
|
|
211
|
+
*/
|
|
212
|
+
GetAlgorithmByID(algorithmId) {
|
|
213
|
+
return this._encryptionAlgorithms.find(a => a.ID === algorithmId);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Gets an encryption algorithm by its name.
|
|
217
|
+
*
|
|
218
|
+
* @param name - The name of the algorithm (e.g., 'AES-256-GCM')
|
|
219
|
+
* @returns The encryption algorithm entity, or undefined if not found
|
|
220
|
+
*/
|
|
221
|
+
GetAlgorithmByName(name) {
|
|
222
|
+
const lowerName = name.trim().toLowerCase();
|
|
223
|
+
return this._encryptionAlgorithms.find(a => a.Name.trim().toLowerCase() === lowerName);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Gets an encryption key source by its ID.
|
|
227
|
+
*
|
|
228
|
+
* @param sourceId - The UUID of the key source
|
|
229
|
+
* @returns The encryption key source entity, or undefined if not found
|
|
230
|
+
*/
|
|
231
|
+
GetKeySourceByID(sourceId) {
|
|
232
|
+
return this._encryptionKeySources.find(s => s.ID === sourceId);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Gets an encryption key source by its driver class name.
|
|
236
|
+
*
|
|
237
|
+
* @param driverClass - The driver class name (e.g., 'EnvVarKeySource')
|
|
238
|
+
* @returns The encryption key source entity, or undefined if not found
|
|
239
|
+
*/
|
|
240
|
+
GetKeySourceByDriverClass(driverClass) {
|
|
241
|
+
const lowerClass = driverClass.trim().toLowerCase();
|
|
242
|
+
return this._encryptionKeySources.find(s => s.DriverClass.trim().toLowerCase() === lowerClass);
|
|
243
|
+
}
|
|
244
|
+
// ========================================================================
|
|
245
|
+
// CONVENIENCE METHODS
|
|
246
|
+
// ========================================================================
|
|
247
|
+
/**
|
|
248
|
+
* Gets the full configuration for an encryption key, including its algorithm and source.
|
|
249
|
+
*
|
|
250
|
+
* This method aggregates the key, its associated algorithm, and source into
|
|
251
|
+
* a single configuration object for convenience.
|
|
252
|
+
*
|
|
253
|
+
* @param keyId - The UUID of the encryption key
|
|
254
|
+
* @returns The full key configuration, or undefined if key not found
|
|
255
|
+
* @throws Error if the key's algorithm or source cannot be found
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* ```typescript
|
|
259
|
+
* const config = engine.GetKeyConfiguration(keyId);
|
|
260
|
+
* if (config) {
|
|
261
|
+
* console.log(`Algorithm: ${config.algorithm.Name}`);
|
|
262
|
+
* console.log(`Source: ${config.source.DriverClass}`);
|
|
263
|
+
* console.log(`Marker: ${config.marker}`);
|
|
264
|
+
* }
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
GetKeyConfiguration(keyId) {
|
|
268
|
+
const key = this.GetKeyByID(keyId);
|
|
269
|
+
if (!key) {
|
|
270
|
+
return undefined;
|
|
271
|
+
}
|
|
272
|
+
const algorithm = this.GetAlgorithmByID(key.EncryptionAlgorithmID);
|
|
273
|
+
if (!algorithm) {
|
|
274
|
+
throw new Error(`Encryption algorithm not found for key "${key.Name}": ${key.EncryptionAlgorithmID}. ` +
|
|
275
|
+
'The algorithm may have been deleted.');
|
|
276
|
+
}
|
|
277
|
+
const source = this.GetKeySourceByID(key.EncryptionKeySourceID);
|
|
278
|
+
if (!source) {
|
|
279
|
+
throw new Error(`Encryption key source not found for key "${key.Name}": ${key.EncryptionKeySourceID}. ` +
|
|
280
|
+
'The key source may have been deleted.');
|
|
281
|
+
}
|
|
282
|
+
return {
|
|
283
|
+
key,
|
|
284
|
+
algorithm,
|
|
285
|
+
source,
|
|
286
|
+
marker: key.Marker || global_1.ENCRYPTION_MARKER
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Validates that a key is usable for encryption operations.
|
|
291
|
+
*
|
|
292
|
+
* Checks that the key, its algorithm, and its source are all active and valid.
|
|
293
|
+
*
|
|
294
|
+
* @param keyId - The UUID of the encryption key to validate
|
|
295
|
+
* @returns Object with isValid boolean and optional error message
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```typescript
|
|
299
|
+
* const result = engine.ValidateKey(keyId);
|
|
300
|
+
* if (!result.isValid) {
|
|
301
|
+
* console.error(`Key validation failed: ${result.error}`);
|
|
302
|
+
* }
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
305
|
+
ValidateKey(keyId) {
|
|
306
|
+
const key = this.GetKeyByID(keyId);
|
|
307
|
+
if (!key) {
|
|
308
|
+
return { isValid: false, error: `Encryption key not found: ${keyId}` };
|
|
309
|
+
}
|
|
310
|
+
if (!key.IsActive) {
|
|
311
|
+
return { isValid: false, error: `Encryption key "${key.Name}" is not active` };
|
|
312
|
+
}
|
|
313
|
+
if (key.Status === 'Expired') {
|
|
314
|
+
return { isValid: false, error: `Encryption key "${key.Name}" has expired` };
|
|
315
|
+
}
|
|
316
|
+
const algorithm = this.GetAlgorithmByID(key.EncryptionAlgorithmID);
|
|
317
|
+
if (!algorithm) {
|
|
318
|
+
return { isValid: false, error: `Algorithm not found for key "${key.Name}"` };
|
|
319
|
+
}
|
|
320
|
+
if (!algorithm.IsActive) {
|
|
321
|
+
return { isValid: false, error: `Algorithm "${algorithm.Name}" is not active` };
|
|
322
|
+
}
|
|
323
|
+
const source = this.GetKeySourceByID(key.EncryptionKeySourceID);
|
|
324
|
+
if (!source) {
|
|
325
|
+
return { isValid: false, error: `Key source not found for key "${key.Name}"` };
|
|
326
|
+
}
|
|
327
|
+
if (!source.IsActive) {
|
|
328
|
+
return { isValid: false, error: `Key source "${source.Name}" is not active` };
|
|
329
|
+
}
|
|
330
|
+
return { isValid: true };
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Gets the marker prefix for a specific encryption key.
|
|
334
|
+
*
|
|
335
|
+
* @param keyId - The UUID of the encryption key
|
|
336
|
+
* @returns The marker string (from key or default ENCRYPTION_MARKER)
|
|
337
|
+
*/
|
|
338
|
+
GetKeyMarker(keyId) {
|
|
339
|
+
const key = this.GetKeyByID(keyId);
|
|
340
|
+
return key?.Marker || global_1.ENCRYPTION_MARKER;
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
exports.EncryptionEngineBase = EncryptionEngineBase;
|
|
344
|
+
exports.EncryptionEngineBase = EncryptionEngineBase = __decorate([
|
|
345
|
+
(0, core_1.RegisterForStartup)()
|
|
346
|
+
], EncryptionEngineBase);
|
|
347
|
+
/**
|
|
348
|
+
* Tree-shaking prevention function.
|
|
349
|
+
* Call this to ensure the EncryptionEngineBase class is included in the build.
|
|
350
|
+
*/
|
|
351
|
+
function LoadEncryptionEngineBase() {
|
|
352
|
+
// This function exists to prevent tree-shaking from removing the class
|
|
353
|
+
}
|
|
354
|
+
exports.LoadEncryptionEngineBase = LoadEncryptionEngineBase;
|
|
355
|
+
//# sourceMappingURL=EncryptionEngineBase.js.map
|