brainerce 1.10.1 → 1.10.3

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 CHANGED
@@ -5685,18 +5685,21 @@ declare class BrainerceClient {
5685
5685
  limit?: number;
5686
5686
  }): Promise<PaginatedResponse<Order>>;
5687
5687
  /**
5688
- * Get download links for a purchased order (requires customerToken)
5689
- * Works in vibe-coded and storefront modes
5688
+ * Get download links for a purchased order.
5689
+ * Auth: customerToken/proxyMode (logged-in) OR checkoutId (guest after payment).
5690
5690
  *
5691
5691
  * @example
5692
5692
  * ```typescript
5693
+ * // Logged-in customer
5693
5694
  * const links = await client.getOrderDownloads('order_123');
5694
- * for (const link of links) {
5695
- * console.log(`${link.productName}: ${link.downloadUrl}`);
5696
- * }
5695
+ *
5696
+ * // Guest (right after checkout)
5697
+ * const links = await client.getOrderDownloads('order_123', { checkoutId: 'ckxxx' });
5697
5698
  * ```
5698
5699
  */
5699
- getOrderDownloads(orderId: string): Promise<OrderDownloadLink[]>;
5700
+ getOrderDownloads(orderId: string, options?: {
5701
+ checkoutId?: string;
5702
+ }): Promise<OrderDownloadLink[]>;
5700
5703
  /**
5701
5704
  * Get download links for a guest order (no login required)
5702
5705
  * Validates identity via email + order number
package/dist/index.d.ts CHANGED
@@ -5685,18 +5685,21 @@ declare class BrainerceClient {
5685
5685
  limit?: number;
5686
5686
  }): Promise<PaginatedResponse<Order>>;
5687
5687
  /**
5688
- * Get download links for a purchased order (requires customerToken)
5689
- * Works in vibe-coded and storefront modes
5688
+ * Get download links for a purchased order.
5689
+ * Auth: customerToken/proxyMode (logged-in) OR checkoutId (guest after payment).
5690
5690
  *
5691
5691
  * @example
5692
5692
  * ```typescript
5693
+ * // Logged-in customer
5693
5694
  * const links = await client.getOrderDownloads('order_123');
5694
- * for (const link of links) {
5695
- * console.log(`${link.productName}: ${link.downloadUrl}`);
5696
- * }
5695
+ *
5696
+ * // Guest (right after checkout)
5697
+ * const links = await client.getOrderDownloads('order_123', { checkoutId: 'ckxxx' });
5697
5698
  * ```
5698
5699
  */
5699
- getOrderDownloads(orderId: string): Promise<OrderDownloadLink[]>;
5700
+ getOrderDownloads(orderId: string, options?: {
5701
+ checkoutId?: string;
5702
+ }): Promise<OrderDownloadLink[]>;
5700
5703
  /**
5701
5704
  * Get download links for a guest order (no login required)
5702
5705
  * Validates identity via email + order number
package/dist/index.js CHANGED
@@ -2415,7 +2415,13 @@ var BrainerceClient = class {
2415
2415
  * ```
2416
2416
  */
2417
2417
  isCustomerLoggedIn() {
2418
- return this.proxyMode || !!this.customerToken;
2418
+ if (this.proxyMode) {
2419
+ if (typeof document !== "undefined") {
2420
+ return document.cookie.includes("brainerce_logged_in=1");
2421
+ }
2422
+ return false;
2423
+ }
2424
+ return !!this.customerToken;
2419
2425
  }
2420
2426
  // -------------------- Session Cart Helpers --------------------
2421
2427
  /**
@@ -4436,34 +4442,35 @@ var BrainerceClient = class {
4436
4442
  throw new BrainerceError("getMyOrders is only available in vibe-coded or storefront mode", 400);
4437
4443
  }
4438
4444
  /**
4439
- * Get download links for a purchased order (requires customerToken)
4440
- * Works in vibe-coded and storefront modes
4445
+ * Get download links for a purchased order.
4446
+ * Auth: customerToken/proxyMode (logged-in) OR checkoutId (guest after payment).
4441
4447
  *
4442
4448
  * @example
4443
4449
  * ```typescript
4450
+ * // Logged-in customer
4444
4451
  * const links = await client.getOrderDownloads('order_123');
4445
- * for (const link of links) {
4446
- * console.log(`${link.productName}: ${link.downloadUrl}`);
4447
- * }
4452
+ *
4453
+ * // Guest (right after checkout)
4454
+ * const links = await client.getOrderDownloads('order_123', { checkoutId: 'ckxxx' });
4448
4455
  * ```
4449
4456
  */
4450
- async getOrderDownloads(orderId) {
4451
- if (!this.customerToken && !this.proxyMode) {
4452
- throw new BrainerceError(
4453
- "Customer token required. Call setCustomerToken() after login.",
4454
- 401
4455
- );
4457
+ async getOrderDownloads(orderId, options) {
4458
+ const hasAuth = this.customerToken || this.proxyMode;
4459
+ const checkoutId = options?.checkoutId;
4460
+ if (!hasAuth && !checkoutId) {
4461
+ throw new BrainerceError("Customer token or checkoutId required for download access.", 401);
4456
4462
  }
4463
+ const qs = checkoutId ? `?checkout_id=${encodeURIComponent(checkoutId)}` : "";
4457
4464
  if (this.isVibeCodedMode()) {
4458
4465
  return this.vibeCodedRequest(
4459
4466
  "GET",
4460
- `/customers/me/orders/${orderId}/downloads`
4467
+ `/customers/me/orders/${orderId}/downloads${qs}`
4461
4468
  );
4462
4469
  }
4463
4470
  if (this.storeId && !this.apiKey) {
4464
4471
  return this.storefrontRequest(
4465
4472
  "GET",
4466
- `/customers/me/orders/${orderId}/downloads`
4473
+ `/customers/me/orders/${orderId}/downloads${qs}`
4467
4474
  );
4468
4475
  }
4469
4476
  throw new BrainerceError(
package/dist/index.mjs CHANGED
@@ -2357,7 +2357,13 @@ var BrainerceClient = class {
2357
2357
  * ```
2358
2358
  */
2359
2359
  isCustomerLoggedIn() {
2360
- return this.proxyMode || !!this.customerToken;
2360
+ if (this.proxyMode) {
2361
+ if (typeof document !== "undefined") {
2362
+ return document.cookie.includes("brainerce_logged_in=1");
2363
+ }
2364
+ return false;
2365
+ }
2366
+ return !!this.customerToken;
2361
2367
  }
2362
2368
  // -------------------- Session Cart Helpers --------------------
2363
2369
  /**
@@ -4378,34 +4384,35 @@ var BrainerceClient = class {
4378
4384
  throw new BrainerceError("getMyOrders is only available in vibe-coded or storefront mode", 400);
4379
4385
  }
4380
4386
  /**
4381
- * Get download links for a purchased order (requires customerToken)
4382
- * Works in vibe-coded and storefront modes
4387
+ * Get download links for a purchased order.
4388
+ * Auth: customerToken/proxyMode (logged-in) OR checkoutId (guest after payment).
4383
4389
  *
4384
4390
  * @example
4385
4391
  * ```typescript
4392
+ * // Logged-in customer
4386
4393
  * const links = await client.getOrderDownloads('order_123');
4387
- * for (const link of links) {
4388
- * console.log(`${link.productName}: ${link.downloadUrl}`);
4389
- * }
4394
+ *
4395
+ * // Guest (right after checkout)
4396
+ * const links = await client.getOrderDownloads('order_123', { checkoutId: 'ckxxx' });
4390
4397
  * ```
4391
4398
  */
4392
- async getOrderDownloads(orderId) {
4393
- if (!this.customerToken && !this.proxyMode) {
4394
- throw new BrainerceError(
4395
- "Customer token required. Call setCustomerToken() after login.",
4396
- 401
4397
- );
4399
+ async getOrderDownloads(orderId, options) {
4400
+ const hasAuth = this.customerToken || this.proxyMode;
4401
+ const checkoutId = options?.checkoutId;
4402
+ if (!hasAuth && !checkoutId) {
4403
+ throw new BrainerceError("Customer token or checkoutId required for download access.", 401);
4398
4404
  }
4405
+ const qs = checkoutId ? `?checkout_id=${encodeURIComponent(checkoutId)}` : "";
4399
4406
  if (this.isVibeCodedMode()) {
4400
4407
  return this.vibeCodedRequest(
4401
4408
  "GET",
4402
- `/customers/me/orders/${orderId}/downloads`
4409
+ `/customers/me/orders/${orderId}/downloads${qs}`
4403
4410
  );
4404
4411
  }
4405
4412
  if (this.storeId && !this.apiKey) {
4406
4413
  return this.storefrontRequest(
4407
4414
  "GET",
4408
- `/customers/me/orders/${orderId}/downloads`
4415
+ `/customers/me/orders/${orderId}/downloads${qs}`
4409
4416
  );
4410
4417
  }
4411
4418
  throw new BrainerceError(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brainerce",
3
- "version": "1.10.1",
3
+ "version": "1.10.3",
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",