@blamejs/core 0.7.83 → 0.7.84
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 +2 -0
- package/lib/crypto.js +41 -0
- package/package.json +1 -1
- package/sbom.cyclonedx.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,8 @@ upgrading across more than a few patches at a time.
|
|
|
8
8
|
|
|
9
9
|
## v0.7.x
|
|
10
10
|
|
|
11
|
+
- **0.7.84** (2026-05-06) — `b.crypto.sri(content, { algorithm? })` — Subresource Integrity hash builder per W3C SRI 1.0. Operators emit `<script integrity="sha384-...">` and `<link integrity="sha384-...">` to defend against CDN compromise + ISP MITM injection — the browser refuses to load a resource whose actual hash diverges from the integrity attribute. Default algorithm is `sha384` (W3C §3.2 — collision margin without sha512's 64-byte overhead); `sha256` and `sha512` also accepted, anything else refused. Accepts `Buffer` / `Uint8Array` / `string` / array of those — array inputs emit multiple space-separated integrity tokens per W3C §3.3 multi-integrity (browser picks the strongest it recognizes). Returns the standard `sha###-<base64>` format ready to paste into the `integrity=""` attribute.
|
|
12
|
+
|
|
11
13
|
- **0.7.83** (2026-05-06) — `b.auth.oauth.endSessionUrl()` (OpenID Connect RP-Initiated Logout) + `b.auth.oauth.pushAuthorizationRequest()` (RFC 9126 PAR). **`endSessionUrl({ idTokenHint?, postLogoutRedirectUri?, state?, logoutHint?, uiLocales?, clientId?, extraParams? })`** builds the URL the operator's `/logout` route redirects the user-agent to so the IdP terminates the session and bounces back to the operator's app. The IdP's `end_session_endpoint` is read from the OIDC discovery document or operator-supplied at `create({ endSessionEndpoint })`. **`pushAuthorizationRequest({ state?, nonce?, prompt?, loginHint?, maxAge?, extraParams? })`** POSTs the authorization-request parameters directly to the IdP's PAR endpoint (mTLS or client-secret authenticated) and returns `{ url, state, nonce, verifier, challenge, requestUri, expiresIn }` — the browser-side redirect URL is `<authorizationEndpoint>?client_id=...&request_uri=...`. Defends against authorization-request parameter tampering by an MITM at the user-agent + against URL-length overflow on long authorization requests (request_uri reference is short). The PAR endpoint is read from the discovery doc's `pushed_authorization_request_endpoint` or operator-supplied at `create({ pushedAuthorizationRequestEndpoint })`. Both helpers throw `auth-oauth/no-end-session-endpoint` / `auth-oauth/no-par-endpoint` when neither the discovery doc nor the operator opts supply the endpoint.
|
|
12
14
|
|
|
13
15
|
- **0.7.82** (2026-05-06) — `b.mail.bimi` — BIMI record builder + verifier (RFC 9091). BIMI publishes a sender's brand logo URL in DNS so receiving MTAs can render it next to the message in supported clients (Gmail, Yahoo, Apple Mail). **`b.mail.bimi.recordShape({ logoUrl, vmcUrl?, selector? })`** produces the canonical `v=BIMI1; l=https://...; a=https://...` TXT-record string per RFC 9091 §4. Both `l=` (SVG logo URL) and `a=` (Verified Mark Certificate URL per RFC 9091 §6) are HTTPS-required (refuses `http://`). All field values are CR/LF/NUL/semicolon-screened so a hostile URL can't inject a record-separator into the published TXT. **`b.mail.bimi.fetchPolicy(domain, { selector?, dnsLookup? })`** queries `<selector>._bimi.<domain>` (default selector `"default"`) and returns the structured record `{ v, l, a }` or `null` when no policy is published / record is malformed. **`b.mail.bimi.parseRecord(text)`** parses any operator-supplied TXT body — semicolon-separated `key=value` pairs per RFC 9091 §4. The framework does NOT validate the SVG / VMC contents against the RFC §5/§6 profiles — operators feed those to their own asset pipeline; the fetch primitive is a thin DNS lookup that returns the structured record so an operator dashboard or SMTP send-time preflight can verify the publication. BIMI is layered on a passing DMARC posture (the receiver requires DMARC quarantine/reject); operators with the existing `b.mail.dmarc` posture set up benefit from BIMI rendering immediately on receivers that honor it.
|
package/lib/crypto.js
CHANGED
|
@@ -95,6 +95,46 @@ function kdf(input, outputLength) { return hash(input, "shake256", outputLength)
|
|
|
95
95
|
function generateBytes(byteLength) { return Buffer.from(random(byteLength)); }
|
|
96
96
|
function generateToken(byteLength) { return random(byteLength || 32).toString("hex"); }
|
|
97
97
|
|
|
98
|
+
// ---- Subresource Integrity (W3C SRI 1.0) ----
|
|
99
|
+
//
|
|
100
|
+
// b.crypto.sri(content, { algorithm? }) — returns a `sha###-base64`
|
|
101
|
+
// integrity attribute string operators paste into <script integrity="...">
|
|
102
|
+
// or <link integrity="..."> tags. Defends against CDN compromise + ISP
|
|
103
|
+
// MITM injection — the browser refuses to load the resource when its
|
|
104
|
+
// hash diverges from the integrity attribute.
|
|
105
|
+
//
|
|
106
|
+
// W3C SRI 1.0 §3.2 lists sha256 / sha384 / sha512 as the supported
|
|
107
|
+
// digest algorithms; sha384 is the recommended default (collision
|
|
108
|
+
// margin without sha512's 64-byte overhead).
|
|
109
|
+
//
|
|
110
|
+
// b.crypto.sri(scriptBuffer, { algorithm: "sha384" })
|
|
111
|
+
// → "sha384-AbCdEf...="
|
|
112
|
+
//
|
|
113
|
+
// b.crypto.sri(["a", "b"], { algorithm: "sha384" }) // array → multi-hash
|
|
114
|
+
// → "sha384-X1... sha384-X2..." (per W3C §3.3 multi-integrity)
|
|
115
|
+
var SRI_ALGORITHMS = { "sha256": "sha256", "sha384": "sha384", "sha512": "sha512" };
|
|
116
|
+
|
|
117
|
+
function sri(content, opts) {
|
|
118
|
+
opts = opts || {};
|
|
119
|
+
var algorithm = (opts.algorithm || "sha384").toLowerCase();
|
|
120
|
+
if (!SRI_ALGORITHMS[algorithm]) {
|
|
121
|
+
throw new Error("crypto.sri: unsupported algorithm '" + algorithm +
|
|
122
|
+
"' (W3C SRI 1.0 §3.2 supports sha256/sha384/sha512)");
|
|
123
|
+
}
|
|
124
|
+
// Array input — emit multiple integrity tokens space-separated per
|
|
125
|
+
// W3C §3.3 (browser picks the strongest one it recognizes).
|
|
126
|
+
if (Array.isArray(content)) {
|
|
127
|
+
return content.map(function (c) { return sri(c, opts); }).join(" ");
|
|
128
|
+
}
|
|
129
|
+
var buf;
|
|
130
|
+
if (Buffer.isBuffer(content)) buf = content;
|
|
131
|
+
else if (typeof content === "string") buf = Buffer.from(content, "utf8");
|
|
132
|
+
else if (content instanceof Uint8Array) buf = Buffer.from(content);
|
|
133
|
+
else throw new Error("crypto.sri: content must be a Buffer, Uint8Array, string, or array of those");
|
|
134
|
+
var digest = nodeCrypto.createHash(algorithm).update(buf).digest("base64");
|
|
135
|
+
return algorithm + "-" + digest;
|
|
136
|
+
}
|
|
137
|
+
|
|
98
138
|
// ---- Key generation ----
|
|
99
139
|
function generateEncryptionKeyPair() {
|
|
100
140
|
var mlkem = generateKeyPair("ml-kem-1024");
|
|
@@ -454,6 +494,7 @@ var SUPPORTED_KEM_ALGORITHMS = Object.freeze([
|
|
|
454
494
|
]);
|
|
455
495
|
|
|
456
496
|
module.exports = {
|
|
497
|
+
sri: sri,
|
|
457
498
|
// Hashing
|
|
458
499
|
sha3Hash: sha3Hash,
|
|
459
500
|
hmacSha3: hmacSha3,
|
package/package.json
CHANGED
package/sbom.cyclonedx.json
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
|
|
3
3
|
"bomFormat": "CycloneDX",
|
|
4
4
|
"specVersion": "1.5",
|
|
5
|
-
"serialNumber": "urn:uuid:
|
|
5
|
+
"serialNumber": "urn:uuid:4072392e-af80-4cf0-a9f7-095c0d6638e0",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-05-06T06:
|
|
8
|
+
"timestamp": "2026-05-06T06:11:44.785Z",
|
|
9
9
|
"lifecycles": [
|
|
10
10
|
{
|
|
11
11
|
"phase": "build"
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
}
|
|
20
20
|
],
|
|
21
21
|
"component": {
|
|
22
|
-
"bom-ref": "@blamejs/core@0.7.
|
|
22
|
+
"bom-ref": "@blamejs/core@0.7.84",
|
|
23
23
|
"type": "library",
|
|
24
24
|
"name": "blamejs",
|
|
25
|
-
"version": "0.7.
|
|
25
|
+
"version": "0.7.84",
|
|
26
26
|
"scope": "required",
|
|
27
27
|
"author": "blamejs contributors",
|
|
28
28
|
"description": "The Node framework that owns its stack.",
|
|
29
|
-
"purl": "pkg:npm/%40blamejs/core@0.7.
|
|
29
|
+
"purl": "pkg:npm/%40blamejs/core@0.7.84",
|
|
30
30
|
"properties": [],
|
|
31
31
|
"externalReferences": [
|
|
32
32
|
{
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"components": [],
|
|
55
55
|
"dependencies": [
|
|
56
56
|
{
|
|
57
|
-
"ref": "@blamejs/core@0.7.
|
|
57
|
+
"ref": "@blamejs/core@0.7.84",
|
|
58
58
|
"dependsOn": []
|
|
59
59
|
}
|
|
60
60
|
]
|