@getstrata/core 2.2.43 → 2.2.44
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
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @getstrata/core changelog
|
|
2
2
|
|
|
3
|
+
## 2.2.44
|
|
4
|
+
|
|
5
|
+
Generate JSON registration, verification/resend, reset and password-confirmed MFA for API/SPA cookie starters; share guarded MFA persistence with HTML, reject malformed TOTP secrets, and extend installed-app SMTP, replay, revocation and compiler coverage without changing HTML contracts.
|
|
6
|
+
|
|
7
|
+
Preserve private/no-store headers when the tenancy boundary maps an HTTP error to JSON, without changing its status/body or transaction rollback. Rebuild the starter in standalone generated-app verification to prevent stale output from producing false green results.
|
|
8
|
+
|
|
9
|
+
Honor the explicit API JSON error context during password confirmation even when a client sends HTML/HTMX headers; preserve automatic HTML behavior outside that context.
|
|
10
|
+
|
|
11
|
+
Use the shared JSON parser for signed password reset so malformed input is a controlled 400 and does not consume the reset proof.
|
|
12
|
+
|
|
3
13
|
## 2.2.43
|
|
4
14
|
|
|
5
15
|
Add `afterCommit` for process-local effects after the outermost managed transaction, sharing savepoint rollback and tenant replay with model events. Generated auth SMTP uses this boundary even inside RLS request transactions; callback failures propagate after commit without undoing persisted accounts. Durable delivery still requires the SQL outbox.
|
|
@@ -1588,6 +1588,12 @@ function verifyTotp(secret, token, window = 1) {
|
|
|
1588
1588
|
if (!/^\d{6}$/u.test(normalized)) {
|
|
1589
1589
|
return false;
|
|
1590
1590
|
}
|
|
1591
|
+
try {
|
|
1592
|
+
if (decodeBase32(secret).length === 0)
|
|
1593
|
+
return false;
|
|
1594
|
+
} catch {
|
|
1595
|
+
return false;
|
|
1596
|
+
}
|
|
1591
1597
|
const timestep = Math.floor(Date.now() / 30000);
|
|
1592
1598
|
let matched = false;
|
|
1593
1599
|
for (let offset = -window;offset <= window; offset += 1) {
|
|
@@ -702,6 +702,12 @@ function verifyTotp(secret, token, window = 1) {
|
|
|
702
702
|
if (!/^\d{6}$/u.test(normalized)) {
|
|
703
703
|
return false;
|
|
704
704
|
}
|
|
705
|
+
try {
|
|
706
|
+
if (decodeBase32(secret).length === 0)
|
|
707
|
+
return false;
|
|
708
|
+
} catch {
|
|
709
|
+
return false;
|
|
710
|
+
}
|
|
705
711
|
const timestep = Math.floor(Date.now() / 30000);
|
|
706
712
|
let matched = false;
|
|
707
713
|
for (let offset = -window;offset <= window; offset += 1) {
|
|
@@ -1,4 +1,31 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
var __esm = (fn, res, err) => () => {
|
|
3
|
+
if (fn)
|
|
4
|
+
try {
|
|
5
|
+
res = fn(fn = 0);
|
|
6
|
+
} catch (e) {
|
|
7
|
+
err = [e];
|
|
8
|
+
}
|
|
9
|
+
if (err)
|
|
10
|
+
throw err[0];
|
|
11
|
+
return res;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// ../../src/core/runtime/asyncContextStore.ts
|
|
15
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
16
|
+
function createAsyncContextStore(key) {
|
|
17
|
+
const symbol = Symbol.for(key);
|
|
18
|
+
const globalRecord = globalThis;
|
|
19
|
+
const existing = globalRecord[symbol];
|
|
20
|
+
if (existing) {
|
|
21
|
+
return existing;
|
|
22
|
+
}
|
|
23
|
+
const store = new AsyncLocalStorage;
|
|
24
|
+
globalRecord[symbol] = store;
|
|
25
|
+
return store;
|
|
26
|
+
}
|
|
27
|
+
var init_asyncContextStore = () => {};
|
|
28
|
+
|
|
2
29
|
// ../../src/core/http/requirePasswordConfirmMiddleware.ts
|
|
3
30
|
import { resolveUserId } from "@getstrata/core/auth/accessControl";
|
|
4
31
|
import { currentAuthUser } from "@getstrata/core/auth/authContext";
|
|
@@ -32,6 +59,19 @@ function requestPrefersJson(request) {
|
|
|
32
59
|
return false;
|
|
33
60
|
}
|
|
34
61
|
|
|
62
|
+
// ../../src/core/http/requestMetaContext.ts
|
|
63
|
+
init_asyncContextStore();
|
|
64
|
+
var requestMetaContext = createAsyncContextStore("@getstrata/requestMetaContext");
|
|
65
|
+
function runWithRequestMeta(meta, callback) {
|
|
66
|
+
return requestMetaContext.run(meta, callback);
|
|
67
|
+
}
|
|
68
|
+
function currentRequestMeta() {
|
|
69
|
+
return requestMetaContext.getStore() ?? {
|
|
70
|
+
ipAddress: null,
|
|
71
|
+
userAgent: null
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
35
75
|
// ../../src/core/http/safeInternalPath.ts
|
|
36
76
|
var NESTED_REDIRECT_KEYS = new Set(["redirect", "next", "return", "returnTo", "return_to"]);
|
|
37
77
|
function looksLikeExternalTarget(value) {
|
|
@@ -101,8 +141,9 @@ var PASSWORD_CONFIRM_PATH = "/confirm-password";
|
|
|
101
141
|
function createRequirePasswordConfirmMiddleware() {
|
|
102
142
|
return async (request, next) => {
|
|
103
143
|
const user = currentAuthUser();
|
|
144
|
+
const json = currentRequestMeta().errorFormat === "json" || requestPrefersJson(request);
|
|
104
145
|
if (!user) {
|
|
105
|
-
if (
|
|
146
|
+
if (json) {
|
|
106
147
|
return errorResponse(new UnauthorizedError("Authentication required."));
|
|
107
148
|
}
|
|
108
149
|
return Response.redirect("/login", 302);
|
|
@@ -111,7 +152,7 @@ function createRequirePasswordConfirmMiddleware() {
|
|
|
111
152
|
if (hasFreshPasswordConfirmation(request, userId, user.authVersion)) {
|
|
112
153
|
return await next();
|
|
113
154
|
}
|
|
114
|
-
if (
|
|
155
|
+
if (json) {
|
|
115
156
|
return errorResponse(new HttpError(423, PASSWORD_CONFIRM_MESSAGE));
|
|
116
157
|
}
|
|
117
158
|
const url = new URL(request.url);
|
|
@@ -164,6 +164,12 @@ function verifyTotp(secret, token, window = 1) {
|
|
|
164
164
|
if (!/^\d{6}$/u.test(normalized)) {
|
|
165
165
|
return false;
|
|
166
166
|
}
|
|
167
|
+
try {
|
|
168
|
+
if (decodeBase32(secret).length === 0)
|
|
169
|
+
return false;
|
|
170
|
+
} catch {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
167
173
|
const timestep = Math.floor(Date.now() / 30000);
|
|
168
174
|
let matched = false;
|
|
169
175
|
for (let offset = -window;offset <= window; offset += 1) {
|
package/dist/index.js
CHANGED
|
@@ -1763,6 +1763,12 @@ function verifyTotp(secret, token, window = 1) {
|
|
|
1763
1763
|
if (!/^\d{6}$/u.test(normalized)) {
|
|
1764
1764
|
return false;
|
|
1765
1765
|
}
|
|
1766
|
+
try {
|
|
1767
|
+
if (decodeBase32(secret).length === 0)
|
|
1768
|
+
return false;
|
|
1769
|
+
} catch {
|
|
1770
|
+
return false;
|
|
1771
|
+
}
|
|
1766
1772
|
const timestep = Math.floor(Date.now() / 30000);
|
|
1767
1773
|
let matched = false;
|
|
1768
1774
|
for (let offset = -window;offset <= window; offset += 1) {
|
|
@@ -16281,7 +16287,7 @@ function createTenantMiddleware(options = {}) {
|
|
|
16281
16287
|
} catch (error) {
|
|
16282
16288
|
const httpError = toHttpError(error);
|
|
16283
16289
|
if (httpError) {
|
|
16284
|
-
return
|
|
16290
|
+
return privateJsonResponse({ error: httpError.message }, { status: httpError.status });
|
|
16285
16291
|
}
|
|
16286
16292
|
throw error;
|
|
16287
16293
|
}
|