Skip to content

Commit

Permalink
feat: use jose to get pem from jwk, since it has no issues in nextjs (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rbrazhnyk authored Jul 5, 2024
1 parent 24d44c3 commit 300608c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 107 deletions.
116 changes: 15 additions & 101 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions packages/auth-provider/helpers/jwt.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios'
import * as jwkToPem from 'jwk-to-pem'
import * as jwt from 'jsonwebtoken'
import * as jose from 'jose'

export interface ISignPayload {
tokenId: string
Expand Down Expand Up @@ -42,7 +42,9 @@ export class Jwt {

if (hasKeys) {
const jwk = data.keys[0]
const publickKeyPem = jwkToPem(jwk)

const ecPublicKey = (await jose.importJWK(jwk)) as jose.KeyLike
const publickKeyPem = await jose.exportSPKI(ecPublicKey)

return publickKeyPem
}
Expand Down
6 changes: 2 additions & 4 deletions packages/auth-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@
"dependencies": {
"@affinidi-tdk/common": "^1.0.0",
"@types/jsonwebtoken": "^9.0.3",
"@types/jwk-to-pem": "^2.0.3",
"@types/qs": "^6.9.8",
"@types/uuid": "^9.0.8",
"axios": "^1.5.1",
"jose": "^5.6.3",
"jsonwebtoken": "^9.0.2",
"jwk-to-pem": "^2.0.5",
"qs": "^6.11.2",
"uuid": "^9.0.1"
},
Expand Down Expand Up @@ -73,12 +72,11 @@
"bundleDependencies": [
"@affinidi-tdk/common",
"@types/jsonwebtoken",
"@types/jwk-to-pem",
"@types/qs",
"@types/uuid",
"axios",
"jose",
"jsonwebtoken",
"jwk-to-pem",
"qs",
"uuid"
]
Expand Down

0 comments on commit 300608c

Please sign in to comment.