omni-sync-sdk 0.7.7 → 0.7.9
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/index.d.mts +48 -1
- package/dist/index.d.ts +48 -1
- package/dist/index.js +79 -0
- package/dist/index.mjs +79 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -498,6 +498,12 @@ interface CustomerAuthResponse {
|
|
|
498
498
|
};
|
|
499
499
|
token: string;
|
|
500
500
|
expiresAt: string;
|
|
501
|
+
/** If true, customer needs to verify their email before proceeding */
|
|
502
|
+
requiresVerification?: boolean;
|
|
503
|
+
}
|
|
504
|
+
interface EmailVerificationResponse {
|
|
505
|
+
verified: boolean;
|
|
506
|
+
message: string;
|
|
501
507
|
}
|
|
502
508
|
interface RegisterCustomerDto {
|
|
503
509
|
email: string;
|
|
@@ -1662,6 +1668,47 @@ declare class OmniSyncClient {
|
|
|
1662
1668
|
forgotPassword(email: string): Promise<{
|
|
1663
1669
|
message: string;
|
|
1664
1670
|
}>;
|
|
1671
|
+
/**
|
|
1672
|
+
* Verify customer email with a verification code
|
|
1673
|
+
* Only available in vibe-coded mode
|
|
1674
|
+
*
|
|
1675
|
+
* @param code - The 6-digit verification code from the email
|
|
1676
|
+
* @param token - Optional customer token. If not provided, uses the token set via setCustomerToken()
|
|
1677
|
+
*
|
|
1678
|
+
* @example
|
|
1679
|
+
* ```typescript
|
|
1680
|
+
* // Option 1: Pass token directly (recommended for verification flow)
|
|
1681
|
+
* const auth = await omni.registerCustomer({...});
|
|
1682
|
+
* if (auth.requiresVerification) {
|
|
1683
|
+
* const result = await omni.verifyEmail('123456', auth.token);
|
|
1684
|
+
* }
|
|
1685
|
+
*
|
|
1686
|
+
* // Option 2: Use setCustomerToken first
|
|
1687
|
+
* omni.setCustomerToken(auth.token);
|
|
1688
|
+
* const result = await omni.verifyEmail('123456');
|
|
1689
|
+
* ```
|
|
1690
|
+
*/
|
|
1691
|
+
verifyEmail(code: string, token?: string): Promise<EmailVerificationResponse>;
|
|
1692
|
+
/**
|
|
1693
|
+
* Resend verification email
|
|
1694
|
+
* Only available in vibe-coded mode
|
|
1695
|
+
* Rate limited to 3 requests per hour
|
|
1696
|
+
*
|
|
1697
|
+
* @param token - Optional customer token. If not provided, uses the token set via setCustomerToken()
|
|
1698
|
+
*
|
|
1699
|
+
* @example
|
|
1700
|
+
* ```typescript
|
|
1701
|
+
* // Option 1: Pass token directly
|
|
1702
|
+
* await omni.resendVerificationEmail(auth.token);
|
|
1703
|
+
*
|
|
1704
|
+
* // Option 2: Use setCustomerToken first
|
|
1705
|
+
* omni.setCustomerToken(auth.token);
|
|
1706
|
+
* await omni.resendVerificationEmail();
|
|
1707
|
+
* ```
|
|
1708
|
+
*/
|
|
1709
|
+
resendVerificationEmail(token?: string): Promise<{
|
|
1710
|
+
message: string;
|
|
1711
|
+
}>;
|
|
1665
1712
|
/**
|
|
1666
1713
|
* Get the current logged-in customer's profile
|
|
1667
1714
|
* Requires a customer token to be set via setCustomerToken()
|
|
@@ -2348,4 +2395,4 @@ declare function isWebhookEventType(event: WebhookEvent, type: WebhookEventType)
|
|
|
2348
2395
|
*/
|
|
2349
2396
|
declare function createWebhookHandler(handlers: Partial<Record<WebhookEventType, (event: WebhookEvent) => Promise<void>>>): (payload: unknown) => Promise<void>;
|
|
2350
2397
|
|
|
2351
|
-
export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartItem, type CartStatus, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutLineItem, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateGuestOrderDto, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerProfile, type CustomerQueryParams, type DraftLineItem, type EditInventoryDto, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InventoryInfo, type InventorySyncStatus, type LocalCart, type LocalCartItem, type MergeCartsDto, type OmniSyncApiError, OmniSyncClient, type OmniSyncClientOptions, OmniSyncError, type Order, type OrderAddress, type OrderCustomer, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PlatformCouponCapabilities, type Product, type ProductAttributeInput, type ProductImage, type ProductQueryParams, type ProductSuggestion, type ProductVariant, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type SearchSuggestions, type SelectShippingMethodDto, type SendInvoiceDto, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingLine, type ShippingRate, type StoreInfo, type SyncJob, type UpdateAddressDto, type UpdateCartItemDto, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateInventoryDto, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateVariantDto, type UpdateVariantInventoryDto, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WebhookEvent, type WebhookEventType, createWebhookHandler, isCouponApplicableToProduct, isWebhookEventType, parseWebhookEvent, verifyWebhook };
|
|
2398
|
+
export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartItem, type CartStatus, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutLineItem, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateGuestOrderDto, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerProfile, type CustomerQueryParams, type DraftLineItem, type EditInventoryDto, type EmailVerificationResponse, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InventoryInfo, type InventorySyncStatus, type LocalCart, type LocalCartItem, type MergeCartsDto, type OmniSyncApiError, OmniSyncClient, type OmniSyncClientOptions, OmniSyncError, type Order, type OrderAddress, type OrderCustomer, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PlatformCouponCapabilities, type Product, type ProductAttributeInput, type ProductImage, type ProductQueryParams, type ProductSuggestion, type ProductVariant, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type SearchSuggestions, type SelectShippingMethodDto, type SendInvoiceDto, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingLine, type ShippingRate, type StoreInfo, type SyncJob, type UpdateAddressDto, type UpdateCartItemDto, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateInventoryDto, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateVariantDto, type UpdateVariantInventoryDto, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WebhookEvent, type WebhookEventType, createWebhookHandler, isCouponApplicableToProduct, isWebhookEventType, parseWebhookEvent, verifyWebhook };
|
package/dist/index.d.ts
CHANGED
|
@@ -498,6 +498,12 @@ interface CustomerAuthResponse {
|
|
|
498
498
|
};
|
|
499
499
|
token: string;
|
|
500
500
|
expiresAt: string;
|
|
501
|
+
/** If true, customer needs to verify their email before proceeding */
|
|
502
|
+
requiresVerification?: boolean;
|
|
503
|
+
}
|
|
504
|
+
interface EmailVerificationResponse {
|
|
505
|
+
verified: boolean;
|
|
506
|
+
message: string;
|
|
501
507
|
}
|
|
502
508
|
interface RegisterCustomerDto {
|
|
503
509
|
email: string;
|
|
@@ -1662,6 +1668,47 @@ declare class OmniSyncClient {
|
|
|
1662
1668
|
forgotPassword(email: string): Promise<{
|
|
1663
1669
|
message: string;
|
|
1664
1670
|
}>;
|
|
1671
|
+
/**
|
|
1672
|
+
* Verify customer email with a verification code
|
|
1673
|
+
* Only available in vibe-coded mode
|
|
1674
|
+
*
|
|
1675
|
+
* @param code - The 6-digit verification code from the email
|
|
1676
|
+
* @param token - Optional customer token. If not provided, uses the token set via setCustomerToken()
|
|
1677
|
+
*
|
|
1678
|
+
* @example
|
|
1679
|
+
* ```typescript
|
|
1680
|
+
* // Option 1: Pass token directly (recommended for verification flow)
|
|
1681
|
+
* const auth = await omni.registerCustomer({...});
|
|
1682
|
+
* if (auth.requiresVerification) {
|
|
1683
|
+
* const result = await omni.verifyEmail('123456', auth.token);
|
|
1684
|
+
* }
|
|
1685
|
+
*
|
|
1686
|
+
* // Option 2: Use setCustomerToken first
|
|
1687
|
+
* omni.setCustomerToken(auth.token);
|
|
1688
|
+
* const result = await omni.verifyEmail('123456');
|
|
1689
|
+
* ```
|
|
1690
|
+
*/
|
|
1691
|
+
verifyEmail(code: string, token?: string): Promise<EmailVerificationResponse>;
|
|
1692
|
+
/**
|
|
1693
|
+
* Resend verification email
|
|
1694
|
+
* Only available in vibe-coded mode
|
|
1695
|
+
* Rate limited to 3 requests per hour
|
|
1696
|
+
*
|
|
1697
|
+
* @param token - Optional customer token. If not provided, uses the token set via setCustomerToken()
|
|
1698
|
+
*
|
|
1699
|
+
* @example
|
|
1700
|
+
* ```typescript
|
|
1701
|
+
* // Option 1: Pass token directly
|
|
1702
|
+
* await omni.resendVerificationEmail(auth.token);
|
|
1703
|
+
*
|
|
1704
|
+
* // Option 2: Use setCustomerToken first
|
|
1705
|
+
* omni.setCustomerToken(auth.token);
|
|
1706
|
+
* await omni.resendVerificationEmail();
|
|
1707
|
+
* ```
|
|
1708
|
+
*/
|
|
1709
|
+
resendVerificationEmail(token?: string): Promise<{
|
|
1710
|
+
message: string;
|
|
1711
|
+
}>;
|
|
1665
1712
|
/**
|
|
1666
1713
|
* Get the current logged-in customer's profile
|
|
1667
1714
|
* Requires a customer token to be set via setCustomerToken()
|
|
@@ -2348,4 +2395,4 @@ declare function isWebhookEventType(event: WebhookEvent, type: WebhookEventType)
|
|
|
2348
2395
|
*/
|
|
2349
2396
|
declare function createWebhookHandler(handlers: Partial<Record<WebhookEventType, (event: WebhookEvent) => Promise<void>>>): (payload: unknown) => Promise<void>;
|
|
2350
2397
|
|
|
2351
|
-
export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartItem, type CartStatus, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutLineItem, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateGuestOrderDto, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerProfile, type CustomerQueryParams, type DraftLineItem, type EditInventoryDto, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InventoryInfo, type InventorySyncStatus, type LocalCart, type LocalCartItem, type MergeCartsDto, type OmniSyncApiError, OmniSyncClient, type OmniSyncClientOptions, OmniSyncError, type Order, type OrderAddress, type OrderCustomer, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PlatformCouponCapabilities, type Product, type ProductAttributeInput, type ProductImage, type ProductQueryParams, type ProductSuggestion, type ProductVariant, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type SearchSuggestions, type SelectShippingMethodDto, type SendInvoiceDto, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingLine, type ShippingRate, type StoreInfo, type SyncJob, type UpdateAddressDto, type UpdateCartItemDto, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateInventoryDto, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateVariantDto, type UpdateVariantInventoryDto, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WebhookEvent, type WebhookEventType, createWebhookHandler, isCouponApplicableToProduct, isWebhookEventType, parseWebhookEvent, verifyWebhook };
|
|
2398
|
+
export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartItem, type CartStatus, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutLineItem, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateGuestOrderDto, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerProfile, type CustomerQueryParams, type DraftLineItem, type EditInventoryDto, type EmailVerificationResponse, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InventoryInfo, type InventorySyncStatus, type LocalCart, type LocalCartItem, type MergeCartsDto, type OmniSyncApiError, OmniSyncClient, type OmniSyncClientOptions, OmniSyncError, type Order, type OrderAddress, type OrderCustomer, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PlatformCouponCapabilities, type Product, type ProductAttributeInput, type ProductImage, type ProductQueryParams, type ProductSuggestion, type ProductVariant, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type SearchSuggestions, type SelectShippingMethodDto, type SendInvoiceDto, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingLine, type ShippingRate, type StoreInfo, type SyncJob, type UpdateAddressDto, type UpdateCartItemDto, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateInventoryDto, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateVariantDto, type UpdateVariantInventoryDto, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WebhookEvent, type WebhookEventType, createWebhookHandler, isCouponApplicableToProduct, isWebhookEventType, parseWebhookEvent, verifyWebhook };
|
package/dist/index.js
CHANGED
|
@@ -1095,6 +1095,85 @@ var OmniSyncClient = class {
|
|
|
1095
1095
|
email
|
|
1096
1096
|
});
|
|
1097
1097
|
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Verify customer email with a verification code
|
|
1100
|
+
* Only available in vibe-coded mode
|
|
1101
|
+
*
|
|
1102
|
+
* @param code - The 6-digit verification code from the email
|
|
1103
|
+
* @param token - Optional customer token. If not provided, uses the token set via setCustomerToken()
|
|
1104
|
+
*
|
|
1105
|
+
* @example
|
|
1106
|
+
* ```typescript
|
|
1107
|
+
* // Option 1: Pass token directly (recommended for verification flow)
|
|
1108
|
+
* const auth = await omni.registerCustomer({...});
|
|
1109
|
+
* if (auth.requiresVerification) {
|
|
1110
|
+
* const result = await omni.verifyEmail('123456', auth.token);
|
|
1111
|
+
* }
|
|
1112
|
+
*
|
|
1113
|
+
* // Option 2: Use setCustomerToken first
|
|
1114
|
+
* omni.setCustomerToken(auth.token);
|
|
1115
|
+
* const result = await omni.verifyEmail('123456');
|
|
1116
|
+
* ```
|
|
1117
|
+
*/
|
|
1118
|
+
async verifyEmail(code, token) {
|
|
1119
|
+
const effectiveToken = token || this.customerToken;
|
|
1120
|
+
if (!effectiveToken) {
|
|
1121
|
+
throw new OmniSyncError("Customer token is required. Pass token parameter or call setCustomerToken() first.", 401);
|
|
1122
|
+
}
|
|
1123
|
+
const originalToken = this.customerToken;
|
|
1124
|
+
if (token) {
|
|
1125
|
+
this.customerToken = token;
|
|
1126
|
+
}
|
|
1127
|
+
try {
|
|
1128
|
+
if (this.isVibeCodedMode()) {
|
|
1129
|
+
return await this.vibeCodedRequest("POST", "/customers/verify-email", {
|
|
1130
|
+
code
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
throw new OmniSyncError("verifyEmail is only available in vibe-coded mode", 400);
|
|
1134
|
+
} finally {
|
|
1135
|
+
if (token) {
|
|
1136
|
+
this.customerToken = originalToken;
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* Resend verification email
|
|
1142
|
+
* Only available in vibe-coded mode
|
|
1143
|
+
* Rate limited to 3 requests per hour
|
|
1144
|
+
*
|
|
1145
|
+
* @param token - Optional customer token. If not provided, uses the token set via setCustomerToken()
|
|
1146
|
+
*
|
|
1147
|
+
* @example
|
|
1148
|
+
* ```typescript
|
|
1149
|
+
* // Option 1: Pass token directly
|
|
1150
|
+
* await omni.resendVerificationEmail(auth.token);
|
|
1151
|
+
*
|
|
1152
|
+
* // Option 2: Use setCustomerToken first
|
|
1153
|
+
* omni.setCustomerToken(auth.token);
|
|
1154
|
+
* await omni.resendVerificationEmail();
|
|
1155
|
+
* ```
|
|
1156
|
+
*/
|
|
1157
|
+
async resendVerificationEmail(token) {
|
|
1158
|
+
const effectiveToken = token || this.customerToken;
|
|
1159
|
+
if (!effectiveToken) {
|
|
1160
|
+
throw new OmniSyncError("Customer token is required. Pass token parameter or call setCustomerToken() first.", 401);
|
|
1161
|
+
}
|
|
1162
|
+
const originalToken = this.customerToken;
|
|
1163
|
+
if (token) {
|
|
1164
|
+
this.customerToken = token;
|
|
1165
|
+
}
|
|
1166
|
+
try {
|
|
1167
|
+
if (this.isVibeCodedMode()) {
|
|
1168
|
+
return await this.vibeCodedRequest("POST", "/customers/resend-verification");
|
|
1169
|
+
}
|
|
1170
|
+
throw new OmniSyncError("resendVerificationEmail is only available in vibe-coded mode", 400);
|
|
1171
|
+
} finally {
|
|
1172
|
+
if (token) {
|
|
1173
|
+
this.customerToken = originalToken;
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1098
1177
|
/**
|
|
1099
1178
|
* Get the current logged-in customer's profile
|
|
1100
1179
|
* Requires a customer token to be set via setCustomerToken()
|
package/dist/index.mjs
CHANGED
|
@@ -1070,6 +1070,85 @@ var OmniSyncClient = class {
|
|
|
1070
1070
|
email
|
|
1071
1071
|
});
|
|
1072
1072
|
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Verify customer email with a verification code
|
|
1075
|
+
* Only available in vibe-coded mode
|
|
1076
|
+
*
|
|
1077
|
+
* @param code - The 6-digit verification code from the email
|
|
1078
|
+
* @param token - Optional customer token. If not provided, uses the token set via setCustomerToken()
|
|
1079
|
+
*
|
|
1080
|
+
* @example
|
|
1081
|
+
* ```typescript
|
|
1082
|
+
* // Option 1: Pass token directly (recommended for verification flow)
|
|
1083
|
+
* const auth = await omni.registerCustomer({...});
|
|
1084
|
+
* if (auth.requiresVerification) {
|
|
1085
|
+
* const result = await omni.verifyEmail('123456', auth.token);
|
|
1086
|
+
* }
|
|
1087
|
+
*
|
|
1088
|
+
* // Option 2: Use setCustomerToken first
|
|
1089
|
+
* omni.setCustomerToken(auth.token);
|
|
1090
|
+
* const result = await omni.verifyEmail('123456');
|
|
1091
|
+
* ```
|
|
1092
|
+
*/
|
|
1093
|
+
async verifyEmail(code, token) {
|
|
1094
|
+
const effectiveToken = token || this.customerToken;
|
|
1095
|
+
if (!effectiveToken) {
|
|
1096
|
+
throw new OmniSyncError("Customer token is required. Pass token parameter or call setCustomerToken() first.", 401);
|
|
1097
|
+
}
|
|
1098
|
+
const originalToken = this.customerToken;
|
|
1099
|
+
if (token) {
|
|
1100
|
+
this.customerToken = token;
|
|
1101
|
+
}
|
|
1102
|
+
try {
|
|
1103
|
+
if (this.isVibeCodedMode()) {
|
|
1104
|
+
return await this.vibeCodedRequest("POST", "/customers/verify-email", {
|
|
1105
|
+
code
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
throw new OmniSyncError("verifyEmail is only available in vibe-coded mode", 400);
|
|
1109
|
+
} finally {
|
|
1110
|
+
if (token) {
|
|
1111
|
+
this.customerToken = originalToken;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
* Resend verification email
|
|
1117
|
+
* Only available in vibe-coded mode
|
|
1118
|
+
* Rate limited to 3 requests per hour
|
|
1119
|
+
*
|
|
1120
|
+
* @param token - Optional customer token. If not provided, uses the token set via setCustomerToken()
|
|
1121
|
+
*
|
|
1122
|
+
* @example
|
|
1123
|
+
* ```typescript
|
|
1124
|
+
* // Option 1: Pass token directly
|
|
1125
|
+
* await omni.resendVerificationEmail(auth.token);
|
|
1126
|
+
*
|
|
1127
|
+
* // Option 2: Use setCustomerToken first
|
|
1128
|
+
* omni.setCustomerToken(auth.token);
|
|
1129
|
+
* await omni.resendVerificationEmail();
|
|
1130
|
+
* ```
|
|
1131
|
+
*/
|
|
1132
|
+
async resendVerificationEmail(token) {
|
|
1133
|
+
const effectiveToken = token || this.customerToken;
|
|
1134
|
+
if (!effectiveToken) {
|
|
1135
|
+
throw new OmniSyncError("Customer token is required. Pass token parameter or call setCustomerToken() first.", 401);
|
|
1136
|
+
}
|
|
1137
|
+
const originalToken = this.customerToken;
|
|
1138
|
+
if (token) {
|
|
1139
|
+
this.customerToken = token;
|
|
1140
|
+
}
|
|
1141
|
+
try {
|
|
1142
|
+
if (this.isVibeCodedMode()) {
|
|
1143
|
+
return await this.vibeCodedRequest("POST", "/customers/resend-verification");
|
|
1144
|
+
}
|
|
1145
|
+
throw new OmniSyncError("resendVerificationEmail is only available in vibe-coded mode", 400);
|
|
1146
|
+
} finally {
|
|
1147
|
+
if (token) {
|
|
1148
|
+
this.customerToken = originalToken;
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1073
1152
|
/**
|
|
1074
1153
|
* Get the current logged-in customer's profile
|
|
1075
1154
|
* Requires a customer token to be set via setCustomerToken()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omni-sync-sdk",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.9",
|
|
4
4
|
"description": "Official SDK for building e-commerce storefronts with OmniSync Platform. Perfect for vibe-coded sites, AI-built stores (Cursor, Lovable, v0), and custom storefronts.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|