@blamejs/blamejs-shop 0.2.4 → 0.2.6
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/CHANGELOG.md +4 -0
- package/lib/admin.js +412 -1
- package/lib/asset-manifest.json +3 -3
- package/lib/customer-surveys.js +40 -0
- package/lib/storefront.js +293 -4
- package/lib/vendor/MANIFEST.json +2 -2
- package/lib/vendor/blamejs/CHANGELOG.md +4 -0
- package/lib/vendor/blamejs/README.md +1 -1
- package/lib/vendor/blamejs/api-snapshot.json +2 -2
- package/lib/vendor/blamejs/lib/middleware/body-parser.js +95 -49
- package/lib/vendor/blamejs/lib/template.js +159 -23
- package/lib/vendor/blamejs/lib/vendor/MANIFEST.json +12 -12
- package/lib/vendor/blamejs/lib/vendor/simplewebauthn-server.cjs +31 -28
- package/lib/vendor/blamejs/package.json +1 -1
- package/lib/vendor/blamejs/release-notes/v0.13.17.json +27 -0
- package/lib/vendor/blamejs/release-notes/v0.13.18.json +18 -0
- package/lib/vendor/blamejs/test/00-primitives.js +144 -3
- package/package.json +1 -1
package/lib/storefront.js
CHANGED
|
@@ -1274,7 +1274,7 @@ function _buildBuyBox(variants, escAttr) {
|
|
|
1274
1274
|
|
|
1275
1275
|
var trustLine =
|
|
1276
1276
|
"<div class=\"pdp__meta\">\n" +
|
|
1277
|
-
" <span class=\"pdp__badge\"><
|
|
1277
|
+
" <span class=\"pdp__badge\"><img class=\"pdp__badge-mark\" src=\"/assets/brand/favicon.svg\" alt=\"\" aria-hidden=\"true\" width=\"22\" height=\"22\"> Post-quantum secured checkout · ML-KEM-1024 key agreement · ML-DSA-65 receipt signature.</span>\n" +
|
|
1278
1278
|
" </div>";
|
|
1279
1279
|
|
|
1280
1280
|
// Many variants → keep the compact table (still a per-row add form).
|
|
@@ -3788,8 +3788,7 @@ var CART_PAGE =
|
|
|
3788
3788
|
" <div><dt>Subtotal</dt><dd>{{subtotal}}</dd></div>\n" +
|
|
3789
3789
|
" <div class=\"totals-list__grand\"><dt>Total</dt><dd>{{total}}</dd></div>\n" +
|
|
3790
3790
|
" </dl>\n" +
|
|
3791
|
-
"
|
|
3792
|
-
" <p class=\"cart-page__note\">Tax and shipping are calculated on the next step. Payment runs through Stripe.</p>\n" +
|
|
3791
|
+
"RAW_CHECKOUT_CTA" +
|
|
3793
3792
|
" </aside>\n" +
|
|
3794
3793
|
" </div>\n" +
|
|
3795
3794
|
"</section>\n";
|
|
@@ -3886,11 +3885,21 @@ function renderCart(opts) {
|
|
|
3886
3885
|
product_url: l.product_url,
|
|
3887
3886
|
}).replace("RAW_CART_LINE_THUMB", thumb).replace("RAW_CART_LINE_SAVE", saveBtn);
|
|
3888
3887
|
}).join("");
|
|
3888
|
+
// Checkout CTA — only a live button when checkout is actually wired
|
|
3889
|
+
// (Stripe configured). Absent that, render a clear, disabled "not set
|
|
3890
|
+
// up" notice instead of a link that 404s. Backward-compatible: callers
|
|
3891
|
+
// that don't pass the flag (older tests) keep the button.
|
|
3892
|
+
var checkoutAvailable = opts.checkout_available !== false;
|
|
3893
|
+
var checkoutCta = checkoutAvailable
|
|
3894
|
+
? " <a href=\"/checkout\" class=\"btn-primary cart-page__checkout\">Continue to checkout <span aria-hidden=\"true\">→</span></a>\n" +
|
|
3895
|
+
" <p class=\"cart-page__note\">Tax and shipping are calculated on the next step. Payment runs through Stripe.</p>\n"
|
|
3896
|
+
: " <button type=\"button\" class=\"btn-primary cart-page__checkout\" disabled aria-disabled=\"true\">Checkout unavailable</button>\n" +
|
|
3897
|
+
" <p class=\"cart-page__note cart-page__note--warn\" role=\"status\">Online checkout isn't set up for this store yet — payments aren't configured. Your cart is saved; please check back soon.</p>\n";
|
|
3889
3898
|
body = _render(CART_PAGE, {
|
|
3890
3899
|
line_rows: "RAW_LINES",
|
|
3891
3900
|
subtotal: subtotal,
|
|
3892
3901
|
total: total,
|
|
3893
|
-
}).replace("RAW_LINES", rows);
|
|
3902
|
+
}).replace("RAW_LINES", rows).replace("RAW_CHECKOUT_CTA", checkoutCta);
|
|
3894
3903
|
}
|
|
3895
3904
|
return _wrap(Object.assign({
|
|
3896
3905
|
title: "Cart",
|
|
@@ -4656,6 +4665,146 @@ function renderAccount(opts) {
|
|
|
4656
4665
|
});
|
|
4657
4666
|
}
|
|
4658
4667
|
|
|
4668
|
+
// ---- customer survey page ----------------------------------------------
|
|
4669
|
+
|
|
4670
|
+
// Render one survey question as a fieldset. Rating → a 0/1..max radio
|
|
4671
|
+
// scale; select → radio options; free_text → a textarea. Field name is
|
|
4672
|
+
// `q_<id>`; the post handler maps it back. All operator-authored strings
|
|
4673
|
+
// are HTML-escaped at the sink.
|
|
4674
|
+
function _surveyQuestion(q) {
|
|
4675
|
+
var esc = function (s) { return b.template.escapeHtml(String(s == null ? "" : s)); };
|
|
4676
|
+
var name = "q_" + esc(q.id);
|
|
4677
|
+
var req = q.required ? " <abbr class=\"survey-req\" title=\"Required\">*</abbr>" : "";
|
|
4678
|
+
var control = "";
|
|
4679
|
+
if (q.kind === "rating") {
|
|
4680
|
+
var lo = (q.max >= 9) ? 0 : 1; // 0..10 for NPS-scale, else 1..max
|
|
4681
|
+
var scale = "";
|
|
4682
|
+
for (var n = lo; n <= q.max; n += 1) {
|
|
4683
|
+
scale += "<label class=\"survey-scale__opt\"><input type=\"radio\" name=\"" + name + "\" value=\"" + n + "\"" + (q.required ? " required" : "") + "><span>" + n + "</span></label>";
|
|
4684
|
+
}
|
|
4685
|
+
control = "<div class=\"survey-scale\">" + scale + "</div>";
|
|
4686
|
+
} else if (q.kind === "select") {
|
|
4687
|
+
var opts = "";
|
|
4688
|
+
for (var k = 0; k < q.options.length; k += 1) {
|
|
4689
|
+
var ov = esc(q.options[k]);
|
|
4690
|
+
opts += "<label class=\"survey-opt\"><input type=\"radio\" name=\"" + name + "\" value=\"" + ov + "\"" + (q.required ? " required" : "") + "> " + ov + "</label>";
|
|
4691
|
+
}
|
|
4692
|
+
control = "<div class=\"survey-opts\">" + opts + "</div>";
|
|
4693
|
+
} else {
|
|
4694
|
+
control = "<textarea name=\"" + name + "\" maxlength=\"" + (q.max || 2000) + "\"" + (q.required ? " required" : "") + "></textarea>";
|
|
4695
|
+
}
|
|
4696
|
+
return "<fieldset class=\"survey-q\"><legend>" + esc(q.label) + req + "</legend>" + control + "</fieldset>";
|
|
4697
|
+
}
|
|
4698
|
+
|
|
4699
|
+
// The token survey page. `state` selects the panel: form (answerable),
|
|
4700
|
+
// thankyou (just submitted), responded (already done), expired, closed, or
|
|
4701
|
+
// notfound. The token is rendered into the form action so the POST carries
|
|
4702
|
+
// it back (it's path-segment-safe — 43 base64url chars).
|
|
4703
|
+
function renderSurveyPage(opts) {
|
|
4704
|
+
opts = opts || {};
|
|
4705
|
+
var esc = function (s) { return b.template.escapeHtml(String(s == null ? "" : s)); };
|
|
4706
|
+
var state = opts.state || "notfound";
|
|
4707
|
+
var body;
|
|
4708
|
+
if (state === "form") {
|
|
4709
|
+
var survey = opts.survey || {};
|
|
4710
|
+
var qs = (survey.questions || []).map(_surveyQuestion).join("");
|
|
4711
|
+
var notice = opts.notice ? "<p class=\"form-notice\">" + esc(opts.notice) + "</p>" : "";
|
|
4712
|
+
body =
|
|
4713
|
+
"<section class=\"survey-page\"><div class=\"survey-page__inner\">" +
|
|
4714
|
+
"<p class=\"eyebrow\">Your feedback</p>" +
|
|
4715
|
+
"<h1 class=\"survey-page__title\">" + esc(survey.title) + "</h1>" +
|
|
4716
|
+
notice +
|
|
4717
|
+
"<form class=\"survey-form\" method=\"post\" action=\"/survey/" + esc(opts.token) + "\">" +
|
|
4718
|
+
qs +
|
|
4719
|
+
"<div class=\"survey-form__actions\"><button class=\"btn-primary\" type=\"submit\">Submit feedback</button></div>" +
|
|
4720
|
+
"</form>" +
|
|
4721
|
+
"</div></section>";
|
|
4722
|
+
} else {
|
|
4723
|
+
var heads = {
|
|
4724
|
+
thankyou: ["Thank you", "Your feedback's in — we appreciate you taking the time."],
|
|
4725
|
+
responded: ["Already answered", "This feedback link has already been used. Thank you."],
|
|
4726
|
+
expired: ["This link has expired", "The feedback window for this survey has closed."],
|
|
4727
|
+
closed: ["This survey is closed", "This feedback link is no longer active."],
|
|
4728
|
+
notfound: ["Survey not found", "This feedback link isn't valid. Check the link from your email."],
|
|
4729
|
+
};
|
|
4730
|
+
var h = heads[state] || heads.notfound;
|
|
4731
|
+
body =
|
|
4732
|
+
"<section class=\"survey-page\"><div class=\"survey-page__inner survey-page__inner--msg\">" +
|
|
4733
|
+
"<h1 class=\"survey-page__title\">" + esc(h[0]) + "</h1>" +
|
|
4734
|
+
"<p class=\"survey-page__lede\">" + esc(h[1]) + "</p>" +
|
|
4735
|
+
"<a class=\"btn-ghost\" href=\"/\">Back to the shop</a>" +
|
|
4736
|
+
"</div></section>";
|
|
4737
|
+
}
|
|
4738
|
+
return _wrap({
|
|
4739
|
+
title: opts.title || "Survey",
|
|
4740
|
+
shop_name: opts.shop_name || "blamejs.shop",
|
|
4741
|
+
cart_count: opts.cart_count == null ? 0 : opts.cart_count,
|
|
4742
|
+
theme_css: opts.theme_css,
|
|
4743
|
+
body: body,
|
|
4744
|
+
});
|
|
4745
|
+
}
|
|
4746
|
+
|
|
4747
|
+
// ---- business-hours page -----------------------------------------------
|
|
4748
|
+
|
|
4749
|
+
var _DOW_NAMES = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
|
4750
|
+
|
|
4751
|
+
// The public /hours page. `opts.schedules` is an array of resolved
|
|
4752
|
+
// schedules: { summary: { slug, timezone, days[7] }, is_open, next_open,
|
|
4753
|
+
// next_close }. Renders each as a card with a live open/closed pill, the
|
|
4754
|
+
// next transition, and the weekly grid. An empty list renders a friendly
|
|
4755
|
+
// "not published yet" notice.
|
|
4756
|
+
function renderHoursPage(opts) {
|
|
4757
|
+
opts = opts || {};
|
|
4758
|
+
var esc = function (s) { return b.template.escapeHtml(String(s == null ? "" : s)); };
|
|
4759
|
+
var schedules = opts.schedules || [];
|
|
4760
|
+
var body;
|
|
4761
|
+
if (!schedules.length) {
|
|
4762
|
+
body =
|
|
4763
|
+
"<section class=\"hours-page\"><div class=\"hours-page__inner hours-page__inner--msg\">" +
|
|
4764
|
+
"<h1 class=\"hours-page__title\">Hours</h1>" +
|
|
4765
|
+
"<p class=\"hours-page__lede\">Our hours haven't been published yet.</p>" +
|
|
4766
|
+
"<a class=\"btn-ghost\" href=\"/\">Back to the shop</a>" +
|
|
4767
|
+
"</div></section>";
|
|
4768
|
+
} else {
|
|
4769
|
+
var cards = schedules.map(function (s) {
|
|
4770
|
+
var pill = s.is_open
|
|
4771
|
+
? "<span class=\"hours-status hours-status--open\">Open now</span>"
|
|
4772
|
+
: "<span class=\"hours-status hours-status--closed\">Closed</span>";
|
|
4773
|
+
var next = "";
|
|
4774
|
+
if (s.is_open && s.next_close) next = "Closes at " + esc(s.next_close.close);
|
|
4775
|
+
else if (!s.is_open && s.next_open) next = "Opens " + esc(s.next_open.date) + " at " + esc(s.next_open.open);
|
|
4776
|
+
var rows = "";
|
|
4777
|
+
var days = (s.summary && s.summary.days) || [];
|
|
4778
|
+
for (var d = 0; d < 7; d += 1) {
|
|
4779
|
+
var wins = days[d] || [];
|
|
4780
|
+
var hrs = wins.length
|
|
4781
|
+
? wins.map(function (w) { return esc(w.open) + "–" + esc(w.close); }).join(", ")
|
|
4782
|
+
: "<span class=\"hours-table__closed\">Closed</span>";
|
|
4783
|
+
rows += "<tr><th scope=\"row\">" + _DOW_NAMES[d] + "</th><td>" + hrs + "</td></tr>";
|
|
4784
|
+
}
|
|
4785
|
+
return "<div class=\"hours-card\">" +
|
|
4786
|
+
"<div class=\"hours-card__head\"><h2>" + esc(s.summary.slug) + "</h2>" + pill + "</div>" +
|
|
4787
|
+
(next ? "<p class=\"hours-card__next\">" + next + "</p>" : "") +
|
|
4788
|
+
"<table class=\"hours-table\"><tbody>" + rows + "</tbody></table>" +
|
|
4789
|
+
"<p class=\"hours-card__tz\">Times shown in " + esc(s.summary.timezone) + ".</p>" +
|
|
4790
|
+
"</div>";
|
|
4791
|
+
}).join("");
|
|
4792
|
+
body =
|
|
4793
|
+
"<section class=\"hours-page\"><div class=\"hours-page__inner\">" +
|
|
4794
|
+
"<p class=\"eyebrow\">When we're around</p>" +
|
|
4795
|
+
"<h1 class=\"hours-page__title\">Hours</h1>" +
|
|
4796
|
+
"<div class=\"hours-grid\">" + cards + "</div>" +
|
|
4797
|
+
"</div></section>";
|
|
4798
|
+
}
|
|
4799
|
+
return _wrap({
|
|
4800
|
+
title: "Hours",
|
|
4801
|
+
shop_name: opts.shop_name || "blamejs.shop",
|
|
4802
|
+
cart_count: opts.cart_count == null ? 0 : opts.cart_count,
|
|
4803
|
+
theme_css: opts.theme_css,
|
|
4804
|
+
body: body,
|
|
4805
|
+
});
|
|
4806
|
+
}
|
|
4807
|
+
|
|
4659
4808
|
function mount(router, deps) {
|
|
4660
4809
|
if (!router || typeof router.get !== "function") throw new TypeError("storefront.mount: router with .get() required");
|
|
4661
4810
|
if (!deps || !deps.catalog || !deps.cart) throw new TypeError("storefront.mount: deps.catalog + deps.cart required");
|
|
@@ -5046,6 +5195,121 @@ function mount(router, deps) {
|
|
|
5046
5195
|
});
|
|
5047
5196
|
}
|
|
5048
5197
|
|
|
5198
|
+
// ---- customer survey (token-gated) ----------------------------------
|
|
5199
|
+
// The invitation token IS the access — no login. GET renders the survey
|
|
5200
|
+
// (or a state notice); POST records the response. Container-only (the
|
|
5201
|
+
// token page is never edge-cached). Resilient: an unknown/garbage token,
|
|
5202
|
+
// a used/expired/closed invitation, and a missing surveys table all
|
|
5203
|
+
// resolve to a clean state page, never a 500.
|
|
5204
|
+
if (deps.customerSurveys) {
|
|
5205
|
+
var _surveyCtx = function (_req) {
|
|
5206
|
+
return {
|
|
5207
|
+
shop_name: (deps.config && deps.config.shop_name) || "blamejs.shop",
|
|
5208
|
+
cart_count: 0,
|
|
5209
|
+
theme_css: (deps.theme && deps.theme.assetUrl) ? deps.theme.assetUrl("css/main.css") : DEFAULT_THEME_CSS_URL,
|
|
5210
|
+
};
|
|
5211
|
+
};
|
|
5212
|
+
|
|
5213
|
+
router.get("/survey/:token", async function (req, res) {
|
|
5214
|
+
var token = (req.params && req.params.token) || "";
|
|
5215
|
+
var state = "notfound", survey = null;
|
|
5216
|
+
try {
|
|
5217
|
+
var preview = await deps.customerSurveys.previewByToken(token);
|
|
5218
|
+
if (preview) {
|
|
5219
|
+
survey = preview.survey;
|
|
5220
|
+
var inv = preview.invitation;
|
|
5221
|
+
if (inv.status === "responded") state = "responded";
|
|
5222
|
+
else if (inv.status === "closed") state = "closed";
|
|
5223
|
+
else if (inv.status === "expired" || Number(inv.expires_at) < Date.now()) state = "expired";
|
|
5224
|
+
else state = "form";
|
|
5225
|
+
}
|
|
5226
|
+
} catch (_e) { state = "notfound"; }
|
|
5227
|
+
var ctx = _surveyCtx(req);
|
|
5228
|
+
_send(res, state === "notfound" ? 404 : 200, renderSurveyPage({
|
|
5229
|
+
state: state, survey: survey, token: token,
|
|
5230
|
+
shop_name: ctx.shop_name, cart_count: ctx.cart_count, theme_css: ctx.theme_css,
|
|
5231
|
+
}));
|
|
5232
|
+
});
|
|
5233
|
+
|
|
5234
|
+
router.post("/survey/:token", async function (req, res) {
|
|
5235
|
+
var token = (req.params && req.params.token) || "";
|
|
5236
|
+
var body = req.body || {};
|
|
5237
|
+
var ctx = _surveyCtx(req);
|
|
5238
|
+
// Resolve the survey first so we can re-render the form on a
|
|
5239
|
+
// validation error (and map the token to its questions).
|
|
5240
|
+
var preview = null;
|
|
5241
|
+
try { preview = await deps.customerSurveys.previewByToken(token); }
|
|
5242
|
+
catch (_e) { preview = null; }
|
|
5243
|
+
if (!preview) {
|
|
5244
|
+
return _send(res, 404, renderSurveyPage({ state: "notfound", token: token, shop_name: ctx.shop_name, theme_css: ctx.theme_css }));
|
|
5245
|
+
}
|
|
5246
|
+
// Build the answers object from the q_<id> fields, typed per question
|
|
5247
|
+
// kind (rating → integer, select/free_text → string). Blank fields are
|
|
5248
|
+
// omitted so optional questions stay unanswered.
|
|
5249
|
+
var answers = {};
|
|
5250
|
+
var questions = preview.survey.questions || [];
|
|
5251
|
+
for (var i = 0; i < questions.length; i += 1) {
|
|
5252
|
+
var q = questions[i];
|
|
5253
|
+
var raw = body["q_" + q.id];
|
|
5254
|
+
if (raw == null || raw === "") continue;
|
|
5255
|
+
if (q.kind === "rating") {
|
|
5256
|
+
var n = parseInt(raw, 10);
|
|
5257
|
+
if (isFinite(n)) answers[q.id] = n;
|
|
5258
|
+
} else {
|
|
5259
|
+
answers[q.id] = String(raw);
|
|
5260
|
+
}
|
|
5261
|
+
}
|
|
5262
|
+
try {
|
|
5263
|
+
await deps.customerSurveys.submitResponse({ token: token, answers: answers });
|
|
5264
|
+
} catch (e) {
|
|
5265
|
+
// Known terminal states → the matching notice; a validation
|
|
5266
|
+
// TypeError → re-render the form with the cleaned message.
|
|
5267
|
+
var code = e && e.code;
|
|
5268
|
+
if (code === "SURVEY_INVITATION_ALREADY_RESPONDED") return _send(res, 200, renderSurveyPage({ state: "responded", token: token, shop_name: ctx.shop_name, theme_css: ctx.theme_css }));
|
|
5269
|
+
if (code === "SURVEY_INVITATION_EXPIRED") return _send(res, 200, renderSurveyPage({ state: "expired", token: token, shop_name: ctx.shop_name, theme_css: ctx.theme_css }));
|
|
5270
|
+
if (code === "SURVEY_INVITATION_CLOSED") return _send(res, 200, renderSurveyPage({ state: "closed", token: token, shop_name: ctx.shop_name, theme_css: ctx.theme_css }));
|
|
5271
|
+
if (code === "SURVEY_INVITATION_NOT_FOUND") return _send(res, 404, renderSurveyPage({ state: "notfound", token: token, shop_name: ctx.shop_name, theme_css: ctx.theme_css }));
|
|
5272
|
+
if (e instanceof TypeError) {
|
|
5273
|
+
return _send(res, 400, renderSurveyPage({
|
|
5274
|
+
state: "form", survey: preview.survey, token: token,
|
|
5275
|
+
notice: (e.message || "Please check your answers.").replace(/^customerSurveys[.:]\s*/, ""),
|
|
5276
|
+
shop_name: ctx.shop_name, theme_css: ctx.theme_css,
|
|
5277
|
+
}));
|
|
5278
|
+
}
|
|
5279
|
+
throw e;
|
|
5280
|
+
}
|
|
5281
|
+
_send(res, 200, renderSurveyPage({ state: "thankyou", token: token, shop_name: ctx.shop_name, theme_css: ctx.theme_css }));
|
|
5282
|
+
});
|
|
5283
|
+
}
|
|
5284
|
+
|
|
5285
|
+
// ---- business hours (public /hours page) ----------------------------
|
|
5286
|
+
// Lists every active schedule with its weekly grid + a live open/closed
|
|
5287
|
+
// status computed at request time in the schedule's timezone. Container-
|
|
5288
|
+
// rendered (the status is time-of-day dependent, so it isn't edge-cached).
|
|
5289
|
+
// Resilient: a missing table / no schedules renders the "not published"
|
|
5290
|
+
// notice, never a 500.
|
|
5291
|
+
if (deps.businessHours) {
|
|
5292
|
+
router.get("/hours", async function (req, res) {
|
|
5293
|
+
var themeCss = (deps.theme && deps.theme.assetUrl) ? deps.theme.assetUrl("css/main.css") : DEFAULT_THEME_CSS_URL;
|
|
5294
|
+
var shopName = (deps.config && deps.config.shop_name) || "blamejs.shop";
|
|
5295
|
+
var resolved = [];
|
|
5296
|
+
try {
|
|
5297
|
+
var schedules = await deps.businessHours.listSchedules();
|
|
5298
|
+
var active = (schedules || []).filter(function (s) { return s.archived_at == null; });
|
|
5299
|
+
var now = Date.now();
|
|
5300
|
+
for (var i = 0; i < active.length; i += 1) {
|
|
5301
|
+
var slug = active[i].slug;
|
|
5302
|
+
var summary = await deps.businessHours.weekSummary({ slug: slug });
|
|
5303
|
+
var isOpen = await deps.businessHours.isOpenAt({ slug: slug, when: now });
|
|
5304
|
+
var nextOpen = isOpen ? null : await deps.businessHours.nextOpenAt({ slug: slug, when: now });
|
|
5305
|
+
var nextClose = isOpen ? await deps.businessHours.nextCloseAt({ slug: slug, when: now }) : null;
|
|
5306
|
+
if (summary) resolved.push({ summary: summary, is_open: isOpen, next_open: nextOpen, next_close: nextClose });
|
|
5307
|
+
}
|
|
5308
|
+
} catch (_e) { resolved = []; /* table absent / read failure → "not published" */ }
|
|
5309
|
+
_send(res, 200, renderHoursPage({ schedules: resolved, shop_name: shopName, theme_css: themeCss }));
|
|
5310
|
+
});
|
|
5311
|
+
}
|
|
5312
|
+
|
|
5049
5313
|
// Persist a locale choice. A GET form (works with JS off) from the
|
|
5050
5314
|
// footer switcher submits `lang` (the chosen tag) + `to` (the path to
|
|
5051
5315
|
// return to). We validate the tag against the active locale set, set
|
|
@@ -6012,6 +6276,7 @@ function mount(router, deps) {
|
|
|
6012
6276
|
totals: totals,
|
|
6013
6277
|
product_lookup: productLookup,
|
|
6014
6278
|
can_save: !!(deps.saveForLater && deps.customers),
|
|
6279
|
+
checkout_available: !!(deps.checkout && deps.order),
|
|
6015
6280
|
shop_name: shopName,
|
|
6016
6281
|
theme: theme,
|
|
6017
6282
|
}, ccy)));
|
|
@@ -6028,6 +6293,30 @@ function mount(router, deps) {
|
|
|
6028
6293
|
// routes only register when supplied. This lets the framework boot
|
|
6029
6294
|
// in pure-storefront mode (catalog + cart only) for stores that
|
|
6030
6295
|
// are still configuring payment.
|
|
6296
|
+
//
|
|
6297
|
+
// When checkout ISN'T wired (no payment provider configured), mount a
|
|
6298
|
+
// graceful placeholder at /checkout so the cart link or a direct hit
|
|
6299
|
+
// renders a clear "not set up yet" page instead of a 404. The cart CTA
|
|
6300
|
+
// is already gated to a disabled notice (renderCart checkout_available),
|
|
6301
|
+
// but a direct navigation still needs a real response. GET + POST both
|
|
6302
|
+
// land here (a stale form POST shouldn't 404 either).
|
|
6303
|
+
if (!(deps.checkout && deps.order)) {
|
|
6304
|
+
var _checkoutUnavailable = function (req, res) {
|
|
6305
|
+
var body =
|
|
6306
|
+
"<section class=\"cart-page cart-page--empty\"><div class=\"cart-empty\"><div class=\"cart-empty__card\">" +
|
|
6307
|
+
"<p class=\"eyebrow cart-empty__eyebrow\">Checkout</p>" +
|
|
6308
|
+
"<h1 class=\"cart-empty__title\">Checkout isn't available yet</h1>" +
|
|
6309
|
+
"<p class=\"cart-empty__lede\">Online payments aren't set up for this store yet, so orders can't be completed right now. Your cart is saved — please check back soon.</p>" +
|
|
6310
|
+
"<div class=\"cart-empty__cta\"><a class=\"btn-primary\" href=\"/cart\">Back to cart</a> <a class=\"btn-ghost\" href=\"/\">Keep browsing</a></div>" +
|
|
6311
|
+
"</div></div></section>";
|
|
6312
|
+
// 503: the capability is unconfigured, not the request's fault — keeps
|
|
6313
|
+
// the page out of search indexes + signals "temporarily unavailable".
|
|
6314
|
+
_send(res, 503, _wrap({ title: "Checkout", shop_name: shopName, theme: theme, cart_count: 0, body: body }));
|
|
6315
|
+
};
|
|
6316
|
+
router.get("/checkout", _checkoutUnavailable);
|
|
6317
|
+
router.post("/checkout", _checkoutUnavailable);
|
|
6318
|
+
}
|
|
6319
|
+
|
|
6031
6320
|
if (deps.checkout && deps.order) {
|
|
6032
6321
|
router.get("/checkout", async function (req, res) {
|
|
6033
6322
|
var sid = _readSidCookie(req);
|
package/lib/vendor/MANIFEST.json
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
"_about": "blamejs.shop vendors a single framework — blamejs — which itself bundles every server-side crypto/identity dependency. The transitive packages blamejs ships are surfaced in its own MANIFEST.json at lib/vendor/blamejs/lib/vendor/MANIFEST.json — Trivy / Grype rely on that nested data for CVE attribution.",
|
|
4
4
|
"packages": {
|
|
5
5
|
"blamejs": {
|
|
6
|
-
"version": "0.13.
|
|
7
|
-
"tag": "v0.13.
|
|
6
|
+
"version": "0.13.18",
|
|
7
|
+
"tag": "v0.13.18",
|
|
8
8
|
"license": "Apache-2.0",
|
|
9
9
|
"author": "blamejs contributors",
|
|
10
10
|
"source": "https://github.com/blamejs/blamejs",
|
|
@@ -8,6 +8,10 @@ upgrading across more than a few patches at a time.
|
|
|
8
8
|
|
|
9
9
|
## v0.13.x
|
|
10
10
|
|
|
11
|
+
- v0.13.18 (2026-05-27) — **`bodyParser` multipart can buffer uploads in memory — no tmp directory for serverless / read-only filesystems.** The multipart/form-data sub-parser previously streamed every file part to a tmp directory on disk (os.tmpdir() by default), which fails on a read-only or ephemeral serverless filesystem. A new multipart.storage option selects where file parts land: "disk" (default, unchanged — req.files[].path points at a tmp file cleaned up on response end) or "memory" (req.files[].buffer holds the assembled bytes, with no filesystem access at all). Both modes enforce the same per-file (fileSize), per-field, and total-request (totalSize) caps, so memory mode adds no new memory-exhaustion surface. The file object shape is stable across both modes — disk sets path with buffer null, memory sets buffer with path null — so a handler branches on whichever is non-null. An invalid storage value is rejected when the middleware is constructed. **Added:** *`bodyParser` multipart `storage: "memory"` — buffer uploads in RAM instead of a tmp directory* — `b.middleware.bodyParser({ multipart: { storage: "memory" } })` buffers each uploaded file part in memory and exposes it as `req.files[].buffer` (a Buffer), with no `os.tmpdir()` write and no tmp-file cleanup — the read-only / serverless path. The default `storage: "disk"` is unchanged: file parts stream to a tmp file, `req.files[].path` points at it, and it is removed when the response finishes. Both modes apply the existing `fileSize` / per-field `maxBytes` / `totalSize` caps and SHA3-512 hash each part during streaming, so memory mode is bounded by the same limits and adds no new DoS surface. The `req.files[]` shape is stable across modes (disk: `path` set, `buffer` null; memory: `buffer` set, `path` null). A `storage` value other than `"disk"` or `"memory"` throws a `TypeError` at construction.
|
|
12
|
+
|
|
13
|
+
- v0.13.17 (2026-05-27) — **Template engine can render from a string with no views directory — for serverless / read-only filesystems.** b.template.create previously required a viewsDir that exists on disk, and rendering always read the template (and its layout/partials) from that directory — unusable on a read-only or ephemeral serverless filesystem where the templates aren't on disk. The engine now accepts a source string directly: viewsDir is optional, and the returned engine exposes renderString(source, data?, opts?) and compileString(source, opts?) that compile and render from a string with no disk read. {% extends %} and {{> partial}} in a string source resolve through an operator-supplied opts.resolve(name) -> string callback (without it, an extends throws a clear error and a missing partial inlines empty, matching the file path). The same HTML-escaping, expression grammar, and extends/partial-depth caps apply. The file-backed render / compile / precompileAll still work exactly as before when a viewsDir is configured, and now refuse with a clear error when one isn't. **Added:** *`engine.renderString` / `engine.compileString` — render templates from a string, no viewsDir* — `b.template.create({})` (no `viewsDir`) returns a string-only engine; `renderString(source, data?, { resolve })` and `compileString(source, { resolve })` compile and render from a source string with zero filesystem access — the read-only / serverless path. `{% extends %}` and `{{> partial}}` resolve through `opts.resolve(name) -> string`. The HTML escaping, grammar, and depth caps are identical to the file path. When a `viewsDir` IS configured, `render`/`compile`/`precompileAll` behave exactly as before; without one they refuse with `viewsDir not configured`. `renderString(source, { resolve })` may omit the data argument — an opts object carrying a function `resolve` is recognized as opts, not data. **Security:** *Vendored `@simplewebauthn/server` refreshed 13.3.0 → 13.3.1* — The vendored WebAuthn server bundle (`b.auth.passkey`'s registration/authentication verification) is refreshed to the latest upstream patch, with the MANIFEST version, CPE, and SHA-256 integrity hashes updated and the bundle re-verified.
|
|
14
|
+
|
|
11
15
|
- v0.13.16 (2026-05-27) — **`b.mail.agent` docs now describe the facade accurately, and not-yet-wired verbs point to the primitive to use.** b.mail.agent's module documentation claimed it was "the standardization contract for every mail protocol" that JMAP / IMAP / POP3 all route through — but no protocol server actually dispatches through the agent (the framework's own JMAP EmailSubmission handler composes b.mail.send.deliver directly), and the compose / send / reply / forward, sieve.list / sieve.activate, identity / vacation / mdn.* and export / job / import verbs throw mail-agent/not-implemented. The docs are corrected to describe what the agent is: a mailbox-access facade (RBAC + posture + audit + dispatch around a mail store) whose read surface plus the mailbox-mutation and Sieve-upload methods are wired, with the remaining verbs not yet routed through it. Those verbs' error message now names the underlying primitive to compose directly (b.mail.send.deliver, b.mail.sieve, b.mailMdn, …) instead of citing a version tag that had long passed. The public WIRED_AT export (a method→version map that no longer reflected reality) is replaced by COMPOSE_HINT (a method→primitive-to-compose map). No behaviour change: the same methods are wired or throw exactly as before. **Changed:** *`b.mail.agent` documentation corrected; not-implemented errors point to the primitive to compose* — The `@module` / `@card` no longer claim the agent is the universal protocol-dispatch contract — it's documented as a mailbox-access facade with a wired read + mutation + Sieve-upload surface, and the compose/send/identity/vacation/MDN/export verbs documented as not yet routed through it (compose the underlying primitive directly until a protocol server adopts the agent). The `mail-agent/not-implemented` error now names that primitive (e.g. `b.mail.send.deliver`) rather than a passed version tag. **Removed:** *`b.mail.agent.WIRED_AT` export replaced by `COMPOSE_HINT`* — The `WIRED_AT` export mapped each method to a framework version that was supposed to "light it up" — versions that have all shipped without the wiring, so the map was misleading. It is replaced by `COMPOSE_HINT`, mapping each not-yet-wired method to the primitive an operator composes directly. Operators reading `b.mail.agent.WIRED_AT` should read `b.mail.agent.COMPOSE_HINT` instead (pre-1.0: no compatibility shim).
|
|
12
16
|
|
|
13
17
|
- v0.13.15 (2026-05-27) — **Corrected more source citations and made deferred/reserved options honest in their docs.** A second accuracy pass over source threat-annotations and option docs. Three citation corrections: the base64url strict-decode guard cited CVE-2022-0235 (which is actually a node-fetch cookie-leak, unrelated) — it now names the weakness class it defends (CWE-347 / CWE-1286 signature canonicalization); the glob consecutive-wildcard ReDoS cap cited the wrong library (the CVE-2026-26996 ReDoS is minimatch, not picomatch — the adjacent picomatch one is CVE-2026-33671); and CVE-2026-32178 is reframed to the CWE-138 header-injection-spoofing class the public record actually documents (and dropped from the end-of-data SMTP-smuggling list, which is a different class). Several options/statuses are now honest about not-yet-implemented surface: b.archive.read.zip.fromTrustedStream is marked experimental (its methods throw and its options aren't honored yet — the example now shows the supported buffer-then-random-access path); b.acme revokeCert's useCertKey / certPrivateKey are marked reserved (the cert-key path throws; account-key signing is the supported default); and a stale message claiming passkey break-glass factors were a future feature is removed (passkeys are a live allowed factor). No runtime behaviour changes beyond message/doc text. **Changed:** *Deferred / reserved surface now documented honestly* — `b.archive.read.zip.fromTrustedStream` is marked `experimental` — its `inspect`/`entries`/`extract` throw and its `bombPolicy`/`audit` options aren't honored yet; the documented example now shows the supported path (buffer the stream, then use the random-access reader). `b.acme` `revokeCert`'s `useCertKey` / `certPrivateKey` options are marked reserved (the cert-key-signed-revocation path throws; account-key signing, the default, covers mainstream CAs). A `b.breakGlass` policy error and comment that called passkey factors a future feature are corrected — passkeys are a live allowed factor. **Fixed:** *Corrected misattributed CVE citations in source threat-annotations* — `b.crypto.fromBase64Url`'s strict-decode guard cited CVE-2022-0235 (a node-fetch header-leak, unrelated to base64/JWT decoding); it now cites the weakness class it actually defends — CWE-347 / CWE-1286 signature canonicalization. `b.guardRegex`'s consecutive-`*` cap attributed CVE-2026-26996 to picomatch; that ReDoS is in minimatch (the picomatch ReDoS it also defends is CVE-2026-33671) — the library name is corrected. CVE-2026-32178 is reframed to the CWE-138 header-injection spoofing class the public advisory documents, and removed from the end-of-data SMTP-smuggling trio (a distinct class). No behaviour change — the defenses are unchanged.
|
|
@@ -125,7 +125,7 @@ The framework bundles the surface a typical Node app reaches for. Every primitiv
|
|
|
125
125
|
- Rate-limit
|
|
126
126
|
- Security headers with `Permissions-Policy` defaults denying storage-access / browsing-topics / private-aggregation / controlled-frame
|
|
127
127
|
- CSP nonce
|
|
128
|
-
- Body parser
|
|
128
|
+
- Body parser — JSON / urlencoded / text / multipart; multipart file parts stream to a tmp dir or buffer in memory (`storage: "memory"`) for read-only / serverless filesystems
|
|
129
129
|
- Compression
|
|
130
130
|
- SSE
|
|
131
131
|
- Request log
|