@mstone6969/vault 0.2.0 → 0.5.0
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/README.md +198 -6
- package/dist/crypto.d.ts +99 -2
- package/dist/crypto.d.ts.map +1 -1
- package/dist/errors.d.ts +122 -4
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +447 -33
- package/dist/index.js.map +9 -7
- package/dist/providers.d.ts +131 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/stores/file.d.ts +190 -0
- package/dist/stores/file.d.ts.map +1 -0
- package/dist/stores/file.js +1 -0
- package/dist/stores/memory.d.ts +98 -7
- package/dist/stores/memory.d.ts.map +1 -1
- package/dist/stores/sqlite.d.ts +140 -9
- package/dist/stores/sqlite.d.ts.map +1 -1
- package/dist/stores/sqlite.js +47 -12
- package/dist/stores/sqlite.js.map +3 -3
- package/dist/types.d.ts +408 -17
- package/dist/types.d.ts.map +1 -1
- package/dist/vault.d.ts +554 -19
- package/dist/vault.d.ts.map +1 -1
- package/docs/README.md +10 -0
- package/docs/index/README.md +48 -0
- package/docs/index/classes/FileStore.md +341 -0
- package/docs/index/classes/MemoryStore.md +240 -0
- package/docs/index/classes/Vault.md +805 -0
- package/docs/index/classes/VaultError.md +371 -0
- package/docs/index/classes/VaultKeyError.md +370 -0
- package/docs/index/functions/envKey.md +43 -0
- package/docs/index/functions/fileKey.md +46 -0
- package/docs/index/functions/generateKey.md +39 -0
- package/docs/index/functions/importKey.md +49 -0
- package/docs/index/functions/isKeyProvider.md +43 -0
- package/docs/index/functions/open.md +67 -0
- package/docs/index/functions/randomValue.md +53 -0
- package/docs/index/functions/seal.md +56 -0
- package/docs/index/functions/staticKey.md +39 -0
- package/docs/index/type-aliases/Generator.md +58 -0
- package/docs/index/type-aliases/HistoryEntry.md +65 -0
- package/docs/index/type-aliases/KeyProvider.md +74 -0
- package/docs/index/type-aliases/PutOptions.md +141 -0
- package/docs/index/type-aliases/RekeyReport.md +37 -0
- package/docs/index/type-aliases/RotationContext.md +49 -0
- package/docs/index/type-aliases/RotationPolicy.md +142 -0
- package/docs/index/type-aliases/SecretRecord.md +214 -0
- package/docs/index/type-aliases/SecretSummary.md +56 -0
- package/docs/index/type-aliases/VaultEvent.md +95 -0
- package/docs/index/type-aliases/VaultOptions.md +142 -0
- package/docs/index/type-aliases/VaultStore.md +156 -0
- package/docs/index/variables/DEFAULT_ALPHABET.md +29 -0
- package/docs/index/variables/DEFAULT_HISTORY_LIMIT.md +28 -0
- package/docs/index/variables/DEFAULT_PREFIX.md +23 -0
- package/docs/stores/sqlite/README.md +11 -0
- package/docs/stores/sqlite/classes/SqliteStore.md +307 -0
- package/package.json +15 -5
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
[**@mstone6969/vault**](../../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@mstone6969/vault](../../README.md) / [index](../README.md) / VaultError
|
|
6
|
+
|
|
7
|
+
# Class: VaultError
|
|
8
|
+
|
|
9
|
+
Defined in: cron/vault/src/errors.ts:27
|
|
10
|
+
|
|
11
|
+
A caller mistake: a bad name, an empty value, a missing secret.
|
|
12
|
+
|
|
13
|
+
## Remarks
|
|
14
|
+
|
|
15
|
+
Everything the vault throws on purpose is a `VaultError`, so a caller can
|
|
16
|
+
tell "you asked for something that cannot be done" apart from a bug, and
|
|
17
|
+
answer accordingly, with one `instanceof`.
|
|
18
|
+
|
|
19
|
+
## Example
|
|
20
|
+
|
|
21
|
+
**Turning a vault call into an HTTP response**
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { Vault, VaultError, MemoryStore, generateKey } from "@mstone6969/vault"
|
|
25
|
+
|
|
26
|
+
const vault = new Vault({ key: generateKey(), store: new MemoryStore() })
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
return new Response(await vault.open("alice", "stripe"))
|
|
30
|
+
} catch (error) {
|
|
31
|
+
if (error instanceof VaultError) {
|
|
32
|
+
return new Response(error.message, { status: error.status })
|
|
33
|
+
}
|
|
34
|
+
throw error
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## See
|
|
39
|
+
|
|
40
|
+
[VaultKeyError](VaultKeyError.md) for the key and ciphertext failures.
|
|
41
|
+
|
|
42
|
+
## Extends
|
|
43
|
+
|
|
44
|
+
- `Error`
|
|
45
|
+
|
|
46
|
+
## Extended by
|
|
47
|
+
|
|
48
|
+
- [`VaultKeyError`](VaultKeyError.md)
|
|
49
|
+
|
|
50
|
+
## Constructors
|
|
51
|
+
|
|
52
|
+
### Constructor
|
|
53
|
+
|
|
54
|
+
> **new VaultError**(`message`, `status?`): `VaultError`
|
|
55
|
+
|
|
56
|
+
Defined in: cron/vault/src/errors.ts:33
|
|
57
|
+
|
|
58
|
+
#### Parameters
|
|
59
|
+
|
|
60
|
+
##### message
|
|
61
|
+
|
|
62
|
+
`string`
|
|
63
|
+
|
|
64
|
+
What the caller did that the vault would not do. Names
|
|
65
|
+
and owners appear in it; secret values never do, so it is safe to log.
|
|
66
|
+
|
|
67
|
+
##### status?
|
|
68
|
+
|
|
69
|
+
`number` = `422`
|
|
70
|
+
|
|
71
|
+
Suggested HTTP status. See [VaultError.status](#status).
|
|
72
|
+
|
|
73
|
+
#### Returns
|
|
74
|
+
|
|
75
|
+
`VaultError`
|
|
76
|
+
|
|
77
|
+
#### Overrides
|
|
78
|
+
|
|
79
|
+
`Error.constructor`
|
|
80
|
+
|
|
81
|
+
## Properties
|
|
82
|
+
|
|
83
|
+
### status
|
|
84
|
+
|
|
85
|
+
> `readonly` **status**: `number` = `422`
|
|
86
|
+
|
|
87
|
+
Defined in: cron/vault/src/errors.ts:63
|
|
88
|
+
|
|
89
|
+
Suggested HTTP status, for callers putting this behind an API.
|
|
90
|
+
|
|
91
|
+
#### Remarks
|
|
92
|
+
|
|
93
|
+
It is a suggestion, not a promise about transport: nothing in the
|
|
94
|
+
vault speaks HTTP. It exists so a handler can map a failure to a
|
|
95
|
+
response without knowing which check inside the vault failed.
|
|
96
|
+
|
|
97
|
+
The statuses actually thrown:
|
|
98
|
+
|
|
99
|
+
- `422` — bad input: a name that is not 1–64 characters of letters,
|
|
100
|
+
numbers, dot, dash or underscore; an empty value; a `randomValue`
|
|
101
|
+
length below one or an alphabet under two characters; a rotation
|
|
102
|
+
asked of an entry with no rotation policy.
|
|
103
|
+
- `404` — no secret under that name for that owner.
|
|
104
|
+
- `409` — the entry is `final`, so it can be deleted but not
|
|
105
|
+
replaced.
|
|
106
|
+
- `403` — the entry is sealed, so `read` will not hand it back.
|
|
107
|
+
`open` is the only way out.
|
|
108
|
+
- `410` — the entry's `expiresAt` has passed. The record is still
|
|
109
|
+
there; it just cannot be used.
|
|
110
|
+
- `501` — the entry's rotation policy names a generator this vault
|
|
111
|
+
was not constructed with.
|
|
112
|
+
- `500` — [VaultKeyError](VaultKeyError.md)'s default: a key or ciphertext
|
|
113
|
+
problem, which is the operator's fault rather than the caller's.
|
|
114
|
+
|
|
115
|
+
#### Default Value
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
422
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
***
|
|
122
|
+
|
|
123
|
+
### stackTraceLimit
|
|
124
|
+
|
|
125
|
+
> `static` **stackTraceLimit**: `number`
|
|
126
|
+
|
|
127
|
+
Defined in: node\_modules/@types/node/globals.d.ts:67
|
|
128
|
+
|
|
129
|
+
The `Error.stackTraceLimit` property specifies the number of stack frames
|
|
130
|
+
collected by a stack trace (whether generated by `new Error().stack` or
|
|
131
|
+
`Error.captureStackTrace(obj)`).
|
|
132
|
+
|
|
133
|
+
The default value is `10` but may be set to any valid JavaScript number. Changes
|
|
134
|
+
will affect any stack trace captured _after_ the value has been changed.
|
|
135
|
+
|
|
136
|
+
If set to a non-number value, or set to a negative number, stack traces will
|
|
137
|
+
not capture any frames.
|
|
138
|
+
|
|
139
|
+
#### Inherited from
|
|
140
|
+
|
|
141
|
+
`Error.stackTraceLimit`
|
|
142
|
+
|
|
143
|
+
***
|
|
144
|
+
|
|
145
|
+
### cause?
|
|
146
|
+
|
|
147
|
+
> `optional` **cause?**: `unknown`
|
|
148
|
+
|
|
149
|
+
Defined in: cron/node\_modules/.bun/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24
|
|
150
|
+
|
|
151
|
+
The cause of the error.
|
|
152
|
+
|
|
153
|
+
#### Inherited from
|
|
154
|
+
|
|
155
|
+
`Error.cause`
|
|
156
|
+
|
|
157
|
+
***
|
|
158
|
+
|
|
159
|
+
### name
|
|
160
|
+
|
|
161
|
+
> **name**: `string`
|
|
162
|
+
|
|
163
|
+
Defined in: cron/node\_modules/.bun/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1074
|
|
164
|
+
|
|
165
|
+
#### Inherited from
|
|
166
|
+
|
|
167
|
+
`Error.name`
|
|
168
|
+
|
|
169
|
+
***
|
|
170
|
+
|
|
171
|
+
### message
|
|
172
|
+
|
|
173
|
+
> **message**: `string`
|
|
174
|
+
|
|
175
|
+
Defined in: cron/node\_modules/.bun/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1075
|
|
176
|
+
|
|
177
|
+
#### Inherited from
|
|
178
|
+
|
|
179
|
+
`Error.message`
|
|
180
|
+
|
|
181
|
+
***
|
|
182
|
+
|
|
183
|
+
### stack?
|
|
184
|
+
|
|
185
|
+
> `optional` **stack?**: `string`
|
|
186
|
+
|
|
187
|
+
Defined in: cron/node\_modules/.bun/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076
|
|
188
|
+
|
|
189
|
+
#### Inherited from
|
|
190
|
+
|
|
191
|
+
`Error.stack`
|
|
192
|
+
|
|
193
|
+
## Methods
|
|
194
|
+
|
|
195
|
+
### captureStackTrace()
|
|
196
|
+
|
|
197
|
+
#### Call Signature
|
|
198
|
+
|
|
199
|
+
> `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`
|
|
200
|
+
|
|
201
|
+
Defined in: node\_modules/@types/node/globals.d.ts:51
|
|
202
|
+
|
|
203
|
+
Creates a `.stack` property on `targetObject`, which when accessed returns
|
|
204
|
+
a string representing the location in the code at which
|
|
205
|
+
`Error.captureStackTrace()` was called.
|
|
206
|
+
|
|
207
|
+
```js
|
|
208
|
+
const myObject = {};
|
|
209
|
+
Error.captureStackTrace(myObject);
|
|
210
|
+
myObject.stack; // Similar to `new Error().stack`
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
The first line of the trace will be prefixed with
|
|
214
|
+
`${myObject.name}: ${myObject.message}`.
|
|
215
|
+
|
|
216
|
+
The optional `constructorOpt` argument accepts a function. If given, all frames
|
|
217
|
+
above `constructorOpt`, including `constructorOpt`, will be omitted from the
|
|
218
|
+
generated stack trace.
|
|
219
|
+
|
|
220
|
+
The `constructorOpt` argument is useful for hiding implementation
|
|
221
|
+
details of error generation from the user. For instance:
|
|
222
|
+
|
|
223
|
+
```js
|
|
224
|
+
function a() {
|
|
225
|
+
b();
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function b() {
|
|
229
|
+
c();
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function c() {
|
|
233
|
+
// Create an error without stack trace to avoid calculating the stack trace twice.
|
|
234
|
+
const { stackTraceLimit } = Error;
|
|
235
|
+
Error.stackTraceLimit = 0;
|
|
236
|
+
const error = new Error();
|
|
237
|
+
Error.stackTraceLimit = stackTraceLimit;
|
|
238
|
+
|
|
239
|
+
// Capture the stack trace above function b
|
|
240
|
+
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
|
|
241
|
+
throw error;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
a();
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
##### Parameters
|
|
248
|
+
|
|
249
|
+
###### targetObject
|
|
250
|
+
|
|
251
|
+
`object`
|
|
252
|
+
|
|
253
|
+
###### constructorOpt?
|
|
254
|
+
|
|
255
|
+
`Function`
|
|
256
|
+
|
|
257
|
+
##### Returns
|
|
258
|
+
|
|
259
|
+
`void`
|
|
260
|
+
|
|
261
|
+
##### Inherited from
|
|
262
|
+
|
|
263
|
+
`Error.captureStackTrace`
|
|
264
|
+
|
|
265
|
+
#### Call Signature
|
|
266
|
+
|
|
267
|
+
> `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`
|
|
268
|
+
|
|
269
|
+
Defined in: cron/node\_modules/.bun/bun-types@1.4.0/node\_modules/bun-types/globals.d.ts:1062
|
|
270
|
+
|
|
271
|
+
Create .stack property on a target object
|
|
272
|
+
|
|
273
|
+
##### Parameters
|
|
274
|
+
|
|
275
|
+
###### targetObject
|
|
276
|
+
|
|
277
|
+
`object`
|
|
278
|
+
|
|
279
|
+
###### constructorOpt?
|
|
280
|
+
|
|
281
|
+
`Function`
|
|
282
|
+
|
|
283
|
+
##### Returns
|
|
284
|
+
|
|
285
|
+
`void`
|
|
286
|
+
|
|
287
|
+
##### Inherited from
|
|
288
|
+
|
|
289
|
+
`Error.captureStackTrace`
|
|
290
|
+
|
|
291
|
+
***
|
|
292
|
+
|
|
293
|
+
### prepareStackTrace()
|
|
294
|
+
|
|
295
|
+
> `static` **prepareStackTrace**(`err`, `stackTraces`): `any`
|
|
296
|
+
|
|
297
|
+
Defined in: node\_modules/@types/node/globals.d.ts:55
|
|
298
|
+
|
|
299
|
+
#### Parameters
|
|
300
|
+
|
|
301
|
+
##### err
|
|
302
|
+
|
|
303
|
+
`Error`
|
|
304
|
+
|
|
305
|
+
##### stackTraces
|
|
306
|
+
|
|
307
|
+
`CallSite`[]
|
|
308
|
+
|
|
309
|
+
#### Returns
|
|
310
|
+
|
|
311
|
+
`any`
|
|
312
|
+
|
|
313
|
+
#### See
|
|
314
|
+
|
|
315
|
+
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
|
316
|
+
|
|
317
|
+
#### Inherited from
|
|
318
|
+
|
|
319
|
+
`Error.prepareStackTrace`
|
|
320
|
+
|
|
321
|
+
***
|
|
322
|
+
|
|
323
|
+
### isError()
|
|
324
|
+
|
|
325
|
+
#### Call Signature
|
|
326
|
+
|
|
327
|
+
> `static` **isError**(`error`): `error is Error`
|
|
328
|
+
|
|
329
|
+
Defined in: cron/node\_modules/.bun/typescript@6.0.3/node\_modules/typescript/lib/lib.esnext.error.d.ts:21
|
|
330
|
+
|
|
331
|
+
Indicates whether the argument provided is a built-in Error instance or not.
|
|
332
|
+
|
|
333
|
+
##### Parameters
|
|
334
|
+
|
|
335
|
+
###### error
|
|
336
|
+
|
|
337
|
+
`unknown`
|
|
338
|
+
|
|
339
|
+
##### Returns
|
|
340
|
+
|
|
341
|
+
`error is Error`
|
|
342
|
+
|
|
343
|
+
##### Inherited from
|
|
344
|
+
|
|
345
|
+
`Error.isError`
|
|
346
|
+
|
|
347
|
+
#### Call Signature
|
|
348
|
+
|
|
349
|
+
> `static` **isError**(`value`): `value is Error`
|
|
350
|
+
|
|
351
|
+
Defined in: cron/node\_modules/.bun/bun-types@1.4.0/node\_modules/bun-types/globals.d.ts:1057
|
|
352
|
+
|
|
353
|
+
Check if a value is an instance of Error
|
|
354
|
+
|
|
355
|
+
##### Parameters
|
|
356
|
+
|
|
357
|
+
###### value
|
|
358
|
+
|
|
359
|
+
`unknown`
|
|
360
|
+
|
|
361
|
+
The value to check
|
|
362
|
+
|
|
363
|
+
##### Returns
|
|
364
|
+
|
|
365
|
+
`value is Error`
|
|
366
|
+
|
|
367
|
+
True if the value is an instance of Error, false otherwise
|
|
368
|
+
|
|
369
|
+
##### Inherited from
|
|
370
|
+
|
|
371
|
+
`Error.isError`
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
[**@mstone6969/vault**](../../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@mstone6969/vault](../../README.md) / [index](../README.md) / VaultKeyError
|
|
6
|
+
|
|
7
|
+
# Class: VaultKeyError
|
|
8
|
+
|
|
9
|
+
Defined in: cron/vault/src/errors.ts:101
|
|
10
|
+
|
|
11
|
+
The key is the wrong shape, or cannot open what it was given.
|
|
12
|
+
|
|
13
|
+
## Remarks
|
|
14
|
+
|
|
15
|
+
Thrown for a base64 key that is not 32 bytes, a sealed value not in
|
|
16
|
+
`iv:payload` form, and a value that will not open — which covers both the
|
|
17
|
+
wrong key and a value someone has altered, since GCM authenticates what it
|
|
18
|
+
decrypts and cannot tell you which it was. The key providers throw it too,
|
|
19
|
+
when the environment variable is unset or the key file is missing or empty.
|
|
20
|
+
|
|
21
|
+
Its status is 500 rather than a 4xx because a request that reaches this did
|
|
22
|
+
nothing wrong: the vault is misconfigured, or its data no longer matches its
|
|
23
|
+
key.
|
|
24
|
+
|
|
25
|
+
## Example
|
|
26
|
+
|
|
27
|
+
**Distinguishing a key problem from a caller problem**
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { importKey, VaultKeyError } from "@mstone6969/vault"
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
await importKey(process.env.VAULT_KEY!)
|
|
34
|
+
} catch (error) {
|
|
35
|
+
if (error instanceof VaultKeyError) {
|
|
36
|
+
console.error("vault key is unusable:", error.message)
|
|
37
|
+
process.exit(1)
|
|
38
|
+
}
|
|
39
|
+
throw error
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## See
|
|
44
|
+
|
|
45
|
+
[VaultError](VaultError.md) for the mistakes callers can fix themselves.
|
|
46
|
+
|
|
47
|
+
## Extends
|
|
48
|
+
|
|
49
|
+
- [`VaultError`](VaultError.md)
|
|
50
|
+
|
|
51
|
+
## Constructors
|
|
52
|
+
|
|
53
|
+
### Constructor
|
|
54
|
+
|
|
55
|
+
> **new VaultKeyError**(`message`): `VaultKeyError`
|
|
56
|
+
|
|
57
|
+
Defined in: cron/vault/src/errors.ts:106
|
|
58
|
+
|
|
59
|
+
#### Parameters
|
|
60
|
+
|
|
61
|
+
##### message
|
|
62
|
+
|
|
63
|
+
`string`
|
|
64
|
+
|
|
65
|
+
What was wrong with the key or the sealed value. It never
|
|
66
|
+
says which key was tried or what the value held.
|
|
67
|
+
|
|
68
|
+
#### Returns
|
|
69
|
+
|
|
70
|
+
`VaultKeyError`
|
|
71
|
+
|
|
72
|
+
#### Overrides
|
|
73
|
+
|
|
74
|
+
[`VaultError`](VaultError.md).[`constructor`](VaultError.md#constructor)
|
|
75
|
+
|
|
76
|
+
## Properties
|
|
77
|
+
|
|
78
|
+
### status
|
|
79
|
+
|
|
80
|
+
> `readonly` **status**: `number` = `422`
|
|
81
|
+
|
|
82
|
+
Defined in: cron/vault/src/errors.ts:63
|
|
83
|
+
|
|
84
|
+
Suggested HTTP status, for callers putting this behind an API.
|
|
85
|
+
|
|
86
|
+
#### Remarks
|
|
87
|
+
|
|
88
|
+
It is a suggestion, not a promise about transport: nothing in the
|
|
89
|
+
vault speaks HTTP. It exists so a handler can map a failure to a
|
|
90
|
+
response without knowing which check inside the vault failed.
|
|
91
|
+
|
|
92
|
+
The statuses actually thrown:
|
|
93
|
+
|
|
94
|
+
- `422` — bad input: a name that is not 1–64 characters of letters,
|
|
95
|
+
numbers, dot, dash or underscore; an empty value; a `randomValue`
|
|
96
|
+
length below one or an alphabet under two characters; a rotation
|
|
97
|
+
asked of an entry with no rotation policy.
|
|
98
|
+
- `404` — no secret under that name for that owner.
|
|
99
|
+
- `409` — the entry is `final`, so it can be deleted but not
|
|
100
|
+
replaced.
|
|
101
|
+
- `403` — the entry is sealed, so `read` will not hand it back.
|
|
102
|
+
`open` is the only way out.
|
|
103
|
+
- `410` — the entry's `expiresAt` has passed. The record is still
|
|
104
|
+
there; it just cannot be used.
|
|
105
|
+
- `501` — the entry's rotation policy names a generator this vault
|
|
106
|
+
was not constructed with.
|
|
107
|
+
- `500` — VaultKeyError's default: a key or ciphertext
|
|
108
|
+
problem, which is the operator's fault rather than the caller's.
|
|
109
|
+
|
|
110
|
+
#### Default Value
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
422
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### Inherited from
|
|
117
|
+
|
|
118
|
+
[`VaultError`](VaultError.md).[`status`](VaultError.md#status)
|
|
119
|
+
|
|
120
|
+
***
|
|
121
|
+
|
|
122
|
+
### stackTraceLimit
|
|
123
|
+
|
|
124
|
+
> `static` **stackTraceLimit**: `number`
|
|
125
|
+
|
|
126
|
+
Defined in: node\_modules/@types/node/globals.d.ts:67
|
|
127
|
+
|
|
128
|
+
The `Error.stackTraceLimit` property specifies the number of stack frames
|
|
129
|
+
collected by a stack trace (whether generated by `new Error().stack` or
|
|
130
|
+
`Error.captureStackTrace(obj)`).
|
|
131
|
+
|
|
132
|
+
The default value is `10` but may be set to any valid JavaScript number. Changes
|
|
133
|
+
will affect any stack trace captured _after_ the value has been changed.
|
|
134
|
+
|
|
135
|
+
If set to a non-number value, or set to a negative number, stack traces will
|
|
136
|
+
not capture any frames.
|
|
137
|
+
|
|
138
|
+
#### Inherited from
|
|
139
|
+
|
|
140
|
+
[`VaultError`](VaultError.md).[`stackTraceLimit`](VaultError.md#stacktracelimit)
|
|
141
|
+
|
|
142
|
+
***
|
|
143
|
+
|
|
144
|
+
### cause?
|
|
145
|
+
|
|
146
|
+
> `optional` **cause?**: `unknown`
|
|
147
|
+
|
|
148
|
+
Defined in: cron/node\_modules/.bun/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24
|
|
149
|
+
|
|
150
|
+
The cause of the error.
|
|
151
|
+
|
|
152
|
+
#### Inherited from
|
|
153
|
+
|
|
154
|
+
[`VaultError`](VaultError.md).[`cause`](VaultError.md#cause)
|
|
155
|
+
|
|
156
|
+
***
|
|
157
|
+
|
|
158
|
+
### name
|
|
159
|
+
|
|
160
|
+
> **name**: `string`
|
|
161
|
+
|
|
162
|
+
Defined in: cron/node\_modules/.bun/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1074
|
|
163
|
+
|
|
164
|
+
#### Inherited from
|
|
165
|
+
|
|
166
|
+
[`VaultError`](VaultError.md).[`name`](VaultError.md#name)
|
|
167
|
+
|
|
168
|
+
***
|
|
169
|
+
|
|
170
|
+
### message
|
|
171
|
+
|
|
172
|
+
> **message**: `string`
|
|
173
|
+
|
|
174
|
+
Defined in: cron/node\_modules/.bun/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1075
|
|
175
|
+
|
|
176
|
+
#### Inherited from
|
|
177
|
+
|
|
178
|
+
[`VaultError`](VaultError.md).[`message`](VaultError.md#message)
|
|
179
|
+
|
|
180
|
+
***
|
|
181
|
+
|
|
182
|
+
### stack?
|
|
183
|
+
|
|
184
|
+
> `optional` **stack?**: `string`
|
|
185
|
+
|
|
186
|
+
Defined in: cron/node\_modules/.bun/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076
|
|
187
|
+
|
|
188
|
+
#### Inherited from
|
|
189
|
+
|
|
190
|
+
[`VaultError`](VaultError.md).[`stack`](VaultError.md#stack)
|
|
191
|
+
|
|
192
|
+
## Methods
|
|
193
|
+
|
|
194
|
+
### captureStackTrace()
|
|
195
|
+
|
|
196
|
+
#### Call Signature
|
|
197
|
+
|
|
198
|
+
> `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`
|
|
199
|
+
|
|
200
|
+
Defined in: node\_modules/@types/node/globals.d.ts:51
|
|
201
|
+
|
|
202
|
+
Creates a `.stack` property on `targetObject`, which when accessed returns
|
|
203
|
+
a string representing the location in the code at which
|
|
204
|
+
`Error.captureStackTrace()` was called.
|
|
205
|
+
|
|
206
|
+
```js
|
|
207
|
+
const myObject = {};
|
|
208
|
+
Error.captureStackTrace(myObject);
|
|
209
|
+
myObject.stack; // Similar to `new Error().stack`
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
The first line of the trace will be prefixed with
|
|
213
|
+
`${myObject.name}: ${myObject.message}`.
|
|
214
|
+
|
|
215
|
+
The optional `constructorOpt` argument accepts a function. If given, all frames
|
|
216
|
+
above `constructorOpt`, including `constructorOpt`, will be omitted from the
|
|
217
|
+
generated stack trace.
|
|
218
|
+
|
|
219
|
+
The `constructorOpt` argument is useful for hiding implementation
|
|
220
|
+
details of error generation from the user. For instance:
|
|
221
|
+
|
|
222
|
+
```js
|
|
223
|
+
function a() {
|
|
224
|
+
b();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function b() {
|
|
228
|
+
c();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function c() {
|
|
232
|
+
// Create an error without stack trace to avoid calculating the stack trace twice.
|
|
233
|
+
const { stackTraceLimit } = Error;
|
|
234
|
+
Error.stackTraceLimit = 0;
|
|
235
|
+
const error = new Error();
|
|
236
|
+
Error.stackTraceLimit = stackTraceLimit;
|
|
237
|
+
|
|
238
|
+
// Capture the stack trace above function b
|
|
239
|
+
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
|
|
240
|
+
throw error;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
a();
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
##### Parameters
|
|
247
|
+
|
|
248
|
+
###### targetObject
|
|
249
|
+
|
|
250
|
+
`object`
|
|
251
|
+
|
|
252
|
+
###### constructorOpt?
|
|
253
|
+
|
|
254
|
+
`Function`
|
|
255
|
+
|
|
256
|
+
##### Returns
|
|
257
|
+
|
|
258
|
+
`void`
|
|
259
|
+
|
|
260
|
+
##### Inherited from
|
|
261
|
+
|
|
262
|
+
[`VaultError`](VaultError.md).[`captureStackTrace`](VaultError.md#capturestacktrace)
|
|
263
|
+
|
|
264
|
+
#### Call Signature
|
|
265
|
+
|
|
266
|
+
> `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`
|
|
267
|
+
|
|
268
|
+
Defined in: cron/node\_modules/.bun/bun-types@1.4.0/node\_modules/bun-types/globals.d.ts:1062
|
|
269
|
+
|
|
270
|
+
Create .stack property on a target object
|
|
271
|
+
|
|
272
|
+
##### Parameters
|
|
273
|
+
|
|
274
|
+
###### targetObject
|
|
275
|
+
|
|
276
|
+
`object`
|
|
277
|
+
|
|
278
|
+
###### constructorOpt?
|
|
279
|
+
|
|
280
|
+
`Function`
|
|
281
|
+
|
|
282
|
+
##### Returns
|
|
283
|
+
|
|
284
|
+
`void`
|
|
285
|
+
|
|
286
|
+
##### Inherited from
|
|
287
|
+
|
|
288
|
+
[`VaultError`](VaultError.md).[`captureStackTrace`](VaultError.md#capturestacktrace)
|
|
289
|
+
|
|
290
|
+
***
|
|
291
|
+
|
|
292
|
+
### prepareStackTrace()
|
|
293
|
+
|
|
294
|
+
> `static` **prepareStackTrace**(`err`, `stackTraces`): `any`
|
|
295
|
+
|
|
296
|
+
Defined in: node\_modules/@types/node/globals.d.ts:55
|
|
297
|
+
|
|
298
|
+
#### Parameters
|
|
299
|
+
|
|
300
|
+
##### err
|
|
301
|
+
|
|
302
|
+
`Error`
|
|
303
|
+
|
|
304
|
+
##### stackTraces
|
|
305
|
+
|
|
306
|
+
`CallSite`[]
|
|
307
|
+
|
|
308
|
+
#### Returns
|
|
309
|
+
|
|
310
|
+
`any`
|
|
311
|
+
|
|
312
|
+
#### See
|
|
313
|
+
|
|
314
|
+
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
|
315
|
+
|
|
316
|
+
#### Inherited from
|
|
317
|
+
|
|
318
|
+
[`VaultError`](VaultError.md).[`prepareStackTrace`](VaultError.md#preparestacktrace)
|
|
319
|
+
|
|
320
|
+
***
|
|
321
|
+
|
|
322
|
+
### isError()
|
|
323
|
+
|
|
324
|
+
#### Call Signature
|
|
325
|
+
|
|
326
|
+
> `static` **isError**(`error`): `error is Error`
|
|
327
|
+
|
|
328
|
+
Defined in: cron/node\_modules/.bun/typescript@6.0.3/node\_modules/typescript/lib/lib.esnext.error.d.ts:21
|
|
329
|
+
|
|
330
|
+
Indicates whether the argument provided is a built-in Error instance or not.
|
|
331
|
+
|
|
332
|
+
##### Parameters
|
|
333
|
+
|
|
334
|
+
###### error
|
|
335
|
+
|
|
336
|
+
`unknown`
|
|
337
|
+
|
|
338
|
+
##### Returns
|
|
339
|
+
|
|
340
|
+
`error is Error`
|
|
341
|
+
|
|
342
|
+
##### Inherited from
|
|
343
|
+
|
|
344
|
+
[`VaultError`](VaultError.md).[`isError`](VaultError.md#iserror)
|
|
345
|
+
|
|
346
|
+
#### Call Signature
|
|
347
|
+
|
|
348
|
+
> `static` **isError**(`value`): `value is Error`
|
|
349
|
+
|
|
350
|
+
Defined in: cron/node\_modules/.bun/bun-types@1.4.0/node\_modules/bun-types/globals.d.ts:1057
|
|
351
|
+
|
|
352
|
+
Check if a value is an instance of Error
|
|
353
|
+
|
|
354
|
+
##### Parameters
|
|
355
|
+
|
|
356
|
+
###### value
|
|
357
|
+
|
|
358
|
+
`unknown`
|
|
359
|
+
|
|
360
|
+
The value to check
|
|
361
|
+
|
|
362
|
+
##### Returns
|
|
363
|
+
|
|
364
|
+
`value is Error`
|
|
365
|
+
|
|
366
|
+
True if the value is an instance of Error, false otherwise
|
|
367
|
+
|
|
368
|
+
##### Inherited from
|
|
369
|
+
|
|
370
|
+
[`VaultError`](VaultError.md).[`isError`](VaultError.md#iserror)
|