@skalpgg/sdk 1.8.0 → 1.8.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.
@@ -1,6 +1,6 @@
1
1
  import type { AccessRule, AddAccessRuleParams, AddSerialsParams, AddSerialsResult, AppealFeedbackParams, ChangeSubscriptionPlanParams, CheckoutSession, CheckoutSessionStatus, CoinCheckout, CoinCheckoutStatus, Coupon, CreateCheckoutParams, CreateCoinCheckoutParams, CreateCouponParams, CreateCustomerParams, CreateProductGroupParams, CreateProductParams, CreateStoreCategoryParams, CreateSubscriptionCheckoutParams, CreateUsageChargeParams, CreateWebhookParams, CreatedWebhookEndpoint, Customer, CustomerDetails, CustomerList, Deleted, Feedback, FeedbackList, HeartbeatParams, Invoice, LicenseKeyInfo, LicenseValidation, LicenseVerification, ListAccessRulesParams, ListCustomersParams, ListFeedbackParams, ListOrdersParams, ListProductsParams, ListQueriesParams, ListSerialsParams, ListSubscriptionsParams, Me, Order, OrderKeysReplaced, OrderList, Product, ProductGroup, ProductStock, ReplaceOrderKeysParams, ReplyParams, SerialList, SkalpEvent, StoreCategory, StoreCategoryWithCount, Subscription, SubscriptionCheckout, SubscriptionCheckoutStatus, SubscriptionList, SupportQueryDetails, SupportQueryList, ResetLicenseDevicesParams, UpdateCouponParams, UpdateCustomerParams, UpdateProductGroupParams, UpdateProductParams, UpdateStoreCategoryParams, UsageCharge, ValidateLicenseParams, VerifyLicenseParams, WebhookEndpoint } from './types.js';
2
2
  export type * from './types.js';
3
- export declare const VERSION = "1.8.0";
3
+ export declare const VERSION = "1.8.1";
4
4
  export interface SkalpOptions {
5
5
  apiKey?: string;
6
6
  webhookSecret?: string;
package/dist/cjs/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Skalp = exports.SkalpSignatureError = exports.SkalpConnectionError = exports.SkalpError = exports.VERSION = void 0;
4
- exports.VERSION = '1.8.0';
4
+ exports.VERSION = '1.8.1';
5
5
  const SIGNATURE_HEADER = 'skalp-signature';
6
6
  const SIGNATURE_TOLERANCE_SECONDS = 300;
7
7
  const PRODUCT_PAGE = 100;
@@ -40,7 +40,11 @@ class SkalpSignatureError extends Error {
40
40
  }
41
41
  exports.SkalpSignatureError = SkalpSignatureError;
42
42
  const env = (name) => globalThis.process?.env?.[name];
43
- const segment = (id) => encodeURIComponent(id);
43
+ const INVALID_SEGMENT = '\0';
44
+ const segment = (id) => {
45
+ const encoded = encodeURIComponent(id);
46
+ return encoded === '' || encoded === '.' || encoded === '..' ? INVALID_SEGMENT : encoded;
47
+ };
44
48
  const isoDate = (value) => (value instanceof Date ? value.toISOString() : value);
45
49
  const optionalDate = (value) => value instanceof Date ? value.toISOString() : value;
46
50
  const PRODUCT_FIELDS = [
@@ -347,6 +351,8 @@ class Skalp {
347
351
  if (auth && !this.#apiKey) {
348
352
  throw new Error('Skalp: missing API key. Pass it to new Skalp(apiKey) or set SKALP_API_KEY.');
349
353
  }
354
+ if (path.includes(INVALID_SEGMENT))
355
+ throw new Error('Skalp: an ID cannot be empty, "." or "..".');
350
356
  const url = new URL(this.#baseUrl + path);
351
357
  for (const [name, value] of Object.entries(query ?? {})) {
352
358
  if (Array.isArray(value))
@@ -56,6 +56,7 @@ export interface Order {
56
56
  currency: Currency;
57
57
  discountAmount: number;
58
58
  serviceFee: number | null;
59
+ sellerPaymentFee: number | null;
59
60
  couponCode: string | null;
60
61
  productId: string;
61
62
  productName: string;
@@ -1031,6 +1032,23 @@ export interface FeedbackReceivedData {
1031
1032
  customerName: string | null;
1032
1033
  createdAt: string;
1033
1034
  }
1035
+ export interface SubscriptionCheckoutExpiredData {
1036
+ idempotencyKey: string;
1037
+ checkoutId: string;
1038
+ externalRef: string | null;
1039
+ status: 'EXPIRED';
1040
+ active: false;
1041
+ reason: 'payment_not_completed';
1042
+ storeId: string;
1043
+ productId: string;
1044
+ productSlug: string;
1045
+ productName: string;
1046
+ buyerId: string;
1047
+ buyerEmail: string | null;
1048
+ amount: number;
1049
+ currency: string;
1050
+ metadata: Record<string, unknown>;
1051
+ }
1034
1052
  export type SkalpEvent = Envelope<'order.created' | 'order.updated' | 'order.canceled', OrderEventData> | Envelope<'order.replaced', OrderReplacedData> | Envelope<'order.paid' | 'purchase.completed', OrderPaidData> | Envelope<'order.refunded', OrderRefundedData> | Envelope<'order.disputed' | 'account.suspend', OrderDisputedData> | Envelope<'account.restore', AccountRestoreData> | Envelope<'subscription.created' | 'subscription.updated' | 'subscription.trial_started' | 'subscription.trial_ended', SubscriptionEventData> | Envelope<'subscription.upcoming', SubscriptionEventData & {
1035
1053
  amountDue: number;
1036
1054
  nextPaymentAttempt: string | null;
@@ -1038,7 +1056,7 @@ export type SkalpEvent = Envelope<'order.created' | 'order.updated' | 'order.can
1038
1056
  invoiceId: string;
1039
1057
  amountPaid: number;
1040
1058
  periodExtendedTo: string;
1041
- }> | Envelope<'subscription.past_due', SubscriptionEventData & {
1059
+ }> | Envelope<'subscription.checkout_expired', SubscriptionCheckoutExpiredData> | Envelope<'subscription.past_due', SubscriptionEventData & {
1042
1060
  invoiceId: string;
1043
1061
  attemptCount: number;
1044
1062
  nextPaymentAttempt: string | null;
@@ -1,6 +1,6 @@
1
1
  import type { AccessRule, AddAccessRuleParams, AddSerialsParams, AddSerialsResult, AppealFeedbackParams, ChangeSubscriptionPlanParams, CheckoutSession, CheckoutSessionStatus, CoinCheckout, CoinCheckoutStatus, Coupon, CreateCheckoutParams, CreateCoinCheckoutParams, CreateCouponParams, CreateCustomerParams, CreateProductGroupParams, CreateProductParams, CreateStoreCategoryParams, CreateSubscriptionCheckoutParams, CreateUsageChargeParams, CreateWebhookParams, CreatedWebhookEndpoint, Customer, CustomerDetails, CustomerList, Deleted, Feedback, FeedbackList, HeartbeatParams, Invoice, LicenseKeyInfo, LicenseValidation, LicenseVerification, ListAccessRulesParams, ListCustomersParams, ListFeedbackParams, ListOrdersParams, ListProductsParams, ListQueriesParams, ListSerialsParams, ListSubscriptionsParams, Me, Order, OrderKeysReplaced, OrderList, Product, ProductGroup, ProductStock, ReplaceOrderKeysParams, ReplyParams, SerialList, SkalpEvent, StoreCategory, StoreCategoryWithCount, Subscription, SubscriptionCheckout, SubscriptionCheckoutStatus, SubscriptionList, SupportQueryDetails, SupportQueryList, ResetLicenseDevicesParams, UpdateCouponParams, UpdateCustomerParams, UpdateProductGroupParams, UpdateProductParams, UpdateStoreCategoryParams, UsageCharge, ValidateLicenseParams, VerifyLicenseParams, WebhookEndpoint } from './types.js';
2
2
  export type * from './types.js';
3
- export declare const VERSION = "1.8.0";
3
+ export declare const VERSION = "1.8.1";
4
4
  export interface SkalpOptions {
5
5
  apiKey?: string;
6
6
  webhookSecret?: string;
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const VERSION = '1.8.0';
1
+ export const VERSION = '1.8.1';
2
2
  const SIGNATURE_HEADER = 'skalp-signature';
3
3
  const SIGNATURE_TOLERANCE_SECONDS = 300;
4
4
  const PRODUCT_PAGE = 100;
@@ -34,7 +34,11 @@ export class SkalpSignatureError extends Error {
34
34
  }
35
35
  }
36
36
  const env = (name) => globalThis.process?.env?.[name];
37
- const segment = (id) => encodeURIComponent(id);
37
+ const INVALID_SEGMENT = '\0';
38
+ const segment = (id) => {
39
+ const encoded = encodeURIComponent(id);
40
+ return encoded === '' || encoded === '.' || encoded === '..' ? INVALID_SEGMENT : encoded;
41
+ };
38
42
  const isoDate = (value) => (value instanceof Date ? value.toISOString() : value);
39
43
  const optionalDate = (value) => value instanceof Date ? value.toISOString() : value;
40
44
  const PRODUCT_FIELDS = [
@@ -341,6 +345,8 @@ export class Skalp {
341
345
  if (auth && !this.#apiKey) {
342
346
  throw new Error('Skalp: missing API key. Pass it to new Skalp(apiKey) or set SKALP_API_KEY.');
343
347
  }
348
+ if (path.includes(INVALID_SEGMENT))
349
+ throw new Error('Skalp: an ID cannot be empty, "." or "..".');
344
350
  const url = new URL(this.#baseUrl + path);
345
351
  for (const [name, value] of Object.entries(query ?? {})) {
346
352
  if (Array.isArray(value))
@@ -56,6 +56,7 @@ export interface Order {
56
56
  currency: Currency;
57
57
  discountAmount: number;
58
58
  serviceFee: number | null;
59
+ sellerPaymentFee: number | null;
59
60
  couponCode: string | null;
60
61
  productId: string;
61
62
  productName: string;
@@ -1031,6 +1032,23 @@ export interface FeedbackReceivedData {
1031
1032
  customerName: string | null;
1032
1033
  createdAt: string;
1033
1034
  }
1035
+ export interface SubscriptionCheckoutExpiredData {
1036
+ idempotencyKey: string;
1037
+ checkoutId: string;
1038
+ externalRef: string | null;
1039
+ status: 'EXPIRED';
1040
+ active: false;
1041
+ reason: 'payment_not_completed';
1042
+ storeId: string;
1043
+ productId: string;
1044
+ productSlug: string;
1045
+ productName: string;
1046
+ buyerId: string;
1047
+ buyerEmail: string | null;
1048
+ amount: number;
1049
+ currency: string;
1050
+ metadata: Record<string, unknown>;
1051
+ }
1034
1052
  export type SkalpEvent = Envelope<'order.created' | 'order.updated' | 'order.canceled', OrderEventData> | Envelope<'order.replaced', OrderReplacedData> | Envelope<'order.paid' | 'purchase.completed', OrderPaidData> | Envelope<'order.refunded', OrderRefundedData> | Envelope<'order.disputed' | 'account.suspend', OrderDisputedData> | Envelope<'account.restore', AccountRestoreData> | Envelope<'subscription.created' | 'subscription.updated' | 'subscription.trial_started' | 'subscription.trial_ended', SubscriptionEventData> | Envelope<'subscription.upcoming', SubscriptionEventData & {
1035
1053
  amountDue: number;
1036
1054
  nextPaymentAttempt: string | null;
@@ -1038,7 +1056,7 @@ export type SkalpEvent = Envelope<'order.created' | 'order.updated' | 'order.can
1038
1056
  invoiceId: string;
1039
1057
  amountPaid: number;
1040
1058
  periodExtendedTo: string;
1041
- }> | Envelope<'subscription.past_due', SubscriptionEventData & {
1059
+ }> | Envelope<'subscription.checkout_expired', SubscriptionCheckoutExpiredData> | Envelope<'subscription.past_due', SubscriptionEventData & {
1042
1060
  invoiceId: string;
1043
1061
  attemptCount: number;
1044
1062
  nextPaymentAttempt: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skalpgg/sdk",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "Official Skalp SDK for Node.js and edge runtimes: checkout, subscriptions, catalog and key stock, webhooks and license verification.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://skalp.gg/docs/sdk",