[email protected]: crypto/KeyFormat declarations require the global JsonWebKey, breaking Node-only type-checks
Los mantenedores suelen responder en 1 día
Evaluación
Este issue todavía no se ha evaluado.
Descripción
What version of Effect is running?
- Effect:
4.1.0. Not reproducible with4.0.7. The declaration is unchanged onmainat dae6428. - TypeScript:
7.0.2,6.0.3and5.9.3 @types/node:26.6.4- Node.js:
24.20.0
What steps can reproduce the bug?
Create these files in an otherwise empty directory.
package.json:
{
"private": true,
"type": "module",
"dependencies": {
"effect": "4.1.0"
},
"devDependencies": {
"@types/node": "26.6.4",
"typescript": "7.0.2"
}
}
tsconfig.json:
{
"compilerOptions": {
"target": "ES2024",
"module": "NodeNext",
"lib": ["ES2024"],
"types": ["node"],
"strict": true,
"noEmit": true
},
"include": ["src/**/*.ts"]
}
src/repro.ts:
import type * as Effect from "effect/Effect"
export type Probe = Effect.Effect<void>
Run:
npm install
npx tsc --project tsconfig.json
What is the expected behavior?
The import type-checks with Node's declarations, as it does on 4.0.7. This is the same configuration as #8745, which was fixed for TextDecoderOptions.
What do you see instead?
node_modules/effect/dist/crypto/KeyFormat.d.ts(122,51): error TS2304: Cannot find name 'JsonWebKey'.
KeyFormat.jwk is typed with the global JsonWebKey. TypeScript's DOM library declares that global, but @types/node does not: Node declares the type only as webcrypto.JsonWebKey inside node:crypto.
Schema imports crypto/KeyFormat, so the error appears for imports of effect, effect/Effect and effect/Schema without using any crypto API. It is the only unresolved name in this configuration. Adding DOM to lib, enabling skipLibCheck, or declaring a global JsonWebKey makes the reproduction pass.
Additional information
Proposed fix
Declare the RFC 7517 shape in KeyFormat instead of relying on the global, and use it in place of JsonWebKey throughout the module:
/**
* A JSON Web Key (RFC 7517) as the Web Crypto API reads and writes it.
*/
export interface JsonWebKey {
alg?: string
crv?: string
d?: string
dp?: string
dq?: string
e?: string
ext?: boolean
k?: string
key_ops?: Array<string>
kty?: string
n?: string
oth?: Array<{ d?: string; r?: string; t?: string }>
p?: string
q?: string
qi?: string
use?: string
x?: string
y?: string
}
The members match the DOM library's JsonWebKey and Node's webcrypto.JsonWebKey. With TypeScript 5.9.3, 6.0.3 and 7.0.2, under strict and exactOptionalPropertyTypes, a standalone check that this interface is assignable to and from the DOM global and webcrypto.JsonWebKey, and is accepted by and returned from crypto.subtle.importKey("jwk", …) and crypto.subtle.exportKey("jwk", …), passes with Node types only, DOM types only, and both.
The proposed change has not been tested inside Effect's own build or test suite. The open effect/jose PR (#9883) also uses the global JsonWebKey, so it may need the same treatment.
Current workaround
A dependency patch that replaces JsonWebKey at dist/crypto/KeyFormat.d.ts:122 with the structural type above.
- Lenguaje dominante
- TypeScript
- Estrellas
- 16.7k
- Forks
- 808
- Merge medio
- 11 h 11 min
- PR fusionados (30 d)
- 840
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Effect-TS/effect
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
@effect/ai-anthropic: text_editor_20250728 insert decodes `new_str`, but the API sends `insert_text`Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 4/5 1-2 días Aptitud para principiantes 55/100
Los mantenedores suelen responder en 1 día
-
sql-pg: send several statements in one extended-query Sync (transaction-local context without extra round trips)Posiblemente ocupada @effect-bot la tomó hoy. Abierto
Effect-TS/effect#10113 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
CircuitBreaker: record an outcome without guarding the callPosiblemente ocupada @effect-bot la tomó hoy. Abierto
Effect-TS/effect#10110 · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de Effect-TS/effect
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
lichess-org/lila#22324 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Feature Request] [Web] Expose kvCacheQuantizationBits in the onnxruntime-web WebGPU EP optionsAbiertoep:WebGPU platform:web quantization
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
microsoft/onnxruntime#33752 ·
Los mantenedores suelen responder en 2 días
-
[Skill Bug]: entra-agent-id: inaccurate blueprint permission inheritance and parent token sub claimAbiertobug entra-agent-id
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
microsoft/GitHub-Copilot-for-Azure#3467 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
fix(worker): keep normal prepare waiting states failure-freePosiblemente ocupada @LichKing-2234 la tomó hoy. Abiertoagent:codex priority:P1
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
AgoraIO-Extensions/agent-infra#3745 ·
Los mantenedores suelen responder en 1 día
-
The five-line work window can drop its oldest line: the per-line byte share ignores the JSON framingPosiblemente ocupada @Eapp1e la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
makecindy/cindy#7973 · 1 comentario ·
Los mantenedores suelen responder en 1 día