@eventop/sdk 1.0.0 → 1.0.2

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.
Files changed (56) hide show
  1. package/dist/cjs/client.js +52 -0
  2. package/dist/cjs/errors.js +33 -0
  3. package/{src → dist/cjs}/index.js +8 -9
  4. package/dist/cjs/resources/checkout.js +18 -0
  5. package/dist/cjs/resources/customers.js +1 -0
  6. package/dist/cjs/resources/subscriptions.js +18 -0
  7. package/dist/cjs/resources/webhooks.js +60 -0
  8. package/dist/client.js +63 -0
  9. package/dist/errors.js +33 -0
  10. package/dist/esm/client.js +45 -0
  11. package/dist/esm/errors.js +26 -0
  12. package/dist/esm/index.js +14 -0
  13. package/dist/esm/resources/checkout.js +14 -0
  14. package/dist/esm/resources/customers.js +1 -0
  15. package/dist/esm/resources/subscriptions.js +14 -0
  16. package/dist/esm/resources/webhooks.js +23 -0
  17. package/dist/esm/types.js +1 -0
  18. package/dist/index.js +32 -0
  19. package/dist/resources/checkout.js +33 -0
  20. package/dist/resources/customers.js +1 -0
  21. package/dist/resources/subscriptions.js +33 -0
  22. package/dist/resources/webhooks.js +60 -0
  23. package/dist/types/client.d.ts +9 -0
  24. package/dist/types/client.d.ts.map +1 -0
  25. package/dist/types/errors.d.ts +15 -0
  26. package/dist/types/errors.d.ts.map +1 -0
  27. package/dist/types/index.d.ts +13 -0
  28. package/dist/types/index.d.ts.map +1 -0
  29. package/dist/types/resources/checkout.d.ts +10 -0
  30. package/dist/types/resources/checkout.d.ts.map +1 -0
  31. package/dist/types/resources/customers.d.ts +1 -0
  32. package/dist/types/resources/customers.d.ts.map +1 -0
  33. package/dist/types/resources/subscriptions.d.ts +10 -0
  34. package/dist/types/resources/subscriptions.d.ts.map +1 -0
  35. package/dist/types/resources/webhooks.d.ts +9 -0
  36. package/dist/types/resources/webhooks.d.ts.map +1 -0
  37. package/dist/types/types.d.ts +44 -0
  38. package/dist/types/types.d.ts.map +1 -0
  39. package/dist/types.js +2 -0
  40. package/package.json +44 -35
  41. package/src/client.js +0 -98
  42. package/src/client.ts +0 -64
  43. package/src/errors.js +0 -61
  44. package/src/errors.ts +0 -31
  45. package/src/index.ts +0 -22
  46. package/src/resources/checkout.js +0 -67
  47. package/src/resources/checkout.ts +0 -22
  48. package/src/resources/customers.js +0 -0
  49. package/src/resources/customers.ts +0 -0
  50. package/src/resources/subscriptions.js +0 -67
  51. package/src/resources/subscriptions.ts +0 -24
  52. package/src/resources/webhooks.js +0 -28
  53. package/src/resources/webhooks.ts +0 -42
  54. package/src/types.ts +0 -49
  55. package/tsconfig.json +0 -0
  56. /package/{src → dist/cjs}/types.js +0 -0
@@ -1,24 +0,0 @@
1
- import { EventopClient } from '../client';
2
- import { Subscription } from '../types';
3
-
4
- export class Subscriptions {
5
- constructor(private client: EventopClient) {}
6
-
7
- async list(): Promise<Subscription[]> {
8
- return this.client.request<Subscription[]>('GET', '/subscriptions');
9
- }
10
-
11
- async get(subscriptionId: string): Promise<Subscription> {
12
- return this.client.request<Subscription>(
13
- 'GET',
14
- `/subscriptions/${subscriptionId}`,
15
- );
16
- }
17
-
18
- async cancel(subscriptionId: string): Promise<any> {
19
- return this.client.request(
20
- 'POST',
21
- `/subscriptions/${subscriptionId}/cancel`,
22
- );
23
- }
24
- }
@@ -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;
@@ -1,42 +0,0 @@
1
- import * as crypto from 'crypto';
2
- import { EventopClient } from '../client';
3
- import { WebhookPayload } from '../types';
4
-
5
- export class Webhooks {
6
- constructor(private client: EventopClient) {}
7
-
8
- verifySignature(
9
- payload: WebhookPayload | string,
10
- signature: string,
11
- secret: string,
12
- ): boolean {
13
- const payloadString =
14
- typeof payload === 'string' ? payload : JSON.stringify(payload);
15
-
16
- const expectedSignature = crypto
17
- .createHmac('sha256', secret)
18
- .update(payloadString)
19
- .digest('hex');
20
-
21
- return crypto.timingSafeEqual(
22
- Buffer.from(signature),
23
- Buffer.from(expectedSignature),
24
- );
25
- }
26
-
27
- constructEvent(
28
- payload: string | Buffer,
29
- signature: string,
30
- secret: string,
31
- ): WebhookPayload {
32
- const payloadString = Buffer.isBuffer(payload)
33
- ? payload.toString('utf8')
34
- : payload;
35
-
36
- if (!this.verifySignature(payloadString, signature, secret)) {
37
- throw new Error('Invalid webhook signature');
38
- }
39
-
40
- return JSON.parse(payloadString);
41
- }
42
- }
package/src/types.ts DELETED
@@ -1,49 +0,0 @@
1
- export type Environment = 'devnet' | 'mainnet';
2
-
3
- export interface EventopConfig {
4
- apiKey: string;
5
- environment?: Environment;
6
- apiUrl?: string;
7
- }
8
-
9
- export interface CheckoutSessionParams {
10
- planId: string;
11
- customerEmail: string;
12
- customerId?: string;
13
- successUrl: string;
14
- cancelUrl?: string;
15
- metadata?: Record<string, any>;
16
- }
17
-
18
- export interface CheckoutSession {
19
- sessionId: string;
20
- url: string;
21
- expiresAt: string;
22
- }
23
-
24
- export interface Subscription {
25
- subscriptionPda: string;
26
- userWallet: string;
27
- merchantWallet: string;
28
- planId: string;
29
- feeAmount: string;
30
- paymentInterval: string;
31
- isActive: boolean;
32
- totalPaid: string;
33
- paymentCount: number;
34
- createdAt: string;
35
- cancelledAt?: string;
36
- }
37
-
38
- export interface Customer {
39
- email: string;
40
- customerId?: string;
41
- walletAddress: string;
42
- subscriptions: Subscription[];
43
- }
44
-
45
- export interface WebhookPayload {
46
- event: string;
47
- timestamp: number;
48
- data: any;
49
- }
package/tsconfig.json DELETED
File without changes
File without changes