opticedge-cloud-utils 1.0.26 → 1.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,6 +35,7 @@ export type Card = {
35
35
  edge_grading: number;
36
36
  frontImage: string;
37
37
  frontImageUncropped: string;
38
+ gifUrl?: string;
38
39
  gradeDate: number;
39
40
  grading: number;
40
41
  grading_confidence: number;
@@ -1 +1 @@
1
- export declare function isValidSignature(secret: string, body: string, signature: string): boolean;
1
+ export declare function isValidWebhookSignature(secret: string, body: string, signature: string): boolean;
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isValidSignature = isValidSignature;
6
+ exports.isValidWebhookSignature = isValidWebhookSignature;
7
7
  const crypto_1 = __importDefault(require("crypto"));
8
- function isValidSignature(secret, body, signature) {
8
+ function isValidWebhookSignature(secret, body, signature) {
9
9
  const computedSignature = crypto_1.default.createHmac('sha256', secret).update(body).digest('hex');
10
10
  return computedSignature === signature;
11
11
  }
@@ -5,22 +5,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const thirdweb_1 = require("./thirdweb");
7
7
  const crypto_1 = __importDefault(require("crypto"));
8
- describe('isValidSignature', () => {
8
+ describe('isValidWebhookSignature', () => {
9
9
  const secret = 'test_secret';
10
10
  const body = '{"message":"hello"}';
11
11
  it('returns true for a valid signature', () => {
12
12
  const validSignature = crypto_1.default.createHmac('sha256', secret).update(body).digest('hex');
13
- expect((0, thirdweb_1.isValidSignature)(secret, body, validSignature)).toBe(true);
13
+ expect((0, thirdweb_1.isValidWebhookSignature)(secret, body, validSignature)).toBe(true);
14
14
  });
15
15
  it('returns false for an invalid signature', () => {
16
16
  const invalidSignature = 'invalidsignature123';
17
- expect((0, thirdweb_1.isValidSignature)(secret, body, invalidSignature)).toBe(false);
17
+ expect((0, thirdweb_1.isValidWebhookSignature)(secret, body, invalidSignature)).toBe(false);
18
18
  });
19
19
  it('returns false if body or secret is tampered', () => {
20
20
  const originalSignature = crypto_1.default.createHmac('sha256', secret).update(body).digest('hex');
21
21
  // wrong body
22
- expect((0, thirdweb_1.isValidSignature)(secret, '{"message":"tampered"}', originalSignature)).toBe(false);
22
+ expect((0, thirdweb_1.isValidWebhookSignature)(secret, '{"message":"tampered"}', originalSignature)).toBe(false);
23
23
  // wrong secret
24
- expect((0, thirdweb_1.isValidSignature)('wrong_secret', body, originalSignature)).toBe(false);
24
+ expect((0, thirdweb_1.isValidWebhookSignature)('wrong_secret', body, originalSignature)).toBe(false);
25
25
  });
26
26
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opticedge-cloud-utils",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "description": "Common utilities for cloud functions",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/types/card.ts CHANGED
@@ -37,6 +37,7 @@ export type Card = {
37
37
  edge_grading: number
38
38
  frontImage: string
39
39
  frontImageUncropped: string
40
+ gifUrl?: string
40
41
  gradeDate: number
41
42
  grading: number
42
43
  grading_confidence: number
@@ -1,29 +1,29 @@
1
- import { isValidSignature } from './thirdweb'
1
+ import { isValidWebhookSignature } from './thirdweb'
2
2
  import crypto from 'crypto'
3
3
 
4
- describe('isValidSignature', () => {
4
+ describe('isValidWebhookSignature', () => {
5
5
  const secret = 'test_secret'
6
6
  const body = '{"message":"hello"}'
7
7
 
8
8
  it('returns true for a valid signature', () => {
9
9
  const validSignature = crypto.createHmac('sha256', secret).update(body).digest('hex')
10
10
 
11
- expect(isValidSignature(secret, body, validSignature)).toBe(true)
11
+ expect(isValidWebhookSignature(secret, body, validSignature)).toBe(true)
12
12
  })
13
13
 
14
14
  it('returns false for an invalid signature', () => {
15
15
  const invalidSignature = 'invalidsignature123'
16
16
 
17
- expect(isValidSignature(secret, body, invalidSignature)).toBe(false)
17
+ expect(isValidWebhookSignature(secret, body, invalidSignature)).toBe(false)
18
18
  })
19
19
 
20
20
  it('returns false if body or secret is tampered', () => {
21
21
  const originalSignature = crypto.createHmac('sha256', secret).update(body).digest('hex')
22
22
 
23
23
  // wrong body
24
- expect(isValidSignature(secret, '{"message":"tampered"}', originalSignature)).toBe(false)
24
+ expect(isValidWebhookSignature(secret, '{"message":"tampered"}', originalSignature)).toBe(false)
25
25
 
26
26
  // wrong secret
27
- expect(isValidSignature('wrong_secret', body, originalSignature)).toBe(false)
27
+ expect(isValidWebhookSignature('wrong_secret', body, originalSignature)).toBe(false)
28
28
  })
29
29
  })
@@ -1,6 +1,6 @@
1
1
  import crypto from 'crypto'
2
2
 
3
- export function isValidSignature(secret: string, body: string, signature: string): boolean {
3
+ export function isValidWebhookSignature(secret: string, body: string, signature: string): boolean {
4
4
  const computedSignature = crypto.createHmac('sha256', secret).update(body).digest('hex')
5
5
  return computedSignature === signature
6
6
  }