brainerce 1.3.3 → 1.4.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/AI_BUILDER_PROMPT.md +12 -0
- package/README.md +17 -0
- package/dist/index.d.mts +44 -17
- package/dist/index.d.ts +44 -17
- package/dist/index.js +38 -11
- package/dist/index.mjs +38 -11
- package/package.json +1 -1
package/AI_BUILDER_PROMPT.md
CHANGED
|
@@ -675,6 +675,15 @@ if (result.verified) {
|
|
|
675
675
|
// Resend verification code
|
|
676
676
|
await client.resendVerificationEmail(token);
|
|
677
677
|
|
|
678
|
+
// Forgot password (on /forgot-password page)
|
|
679
|
+
await client.forgotPassword(email);
|
|
680
|
+
// Always succeeds (prevents email enumeration)
|
|
681
|
+
|
|
682
|
+
// Reset password (on /reset-password page — user arrives via email link)
|
|
683
|
+
const token = new URLSearchParams(window.location.search).get('token');
|
|
684
|
+
await client.resetPassword(token!, newPassword);
|
|
685
|
+
// On success: redirect to /login
|
|
686
|
+
|
|
678
687
|
// Logout
|
|
679
688
|
client.setCustomerToken(null);
|
|
680
689
|
localStorage.removeItem('customerToken');
|
|
@@ -725,6 +734,8 @@ if (params.get('oauth_success') === 'true') {
|
|
|
725
734
|
- [ ] **Login** (`/login`) - Email/password + social buttons, handle `requiresVerification`
|
|
726
735
|
- [ ] **Register** (`/register`) - Registration form, handle `requiresVerification`
|
|
727
736
|
- [ ] **Verify Email** (`/verify-email`) - 6-digit code input + resend button. **ALWAYS create this page** even if verification is currently disabled — the store owner can enable it at any time
|
|
737
|
+
- [ ] **Forgot Password** (`/forgot-password`) - Email input, shows success message
|
|
738
|
+
- [ ] **Reset Password** (`/reset-password`) - Token from URL + new password form
|
|
728
739
|
- [ ] **OAuth Callback** (`/auth/callback`) - Handle OAuth redirect with token from URL params
|
|
729
740
|
- [ ] **Account** (`/account`) - Profile + order history
|
|
730
741
|
- [ ] **Header** - Logo, nav, cart icon with count, search
|
|
@@ -735,6 +746,7 @@ Some features may not be configured yet, but the store owner can enable them at
|
|
|
735
746
|
|
|
736
747
|
- **Email Verification** → `/verify-email` page. `requiresVerification` is checked in login/register flows.
|
|
737
748
|
- **OAuth Buttons** → Social login buttons on Login & Register + `/auth/callback` page. `getAvailableOAuthProviders()` returns `[]` when none configured — buttons just don't render.
|
|
749
|
+
- **Password Reset** → `/forgot-password` + `/reset-password` pages. `forgotPassword()` silently succeeds when no account exists.
|
|
738
750
|
- **Discount Banners** → `getDiscountBanners()` returns `[]` when no rules — component renders nothing.
|
|
739
751
|
- **Product Discount Badges** → `getProductDiscountBadge(id)` returns `null` — renders nothing.
|
|
740
752
|
- **Cart Nudges** → `cart.nudges` is `[]` — renders nothing.
|
package/README.md
CHANGED
|
@@ -2037,6 +2037,23 @@ window.location.href = returnUrl;
|
|
|
2037
2037
|
|
|
2038
2038
|
> **Best Practice:** Before showing login page, save the current URL with `localStorage.setItem('returnUrl', window.location.pathname)`. After login, redirect back to that URL. This is how Amazon, Shopify, and most e-commerce sites work.
|
|
2039
2039
|
|
|
2040
|
+
#### Forgot Password
|
|
2041
|
+
|
|
2042
|
+
```typescript
|
|
2043
|
+
await client.forgotPassword('customer@example.com');
|
|
2044
|
+
// Always returns success message (prevents email enumeration)
|
|
2045
|
+
// If account exists, sends email with reset link
|
|
2046
|
+
```
|
|
2047
|
+
|
|
2048
|
+
#### Reset Password
|
|
2049
|
+
|
|
2050
|
+
```typescript
|
|
2051
|
+
// On /reset-password page, extract token from URL
|
|
2052
|
+
const token = new URLSearchParams(window.location.search).get('token');
|
|
2053
|
+
const result = await client.resetPassword(token!, 'newSecurePassword123');
|
|
2054
|
+
// result.message = "Password has been reset successfully"
|
|
2055
|
+
```
|
|
2056
|
+
|
|
2040
2057
|
#### Logout Customer
|
|
2041
2058
|
|
|
2042
2059
|
```typescript
|
package/dist/index.d.mts
CHANGED
|
@@ -176,12 +176,6 @@ interface Product {
|
|
|
176
176
|
attributes?: string[];
|
|
177
177
|
metafields?: ProductMetafield[];
|
|
178
178
|
channels?: Record<string, Record<string, unknown>>;
|
|
179
|
-
/** Shopify product ID (admin mode only) */
|
|
180
|
-
shopifyProductId?: string | null;
|
|
181
|
-
/** WooCommerce product ID (admin mode only) */
|
|
182
|
-
woocommerceProductId?: string | null;
|
|
183
|
-
/** Meta/Facebook Item Group ID (admin mode only) */
|
|
184
|
-
metaItemGroupId?: string | null;
|
|
185
179
|
/** Whether product needs sync to platforms. Always returned by backend. */
|
|
186
180
|
needsSync: boolean;
|
|
187
181
|
/** Last sync timestamp (admin mode only) */
|
|
@@ -761,6 +755,27 @@ interface Order {
|
|
|
761
755
|
platform?: string;
|
|
762
756
|
/** Whether this order contains downloadable products */
|
|
763
757
|
hasDownloads?: boolean;
|
|
758
|
+
/** Subtotal before discounts/shipping/tax */
|
|
759
|
+
subtotal?: string | null;
|
|
760
|
+
/** Total discount amount */
|
|
761
|
+
discountAmount?: string | null;
|
|
762
|
+
/** Applied coupon code */
|
|
763
|
+
couponCode?: string | null;
|
|
764
|
+
/** Coupon discount amount */
|
|
765
|
+
couponDiscount?: string | null;
|
|
766
|
+
/** Total discount from rules */
|
|
767
|
+
ruleDiscountAmount?: string | null;
|
|
768
|
+
/** Per-rule discount snapshots */
|
|
769
|
+
appliedDiscounts?: Array<{
|
|
770
|
+
ruleId: string;
|
|
771
|
+
ruleName: string;
|
|
772
|
+
type: string;
|
|
773
|
+
discountAmount: string | null;
|
|
774
|
+
}> | null;
|
|
775
|
+
/** Shipping cost */
|
|
776
|
+
shippingAmount?: string | null;
|
|
777
|
+
/** Tax amount */
|
|
778
|
+
taxAmount?: string | null;
|
|
764
779
|
createdAt: string;
|
|
765
780
|
}
|
|
766
781
|
/**
|
|
@@ -882,7 +897,7 @@ interface SyncJob {
|
|
|
882
897
|
platform?: string;
|
|
883
898
|
message?: string;
|
|
884
899
|
}
|
|
885
|
-
type ConnectorPlatform =
|
|
900
|
+
type ConnectorPlatform = string;
|
|
886
901
|
/**
|
|
887
902
|
* Reference to an entity with ID and name.
|
|
888
903
|
* Used for products, categories, and other related entities.
|
|
@@ -925,9 +940,6 @@ interface Coupon {
|
|
|
925
940
|
lastSyncedAt?: string | null;
|
|
926
941
|
/** Per-platform channel overrides */
|
|
927
942
|
channels?: Record<string, Record<string, unknown>> | null;
|
|
928
|
-
shopifyCouponId?: string | null;
|
|
929
|
-
woocommerceCouponId?: string | null;
|
|
930
|
-
tiktokCouponId?: string | null;
|
|
931
943
|
createdAt: string;
|
|
932
944
|
updatedAt: string;
|
|
933
945
|
}
|
|
@@ -1839,8 +1851,8 @@ interface SelectPickupLocationDto {
|
|
|
1839
1851
|
* 2. Select shipping method: `selectShippingMethod(id, rateId)`
|
|
1840
1852
|
* 3. Pay with Stripe: `createPaymentIntent(id)` → `stripe.confirmPayment()` → Order created automatically!
|
|
1841
1853
|
*
|
|
1842
|
-
* **Note:**
|
|
1843
|
-
*
|
|
1854
|
+
* **Note:** Always call `completeGuestCheckout()` on the success page.
|
|
1855
|
+
* It is idempotent — if the payment webhook already created the order, it returns the existing order.
|
|
1844
1856
|
*
|
|
1845
1857
|
* **IMPORTANT: Order Summary Display**
|
|
1846
1858
|
* Always use `checkout.lineItems` for displaying the Order Summary during checkout!
|
|
@@ -1906,6 +1918,8 @@ interface Checkout {
|
|
|
1906
1918
|
subtotal: string;
|
|
1907
1919
|
/** Discount amount as string - use parseFloat() */
|
|
1908
1920
|
discountAmount: string;
|
|
1921
|
+
/** Discount amount from automatic rules as string - use parseFloat() */
|
|
1922
|
+
ruleDiscountAmount?: string;
|
|
1909
1923
|
/** Shipping cost as string - use parseFloat() */
|
|
1910
1924
|
shippingAmount: string;
|
|
1911
1925
|
/** Tax amount as string - use parseFloat() */
|
|
@@ -4215,6 +4229,13 @@ declare class BrainerceClient {
|
|
|
4215
4229
|
forgotPassword(email: string): Promise<{
|
|
4216
4230
|
message: string;
|
|
4217
4231
|
}>;
|
|
4232
|
+
/**
|
|
4233
|
+
* Reset customer password using a reset token received via email
|
|
4234
|
+
* Works in vibe-coded, storefront, and admin mode
|
|
4235
|
+
*/
|
|
4236
|
+
resetPassword(token: string, newPassword: string): Promise<{
|
|
4237
|
+
message: string;
|
|
4238
|
+
}>;
|
|
4218
4239
|
/**
|
|
4219
4240
|
* Verify customer email with a verification code
|
|
4220
4241
|
* Only available in vibe-coded mode
|
|
@@ -5164,16 +5185,22 @@ declare class BrainerceClient {
|
|
|
5164
5185
|
*/
|
|
5165
5186
|
getPaymentStatus(checkoutId: string): Promise<PaymentStatus>;
|
|
5166
5187
|
/**
|
|
5167
|
-
* Confirm a
|
|
5168
|
-
* Call this in the
|
|
5169
|
-
* that payment succeeded, triggering order creation.
|
|
5188
|
+
* Confirm a client-side SDK payment from the frontend.
|
|
5189
|
+
* Call this in the payment SDK's success callback (e.g., Grow onSuccess) to notify the
|
|
5190
|
+
* backend that payment succeeded, triggering order creation.
|
|
5170
5191
|
*
|
|
5171
5192
|
* **Vibe-coded mode only** - requires connectionId
|
|
5172
5193
|
*
|
|
5173
5194
|
* @param checkoutId - The checkout ID
|
|
5174
|
-
* @param
|
|
5195
|
+
* @param providerResponseData - Optional payment provider SDK callback data (transactionId, transactionToken, confirmation_number, etc.)
|
|
5196
|
+
*/
|
|
5197
|
+
confirmSdkPayment(checkoutId: string, providerResponseData?: Record<string, unknown>): Promise<{
|
|
5198
|
+
confirmed: boolean;
|
|
5199
|
+
}>;
|
|
5200
|
+
/**
|
|
5201
|
+
* @deprecated Use `confirmSdkPayment` instead. This method will be removed in a future version.
|
|
5175
5202
|
*/
|
|
5176
|
-
confirmGrowPayment(checkoutId: string, confirmationNumber?: string): Promise<{
|
|
5203
|
+
confirmGrowPayment(checkoutId: string, confirmationNumber?: string, growResponseData?: Record<string, unknown>): Promise<{
|
|
5177
5204
|
confirmed: boolean;
|
|
5178
5205
|
}>;
|
|
5179
5206
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -176,12 +176,6 @@ interface Product {
|
|
|
176
176
|
attributes?: string[];
|
|
177
177
|
metafields?: ProductMetafield[];
|
|
178
178
|
channels?: Record<string, Record<string, unknown>>;
|
|
179
|
-
/** Shopify product ID (admin mode only) */
|
|
180
|
-
shopifyProductId?: string | null;
|
|
181
|
-
/** WooCommerce product ID (admin mode only) */
|
|
182
|
-
woocommerceProductId?: string | null;
|
|
183
|
-
/** Meta/Facebook Item Group ID (admin mode only) */
|
|
184
|
-
metaItemGroupId?: string | null;
|
|
185
179
|
/** Whether product needs sync to platforms. Always returned by backend. */
|
|
186
180
|
needsSync: boolean;
|
|
187
181
|
/** Last sync timestamp (admin mode only) */
|
|
@@ -761,6 +755,27 @@ interface Order {
|
|
|
761
755
|
platform?: string;
|
|
762
756
|
/** Whether this order contains downloadable products */
|
|
763
757
|
hasDownloads?: boolean;
|
|
758
|
+
/** Subtotal before discounts/shipping/tax */
|
|
759
|
+
subtotal?: string | null;
|
|
760
|
+
/** Total discount amount */
|
|
761
|
+
discountAmount?: string | null;
|
|
762
|
+
/** Applied coupon code */
|
|
763
|
+
couponCode?: string | null;
|
|
764
|
+
/** Coupon discount amount */
|
|
765
|
+
couponDiscount?: string | null;
|
|
766
|
+
/** Total discount from rules */
|
|
767
|
+
ruleDiscountAmount?: string | null;
|
|
768
|
+
/** Per-rule discount snapshots */
|
|
769
|
+
appliedDiscounts?: Array<{
|
|
770
|
+
ruleId: string;
|
|
771
|
+
ruleName: string;
|
|
772
|
+
type: string;
|
|
773
|
+
discountAmount: string | null;
|
|
774
|
+
}> | null;
|
|
775
|
+
/** Shipping cost */
|
|
776
|
+
shippingAmount?: string | null;
|
|
777
|
+
/** Tax amount */
|
|
778
|
+
taxAmount?: string | null;
|
|
764
779
|
createdAt: string;
|
|
765
780
|
}
|
|
766
781
|
/**
|
|
@@ -882,7 +897,7 @@ interface SyncJob {
|
|
|
882
897
|
platform?: string;
|
|
883
898
|
message?: string;
|
|
884
899
|
}
|
|
885
|
-
type ConnectorPlatform =
|
|
900
|
+
type ConnectorPlatform = string;
|
|
886
901
|
/**
|
|
887
902
|
* Reference to an entity with ID and name.
|
|
888
903
|
* Used for products, categories, and other related entities.
|
|
@@ -925,9 +940,6 @@ interface Coupon {
|
|
|
925
940
|
lastSyncedAt?: string | null;
|
|
926
941
|
/** Per-platform channel overrides */
|
|
927
942
|
channels?: Record<string, Record<string, unknown>> | null;
|
|
928
|
-
shopifyCouponId?: string | null;
|
|
929
|
-
woocommerceCouponId?: string | null;
|
|
930
|
-
tiktokCouponId?: string | null;
|
|
931
943
|
createdAt: string;
|
|
932
944
|
updatedAt: string;
|
|
933
945
|
}
|
|
@@ -1839,8 +1851,8 @@ interface SelectPickupLocationDto {
|
|
|
1839
1851
|
* 2. Select shipping method: `selectShippingMethod(id, rateId)`
|
|
1840
1852
|
* 3. Pay with Stripe: `createPaymentIntent(id)` → `stripe.confirmPayment()` → Order created automatically!
|
|
1841
1853
|
*
|
|
1842
|
-
* **Note:**
|
|
1843
|
-
*
|
|
1854
|
+
* **Note:** Always call `completeGuestCheckout()` on the success page.
|
|
1855
|
+
* It is idempotent — if the payment webhook already created the order, it returns the existing order.
|
|
1844
1856
|
*
|
|
1845
1857
|
* **IMPORTANT: Order Summary Display**
|
|
1846
1858
|
* Always use `checkout.lineItems` for displaying the Order Summary during checkout!
|
|
@@ -1906,6 +1918,8 @@ interface Checkout {
|
|
|
1906
1918
|
subtotal: string;
|
|
1907
1919
|
/** Discount amount as string - use parseFloat() */
|
|
1908
1920
|
discountAmount: string;
|
|
1921
|
+
/** Discount amount from automatic rules as string - use parseFloat() */
|
|
1922
|
+
ruleDiscountAmount?: string;
|
|
1909
1923
|
/** Shipping cost as string - use parseFloat() */
|
|
1910
1924
|
shippingAmount: string;
|
|
1911
1925
|
/** Tax amount as string - use parseFloat() */
|
|
@@ -4215,6 +4229,13 @@ declare class BrainerceClient {
|
|
|
4215
4229
|
forgotPassword(email: string): Promise<{
|
|
4216
4230
|
message: string;
|
|
4217
4231
|
}>;
|
|
4232
|
+
/**
|
|
4233
|
+
* Reset customer password using a reset token received via email
|
|
4234
|
+
* Works in vibe-coded, storefront, and admin mode
|
|
4235
|
+
*/
|
|
4236
|
+
resetPassword(token: string, newPassword: string): Promise<{
|
|
4237
|
+
message: string;
|
|
4238
|
+
}>;
|
|
4218
4239
|
/**
|
|
4219
4240
|
* Verify customer email with a verification code
|
|
4220
4241
|
* Only available in vibe-coded mode
|
|
@@ -5164,16 +5185,22 @@ declare class BrainerceClient {
|
|
|
5164
5185
|
*/
|
|
5165
5186
|
getPaymentStatus(checkoutId: string): Promise<PaymentStatus>;
|
|
5166
5187
|
/**
|
|
5167
|
-
* Confirm a
|
|
5168
|
-
* Call this in the
|
|
5169
|
-
* that payment succeeded, triggering order creation.
|
|
5188
|
+
* Confirm a client-side SDK payment from the frontend.
|
|
5189
|
+
* Call this in the payment SDK's success callback (e.g., Grow onSuccess) to notify the
|
|
5190
|
+
* backend that payment succeeded, triggering order creation.
|
|
5170
5191
|
*
|
|
5171
5192
|
* **Vibe-coded mode only** - requires connectionId
|
|
5172
5193
|
*
|
|
5173
5194
|
* @param checkoutId - The checkout ID
|
|
5174
|
-
* @param
|
|
5195
|
+
* @param providerResponseData - Optional payment provider SDK callback data (transactionId, transactionToken, confirmation_number, etc.)
|
|
5196
|
+
*/
|
|
5197
|
+
confirmSdkPayment(checkoutId: string, providerResponseData?: Record<string, unknown>): Promise<{
|
|
5198
|
+
confirmed: boolean;
|
|
5199
|
+
}>;
|
|
5200
|
+
/**
|
|
5201
|
+
* @deprecated Use `confirmSdkPayment` instead. This method will be removed in a future version.
|
|
5175
5202
|
*/
|
|
5176
|
-
confirmGrowPayment(checkoutId: string, confirmationNumber?: string): Promise<{
|
|
5203
|
+
confirmGrowPayment(checkoutId: string, confirmationNumber?: string, growResponseData?: Record<string, unknown>): Promise<{
|
|
5177
5204
|
confirmed: boolean;
|
|
5178
5205
|
}>;
|
|
5179
5206
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1487,20 +1487,38 @@ var BrainerceClient = class {
|
|
|
1487
1487
|
* Works in vibe-coded, storefront, and admin mode
|
|
1488
1488
|
*/
|
|
1489
1489
|
async forgotPassword(email) {
|
|
1490
|
+
const resetUrl = typeof window !== "undefined" ? `${window.location.origin}/reset-password` : void 0;
|
|
1490
1491
|
if (this.isVibeCodedMode()) {
|
|
1491
1492
|
return this.vibeCodedRequest("POST", "/customers/forgot-password", {
|
|
1492
|
-
email
|
|
1493
|
+
email,
|
|
1494
|
+
resetUrl
|
|
1493
1495
|
});
|
|
1494
1496
|
}
|
|
1495
1497
|
if (this.storeId && !this.apiKey) {
|
|
1496
1498
|
return this.storefrontRequest("POST", "/customers/forgot-password", {
|
|
1497
|
-
email
|
|
1499
|
+
email,
|
|
1500
|
+
resetUrl
|
|
1498
1501
|
});
|
|
1499
1502
|
}
|
|
1500
1503
|
return this.adminRequest("POST", "/api/v1/customers/forgot-password", {
|
|
1501
|
-
email
|
|
1504
|
+
email,
|
|
1505
|
+
resetUrl
|
|
1502
1506
|
});
|
|
1503
1507
|
}
|
|
1508
|
+
/**
|
|
1509
|
+
* Reset customer password using a reset token received via email
|
|
1510
|
+
* Works in vibe-coded, storefront, and admin mode
|
|
1511
|
+
*/
|
|
1512
|
+
async resetPassword(token, newPassword) {
|
|
1513
|
+
const body = { token, newPassword };
|
|
1514
|
+
if (this.isVibeCodedMode()) {
|
|
1515
|
+
return this.vibeCodedRequest("POST", "/customers/reset-password", body);
|
|
1516
|
+
}
|
|
1517
|
+
if (this.storeId && !this.apiKey) {
|
|
1518
|
+
return this.storefrontRequest("POST", "/customers/reset-password", body);
|
|
1519
|
+
}
|
|
1520
|
+
return this.adminRequest("POST", "/api/v1/customers/reset-password", body);
|
|
1521
|
+
}
|
|
1504
1522
|
/**
|
|
1505
1523
|
* Verify customer email with a verification code
|
|
1506
1524
|
* Only available in vibe-coded mode
|
|
@@ -3431,25 +3449,34 @@ var BrainerceClient = class {
|
|
|
3431
3449
|
return this.vibeCodedRequest("GET", `/checkout/${checkoutId}/payment-status`);
|
|
3432
3450
|
}
|
|
3433
3451
|
/**
|
|
3434
|
-
* Confirm a
|
|
3435
|
-
* Call this in the
|
|
3436
|
-
* that payment succeeded, triggering order creation.
|
|
3452
|
+
* Confirm a client-side SDK payment from the frontend.
|
|
3453
|
+
* Call this in the payment SDK's success callback (e.g., Grow onSuccess) to notify the
|
|
3454
|
+
* backend that payment succeeded, triggering order creation.
|
|
3437
3455
|
*
|
|
3438
3456
|
* **Vibe-coded mode only** - requires connectionId
|
|
3439
3457
|
*
|
|
3440
3458
|
* @param checkoutId - The checkout ID
|
|
3441
|
-
* @param
|
|
3459
|
+
* @param providerResponseData - Optional payment provider SDK callback data (transactionId, transactionToken, confirmation_number, etc.)
|
|
3442
3460
|
*/
|
|
3443
|
-
async
|
|
3461
|
+
async confirmSdkPayment(checkoutId, providerResponseData) {
|
|
3444
3462
|
if (!this.isVibeCodedMode()) {
|
|
3445
3463
|
throw new BrainerceError(
|
|
3446
|
-
"
|
|
3464
|
+
"confirmSdkPayment is only available in vibe-coded mode (use connectionId)",
|
|
3447
3465
|
400
|
|
3448
3466
|
);
|
|
3449
3467
|
}
|
|
3450
|
-
return this.vibeCodedRequest("POST", "/payment/
|
|
3468
|
+
return this.vibeCodedRequest("POST", "/payment/sdk-confirm", {
|
|
3451
3469
|
checkoutId,
|
|
3452
|
-
|
|
3470
|
+
providerResponseData
|
|
3471
|
+
});
|
|
3472
|
+
}
|
|
3473
|
+
/**
|
|
3474
|
+
* @deprecated Use `confirmSdkPayment` instead. This method will be removed in a future version.
|
|
3475
|
+
*/
|
|
3476
|
+
async confirmGrowPayment(checkoutId, confirmationNumber, growResponseData) {
|
|
3477
|
+
return this.confirmSdkPayment(checkoutId, {
|
|
3478
|
+
confirmation_number: confirmationNumber,
|
|
3479
|
+
...growResponseData || {}
|
|
3453
3480
|
});
|
|
3454
3481
|
}
|
|
3455
3482
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1429,20 +1429,38 @@ var BrainerceClient = class {
|
|
|
1429
1429
|
* Works in vibe-coded, storefront, and admin mode
|
|
1430
1430
|
*/
|
|
1431
1431
|
async forgotPassword(email) {
|
|
1432
|
+
const resetUrl = typeof window !== "undefined" ? `${window.location.origin}/reset-password` : void 0;
|
|
1432
1433
|
if (this.isVibeCodedMode()) {
|
|
1433
1434
|
return this.vibeCodedRequest("POST", "/customers/forgot-password", {
|
|
1434
|
-
email
|
|
1435
|
+
email,
|
|
1436
|
+
resetUrl
|
|
1435
1437
|
});
|
|
1436
1438
|
}
|
|
1437
1439
|
if (this.storeId && !this.apiKey) {
|
|
1438
1440
|
return this.storefrontRequest("POST", "/customers/forgot-password", {
|
|
1439
|
-
email
|
|
1441
|
+
email,
|
|
1442
|
+
resetUrl
|
|
1440
1443
|
});
|
|
1441
1444
|
}
|
|
1442
1445
|
return this.adminRequest("POST", "/api/v1/customers/forgot-password", {
|
|
1443
|
-
email
|
|
1446
|
+
email,
|
|
1447
|
+
resetUrl
|
|
1444
1448
|
});
|
|
1445
1449
|
}
|
|
1450
|
+
/**
|
|
1451
|
+
* Reset customer password using a reset token received via email
|
|
1452
|
+
* Works in vibe-coded, storefront, and admin mode
|
|
1453
|
+
*/
|
|
1454
|
+
async resetPassword(token, newPassword) {
|
|
1455
|
+
const body = { token, newPassword };
|
|
1456
|
+
if (this.isVibeCodedMode()) {
|
|
1457
|
+
return this.vibeCodedRequest("POST", "/customers/reset-password", body);
|
|
1458
|
+
}
|
|
1459
|
+
if (this.storeId && !this.apiKey) {
|
|
1460
|
+
return this.storefrontRequest("POST", "/customers/reset-password", body);
|
|
1461
|
+
}
|
|
1462
|
+
return this.adminRequest("POST", "/api/v1/customers/reset-password", body);
|
|
1463
|
+
}
|
|
1446
1464
|
/**
|
|
1447
1465
|
* Verify customer email with a verification code
|
|
1448
1466
|
* Only available in vibe-coded mode
|
|
@@ -3373,25 +3391,34 @@ var BrainerceClient = class {
|
|
|
3373
3391
|
return this.vibeCodedRequest("GET", `/checkout/${checkoutId}/payment-status`);
|
|
3374
3392
|
}
|
|
3375
3393
|
/**
|
|
3376
|
-
* Confirm a
|
|
3377
|
-
* Call this in the
|
|
3378
|
-
* that payment succeeded, triggering order creation.
|
|
3394
|
+
* Confirm a client-side SDK payment from the frontend.
|
|
3395
|
+
* Call this in the payment SDK's success callback (e.g., Grow onSuccess) to notify the
|
|
3396
|
+
* backend that payment succeeded, triggering order creation.
|
|
3379
3397
|
*
|
|
3380
3398
|
* **Vibe-coded mode only** - requires connectionId
|
|
3381
3399
|
*
|
|
3382
3400
|
* @param checkoutId - The checkout ID
|
|
3383
|
-
* @param
|
|
3401
|
+
* @param providerResponseData - Optional payment provider SDK callback data (transactionId, transactionToken, confirmation_number, etc.)
|
|
3384
3402
|
*/
|
|
3385
|
-
async
|
|
3403
|
+
async confirmSdkPayment(checkoutId, providerResponseData) {
|
|
3386
3404
|
if (!this.isVibeCodedMode()) {
|
|
3387
3405
|
throw new BrainerceError(
|
|
3388
|
-
"
|
|
3406
|
+
"confirmSdkPayment is only available in vibe-coded mode (use connectionId)",
|
|
3389
3407
|
400
|
|
3390
3408
|
);
|
|
3391
3409
|
}
|
|
3392
|
-
return this.vibeCodedRequest("POST", "/payment/
|
|
3410
|
+
return this.vibeCodedRequest("POST", "/payment/sdk-confirm", {
|
|
3393
3411
|
checkoutId,
|
|
3394
|
-
|
|
3412
|
+
providerResponseData
|
|
3413
|
+
});
|
|
3414
|
+
}
|
|
3415
|
+
/**
|
|
3416
|
+
* @deprecated Use `confirmSdkPayment` instead. This method will be removed in a future version.
|
|
3417
|
+
*/
|
|
3418
|
+
async confirmGrowPayment(checkoutId, confirmationNumber, growResponseData) {
|
|
3419
|
+
return this.confirmSdkPayment(checkoutId, {
|
|
3420
|
+
confirmation_number: confirmationNumber,
|
|
3421
|
+
...growResponseData || {}
|
|
3395
3422
|
});
|
|
3396
3423
|
}
|
|
3397
3424
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brainerce",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Official SDK for building e-commerce storefronts with Brainerce 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",
|