cloudflare-apple-sign-in
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -123,3 +123,2 @@ export interface AppleSignInOptions { | ||
private privateKey; | ||
private jwksClient; | ||
constructor(options: AppleSignInOptions); | ||
@@ -126,0 +125,0 @@ /** |
@@ -1,3 +0,1 @@ | ||
//@ts-ignore | ||
import jwksClient from "jwks-rsa-browser"; | ||
import jwt from "@tsndr/cloudflare-worker-jwt"; | ||
@@ -23,9 +21,2 @@ export class AppleSignIn { | ||
this.privateKey = privateKey; | ||
/** | ||
* Create jwks instance that caches 5 kid's up to 10 minutes to reduce amount calls to apple auth keys endpoint. | ||
* @link https://github.com/auth0/node-jwks-rsa#caching | ||
*/ | ||
this.jwksClient = jwksClient({ | ||
jwksUri: "https://appleid.apple.com/auth/keys", | ||
}); | ||
} | ||
@@ -147,11 +138,16 @@ /** | ||
getAppleSigningKey(kid) { | ||
return new Promise((resolve, reject) => { | ||
this.jwksClient.getSigningKey(kid, (err, key) => { | ||
if (err || key === undefined) { | ||
reject(err); | ||
} | ||
else { | ||
resolve(key); | ||
} | ||
}); | ||
const jwksUri = "https://appleid.apple.com/auth/keys"; | ||
return fetch(jwksUri) | ||
.then(response => { | ||
if (!response.ok) { | ||
throw new Error(`Failed to fetch JWKS: ${response.statusText}`); | ||
} | ||
return response.json(); | ||
}) | ||
.then((jwks) => { | ||
const key = jwks.keys.find((k) => k.kid === kid); | ||
if (!key) { | ||
throw new Error(`Key with kid ${kid} not found in JWKS`); | ||
} | ||
return key; | ||
}); | ||
@@ -158,0 +154,0 @@ } |
{ | ||
"name": "cloudflare-apple-sign-in", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "A forked Apple sign-in REST API implementation adapted for Cloudflare Workers.", | ||
@@ -53,4 +53,3 @@ "main": "build/AppleSignIn.js", | ||
"dependencies": { | ||
"@tsndr/cloudflare-worker-jwt": "^2.5.2", | ||
"jwks-rsa-browser": "^1.4.2" | ||
"@tsndr/cloudflare-worker-jwt": "^2.5.2" | ||
}, | ||
@@ -57,0 +56,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1
42743
415
3
- Removedjwks-rsa-browser@^1.4.2
- Removed@types/body-parser@1.19.5(transitive)
- Removed@types/connect@3.4.38(transitive)
- Removed@types/express@4.17.21(transitive)
- Removed@types/express-jwt@0.0.34(transitive)
- Removed@types/express-serve-static-core@4.19.3(transitive)
- Removed@types/express-unless@2.0.1(transitive)
- Removed@types/http-errors@2.0.4(transitive)
- Removed@types/mime@1.3.5(transitive)
- Removed@types/node@20.12.13(transitive)
- Removed@types/qs@6.9.15(transitive)
- Removed@types/range-parser@1.2.7(transitive)
- Removed@types/send@0.17.4(transitive)
- Removed@types/serve-static@1.15.7(transitive)
- Removedbrowser-request@0.3.3(transitive)
- Removeddebug@2.6.9(transitive)
- Removedexpress-unless@2.1.3(transitive)
- Removedjwks-rsa-browser@1.4.2(transitive)
- Removedlimiter@1.1.5(transitive)
- Removedlock@0.1.4(transitive)
- Removedlodash@4.17.21(transitive)
- Removedlru-cache@4.0.2(transitive)
- Removedlru-memoizer@1.13.0(transitive)
- Removedms@2.0.02.1.3(transitive)
- Removedpseudomap@1.0.2(transitive)
- Removedundici-types@5.26.5(transitive)
- Removedvery-fast-args@1.1.0(transitive)
- Removedyallist@2.1.2(transitive)