@privateaim/kit 0.8.14 → 0.8.16

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 (56) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/crypto/asymmetric/helpers.d.ts +0 -2
  3. package/dist/crypto/asymmetric/helpers.d.ts.map +1 -1
  4. package/dist/crypto/asymmetric/module.d.ts +1 -7
  5. package/dist/crypto/asymmetric/module.d.ts.map +1 -1
  6. package/dist/crypto/index.d.ts +0 -1
  7. package/dist/crypto/index.d.ts.map +1 -1
  8. package/dist/domains/constants.d.ts +7 -0
  9. package/dist/domains/constants.d.ts.map +1 -0
  10. package/dist/domains/helpers.d.ts +3 -0
  11. package/dist/domains/helpers.d.ts.map +1 -0
  12. package/dist/domains/index.d.ts +2 -0
  13. package/dist/domains/index.d.ts.map +1 -1
  14. package/dist/domains/permission/constants.d.ts +6 -0
  15. package/dist/domains/permission/constants.d.ts.map +1 -1
  16. package/dist/index.cjs +93 -266
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.ts +0 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.mjs +88 -264
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/types.d.ts +7 -1
  23. package/dist/types.d.ts.map +1 -1
  24. package/dist/utils/index.d.ts +2 -0
  25. package/dist/utils/index.d.ts.map +1 -1
  26. package/dist/utils/nanoseconds.d.ts +2 -0
  27. package/dist/utils/nanoseconds.d.ts.map +1 -0
  28. package/dist/utils/wait.d.ts +2 -0
  29. package/dist/utils/wait.d.ts.map +1 -0
  30. package/package.json +5 -3
  31. package/src/crypto/asymmetric/helpers.ts +0 -30
  32. package/src/crypto/asymmetric/module.ts +1 -141
  33. package/src/crypto/index.ts +0 -1
  34. package/src/{log/index.ts → domains/constants.ts} +7 -1
  35. package/src/domains/helpers.ts +24 -0
  36. package/src/domains/index.ts +3 -0
  37. package/src/domains/permission/constants.ts +8 -0
  38. package/src/index.ts +0 -1
  39. package/src/types.ts +8 -1
  40. package/src/utils/index.ts +2 -0
  41. package/src/utils/nanoseconds.ts +14 -0
  42. package/src/utils/wait.ts +12 -0
  43. package/dist/crypto/symmetric/index.d.ts +0 -3
  44. package/dist/crypto/symmetric/index.d.ts.map +0 -1
  45. package/dist/crypto/symmetric/module.d.ts +0 -10
  46. package/dist/crypto/symmetric/module.d.ts.map +0 -1
  47. package/dist/crypto/symmetric/types.d.ts +0 -3
  48. package/dist/crypto/symmetric/types.d.ts.map +0 -1
  49. package/dist/log/constants.d.ts +0 -43
  50. package/dist/log/constants.d.ts.map +0 -1
  51. package/dist/log/index.d.ts +0 -2
  52. package/dist/log/index.d.ts.map +0 -1
  53. package/src/crypto/symmetric/index.ts +0 -9
  54. package/src/crypto/symmetric/module.ts +0 -71
  55. package/src/crypto/symmetric/types.ts +0 -10
  56. package/src/log/constants.ts +0 -56
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.8.16](https://github.com/PrivateAIM/hub/compare/v0.8.15...v0.8.16) (2025-08-26)
4
+
5
+
6
+ ### Features
7
+
8
+ * initial server-db-kit package & event subscriber ([ab0f7c2](https://github.com/PrivateAIM/hub/commit/ab0f7c2ba4e87b6c3794f941dfd90a08aefd3730))
9
+ * initial server-telmetry package with http api & db ([31dbfdc](https://github.com/PrivateAIM/hub/commit/31dbfdcd7c5a0d833aa5021c44da00fb8685e55e))
10
+ * minor subscriber & event publish refactoring ([1ffdd68](https://github.com/PrivateAIM/hub/commit/1ffdd6853283409e83d1d9bb89a67e2964e3cb35))
11
+ * move log-store, loki setup etc. to telemetry service ([#1151](https://github.com/PrivateAIM/hub/issues/1151)) ([8b38b0e](https://github.com/PrivateAIM/hub/commit/8b38b0ee0fafafb121eb4efb0aaf548c27edcde4))
12
+ * remove rsa key generation feature ([b754dfc](https://github.com/PrivateAIM/hub/commit/b754dfce9e17a28e09319e14deb0c5473c0b2ae6))
13
+ * simplify log-store ([5928dd7](https://github.com/PrivateAIM/hub/commit/5928dd72429d2ee0582da05252c2b5f3f9b3cb28))
14
+
15
+ ## [0.8.15](https://github.com/PrivateAIM/hub/compare/v0.8.14...v0.8.15) (2025-07-30)
16
+
17
+
18
+ ### Features
19
+
20
+ * align analysis-logs & initital log render view ([5fd2365](https://github.com/PrivateAIM/hub/commit/5fd236552dd8489d7ab00bf6f59751824ce554fd))
21
+ * event (re-) modelling ([#1125](https://github.com/PrivateAIM/hub/issues/1125)) ([621f704](https://github.com/PrivateAIM/hub/commit/621f7041794d0bf6d530445a9c3e7c9b66a373ba))
22
+ * migrated to authup v1.0.0-beta.27 ([f96db78](https://github.com/PrivateAIM/hub/commit/f96db782a5b74e3aa8ab1ada270af770f3c92631))
23
+
3
24
  ## [0.8.14](https://github.com/PrivateAIM/hub/compare/v0.8.13...v0.8.14) (2025-07-10)
4
25
 
5
26
 
@@ -1,5 +1,3 @@
1
- import type { AsymmetricAlgorithmImportParams } from './types';
2
1
  export declare function exportAsymmetricPublicKey(key: CryptoKey): Promise<string>;
3
2
  export declare function exportAsymmetricPrivateKey(key: CryptoKey): Promise<string>;
4
- export declare function importAsymmetricPublicKey(pem: string, params: AsymmetricAlgorithmImportParams): Promise<CryptoKey>;
5
3
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/crypto/asymmetric/helpers.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,SAAS,CAAC;AAM/D,wBAAsB,yBAAyB,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAO/E;AAED,wBAAsB,0BAA0B,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAOhF;AAED,wBAAsB,yBAAyB,CAC3C,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,+BAA+B,GACxC,OAAO,CAAC,SAAS,CAAC,CAuBpB"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/crypto/asymmetric/helpers.ts"],"names":[],"mappings":"AAWA,wBAAsB,yBAAyB,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAO/E;AAED,wBAAsB,0BAA0B,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAOhF"}
@@ -1,14 +1,8 @@
1
- import type { AsymmetricAlgorithmImportParams, AsymmetricAlgorithmParams } from './types';
1
+ import type { AsymmetricAlgorithmParams } from './types';
2
2
  export declare class CryptoAsymmetricAlgorithm {
3
3
  readonly algorithm: AsymmetricAlgorithmParams;
4
4
  protected keyPair: CryptoKeyPair | undefined;
5
5
  constructor(algorithm: AsymmetricAlgorithmParams);
6
- buildImportParams(): AsymmetricAlgorithmImportParams;
7
6
  generateKeyPair(): Promise<CryptoKeyPair>;
8
- useKeyPair(): Promise<CryptoKeyPair>;
9
- exportPublicKey(): Promise<string>;
10
- exportPrivateKey(): Promise<string>;
11
- encrypt(data: Buffer, remoteKey?: CryptoKey): Promise<ArrayBuffer>;
12
- decrypt(data: Buffer, remoteKey?: CryptoKey): Promise<ArrayBuffer>;
13
7
  }
14
8
  //# sourceMappingURL=module.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/crypto/asymmetric/module.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,+BAA+B,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAG1F,qBAAa,yBAAyB;IAClC,SAAgB,SAAS,EAAE,yBAAyB,CAAC;IAErD,SAAS,CAAC,OAAO,EAAG,aAAa,GAAG,SAAS,CAAC;gBAElC,SAAS,EAAE,yBAAyB;IAWhD,iBAAiB,IAAK,+BAA+B;IAmB/C,eAAe,IAAK,OAAO,CAAC,aAAa,CAAC;IAwB1C,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC;IAQpC,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC;IAMlC,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAMnC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS;IAoD3C,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS;CA+CpD"}
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/crypto/asymmetric/module.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAEzD,qBAAa,yBAAyB;IAClC,SAAgB,SAAS,EAAE,yBAAyB,CAAC;IAErD,SAAS,CAAC,OAAO,EAAG,aAAa,GAAG,SAAS,CAAC;gBAElC,SAAS,EAAE,yBAAyB;IAW1C,eAAe,IAAK,OAAO,CAAC,aAAa,CAAC;CAuBnD"}
@@ -1,3 +1,2 @@
1
1
  export * from './asymmetric';
2
- export * from './symmetric';
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/crypto/index.ts"],"names":[],"mappings":"AAOA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/crypto/index.ts"],"names":[],"mappings":"AAOA,cAAc,cAAc,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare enum DomainEventName {
2
+ CREATED = "created",
3
+ DELETED = "deleted",
4
+ UPDATED = "updated"
5
+ }
6
+ export declare const DomainEventNamespace = "resources";
7
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/domains/constants.ts"],"names":[],"mappings":"AAOA,oBAAY,eAAe;IACvB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,OAAO,YAAY;CACtB;AAED,eAAO,MAAM,oBAAoB,cAAc,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function buildDomainChannelName(domain: string, id?: string | number): string;
2
+ export declare function buildDomainNamespaceName(id?: string): string;
3
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/domains/helpers.ts"],"names":[],"mappings":"AAOA,wBAAgB,sBAAsB,CAClC,MAAM,EAAE,MAAM,EACd,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,UAOvB;AAGD,wBAAgB,wBAAwB,CAAC,EAAE,CAAC,EAAE,MAAM,UAInD"}
@@ -1,3 +1,5 @@
1
1
  export * from './permission';
2
2
  export * from './realm';
3
+ export * from './constants';
4
+ export * from './helpers';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/domains/index.ts"],"names":[],"mappings":"AAOA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/domains/index.ts"],"names":[],"mappings":"AAOA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AAExB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC"}
@@ -1,7 +1,13 @@
1
1
  export declare enum PermissionName {
2
+ EVENT_CREATE = "event_create",
3
+ EVENT_READ = "event_read",
4
+ EVENT_DELETE = "event_delete",
2
5
  BUCKET_CREATE = "bucket_create",
3
6
  BUCKET_UPDATE = "bucket_update",
4
7
  BUCKET_DELETE = "bucket_delete",
8
+ LOG_CREATE = "log_create",
9
+ LOG_DELETE = "log_delete",
10
+ LOG_READ = "log_read",
5
11
  PROJECT_CREATE = "project_create",
6
12
  PROJECT_DELETE = "project_delete",
7
13
  PROJECT_UPDATE = "project_update",
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/domains/permission/constants.ts"],"names":[],"mappings":"AAOA,oBAAY,cAAc;IACtB,aAAa,kBAAkB;IAC/B,aAAa,kBAAkB;IAC/B,aAAa,kBAAkB;IAE/B,cAAc,mBAAmB;IACjC,cAAc,mBAAmB;IACjC,cAAc,mBAAmB;IACjC,eAAe,oBAAoB;IAEnC,eAAe,oBAAoB;IACnC,uBAAuB,4BAA4B;IAEnD,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;IAE3B,gBAAgB,qBAAqB;IACrC,eAAe,oBAAoB;IACnC,eAAe,oBAAoB;IACnC,wBAAwB,6BAA6B;IACrD,uBAAuB,4BAA4B;IACnD,eAAe,oBAAoB;IACnC,oBAAoB,yBAAyB,CAAE,2CAA2C;IAE1F,gCAAgC,qCAAqC;IACrE,yBAAyB,8BAA8B;IAEvD,mBAAmB,wBAAwB;IAC3C,yBAAyB,8BAA8B;IAEvD,cAAc,mBAAmB;CACpC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/domains/permission/constants.ts"],"names":[],"mappings":"AAOA,oBAAY,cAAc;IACtB,YAAY,iBAAiB;IAC7B,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAE7B,aAAa,kBAAkB;IAC/B,aAAa,kBAAkB;IAC/B,aAAa,kBAAkB;IAE/B,UAAU,eAAe;IACzB,UAAU,eAAe;IACzB,QAAQ,aAAa;IAErB,cAAc,mBAAmB;IACjC,cAAc,mBAAmB;IACjC,cAAc,mBAAmB;IACjC,eAAe,oBAAoB;IAEnC,eAAe,oBAAoB;IACnC,uBAAuB,4BAA4B;IAEnD,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;IAE3B,gBAAgB,qBAAqB;IACrC,eAAe,oBAAoB;IACnC,eAAe,oBAAoB;IACnC,wBAAwB,6BAA6B;IACrD,uBAAuB,4BAA4B;IACnD,eAAe,oBAAoB;IACnC,oBAAoB,yBAAyB,CAAE,2CAA2C;IAE1F,gCAAgC,qCAAqC;IACrE,yBAAyB,8BAA8B;IAEvD,mBAAmB,wBAAwB;IAC3C,yBAAyB,8BAA8B;IAEvD,cAAc,mBAAmB;CACpC"}
package/dist/index.cjs CHANGED
@@ -63,22 +63,6 @@ function exportAsymmetricPrivateKey(key) {
63
63
  return `-----BEGIN PRIVATE KEY-----\n${arrayBufferToBase64(exported)}\n-----END PRIVATE KEY-----`;
64
64
  })();
65
65
  }
66
- function importAsymmetricPublicKey(pem, params) {
67
- return _async_to_generator$2(function*() {
68
- const pemHeader = '-----BEGIN PUBLIC KEY-----';
69
- const pemFooter = '-----END PUBLIC KEY-----';
70
- const pemContents = pem.substring(pemHeader.length, pem.length - pemFooter.length);
71
- const buffer = Buffer.from(pemContents, 'base64');
72
- if (params.name === 'ECDH') {
73
- return crypto.subtle.importKey('spki', buffer, params, true, [
74
- 'deriveKey'
75
- ]);
76
- }
77
- return crypto.subtle.importKey('spki', buffer, params, true, [
78
- 'encrypt'
79
- ]);
80
- })();
81
- }
82
66
 
83
67
  /*
84
68
  * Copyright (c) 2024.
@@ -114,7 +98,7 @@ function _async_to_generator$1(fn) {
114
98
  });
115
99
  };
116
100
  }
117
- function _define_property$1(obj, key, value) {
101
+ function _define_property(obj, key, value) {
118
102
  if (key in obj) {
119
103
  Object.defineProperty(obj, key, {
120
104
  value: value,
@@ -137,7 +121,7 @@ function _object_spread(target) {
137
121
  }));
138
122
  }
139
123
  ownKeys.forEach(function(key) {
140
- _define_property$1(target, key, source[key]);
124
+ _define_property(target, key, source[key]);
141
125
  });
142
126
  }
143
127
  return target;
@@ -162,22 +146,6 @@ function _object_spread_props(target, source) {
162
146
  return target;
163
147
  }
164
148
  class CryptoAsymmetricAlgorithm {
165
- buildImportParams() {
166
- if (this.algorithm.name === AsymmetricCryptoAlgorithmName.RSA_OAEP) {
167
- return {
168
- name: 'RSA-OAEP',
169
- hash: 'SHA-256'
170
- };
171
- }
172
- if (this.algorithm.name === AsymmetricCryptoAlgorithmName.ECDH) {
173
- return {
174
- name: 'ECDH',
175
- namedCurve: this.algorithm.namedCurve,
176
- hash: 'SHA-256'
177
- };
178
- }
179
- throw new Error('Import params could not be created.');
180
- }
181
149
  generateKeyPair() {
182
150
  return _async_to_generator$1(function*() {
183
151
  if (this.algorithm.name === AsymmetricCryptoAlgorithmName.RSA_OAEP) {
@@ -196,97 +164,9 @@ class CryptoAsymmetricAlgorithm {
196
164
  throw new Error('The algorithm is not supported for key generation.');
197
165
  }).call(this);
198
166
  }
199
- useKeyPair() {
200
- return _async_to_generator$1(function*() {
201
- if (typeof this.keyPair !== 'undefined') {
202
- return this.keyPair;
203
- }
204
- return this.generateKeyPair();
205
- }).call(this);
206
- }
207
- exportPublicKey() {
208
- return _async_to_generator$1(function*() {
209
- const keyPair = yield this.useKeyPair();
210
- return exportAsymmetricPublicKey(keyPair.publicKey);
211
- }).call(this);
212
- }
213
- exportPrivateKey() {
214
- return _async_to_generator$1(function*() {
215
- const keyPair = yield this.useKeyPair();
216
- return exportAsymmetricPrivateKey(keyPair.privateKey);
217
- }).call(this);
218
- }
219
- encrypt(data, remoteKey) {
220
- return _async_to_generator$1(function*() {
221
- const keyPair = yield this.useKeyPair();
222
- if (this.algorithm.name === AsymmetricCryptoAlgorithmName.RSA_OAEP) {
223
- return crypto.subtle.encrypt({
224
- name: 'RSA-OAEP'
225
- }, remoteKey || keyPair.publicKey, data);
226
- }
227
- if (this.algorithm.name === AsymmetricCryptoAlgorithmName.ECDH) {
228
- if (typeof remoteKey === 'undefined') {
229
- throw new Error('Remote public key is required.');
230
- }
231
- const array = new Uint8Array(16);
232
- const iv = crypto.getRandomValues(array);
233
- const key = yield crypto.subtle.deriveKey({
234
- name: 'ECDH',
235
- public: remoteKey
236
- }, keyPair.privateKey, {
237
- name: 'AES-GCM',
238
- length: 256
239
- }, true, [
240
- 'encrypt'
241
- ]);
242
- const arrayBuffer = yield crypto.subtle.encrypt({
243
- name: 'AES-GCM',
244
- length: 256,
245
- iv
246
- }, key, data);
247
- const buffer = Buffer.from(arrayBuffer);
248
- return Buffer.concat([
249
- iv,
250
- buffer
251
- ]);
252
- }
253
- throw new Error('Unsupported algorithm for encryption.');
254
- }).call(this);
255
- }
256
- decrypt(data, remoteKey) {
257
- return _async_to_generator$1(function*() {
258
- const keyPair = yield this.useKeyPair();
259
- if (this.algorithm.name === AsymmetricCryptoAlgorithmName.RSA_OAEP) {
260
- return crypto.subtle.decrypt({
261
- name: 'RSA-OAEP'
262
- }, keyPair.privateKey, data);
263
- }
264
- if (this.algorithm.name === AsymmetricCryptoAlgorithmName.ECDH) {
265
- if (typeof remoteKey === 'undefined') {
266
- throw new Error('Remote public key is required.');
267
- }
268
- const iv = data.slice(0, 16);
269
- const key = yield crypto.subtle.deriveKey({
270
- name: 'ECDH',
271
- public: remoteKey
272
- }, keyPair.privateKey, {
273
- name: 'AES-GCM',
274
- length: 256
275
- }, true, [
276
- 'decrypt'
277
- ]);
278
- return crypto.subtle.decrypt({
279
- name: 'AES-GCM',
280
- length: 256,
281
- iv
282
- }, key, data.slice(16));
283
- }
284
- throw new Error('Unsupported algorithm for decryption.');
285
- }).call(this);
286
- }
287
167
  constructor(algorithm){
288
- _define_property$1(this, "algorithm", void 0);
289
- _define_property$1(this, "keyPair", void 0);
168
+ _define_property(this, "algorithm", void 0);
169
+ _define_property(this, "keyPair", void 0);
290
170
  if (algorithm.name === AsymmetricCryptoAlgorithmName.RSA_OAEP) {
291
171
  algorithm = _object_spread_props(_object_spread({}, algorithm), {
292
172
  publicExponent: new Uint8Array([
@@ -300,116 +180,21 @@ class CryptoAsymmetricAlgorithm {
300
180
  }
301
181
  }
302
182
 
303
- /*
304
- * Copyright (c) 2024.
305
- * Author Peter Placzek (tada5hi)
306
- * For the full copyright and license information,
307
- * view the LICENSE file that was distributed with this source code.
308
- */ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
309
- try {
310
- var info = gen[key](arg);
311
- var value = info.value;
312
- } catch (error) {
313
- reject(error);
314
- return;
315
- }
316
- if (info.done) {
317
- resolve(value);
318
- } else {
319
- Promise.resolve(value).then(_next, _throw);
320
- }
321
- }
322
- function _async_to_generator(fn) {
323
- return function() {
324
- var self = this, args = arguments;
325
- return new Promise(function(resolve, reject) {
326
- var gen = fn.apply(self, args);
327
- function _next(value) {
328
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
329
- }
330
- function _throw(err) {
331
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
332
- }
333
- _next(undefined);
334
- });
335
- };
336
- }
337
- function _define_property(obj, key, value) {
338
- if (key in obj) {
339
- Object.defineProperty(obj, key, {
340
- value: value,
341
- enumerable: true,
342
- configurable: true,
343
- writable: true
344
- });
345
- } else {
346
- obj[key] = value;
347
- }
348
- return obj;
349
- }
350
- class CryptoSymmetricAlgorithm {
351
- generateKey() {
352
- return _async_to_generator(function*() {
353
- return crypto.subtle.generateKey({
354
- name: this.algorithm.name,
355
- length: 256
356
- }, true, [
357
- 'encrypt',
358
- 'decrypt'
359
- ]);
360
- }).call(this);
361
- }
362
- importKey(buffer) {
363
- return _async_to_generator(function*() {
364
- return crypto.subtle.importKey('raw', buffer, {
365
- name: this.algorithm.name,
366
- length: 256
367
- }, true, [
368
- 'encrypt',
369
- 'decrypt'
370
- ]);
371
- }).call(this);
372
- }
373
- encrypt(key, iv, data) {
374
- return _async_to_generator(function*() {
375
- const arrayBuffer = yield crypto.subtle.encrypt({
376
- name: this.algorithm.name,
377
- length: 256,
378
- iv
379
- }, key, data);
380
- const buffer = Buffer.from(arrayBuffer);
381
- return Buffer.concat([
382
- iv,
383
- buffer
384
- ]);
385
- }).call(this);
386
- }
387
- decrypt(key, data) {
388
- return _async_to_generator(function*() {
389
- const iv = data.slice(0, 16);
390
- const arrayBuffer = yield crypto.subtle.decrypt({
391
- name: this.algorithm.name,
392
- length: 256,
393
- iv
394
- }, key, data.slice(16));
395
- return Buffer.from(arrayBuffer);
396
- }).call(this);
397
- }
398
- constructor(algorithm){
399
- _define_property(this, "algorithm", void 0);
400
- this.algorithm = algorithm;
401
- }
402
- }
403
-
404
183
  /*
405
184
  * Copyright (c) 2021-2024.
406
185
  * Author Peter Placzek (tada5hi)
407
186
  * For the full copyright and license information,
408
187
  * view the LICENSE file that was distributed with this source code.
409
188
  */ var PermissionName = /*#__PURE__*/ function(PermissionName) {
189
+ PermissionName["EVENT_CREATE"] = "event_create";
190
+ PermissionName["EVENT_READ"] = "event_read";
191
+ PermissionName["EVENT_DELETE"] = "event_delete";
410
192
  PermissionName["BUCKET_CREATE"] = "bucket_create";
411
193
  PermissionName["BUCKET_UPDATE"] = "bucket_update";
412
194
  PermissionName["BUCKET_DELETE"] = "bucket_delete";
195
+ PermissionName["LOG_CREATE"] = "log_create";
196
+ PermissionName["LOG_DELETE"] = "log_delete";
197
+ PermissionName["LOG_READ"] = "log_read";
413
198
  PermissionName["PROJECT_CREATE"] = "project_create";
414
199
  PermissionName["PROJECT_DELETE"] = "project_delete";
415
200
  PermissionName["PROJECT_UPDATE"] = "project_update";
@@ -517,6 +302,15 @@ function createNanoID(alphabetOrLen, len) {
517
302
  return nanoid.customAlphabet('0123456789abcdefghijklmnopqrstuvwxyz', len || 21)();
518
303
  }
519
304
 
305
+ /*
306
+ * Copyright (c) 2025.
307
+ * Author Peter Placzek (tada5hi)
308
+ * For the full copyright and license information,
309
+ * view the LICENSE file that was distributed with this source code.
310
+ */ function nanoSeconds() {
311
+ return BigInt(Math.floor(performance.timeOrigin)) * 1000000n + BigInt(Math.floor(performance.now() * 1000000));
312
+ }
313
+
520
314
  /*
521
315
  * Copyright (c) 2021-2024.
522
316
  * Author Peter Placzek (tada5hi)
@@ -591,6 +385,48 @@ function detectProxyConnectionConfig() {
591
385
  */ const alphaNumHyphenUnderscoreRegex = /^[a-z0-9-_]*$/;
592
386
  const registryRobotSecretRegex = /^(?=.*[A-Z])(?=.*[a-z])(?=.*\d).{8,}$/;
593
387
 
388
+ /*
389
+ * Copyright (c) 2025.
390
+ * Author Peter Placzek (tada5hi)
391
+ * For the full copyright and license information,
392
+ * view the LICENSE file that was distributed with this source code.
393
+ */ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
394
+ try {
395
+ var info = gen[key](arg);
396
+ var value = info.value;
397
+ } catch (error) {
398
+ reject(error);
399
+ return;
400
+ }
401
+ if (info.done) {
402
+ resolve(value);
403
+ } else {
404
+ Promise.resolve(value).then(_next, _throw);
405
+ }
406
+ }
407
+ function _async_to_generator(fn) {
408
+ return function() {
409
+ var self = this, args = arguments;
410
+ return new Promise(function(resolve, reject) {
411
+ var gen = fn.apply(self, args);
412
+ function _next(value) {
413
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
414
+ }
415
+ function _throw(err) {
416
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
417
+ }
418
+ _next(undefined);
419
+ });
420
+ };
421
+ }
422
+ function wait(ms) {
423
+ return _async_to_generator(function*() {
424
+ return new Promise((resolve)=>{
425
+ setTimeout(resolve, ms);
426
+ });
427
+ })();
428
+ }
429
+
594
430
  /**
595
431
  * Check if a realm resource is writable.
596
432
  *
@@ -644,9 +480,28 @@ const registryRobotSecretRegex = /^(?=.*[A-Z])(?=.*[a-z])(?=.*\d).{8,}$/;
644
480
  * Author Peter Placzek (tada5hi)
645
481
  * For the full copyright and license information,
646
482
  * view the LICENSE file that was distributed with this source code.
647
- */ function buildDomainEventFullName(type, event) {
648
- const eventCapitalized = event.substring(0, 1).toUpperCase() + event.substring(1);
649
- return type + eventCapitalized;
483
+ */ var DomainEventName = /*#__PURE__*/ function(DomainEventName) {
484
+ DomainEventName["CREATED"] = "created";
485
+ DomainEventName["DELETED"] = "deleted";
486
+ DomainEventName["UPDATED"] = "updated";
487
+ return DomainEventName;
488
+ }({});
489
+ const DomainEventNamespace = 'resources';
490
+
491
+ /*
492
+ * Copyright (c) 2025.
493
+ * Author Peter Placzek (tada5hi)
494
+ * For the full copyright and license information,
495
+ * view the LICENSE file that was distributed with this source code.
496
+ */ function buildDomainChannelName(domain, id) {
497
+ if (typeof id === 'string' || typeof id === 'number') {
498
+ return `${domain}:${id}`;
499
+ }
500
+ return domain;
501
+ }
502
+ // todo: rename to buildEntityNamespaceName
503
+ function buildDomainNamespaceName(id) {
504
+ return id ? `/resources:${id}` : '/resources';
650
505
  }
651
506
 
652
507
  /*
@@ -654,41 +509,10 @@ const registryRobotSecretRegex = /^(?=.*[A-Z])(?=.*[a-z])(?=.*\d).{8,}$/;
654
509
  * Author Peter Placzek (tada5hi)
655
510
  * For the full copyright and license information,
656
511
  * view the LICENSE file that was distributed with this source code.
657
- */ var LogLevel = /*#__PURE__*/ function(LogLevel) {
658
- /**
659
- * indicates that the system is unusable
660
- * and requires immediate attention
661
- */ LogLevel["EMERGENCE"] = "emerg";
662
- /**
663
- * indicates that immediate action is necessary
664
- * to resolve a critical issue.
665
- */ LogLevel["ALERT"] = "alert";
666
- /**
667
- * signifies critical conditions in the program that demand
668
- * intervention to prevent system failure.
669
- */ LogLevel["CRITICAL"] = "crit";
670
- /**
671
- * indicates error conditions that impair
672
- * some operation but are less severe than critical situations.
673
- */ LogLevel["ERROR"] = "error";
674
- /**
675
- * signifies potential issues that may lead to errors
676
- * or unexpected behavior in the future if not addressed.
677
- */ LogLevel["WARNING"] = "warn";
678
- /**
679
- * applies to normal but significant
680
- * conditions that may require monitoring
681
- */ LogLevel["NOTICE"] = "notice";
682
- /**
683
- * includes messages that provide a record
684
- * of the normal operation of the system.
685
- */ LogLevel["INFORMATIONAL"] = "info";
686
- /**
687
- * intended for logging detailed information about the system
688
- * for debugging purposes.
689
- */ LogLevel["DEBUG"] = "debug";
690
- return LogLevel;
691
- }({});
512
+ */ function buildDomainEventFullName(type, event) {
513
+ const eventCapitalized = event.substring(0, 1).toUpperCase() + event.substring(1);
514
+ return type + eventCapitalized;
515
+ }
692
516
 
693
517
  /*
694
518
  * Copyright (c) 2024.
@@ -704,12 +528,14 @@ const registryRobotSecretRegex = /^(?=.*[A-Z])(?=.*[a-z])(?=.*\d).{8,}$/;
704
528
 
705
529
  exports.AsymmetricCryptoAlgorithmName = AsymmetricCryptoAlgorithmName;
706
530
  exports.CryptoAsymmetricAlgorithm = CryptoAsymmetricAlgorithm;
707
- exports.CryptoSymmetricAlgorithm = CryptoSymmetricAlgorithm;
531
+ exports.DomainEventName = DomainEventName;
532
+ exports.DomainEventNamespace = DomainEventNamespace;
708
533
  exports.EnvironmentName = EnvironmentName;
709
- exports.LogLevel = LogLevel;
710
534
  exports.PermissionName = PermissionName;
711
535
  exports.alphaNumHyphenUnderscoreRegex = alphaNumHyphenUnderscoreRegex;
536
+ exports.buildDomainChannelName = buildDomainChannelName;
712
537
  exports.buildDomainEventFullName = buildDomainEventFullName;
538
+ exports.buildDomainNamespaceName = buildDomainNamespaceName;
713
539
  exports.createNanoID = createNanoID;
714
540
  exports.deleteUndefinedObjectProperties = deleteUndefinedObjectProperties;
715
541
  exports.detectProxyConnectionConfig = detectProxyConnectionConfig;
@@ -718,7 +544,6 @@ exports.exportAsymmetricPublicKey = exportAsymmetricPublicKey;
718
544
  exports.getHostNameFromString = getHostNameFromString;
719
545
  exports.hasOwnProperty = hasOwnProperty;
720
546
  exports.hexToUTF8 = hexToUTF8;
721
- exports.importAsymmetricPublicKey = importAsymmetricPublicKey;
722
547
  exports.isBool = isBool;
723
548
  exports.isBoolFalse = isBoolFalse;
724
549
  exports.isBoolTrue = isBoolTrue;
@@ -728,7 +553,9 @@ exports.isObject = isObject;
728
553
  exports.isPropertySet = isPropertySet;
729
554
  exports.isRealmResourceReadable = isRealmResourceReadable;
730
555
  exports.isRealmResourceWritable = isRealmResourceWritable;
556
+ exports.nanoSeconds = nanoSeconds;
731
557
  exports.nullifyEmptyObjectProperties = nullifyEmptyObjectProperties;
732
558
  exports.parseProxyConnectionString = parseProxyConnectionString;
733
559
  exports.registryRobotSecretRegex = registryRobotSecretRegex;
560
+ exports.wait = wait;
734
561
  //# sourceMappingURL=index.cjs.map