🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@prisma-next/utils

Package Overview
Dependencies
Maintainers
4
Versions
1006
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prisma-next/utils - npm Package Compare versions

Comparing version
0.16.0-dev.14
to
0.16.0-dev.15
+2
-2
dist/hash-content.d.mts

@@ -45,4 +45,4 @@ //#region src/hash-content.d.ts

* prefix). Self-describing so a future migration to a different hash
* produces visibly distinct keys, and consistent with the
* `sha256:HEXDIGEST` shape already used by `meta.storageHash`.
* produces visibly distinct keys. This in-memory cache key deliberately
* keeps its tag — unlike persisted contract hashes, which are bare hex.
*

@@ -49,0 +49,0 @@ * @example

@@ -45,4 +45,4 @@ //#region src/hash-content.ts

* prefix). Self-describing so a future migration to a different hash
* produces visibly distinct keys, and consistent with the
* `sha256:HEXDIGEST` shape already used by `meta.storageHash`.
* produces visibly distinct keys. This in-memory cache key deliberately
* keeps its tag — unlike persisted contract hashes, which are bare hex.
*

@@ -49,0 +49,0 @@ * @example

@@ -1,1 +0,1 @@

{"version":3,"file":"hash-content.mjs","names":[],"sources":["../src/hash-content.ts"],"sourcesContent":["/**\n * Hashes a canonical-string representation of an execution into a bounded,\n * opaque cache-key digest.\n *\n * Designed for use as the final step of `RuntimeMiddlewareContext.contentHash`\n * implementations: family runtimes compose a canonical string from\n * `meta.storageHash`, the rendered statement (or wire command), and\n * canonicalized parameters via `canonicalStringify`, then pipe the result\n * through this helper.\n *\n * Why hash the canonical string instead of using it directly as a `Map` key:\n *\n * 1. **Bounded memory.** A raw canonical key includes concrete parameter\n * values, so a query bound to a 10 MB JSON column or binary blob produces\n * a 10 MB cache key. With `maxEntries = 1000`, that scales to gigabytes\n * of cache keys alone. SHA-512 pins per-key cost at a fixed digest\n * length regardless of input size.\n *\n * 2. **Sensitive-data isolation.** The canonical string contains parameter\n * values verbatim. Cache keys flow into debug logs, Redis `KEYS`/`MONITOR`\n * output, persistence dumps, monitoring tools, and any user-supplied\n * `CacheStore` implementation. Hashing prevents PII / credentials /\n * tokens that appear in query parameters from showing up in any of those\n * surfaces.\n *\n * Algorithm choice — SHA-512 (`SHA-512` via the WebCrypto API):\n *\n * - **Portability.** WebCrypto (`globalThis.crypto.subtle`) is available in\n * every modern JavaScript runtime — Node, Deno, Bun, browsers, edge\n * workers — without importing a Node-specific module. This keeps the\n * helper usable in non-Node hosts where `node:crypto` is not available.\n * - **Collision space.** 512 bits of output makes accidental collisions\n * astronomically improbable — far beyond what a cache needs, but the\n * incremental cost over 256-bit output is negligible and the headroom\n * is free.\n * - **No additional dependency.** SHA-512 is part of the WebCrypto standard\n * set of digest algorithms; no third-party package needed.\n *\n * The function is `async` because the WebCrypto digest API is async by\n * design. Callers must await the result.\n *\n * Output format: `sha512:HEXDIGEST` (128-char hex with the algorithm tag\n * prefix). Self-describing so a future migration to a different hash\n * produces visibly distinct keys, and consistent with the\n * `sha256:HEXDIGEST` shape already used by `meta.storageHash`.\n *\n * @example\n * ```typescript\n * const canonical = `${exec.meta.storageHash}|${exec.sql}|${canonicalStringify(exec.params)}`;\n * return await hashContent(canonical);\n * // → 'sha512:8f3...e1c' (always 135 chars: 'sha512:' + 128 hex chars)\n * ```\n */\nexport async function hashContent(value: string): Promise<string> {\n const bytes = new TextEncoder().encode(value);\n const digest = await crypto.subtle.digest('SHA-512', bytes);\n const hex = Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, '0')).join('');\n return `sha512:${hex}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,eAAsB,YAAY,OAAgC;CAChE,MAAM,QAAQ,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK;CAC5C,MAAM,SAAS,MAAM,OAAO,OAAO,OAAO,WAAW,KAAK;CAE1D,OAAO,UADK,MAAM,KAAK,IAAI,WAAW,MAAM,IAAI,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,EACzE;AACrB"}
{"version":3,"file":"hash-content.mjs","names":[],"sources":["../src/hash-content.ts"],"sourcesContent":["/**\n * Hashes a canonical-string representation of an execution into a bounded,\n * opaque cache-key digest.\n *\n * Designed for use as the final step of `RuntimeMiddlewareContext.contentHash`\n * implementations: family runtimes compose a canonical string from\n * `meta.storageHash`, the rendered statement (or wire command), and\n * canonicalized parameters via `canonicalStringify`, then pipe the result\n * through this helper.\n *\n * Why hash the canonical string instead of using it directly as a `Map` key:\n *\n * 1. **Bounded memory.** A raw canonical key includes concrete parameter\n * values, so a query bound to a 10 MB JSON column or binary blob produces\n * a 10 MB cache key. With `maxEntries = 1000`, that scales to gigabytes\n * of cache keys alone. SHA-512 pins per-key cost at a fixed digest\n * length regardless of input size.\n *\n * 2. **Sensitive-data isolation.** The canonical string contains parameter\n * values verbatim. Cache keys flow into debug logs, Redis `KEYS`/`MONITOR`\n * output, persistence dumps, monitoring tools, and any user-supplied\n * `CacheStore` implementation. Hashing prevents PII / credentials /\n * tokens that appear in query parameters from showing up in any of those\n * surfaces.\n *\n * Algorithm choice — SHA-512 (`SHA-512` via the WebCrypto API):\n *\n * - **Portability.** WebCrypto (`globalThis.crypto.subtle`) is available in\n * every modern JavaScript runtime — Node, Deno, Bun, browsers, edge\n * workers — without importing a Node-specific module. This keeps the\n * helper usable in non-Node hosts where `node:crypto` is not available.\n * - **Collision space.** 512 bits of output makes accidental collisions\n * astronomically improbable — far beyond what a cache needs, but the\n * incremental cost over 256-bit output is negligible and the headroom\n * is free.\n * - **No additional dependency.** SHA-512 is part of the WebCrypto standard\n * set of digest algorithms; no third-party package needed.\n *\n * The function is `async` because the WebCrypto digest API is async by\n * design. Callers must await the result.\n *\n * Output format: `sha512:HEXDIGEST` (128-char hex with the algorithm tag\n * prefix). Self-describing so a future migration to a different hash\n * produces visibly distinct keys. This in-memory cache key deliberately\n * keeps its tag — unlike persisted contract hashes, which are bare hex.\n *\n * @example\n * ```typescript\n * const canonical = `${exec.meta.storageHash}|${exec.sql}|${canonicalStringify(exec.params)}`;\n * return await hashContent(canonical);\n * // → 'sha512:8f3...e1c' (always 135 chars: 'sha512:' + 128 hex chars)\n * ```\n */\nexport async function hashContent(value: string): Promise<string> {\n const bytes = new TextEncoder().encode(value);\n const digest = await crypto.subtle.digest('SHA-512', bytes);\n const hex = Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, '0')).join('');\n return `sha512:${hex}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,eAAsB,YAAY,OAAgC;CAChE,MAAM,QAAQ,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK;CAC5C,MAAM,SAAS,MAAM,OAAO,OAAO,OAAO,WAAW,KAAK;CAE1D,OAAO,UADK,MAAM,KAAK,IAAI,WAAW,MAAM,IAAI,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,EACzE;AACrB"}
{
"name": "@prisma-next/utils",
"version": "0.16.0-dev.14",
"version": "0.16.0-dev.15",
"license": "Apache-2.0",

@@ -9,4 +9,4 @@ "type": "module",

"devDependencies": {
"@prisma-next/tsconfig": "0.16.0-dev.14",
"@prisma-next/tsdown": "0.16.0-dev.14",
"@prisma-next/tsconfig": "0.16.0-dev.15",
"@prisma-next/tsdown": "0.16.0-dev.15",
"tsdown": "0.22.8",

@@ -13,0 +13,0 @@ "typescript": "5.9.3",

@@ -44,4 +44,4 @@ /**

* prefix). Self-describing so a future migration to a different hash
* produces visibly distinct keys, and consistent with the
* `sha256:HEXDIGEST` shape already used by `meta.storageHash`.
* produces visibly distinct keys. This in-memory cache key deliberately
* keeps its tag — unlike persisted contract hashes, which are bare hex.
*

@@ -48,0 +48,0 @@ * @example