Skip to content

Commit

Permalink
feat: export the used crypto runtime as a constant
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
panva committed Oct 2, 2023
1 parent 3912eb2 commit 0681dda
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/index.ts
Expand Up @@ -96,3 +96,5 @@ export type {
JWTHeaderParameters,
JSONWebKeySet,
} from './types.d'

export { default as cryptoRuntime } from './runtime/runtime.js'
3 changes: 3 additions & 0 deletions src/runtime/browser/runtime.ts
@@ -0,0 +1,3 @@
import { CryptoRuntime } from '../../types.d'

export default 'WebCryptoAPI' as CryptoRuntime
3 changes: 3 additions & 0 deletions src/runtime/node/runtime.ts
@@ -0,0 +1,3 @@
import { CryptoRuntime } from '../../types.d'

export default 'node:crypto' as CryptoRuntime
2 changes: 2 additions & 0 deletions src/types.d.ts
Expand Up @@ -668,3 +668,5 @@ export interface CompactJWEHeaderParameters extends JWEHeaderParameters {
export interface JSONWebKeySet {
keys: JWK[]
}

export type CryptoRuntime = 'WebCryptoAPI' | 'node:crypto'

0 comments on commit 0681dda

Please sign in to comment.