@privateaim/kit 0.8.15 → 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 (53) hide show
  1. package/CHANGELOG.md +12 -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 -1
  13. package/dist/domains/index.d.ts.map +1 -1
  14. package/dist/domains/permission/constants.d.ts +4 -0
  15. package/dist/domains/permission/constants.d.ts.map +1 -1
  16. package/dist/index.cjs +62 -300
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.mjs +58 -296
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/utils/index.d.ts +1 -0
  21. package/dist/utils/index.d.ts.map +1 -1
  22. package/dist/utils/nanoseconds.d.ts +2 -0
  23. package/dist/utils/nanoseconds.d.ts.map +1 -0
  24. package/package.json +1 -1
  25. package/src/crypto/asymmetric/helpers.ts +0 -30
  26. package/src/crypto/asymmetric/module.ts +1 -141
  27. package/src/crypto/index.ts +0 -1
  28. package/src/domains/{log/index.ts → constants.ts} +7 -3
  29. package/src/domains/helpers.ts +24 -0
  30. package/src/domains/index.ts +3 -1
  31. package/src/domains/permission/constants.ts +5 -0
  32. package/src/utils/index.ts +1 -0
  33. package/src/utils/nanoseconds.ts +14 -0
  34. package/dist/crypto/symmetric/index.d.ts +0 -3
  35. package/dist/crypto/symmetric/index.d.ts.map +0 -1
  36. package/dist/crypto/symmetric/module.d.ts +0 -10
  37. package/dist/crypto/symmetric/module.d.ts.map +0 -1
  38. package/dist/crypto/symmetric/types.d.ts +0 -3
  39. package/dist/crypto/symmetric/types.d.ts.map +0 -1
  40. package/dist/domains/log/constants.d.ts +0 -43
  41. package/dist/domains/log/constants.d.ts.map +0 -1
  42. package/dist/domains/log/entity.d.ts +0 -20
  43. package/dist/domains/log/entity.d.ts.map +0 -1
  44. package/dist/domains/log/helpers.d.ts +0 -4
  45. package/dist/domains/log/helpers.d.ts.map +0 -1
  46. package/dist/domains/log/index.d.ts +0 -4
  47. package/dist/domains/log/index.d.ts.map +0 -1
  48. package/src/crypto/symmetric/index.ts +0 -9
  49. package/src/crypto/symmetric/module.ts +0 -71
  50. package/src/crypto/symmetric/types.ts +0 -10
  51. package/src/domains/log/constants.ts +0 -56
  52. package/src/domains/log/entity.ts +0 -30
  53. package/src/domains/log/helpers.ts +0 -27
@@ -1,71 +0,0 @@
1
- /*
2
- * Copyright (c) 2024.
3
- * Author Peter Placzek (tada5hi)
4
- * For the full copyright and license information,
5
- * view the LICENSE file that was distributed with this source code.
6
- */
7
-
8
- import type { SymmetricAlgorithmParams } from './types';
9
-
10
- export class CryptoSymmetricAlgorithm {
11
- protected algorithm : SymmetricAlgorithmParams;
12
-
13
- constructor(algorithm: SymmetricAlgorithmParams) {
14
- this.algorithm = algorithm;
15
- }
16
-
17
- async generateKey() : Promise<CryptoKey> {
18
- return crypto.subtle.generateKey(
19
- {
20
- name: this.algorithm.name,
21
- length: 256,
22
- },
23
- true,
24
- ['encrypt', 'decrypt'],
25
- );
26
- }
27
-
28
- async importKey(buffer: Buffer | ArrayBuffer) : Promise<CryptoKey> {
29
- return crypto.subtle.importKey(
30
- 'raw',
31
- buffer,
32
- {
33
- name: this.algorithm.name,
34
- length: 256,
35
- },
36
- true,
37
- ['encrypt', 'decrypt'],
38
- );
39
- }
40
-
41
- async encrypt(key: CryptoKey, iv: Buffer, data: Buffer) : Promise<Buffer> {
42
- const arrayBuffer = await crypto.subtle.encrypt(
43
- {
44
- name: this.algorithm.name,
45
- length: 256,
46
- iv,
47
- },
48
- key,
49
- data,
50
- );
51
-
52
- const buffer = Buffer.from(arrayBuffer);
53
-
54
- return Buffer.concat([iv, buffer]);
55
- }
56
-
57
- async decrypt(key: CryptoKey, data: Buffer) : Promise<Buffer> {
58
- const iv = data.slice(0, 16);
59
- const arrayBuffer = await crypto.subtle.decrypt(
60
- {
61
- name: this.algorithm.name,
62
- length: 256,
63
- iv,
64
- },
65
- key,
66
- data.slice(16),
67
- );
68
-
69
- return Buffer.from(arrayBuffer);
70
- }
71
- }
@@ -1,10 +0,0 @@
1
- /*
2
- * Copyright (c) 2024.
3
- * Author Peter Placzek (tada5hi)
4
- * For the full copyright and license information,
5
- * view the LICENSE file that was distributed with this source code.
6
- */
7
-
8
- import type { webcrypto } from 'crypto';
9
-
10
- export type SymmetricAlgorithmParams = webcrypto.AesKeyGenParams;
@@ -1,56 +0,0 @@
1
- /*
2
- * Copyright (c) 2025.
3
- * Author Peter Placzek (tada5hi)
4
- * For the full copyright and license information,
5
- * view the LICENSE file that was distributed with this source code.
6
- */
7
-
8
- export enum LogLevel {
9
- /**
10
- * indicates that the system is unusable
11
- * and requires immediate attention
12
- */
13
- EMERGENCE = 'emerg',
14
-
15
- /**
16
- * indicates that immediate action is necessary
17
- * to resolve a critical issue.
18
- */
19
- ALERT = 'alert',
20
-
21
- /**
22
- * signifies critical conditions in the program that demand
23
- * intervention to prevent system failure.
24
- */
25
- CRITICAL = 'crit',
26
-
27
- /**
28
- * indicates error conditions that impair
29
- * some operation but are less severe than critical situations.
30
- */
31
- ERROR = 'error',
32
-
33
- /**
34
- * signifies potential issues that may lead to errors
35
- * or unexpected behavior in the future if not addressed.
36
- */
37
- WARNING = 'warn',
38
-
39
- /**
40
- * applies to normal but significant
41
- * conditions that may require monitoring
42
- */
43
- NOTICE = 'notice',
44
-
45
- /**
46
- * includes messages that provide a record
47
- * of the normal operation of the system.
48
- */
49
- INFORMATIONAL = 'info',
50
-
51
- /**
52
- * intended for logging detailed information about the system
53
- * for debugging purposes.
54
- */
55
- DEBUG = 'debug',
56
- }
@@ -1,30 +0,0 @@
1
- /*
2
- * Copyright (c) 2025.
3
- * Author Peter Placzek (tada5hi)
4
- * For the full copyright and license information,
5
- * view the LICENSE file that was distributed with this source code.
6
- */
7
-
8
- import type { LogLevel } from './index';
9
-
10
- export interface Log {
11
- /**
12
- * Time in micro seconds
13
- */
14
- time: string | bigint,
15
-
16
- /**
17
- * message
18
- */
19
- message: string,
20
-
21
- /**
22
- * level
23
- */
24
- level: `${LogLevel}`,
25
-
26
- /**
27
- * additional labels
28
- */
29
- labels: Record<string, string>
30
- }
@@ -1,27 +0,0 @@
1
- /*
2
- * Copyright (c) 2025.
3
- * Author Peter Placzek (tada5hi)
4
- * For the full copyright and license information,
5
- * view the LICENSE file that was distributed with this source code.
6
- */
7
-
8
- import { omitRecord, pickRecord } from '@authup/kit';
9
- import type { Log } from './entity';
10
-
11
- export function omitLogProperties<T extends Log>(input: T) : Omit<T, keyof Log> {
12
- return omitRecord(input, [
13
- 'message',
14
- 'time',
15
- 'labels',
16
- 'level',
17
- ]);
18
- }
19
-
20
- export function pickLogProperties<T extends Log>(input: T) : Log {
21
- return pickRecord(input, [
22
- 'message',
23
- 'time',
24
- 'labels',
25
- 'level',
26
- ]);
27
- }