@strimz/shared-crypto 0.1.0 → 0.1.1
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 +68 -8
- package/dist/aes-gcm.cjs.map +1 -1
- package/dist/aes-gcm.d.cts +18 -29
- package/dist/aes-gcm.d.ts +18 -29
- package/dist/aes-gcm.js.map +1 -1
- package/dist/api-key.cjs.map +1 -1
- package/dist/api-key.d.cts +2 -2
- package/dist/api-key.d.ts +2 -2
- package/dist/api-key.js.map +1 -1
- package/dist/encoding.cjs.map +1 -1
- package/dist/encoding.d.cts +1 -1
- package/dist/encoding.d.ts +1 -1
- package/dist/encoding.js.map +1 -1
- package/dist/hash.cjs.map +1 -1
- package/dist/hash.js.map +1 -1
- package/dist/hmac.cjs.map +1 -1
- package/dist/hmac.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/random.cjs.map +1 -1
- package/dist/random.js.map +1 -1
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.js.map +1 -1
- package/package.json +4 -4
- package/src/aes-gcm.ts +18 -29
- package/src/api-key.ts +2 -2
- package/src/encoding.ts +1 -1
- package/src/random.ts +1 -1
package/src/api-key.ts
CHANGED
|
@@ -22,13 +22,13 @@ import { sha256Hex } from './hash.js'
|
|
|
22
22
|
import { randomBase64Url } from './random.js'
|
|
23
23
|
|
|
24
24
|
export interface GeneratedApiKey {
|
|
25
|
-
/** The full plaintext key
|
|
25
|
+
/** The full plaintext key. Display once then discard. */
|
|
26
26
|
secret: string
|
|
27
27
|
/** Stored as the index. */
|
|
28
28
|
hash: string
|
|
29
29
|
/** Stored for display / log redaction. */
|
|
30
30
|
prefix: string
|
|
31
|
-
/** Stored for display
|
|
31
|
+
/** Stored for display, e.g. "my key ending in ...abcd". */
|
|
32
32
|
lastFour: string
|
|
33
33
|
kind: ApiKeyKind
|
|
34
34
|
mode: ApiKeyMode
|
package/src/encoding.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Byte encoders that work in every JavaScript runtime we target.
|
|
3
|
-
* No Node `Buffer`, no dependency on the DOM
|
|
3
|
+
* No Node `Buffer`, no dependency on the DOM. Only Uint8Array, strings, and
|
|
4
4
|
* the two TextEncoder/TextDecoder classes available everywhere.
|
|
5
5
|
*/
|
|
6
6
|
|
package/src/random.ts
CHANGED
|
@@ -27,7 +27,7 @@ export function uuid(): string {
|
|
|
27
27
|
if (c && typeof c.randomUUID === 'function') {
|
|
28
28
|
return c.randomUUID()
|
|
29
29
|
}
|
|
30
|
-
// Fallback
|
|
30
|
+
// Fallback. RFC 4122 v4 from getRandomValues.
|
|
31
31
|
const bytes = randomBytes(16)
|
|
32
32
|
bytes[6] = ((bytes[6] as number) & 0x0f) | 0x40
|
|
33
33
|
bytes[8] = ((bytes[8] as number) & 0x3f) | 0x80
|