@asteby/storefront 0.20.0 → 0.22.0
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/{account-settings-eGXCcSzz.d.cts → account-settings-Cj-yownd.d.cts} +47 -1
- package/dist/{account-settings-BNDoVH3W.d.ts → account-settings-DYMmes8_.d.ts} +47 -1
- package/dist/cli.js +26 -1
- package/dist/fiscal-document.d.cts +2 -2
- package/dist/fiscal-document.d.ts +2 -2
- package/dist/index.cjs +25 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -3
- package/dist/index.d.ts +28 -3
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -1
- package/dist/mock.cjs +52 -3
- package/dist/mock.cjs.map +1 -1
- package/dist/mock.d.cts +1 -1
- package/dist/mock.d.ts +1 -1
- package/dist/mock.js +52 -3
- package/dist/mock.js.map +1 -1
- package/dist/mockup.d.cts +1 -1
- package/dist/mockup.d.ts +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.js +1 -1
- package/package.json +1 -1
package/dist/mock.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bS as SubjectKind, aa as IdentityRulesV1, bm as RegionFiscalId, a8 as IdentityDocumentSpec, bk as Region, bD as Shop, b5 as Product, y as Collection, bV as Theme, aM as Page, au as Menu, c as Article, C as Cart, a as Address, ak as InvoiceRequest, B as Customer, a3 as FiscalProfile, bM as Subject, aB as Order, aP as PaymentAttemptResult, b2 as PendingPayment, am as InvoiceStage, D as CustomerCapabilities, bc as PromotionAnnouncement, bC as ShippingRate, aW as PaymentMethod } from './account-settings-Cj-yownd.cjs';
|
|
2
2
|
import './geo.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/mock.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bS as SubjectKind, aa as IdentityRulesV1, bm as RegionFiscalId, a8 as IdentityDocumentSpec, bk as Region, bD as Shop, b5 as Product, y as Collection, bV as Theme, aM as Page, au as Menu, c as Article, C as Cart, a as Address, ak as InvoiceRequest, B as Customer, a3 as FiscalProfile, bM as Subject, aB as Order, aP as PaymentAttemptResult, b2 as PendingPayment, am as InvoiceStage, D as CustomerCapabilities, bc as PromotionAnnouncement, bC as ShippingRate, aW as PaymentMethod } from './account-settings-DYMmes8_.js';
|
|
2
2
|
import './geo.js';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/mock.js
CHANGED
|
@@ -53,6 +53,9 @@ function buildAccountOrders(currency) {
|
|
|
53
53
|
folio_number: "1042",
|
|
54
54
|
total: money(129900, currency),
|
|
55
55
|
issued_at: "2026-08-13T10:00:00.000Z",
|
|
56
|
+
payment_method: "PUE",
|
|
57
|
+
payment_form: "04",
|
|
58
|
+
receiver: { rfc: "XAXX010101000", name: "P\xFAblico en general", tax_regime: "616", cfdi_use: "S01", postal_code: "76000" },
|
|
56
59
|
test_mode: false,
|
|
57
60
|
environment: "production"
|
|
58
61
|
};
|
|
@@ -1639,6 +1642,7 @@ function createMockStorefront(options = {}) {
|
|
|
1639
1642
|
notifications: { channels: ["email"] },
|
|
1640
1643
|
data_export: true,
|
|
1641
1644
|
account_delete: true,
|
|
1645
|
+
email_change: true,
|
|
1642
1646
|
...(options.subjectKinds?.length ?? 0) > 0 ? { subjects: { kinds: options.subjectKinds.map((k) => k.key), share_with_workshop: false } } : {},
|
|
1643
1647
|
...options.customerCapabilities
|
|
1644
1648
|
};
|
|
@@ -2044,7 +2048,9 @@ function createMockStorefront(options = {}) {
|
|
|
2044
2048
|
first_name: extra.first_name ?? null,
|
|
2045
2049
|
last_name: extra.last_name ?? null,
|
|
2046
2050
|
default_address_id: null,
|
|
2047
|
-
created_at: now()
|
|
2051
|
+
created_at: now(),
|
|
2052
|
+
// Registered with no mail connector: the e-mail is only a login name until a code proves it.
|
|
2053
|
+
email_verified: capabilities.email_verification
|
|
2048
2054
|
};
|
|
2049
2055
|
state.customers.push(customer);
|
|
2050
2056
|
}
|
|
@@ -2480,7 +2486,8 @@ function createMockStorefront(options = {}) {
|
|
|
2480
2486
|
first_name: null,
|
|
2481
2487
|
last_name: null,
|
|
2482
2488
|
default_address_id: null,
|
|
2483
|
-
created_at: now()
|
|
2489
|
+
created_at: now(),
|
|
2490
|
+
email_verified: kind === "email"
|
|
2484
2491
|
};
|
|
2485
2492
|
state.customers.push(customer);
|
|
2486
2493
|
}
|
|
@@ -2501,12 +2508,12 @@ function createMockStorefront(options = {}) {
|
|
|
2501
2508
|
const text = (v) => typeof v === "string" && v.trim() ? v.trim() : null;
|
|
2502
2509
|
const first_name = text(body.first_name);
|
|
2503
2510
|
const last_name = text(body.last_name);
|
|
2504
|
-
if (state.passwords.has(email)) throw new HttpError(409, "conflict", "An account with this email already exists", "email");
|
|
2505
2511
|
if (capabilities.email_verification) {
|
|
2506
2512
|
state.pendingRegistrations.set(email, { password, first_name, last_name });
|
|
2507
2513
|
state.otps.set(`email:${email}`, otpCode);
|
|
2508
2514
|
return { status: 202, body: { status: "verification_required" }, cache: "private" };
|
|
2509
2515
|
}
|
|
2516
|
+
if (state.passwords.has(email)) throw new HttpError(409, "conflict", "An account with this email already exists", "email");
|
|
2510
2517
|
state.passwords.set(email, password);
|
|
2511
2518
|
return { status: 201, body: sessionFor(email, { first_name, last_name }), cache: "private" };
|
|
2512
2519
|
});
|
|
@@ -2683,6 +2690,48 @@ function createMockStorefront(options = {}) {
|
|
|
2683
2690
|
info.reauth_at = Date.now();
|
|
2684
2691
|
return { body: { reauth_at: new Date(info.reauth_at).toISOString(), valid_for_seconds: REAUTH_WINDOW_MS / 1e3 }, cache: "private" };
|
|
2685
2692
|
});
|
|
2693
|
+
const emailCodeKey = (kind, customerId, email) => `${kind}_email:${customerId}:${email}`;
|
|
2694
|
+
route("POST", "/customer/email/verification", "customer:write", ({ headers }) => {
|
|
2695
|
+
const { c } = sessionOf(headers);
|
|
2696
|
+
if (!c.email) throw new HttpError(422, "invalid_state", "The account has no email", "email");
|
|
2697
|
+
if (c.email_verified !== false) throw new HttpError(422, "invalid_state", "The email is already verified", "email");
|
|
2698
|
+
state.otps.set(emailCodeKey("verify", c.id, c.email), otpCode);
|
|
2699
|
+
return { status: 204 };
|
|
2700
|
+
});
|
|
2701
|
+
route("POST", "/customer/email/verification/confirm", "customer:write", ({ headers, body }) => {
|
|
2702
|
+
const { c } = sessionOf(headers);
|
|
2703
|
+
if (!c.email) throw new HttpError(422, "invalid_state", "The account has no email", "email");
|
|
2704
|
+
if (c.email_verified !== false) throw new HttpError(422, "invalid_state", "The email is already verified", "email");
|
|
2705
|
+
const key = emailCodeKey("verify", c.id, c.email);
|
|
2706
|
+
if (typeof body.code !== "string" || state.otps.get(key) !== body.code) throw new HttpError(400, "validation", "The code is invalid or expired; request a new one", "code");
|
|
2707
|
+
state.otps.delete(key);
|
|
2708
|
+
c.email_verified = true;
|
|
2709
|
+
return { body: c, cache: "private" };
|
|
2710
|
+
});
|
|
2711
|
+
route("POST", "/customer/email/change", "customer:write", ({ headers, body }) => {
|
|
2712
|
+
const { c, info } = sessionOf(headers);
|
|
2713
|
+
requireRecentReauth(info);
|
|
2714
|
+
const email = emailOf(body);
|
|
2715
|
+
if (email === c.email) throw new HttpError(400, "validation", "This is already the email of the account", "email");
|
|
2716
|
+
const taken = state.customers.some((x) => x.email === email) || state.passwords.has(email);
|
|
2717
|
+
if (!taken) state.otps.set(emailCodeKey("change", c.id, email), otpCode);
|
|
2718
|
+
return { status: 202, body: { status: "verification_required" }, cache: "private" };
|
|
2719
|
+
});
|
|
2720
|
+
route("POST", "/customer/email/change/confirm", "customer:write", ({ headers, body }) => {
|
|
2721
|
+
const { c, token } = sessionOf(headers);
|
|
2722
|
+
const email = emailOf(body);
|
|
2723
|
+
const key = emailCodeKey("change", c.id, email);
|
|
2724
|
+
if (typeof body.code !== "string" || state.otps.get(key) !== body.code) throw new HttpError(400, "validation", "The code is invalid or expired; request a new one", "code");
|
|
2725
|
+
state.otps.delete(key);
|
|
2726
|
+
if (c.email && state.passwords.has(c.email)) {
|
|
2727
|
+
state.passwords.set(email, state.passwords.get(c.email));
|
|
2728
|
+
state.passwords.delete(c.email);
|
|
2729
|
+
}
|
|
2730
|
+
c.email = email;
|
|
2731
|
+
c.email_verified = true;
|
|
2732
|
+
for (const [t, id] of [...state.sessions.entries()]) if (id === c.id && t !== token) state.sessions.delete(t);
|
|
2733
|
+
return { body: c, cache: "private" };
|
|
2734
|
+
});
|
|
2686
2735
|
route("POST", "/customer/data-export", "customer:write", ({ headers }) => {
|
|
2687
2736
|
const { c, info } = sessionOf(headers);
|
|
2688
2737
|
requireRecentReauth(info);
|