@twin.org/api-service 0.0.3-next.43 → 0.0.3-next.45

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.
Files changed (43) hide show
  1. package/dist/es/healthService.js +3 -3
  2. package/dist/es/healthService.js.map +1 -1
  3. package/dist/es/index.js +3 -3
  4. package/dist/es/index.js.map +1 -1
  5. package/dist/es/informationService.js +2 -2
  6. package/dist/es/informationService.js.map +1 -1
  7. package/dist/es/models/IPlatformServiceConfig.js +4 -0
  8. package/dist/es/models/IPlatformServiceConfig.js.map +1 -0
  9. package/dist/es/models/IPlatformServiceConstructorOptions.js +2 -0
  10. package/dist/es/models/IPlatformServiceConstructorOptions.js.map +1 -0
  11. package/dist/es/platformService.js +76 -0
  12. package/dist/es/platformService.js.map +1 -0
  13. package/dist/es/restEntryPoints.js +3 -0
  14. package/dist/es/restEntryPoints.js.map +1 -1
  15. package/dist/types/healthService.d.ts +2 -2
  16. package/dist/types/index.d.ts +3 -3
  17. package/dist/types/informationService.d.ts +2 -2
  18. package/dist/types/models/IPlatformServiceConfig.d.ts +10 -0
  19. package/dist/types/models/IPlatformServiceConstructorOptions.d.ts +15 -0
  20. package/dist/types/platformService.d.ts +32 -0
  21. package/dist/types/restEntryPoints.d.ts +3 -0
  22. package/docs/changelog.md +28 -0
  23. package/docs/reference/classes/HealthService.md +2 -2
  24. package/docs/reference/classes/InformationService.md +2 -2
  25. package/docs/reference/classes/PlatformService.md +97 -0
  26. package/docs/reference/index.md +3 -3
  27. package/docs/reference/interfaces/IPlatformServiceConfig.md +17 -0
  28. package/docs/reference/interfaces/IPlatformServiceConstructorOptions.md +25 -0
  29. package/docs/reference/variables/restEntryPoints.md +2 -0
  30. package/locales/en.json +0 -6
  31. package/package.json +3 -2
  32. package/dist/es/models/IUrlTransformerServiceConfig.js +0 -4
  33. package/dist/es/models/IUrlTransformerServiceConfig.js.map +0 -1
  34. package/dist/es/models/IUrlTransformerServiceConstructorOptions.js +0 -2
  35. package/dist/es/models/IUrlTransformerServiceConstructorOptions.js.map +0 -1
  36. package/dist/es/urlTransformerService.js +0 -256
  37. package/dist/es/urlTransformerService.js.map +0 -1
  38. package/dist/types/models/IUrlTransformerServiceConfig.d.ts +0 -19
  39. package/dist/types/models/IUrlTransformerServiceConstructorOptions.d.ts +0 -15
  40. package/dist/types/urlTransformerService.d.ts +0 -94
  41. package/docs/reference/classes/UrlTransformerService.md +0 -379
  42. package/docs/reference/interfaces/IUrlTransformerServiceConfig.md +0 -32
  43. package/docs/reference/interfaces/IUrlTransformerServiceConstructorOptions.md +0 -25
@@ -0,0 +1,25 @@
1
+ # Interface: IPlatformServiceConstructorOptions
2
+
3
+ Options for the Platform Service constructor.
4
+
5
+ ## Properties
6
+
7
+ ### tenantEntityStorageType? {#tenantentitystoragetype}
8
+
9
+ > `optional` **tenantEntityStorageType?**: `string`
10
+
11
+ The entity storage for the tenants.
12
+
13
+ #### Default
14
+
15
+ ```ts
16
+ tenant
17
+ ```
18
+
19
+ ***
20
+
21
+ ### config? {#config}
22
+
23
+ > `optional` **config?**: [`IPlatformServiceConfig`](IPlatformServiceConfig.md)
24
+
25
+ Configuration for the service.
@@ -1,3 +1,5 @@
1
1
  # Variable: restEntryPoints
2
2
 
3
3
  > `const` **restEntryPoints**: `IRestRouteEntryPoint`[]
4
+
5
+ REST entry points for the information and health services.
package/locales/en.json CHANGED
@@ -1,11 +1,5 @@
1
1
  {
2
2
  "error": {
3
- "urlTransformerService": {
4
- "encryptionUnavailable": "Encryption is unavailable because no nodeId is configured",
5
- "decryptionUnavailable": "Decryption is unavailable because no nodeId is configured",
6
- "encryptionFailed": "An error occurred during encryption",
7
- "decryptionFailed": "An error occurred during decryption"
8
- },
9
3
  "healthService": {
10
4
  "componentHealthCheckFailed": "Health check failed for component \"{className}\""
11
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/api-service",
3
- "version": "0.0.3-next.43",
3
+ "version": "0.0.3-next.45",
4
4
  "description": "Information and hosting service implementations with generated REST route handlers.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,10 +14,11 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/api-models": "0.0.3-next.43",
17
+ "@twin.org/api-models": "0.0.3-next.45",
18
18
  "@twin.org/context": "next",
19
19
  "@twin.org/core": "next",
20
20
  "@twin.org/engine-models": "next",
21
+ "@twin.org/entity-storage-models": "next",
21
22
  "@twin.org/logging-models": "next",
22
23
  "@twin.org/nameof": "next",
23
24
  "@twin.org/vault-models": "next",
@@ -1,4 +0,0 @@
1
- // Copyright 2024 IOTA Stiftung.
2
- // SPDX-License-Identifier: Apache-2.0.
3
- export {};
4
- //# sourceMappingURL=IUrlTransformerServiceConfig.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IUrlTransformerServiceConfig.js","sourceRoot":"","sources":["../../../src/models/IUrlTransformerServiceConfig.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Configuration for the URL transformer service.\n */\nexport interface IUrlTransformerServiceConfig {\n\t/**\n\t * The name of the key to retrieve from the vault for encryption/decryption of parameters.\n\t * @default param-encryption\n\t */\n\tparamEncryptionKeyName?: string;\n\n\t/**\n\t * A dictionary mapping logical token identifiers to their URL query parameter names.\n\t * For example: tenant => tenant-token maps the logical id \"tenant\" to the\n\t * query param \"tenant-token\". When an id is not present the id itself is used as\n\t * the param name.\n\t */\n\tqueryParamNames?: { [id: string]: string };\n}\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=IUrlTransformerServiceConstructorOptions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IUrlTransformerServiceConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IUrlTransformerServiceConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IUrlTransformerServiceConfig } from \"./IUrlTransformerServiceConfig.js\";\n\n/**\n * Options for the UrlTransformerService constructor.\n */\nexport interface IUrlTransformerServiceConstructorOptions {\n\t/**\n\t * The vault connector type.\n\t * @default vault\n\t */\n\tvaultConnectorType?: string;\n\n\t/**\n\t * The configuration for the service.\n\t */\n\tconfig?: IUrlTransformerServiceConfig;\n}\n"]}
@@ -1,256 +0,0 @@
1
- import { ContextIdKeys, ContextIdStore } from "@twin.org/context";
2
- import { BaseError, Converter, GeneralError, Guards, Is, ObjectHelper, RandomHelper, Uint8ArrayHelper } from "@twin.org/core";
3
- import { VaultConnectorFactory, VaultEncryptionType } from "@twin.org/vault-models";
4
- /**
5
- * The URL transformer service for encrypting and decrypting URL parameters.
6
- */
7
- export class UrlTransformerService {
8
- /**
9
- * Runtime name for the class.
10
- */
11
- static CLASS_NAME = "UrlTransformerService";
12
- /**
13
- * The prefix to use for encrypted query parameters.
14
- * @internal
15
- */
16
- static _KEY_PREFIX = "x-enc-";
17
- /**
18
- * The default name for the parameter encryption key query parameter.
19
- * @internal
20
- */
21
- static _DEFAULT_PARAM_ENCRYPTION_KEY_NAME = "param-encryption";
22
- /**
23
- * The vault connector.
24
- * @internal
25
- */
26
- _vaultConnector;
27
- /**
28
- * The name of the key to retrieve from the vault for encryption/decryption of parameters.
29
- * @internal
30
- */
31
- _paramEncryptionKeyName;
32
- /**
33
- * Maps logical token ids to their URL query parameter names.
34
- * @internal
35
- */
36
- _queryParamNames;
37
- /**
38
- * The node identity, captured at start.
39
- * @internal
40
- */
41
- _nodeId;
42
- /**
43
- * Create a new instance of UrlTransformerService.
44
- * @param options The options to create the service.
45
- */
46
- constructor(options) {
47
- this._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? "vault");
48
- this._paramEncryptionKeyName =
49
- options?.config?.paramEncryptionKeyName ??
50
- UrlTransformerService._DEFAULT_PARAM_ENCRYPTION_KEY_NAME;
51
- this._queryParamNames = options?.config?.queryParamNames ?? {};
52
- }
53
- /**
54
- * Returns the class name of the component.
55
- * @returns The class name of the component.
56
- */
57
- className() {
58
- return UrlTransformerService.CLASS_NAME;
59
- }
60
- /**
61
- * The component needs to be started when the node is initialized.
62
- * @returns Nothing.
63
- */
64
- async start() {
65
- const contextIds = await ContextIdStore.getContextIds();
66
- this._nodeId = contextIds?.[ContextIdKeys.Node];
67
- }
68
- /**
69
- * Encrypt a named token value and append it as a query parameter to the given URL.
70
- * @param url The URL to append the encrypted token to.
71
- * @param id The logical token identifier (e.g. "tenant").
72
- * @param value The value to encrypt and add.
73
- * @returns The URL with the encrypted token added as a query parameter.
74
- */
75
- async addEncryptedQueryParamToUrl(url, id, value) {
76
- const paramName = this._queryParamNames[id] ?? id;
77
- return this.addEncryptedToUrl(url, { [paramName]: value });
78
- }
79
- /**
80
- * Get a named token value from the query parameters.
81
- * @param queryParams The HTTP request query containing the parameters.
82
- * @param id The logical token identifier (e.g. "tenant").
83
- * @returns The decrypted token value if it exists.
84
- */
85
- async getEncryptedQueryParam(queryParams, id) {
86
- const paramName = this._queryParamNames[id] ?? id;
87
- const decrypted = await this.getDecryptedFromQueryParams(queryParams, [paramName]);
88
- return decrypted[paramName];
89
- }
90
- /**
91
- * Add encrypted key/value pairs to a URL's query string.
92
- * @param url The base URL to add parameters to.
93
- * @param params The key/value pairs to encrypt and append.
94
- * @returns The URL with the encrypted parameters added.
95
- */
96
- async addEncryptedToUrl(url, params) {
97
- let urlObj;
98
- try {
99
- urlObj = new URL(url);
100
- }
101
- catch {
102
- return url;
103
- }
104
- const query = {};
105
- for (const [key, value] of urlObj.searchParams.entries()) {
106
- query[key] = value;
107
- }
108
- const keysToEncrypt = Object.keys(params);
109
- for (const [key, value] of Object.entries(params)) {
110
- query[key] = value;
111
- }
112
- await this.encryptQueryParams(query, keysToEncrypt);
113
- urlObj.search = "";
114
- for (const [key, value] of Object.entries(query)) {
115
- urlObj.searchParams.set(key, value);
116
- }
117
- return urlObj.toString();
118
- }
119
- /**
120
- * Get an encrypted value from a URL's query string.
121
- * @param url The URL to extract the encrypted value from.
122
- * @param id The logical identifier for the value to retrieve (e.g. "tenant").
123
- * @returns The decrypted value if it exists.
124
- */
125
- async getEncryptedFromUrl(url, id) {
126
- let urlObj;
127
- try {
128
- urlObj = new URL(url);
129
- }
130
- catch {
131
- return undefined;
132
- }
133
- const name = this.getParamName(id);
134
- if (!Is.stringValue(name)) {
135
- return undefined;
136
- }
137
- if (urlObj.searchParams.has(name)) {
138
- const encryptedValue = urlObj.searchParams.get(name);
139
- if (Is.stringValue(encryptedValue)) {
140
- return this.decryptParam(encryptedValue);
141
- }
142
- return undefined;
143
- }
144
- }
145
- /**
146
- * Decrypt specified keys from a query parameter object and return their plain-text values.
147
- * @param queryParams The HTTP request query containing the encrypted parameters.
148
- * @param keys The keys to decrypt.
149
- * @returns A map of the decrypted key/value pairs that were present.
150
- */
151
- async getDecryptedFromQueryParams(queryParams, keys) {
152
- const queryParamsClone = ObjectHelper.clone(queryParams) ?? {};
153
- await this.decryptQueryParams(queryParamsClone, keys);
154
- const result = {};
155
- for (const key of keys) {
156
- if (Is.stringValue(queryParamsClone[key])) {
157
- result[key] = queryParamsClone[key];
158
- }
159
- }
160
- return result;
161
- }
162
- /**
163
- * Encrypt query parameters.
164
- * @param httpRequestQuery The HTTP request query containing the parameters to encrypt.
165
- * @param keys The keys of the parameters to encrypt.
166
- * @returns A promise that resolves when the query parameters have been encrypted.
167
- */
168
- async encryptQueryParams(httpRequestQuery, keys) {
169
- if (Is.empty(httpRequestQuery)) {
170
- return;
171
- }
172
- for (const key of keys) {
173
- if (Is.stringValue(httpRequestQuery[key])) {
174
- const encryptedValue = await this.encryptParam(httpRequestQuery[key]);
175
- httpRequestQuery[`${UrlTransformerService._KEY_PREFIX}${key}`] = encryptedValue;
176
- delete httpRequestQuery[key];
177
- }
178
- }
179
- }
180
- /**
181
- * Decrypt query parameters.
182
- * @param httpRequestQuery The HTTP request query containing the encrypted values.
183
- * @param keys The keys of the parameters to decrypt.
184
- * @returns A promise that resolves when the query parameters have been decrypted.
185
- */
186
- async decryptQueryParams(httpRequestQuery, keys) {
187
- if (Is.empty(httpRequestQuery)) {
188
- return;
189
- }
190
- for (const key of Object.keys(httpRequestQuery)) {
191
- if (key.startsWith(UrlTransformerService._KEY_PREFIX)) {
192
- const originalKey = key.slice(UrlTransformerService._KEY_PREFIX.length);
193
- if (keys.includes(originalKey)) {
194
- const decryptedValue = await this.decryptParam(httpRequestQuery[key]);
195
- httpRequestQuery[originalKey] = decryptedValue;
196
- delete httpRequestQuery[key];
197
- }
198
- }
199
- }
200
- }
201
- /**
202
- * Encrypt a parameter value.
203
- * @param paramValue The value of the parameter to encrypt.
204
- * @returns A promise that resolves to the encrypted value of the parameter.
205
- */
206
- async encryptParam(paramValue) {
207
- Guards.stringValue(UrlTransformerService.CLASS_NAME, "paramValue", paramValue);
208
- if (Is.empty(this._nodeId)) {
209
- throw new GeneralError(UrlTransformerService.CLASS_NAME, "encryptionUnavailable");
210
- }
211
- try {
212
- const salt = RandomHelper.generate(8);
213
- const encryptedParamValue = await this._vaultConnector.encrypt(`${this._nodeId}/${this._paramEncryptionKeyName}`, VaultEncryptionType.ChaCha20Poly1305, Uint8ArrayHelper.concat([salt, Converter.utf8ToBytes(paramValue)]));
214
- if (!Is.uint8Array(encryptedParamValue)) {
215
- throw new GeneralError(UrlTransformerService.CLASS_NAME, "encryptionFailed");
216
- }
217
- return Converter.bytesToBase64Url(encryptedParamValue);
218
- }
219
- catch (err) {
220
- throw new GeneralError(UrlTransformerService.CLASS_NAME, "encryptionFailed", undefined, BaseError.fromError(err));
221
- }
222
- }
223
- /**
224
- * Decrypt a parameter value.
225
- * @param encryptedValue The encrypted value of the parameter.
226
- * @returns A promise that resolves to the decrypted value of the parameter.
227
- */
228
- async decryptParam(encryptedValue) {
229
- Guards.stringValue(UrlTransformerService.CLASS_NAME, "encryptedValue", encryptedValue);
230
- if (Is.empty(this._nodeId)) {
231
- throw new GeneralError(UrlTransformerService.CLASS_NAME, "decryptionUnavailable");
232
- }
233
- try {
234
- const encryptedBytes = Converter.base64UrlToBytes(encryptedValue);
235
- const decryptedBytes = await this._vaultConnector.decrypt(`${this._nodeId}/${this._paramEncryptionKeyName}`, VaultEncryptionType.ChaCha20Poly1305, encryptedBytes);
236
- if (!Is.uint8Array(decryptedBytes)) {
237
- throw new GeneralError(UrlTransformerService.CLASS_NAME, "decryptionFailed");
238
- }
239
- return Converter.bytesToUtf8(decryptedBytes.slice(8));
240
- }
241
- catch (err) {
242
- throw new GeneralError(UrlTransformerService.CLASS_NAME, "decryptionFailed", undefined, BaseError.fromError(err));
243
- }
244
- }
245
- /**
246
- * Get the parameter name for a given key.
247
- * @param key The key of the parameter.
248
- * @returns The parameter name.
249
- */
250
- getParamName(key) {
251
- return Is.stringValue(this._queryParamNames[key])
252
- ? `${UrlTransformerService._KEY_PREFIX}${this._queryParamNames[key]}`
253
- : undefined;
254
- }
255
- }
256
- //# sourceMappingURL=urlTransformerService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"urlTransformerService.js","sourceRoot":"","sources":["../../src/urlTransformerService.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EACN,SAAS,EACT,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAEN,qBAAqB,EACrB,mBAAmB,EACnB,MAAM,wBAAwB,CAAC;AAGhC;;GAEG;AACH,MAAM,OAAO,qBAAqB;IACjC;;OAEG;IACI,MAAM,CAAU,UAAU,2BAA2C;IAE5E;;;OAGG;IACK,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC;IAE/C;;;OAGG;IACK,MAAM,CAAU,kCAAkC,GAAW,kBAAkB,CAAC;IAExF;;;O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cAAc,GAAG,SAAS,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC;YAClE,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CACxD,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,uBAAuB,EAAE,EACjD,mBAAmB,CAAC,gBAAgB,EACpC,cAAc,CACd,CAAC;YAEF,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;gBACpC,MAAM,IAAI,YAAY,CAAC,qBAAqB,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;YAC9E,CAAC;YAED,OAAO,SAAS,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACvD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,MAAM,IAAI,YAAY,CACrB,qBAAqB,CAAC,UAAU,EAChC,kBAAkB,EAClB,SAAS,EACT,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,CACxB,CAAC;QACH,CAAC;IACF,CAAC;IAED;;;;OAIG;IACI,YAAY,CAAC,GAAW;QAC9B,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;YAChD,CAAC,CAAC,GAAG,qBAAqB,CAAC,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE;YACrE,CAAC,CAAC,SAAS,CAAC;IACd,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IHttpRequestQuery, IUrlTransformerComponent } from \"@twin.org/api-models\";\nimport { ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport {\n\tBaseError,\n\tConverter,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tObjectHelper,\n\tRandomHelper,\n\tUint8ArrayHelper\n} from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\ttype IVaultConnector,\n\tVaultConnectorFactory,\n\tVaultEncryptionType\n} from \"@twin.org/vault-models\";\nimport type { IUrlTransformerServiceConstructorOptions } from \"./models/IUrlTransformerServiceConstructorOptions.js\";\n\n/**\n * The URL transformer service for encrypting and decrypting URL parameters.\n */\nexport class UrlTransformerService implements IUrlTransformerComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<UrlTransformerService>();\n\n\t/**\n\t * The prefix to use for encrypted query parameters.\n\t * @internal\n\t */\n\tprivate static readonly _KEY_PREFIX = \"x-enc-\";\n\n\t/**\n\t * The default name for the parameter encryption key query parameter.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_PARAM_ENCRYPTION_KEY_NAME: string = \"param-encryption\";\n\n\t/**\n\t * The vault connector.\n\t * @internal\n\t */\n\tprivate readonly _vaultConnector: IVaultConnector;\n\n\t/**\n\t * The name of the key to retrieve from the vault for encryption/decryption of parameters.\n\t * @internal\n\t */\n\tprivate readonly _paramEncryptionKeyName: string;\n\n\t/**\n\t * Maps logical token ids to their URL query parameter names.\n\t * @internal\n\t */\n\tprivate readonly _queryParamNames: { [id: string]: string };\n\n\t/**\n\t * The node identity, captured at start.\n\t * @internal\n\t */\n\tprivate _nodeId?: string;\n\n\t/**\n\t * Create a new instance of UrlTransformerService.\n\t * @param options The options to create the service.\n\t */\n\tconstructor(options?: IUrlTransformerServiceConstructorOptions) {\n\t\tthis._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? \"vault\");\n\t\tthis._paramEncryptionKeyName =\n\t\t\toptions?.config?.paramEncryptionKeyName ??\n\t\t\tUrlTransformerService._DEFAULT_PARAM_ENCRYPTION_KEY_NAME;\n\t\tthis._queryParamNames = options?.config?.queryParamNames ?? {};\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn UrlTransformerService.CLASS_NAME;\n\t}\n\n\t/**\n\t * The component needs to be started when the node is initialized.\n\t * @returns Nothing.\n\t */\n\tpublic async start(): Promise<void> {\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tthis._nodeId = contextIds?.[ContextIdKeys.Node];\n\t}\n\n\t/**\n\t * Encrypt a named token value and append it as a query parameter to the given URL.\n\t * @param url The URL to append the encrypted token to.\n\t * @param id The logical token identifier (e.g. \"tenant\").\n\t * @param value The value to encrypt and add.\n\t * @returns The URL with the encrypted token added as a query parameter.\n\t */\n\tpublic async addEncryptedQueryParamToUrl(\n\t\turl: string,\n\t\tid: string,\n\t\tvalue: string\n\t): Promise<string> {\n\t\tconst paramName = this._queryParamNames[id] ?? id;\n\t\treturn this.addEncryptedToUrl(url, { [paramName]: value });\n\t}\n\n\t/**\n\t * Get a named token value from the query parameters.\n\t * @param queryParams The HTTP request query containing the parameters.\n\t * @param id The logical token identifier (e.g. \"tenant\").\n\t * @returns The decrypted token value if it exists.\n\t */\n\tpublic async getEncryptedQueryParam(\n\t\tqueryParams: IHttpRequestQuery | undefined,\n\t\tid: string\n\t): Promise<string | undefined> {\n\t\tconst paramName = this._queryParamNames[id] ?? id;\n\t\tconst decrypted = await this.getDecryptedFromQueryParams(queryParams, [paramName]);\n\t\treturn decrypted[paramName];\n\t}\n\n\t/**\n\t * Add encrypted key/value pairs to a URL's query string.\n\t * @param url The base URL to add parameters to.\n\t * @param params The key/value pairs to encrypt and append.\n\t * @returns The URL with the encrypted parameters added.\n\t */\n\tpublic async addEncryptedToUrl(url: string, params: IHttpRequestQuery): Promise<string> {\n\t\tlet urlObj: URL;\n\t\ttry {\n\t\t\turlObj = new URL(url);\n\t\t} catch {\n\t\t\treturn url;\n\t\t}\n\n\t\tconst query: IHttpRequestQuery = {};\n\t\tfor (const [key, value] of urlObj.searchParams.entries()) {\n\t\t\tquery[key] = value;\n\t\t}\n\t\tconst keysToEncrypt = Object.keys(params);\n\t\tfor (const [key, value] of Object.entries(params)) {\n\t\t\tquery[key] = value;\n\t\t}\n\t\tawait this.encryptQueryParams(query, keysToEncrypt);\n\t\turlObj.search = \"\";\n\t\tfor (const [key, value] of Object.entries(query)) {\n\t\t\turlObj.searchParams.set(key, value);\n\t\t}\n\t\treturn urlObj.toString();\n\t}\n\n\t/**\n\t * Get an encrypted value from a URL's query string.\n\t * @param url The URL to extract the encrypted value from.\n\t * @param id The logical identifier for the value to retrieve (e.g. \"tenant\").\n\t * @returns The decrypted value if it exists.\n\t */\n\tpublic async getEncryptedFromUrl(url: string, id: string): Promise<string | undefined> {\n\t\tlet urlObj: URL;\n\t\ttry {\n\t\t\turlObj = new URL(url);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst name = this.getParamName(id);\n\t\tif (!Is.stringValue(name)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (urlObj.searchParams.has(name)) {\n\t\t\tconst encryptedValue = urlObj.searchParams.get(name);\n\t\t\tif (Is.stringValue(encryptedValue)) {\n\t\t\t\treturn this.decryptParam(encryptedValue);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t/**\n\t * Decrypt specified keys from a query parameter object and return their plain-text values.\n\t * @param queryParams The HTTP request query containing the encrypted parameters.\n\t * @param keys The keys to decrypt.\n\t * @returns A map of the decrypted key/value pairs that were present.\n\t */\n\tpublic async getDecryptedFromQueryParams(\n\t\tqueryParams: IHttpRequestQuery | undefined,\n\t\tkeys: string[]\n\t): Promise<IHttpRequestQuery> {\n\t\tconst queryParamsClone = ObjectHelper.clone(queryParams) ?? {};\n\t\tawait this.decryptQueryParams(queryParamsClone, keys);\n\t\tconst result: IHttpRequestQuery = {};\n\t\tfor (const key of keys) {\n\t\t\tif (Is.stringValue(queryParamsClone[key])) {\n\t\t\t\tresult[key] = queryParamsClone[key];\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Encrypt query parameters.\n\t * @param httpRequestQuery The HTTP request query containing the parameters to encrypt.\n\t * @param keys The keys of the parameters to encrypt.\n\t * @returns A promise that resolves when the query parameters have been encrypted.\n\t */\n\tpublic async encryptQueryParams(\n\t\thttpRequestQuery: IHttpRequestQuery | undefined,\n\t\tkeys: string[]\n\t): Promise<void> {\n\t\tif (Is.empty(httpRequestQuery)) {\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const key of keys) {\n\t\t\tif (Is.stringValue(httpRequestQuery[key])) {\n\t\t\t\tconst encryptedValue = await this.encryptParam(httpRequestQuery[key]);\n\t\t\t\thttpRequestQuery[`${UrlTransformerService._KEY_PREFIX}${key}`] = encryptedValue;\n\t\t\t\tdelete httpRequestQuery[key];\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Decrypt query parameters.\n\t * @param httpRequestQuery The HTTP request query containing the encrypted values.\n\t * @param keys The keys of the parameters to decrypt.\n\t * @returns A promise that resolves when the query parameters have been decrypted.\n\t */\n\tpublic async decryptQueryParams(\n\t\thttpRequestQuery: IHttpRequestQuery | undefined,\n\t\tkeys: string[]\n\t): Promise<void> {\n\t\tif (Is.empty(httpRequestQuery)) {\n\t\t\treturn;\n\t\t}\n\t\tfor (const key of Object.keys(httpRequestQuery)) {\n\t\t\tif (key.startsWith(UrlTransformerService._KEY_PREFIX)) {\n\t\t\t\tconst originalKey = key.slice(UrlTransformerService._KEY_PREFIX.length);\n\n\t\t\t\tif (keys.includes(originalKey)) {\n\t\t\t\t\tconst decryptedValue = await this.decryptParam(httpRequestQuery[key]);\n\t\t\t\t\thttpRequestQuery[originalKey] = decryptedValue;\n\t\t\t\t\tdelete httpRequestQuery[key];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Encrypt a parameter value.\n\t * @param paramValue The value of the parameter to encrypt.\n\t * @returns A promise that resolves to the encrypted value of the parameter.\n\t */\n\tpublic async encryptParam(paramValue: string): Promise<string> {\n\t\tGuards.stringValue(UrlTransformerService.CLASS_NAME, nameof(paramValue), paramValue);\n\n\t\tif (Is.empty(this._nodeId)) {\n\t\t\tthrow new GeneralError(UrlTransformerService.CLASS_NAME, \"encryptionUnavailable\");\n\t\t}\n\n\t\ttry {\n\t\t\tconst salt = RandomHelper.generate(8);\n\n\t\t\tconst encryptedParamValue = await this._vaultConnector.encrypt(\n\t\t\t\t`${this._nodeId}/${this._paramEncryptionKeyName}`,\n\t\t\t\tVaultEncryptionType.ChaCha20Poly1305,\n\t\t\t\tUint8ArrayHelper.concat([salt, Converter.utf8ToBytes(paramValue)])\n\t\t\t);\n\n\t\t\tif (!Is.uint8Array(encryptedParamValue)) {\n\t\t\t\tthrow new GeneralError(UrlTransformerService.CLASS_NAME, \"encryptionFailed\");\n\t\t\t}\n\n\t\t\treturn Converter.bytesToBase64Url(encryptedParamValue);\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tUrlTransformerService.CLASS_NAME,\n\t\t\t\t\"encryptionFailed\",\n\t\t\t\tundefined,\n\t\t\t\tBaseError.fromError(err)\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Decrypt a parameter value.\n\t * @param encryptedValue The encrypted value of the parameter.\n\t * @returns A promise that resolves to the decrypted value of the parameter.\n\t */\n\tpublic async decryptParam(encryptedValue: string): Promise<string> {\n\t\tGuards.stringValue(UrlTransformerService.CLASS_NAME, nameof(encryptedValue), encryptedValue);\n\n\t\tif (Is.empty(this._nodeId)) {\n\t\t\tthrow new GeneralError(UrlTransformerService.CLASS_NAME, \"decryptionUnavailable\");\n\t\t}\n\n\t\ttry {\n\t\t\tconst encryptedBytes = Converter.base64UrlToBytes(encryptedValue);\n\t\t\tconst decryptedBytes = await this._vaultConnector.decrypt(\n\t\t\t\t`${this._nodeId}/${this._paramEncryptionKeyName}`,\n\t\t\t\tVaultEncryptionType.ChaCha20Poly1305,\n\t\t\t\tencryptedBytes\n\t\t\t);\n\n\t\t\tif (!Is.uint8Array(decryptedBytes)) {\n\t\t\t\tthrow new GeneralError(UrlTransformerService.CLASS_NAME, \"decryptionFailed\");\n\t\t\t}\n\n\t\t\treturn Converter.bytesToUtf8(decryptedBytes.slice(8));\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tUrlTransformerService.CLASS_NAME,\n\t\t\t\t\"decryptionFailed\",\n\t\t\t\tundefined,\n\t\t\t\tBaseError.fromError(err)\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the parameter name for a given key.\n\t * @param key The key of the parameter.\n\t * @returns The parameter name.\n\t */\n\tpublic getParamName(key: string): string | undefined {\n\t\treturn Is.stringValue(this._queryParamNames[key])\n\t\t\t? `${UrlTransformerService._KEY_PREFIX}${this._queryParamNames[key]}`\n\t\t\t: undefined;\n\t}\n}\n"]}
@@ -1,19 +0,0 @@
1
- /**
2
- * Configuration for the URL transformer service.
3
- */
4
- export interface IUrlTransformerServiceConfig {
5
- /**
6
- * The name of the key to retrieve from the vault for encryption/decryption of parameters.
7
- * @default param-encryption
8
- */
9
- paramEncryptionKeyName?: string;
10
- /**
11
- * A dictionary mapping logical token identifiers to their URL query parameter names.
12
- * For example: tenant => tenant-token maps the logical id "tenant" to the
13
- * query param "tenant-token". When an id is not present the id itself is used as
14
- * the param name.
15
- */
16
- queryParamNames?: {
17
- [id: string]: string;
18
- };
19
- }
@@ -1,15 +0,0 @@
1
- import type { IUrlTransformerServiceConfig } from "./IUrlTransformerServiceConfig.js";
2
- /**
3
- * Options for the UrlTransformerService constructor.
4
- */
5
- export interface IUrlTransformerServiceConstructorOptions {
6
- /**
7
- * The vault connector type.
8
- * @default vault
9
- */
10
- vaultConnectorType?: string;
11
- /**
12
- * The configuration for the service.
13
- */
14
- config?: IUrlTransformerServiceConfig;
15
- }
@@ -1,94 +0,0 @@
1
- import type { IHttpRequestQuery, IUrlTransformerComponent } from "@twin.org/api-models";
2
- import type { IUrlTransformerServiceConstructorOptions } from "./models/IUrlTransformerServiceConstructorOptions.js";
3
- /**
4
- * The URL transformer service for encrypting and decrypting URL parameters.
5
- */
6
- export declare class UrlTransformerService implements IUrlTransformerComponent {
7
- /**
8
- * Runtime name for the class.
9
- */
10
- static readonly CLASS_NAME: string;
11
- /**
12
- * Create a new instance of UrlTransformerService.
13
- * @param options The options to create the service.
14
- */
15
- constructor(options?: IUrlTransformerServiceConstructorOptions);
16
- /**
17
- * Returns the class name of the component.
18
- * @returns The class name of the component.
19
- */
20
- className(): string;
21
- /**
22
- * The component needs to be started when the node is initialized.
23
- * @returns Nothing.
24
- */
25
- start(): Promise<void>;
26
- /**
27
- * Encrypt a named token value and append it as a query parameter to the given URL.
28
- * @param url The URL to append the encrypted token to.
29
- * @param id The logical token identifier (e.g. "tenant").
30
- * @param value The value to encrypt and add.
31
- * @returns The URL with the encrypted token added as a query parameter.
32
- */
33
- addEncryptedQueryParamToUrl(url: string, id: string, value: string): Promise<string>;
34
- /**
35
- * Get a named token value from the query parameters.
36
- * @param queryParams The HTTP request query containing the parameters.
37
- * @param id The logical token identifier (e.g. "tenant").
38
- * @returns The decrypted token value if it exists.
39
- */
40
- getEncryptedQueryParam(queryParams: IHttpRequestQuery | undefined, id: string): Promise<string | undefined>;
41
- /**
42
- * Add encrypted key/value pairs to a URL's query string.
43
- * @param url The base URL to add parameters to.
44
- * @param params The key/value pairs to encrypt and append.
45
- * @returns The URL with the encrypted parameters added.
46
- */
47
- addEncryptedToUrl(url: string, params: IHttpRequestQuery): Promise<string>;
48
- /**
49
- * Get an encrypted value from a URL's query string.
50
- * @param url The URL to extract the encrypted value from.
51
- * @param id The logical identifier for the value to retrieve (e.g. "tenant").
52
- * @returns The decrypted value if it exists.
53
- */
54
- getEncryptedFromUrl(url: string, id: string): Promise<string | undefined>;
55
- /**
56
- * Decrypt specified keys from a query parameter object and return their plain-text values.
57
- * @param queryParams The HTTP request query containing the encrypted parameters.
58
- * @param keys The keys to decrypt.
59
- * @returns A map of the decrypted key/value pairs that were present.
60
- */
61
- getDecryptedFromQueryParams(queryParams: IHttpRequestQuery | undefined, keys: string[]): Promise<IHttpRequestQuery>;
62
- /**
63
- * Encrypt query parameters.
64
- * @param httpRequestQuery The HTTP request query containing the parameters to encrypt.
65
- * @param keys The keys of the parameters to encrypt.
66
- * @returns A promise that resolves when the query parameters have been encrypted.
67
- */
68
- encryptQueryParams(httpRequestQuery: IHttpRequestQuery | undefined, keys: string[]): Promise<void>;
69
- /**
70
- * Decrypt query parameters.
71
- * @param httpRequestQuery The HTTP request query containing the encrypted values.
72
- * @param keys The keys of the parameters to decrypt.
73
- * @returns A promise that resolves when the query parameters have been decrypted.
74
- */
75
- decryptQueryParams(httpRequestQuery: IHttpRequestQuery | undefined, keys: string[]): Promise<void>;
76
- /**
77
- * Encrypt a parameter value.
78
- * @param paramValue The value of the parameter to encrypt.
79
- * @returns A promise that resolves to the encrypted value of the parameter.
80
- */
81
- encryptParam(paramValue: string): Promise<string>;
82
- /**
83
- * Decrypt a parameter value.
84
- * @param encryptedValue The encrypted value of the parameter.
85
- * @returns A promise that resolves to the decrypted value of the parameter.
86
- */
87
- decryptParam(encryptedValue: string): Promise<string>;
88
- /**
89
- * Get the parameter name for a given key.
90
- * @param key The key of the parameter.
91
- * @returns The parameter name.
92
- */
93
- getParamName(key: string): string | undefined;
94
- }