@fedify/fedify 0.9.0-dev.182 → 0.9.0-dev.184
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of @fedify/fedify might be problematic. Click here for more details.
- package/CHANGES.md +4 -0
- package/esm/federation/handler.js +3 -2
- package/esm/federation/send.js +2 -2
- package/esm/sig/http.js +1 -1
- package/package.json +1 -1
- package/types/federation/handler.d.ts.map +1 -1
- package/types/sig/http.d.ts +1 -1
package/CHANGES.md
CHANGED
@@ -55,6 +55,10 @@ To be released.
|
|
55
55
|
- Deprecated `VerifyOptions` interface. Use `VerifyRequestOptions`
|
56
56
|
instead.
|
57
57
|
|
58
|
+
- When signing an HTTP request, the `algorithm` parameter is now added to
|
59
|
+
the `Signature` header. This change improves the compatibility with
|
60
|
+
Misskey and other implementations that require the `algorithm` parameter.
|
61
|
+
|
58
62
|
- Added more log messages using the [LogTape] library. Currently the below
|
59
63
|
logger categories are used:
|
60
64
|
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
2
2
|
import { getLogger } from "@logtape/logtape";
|
3
3
|
import { accepts } from "../deps/jsr.io/@std/http/0.224.2/negotiation.js";
|
4
|
-
import {
|
4
|
+
import { verifyRequest } from "../sig/http.js";
|
5
|
+
import { doesActorOwnKey } from "../sig/owner.js";
|
5
6
|
import { Activity, Link, Object, OrderedCollection, OrderedCollectionPage, } from "../vocab/vocab.js";
|
6
7
|
export function acceptsJsonLd(request) {
|
7
8
|
const types = accepts(request);
|
@@ -176,7 +177,7 @@ export async function handleInbox(request, { handle, context, kv, kvPrefix, acto
|
|
176
177
|
return await onNotFound(request);
|
177
178
|
}
|
178
179
|
}
|
179
|
-
const key = await
|
180
|
+
const key = await verifyRequest(request, {
|
180
181
|
...context,
|
181
182
|
timeWindow: signatureTimeWindow,
|
182
183
|
});
|
package/esm/federation/send.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { getLogger } from "@logtape/logtape";
|
2
|
-
import {
|
2
|
+
import { signRequest } from "../sig/http.js";
|
3
3
|
/**
|
4
4
|
* Extracts the inbox URLs from recipients.
|
5
5
|
* @param parameters The parameters to extract the inboxes.
|
@@ -43,7 +43,7 @@ export async function sendActivity({ activity, privateKey, keyId, inbox, context
|
|
43
43
|
headers,
|
44
44
|
body: JSON.stringify(jsonLd),
|
45
45
|
});
|
46
|
-
request = await
|
46
|
+
request = await signRequest(request, privateKey, keyId);
|
47
47
|
const response = await fetch(request);
|
48
48
|
if (!response.ok) {
|
49
49
|
let error;
|
package/esm/sig/http.js
CHANGED
@@ -41,7 +41,7 @@ export async function signRequest(request, privateKey, keyId) {
|
|
41
41
|
.map(([name, value]) => `${name}: ${value.trim()}`).join("\n");
|
42
42
|
// TODO: support other than RSASSA-PKCS1-v1_5:
|
43
43
|
const signature = await dntShim.crypto.subtle.sign("RSASSA-PKCS1-v1_5", privateKey, new TextEncoder().encode(message));
|
44
|
-
const sigHeader = `keyId="${keyId.href}",headers="${headerNames.join(" ")}",signature="${encodeBase64(signature)}"`;
|
44
|
+
const sigHeader = `keyId="${keyId.href}",algorithm="rsa-sha256",headers="${headerNames.join(" ")}",signature="${encodeBase64(signature)}"`;
|
45
45
|
headers.set("Signature", sigHeader);
|
46
46
|
return new Request(request, {
|
47
47
|
headers,
|
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/federation/handler.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/federation/handler.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAK5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EACL,QAAQ,EACR,IAAI,EACJ,MAAM,EAGP,MAA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AAC;IACF,iBAAiB,CAAC,EAAE,iBAAiB,CAAC,YAAY,CAAC,CAAC;IACpD,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3D,mBAAmB,EAAE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;CACpD;AAED,wBAAsB,WAAW,CAAC,YAAY,EAC5C,OAAO,EAAE,OAAO,EAChB,EACE,MAAM,EACN,OAAO,EACP,EAAE,EACF,QAAQ,EACR,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,UAAU,EACV,mBAAmB,GACpB,EAAE,sBAAsB,CAAC,YAAY,CAAC,GACtC,OAAO,CAAC,QAAQ,CAAC,CAgInB;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,aAAa,EAAE,cAAc,CAAC;CAC/B;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,QAAQ,CAAC,CAOnB;AAED;;;;;;;;GAQG;AACH,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAK1B"}
|
package/types/sig/http.d.ts
CHANGED
@@ -14,7 +14,7 @@ import { CryptographicKey } from "../vocab/vocab.js";
|
|
14
14
|
*/
|
15
15
|
export declare function signRequest(request: Request, privateKey: dntShim.CryptoKey, keyId: URL): Promise<Request>;
|
16
16
|
/**
|
17
|
-
* Options for {@link
|
17
|
+
* Options for {@link verifyRequest}.
|
18
18
|
*/
|
19
19
|
export interface VerifyRequestOptions {
|
20
20
|
/**
|