@strimz/shared-crypto 0.2.6 → 0.2.8

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 (2) hide show
  1. package/README.md +16 -12
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @strimz/shared-crypto
2
2
 
3
- > Web Crypto primitives for Strimz. HMAC webhook signing, API key generation, AES-256-GCM envelope encryption, and constant-time comparison. Runs anywhere Web Crypto runs.
3
+ > Crypto primitives for Strimz. HMAC webhook signing, API key generation, AES-256-GCM envelope encryption, constant-time comparison, and the checkout payment nonce. Runs anywhere Web Crypto runs.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@strimz/shared-crypto.svg?color=02C76A)](https://www.npmjs.com/package/@strimz/shared-crypto)
6
6
  [![npm downloads](https://img.shields.io/npm/dm/@strimz/shared-crypto.svg)](https://www.npmjs.com/package/@strimz/shared-crypto)
@@ -8,11 +8,14 @@
8
8
  [![types](https://img.shields.io/npm/types/@strimz/shared-crypto.svg)](https://www.npmjs.com/package/@strimz/shared-crypto)
9
9
  [![License: MIT](https://img.shields.io/badge/License-MIT-02C76A.svg)](./LICENSE)
10
10
 
11
- Every primitive is built on the Web Crypto API
12
- (`globalThis.crypto.subtle`), so the same code runs unchanged in
13
- Node 22, Vercel Edge, Cloudflare Workers, Deno, Bun, and any modern
14
- browser. There is no `node:crypto`, no Buffer, no platform-specific
15
- shim.
11
+ The hashing, HMAC, random and AES primitives are built on the Web
12
+ Crypto API (`globalThis.crypto.subtle`), so the same code runs
13
+ unchanged in Node 22, Vercel Edge, Cloudflare Workers, Deno, Bun, and
14
+ any modern browser. There is no `node:crypto`, no Buffer, no
15
+ platform-specific shim. `checkoutPaymentNonce` uses `viem`'s
16
+ `keccak256` instead.
17
+
18
+ Runtime dependencies: `viem` and `@strimz/shared-config`.
16
19
 
17
20
  ## Install
18
21
 
@@ -33,10 +36,10 @@ Every group is also available as a subpath import.
33
36
  | `/hmac` | `hmacSha256`, `hmacSha256Hex` |
34
37
  | `/random` | `randomBytes`, `randomHex`, `randomBase64Url`, `uuid` |
35
38
  | `/timing-safe` | `timingSafeEqualBytes`, `timingSafeEqualString` |
36
- | `/webhook` | `signWebhookPayload`, `verifyWebhookSignature` (timestamp + HMAC scheme) |
39
+ | `/webhook` | `signWebhookPayload`, `verifyWebhookSignature`, `WEBHOOK_SIGNATURE_VERSION` (timestamp + HMAC scheme) |
37
40
  | `/api-key` | `generateApiKey`, `hashApiKey`, `redactApiKey` |
38
41
  | `/aes-gcm` | `encryptAesGcm`, `decryptAesGcm`, `generateAesGcmKey` (envelope encryption for webhook secrets at rest) |
39
- | `/checkout` | `checkoutPaymentNonce` (the EIP-3009 nonce the hosted checkout signs for a payment session) |
42
+ | `/checkout` | `checkoutPaymentNonce`, `CHECKOUT_PAYMENT_NONCE_DOMAIN` (the EIP-3009 nonce for a payment session) |
40
43
 
41
44
  The package root re-exports every subpath.
42
45
 
@@ -102,16 +105,17 @@ small secrets where the key is held outside the data store.
102
105
  ## Design notes
103
106
 
104
107
  - **No secrets are logged.** `redactApiKey` exists specifically so any diagnostic that must include a key logs only the safe prefix and the last four characters.
105
- - **No Node `Buffer` or `node:crypto`.** Every primitive uses `globalThis.crypto.subtle` and `Uint8Array`.
108
+ - **No Node `Buffer` or `node:crypto`.** The primitives use `globalThis.crypto.subtle` and `Uint8Array`; the checkout nonce uses `viem`.
109
+ - **One nonce per session.** `checkoutPaymentNonce(sessionId)` is `keccak256(abi.encode(CHECKOUT_PAYMENT_NONCE_DOMAIN, sessionId))`, so every authorization for a session shares it and the token accepts at most one.
106
110
  - **Constant-time compare on signatures.** Signature verification never short-circuits on the first mismatched byte.
107
111
  - **Policy lives elsewhere.** Tolerance windows, key prefixes, and tier thresholds come from `@strimz/shared-config`; this package consumes them.
108
112
 
109
113
  ## Links
110
114
 
111
- - [Documentation](https://strimz.finance/docs)
112
- - [Repository](https://github.com/StrimzLab/Strimz/tree/main/packages/shared-crypto)
115
+ - [Documentation](https://www.strimz.finance/docs)
116
+ - [Repository](https://github.com/StrimzLab/strimz/tree/main/packages/shared-crypto)
113
117
  - [Changelog](./CHANGELOG.md)
114
- - [Issues](https://github.com/StrimzLab/Strimz/issues)
118
+ - [Issues](https://github.com/StrimzLab/strimz/issues)
115
119
 
116
120
  ## License
117
121
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strimz/shared-crypto",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "Web Crypto primitives for Strimz. HMAC webhook signing, API key generation, hashing, AES-256-GCM envelope encryption, and constant-time comparison. Runs in Node 22 and Edge runtimes.",
5
5
  "license": "MIT",
6
6
  "author": "Strimz <hello@strimz.finance>",
@@ -89,7 +89,7 @@
89
89
  ],
90
90
  "dependencies": {
91
91
  "viem": "^2.22.6",
92
- "@strimz/shared-config": "0.7.0"
92
+ "@strimz/shared-config": "0.8.0"
93
93
  },
94
94
  "devDependencies": {
95
95
  "eslint": "^9.18.0",