Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Checklist
- [ ] Did you write some relevant docs about this change (if it's a new feature)?
- [ ] Did you write a regression test to reproduce the bug (if it's a bug fix)?
- [ ] Did you write some tests for this change (if it's a new feature)?
- [ ] Did you run `deno task test-all` on your machine?
- [ ] Did you run `mise test` on your machine?


Additional notes
Expand Down
1 change: 1 addition & 0 deletions .hongdown.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ exclude = [
"CLAUDE.md",
"GEMINI.md",
"WARP.md",
"packages/fedify/src/cfworkers/**",
]

[heading]
Expand Down
10 changes: 5 additions & 5 deletions packages/amqp/src/mq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ export interface AmqpMessageQueueOptions {
* The name of the queue to use. Defaults to `"fedify_queue"`.
* @default `"fedify_queue"`
*/
queue?: string;
readonly queue?: string;

/**
* The prefix to use for the delayed queue. Defaults to `"fedify_delayed_"`.
* Defaults to `"fedify_delayed_"`.
* @default `"fedify_delayed_"`
*/
delayedQueuePrefix?: string;
readonly delayedQueuePrefix?: string;

/**
* Whether the queue will survive a broker restart. Defaults to `true`.
* @default `true`
*/
durable?: boolean;
readonly durable?: boolean;

/**
* Whether to use native retrial mechanism. If set to `true`, the queue will
Expand All @@ -45,7 +45,7 @@ export interface AmqpMessageQueueOptions {
* @default `false`
* @since 0.3.0
*/
nativeRetrial?: boolean;
readonly nativeRetrial?: boolean;
}

/**
Expand Down Expand Up @@ -135,7 +135,7 @@ export class AmqpMessageQueue implements MessageQueue {

async enqueueMany(
// deno-lint-ignore no-explicit-any
messages: any[],
messages: readonly any[],
options?: MessageQueueEnqueueOptions,
): Promise<void> {
const channel = await this.#getSenderChannel();
Expand Down
2 changes: 1 addition & 1 deletion packages/cfworkers/src/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class WorkersMessageQueue implements MessageQueue {

enqueueMany(
// deno-lint-ignore no-explicit-any
messages: any[],
messages: readonly any[],
options?: MessageQueueEnqueueOptions,
): Promise<void> {
const requests: MessageSendRequest[] = messages.map((msg) => ({
Expand Down
6 changes: 3 additions & 3 deletions packages/fedify/src/federation/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { encodeHex } from "byte-encodings/hex";
* A page of items.
*/
export interface PageItems<TItem> {
prevCursor?: string | null;
nextCursor?: string | null;
items: TItem[];
readonly prevCursor?: string | null;
readonly nextCursor?: string | null;
readonly items: readonly TItem[];
}

/**
Expand Down
10 changes: 5 additions & 5 deletions packages/fedify/src/federation/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ export interface InboxContext<TContextData> extends Context<TContextData> {
* inbox, it is `null`.
* @since 1.2.0
*/
recipient: string | null;
readonly recipient: string | null;

/**
* Creates a new context with the same properties as this one,
Expand Down Expand Up @@ -783,7 +783,7 @@ export interface SendActivityOptions {
*
* @since 0.9.0
*/
excludeBaseUris?: URL[];
readonly excludeBaseUris?: readonly URL[];
}

/**
Expand Down Expand Up @@ -876,15 +876,15 @@ export interface ActorKeyPair extends CryptoKeyPair {
/**
* The URI of the public key, which is used for verifying HTTP Signatures.
*/
keyId: URL;
readonly keyId: URL;

/**
* A {@link CryptographicKey} instance of the public key.
*/
cryptographicKey: CryptographicKey;
readonly cryptographicKey: CryptographicKey;

/**
* A {@link Multikey} instance of the public key.
*/
multikey: Multikey;
readonly multikey: Multikey;
}
4 changes: 2 additions & 2 deletions packages/fedify/src/federation/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ export async function handleCollection<
* @returns The filtered items as Objects, Links, or URLs.
*/
function filterCollectionItems<TItem extends Object | Link | Recipient | URL>(
items: TItem[],
items: readonly TItem[],
collectionName: string,
filterPredicate?: (item: TItem) => boolean,
): (Object | Link | URL)[] {
Expand Down Expand Up @@ -1319,7 +1319,7 @@ class CustomCollectionHandler<
* @param items The items to filter.
* @returns The filtered items.
*/
filterItems(items: TItem[]): (Object | Link | URL)[] {
filterItems(items: readonly TItem[]): (Object | Link | URL)[] {
return filterCollectionItems(items, this.name, this.filterPredicate);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/fedify/src/federation/kv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ export interface KvStoreListEntry {
/**
* The key of the entry.
*/
key: KvKey;
readonly key: KvKey;

/**
* The value of the entry.
*/
value: unknown;
readonly value: unknown;
}

/**
Expand Down
14 changes: 7 additions & 7 deletions packages/fedify/src/federation/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,21 @@ export interface FederationQueueOptions {
* The message queue for incoming activities. If not provided, incoming
* activities will not be queued and will be processed immediately.
*/
inbox?: MessageQueue;
readonly inbox?: MessageQueue;

/**
* The message queue for outgoing activities. If not provided, outgoing
* activities will not be queued and will be sent immediately.
*/
outbox?: MessageQueue;
readonly outbox?: MessageQueue;

/**
* The message queue for fanning out outgoing activities. If not provided,
* outgoing activities will not be fanned out in the background, but will be
* fanned out immediately, which causes slow response times on
* {@link Context.sendActivity} calls.
*/
fanout?: MessageQueue;
readonly fanout?: MessageQueue;
}

/**
Expand All @@ -154,20 +154,20 @@ export interface FederationKvPrefixes {
* processed or not.
* @default `["_fedify", "activityIdempotence"]`
*/
activityIdempotence: KvKey;
readonly activityIdempotence: KvKey;

/**
* The key prefix used for storing remote JSON-LD documents.
* @default `["_fedify", "remoteDocument"]`
*/
remoteDocument: KvKey;
readonly remoteDocument: KvKey;

/**
* The key prefix used for caching public keys.
* @default `["_fedify", "publicKey"]`
* @since 0.12.0
*/
publicKey: KvKey;
readonly publicKey: KvKey;

/**
* The key prefix used for caching HTTP Message Signatures specs.
Expand All @@ -176,7 +176,7 @@ export interface FederationKvPrefixes {
* @default `["_fedify", "httpMessageSignaturesSpec"]`
* @since 1.6.0
*/
httpMessageSignaturesSpec: KvKey;
readonly httpMessageSignaturesSpec: KvKey;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/fedify/src/federation/mq.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ test("MessageQueue.nativeRetrial", async (t) => {
return this.#queue.send(message);
}

enqueueMany(messages: unknown[]): Promise<void> {
return this.#queue.sendBatch(messages);
enqueueMany(messages: readonly unknown[]): Promise<void> {
return this.#queue.sendBatch(messages as unknown[]);
}

listen(): Promise<void> {
Expand Down
6 changes: 3 additions & 3 deletions packages/fedify/src/federation/mq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export interface MessageQueue {
* @param options Additional options for enqueuing the messages.
*/
enqueueMany?: (
messages: any[],
messages: readonly any[],
options?: MessageQueueEnqueueOptions,
) => Promise<void>;

Expand Down Expand Up @@ -138,7 +138,7 @@ export class InProcessMessageQueue implements MessageQueue {
}

enqueueMany(
messages: any[],
messages: readonly any[],
options?: MessageQueueEnqueueOptions,
): Promise<void> {
if (messages.length === 0) return Promise.resolve();
Expand Down Expand Up @@ -243,7 +243,7 @@ export class ParallelMessageQueue implements MessageQueue {
}

async enqueueMany(
messages: any[],
messages: readonly any[],
options?: MessageQueueEnqueueOptions,
): Promise<void> {
if (this.queue.enqueueMany == null) {
Expand Down
71 changes: 38 additions & 33 deletions packages/fedify/src/federation/queue.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export interface SenderKeyJwkPair {
keyId: string;
privateKey: JsonWebKey;
readonly keyId: string;
readonly privateKey: JsonWebKey;
}

/**
Expand All @@ -15,41 +15,46 @@ export interface SenderKeyJwkPair {
export type Message = FanoutMessage | OutboxMessage | InboxMessage;

export interface FanoutMessage {
type: "fanout";
id: ReturnType<typeof crypto.randomUUID>;
baseUrl: string;
keys: SenderKeyJwkPair[];
inboxes: Record<string, { actorIds: string[]; sharedInbox: boolean }>;
activity: unknown;
activityId?: string;
activityType: string;
collectionSync?: string;
traceContext: Record<string, string>;
readonly type: "fanout";
readonly id: ReturnType<typeof crypto.randomUUID>;
readonly baseUrl: string;
readonly keys: readonly SenderKeyJwkPair[];
readonly inboxes: Readonly<
Record<
string,
{ readonly actorIds: readonly string[]; readonly sharedInbox: boolean }
>
>;
readonly activity: unknown;
readonly activityId?: string;
readonly activityType: string;
readonly collectionSync?: string;
readonly traceContext: Readonly<Record<string, string>>;
}

export interface OutboxMessage {
type: "outbox";
id: ReturnType<typeof crypto.randomUUID>;
baseUrl: string;
keys: SenderKeyJwkPair[];
activity: unknown;
activityId?: string;
activityType: string;
inbox: string;
sharedInbox: boolean;
started: string;
attempt: number;
headers: Record<string, string>;
traceContext: Record<string, string>;
readonly type: "outbox";
readonly id: ReturnType<typeof crypto.randomUUID>;
readonly baseUrl: string;
readonly keys: readonly SenderKeyJwkPair[];
readonly activity: unknown;
readonly activityId?: string;
readonly activityType: string;
readonly inbox: string;
readonly sharedInbox: boolean;
readonly started: string;
readonly attempt: number;
readonly headers: Readonly<Record<string, string>>;
readonly traceContext: Readonly<Record<string, string>>;
}

export interface InboxMessage {
type: "inbox";
id: ReturnType<typeof crypto.randomUUID>;
baseUrl: string;
activity: unknown;
started: string;
attempt: number;
identifier: string | null;
traceContext: Record<string, string>;
readonly type: "inbox";
readonly id: ReturnType<typeof crypto.randomUUID>;
readonly baseUrl: string;
readonly activity: unknown;
readonly started: string;
readonly attempt: number;
readonly identifier: string | null;
readonly traceContext: Readonly<Record<string, string>>;
}
Loading
Loading