Skip to content

Commit

Permalink
chore: run lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Feb 27, 2024
1 parent a0b0896 commit e0c211e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './errors'
export * from './signature'
export * from './middleware'
export * from './signature'
export type * from './types'
1 change: 1 addition & 0 deletions src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type {RequestHandler} from 'express'

import {isSignatureError} from './errors'
import {assertValidRequest} from './signature'

Expand Down
6 changes: 3 additions & 3 deletions src/signature.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {WebhookSignatureFormatError, WebhookSignatureValueError, isSignatureError} from './errors'
import type {DecodedSignature, ConnectLikeRequest} from './types'
import {isSignatureError, WebhookSignatureFormatError, WebhookSignatureValueError} from './errors'
import type {ConnectLikeRequest, DecodedSignature} from './types'

/**
* We didn't send signed payloads prior to 2021 (2021-01-01T00:00:00.000Z)
Expand Down Expand Up @@ -208,7 +208,7 @@ async function createHS256Signature(
const signature = await crypto.subtle.sign('HMAC', key, enc.encode(signaturePayload))

// Encode as base64url
let signatureArray = Array.from(new Uint8Array(signature))
const signatureArray = Array.from(new Uint8Array(signature))
return btoa(String.fromCharCode.apply(null, signatureArray))
.replace(/\+/g, '-') // Replace '+' with '-'
.replace(/\//g, '_') // Replace '/' with '_'
Expand Down
5 changes: 3 additions & 2 deletions test/middleware.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {describe, test} from 'vitest'
import express, {Express, NextFunction, Request, RequestHandler, Response} from 'express'
import {json, text} from 'body-parser'
import express, {Express, NextFunction, Request, RequestHandler, Response} from 'express'
import request from 'supertest'
import {describe, test} from 'vitest'

import {isSignatureError, requireSignedRequest, SIGNATURE_HEADER_NAME} from '../src'

describe.runIf(typeof globalThis.crypto !== 'undefined')('middleware', () => {
Expand Down
3 changes: 2 additions & 1 deletion test/signature.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {describe, test, expect} from 'vitest'
import {describe, expect, test} from 'vitest'

import {
assertValidRequest,
assertValidSignature,
Expand Down

0 comments on commit e0c211e

Please sign in to comment.