@eventop/sdk 1.0.0 → 1.0.1

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/client.js ADDED
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.EventopClient = void 0;
16
+ const node_fetch_1 = __importDefault(require("node-fetch"));
17
+ const errors_1 = require("./errors");
18
+ class EventopClient {
19
+ constructor(config) {
20
+ this.apiKey = config.apiKey;
21
+ // Set base URL based on environment
22
+ if (config.apiUrl) {
23
+ this.baseUrl = config.apiUrl;
24
+ }
25
+ else {
26
+ const env = config.environment || this.detectEnvironment();
27
+ this.baseUrl =
28
+ env === 'devnet'
29
+ ? 'https://eventop-server-app-production.up.railway.app'
30
+ : 'https://api.eventop.xyz';
31
+ }
32
+ }
33
+ detectEnvironment() {
34
+ // Detect from API key prefix
35
+ if (this.apiKey.startsWith('sk_test_')) {
36
+ return 'devnet';
37
+ }
38
+ else if (this.apiKey.startsWith('sk_live_')) {
39
+ return 'mainnet';
40
+ }
41
+ throw new errors_1.AuthenticationError('Invalid API key format');
42
+ }
43
+ request(method, path, body) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ const url = `${this.baseUrl}${path}`;
46
+ const headers = {
47
+ 'Authorization': `Bearer ${this.apiKey}`,
48
+ 'Content-Type': 'application/json',
49
+ };
50
+ const response = yield (0, node_fetch_1.default)(url, {
51
+ method,
52
+ headers,
53
+ body: body ? JSON.stringify(body) : undefined,
54
+ });
55
+ const data = yield response.json();
56
+ if (!response.ok) {
57
+ throw new errors_1.EventopError(data.message || 'Request failed', response.status, data.code);
58
+ }
59
+ return data;
60
+ });
61
+ }
62
+ }
63
+ exports.EventopClient = EventopClient;
package/dist/errors.js ADDED
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotFoundError = exports.InvalidRequestError = exports.AuthenticationError = exports.EventopError = void 0;
4
+ class EventopError extends Error {
5
+ constructor(message, statusCode, code) {
6
+ super(message);
7
+ this.statusCode = statusCode;
8
+ this.code = code;
9
+ this.name = 'EventopError';
10
+ }
11
+ }
12
+ exports.EventopError = EventopError;
13
+ class AuthenticationError extends EventopError {
14
+ constructor(message = 'Invalid API key') {
15
+ super(message, 401, 'authentication_error');
16
+ this.name = 'AuthenticationError';
17
+ }
18
+ }
19
+ exports.AuthenticationError = AuthenticationError;
20
+ class InvalidRequestError extends EventopError {
21
+ constructor(message) {
22
+ super(message, 400, 'invalid_request');
23
+ this.name = 'InvalidRequestError';
24
+ }
25
+ }
26
+ exports.InvalidRequestError = InvalidRequestError;
27
+ class NotFoundError extends EventopError {
28
+ constructor(message) {
29
+ super(message, 404, 'not_found');
30
+ this.name = 'NotFoundError';
31
+ }
32
+ }
33
+ exports.NotFoundError = NotFoundError;
@@ -15,19 +15,18 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.Eventop = void 0;
18
- var client_1 = require("./client");
19
- var checkout_1 = require("./resources/checkout");
20
- var subscriptions_1 = require("./resources/subscriptions");
21
- var webhooks_1 = require("./resources/webhooks");
22
- var Eventop = /** @class */ (function () {
23
- function Eventop(config) {
24
- var client = new client_1.EventopClient(config);
18
+ const client_1 = require("./client");
19
+ const checkout_1 = require("./resources/checkout");
20
+ const subscriptions_1 = require("./resources/subscriptions");
21
+ const webhooks_1 = require("./resources/webhooks");
22
+ class Eventop {
23
+ constructor(config) {
24
+ const client = new client_1.EventopClient(config);
25
25
  this.checkout = new checkout_1.Checkout(client);
26
26
  this.subscriptions = new subscriptions_1.Subscriptions(client);
27
27
  this.webhooks = new webhooks_1.Webhooks(client);
28
28
  }
29
- return Eventop;
30
- }());
29
+ }
31
30
  exports.Eventop = Eventop;
32
31
  __exportStar(require("./types"), exports);
33
32
  __exportStar(require("./errors"), exports);
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Checkout = void 0;
13
+ class Checkout {
14
+ constructor(client) {
15
+ this.client = client;
16
+ }
17
+ create(params) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ return this.client.request('POST', '/checkout/create', params);
20
+ });
21
+ }
22
+ get(sessionId) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ return this.client.request('GET', `/checkout/${sessionId}`);
25
+ });
26
+ }
27
+ cancel(sessionId) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ return this.client.request('POST', `/checkout/${sessionId}/cancel`);
30
+ });
31
+ }
32
+ }
33
+ exports.Checkout = Checkout;
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Subscriptions = void 0;
13
+ class Subscriptions {
14
+ constructor(client) {
15
+ this.client = client;
16
+ }
17
+ list() {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ return this.client.request('GET', '/subscriptions');
20
+ });
21
+ }
22
+ get(subscriptionId) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ return this.client.request('GET', `/subscriptions/${subscriptionId}`);
25
+ });
26
+ }
27
+ cancel(subscriptionId) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ return this.client.request('POST', `/subscriptions/${subscriptionId}/cancel`);
30
+ });
31
+ }
32
+ }
33
+ exports.Subscriptions = Subscriptions;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.Webhooks = void 0;
37
+ const crypto = __importStar(require("crypto"));
38
+ class Webhooks {
39
+ constructor(client) {
40
+ this.client = client;
41
+ }
42
+ verifySignature(payload, signature, secret) {
43
+ const payloadString = typeof payload === 'string' ? payload : JSON.stringify(payload);
44
+ const expectedSignature = crypto
45
+ .createHmac('sha256', secret)
46
+ .update(payloadString)
47
+ .digest('hex');
48
+ return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expectedSignature));
49
+ }
50
+ constructEvent(payload, signature, secret) {
51
+ const payloadString = Buffer.isBuffer(payload)
52
+ ? payload.toString('utf8')
53
+ : payload;
54
+ if (!this.verifySignature(payloadString, signature, secret)) {
55
+ throw new Error('Invalid webhook signature');
56
+ }
57
+ return JSON.parse(payloadString);
58
+ }
59
+ }
60
+ exports.Webhooks = Webhooks;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eventop/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Official SDK for Eventop on-chain subscriptions",
5
5
  "keywords": [
6
6
  "solana",
package/src/client.ts CHANGED
@@ -16,7 +16,7 @@ export class EventopClient {
16
16
  const env = config.environment || this.detectEnvironment();
17
17
  this.baseUrl =
18
18
  env === 'devnet'
19
- ? 'https://api-devnet.eventop.xyz'
19
+ ? 'https://eventop-server-app-production.up.railway.app'
20
20
  : 'https://api.eventop.xyz';
21
21
  }
22
22
  }
package/tsconfig.json CHANGED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2016",
4
+ "module": "CommonJS",
5
+ "outDir": "./dist",
6
+ "rootDir": "./src",
7
+ "strict": true,
8
+ "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "forceConsistentCasingInFileNames": true
11
+ },
12
+ "include": [
13
+ "src/**/*.ts"
14
+ ],
15
+ "exclude": [
16
+ "node_modules"
17
+ ]
18
+ }
package/src/client.js DELETED
@@ -1,98 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.EventopClient = void 0;
40
- var node_fetch_1 = require("node-fetch");
41
- var errors_1 = require("./errors");
42
- var EventopClient = /** @class */ (function () {
43
- function EventopClient(config) {
44
- this.apiKey = config.apiKey;
45
- // Set base URL based on environment
46
- if (config.apiUrl) {
47
- this.baseUrl = config.apiUrl;
48
- }
49
- else {
50
- var env = config.environment || this.detectEnvironment();
51
- this.baseUrl =
52
- env === 'devnet'
53
- ? 'https://api-devnet.eventop.xyz'
54
- : 'https://api.eventop.xyz';
55
- }
56
- }
57
- EventopClient.prototype.detectEnvironment = function () {
58
- // Detect from API key prefix
59
- if (this.apiKey.startsWith('sk_test_')) {
60
- return 'devnet';
61
- }
62
- else if (this.apiKey.startsWith('sk_live_')) {
63
- return 'mainnet';
64
- }
65
- throw new errors_1.AuthenticationError('Invalid API key format');
66
- };
67
- EventopClient.prototype.request = function (method, path, body) {
68
- return __awaiter(this, void 0, void 0, function () {
69
- var url, headers, response, data;
70
- return __generator(this, function (_a) {
71
- switch (_a.label) {
72
- case 0:
73
- url = "".concat(this.baseUrl).concat(path);
74
- headers = {
75
- 'Authorization': "Bearer ".concat(this.apiKey),
76
- 'Content-Type': 'application/json',
77
- };
78
- return [4 /*yield*/, (0, node_fetch_1.default)(url, {
79
- method: method,
80
- headers: headers,
81
- body: body ? JSON.stringify(body) : undefined,
82
- })];
83
- case 1:
84
- response = _a.sent();
85
- return [4 /*yield*/, response.json()];
86
- case 2:
87
- data = _a.sent();
88
- if (!response.ok) {
89
- throw new errors_1.EventopError(data.message || 'Request failed', response.status, data.code);
90
- }
91
- return [2 /*return*/, data];
92
- }
93
- });
94
- });
95
- };
96
- return EventopClient;
97
- }());
98
- exports.EventopClient = EventopClient;
package/src/errors.js DELETED
@@ -1,61 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.NotFoundError = exports.InvalidRequestError = exports.AuthenticationError = exports.EventopError = void 0;
19
- var EventopError = /** @class */ (function (_super) {
20
- __extends(EventopError, _super);
21
- function EventopError(message, statusCode, code) {
22
- var _this = _super.call(this, message) || this;
23
- _this.statusCode = statusCode;
24
- _this.code = code;
25
- _this.name = 'EventopError';
26
- return _this;
27
- }
28
- return EventopError;
29
- }(Error));
30
- exports.EventopError = EventopError;
31
- var AuthenticationError = /** @class */ (function (_super) {
32
- __extends(AuthenticationError, _super);
33
- function AuthenticationError(message) {
34
- if (message === void 0) { message = 'Invalid API key'; }
35
- var _this = _super.call(this, message, 401, 'authentication_error') || this;
36
- _this.name = 'AuthenticationError';
37
- return _this;
38
- }
39
- return AuthenticationError;
40
- }(EventopError));
41
- exports.AuthenticationError = AuthenticationError;
42
- var InvalidRequestError = /** @class */ (function (_super) {
43
- __extends(InvalidRequestError, _super);
44
- function InvalidRequestError(message) {
45
- var _this = _super.call(this, message, 400, 'invalid_request') || this;
46
- _this.name = 'InvalidRequestError';
47
- return _this;
48
- }
49
- return InvalidRequestError;
50
- }(EventopError));
51
- exports.InvalidRequestError = InvalidRequestError;
52
- var NotFoundError = /** @class */ (function (_super) {
53
- __extends(NotFoundError, _super);
54
- function NotFoundError(message) {
55
- var _this = _super.call(this, message, 404, 'not_found') || this;
56
- _this.name = 'NotFoundError';
57
- return _this;
58
- }
59
- return NotFoundError;
60
- }(EventopError));
61
- exports.NotFoundError = NotFoundError;
@@ -1,67 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.Checkout = void 0;
40
- var Checkout = /** @class */ (function () {
41
- function Checkout(client) {
42
- this.client = client;
43
- }
44
- Checkout.prototype.create = function (params) {
45
- return __awaiter(this, void 0, void 0, function () {
46
- return __generator(this, function (_a) {
47
- return [2 /*return*/, this.client.request('POST', '/checkout/create', params)];
48
- });
49
- });
50
- };
51
- Checkout.prototype.get = function (sessionId) {
52
- return __awaiter(this, void 0, void 0, function () {
53
- return __generator(this, function (_a) {
54
- return [2 /*return*/, this.client.request('GET', "/checkout/".concat(sessionId))];
55
- });
56
- });
57
- };
58
- Checkout.prototype.cancel = function (sessionId) {
59
- return __awaiter(this, void 0, void 0, function () {
60
- return __generator(this, function (_a) {
61
- return [2 /*return*/, this.client.request('POST', "/checkout/".concat(sessionId, "/cancel"))];
62
- });
63
- });
64
- };
65
- return Checkout;
66
- }());
67
- exports.Checkout = Checkout;
File without changes
@@ -1,67 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.Subscriptions = void 0;
40
- var Subscriptions = /** @class */ (function () {
41
- function Subscriptions(client) {
42
- this.client = client;
43
- }
44
- Subscriptions.prototype.list = function () {
45
- return __awaiter(this, void 0, void 0, function () {
46
- return __generator(this, function (_a) {
47
- return [2 /*return*/, this.client.request('GET', '/subscriptions')];
48
- });
49
- });
50
- };
51
- Subscriptions.prototype.get = function (subscriptionId) {
52
- return __awaiter(this, void 0, void 0, function () {
53
- return __generator(this, function (_a) {
54
- return [2 /*return*/, this.client.request('GET', "/subscriptions/".concat(subscriptionId))];
55
- });
56
- });
57
- };
58
- Subscriptions.prototype.cancel = function (subscriptionId) {
59
- return __awaiter(this, void 0, void 0, function () {
60
- return __generator(this, function (_a) {
61
- return [2 /*return*/, this.client.request('POST', "/subscriptions/".concat(subscriptionId, "/cancel"))];
62
- });
63
- });
64
- };
65
- return Subscriptions;
66
- }());
67
- exports.Subscriptions = Subscriptions;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Webhooks = void 0;
4
- var crypto = require("crypto");
5
- var Webhooks = /** @class */ (function () {
6
- function Webhooks(client) {
7
- this.client = client;
8
- }
9
- Webhooks.prototype.verifySignature = function (payload, signature, secret) {
10
- var payloadString = typeof payload === 'string' ? payload : JSON.stringify(payload);
11
- var expectedSignature = crypto
12
- .createHmac('sha256', secret)
13
- .update(payloadString)
14
- .digest('hex');
15
- return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expectedSignature));
16
- };
17
- Webhooks.prototype.constructEvent = function (payload, signature, secret) {
18
- var payloadString = Buffer.isBuffer(payload)
19
- ? payload.toString('utf8')
20
- : payload;
21
- if (!this.verifySignature(payloadString, signature, secret)) {
22
- throw new Error('Invalid webhook signature');
23
- }
24
- return JSON.parse(payloadString);
25
- };
26
- return Webhooks;
27
- }());
28
- exports.Webhooks = Webhooks;
File without changes