Skip to content

Commit

Permalink
fixed lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Ptroger committed Mar 25, 2024
1 parent db6be06 commit b614e2f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion packages/signature/src/lib/sign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { sha256 as sha256Hash } from '@noble/hashes/sha256'
import { keccak_256 as keccak256 } from '@noble/hashes/sha3'
import { SignJWT, base64url, importJWK } from 'jose'
import { isHex, signatureToHex, toBytes, toHex } from 'viem'
import { hash } from './hash-request'
import { privateKeySchema } from './schemas'
import { EcdsaSignature, Header, Hex, Jwk, JwsdHeader, Payload, PrivateKey, SigningAlg } from './types'
import { hash } from './hash-request'
import { hexToBase64Url } from './utils'
import { validate } from './validate'

Expand Down
12 changes: 6 additions & 6 deletions packages/signature/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ const rsaKeyToKid = (jwk: Jwk) => {
const generateRsaKeyPair = async (
opts: {
keyId?: string
modulusLength?: number,
use?: Use,
modulusLength?: number
use?: Use
} = {
modulusLength: 2048
}
Expand All @@ -175,9 +175,9 @@ const generateRsaKeyPair = async (
alg: Alg.RS256,
kty: KeyTypes.RSA,
crv: undefined,
use: opts.use || undefined,
use: opts.use || undefined
}
jwk.kid = opts.keyId || rsaKeyToKid(jwk);
jwk.kid = opts.keyId || rsaKeyToKid(jwk)

const pk = validate<RsaPrivateKey>(rsaPrivateKeySchema, jwk, 'Invalid RSA Private Key JWK')
return pk
Expand All @@ -187,8 +187,8 @@ export const generateJwk = async (
alg: Alg,
opts?: {
keyId?: string
modulusLength?: number,
use?: Use,
modulusLength?: number
use?: Use
}
): Promise<Jwk> => {
switch (alg) {
Expand Down
26 changes: 13 additions & 13 deletions packages/signature/src/lib/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,19 @@ export async function verifyJwt(jwt: string, jwk: Jwk): Promise<Jwt> {
}

export async function verifyJwsd(jws: string, jwk: PublicKey): Promise<Jwsd> {
const { header, payload, signature } = decodeJwsd(jws)
const { header, payload, signature } = decodeJwsd(jws)

if (header.alg === SigningAlg.EIP191) {
await verifyEip191(jws, jwk)
} else {
// TODO: Implement other algs individually without jose
const joseJwk = await importJWK(jwk)
await jwtVerify(jws, joseJwk)
}
if (header.alg === SigningAlg.EIP191) {
await verifyEip191(jws, jwk)
} else {
// TODO: Implement other algs individually without jose
const joseJwk = await importJWK(jwk)
await jwtVerify(jws, joseJwk)
}

return {
header,
payload,
signature
}
return {
header,
payload,
signature
}
}

0 comments on commit b614e2f

Please sign in to comment.