@fedify/vocab-runtime
Advanced tools
| /// <reference lib="esnext.temporal" /> | ||
| import { Logger } from "@logtape/logtape"; | ||
| //#region src/request.d.ts | ||
| /** | ||
| * Error thrown when fetching a JSON-LD document failed. | ||
| */ | ||
| declare class FetchError extends Error { | ||
| /** | ||
| * The URL that failed to fetch. | ||
| */ | ||
| url: URL; | ||
| /** | ||
| * The HTTP response that failed, if available. | ||
| */ | ||
| response?: Response; | ||
| /** | ||
| * Constructs a new `FetchError`. | ||
| * | ||
| * @param url The URL that failed to fetch. | ||
| * @param message Error message. | ||
| * @param response The failed HTTP response, if available. | ||
| */ | ||
| constructor(url: URL | string, message?: string, response?: Response); | ||
| } | ||
| /** | ||
| * Options for creating a request. | ||
| * @internal | ||
| */ | ||
| interface CreateRequestOptions { | ||
| userAgent?: GetUserAgentOptions | string; | ||
| } | ||
| /** | ||
| * Creates a request for the given URL. | ||
| * @param url The URL to create the request for. | ||
| * @param options The options for the request. | ||
| * @returns The created request. | ||
| * @internal | ||
| */ | ||
| declare function createActivityPubRequest(url: string, options?: CreateRequestOptions): Request; | ||
| /** | ||
| * Options for making `User-Agent` string. | ||
| * @see {@link getUserAgent} | ||
| * @since 1.3.0 | ||
| */ | ||
| interface GetUserAgentOptions { | ||
| /** | ||
| * An optional software name and version, e.g., `"Hollo/1.0.0"`. | ||
| */ | ||
| software?: string | null; | ||
| /** | ||
| * An optional URL to append to the user agent string. | ||
| * Usually the URL of the ActivityPub instance. | ||
| */ | ||
| url?: string | URL | null; | ||
| } | ||
| /** | ||
| * Gets the user agent string for the given application and URL. | ||
| * @param options The options for making the user agent string. | ||
| * @returns The user agent string. | ||
| * @since 1.3.0 | ||
| */ | ||
| declare function getUserAgent({ | ||
| software, | ||
| url | ||
| }?: GetUserAgentOptions): string; | ||
| /** | ||
| * Logs the request. | ||
| * @param request The request to log. | ||
| * @internal | ||
| */ | ||
| declare function logRequest(logger: Logger, request: Request): void; | ||
| //#endregion | ||
| //#region src/docloader.d.ts | ||
| /** | ||
| * A remote JSON-LD document and its context fetched by | ||
| * a {@link DocumentLoader}. | ||
| */ | ||
| interface RemoteDocument { | ||
| /** | ||
| * The URL of the context document. | ||
| */ | ||
| contextUrl: string | null; | ||
| /** | ||
| * The fetched JSON-LD document. | ||
| */ | ||
| document: unknown; | ||
| /** | ||
| * The URL of the fetched document. | ||
| */ | ||
| documentUrl: string; | ||
| } | ||
| /** | ||
| * Options for {@link DocumentLoader}. | ||
| * @since 1.8.0 | ||
| */ | ||
| interface DocumentLoaderOptions { | ||
| /** | ||
| * An `AbortSignal` for cancellation. | ||
| * @since 1.8.0 | ||
| */ | ||
| signal?: AbortSignal; | ||
| } | ||
| /** | ||
| * A JSON-LD document loader that fetches documents from the Web. | ||
| * @param url The URL of the document to load. | ||
| * @param options The options for the document loader. | ||
| * @returns The loaded remote document. | ||
| */ | ||
| type DocumentLoader = (url: string, options?: DocumentLoaderOptions) => Promise<RemoteDocument>; | ||
| /** | ||
| * A factory function that creates a {@link DocumentLoader} with options. | ||
| * @param options The options for the document loader. | ||
| * @returns The document loader. | ||
| * @since 1.4.0 | ||
| */ | ||
| type DocumentLoaderFactory = (options?: DocumentLoaderFactoryOptions) => DocumentLoader; | ||
| /** | ||
| * Options for {@link DocumentLoaderFactory}. | ||
| * @see {@link DocumentLoaderFactory} | ||
| * @see {@link AuthenticatedDocumentLoaderFactory} | ||
| * @since 1.4.0 | ||
| */ | ||
| interface DocumentLoaderFactoryOptions { | ||
| /** | ||
| * Whether to allow fetching private network addresses. | ||
| * Turned off by default. | ||
| * @default `false`` | ||
| */ | ||
| allowPrivateAddress?: boolean; | ||
| /** | ||
| * Options for making `User-Agent` string. | ||
| * If a string is given, it is used as the `User-Agent` header value. | ||
| * If an object is given, it is passed to {@link getUserAgent} function. | ||
| */ | ||
| userAgent?: GetUserAgentOptions | string; | ||
| /** | ||
| * The maximum number of redirections to follow. | ||
| * @default `20` | ||
| * @since 2.2.0 | ||
| */ | ||
| maxRedirection?: number; | ||
| } | ||
| /** | ||
| * A factory function that creates an authenticated {@link DocumentLoader} for | ||
| * a given identity. This is used for fetching documents that require | ||
| * authentication. | ||
| * @param identity The identity to create the document loader for. | ||
| * The actor's key pair. | ||
| * @param options The options for the document loader. | ||
| * @returns The authenticated document loader. | ||
| * @since 0.4.0 | ||
| */ | ||
| type AuthenticatedDocumentLoaderFactory = (identity: { | ||
| keyId: URL; | ||
| privateKey: CryptoKey; | ||
| }, options?: DocumentLoaderFactoryOptions) => DocumentLoader; | ||
| /** | ||
| * Gets a {@link RemoteDocument} from the given response. | ||
| * @param url The URL of the document to load. | ||
| * @param response The response to get the document from. | ||
| * @param fetch The function to fetch the document. | ||
| * @returns The loaded remote document. | ||
| * @throws {FetchError} If the response is not OK. | ||
| * @internal | ||
| */ | ||
| declare function getRemoteDocument(url: string, response: Response, fetch: (url: string, options?: DocumentLoaderOptions) => Promise<RemoteDocument>): Promise<RemoteDocument>; | ||
| /** | ||
| * Options for {@link getDocumentLoader}. | ||
| * @since 1.3.0 | ||
| */ | ||
| interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions { | ||
| /** | ||
| * Whether to preload the frequently used contexts. | ||
| */ | ||
| skipPreloadedContexts?: boolean; | ||
| } | ||
| /** | ||
| * Creates a JSON-LD document loader that utilizes the browser's `fetch` API. | ||
| * | ||
| * The created loader preloads the below frequently used contexts by default | ||
| * (unless `options.skipPreloadedContexts` is set to `true`): | ||
| * | ||
| * - <https://www.w3.org/ns/activitystreams> | ||
| * - <https://w3id.org/security/v1> | ||
| * - <https://w3id.org/security/data-integrity/v1> | ||
| * - <https://w3id.org/security/data-integrity/v2> | ||
| * - <https://www.w3.org/ns/did/v1> | ||
| * - <https://www.w3.org/ns/cid/v1> | ||
| * - <https://w3id.org/security/multikey/v1> | ||
| * - <https://w3id.org/fep/ef61> | ||
| * - <https://purl.archive.org/socialweb/webfinger> | ||
| * - <http://schema.org/> | ||
| * @param options Options for the document loader. | ||
| * @returns The document loader. | ||
| * @since 1.3.0 | ||
| */ | ||
| declare function getDocumentLoader({ | ||
| allowPrivateAddress, | ||
| maxRedirection, | ||
| skipPreloadedContexts, | ||
| userAgent | ||
| }?: GetDocumentLoaderOptions): DocumentLoader; | ||
| //#endregion | ||
| export { DocumentLoaderOptions as a, getDocumentLoader as c, FetchError as d, GetUserAgentOptions as f, logRequest as h, DocumentLoaderFactoryOptions as i, getRemoteDocument as l, getUserAgent as m, DocumentLoader as n, GetDocumentLoaderOptions as o, createActivityPubRequest as p, DocumentLoaderFactory as r, RemoteDocument as s, AuthenticatedDocumentLoaderFactory as t, CreateRequestOptions as u }; |
| /// <reference lib="esnext.temporal" /> | ||
| import { Logger } from "@logtape/logtape"; | ||
| //#region src/request.d.ts | ||
| /** | ||
| * Error thrown when fetching a JSON-LD document failed. | ||
| */ | ||
| declare class FetchError extends Error { | ||
| /** | ||
| * The URL that failed to fetch. | ||
| */ | ||
| url: URL; | ||
| /** | ||
| * The HTTP response that failed, if available. | ||
| */ | ||
| response?: Response; | ||
| /** | ||
| * Constructs a new `FetchError`. | ||
| * | ||
| * @param url The URL that failed to fetch. | ||
| * @param message Error message. | ||
| * @param response The failed HTTP response, if available. | ||
| */ | ||
| constructor(url: URL | string, message?: string, response?: Response); | ||
| } | ||
| /** | ||
| * Options for creating a request. | ||
| * @internal | ||
| */ | ||
| interface CreateRequestOptions { | ||
| userAgent?: GetUserAgentOptions | string; | ||
| } | ||
| /** | ||
| * Creates a request for the given URL. | ||
| * @param url The URL to create the request for. | ||
| * @param options The options for the request. | ||
| * @returns The created request. | ||
| * @internal | ||
| */ | ||
| declare function createActivityPubRequest(url: string, options?: CreateRequestOptions): Request; | ||
| /** | ||
| * Options for making `User-Agent` string. | ||
| * @see {@link getUserAgent} | ||
| * @since 1.3.0 | ||
| */ | ||
| interface GetUserAgentOptions { | ||
| /** | ||
| * An optional software name and version, e.g., `"Hollo/1.0.0"`. | ||
| */ | ||
| software?: string | null; | ||
| /** | ||
| * An optional URL to append to the user agent string. | ||
| * Usually the URL of the ActivityPub instance. | ||
| */ | ||
| url?: string | URL | null; | ||
| } | ||
| /** | ||
| * Gets the user agent string for the given application and URL. | ||
| * @param options The options for making the user agent string. | ||
| * @returns The user agent string. | ||
| * @since 1.3.0 | ||
| */ | ||
| declare function getUserAgent({ | ||
| software, | ||
| url | ||
| }?: GetUserAgentOptions): string; | ||
| /** | ||
| * Logs the request. | ||
| * @param request The request to log. | ||
| * @internal | ||
| */ | ||
| declare function logRequest(logger: Logger, request: Request): void; | ||
| //#endregion | ||
| //#region src/docloader.d.ts | ||
| /** | ||
| * A remote JSON-LD document and its context fetched by | ||
| * a {@link DocumentLoader}. | ||
| */ | ||
| interface RemoteDocument { | ||
| /** | ||
| * The URL of the context document. | ||
| */ | ||
| contextUrl: string | null; | ||
| /** | ||
| * The fetched JSON-LD document. | ||
| */ | ||
| document: unknown; | ||
| /** | ||
| * The URL of the fetched document. | ||
| */ | ||
| documentUrl: string; | ||
| } | ||
| /** | ||
| * Options for {@link DocumentLoader}. | ||
| * @since 1.8.0 | ||
| */ | ||
| interface DocumentLoaderOptions { | ||
| /** | ||
| * An `AbortSignal` for cancellation. | ||
| * @since 1.8.0 | ||
| */ | ||
| signal?: AbortSignal; | ||
| } | ||
| /** | ||
| * A JSON-LD document loader that fetches documents from the Web. | ||
| * @param url The URL of the document to load. | ||
| * @param options The options for the document loader. | ||
| * @returns The loaded remote document. | ||
| */ | ||
| type DocumentLoader = (url: string, options?: DocumentLoaderOptions) => Promise<RemoteDocument>; | ||
| /** | ||
| * A factory function that creates a {@link DocumentLoader} with options. | ||
| * @param options The options for the document loader. | ||
| * @returns The document loader. | ||
| * @since 1.4.0 | ||
| */ | ||
| type DocumentLoaderFactory = (options?: DocumentLoaderFactoryOptions) => DocumentLoader; | ||
| /** | ||
| * Options for {@link DocumentLoaderFactory}. | ||
| * @see {@link DocumentLoaderFactory} | ||
| * @see {@link AuthenticatedDocumentLoaderFactory} | ||
| * @since 1.4.0 | ||
| */ | ||
| interface DocumentLoaderFactoryOptions { | ||
| /** | ||
| * Whether to allow fetching private network addresses. | ||
| * Turned off by default. | ||
| * @default `false`` | ||
| */ | ||
| allowPrivateAddress?: boolean; | ||
| /** | ||
| * Options for making `User-Agent` string. | ||
| * If a string is given, it is used as the `User-Agent` header value. | ||
| * If an object is given, it is passed to {@link getUserAgent} function. | ||
| */ | ||
| userAgent?: GetUserAgentOptions | string; | ||
| /** | ||
| * The maximum number of redirections to follow. | ||
| * @default `20` | ||
| * @since 2.2.0 | ||
| */ | ||
| maxRedirection?: number; | ||
| } | ||
| /** | ||
| * A factory function that creates an authenticated {@link DocumentLoader} for | ||
| * a given identity. This is used for fetching documents that require | ||
| * authentication. | ||
| * @param identity The identity to create the document loader for. | ||
| * The actor's key pair. | ||
| * @param options The options for the document loader. | ||
| * @returns The authenticated document loader. | ||
| * @since 0.4.0 | ||
| */ | ||
| type AuthenticatedDocumentLoaderFactory = (identity: { | ||
| keyId: URL; | ||
| privateKey: CryptoKey; | ||
| }, options?: DocumentLoaderFactoryOptions) => DocumentLoader; | ||
| /** | ||
| * Gets a {@link RemoteDocument} from the given response. | ||
| * @param url The URL of the document to load. | ||
| * @param response The response to get the document from. | ||
| * @param fetch The function to fetch the document. | ||
| * @returns The loaded remote document. | ||
| * @throws {FetchError} If the response is not OK. | ||
| * @internal | ||
| */ | ||
| declare function getRemoteDocument(url: string, response: Response, fetch: (url: string, options?: DocumentLoaderOptions) => Promise<RemoteDocument>): Promise<RemoteDocument>; | ||
| /** | ||
| * Options for {@link getDocumentLoader}. | ||
| * @since 1.3.0 | ||
| */ | ||
| interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions { | ||
| /** | ||
| * Whether to preload the frequently used contexts. | ||
| */ | ||
| skipPreloadedContexts?: boolean; | ||
| } | ||
| /** | ||
| * Creates a JSON-LD document loader that utilizes the browser's `fetch` API. | ||
| * | ||
| * The created loader preloads the below frequently used contexts by default | ||
| * (unless `options.skipPreloadedContexts` is set to `true`): | ||
| * | ||
| * - <https://www.w3.org/ns/activitystreams> | ||
| * - <https://w3id.org/security/v1> | ||
| * - <https://w3id.org/security/data-integrity/v1> | ||
| * - <https://w3id.org/security/data-integrity/v2> | ||
| * - <https://www.w3.org/ns/did/v1> | ||
| * - <https://www.w3.org/ns/cid/v1> | ||
| * - <https://w3id.org/security/multikey/v1> | ||
| * - <https://w3id.org/fep/ef61> | ||
| * - <https://purl.archive.org/socialweb/webfinger> | ||
| * - <http://schema.org/> | ||
| * @param options Options for the document loader. | ||
| * @returns The document loader. | ||
| * @since 1.3.0 | ||
| */ | ||
| declare function getDocumentLoader({ | ||
| allowPrivateAddress, | ||
| maxRedirection, | ||
| skipPreloadedContexts, | ||
| userAgent | ||
| }?: GetDocumentLoaderOptions): DocumentLoader; | ||
| //#endregion | ||
| export { DocumentLoaderOptions as a, getDocumentLoader as c, FetchError as d, GetUserAgentOptions as f, logRequest as h, DocumentLoaderFactoryOptions as i, getRemoteDocument as l, getUserAgent as m, DocumentLoader as n, GetDocumentLoaderOptions as o, createActivityPubRequest as p, DocumentLoaderFactory as r, RemoteDocument as s, AuthenticatedDocumentLoaderFactory as t, CreateRequestOptions as u }; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.cjs"); | ||
| let node_process = require("node:process"); | ||
| node_process = require_rolldown_runtime.__toESM(node_process, 1); | ||
| //#region deno.json | ||
| var name = "@fedify/vocab-runtime"; | ||
| var version = "2.4.0-dev.1881+17358f2e"; | ||
| //#endregion | ||
| //#region src/request.ts | ||
| /** | ||
| * Error thrown when fetching a JSON-LD document failed. | ||
| */ | ||
| var FetchError = class extends Error { | ||
| /** | ||
| * The URL that failed to fetch. | ||
| */ | ||
| url; | ||
| /** | ||
| * The HTTP response that failed, if available. | ||
| */ | ||
| response; | ||
| /** | ||
| * Constructs a new `FetchError`. | ||
| * | ||
| * @param url The URL that failed to fetch. | ||
| * @param message Error message. | ||
| * @param response The failed HTTP response, if available. | ||
| */ | ||
| constructor(url, message, response) { | ||
| super(message == null ? url.toString() : `${url}: ${message}`); | ||
| this.name = "FetchError"; | ||
| this.url = typeof url === "string" ? new URL(url) : url; | ||
| this.response = response; | ||
| } | ||
| }; | ||
| /** | ||
| * Creates a request for the given URL. | ||
| * @param url The URL to create the request for. | ||
| * @param options The options for the request. | ||
| * @returns The created request. | ||
| * @internal | ||
| */ | ||
| function createActivityPubRequest(url, options = {}) { | ||
| return new Request(url, { | ||
| headers: { | ||
| Accept: "application/activity+json, application/ld+json", | ||
| "User-Agent": typeof options.userAgent === "string" ? options.userAgent : getUserAgent(options.userAgent) | ||
| }, | ||
| redirect: "manual" | ||
| }); | ||
| } | ||
| /** | ||
| * Gets the user agent string for the given application and URL. | ||
| * @param options The options for making the user agent string. | ||
| * @returns The user agent string. | ||
| * @since 1.3.0 | ||
| */ | ||
| function getUserAgent({ software, url } = {}) { | ||
| const fedify = `Fedify/${version}`; | ||
| const runtime = globalThis.Deno?.version?.deno != null ? `Deno/${Deno.version.deno}` : globalThis.process?.versions?.bun != null ? `Bun/${node_process.default.versions.bun}` : "navigator" in globalThis && navigator.userAgent === "Cloudflare-Workers" ? navigator.userAgent : globalThis.process?.versions?.node != null ? `Node.js/${node_process.default.versions.node}` : null; | ||
| const userAgent = software == null ? [fedify] : [software, fedify]; | ||
| if (runtime != null) userAgent.push(runtime); | ||
| if (url != null) userAgent.push(`+${url.toString()}`); | ||
| return `${userAgent.shift()} (${userAgent.join("; ")})`; | ||
| } | ||
| /** | ||
| * Logs the request. | ||
| * @param request The request to log. | ||
| * @internal | ||
| */ | ||
| function logRequest(logger, request) { | ||
| logger.debug("Fetching document: {method} {url} {headers}", { | ||
| method: request.method, | ||
| url: request.url, | ||
| headers: Object.fromEntries(request.headers.entries()) | ||
| }); | ||
| } | ||
| //#endregion | ||
| Object.defineProperty(exports, "FetchError", { | ||
| enumerable: true, | ||
| get: function() { | ||
| return FetchError; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, "createActivityPubRequest", { | ||
| enumerable: true, | ||
| get: function() { | ||
| return createActivityPubRequest; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, "getUserAgent", { | ||
| enumerable: true, | ||
| get: function() { | ||
| return getUserAgent; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, "logRequest", { | ||
| enumerable: true, | ||
| get: function() { | ||
| return logRequest; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, "name", { | ||
| enumerable: true, | ||
| get: function() { | ||
| return name; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, "version", { | ||
| enumerable: true, | ||
| get: function() { | ||
| return version; | ||
| } | ||
| }); |
| import process from "node:process"; | ||
| //#region deno.json | ||
| var name = "@fedify/vocab-runtime"; | ||
| var version = "2.4.0-dev.1881+17358f2e"; | ||
| //#endregion | ||
| //#region src/request.ts | ||
| /** | ||
| * Error thrown when fetching a JSON-LD document failed. | ||
| */ | ||
| var FetchError = class extends Error { | ||
| /** | ||
| * The URL that failed to fetch. | ||
| */ | ||
| url; | ||
| /** | ||
| * The HTTP response that failed, if available. | ||
| */ | ||
| response; | ||
| /** | ||
| * Constructs a new `FetchError`. | ||
| * | ||
| * @param url The URL that failed to fetch. | ||
| * @param message Error message. | ||
| * @param response The failed HTTP response, if available. | ||
| */ | ||
| constructor(url, message, response) { | ||
| super(message == null ? url.toString() : `${url}: ${message}`); | ||
| this.name = "FetchError"; | ||
| this.url = typeof url === "string" ? new URL(url) : url; | ||
| this.response = response; | ||
| } | ||
| }; | ||
| /** | ||
| * Creates a request for the given URL. | ||
| * @param url The URL to create the request for. | ||
| * @param options The options for the request. | ||
| * @returns The created request. | ||
| * @internal | ||
| */ | ||
| function createActivityPubRequest(url, options = {}) { | ||
| return new Request(url, { | ||
| headers: { | ||
| Accept: "application/activity+json, application/ld+json", | ||
| "User-Agent": typeof options.userAgent === "string" ? options.userAgent : getUserAgent(options.userAgent) | ||
| }, | ||
| redirect: "manual" | ||
| }); | ||
| } | ||
| /** | ||
| * Gets the user agent string for the given application and URL. | ||
| * @param options The options for making the user agent string. | ||
| * @returns The user agent string. | ||
| * @since 1.3.0 | ||
| */ | ||
| function getUserAgent({ software, url } = {}) { | ||
| const fedify = `Fedify/${version}`; | ||
| const runtime = globalThis.Deno?.version?.deno != null ? `Deno/${Deno.version.deno}` : globalThis.process?.versions?.bun != null ? `Bun/${process.versions.bun}` : "navigator" in globalThis && navigator.userAgent === "Cloudflare-Workers" ? navigator.userAgent : globalThis.process?.versions?.node != null ? `Node.js/${process.versions.node}` : null; | ||
| const userAgent = software == null ? [fedify] : [software, fedify]; | ||
| if (runtime != null) userAgent.push(runtime); | ||
| if (url != null) userAgent.push(`+${url.toString()}`); | ||
| return `${userAgent.shift()} (${userAgent.join("; ")})`; | ||
| } | ||
| /** | ||
| * Logs the request. | ||
| * @param request The request to log. | ||
| * @internal | ||
| */ | ||
| function logRequest(logger, request) { | ||
| logger.debug("Fetching document: {method} {url} {headers}", { | ||
| method: request.method, | ||
| url: request.url, | ||
| headers: Object.fromEntries(request.headers.entries()) | ||
| }); | ||
| } | ||
| //#endregion | ||
| export { name as a, logRequest as i, createActivityPubRequest as n, version as o, getUserAgent as r, FetchError as t }; |
| { | ||
| "@context": { | ||
| "@protected": true, | ||
| "id": "@id", | ||
| "type": "@type", | ||
| "alsoKnownAs": { | ||
| "@id": "https://www.w3.org/ns/activitystreams#alsoKnownAs", | ||
| "@type": "@id" | ||
| }, | ||
| "assertionMethod": { | ||
| "@id": "https://w3id.org/security#assertionMethod", | ||
| "@type": "@id", | ||
| "@container": "@set" | ||
| }, | ||
| "authentication": { | ||
| "@id": "https://w3id.org/security#authenticationMethod", | ||
| "@type": "@id", | ||
| "@container": "@set" | ||
| }, | ||
| "capabilityDelegation": { | ||
| "@id": "https://w3id.org/security#capabilityDelegationMethod", | ||
| "@type": "@id", | ||
| "@container": "@set" | ||
| }, | ||
| "capabilityInvocation": { | ||
| "@id": "https://w3id.org/security#capabilityInvocationMethod", | ||
| "@type": "@id", | ||
| "@container": "@set" | ||
| }, | ||
| "controller": { | ||
| "@id": "https://w3id.org/security#controller", | ||
| "@type": "@id" | ||
| }, | ||
| "keyAgreement": { | ||
| "@id": "https://w3id.org/security#keyAgreementMethod", | ||
| "@type": "@id", | ||
| "@container": "@set" | ||
| }, | ||
| "service": { | ||
| "@id": "https://www.w3.org/ns/did#service", | ||
| "@type": "@id", | ||
| "@context": { | ||
| "@protected": true, | ||
| "id": "@id", | ||
| "type": "@type", | ||
| "serviceEndpoint": { | ||
| "@id": "https://www.w3.org/ns/did#serviceEndpoint", | ||
| "@type": "@id" | ||
| } | ||
| } | ||
| }, | ||
| "verificationMethod": { | ||
| "@id": "https://w3id.org/security#verificationMethod", | ||
| "@type": "@id" | ||
| }, | ||
| "Multikey": { | ||
| "@id": "https://w3id.org/security#Multikey", | ||
| "@context": { | ||
| "@protected": true, | ||
| "id": "@id", | ||
| "type": "@type", | ||
| "controller": { | ||
| "@id": "https://w3id.org/security#controller", | ||
| "@type": "@id" | ||
| }, | ||
| "revoked": { | ||
| "@id": "https://w3id.org/security#revoked", | ||
| "@type": "http://www.w3.org/2001/XMLSchema#dateTime" | ||
| }, | ||
| "expires": { | ||
| "@id": "https://w3id.org/security#expiration", | ||
| "@type": "http://www.w3.org/2001/XMLSchema#dateTime" | ||
| }, | ||
| "publicKeyMultibase": { | ||
| "@id": "https://w3id.org/security#publicKeyMultibase", | ||
| "@type": "https://w3id.org/security#multibase" | ||
| }, | ||
| "secretKeyMultibase": { | ||
| "@id": "https://w3id.org/security#secretKeyMultibase", | ||
| "@type": "https://w3id.org/security#multibase" | ||
| } | ||
| } | ||
| }, | ||
| "JsonWebKey": { | ||
| "@id": "https://w3id.org/security#JsonWebKey", | ||
| "@context": { | ||
| "@protected": true, | ||
| "id": "@id", | ||
| "type": "@type", | ||
| "controller": { | ||
| "@id": "https://w3id.org/security#controller", | ||
| "@type": "@id" | ||
| }, | ||
| "revoked": { | ||
| "@id": "https://w3id.org/security#revoked", | ||
| "@type": "http://www.w3.org/2001/XMLSchema#dateTime" | ||
| }, | ||
| "expires": { | ||
| "@id": "https://w3id.org/security#expiration", | ||
| "@type": "http://www.w3.org/2001/XMLSchema#dateTime" | ||
| }, | ||
| "publicKeyJwk": { | ||
| "@id": "https://w3id.org/security#publicKeyJwk", | ||
| "@type": "@json" | ||
| }, | ||
| "secretKeyJwk": { | ||
| "@id": "https://w3id.org/security#secretKeyJwk", | ||
| "@type": "@json" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
+1
-1
| { | ||
| "name": "@fedify/vocab-runtime", | ||
| "version": "2.4.0-dev.1873+f79eae3d", | ||
| "version": "2.4.0-dev.1881+17358f2e", | ||
| "license": "MIT", | ||
@@ -5,0 +5,0 @@ "exports": { |
| /// <reference lib="esnext.temporal" /> | ||
| import { n as DocumentLoader } from "../docloader-BK627tQQ.cjs"; | ||
| import { n as DocumentLoader } from "../docloader-Dr8wEkif.cjs"; | ||
@@ -4,0 +4,0 @@ //#region src/internal/jsonld-cache.d.ts |
| /// <reference lib="esnext.temporal" /> | ||
| import { n as DocumentLoader } from "../docloader-BK627tQQ.js"; | ||
| import { n as DocumentLoader } from "../docloader-Dr8wEkif.js"; | ||
@@ -4,0 +4,0 @@ //#region src/internal/jsonld-cache.d.ts |
+1
-1
| /// <reference lib="esnext.temporal" /> | ||
| import { a as DocumentLoaderOptions, c as getDocumentLoader, d as FetchError, f as GetUserAgentOptions, h as logRequest, i as DocumentLoaderFactoryOptions, l as getRemoteDocument, m as getUserAgent, n as DocumentLoader, o as GetDocumentLoaderOptions, p as createActivityPubRequest, r as DocumentLoaderFactory, s as RemoteDocument, t as AuthenticatedDocumentLoaderFactory, u as CreateRequestOptions } from "./docloader-BK627tQQ.cjs"; | ||
| import { a as DocumentLoaderOptions, c as getDocumentLoader, d as FetchError, f as GetUserAgentOptions, h as logRequest, i as DocumentLoaderFactoryOptions, l as getRemoteDocument, m as getUserAgent, n as DocumentLoader, o as GetDocumentLoaderOptions, p as createActivityPubRequest, r as DocumentLoaderFactory, s as RemoteDocument, t as AuthenticatedDocumentLoaderFactory, u as CreateRequestOptions } from "./docloader-Dr8wEkif.cjs"; | ||
| import { TracerProvider } from "@opentelemetry/api"; | ||
@@ -4,0 +4,0 @@ |
+1
-1
| /// <reference lib="esnext.temporal" /> | ||
| import { a as DocumentLoaderOptions, c as getDocumentLoader, d as FetchError, f as GetUserAgentOptions, h as logRequest, i as DocumentLoaderFactoryOptions, l as getRemoteDocument, m as getUserAgent, n as DocumentLoader, o as GetDocumentLoaderOptions, p as createActivityPubRequest, r as DocumentLoaderFactory, s as RemoteDocument, t as AuthenticatedDocumentLoaderFactory, u as CreateRequestOptions } from "./docloader-BK627tQQ.js"; | ||
| import { a as DocumentLoaderOptions, c as getDocumentLoader, d as FetchError, f as GetUserAgentOptions, h as logRequest, i as DocumentLoaderFactoryOptions, l as getRemoteDocument, m as getUserAgent, n as DocumentLoader, o as GetDocumentLoaderOptions, p as createActivityPubRequest, r as DocumentLoaderFactory, s as RemoteDocument, t as AuthenticatedDocumentLoaderFactory, u as CreateRequestOptions } from "./docloader-Dr8wEkif.js"; | ||
| import { TracerProvider } from "@opentelemetry/api"; | ||
@@ -4,0 +4,0 @@ //#region src/contexts.d.ts |
@@ -1,2 +0,2 @@ | ||
| require("./docloader-uFQgIcvu.cjs"); | ||
| require("./docloader-y_0ATxGw.cjs"); | ||
| require("./url-CPfMatUL.cjs"); | ||
@@ -3,0 +3,0 @@ require("./key-8Qg2SbZi.cjs"); |
@@ -1,2 +0,2 @@ | ||
| import "./docloader-Z0l0O1GH.mjs"; | ||
| import "./docloader-B_n1Fvv6.mjs"; | ||
| import "./url-Basm1L_c.mjs"; | ||
@@ -3,0 +3,0 @@ import "./key-C7MNhlkO.mjs"; |
| const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.cjs"); | ||
| const require_docloader = require("./docloader-uFQgIcvu.cjs"); | ||
| const require_request = require("./request-DsDLaP7D.cjs"); | ||
| const require_docloader = require("./docloader-y_0ATxGw.cjs"); | ||
| const require_request = require("./request-CBsvHmNG.cjs"); | ||
| const require_url = require("./url-CPfMatUL.cjs"); | ||
@@ -1493,2 +1493,11 @@ let node_assert = require("node:assert"); | ||
| }); | ||
| esm_default.get("https://www.w3.org/ns/cid/v1", { status: 503 }); | ||
| await t.test("preloaded CID v1 context", async () => { | ||
| const url = "https://www.w3.org/ns/cid/v1"; | ||
| (0, node_assert.deepStrictEqual)(await fetchDocumentLoader(url), { | ||
| contextUrl: null, | ||
| documentUrl: url, | ||
| document: require_docloader.cid_v1_default | ||
| }); | ||
| }); | ||
| await t.test("preloaded FEP-ef61 context", async () => { | ||
@@ -1495,0 +1504,0 @@ const url = "https://w3id.org/fep/ef61"; |
@@ -1,3 +0,3 @@ | ||
| import { n as getRemoteDocument, r as preloadedContexts, t as getDocumentLoader } from "./docloader-Z0l0O1GH.mjs"; | ||
| import { t as FetchError } from "./request-D5t8Xg89.mjs"; | ||
| import { i as cid_v1_default, n as getRemoteDocument, r as preloadedContexts, t as getDocumentLoader } from "./docloader-B_n1Fvv6.mjs"; | ||
| import { t as FetchError } from "./request-DtrJ65EW.mjs"; | ||
| import { t as UrlError } from "./url-Basm1L_c.mjs"; | ||
@@ -1512,2 +1512,11 @@ import { deepStrictEqual, ok, rejects } from "node:assert"; | ||
| }); | ||
| esm_default.get("https://www.w3.org/ns/cid/v1", { status: 503 }); | ||
| await t.test("preloaded CID v1 context", async () => { | ||
| const url = "https://www.w3.org/ns/cid/v1"; | ||
| deepStrictEqual(await fetchDocumentLoader(url), { | ||
| contextUrl: null, | ||
| documentUrl: url, | ||
| document: cid_v1_default | ||
| }); | ||
| }); | ||
| await t.test("preloaded FEP-ef61 context", async () => { | ||
@@ -1514,0 +1523,0 @@ const url = "https://w3id.org/fep/ef61"; |
| const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.cjs"); | ||
| const require_request = require("./request-DsDLaP7D.cjs"); | ||
| const require_request = require("./request-CBsvHmNG.cjs"); | ||
| let node_assert = require("node:assert"); | ||
@@ -4,0 +4,0 @@ let node_test = require("node:test"); |
@@ -1,2 +0,2 @@ | ||
| import { o as version, r as getUserAgent } from "./request-D5t8Xg89.mjs"; | ||
| import { o as version, r as getUserAgent } from "./request-DtrJ65EW.mjs"; | ||
| import { deepStrictEqual } from "node:assert"; | ||
@@ -3,0 +3,0 @@ import { test } from "node:test"; |
+1
-1
| { | ||
| "name": "@fedify/vocab-runtime", | ||
| "version": "2.4.0-dev.1873+f79eae3d", | ||
| "version": "2.4.0-dev.1881+17358f2e", | ||
| "homepage": "https://fedify.dev/", | ||
@@ -5,0 +5,0 @@ "repository": { |
+9
-0
@@ -8,2 +8,3 @@ // Preloaded context documents | ||
| }; | ||
| import cidV1Context from "./contexts/cid-v1.json" with { type: "json" }; | ||
| import didV1 from "./contexts/did-v1.json" with { type: "json" }; | ||
@@ -44,2 +45,10 @@ import fep5711 from "./contexts/fep-5711.json" with { type: "json" }; | ||
| // Controlled Identifiers v1.0 requires JSON-LD processors to treat this | ||
| // context URL as already resolved. We ship the official W3C context so that | ||
| // controlled identifier documents can be processed without depending on the | ||
| // availability of the remote context server. | ||
| // See: https://www.w3.org/TR/cid-1.0/#json-ld-context | ||
| // https://github.com/fedify-dev/fedify/issues/932 | ||
| "https://www.w3.org/ns/cid/v1": cidV1Context, | ||
| // The FEP-ef61 context. The w3id.org URL redirects to Codeberg Pages, which | ||
@@ -46,0 +55,0 @@ // suffers recurring outages; while it is unreachable, every document |
@@ -5,2 +5,3 @@ import fetchMock from "fetch-mock"; | ||
| import preloadedContexts from "./contexts.ts"; | ||
| import cidV1Context from "./contexts/cid-v1.json" with { type: "json" }; | ||
| import { getDocumentLoader, getRemoteDocument } from "./docloader.ts"; | ||
@@ -393,2 +394,17 @@ import { FetchError } from "./request.ts"; | ||
| // Controlled Identifiers v1.0 requires JSON-LD processors to treat this | ||
| // context URL as already resolved. A temporary W3C outage must not prevent | ||
| // an otherwise valid document from being processed. | ||
| // See: https://www.w3.org/TR/cid-1.0/#json-ld-context | ||
| // https://github.com/fedify-dev/fedify/issues/932 | ||
| fetchMock.get("https://www.w3.org/ns/cid/v1", { status: 503 }); | ||
| await t.test("preloaded CID v1 context", async () => { | ||
| const url = "https://www.w3.org/ns/cid/v1"; | ||
| deepStrictEqual(await fetchDocumentLoader(url), { | ||
| contextUrl: null, | ||
| documentUrl: url, | ||
| document: cidV1Context, | ||
| }); | ||
| }); | ||
| // The <https://w3id.org/fep/ef61> URL redirects to a Codeberg Pages host | ||
@@ -395,0 +411,0 @@ // which suffers recurring outages; while it is unreachable, expanding any |
+1
-0
@@ -356,2 +356,3 @@ import { getLogger } from "@logtape/logtape"; | ||
| * - <https://www.w3.org/ns/did/v1> | ||
| * - <https://www.w3.org/ns/cid/v1> | ||
| * - <https://w3id.org/security/multikey/v1> | ||
@@ -358,0 +359,0 @@ * - <https://w3id.org/fep/ef61> |
| /// <reference lib="esnext.temporal" /> | ||
| import { Logger } from "@logtape/logtape"; | ||
| //#region src/request.d.ts | ||
| /** | ||
| * Error thrown when fetching a JSON-LD document failed. | ||
| */ | ||
| declare class FetchError extends Error { | ||
| /** | ||
| * The URL that failed to fetch. | ||
| */ | ||
| url: URL; | ||
| /** | ||
| * The HTTP response that failed, if available. | ||
| */ | ||
| response?: Response; | ||
| /** | ||
| * Constructs a new `FetchError`. | ||
| * | ||
| * @param url The URL that failed to fetch. | ||
| * @param message Error message. | ||
| * @param response The failed HTTP response, if available. | ||
| */ | ||
| constructor(url: URL | string, message?: string, response?: Response); | ||
| } | ||
| /** | ||
| * Options for creating a request. | ||
| * @internal | ||
| */ | ||
| interface CreateRequestOptions { | ||
| userAgent?: GetUserAgentOptions | string; | ||
| } | ||
| /** | ||
| * Creates a request for the given URL. | ||
| * @param url The URL to create the request for. | ||
| * @param options The options for the request. | ||
| * @returns The created request. | ||
| * @internal | ||
| */ | ||
| declare function createActivityPubRequest(url: string, options?: CreateRequestOptions): Request; | ||
| /** | ||
| * Options for making `User-Agent` string. | ||
| * @see {@link getUserAgent} | ||
| * @since 1.3.0 | ||
| */ | ||
| interface GetUserAgentOptions { | ||
| /** | ||
| * An optional software name and version, e.g., `"Hollo/1.0.0"`. | ||
| */ | ||
| software?: string | null; | ||
| /** | ||
| * An optional URL to append to the user agent string. | ||
| * Usually the URL of the ActivityPub instance. | ||
| */ | ||
| url?: string | URL | null; | ||
| } | ||
| /** | ||
| * Gets the user agent string for the given application and URL. | ||
| * @param options The options for making the user agent string. | ||
| * @returns The user agent string. | ||
| * @since 1.3.0 | ||
| */ | ||
| declare function getUserAgent({ | ||
| software, | ||
| url | ||
| }?: GetUserAgentOptions): string; | ||
| /** | ||
| * Logs the request. | ||
| * @param request The request to log. | ||
| * @internal | ||
| */ | ||
| declare function logRequest(logger: Logger, request: Request): void; | ||
| //#endregion | ||
| //#region src/docloader.d.ts | ||
| /** | ||
| * A remote JSON-LD document and its context fetched by | ||
| * a {@link DocumentLoader}. | ||
| */ | ||
| interface RemoteDocument { | ||
| /** | ||
| * The URL of the context document. | ||
| */ | ||
| contextUrl: string | null; | ||
| /** | ||
| * The fetched JSON-LD document. | ||
| */ | ||
| document: unknown; | ||
| /** | ||
| * The URL of the fetched document. | ||
| */ | ||
| documentUrl: string; | ||
| } | ||
| /** | ||
| * Options for {@link DocumentLoader}. | ||
| * @since 1.8.0 | ||
| */ | ||
| interface DocumentLoaderOptions { | ||
| /** | ||
| * An `AbortSignal` for cancellation. | ||
| * @since 1.8.0 | ||
| */ | ||
| signal?: AbortSignal; | ||
| } | ||
| /** | ||
| * A JSON-LD document loader that fetches documents from the Web. | ||
| * @param url The URL of the document to load. | ||
| * @param options The options for the document loader. | ||
| * @returns The loaded remote document. | ||
| */ | ||
| type DocumentLoader = (url: string, options?: DocumentLoaderOptions) => Promise<RemoteDocument>; | ||
| /** | ||
| * A factory function that creates a {@link DocumentLoader} with options. | ||
| * @param options The options for the document loader. | ||
| * @returns The document loader. | ||
| * @since 1.4.0 | ||
| */ | ||
| type DocumentLoaderFactory = (options?: DocumentLoaderFactoryOptions) => DocumentLoader; | ||
| /** | ||
| * Options for {@link DocumentLoaderFactory}. | ||
| * @see {@link DocumentLoaderFactory} | ||
| * @see {@link AuthenticatedDocumentLoaderFactory} | ||
| * @since 1.4.0 | ||
| */ | ||
| interface DocumentLoaderFactoryOptions { | ||
| /** | ||
| * Whether to allow fetching private network addresses. | ||
| * Turned off by default. | ||
| * @default `false`` | ||
| */ | ||
| allowPrivateAddress?: boolean; | ||
| /** | ||
| * Options for making `User-Agent` string. | ||
| * If a string is given, it is used as the `User-Agent` header value. | ||
| * If an object is given, it is passed to {@link getUserAgent} function. | ||
| */ | ||
| userAgent?: GetUserAgentOptions | string; | ||
| /** | ||
| * The maximum number of redirections to follow. | ||
| * @default `20` | ||
| * @since 2.2.0 | ||
| */ | ||
| maxRedirection?: number; | ||
| } | ||
| /** | ||
| * A factory function that creates an authenticated {@link DocumentLoader} for | ||
| * a given identity. This is used for fetching documents that require | ||
| * authentication. | ||
| * @param identity The identity to create the document loader for. | ||
| * The actor's key pair. | ||
| * @param options The options for the document loader. | ||
| * @returns The authenticated document loader. | ||
| * @since 0.4.0 | ||
| */ | ||
| type AuthenticatedDocumentLoaderFactory = (identity: { | ||
| keyId: URL; | ||
| privateKey: CryptoKey; | ||
| }, options?: DocumentLoaderFactoryOptions) => DocumentLoader; | ||
| /** | ||
| * Gets a {@link RemoteDocument} from the given response. | ||
| * @param url The URL of the document to load. | ||
| * @param response The response to get the document from. | ||
| * @param fetch The function to fetch the document. | ||
| * @returns The loaded remote document. | ||
| * @throws {FetchError} If the response is not OK. | ||
| * @internal | ||
| */ | ||
| declare function getRemoteDocument(url: string, response: Response, fetch: (url: string, options?: DocumentLoaderOptions) => Promise<RemoteDocument>): Promise<RemoteDocument>; | ||
| /** | ||
| * Options for {@link getDocumentLoader}. | ||
| * @since 1.3.0 | ||
| */ | ||
| interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions { | ||
| /** | ||
| * Whether to preload the frequently used contexts. | ||
| */ | ||
| skipPreloadedContexts?: boolean; | ||
| } | ||
| /** | ||
| * Creates a JSON-LD document loader that utilizes the browser's `fetch` API. | ||
| * | ||
| * The created loader preloads the below frequently used contexts by default | ||
| * (unless `options.skipPreloadedContexts` is set to `true`): | ||
| * | ||
| * - <https://www.w3.org/ns/activitystreams> | ||
| * - <https://w3id.org/security/v1> | ||
| * - <https://w3id.org/security/data-integrity/v1> | ||
| * - <https://w3id.org/security/data-integrity/v2> | ||
| * - <https://www.w3.org/ns/did/v1> | ||
| * - <https://w3id.org/security/multikey/v1> | ||
| * - <https://w3id.org/fep/ef61> | ||
| * - <https://purl.archive.org/socialweb/webfinger> | ||
| * - <http://schema.org/> | ||
| * @param options Options for the document loader. | ||
| * @returns The document loader. | ||
| * @since 1.3.0 | ||
| */ | ||
| declare function getDocumentLoader({ | ||
| allowPrivateAddress, | ||
| maxRedirection, | ||
| skipPreloadedContexts, | ||
| userAgent | ||
| }?: GetDocumentLoaderOptions): DocumentLoader; | ||
| //#endregion | ||
| export { DocumentLoaderOptions as a, getDocumentLoader as c, FetchError as d, GetUserAgentOptions as f, logRequest as h, DocumentLoaderFactoryOptions as i, getRemoteDocument as l, getUserAgent as m, DocumentLoader as n, GetDocumentLoaderOptions as o, createActivityPubRequest as p, DocumentLoaderFactory as r, RemoteDocument as s, AuthenticatedDocumentLoaderFactory as t, CreateRequestOptions as u }; |
| /// <reference lib="esnext.temporal" /> | ||
| import { Logger } from "@logtape/logtape"; | ||
| //#region src/request.d.ts | ||
| /** | ||
| * Error thrown when fetching a JSON-LD document failed. | ||
| */ | ||
| declare class FetchError extends Error { | ||
| /** | ||
| * The URL that failed to fetch. | ||
| */ | ||
| url: URL; | ||
| /** | ||
| * The HTTP response that failed, if available. | ||
| */ | ||
| response?: Response; | ||
| /** | ||
| * Constructs a new `FetchError`. | ||
| * | ||
| * @param url The URL that failed to fetch. | ||
| * @param message Error message. | ||
| * @param response The failed HTTP response, if available. | ||
| */ | ||
| constructor(url: URL | string, message?: string, response?: Response); | ||
| } | ||
| /** | ||
| * Options for creating a request. | ||
| * @internal | ||
| */ | ||
| interface CreateRequestOptions { | ||
| userAgent?: GetUserAgentOptions | string; | ||
| } | ||
| /** | ||
| * Creates a request for the given URL. | ||
| * @param url The URL to create the request for. | ||
| * @param options The options for the request. | ||
| * @returns The created request. | ||
| * @internal | ||
| */ | ||
| declare function createActivityPubRequest(url: string, options?: CreateRequestOptions): Request; | ||
| /** | ||
| * Options for making `User-Agent` string. | ||
| * @see {@link getUserAgent} | ||
| * @since 1.3.0 | ||
| */ | ||
| interface GetUserAgentOptions { | ||
| /** | ||
| * An optional software name and version, e.g., `"Hollo/1.0.0"`. | ||
| */ | ||
| software?: string | null; | ||
| /** | ||
| * An optional URL to append to the user agent string. | ||
| * Usually the URL of the ActivityPub instance. | ||
| */ | ||
| url?: string | URL | null; | ||
| } | ||
| /** | ||
| * Gets the user agent string for the given application and URL. | ||
| * @param options The options for making the user agent string. | ||
| * @returns The user agent string. | ||
| * @since 1.3.0 | ||
| */ | ||
| declare function getUserAgent({ | ||
| software, | ||
| url | ||
| }?: GetUserAgentOptions): string; | ||
| /** | ||
| * Logs the request. | ||
| * @param request The request to log. | ||
| * @internal | ||
| */ | ||
| declare function logRequest(logger: Logger, request: Request): void; | ||
| //#endregion | ||
| //#region src/docloader.d.ts | ||
| /** | ||
| * A remote JSON-LD document and its context fetched by | ||
| * a {@link DocumentLoader}. | ||
| */ | ||
| interface RemoteDocument { | ||
| /** | ||
| * The URL of the context document. | ||
| */ | ||
| contextUrl: string | null; | ||
| /** | ||
| * The fetched JSON-LD document. | ||
| */ | ||
| document: unknown; | ||
| /** | ||
| * The URL of the fetched document. | ||
| */ | ||
| documentUrl: string; | ||
| } | ||
| /** | ||
| * Options for {@link DocumentLoader}. | ||
| * @since 1.8.0 | ||
| */ | ||
| interface DocumentLoaderOptions { | ||
| /** | ||
| * An `AbortSignal` for cancellation. | ||
| * @since 1.8.0 | ||
| */ | ||
| signal?: AbortSignal; | ||
| } | ||
| /** | ||
| * A JSON-LD document loader that fetches documents from the Web. | ||
| * @param url The URL of the document to load. | ||
| * @param options The options for the document loader. | ||
| * @returns The loaded remote document. | ||
| */ | ||
| type DocumentLoader = (url: string, options?: DocumentLoaderOptions) => Promise<RemoteDocument>; | ||
| /** | ||
| * A factory function that creates a {@link DocumentLoader} with options. | ||
| * @param options The options for the document loader. | ||
| * @returns The document loader. | ||
| * @since 1.4.0 | ||
| */ | ||
| type DocumentLoaderFactory = (options?: DocumentLoaderFactoryOptions) => DocumentLoader; | ||
| /** | ||
| * Options for {@link DocumentLoaderFactory}. | ||
| * @see {@link DocumentLoaderFactory} | ||
| * @see {@link AuthenticatedDocumentLoaderFactory} | ||
| * @since 1.4.0 | ||
| */ | ||
| interface DocumentLoaderFactoryOptions { | ||
| /** | ||
| * Whether to allow fetching private network addresses. | ||
| * Turned off by default. | ||
| * @default `false`` | ||
| */ | ||
| allowPrivateAddress?: boolean; | ||
| /** | ||
| * Options for making `User-Agent` string. | ||
| * If a string is given, it is used as the `User-Agent` header value. | ||
| * If an object is given, it is passed to {@link getUserAgent} function. | ||
| */ | ||
| userAgent?: GetUserAgentOptions | string; | ||
| /** | ||
| * The maximum number of redirections to follow. | ||
| * @default `20` | ||
| * @since 2.2.0 | ||
| */ | ||
| maxRedirection?: number; | ||
| } | ||
| /** | ||
| * A factory function that creates an authenticated {@link DocumentLoader} for | ||
| * a given identity. This is used for fetching documents that require | ||
| * authentication. | ||
| * @param identity The identity to create the document loader for. | ||
| * The actor's key pair. | ||
| * @param options The options for the document loader. | ||
| * @returns The authenticated document loader. | ||
| * @since 0.4.0 | ||
| */ | ||
| type AuthenticatedDocumentLoaderFactory = (identity: { | ||
| keyId: URL; | ||
| privateKey: CryptoKey; | ||
| }, options?: DocumentLoaderFactoryOptions) => DocumentLoader; | ||
| /** | ||
| * Gets a {@link RemoteDocument} from the given response. | ||
| * @param url The URL of the document to load. | ||
| * @param response The response to get the document from. | ||
| * @param fetch The function to fetch the document. | ||
| * @returns The loaded remote document. | ||
| * @throws {FetchError} If the response is not OK. | ||
| * @internal | ||
| */ | ||
| declare function getRemoteDocument(url: string, response: Response, fetch: (url: string, options?: DocumentLoaderOptions) => Promise<RemoteDocument>): Promise<RemoteDocument>; | ||
| /** | ||
| * Options for {@link getDocumentLoader}. | ||
| * @since 1.3.0 | ||
| */ | ||
| interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions { | ||
| /** | ||
| * Whether to preload the frequently used contexts. | ||
| */ | ||
| skipPreloadedContexts?: boolean; | ||
| } | ||
| /** | ||
| * Creates a JSON-LD document loader that utilizes the browser's `fetch` API. | ||
| * | ||
| * The created loader preloads the below frequently used contexts by default | ||
| * (unless `options.skipPreloadedContexts` is set to `true`): | ||
| * | ||
| * - <https://www.w3.org/ns/activitystreams> | ||
| * - <https://w3id.org/security/v1> | ||
| * - <https://w3id.org/security/data-integrity/v1> | ||
| * - <https://w3id.org/security/data-integrity/v2> | ||
| * - <https://www.w3.org/ns/did/v1> | ||
| * - <https://w3id.org/security/multikey/v1> | ||
| * - <https://w3id.org/fep/ef61> | ||
| * - <https://purl.archive.org/socialweb/webfinger> | ||
| * - <http://schema.org/> | ||
| * @param options Options for the document loader. | ||
| * @returns The document loader. | ||
| * @since 1.3.0 | ||
| */ | ||
| declare function getDocumentLoader({ | ||
| allowPrivateAddress, | ||
| maxRedirection, | ||
| skipPreloadedContexts, | ||
| userAgent | ||
| }?: GetDocumentLoaderOptions): DocumentLoader; | ||
| //#endregion | ||
| export { DocumentLoaderOptions as a, getDocumentLoader as c, FetchError as d, GetUserAgentOptions as f, logRequest as h, DocumentLoaderFactoryOptions as i, getRemoteDocument as l, getUserAgent as m, DocumentLoader as n, GetDocumentLoaderOptions as o, createActivityPubRequest as p, DocumentLoaderFactory as r, RemoteDocument as s, AuthenticatedDocumentLoaderFactory as t, CreateRequestOptions as u }; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| import process from "node:process"; | ||
| //#region deno.json | ||
| var name = "@fedify/vocab-runtime"; | ||
| var version = "2.4.0-dev.1873+f79eae3d"; | ||
| //#endregion | ||
| //#region src/request.ts | ||
| /** | ||
| * Error thrown when fetching a JSON-LD document failed. | ||
| */ | ||
| var FetchError = class extends Error { | ||
| /** | ||
| * The URL that failed to fetch. | ||
| */ | ||
| url; | ||
| /** | ||
| * The HTTP response that failed, if available. | ||
| */ | ||
| response; | ||
| /** | ||
| * Constructs a new `FetchError`. | ||
| * | ||
| * @param url The URL that failed to fetch. | ||
| * @param message Error message. | ||
| * @param response The failed HTTP response, if available. | ||
| */ | ||
| constructor(url, message, response) { | ||
| super(message == null ? url.toString() : `${url}: ${message}`); | ||
| this.name = "FetchError"; | ||
| this.url = typeof url === "string" ? new URL(url) : url; | ||
| this.response = response; | ||
| } | ||
| }; | ||
| /** | ||
| * Creates a request for the given URL. | ||
| * @param url The URL to create the request for. | ||
| * @param options The options for the request. | ||
| * @returns The created request. | ||
| * @internal | ||
| */ | ||
| function createActivityPubRequest(url, options = {}) { | ||
| return new Request(url, { | ||
| headers: { | ||
| Accept: "application/activity+json, application/ld+json", | ||
| "User-Agent": typeof options.userAgent === "string" ? options.userAgent : getUserAgent(options.userAgent) | ||
| }, | ||
| redirect: "manual" | ||
| }); | ||
| } | ||
| /** | ||
| * Gets the user agent string for the given application and URL. | ||
| * @param options The options for making the user agent string. | ||
| * @returns The user agent string. | ||
| * @since 1.3.0 | ||
| */ | ||
| function getUserAgent({ software, url } = {}) { | ||
| const fedify = `Fedify/${version}`; | ||
| const runtime = globalThis.Deno?.version?.deno != null ? `Deno/${Deno.version.deno}` : globalThis.process?.versions?.bun != null ? `Bun/${process.versions.bun}` : "navigator" in globalThis && navigator.userAgent === "Cloudflare-Workers" ? navigator.userAgent : globalThis.process?.versions?.node != null ? `Node.js/${process.versions.node}` : null; | ||
| const userAgent = software == null ? [fedify] : [software, fedify]; | ||
| if (runtime != null) userAgent.push(runtime); | ||
| if (url != null) userAgent.push(`+${url.toString()}`); | ||
| return `${userAgent.shift()} (${userAgent.join("; ")})`; | ||
| } | ||
| /** | ||
| * Logs the request. | ||
| * @param request The request to log. | ||
| * @internal | ||
| */ | ||
| function logRequest(logger, request) { | ||
| logger.debug("Fetching document: {method} {url} {headers}", { | ||
| method: request.method, | ||
| url: request.url, | ||
| headers: Object.fromEntries(request.headers.entries()) | ||
| }); | ||
| } | ||
| //#endregion | ||
| export { name as a, logRequest as i, createActivityPubRequest as n, version as o, getUserAgent as r, FetchError as t }; |
| const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.cjs"); | ||
| let node_process = require("node:process"); | ||
| node_process = require_rolldown_runtime.__toESM(node_process, 1); | ||
| //#region deno.json | ||
| var name = "@fedify/vocab-runtime"; | ||
| var version = "2.4.0-dev.1873+f79eae3d"; | ||
| //#endregion | ||
| //#region src/request.ts | ||
| /** | ||
| * Error thrown when fetching a JSON-LD document failed. | ||
| */ | ||
| var FetchError = class extends Error { | ||
| /** | ||
| * The URL that failed to fetch. | ||
| */ | ||
| url; | ||
| /** | ||
| * The HTTP response that failed, if available. | ||
| */ | ||
| response; | ||
| /** | ||
| * Constructs a new `FetchError`. | ||
| * | ||
| * @param url The URL that failed to fetch. | ||
| * @param message Error message. | ||
| * @param response The failed HTTP response, if available. | ||
| */ | ||
| constructor(url, message, response) { | ||
| super(message == null ? url.toString() : `${url}: ${message}`); | ||
| this.name = "FetchError"; | ||
| this.url = typeof url === "string" ? new URL(url) : url; | ||
| this.response = response; | ||
| } | ||
| }; | ||
| /** | ||
| * Creates a request for the given URL. | ||
| * @param url The URL to create the request for. | ||
| * @param options The options for the request. | ||
| * @returns The created request. | ||
| * @internal | ||
| */ | ||
| function createActivityPubRequest(url, options = {}) { | ||
| return new Request(url, { | ||
| headers: { | ||
| Accept: "application/activity+json, application/ld+json", | ||
| "User-Agent": typeof options.userAgent === "string" ? options.userAgent : getUserAgent(options.userAgent) | ||
| }, | ||
| redirect: "manual" | ||
| }); | ||
| } | ||
| /** | ||
| * Gets the user agent string for the given application and URL. | ||
| * @param options The options for making the user agent string. | ||
| * @returns The user agent string. | ||
| * @since 1.3.0 | ||
| */ | ||
| function getUserAgent({ software, url } = {}) { | ||
| const fedify = `Fedify/${version}`; | ||
| const runtime = globalThis.Deno?.version?.deno != null ? `Deno/${Deno.version.deno}` : globalThis.process?.versions?.bun != null ? `Bun/${node_process.default.versions.bun}` : "navigator" in globalThis && navigator.userAgent === "Cloudflare-Workers" ? navigator.userAgent : globalThis.process?.versions?.node != null ? `Node.js/${node_process.default.versions.node}` : null; | ||
| const userAgent = software == null ? [fedify] : [software, fedify]; | ||
| if (runtime != null) userAgent.push(runtime); | ||
| if (url != null) userAgent.push(`+${url.toString()}`); | ||
| return `${userAgent.shift()} (${userAgent.join("; ")})`; | ||
| } | ||
| /** | ||
| * Logs the request. | ||
| * @param request The request to log. | ||
| * @internal | ||
| */ | ||
| function logRequest(logger, request) { | ||
| logger.debug("Fetching document: {method} {url} {headers}", { | ||
| method: request.method, | ||
| url: request.url, | ||
| headers: Object.fromEntries(request.headers.entries()) | ||
| }); | ||
| } | ||
| //#endregion | ||
| Object.defineProperty(exports, "FetchError", { | ||
| enumerable: true, | ||
| get: function() { | ||
| return FetchError; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, "createActivityPubRequest", { | ||
| enumerable: true, | ||
| get: function() { | ||
| return createActivityPubRequest; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, "getUserAgent", { | ||
| enumerable: true, | ||
| get: function() { | ||
| return getUserAgent; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, "logRequest", { | ||
| enumerable: true, | ||
| get: function() { | ||
| return logRequest; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, "name", { | ||
| enumerable: true, | ||
| get: function() { | ||
| return name; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, "version", { | ||
| enumerable: true, | ||
| get: function() { | ||
| return version; | ||
| } | ||
| }); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
1881979
0.89%144
0.7%50667
1.24%