@asteby/storefront 0.21.1 → 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-BkShqX2k.d.cts → account-settings-Cj-yownd.d.cts} +28 -1
- package/dist/{account-settings-quulZwuF.d.ts → account-settings-DYMmes8_.d.ts} +28 -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 +48 -2
- 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 +48 -2
- 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
|
@@ -1642,6 +1642,7 @@ function createMockStorefront(options = {}) {
|
|
|
1642
1642
|
notifications: { channels: ["email"] },
|
|
1643
1643
|
data_export: true,
|
|
1644
1644
|
account_delete: true,
|
|
1645
|
+
email_change: true,
|
|
1645
1646
|
...(options.subjectKinds?.length ?? 0) > 0 ? { subjects: { kinds: options.subjectKinds.map((k) => k.key), share_with_workshop: false } } : {},
|
|
1646
1647
|
...options.customerCapabilities
|
|
1647
1648
|
};
|
|
@@ -2047,7 +2048,9 @@ function createMockStorefront(options = {}) {
|
|
|
2047
2048
|
first_name: extra.first_name ?? null,
|
|
2048
2049
|
last_name: extra.last_name ?? null,
|
|
2049
2050
|
default_address_id: null,
|
|
2050
|
-
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
|
|
2051
2054
|
};
|
|
2052
2055
|
state.customers.push(customer);
|
|
2053
2056
|
}
|
|
@@ -2483,7 +2486,8 @@ function createMockStorefront(options = {}) {
|
|
|
2483
2486
|
first_name: null,
|
|
2484
2487
|
last_name: null,
|
|
2485
2488
|
default_address_id: null,
|
|
2486
|
-
created_at: now()
|
|
2489
|
+
created_at: now(),
|
|
2490
|
+
email_verified: kind === "email"
|
|
2487
2491
|
};
|
|
2488
2492
|
state.customers.push(customer);
|
|
2489
2493
|
}
|
|
@@ -2686,6 +2690,48 @@ function createMockStorefront(options = {}) {
|
|
|
2686
2690
|
info.reauth_at = Date.now();
|
|
2687
2691
|
return { body: { reauth_at: new Date(info.reauth_at).toISOString(), valid_for_seconds: REAUTH_WINDOW_MS / 1e3 }, cache: "private" };
|
|
2688
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
|
+
});
|
|
2689
2735
|
route("POST", "/customer/data-export", "customer:write", ({ headers }) => {
|
|
2690
2736
|
const { c, info } = sessionOf(headers);
|
|
2691
2737
|
requireRecentReauth(info);
|