@alexberardi/jarvis-admin 0.1.21 → 0.1.23

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.
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,157 @@
1
+ // Originally imported from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/8b36dbdf95b624b8a7cd7f8416f06c15d274f9e6/types/bcryptjs/index.d.ts
2
+ // MIT license.
3
+
4
+ /** Called with an error on failure or a value of type `T` upon success. */
5
+ type Callback<T> = (err: Error | null, result?: T) => void;
6
+ /** Called with the percentage of rounds completed (0.0 - 1.0), maximally once per `MAX_EXECUTION_TIME = 100` ms. */
7
+ type ProgressCallback = (percentage: number) => void;
8
+ /** Called to obtain random bytes when both Web Crypto API and Node.js crypto are not available. */
9
+ type RandomFallback = (length: number) => number[];
10
+
11
+ /**
12
+ * Sets the pseudo random number generator to use as a fallback if neither node's crypto module nor the Web Crypto API is available.
13
+ * Please note: It is highly important that the PRNG used is cryptographically secure and that it is seeded properly!
14
+ * @param random Function taking the number of bytes to generate as its sole argument, returning the corresponding array of cryptographically secure random byte values.
15
+ */
16
+ export declare function setRandomFallback(random: RandomFallback): void;
17
+
18
+ /**
19
+ * Synchronously generates a salt.
20
+ * @param rounds Number of rounds to use, defaults to 10 if omitted
21
+ * @return Resulting salt
22
+ * @throws If a random fallback is required but not set
23
+ */
24
+ export declare function genSaltSync(rounds?: number): string;
25
+
26
+ /**
27
+ * Asynchronously generates a salt.
28
+ * @param rounds Number of rounds to use, defaults to 10 if omitted
29
+ * @return Promise with resulting salt, if callback has been omitted
30
+ */
31
+ export declare function genSalt(rounds?: number): Promise<string>;
32
+
33
+ /**
34
+ * Asynchronously generates a salt.
35
+ * @param callback Callback receiving the error, if any, and the resulting salt
36
+ */
37
+ export declare function genSalt(callback: Callback<string>): void;
38
+
39
+ /**
40
+ * Asynchronously generates a salt.
41
+ * @param rounds Number of rounds to use, defaults to 10 if omitted
42
+ * @param callback Callback receiving the error, if any, and the resulting salt
43
+ */
44
+ export declare function genSalt(
45
+ rounds: number,
46
+ callback: Callback<string>,
47
+ ): void;
48
+
49
+ /**
50
+ * Synchronously generates a hash for the given password.
51
+ * @param password Password to hash
52
+ * @param salt Salt length to generate or salt to use, default to 10
53
+ * @return Resulting hash
54
+ */
55
+ export declare function hashSync(
56
+ password: string,
57
+ salt?: number | string,
58
+ ): string;
59
+
60
+ /**
61
+ * Asynchronously generates a hash for the given password.
62
+ * @param password Password to hash
63
+ * @param salt Salt length to generate or salt to use
64
+ * @return Promise with resulting hash, if callback has been omitted
65
+ */
66
+ export declare function hash(
67
+ password: string,
68
+ salt: number | string,
69
+ ): Promise<string>;
70
+
71
+ /**
72
+ * Asynchronously generates a hash for the given password.
73
+ * @param password Password to hash
74
+ * @param salt Salt length to generate or salt to use
75
+ * @param callback Callback receiving the error, if any, and the resulting hash
76
+ * @param progressCallback Callback successively called with the percentage of rounds completed (0.0 - 1.0), maximally once per MAX_EXECUTION_TIME = 100 ms.
77
+ */
78
+ export declare function hash(
79
+ password: string,
80
+ salt: number | string,
81
+ callback?: Callback<string>,
82
+ progressCallback?: ProgressCallback,
83
+ ): void;
84
+
85
+ /**
86
+ * Synchronously tests a password against a hash.
87
+ * @param password Password to test
88
+ * @param hash Hash to test against
89
+ * @return true if matching, otherwise false
90
+ */
91
+ export declare function compareSync(password: string, hash: string): boolean;
92
+
93
+ /**
94
+ * Asynchronously tests a password against a hash.
95
+ * @param password Password to test
96
+ * @param hash Hash to test against
97
+ * @return Promise, if callback has been omitted
98
+ */
99
+ export declare function compare(
100
+ password: string,
101
+ hash: string,
102
+ ): Promise<boolean>;
103
+
104
+ /**
105
+ * Asynchronously tests a password against a hash.
106
+ * @param password Password to test
107
+ * @param hash Hash to test against
108
+ * @param callback Callback receiving the error, if any, otherwise the result
109
+ * @param progressCallback Callback successively called with the percentage of rounds completed (0.0 - 1.0), maximally once per MAX_EXECUTION_TIME = 100 ms.
110
+ */
111
+ export declare function compare(
112
+ password: string,
113
+ hash: string,
114
+ callback?: Callback<boolean>,
115
+ progressCallback?: ProgressCallback,
116
+ ): void;
117
+
118
+ /**
119
+ * Gets the number of rounds used to encrypt the specified hash.
120
+ * @param hash Hash to extract the used number of rounds from
121
+ * @return Number of rounds used
122
+ */
123
+ export declare function getRounds(hash: string): number;
124
+
125
+ /**
126
+ * Gets the salt portion from a hash. Does not validate the hash.
127
+ * @param hash Hash to extract the salt from
128
+ * @return Extracted salt part
129
+ */
130
+ export declare function getSalt(hash: string): string;
131
+
132
+ /**
133
+ * Tests if a password will be truncated when hashed, that is its length is
134
+ * greater than 72 bytes when converted to UTF-8.
135
+ * @param password The password to test
136
+ * @returns `true` if truncated, otherwise `false`
137
+ */
138
+ export declare function truncates(password: string): boolean;
139
+
140
+ /**
141
+ * Encodes a byte array to base64 with up to len bytes of input, using the custom bcrypt alphabet.
142
+ * @function
143
+ * @param b Byte array
144
+ * @param len Maximum input length
145
+ */
146
+ export declare function encodeBase64(
147
+ b: Readonly<ArrayLike<number>>,
148
+ len: number,
149
+ ): string;
150
+
151
+ /**
152
+ * Decodes a base64 encoded string to up to len bytes of output, using the custom bcrypt alphabet.
153
+ * @function
154
+ * @param s String to decode
155
+ * @param len Maximum output length
156
+ */
157
+ export declare function decodeBase64(s: string, len: number): number[];
@@ -13,10 +13,12 @@
13
13
  "dependencies": {
14
14
  "@fastify/cors": "^11.0.0",
15
15
  "@fastify/static": "^8.1.0",
16
+ "bcryptjs": "^3.0.3",
16
17
  "dockerode": "^4.0.4",
17
18
  "fastify": "^5.2.1"
18
19
  },
19
20
  "devDependencies": {
21
+ "@types/bcryptjs": "^2.4.6",
20
22
  "@types/dockerode": "^3.3.35",
21
23
  "@types/node": "^22.15.0",
22
24
  "tsx": "^4.19.0",
@@ -195,7 +195,8 @@
195
195
  "dependsOn": ["jarvis-auth", "jarvis-config-service"],
196
196
  "envVars": [
197
197
  { "name": "JARVIS_CONFIG_URL", "description": "Config service URL", "required": false, "default": "http://jarvis-config-service:7700" }
198
- ]
198
+ ],
199
+ "volumes": ["/var/run/docker.sock:/var/run/docker.sock"]
199
200
  }
200
201
  ],
201
202
  "infrastructure": [