opticedge-cloud-utils 1.0.44 → 1.0.45
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.
package/dist/types/card.d.ts
CHANGED
package/dist/types/card.js
CHANGED
|
@@ -11,6 +11,7 @@ var CardApprovalStatus;
|
|
|
11
11
|
})(CardApprovalStatus || (exports.CardApprovalStatus = CardApprovalStatus = {}));
|
|
12
12
|
var CardGradingType;
|
|
13
13
|
(function (CardGradingType) {
|
|
14
|
+
CardGradingType[CardGradingType["UNKNOWN"] = 0] = "UNKNOWN";
|
|
14
15
|
CardGradingType[CardGradingType["COLLECTION"] = 1] = "COLLECTION";
|
|
15
16
|
CardGradingType[CardGradingType["ADDED"] = 2] = "ADDED";
|
|
16
17
|
CardGradingType[CardGradingType["SOLD"] = 3] = "SOLD";
|
package/package.json
CHANGED
package/src/types/card.ts
CHANGED
package/dist/utils/thirdweb.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isValidWebhookSignature(secret: string, body: string, signature: string): boolean;
|
package/dist/utils/thirdweb.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isValidWebhookSignature = isValidWebhookSignature;
|
|
7
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
-
function isValidWebhookSignature(secret, body, signature) {
|
|
9
|
-
const computedSignature = crypto_1.default.createHmac('sha256', secret).update(body).digest('hex');
|
|
10
|
-
return computedSignature === signature;
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const thirdweb_1 = require("./thirdweb");
|
|
7
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
-
describe('isValidWebhookSignature', () => {
|
|
9
|
-
const secret = 'test_secret';
|
|
10
|
-
const body = '{"message":"hello"}';
|
|
11
|
-
it('returns true for a valid signature', () => {
|
|
12
|
-
const validSignature = crypto_1.default.createHmac('sha256', secret).update(body).digest('hex');
|
|
13
|
-
expect((0, thirdweb_1.isValidWebhookSignature)(secret, body, validSignature)).toBe(true);
|
|
14
|
-
});
|
|
15
|
-
it('returns false for an invalid signature', () => {
|
|
16
|
-
const invalidSignature = 'invalidsignature123';
|
|
17
|
-
expect((0, thirdweb_1.isValidWebhookSignature)(secret, body, invalidSignature)).toBe(false);
|
|
18
|
-
});
|
|
19
|
-
it('returns false if body or secret is tampered', () => {
|
|
20
|
-
const originalSignature = crypto_1.default.createHmac('sha256', secret).update(body).digest('hex');
|
|
21
|
-
// wrong body
|
|
22
|
-
expect((0, thirdweb_1.isValidWebhookSignature)(secret, '{"message":"tampered"}', originalSignature)).toBe(false);
|
|
23
|
-
// wrong secret
|
|
24
|
-
expect((0, thirdweb_1.isValidWebhookSignature)('wrong_secret', body, originalSignature)).toBe(false);
|
|
25
|
-
});
|
|
26
|
-
});
|