@privateaim/kit 0.8.15 → 0.8.17
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/CHANGELOG.md +14 -0
- package/dist/crypto/asymmetric/helpers.d.ts +0 -2
- package/dist/crypto/asymmetric/helpers.d.ts.map +1 -1
- package/dist/crypto/asymmetric/module.d.ts +1 -7
- package/dist/crypto/asymmetric/module.d.ts.map +1 -1
- package/dist/crypto/index.d.ts +0 -1
- package/dist/crypto/index.d.ts.map +1 -1
- package/dist/domains/constants.d.ts +7 -0
- package/dist/domains/constants.d.ts.map +1 -0
- package/dist/domains/helpers.d.ts +3 -0
- package/dist/domains/helpers.d.ts.map +1 -0
- package/dist/domains/index.d.ts +2 -1
- package/dist/domains/index.d.ts.map +1 -1
- package/dist/domains/permission/constants.d.ts +4 -0
- package/dist/domains/permission/constants.d.ts.map +1 -1
- package/dist/index.cjs +62 -300
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +58 -296
- package/dist/index.mjs.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/nanoseconds.d.ts +2 -0
- package/dist/utils/nanoseconds.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/crypto/asymmetric/helpers.ts +0 -30
- package/src/crypto/asymmetric/module.ts +1 -141
- package/src/crypto/index.ts +0 -1
- package/src/domains/{log/index.ts → constants.ts} +7 -3
- package/src/domains/helpers.ts +24 -0
- package/src/domains/index.ts +3 -1
- package/src/domains/permission/constants.ts +5 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/nanoseconds.ts +14 -0
- package/dist/crypto/symmetric/index.d.ts +0 -3
- package/dist/crypto/symmetric/index.d.ts.map +0 -1
- package/dist/crypto/symmetric/module.d.ts +0 -10
- package/dist/crypto/symmetric/module.d.ts.map +0 -1
- package/dist/crypto/symmetric/types.d.ts +0 -3
- package/dist/crypto/symmetric/types.d.ts.map +0 -1
- package/dist/domains/log/constants.d.ts +0 -43
- package/dist/domains/log/constants.d.ts.map +0 -1
- package/dist/domains/log/entity.d.ts +0 -20
- package/dist/domains/log/entity.d.ts.map +0 -1
- package/dist/domains/log/helpers.d.ts +0 -4
- package/dist/domains/log/helpers.d.ts.map +0 -1
- package/dist/domains/log/index.d.ts +0 -4
- package/dist/domains/log/index.d.ts.map +0 -1
- package/src/crypto/symmetric/index.ts +0 -9
- package/src/crypto/symmetric/module.ts +0 -71
- package/src/crypto/symmetric/types.ts +0 -10
- package/src/domains/log/constants.ts +0 -56
- package/src/domains/log/entity.ts +0 -30
- package/src/domains/log/helpers.ts +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.8.17](https://github.com/PrivateAIM/hub/compare/v0.8.16...v0.8.17) (2025-09-01)
|
|
4
|
+
|
|
5
|
+
## [0.8.16](https://github.com/PrivateAIM/hub/compare/v0.8.15...v0.8.16) (2025-08-26)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* initial server-db-kit package & event subscriber ([ab0f7c2](https://github.com/PrivateAIM/hub/commit/ab0f7c2ba4e87b6c3794f941dfd90a08aefd3730))
|
|
11
|
+
* initial server-telmetry package with http api & db ([31dbfdc](https://github.com/PrivateAIM/hub/commit/31dbfdcd7c5a0d833aa5021c44da00fb8685e55e))
|
|
12
|
+
* minor subscriber & event publish refactoring ([1ffdd68](https://github.com/PrivateAIM/hub/commit/1ffdd6853283409e83d1d9bb89a67e2964e3cb35))
|
|
13
|
+
* 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))
|
|
14
|
+
* remove rsa key generation feature ([b754dfc](https://github.com/PrivateAIM/hub/commit/b754dfce9e17a28e09319e14deb0c5473c0b2ae6))
|
|
15
|
+
* simplify log-store ([5928dd7](https://github.com/PrivateAIM/hub/commit/5928dd72429d2ee0582da05252c2b5f3f9b3cb28))
|
|
16
|
+
|
|
3
17
|
## [0.8.15](https://github.com/PrivateAIM/hub/compare/v0.8.14...v0.8.15) (2025-07-30)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -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":"
|
|
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 {
|
|
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
|
|
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"}
|
package/dist/crypto/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/crypto/index.ts"],"names":[],"mappings":"AAOA,cAAc,cAAc,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/crypto/index.ts"],"names":[],"mappings":"AAOA,cAAc,cAAc,CAAC"}
|
|
@@ -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 @@
|
|
|
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"}
|
package/dist/domains/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/domains/index.ts"],"names":[],"mappings":"AAOA,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,9 +1,13 @@
|
|
|
1
1
|
export declare enum PermissionName {
|
|
2
|
+
EVENT_CREATE = "event_create",
|
|
2
3
|
EVENT_READ = "event_read",
|
|
3
4
|
EVENT_DELETE = "event_delete",
|
|
4
5
|
BUCKET_CREATE = "bucket_create",
|
|
5
6
|
BUCKET_UPDATE = "bucket_update",
|
|
6
7
|
BUCKET_DELETE = "bucket_delete",
|
|
8
|
+
LOG_CREATE = "log_create",
|
|
9
|
+
LOG_DELETE = "log_delete",
|
|
10
|
+
LOG_READ = "log_read",
|
|
7
11
|
PROJECT_CREATE = "project_create",
|
|
8
12
|
PROJECT_DELETE = "project_delete",
|
|
9
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,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAE7B,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
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var kit = require('@authup/kit');
|
|
4
3
|
var coreKit = require('@authup/core-kit');
|
|
5
4
|
var nanoid = require('nanoid');
|
|
6
5
|
|
|
@@ -20,7 +19,7 @@ var nanoid = require('nanoid');
|
|
|
20
19
|
* Author Peter Placzek (tada5hi)
|
|
21
20
|
* For the full copyright and license information,
|
|
22
21
|
* view the LICENSE file that was distributed with this source code.
|
|
23
|
-
*/ function asyncGeneratorStep$
|
|
22
|
+
*/ function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
24
23
|
try {
|
|
25
24
|
var info = gen[key](arg);
|
|
26
25
|
var value = info.value;
|
|
@@ -34,16 +33,16 @@ var nanoid = require('nanoid');
|
|
|
34
33
|
Promise.resolve(value).then(_next, _throw);
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
|
-
function _async_to_generator$
|
|
36
|
+
function _async_to_generator$2(fn) {
|
|
38
37
|
return function() {
|
|
39
38
|
var self = this, args = arguments;
|
|
40
39
|
return new Promise(function(resolve, reject) {
|
|
41
40
|
var gen = fn.apply(self, args);
|
|
42
41
|
function _next(value) {
|
|
43
|
-
asyncGeneratorStep$
|
|
42
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
44
43
|
}
|
|
45
44
|
function _throw(err) {
|
|
46
|
-
asyncGeneratorStep$
|
|
45
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
47
46
|
}
|
|
48
47
|
_next(undefined);
|
|
49
48
|
});
|
|
@@ -53,40 +52,24 @@ function arrayBufferToBase64(arrayBuffer) {
|
|
|
53
52
|
return btoa(String.fromCharCode.apply(null, new Uint8Array(arrayBuffer)));
|
|
54
53
|
}
|
|
55
54
|
function exportAsymmetricPublicKey(key) {
|
|
56
|
-
return _async_to_generator$
|
|
55
|
+
return _async_to_generator$2(function*() {
|
|
57
56
|
const exported = yield crypto.subtle.exportKey('spki', key);
|
|
58
57
|
return `-----BEGIN PUBLIC KEY-----\n${arrayBufferToBase64(exported)}\n-----END PUBLIC KEY-----`;
|
|
59
58
|
})();
|
|
60
59
|
}
|
|
61
60
|
function exportAsymmetricPrivateKey(key) {
|
|
62
|
-
return _async_to_generator$
|
|
61
|
+
return _async_to_generator$2(function*() {
|
|
63
62
|
const exported = yield crypto.subtle.exportKey('pkcs8', key);
|
|
64
63
|
return `-----BEGIN PRIVATE KEY-----\n${arrayBufferToBase64(exported)}\n-----END PRIVATE KEY-----`;
|
|
65
64
|
})();
|
|
66
65
|
}
|
|
67
|
-
function importAsymmetricPublicKey(pem, params) {
|
|
68
|
-
return _async_to_generator$3(function*() {
|
|
69
|
-
const pemHeader = '-----BEGIN PUBLIC KEY-----';
|
|
70
|
-
const pemFooter = '-----END PUBLIC KEY-----';
|
|
71
|
-
const pemContents = pem.substring(pemHeader.length, pem.length - pemFooter.length);
|
|
72
|
-
const buffer = Buffer.from(pemContents, 'base64');
|
|
73
|
-
if (params.name === 'ECDH') {
|
|
74
|
-
return crypto.subtle.importKey('spki', buffer, params, true, [
|
|
75
|
-
'deriveKey'
|
|
76
|
-
]);
|
|
77
|
-
}
|
|
78
|
-
return crypto.subtle.importKey('spki', buffer, params, true, [
|
|
79
|
-
'encrypt'
|
|
80
|
-
]);
|
|
81
|
-
})();
|
|
82
|
-
}
|
|
83
66
|
|
|
84
67
|
/*
|
|
85
68
|
* Copyright (c) 2024.
|
|
86
69
|
* Author Peter Placzek (tada5hi)
|
|
87
70
|
* For the full copyright and license information,
|
|
88
71
|
* view the LICENSE file that was distributed with this source code.
|
|
89
|
-
*/ function asyncGeneratorStep$
|
|
72
|
+
*/ function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
90
73
|
try {
|
|
91
74
|
var info = gen[key](arg);
|
|
92
75
|
var value = info.value;
|
|
@@ -100,22 +83,22 @@ function importAsymmetricPublicKey(pem, params) {
|
|
|
100
83
|
Promise.resolve(value).then(_next, _throw);
|
|
101
84
|
}
|
|
102
85
|
}
|
|
103
|
-
function _async_to_generator$
|
|
86
|
+
function _async_to_generator$1(fn) {
|
|
104
87
|
return function() {
|
|
105
88
|
var self = this, args = arguments;
|
|
106
89
|
return new Promise(function(resolve, reject) {
|
|
107
90
|
var gen = fn.apply(self, args);
|
|
108
91
|
function _next(value) {
|
|
109
|
-
asyncGeneratorStep$
|
|
92
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
110
93
|
}
|
|
111
94
|
function _throw(err) {
|
|
112
|
-
asyncGeneratorStep$
|
|
95
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
113
96
|
}
|
|
114
97
|
_next(undefined);
|
|
115
98
|
});
|
|
116
99
|
};
|
|
117
100
|
}
|
|
118
|
-
function _define_property
|
|
101
|
+
function _define_property(obj, key, value) {
|
|
119
102
|
if (key in obj) {
|
|
120
103
|
Object.defineProperty(obj, key, {
|
|
121
104
|
value: value,
|
|
@@ -138,7 +121,7 @@ function _object_spread(target) {
|
|
|
138
121
|
}));
|
|
139
122
|
}
|
|
140
123
|
ownKeys.forEach(function(key) {
|
|
141
|
-
_define_property
|
|
124
|
+
_define_property(target, key, source[key]);
|
|
142
125
|
});
|
|
143
126
|
}
|
|
144
127
|
return target;
|
|
@@ -163,24 +146,8 @@ function _object_spread_props(target, source) {
|
|
|
163
146
|
return target;
|
|
164
147
|
}
|
|
165
148
|
class CryptoAsymmetricAlgorithm {
|
|
166
|
-
buildImportParams() {
|
|
167
|
-
if (this.algorithm.name === AsymmetricCryptoAlgorithmName.RSA_OAEP) {
|
|
168
|
-
return {
|
|
169
|
-
name: 'RSA-OAEP',
|
|
170
|
-
hash: 'SHA-256'
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
if (this.algorithm.name === AsymmetricCryptoAlgorithmName.ECDH) {
|
|
174
|
-
return {
|
|
175
|
-
name: 'ECDH',
|
|
176
|
-
namedCurve: this.algorithm.namedCurve,
|
|
177
|
-
hash: 'SHA-256'
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
throw new Error('Import params could not be created.');
|
|
181
|
-
}
|
|
182
149
|
generateKeyPair() {
|
|
183
|
-
return _async_to_generator$
|
|
150
|
+
return _async_to_generator$1(function*() {
|
|
184
151
|
if (this.algorithm.name === AsymmetricCryptoAlgorithmName.RSA_OAEP) {
|
|
185
152
|
this.keyPair = yield crypto.subtle.generateKey(this.algorithm, true, [
|
|
186
153
|
'encrypt',
|
|
@@ -197,97 +164,9 @@ class CryptoAsymmetricAlgorithm {
|
|
|
197
164
|
throw new Error('The algorithm is not supported for key generation.');
|
|
198
165
|
}).call(this);
|
|
199
166
|
}
|
|
200
|
-
useKeyPair() {
|
|
201
|
-
return _async_to_generator$2(function*() {
|
|
202
|
-
if (typeof this.keyPair !== 'undefined') {
|
|
203
|
-
return this.keyPair;
|
|
204
|
-
}
|
|
205
|
-
return this.generateKeyPair();
|
|
206
|
-
}).call(this);
|
|
207
|
-
}
|
|
208
|
-
exportPublicKey() {
|
|
209
|
-
return _async_to_generator$2(function*() {
|
|
210
|
-
const keyPair = yield this.useKeyPair();
|
|
211
|
-
return exportAsymmetricPublicKey(keyPair.publicKey);
|
|
212
|
-
}).call(this);
|
|
213
|
-
}
|
|
214
|
-
exportPrivateKey() {
|
|
215
|
-
return _async_to_generator$2(function*() {
|
|
216
|
-
const keyPair = yield this.useKeyPair();
|
|
217
|
-
return exportAsymmetricPrivateKey(keyPair.privateKey);
|
|
218
|
-
}).call(this);
|
|
219
|
-
}
|
|
220
|
-
encrypt(data, remoteKey) {
|
|
221
|
-
return _async_to_generator$2(function*() {
|
|
222
|
-
const keyPair = yield this.useKeyPair();
|
|
223
|
-
if (this.algorithm.name === AsymmetricCryptoAlgorithmName.RSA_OAEP) {
|
|
224
|
-
return crypto.subtle.encrypt({
|
|
225
|
-
name: 'RSA-OAEP'
|
|
226
|
-
}, remoteKey || keyPair.publicKey, data);
|
|
227
|
-
}
|
|
228
|
-
if (this.algorithm.name === AsymmetricCryptoAlgorithmName.ECDH) {
|
|
229
|
-
if (typeof remoteKey === 'undefined') {
|
|
230
|
-
throw new Error('Remote public key is required.');
|
|
231
|
-
}
|
|
232
|
-
const array = new Uint8Array(16);
|
|
233
|
-
const iv = crypto.getRandomValues(array);
|
|
234
|
-
const key = yield crypto.subtle.deriveKey({
|
|
235
|
-
name: 'ECDH',
|
|
236
|
-
public: remoteKey
|
|
237
|
-
}, keyPair.privateKey, {
|
|
238
|
-
name: 'AES-GCM',
|
|
239
|
-
length: 256
|
|
240
|
-
}, true, [
|
|
241
|
-
'encrypt'
|
|
242
|
-
]);
|
|
243
|
-
const arrayBuffer = yield crypto.subtle.encrypt({
|
|
244
|
-
name: 'AES-GCM',
|
|
245
|
-
length: 256,
|
|
246
|
-
iv
|
|
247
|
-
}, key, data);
|
|
248
|
-
const buffer = Buffer.from(arrayBuffer);
|
|
249
|
-
return Buffer.concat([
|
|
250
|
-
iv,
|
|
251
|
-
buffer
|
|
252
|
-
]);
|
|
253
|
-
}
|
|
254
|
-
throw new Error('Unsupported algorithm for encryption.');
|
|
255
|
-
}).call(this);
|
|
256
|
-
}
|
|
257
|
-
decrypt(data, remoteKey) {
|
|
258
|
-
return _async_to_generator$2(function*() {
|
|
259
|
-
const keyPair = yield this.useKeyPair();
|
|
260
|
-
if (this.algorithm.name === AsymmetricCryptoAlgorithmName.RSA_OAEP) {
|
|
261
|
-
return crypto.subtle.decrypt({
|
|
262
|
-
name: 'RSA-OAEP'
|
|
263
|
-
}, keyPair.privateKey, data);
|
|
264
|
-
}
|
|
265
|
-
if (this.algorithm.name === AsymmetricCryptoAlgorithmName.ECDH) {
|
|
266
|
-
if (typeof remoteKey === 'undefined') {
|
|
267
|
-
throw new Error('Remote public key is required.');
|
|
268
|
-
}
|
|
269
|
-
const iv = data.slice(0, 16);
|
|
270
|
-
const key = yield crypto.subtle.deriveKey({
|
|
271
|
-
name: 'ECDH',
|
|
272
|
-
public: remoteKey
|
|
273
|
-
}, keyPair.privateKey, {
|
|
274
|
-
name: 'AES-GCM',
|
|
275
|
-
length: 256
|
|
276
|
-
}, true, [
|
|
277
|
-
'decrypt'
|
|
278
|
-
]);
|
|
279
|
-
return crypto.subtle.decrypt({
|
|
280
|
-
name: 'AES-GCM',
|
|
281
|
-
length: 256,
|
|
282
|
-
iv
|
|
283
|
-
}, key, data.slice(16));
|
|
284
|
-
}
|
|
285
|
-
throw new Error('Unsupported algorithm for decryption.');
|
|
286
|
-
}).call(this);
|
|
287
|
-
}
|
|
288
167
|
constructor(algorithm){
|
|
289
|
-
_define_property
|
|
290
|
-
_define_property
|
|
168
|
+
_define_property(this, "algorithm", void 0);
|
|
169
|
+
_define_property(this, "keyPair", void 0);
|
|
291
170
|
if (algorithm.name === AsymmetricCryptoAlgorithmName.RSA_OAEP) {
|
|
292
171
|
algorithm = _object_spread_props(_object_spread({}, algorithm), {
|
|
293
172
|
publicExponent: new Uint8Array([
|
|
@@ -301,176 +180,21 @@ class CryptoAsymmetricAlgorithm {
|
|
|
301
180
|
}
|
|
302
181
|
}
|
|
303
182
|
|
|
304
|
-
/*
|
|
305
|
-
* Copyright (c) 2024.
|
|
306
|
-
* Author Peter Placzek (tada5hi)
|
|
307
|
-
* For the full copyright and license information,
|
|
308
|
-
* view the LICENSE file that was distributed with this source code.
|
|
309
|
-
*/ function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
310
|
-
try {
|
|
311
|
-
var info = gen[key](arg);
|
|
312
|
-
var value = info.value;
|
|
313
|
-
} catch (error) {
|
|
314
|
-
reject(error);
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
if (info.done) {
|
|
318
|
-
resolve(value);
|
|
319
|
-
} else {
|
|
320
|
-
Promise.resolve(value).then(_next, _throw);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
function _async_to_generator$1(fn) {
|
|
324
|
-
return function() {
|
|
325
|
-
var self = this, args = arguments;
|
|
326
|
-
return new Promise(function(resolve, reject) {
|
|
327
|
-
var gen = fn.apply(self, args);
|
|
328
|
-
function _next(value) {
|
|
329
|
-
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
330
|
-
}
|
|
331
|
-
function _throw(err) {
|
|
332
|
-
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
333
|
-
}
|
|
334
|
-
_next(undefined);
|
|
335
|
-
});
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
function _define_property(obj, key, value) {
|
|
339
|
-
if (key in obj) {
|
|
340
|
-
Object.defineProperty(obj, key, {
|
|
341
|
-
value: value,
|
|
342
|
-
enumerable: true,
|
|
343
|
-
configurable: true,
|
|
344
|
-
writable: true
|
|
345
|
-
});
|
|
346
|
-
} else {
|
|
347
|
-
obj[key] = value;
|
|
348
|
-
}
|
|
349
|
-
return obj;
|
|
350
|
-
}
|
|
351
|
-
class CryptoSymmetricAlgorithm {
|
|
352
|
-
generateKey() {
|
|
353
|
-
return _async_to_generator$1(function*() {
|
|
354
|
-
return crypto.subtle.generateKey({
|
|
355
|
-
name: this.algorithm.name,
|
|
356
|
-
length: 256
|
|
357
|
-
}, true, [
|
|
358
|
-
'encrypt',
|
|
359
|
-
'decrypt'
|
|
360
|
-
]);
|
|
361
|
-
}).call(this);
|
|
362
|
-
}
|
|
363
|
-
importKey(buffer) {
|
|
364
|
-
return _async_to_generator$1(function*() {
|
|
365
|
-
return crypto.subtle.importKey('raw', buffer, {
|
|
366
|
-
name: this.algorithm.name,
|
|
367
|
-
length: 256
|
|
368
|
-
}, true, [
|
|
369
|
-
'encrypt',
|
|
370
|
-
'decrypt'
|
|
371
|
-
]);
|
|
372
|
-
}).call(this);
|
|
373
|
-
}
|
|
374
|
-
encrypt(key, iv, data) {
|
|
375
|
-
return _async_to_generator$1(function*() {
|
|
376
|
-
const arrayBuffer = yield crypto.subtle.encrypt({
|
|
377
|
-
name: this.algorithm.name,
|
|
378
|
-
length: 256,
|
|
379
|
-
iv
|
|
380
|
-
}, key, data);
|
|
381
|
-
const buffer = Buffer.from(arrayBuffer);
|
|
382
|
-
return Buffer.concat([
|
|
383
|
-
iv,
|
|
384
|
-
buffer
|
|
385
|
-
]);
|
|
386
|
-
}).call(this);
|
|
387
|
-
}
|
|
388
|
-
decrypt(key, data) {
|
|
389
|
-
return _async_to_generator$1(function*() {
|
|
390
|
-
const iv = data.slice(0, 16);
|
|
391
|
-
const arrayBuffer = yield crypto.subtle.decrypt({
|
|
392
|
-
name: this.algorithm.name,
|
|
393
|
-
length: 256,
|
|
394
|
-
iv
|
|
395
|
-
}, key, data.slice(16));
|
|
396
|
-
return Buffer.from(arrayBuffer);
|
|
397
|
-
}).call(this);
|
|
398
|
-
}
|
|
399
|
-
constructor(algorithm){
|
|
400
|
-
_define_property(this, "algorithm", void 0);
|
|
401
|
-
this.algorithm = algorithm;
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
/*
|
|
406
|
-
* Copyright (c) 2025.
|
|
407
|
-
* Author Peter Placzek (tada5hi)
|
|
408
|
-
* For the full copyright and license information,
|
|
409
|
-
* view the LICENSE file that was distributed with this source code.
|
|
410
|
-
*/ var LogLevel = /*#__PURE__*/ function(LogLevel) {
|
|
411
|
-
/**
|
|
412
|
-
* indicates that the system is unusable
|
|
413
|
-
* and requires immediate attention
|
|
414
|
-
*/ LogLevel["EMERGENCE"] = "emerg";
|
|
415
|
-
/**
|
|
416
|
-
* indicates that immediate action is necessary
|
|
417
|
-
* to resolve a critical issue.
|
|
418
|
-
*/ LogLevel["ALERT"] = "alert";
|
|
419
|
-
/**
|
|
420
|
-
* signifies critical conditions in the program that demand
|
|
421
|
-
* intervention to prevent system failure.
|
|
422
|
-
*/ LogLevel["CRITICAL"] = "crit";
|
|
423
|
-
/**
|
|
424
|
-
* indicates error conditions that impair
|
|
425
|
-
* some operation but are less severe than critical situations.
|
|
426
|
-
*/ LogLevel["ERROR"] = "error";
|
|
427
|
-
/**
|
|
428
|
-
* signifies potential issues that may lead to errors
|
|
429
|
-
* or unexpected behavior in the future if not addressed.
|
|
430
|
-
*/ LogLevel["WARNING"] = "warn";
|
|
431
|
-
/**
|
|
432
|
-
* applies to normal but significant
|
|
433
|
-
* conditions that may require monitoring
|
|
434
|
-
*/ LogLevel["NOTICE"] = "notice";
|
|
435
|
-
/**
|
|
436
|
-
* includes messages that provide a record
|
|
437
|
-
* of the normal operation of the system.
|
|
438
|
-
*/ LogLevel["INFORMATIONAL"] = "info";
|
|
439
|
-
/**
|
|
440
|
-
* intended for logging detailed information about the system
|
|
441
|
-
* for debugging purposes.
|
|
442
|
-
*/ LogLevel["DEBUG"] = "debug";
|
|
443
|
-
return LogLevel;
|
|
444
|
-
}({});
|
|
445
|
-
|
|
446
|
-
function omitLogProperties(input) {
|
|
447
|
-
return kit.omitRecord(input, [
|
|
448
|
-
'message',
|
|
449
|
-
'time',
|
|
450
|
-
'labels',
|
|
451
|
-
'level'
|
|
452
|
-
]);
|
|
453
|
-
}
|
|
454
|
-
function pickLogProperties(input) {
|
|
455
|
-
return kit.pickRecord(input, [
|
|
456
|
-
'message',
|
|
457
|
-
'time',
|
|
458
|
-
'labels',
|
|
459
|
-
'level'
|
|
460
|
-
]);
|
|
461
|
-
}
|
|
462
|
-
|
|
463
183
|
/*
|
|
464
184
|
* Copyright (c) 2021-2024.
|
|
465
185
|
* Author Peter Placzek (tada5hi)
|
|
466
186
|
* For the full copyright and license information,
|
|
467
187
|
* view the LICENSE file that was distributed with this source code.
|
|
468
188
|
*/ var PermissionName = /*#__PURE__*/ function(PermissionName) {
|
|
189
|
+
PermissionName["EVENT_CREATE"] = "event_create";
|
|
469
190
|
PermissionName["EVENT_READ"] = "event_read";
|
|
470
191
|
PermissionName["EVENT_DELETE"] = "event_delete";
|
|
471
192
|
PermissionName["BUCKET_CREATE"] = "bucket_create";
|
|
472
193
|
PermissionName["BUCKET_UPDATE"] = "bucket_update";
|
|
473
194
|
PermissionName["BUCKET_DELETE"] = "bucket_delete";
|
|
195
|
+
PermissionName["LOG_CREATE"] = "log_create";
|
|
196
|
+
PermissionName["LOG_DELETE"] = "log_delete";
|
|
197
|
+
PermissionName["LOG_READ"] = "log_read";
|
|
474
198
|
PermissionName["PROJECT_CREATE"] = "project_create";
|
|
475
199
|
PermissionName["PROJECT_DELETE"] = "project_delete";
|
|
476
200
|
PermissionName["PROJECT_UPDATE"] = "project_update";
|
|
@@ -578,6 +302,15 @@ function createNanoID(alphabetOrLen, len) {
|
|
|
578
302
|
return nanoid.customAlphabet('0123456789abcdefghijklmnopqrstuvwxyz', len || 21)();
|
|
579
303
|
}
|
|
580
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
|
+
|
|
581
314
|
/*
|
|
582
315
|
* Copyright (c) 2021-2024.
|
|
583
316
|
* Author Peter Placzek (tada5hi)
|
|
@@ -742,6 +475,35 @@ function wait(ms) {
|
|
|
742
475
|
return !resourceRealmId || (realm === null || realm === void 0 ? void 0 : realm.id) === resourceRealmId;
|
|
743
476
|
}
|
|
744
477
|
|
|
478
|
+
/*
|
|
479
|
+
* Copyright (c) 2025.
|
|
480
|
+
* Author Peter Placzek (tada5hi)
|
|
481
|
+
* For the full copyright and license information,
|
|
482
|
+
* view the LICENSE file that was distributed with this source code.
|
|
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';
|
|
505
|
+
}
|
|
506
|
+
|
|
745
507
|
/*
|
|
746
508
|
* Copyright (c) 2025.
|
|
747
509
|
* Author Peter Placzek (tada5hi)
|
|
@@ -766,12 +528,14 @@ function wait(ms) {
|
|
|
766
528
|
|
|
767
529
|
exports.AsymmetricCryptoAlgorithmName = AsymmetricCryptoAlgorithmName;
|
|
768
530
|
exports.CryptoAsymmetricAlgorithm = CryptoAsymmetricAlgorithm;
|
|
769
|
-
exports.
|
|
531
|
+
exports.DomainEventName = DomainEventName;
|
|
532
|
+
exports.DomainEventNamespace = DomainEventNamespace;
|
|
770
533
|
exports.EnvironmentName = EnvironmentName;
|
|
771
|
-
exports.LogLevel = LogLevel;
|
|
772
534
|
exports.PermissionName = PermissionName;
|
|
773
535
|
exports.alphaNumHyphenUnderscoreRegex = alphaNumHyphenUnderscoreRegex;
|
|
536
|
+
exports.buildDomainChannelName = buildDomainChannelName;
|
|
774
537
|
exports.buildDomainEventFullName = buildDomainEventFullName;
|
|
538
|
+
exports.buildDomainNamespaceName = buildDomainNamespaceName;
|
|
775
539
|
exports.createNanoID = createNanoID;
|
|
776
540
|
exports.deleteUndefinedObjectProperties = deleteUndefinedObjectProperties;
|
|
777
541
|
exports.detectProxyConnectionConfig = detectProxyConnectionConfig;
|
|
@@ -780,7 +544,6 @@ exports.exportAsymmetricPublicKey = exportAsymmetricPublicKey;
|
|
|
780
544
|
exports.getHostNameFromString = getHostNameFromString;
|
|
781
545
|
exports.hasOwnProperty = hasOwnProperty;
|
|
782
546
|
exports.hexToUTF8 = hexToUTF8;
|
|
783
|
-
exports.importAsymmetricPublicKey = importAsymmetricPublicKey;
|
|
784
547
|
exports.isBool = isBool;
|
|
785
548
|
exports.isBoolFalse = isBoolFalse;
|
|
786
549
|
exports.isBoolTrue = isBoolTrue;
|
|
@@ -790,10 +553,9 @@ exports.isObject = isObject;
|
|
|
790
553
|
exports.isPropertySet = isPropertySet;
|
|
791
554
|
exports.isRealmResourceReadable = isRealmResourceReadable;
|
|
792
555
|
exports.isRealmResourceWritable = isRealmResourceWritable;
|
|
556
|
+
exports.nanoSeconds = nanoSeconds;
|
|
793
557
|
exports.nullifyEmptyObjectProperties = nullifyEmptyObjectProperties;
|
|
794
|
-
exports.omitLogProperties = omitLogProperties;
|
|
795
558
|
exports.parseProxyConnectionString = parseProxyConnectionString;
|
|
796
|
-
exports.pickLogProperties = pickLogProperties;
|
|
797
559
|
exports.registryRobotSecretRegex = registryRobotSecretRegex;
|
|
798
560
|
exports.wait = wait;
|
|
799
561
|
//# sourceMappingURL=index.cjs.map
|