Skip to content

Commit 0681dda

Browse files
committed
feat: export the used crypto runtime as a constant
This will aid libraries to determine which jose runtime was imported/required. With the many JS runtimes each having a different way of resolving transient dependencies and targets this has become a bit troublesome to deal with.
1 parent 3912eb2 commit 0681dda

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,5 @@ export type {
9696
JWTHeaderParameters,
9797
JSONWebKeySet,
9898
} from './types.d'
99+
100+
export { default as cryptoRuntime } from './runtime/runtime.js'

src/runtime/browser/runtime.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { CryptoRuntime } from '../../types.d'
2+
3+
export default 'WebCryptoAPI' as CryptoRuntime

src/runtime/node/runtime.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { CryptoRuntime } from '../../types.d'
2+
3+
export default 'node:crypto' as CryptoRuntime

src/types.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -668,3 +668,5 @@ export interface CompactJWEHeaderParameters extends JWEHeaderParameters {
668668
export interface JSONWebKeySet {
669669
keys: JWK[]
670670
}
671+
672+
export type CryptoRuntime = 'WebCryptoAPI' | 'node:crypto'

0 commit comments

Comments
 (0)