Skip to content

Commit

Permalink
test: Safari 17 now supports Ed25519
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Oct 2, 2023
1 parent 9516195 commit 7c5c926
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions tap/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,27 @@ export const isBrowser =

const BOWSER = 'https://cdn.jsdelivr.net/npm/bowser@2.11.0/src/bowser.js'

async function isEngine(engine: string) {
let parsedUserAgent
async function parseUserAgent() {
const { default: Bowser } = await import(BOWSER)
return Bowser.parse(window.navigator.userAgent).engine.name === engine
parsedUserAgent ||= Bowser.parse(window.navigator.userAgent)
return parsedUserAgent
}

async function isEngine(engine: string) {
const userAgentData = await parseUserAgent()
return userAgentData.engine.name === engine
}

async function isVersionAtLeast(version: number) {
const userAgentData = await parseUserAgent()
return parseInt(userAgentData.browser.version.split('.')[0], 10) >= version
}

export const isBlink = isBrowser && (await isEngine('Blink'))

export const isWebKit = isBrowser && (await isEngine('WebKit'))
export const isWebKitAbove17 = isBrowser && isWebKit && (await isVersionAtLeast(17))

export const isGecko = isBrowser && (await isEngine('Gecko'))

Expand Down
2 changes: 1 addition & 1 deletion tap/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const algs = <lib.JWSAlgorithm[]>[
]
export const fails = <lib.JWSAlgorithm[]>[]
;(env.isDeno ? fails : algs).push('ES512')
;(env.isBrowser ? fails : algs).push('EdDSA')
;(env.isBrowser && !(env.isWebKit && env.isWebKitAbove17) ? fails : algs).push('EdDSA')

export const keys = algs.reduce(
(acc, alg) => {
Expand Down

0 comments on commit 7c5c926

Please sign in to comment.