@fedify/vocab-runtime 2.4.0-pr.936.41 → 2.5.0-dev.2271
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/deno.json +4 -2
- package/dist/{tests/docloader-Ck8bcBir.mjs → contexts-BK1CqBR5.cjs} +164 -275
- package/dist/{tests/docloader-S_gQZ2tt.cjs → contexts-DPuJ4UYL.js} +160 -294
- package/dist/{docloader-C_dir7Xb.d.ts → docloader-CYwqh5Df.d.cts} +66 -2
- package/dist/{docloader-D2DTRiyA.d.cts → docloader-CYwqh5Df.d.ts} +66 -2
- package/dist/internal/jsonld-cache.cjs +70 -1
- package/dist/internal/jsonld-cache.d.cts +35 -2
- package/dist/internal/jsonld-cache.d.ts +35 -2
- package/dist/internal/jsonld-cache.js +67 -2
- package/dist/internal/portable-dereference.cjs +721 -0
- package/dist/internal/portable-dereference.d.cts +349 -0
- package/dist/internal/portable-dereference.d.ts +349 -0
- package/dist/internal/portable-dereference.js +702 -0
- package/dist/internal/signed-representation.cjs +378 -0
- package/dist/internal/signed-representation.d.cts +144 -0
- package/dist/internal/signed-representation.d.ts +144 -0
- package/dist/internal/signed-representation.js +371 -0
- package/dist/jsonld.cjs +2 -2
- package/dist/mod.cjs +711 -4527
- package/dist/mod.d.cts +400 -8
- package/dist/mod.d.ts +400 -9
- package/dist/mod.js +692 -4522
- package/dist/portable-DqtfLy_1.d.cts +160 -0
- package/dist/portable-DtWsu2yU.d.ts +160 -0
- package/dist/tests/body-CVR1bABr.mjs +130 -0
- package/dist/tests/body-T_yQWql3.cjs +153 -0
- package/dist/tests/body.test.cjs +89 -0
- package/dist/tests/body.test.d.cts +1 -0
- package/dist/tests/body.test.d.mts +1 -0
- package/dist/tests/body.test.mjs +90 -0
- package/dist/tests/contexts-CIKsin4e.mjs +4512 -0
- package/dist/tests/contexts-DizzBjz4.cjs +4523 -0
- package/dist/tests/decimal.test.cjs +8 -7
- package/dist/tests/decimal.test.mjs +8 -6
- package/dist/tests/digest-3FeH2Y-Q.cjs +176 -0
- package/dist/tests/digest-COC7xDiQ.mjs +141 -0
- package/dist/tests/digest.test.cjs +102 -0
- package/dist/tests/digest.test.d.cts +1 -0
- package/dist/tests/digest.test.d.mts +1 -0
- package/dist/tests/digest.test.mjs +103 -0
- package/dist/tests/docloader-C6yApEts.mjs +373 -0
- package/dist/tests/docloader-CJK2w3l-.cjs +396 -0
- package/dist/tests/docloader.test.cjs +692 -39
- package/dist/tests/docloader.test.mjs +686 -34
- package/dist/tests/internal/multicodec.test.cjs +2 -3
- package/dist/tests/internal/multicodec.test.mjs +2 -2
- package/dist/tests/internal/portable-dereference.test.cjs +172 -0
- package/dist/tests/internal/portable-dereference.test.d.cts +1 -0
- package/dist/tests/internal/portable-dereference.test.d.mts +1 -0
- package/dist/tests/internal/portable-dereference.test.mjs +173 -0
- package/dist/tests/jsonld-cache-BPQmOZWD.mjs +342 -0
- package/dist/tests/jsonld-cache-C07AyNOY.cjs +397 -0
- package/dist/tests/jsonld-cache.test.cjs +101 -298
- package/dist/tests/jsonld-cache.test.mjs +94 -289
- package/dist/tests/{key-_wXwomh_.cjs → key-C-AYkdJJ.cjs} +11 -4
- package/dist/tests/{key-CDGDH_vC.mjs → key-C2Db_TAJ.mjs} +11 -3
- package/dist/tests/key.test.cjs +6 -5
- package/dist/tests/key.test.mjs +6 -4
- package/dist/tests/langstr.test.cjs +4 -4
- package/dist/tests/langstr.test.mjs +2 -2
- package/dist/tests/link.test.cjs +2 -3
- package/dist/tests/link.test.mjs +2 -2
- package/dist/tests/multibase/multibase.test.cjs +8 -9
- package/dist/tests/multibase/multibase.test.mjs +6 -6
- package/dist/tests/{multibase-Bz_UUDtL.cjs → multibase-B5Mea7Ip.cjs} +19 -2
- package/dist/tests/{multibase-B4bvakyA.mjs → multibase-BPnF_L4e.mjs} +12 -1
- package/dist/tests/portable-dereference-BNXtgg5U.cjs +278 -0
- package/dist/tests/portable-dereference-DRE5bz-l.mjs +249 -0
- package/dist/tests/portable-media-C4LEXJk4.mjs +148 -0
- package/dist/tests/portable-media-D05JJIJg.cjs +153 -0
- package/dist/tests/portable-media.test.cjs +222 -0
- package/dist/tests/portable-media.test.d.cts +1 -0
- package/dist/tests/portable-media.test.d.mts +1 -0
- package/dist/tests/portable-media.test.mjs +223 -0
- package/dist/tests/portable-workers.test.cjs +36 -0
- package/dist/tests/portable-workers.test.d.cts +2 -0
- package/dist/tests/portable-workers.test.d.mts +2 -0
- package/dist/tests/portable-workers.test.mjs +35 -0
- package/dist/tests/{request-uk51rkhO.cjs → request-C-VZ9TLj.cjs} +10 -4
- package/dist/tests/{request-C8CaGwtt.mjs → request-Cf-A3DU-.mjs} +8 -2
- package/dist/tests/request.test.cjs +7 -4
- package/dist/tests/request.test.mjs +5 -2
- package/dist/tests/signed-representation.test.cjs +588 -0
- package/dist/tests/signed-representation.test.d.cts +1 -0
- package/dist/tests/signed-representation.test.d.mts +1 -0
- package/dist/tests/signed-representation.test.mjs +589 -0
- package/dist/tests/temporal.test.cjs +1 -2
- package/dist/tests/temporal.test.mjs +1 -1
- package/dist/tests/url-BNakuZ8k.cjs +998 -0
- package/dist/tests/url-DMxmp7ZG.mjs +859 -0
- package/dist/tests/url.test.cjs +489 -6
- package/dist/tests/url.test.mjs +489 -5
- package/dist/url-DrGTR8yv.cjs +993 -0
- package/dist/url-Dzyp-NsC.js +860 -0
- package/package.json +27 -4
- package/scripts/test-bun.mjs +17 -0
- package/src/body.test.ts +125 -0
- package/src/body.ts +152 -0
- package/src/contexts/cid-v1.json +114 -0
- package/src/contexts/fep-22cd.json +21 -0
- package/src/contexts/miscellany.json +17 -0
- package/src/contexts.ts +39 -1
- package/src/digest.test.ts +220 -0
- package/src/digest.ts +229 -0
- package/src/docloader.test.ts +918 -27
- package/src/docloader.ts +320 -105
- package/src/internal/jsonld-cache.ts +97 -1
- package/src/internal/portable-dereference.test.ts +254 -0
- package/src/internal/portable-dereference.ts +1000 -0
- package/src/internal/signed-representation.ts +565 -0
- package/src/jsonld-cache.test.ts +89 -0
- package/src/key.test.ts +9 -0
- package/src/key.ts +11 -1
- package/src/mod.ts +28 -0
- package/src/multibase/multibase.test.ts +5 -5
- package/src/portable-media.test.ts +293 -0
- package/src/portable-media.ts +264 -0
- package/src/portable-workers.test.ts +81 -0
- package/src/portable.ts +180 -0
- package/src/preprocessor.ts +7 -0
- package/src/request.test.ts +10 -1
- package/src/request.ts +9 -1
- package/src/signed-representation.test.ts +338 -0
- package/src/url.test.ts +823 -3
- package/src/url.ts +700 -23
- package/tsdown.config.ts +2 -0
- package/dist/tests/url-CsOV_B_P.cjs +0 -482
- package/dist/tests/url-Du7RQQgP.mjs +0 -392
- package/dist/url-DD4F0ULf.cjs +0 -483
- package/dist/url-DGVbSVVi.js +0 -393
- /package/dist/{chunk-M78iaK0I.cjs → rolldown-runtime-B7lfambq.cjs} +0 -0
- /package/dist/tests/{langstr-CbAxaeEZ.cjs → langstr-C4Fl80ae.cjs} +0 -0
- /package/dist/tests/{langstr-Di5AvKpB.mjs → langstr-CQ26J_L7.mjs} +0 -0
- /package/dist/tests/{link-NUUWCdnK.mjs → link-Cevmc87v.mjs} +0 -0
- /package/dist/tests/{link-FguCydMA.cjs → link-DlKm8bEr.cjs} +0 -0
- /package/dist/tests/{multicodec-CxGVGa91.cjs → multicodec-CLRPeW4N.cjs} +0 -0
- /package/dist/tests/{multicodec-CyFp54fI.mjs → multicodec-CRIj_05H.mjs} +0 -0
- /package/dist/tests/{chunk-C2EiDwsr.cjs → rolldown-runtime-emK7D4bc.cjs} +0 -0
package/deno.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/vocab-runtime",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0-dev.2271+49d937e2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./src/mod.ts",
|
|
7
7
|
"./internal/jsonld-cache": "./src/internal/jsonld-cache.ts",
|
|
8
|
+
"./internal/portable-dereference": "./src/internal/portable-dereference.ts",
|
|
9
|
+
"./internal/signed-representation": "./src/internal/signed-representation.ts",
|
|
8
10
|
"./jsonld": "./src/jsonld.ts",
|
|
9
11
|
"./temporal": "./src/temporal.ts"
|
|
10
12
|
},
|
|
@@ -34,6 +36,6 @@
|
|
|
34
36
|
},
|
|
35
37
|
"tasks": {
|
|
36
38
|
"check": "deno fmt --check && deno lint && deno check src/*.ts",
|
|
37
|
-
"test": "deno test"
|
|
39
|
+
"test": "deno test --allow-net --allow-env=LOG"
|
|
38
40
|
}
|
|
39
41
|
}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { t as HttpHeaderLink } from "./link-NUUWCdnK.mjs";
|
|
3
|
-
import { h as validatePublicUrl, t as UrlError } from "./url-Du7RQQgP.mjs";
|
|
4
|
-
import { getLogger } from "@logtape/logtape";
|
|
5
|
-
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
1
|
+
|
|
6
2
|
//#endregion
|
|
7
3
|
//#region src/contexts.ts
|
|
8
4
|
const preloadedContexts = {
|
|
@@ -4239,6 +4235,34 @@ const preloadedContexts = {
|
|
|
4239
4235
|
"@type": "@id"
|
|
4240
4236
|
}
|
|
4241
4237
|
} },
|
|
4238
|
+
"https://w3id.org/fep/22cd": { "@context": {
|
|
4239
|
+
"fep-22cd": "https://w3id.org/fep/22cd#",
|
|
4240
|
+
"schema": "https://schema.org/",
|
|
4241
|
+
"xsd": "http://www.w3.org/2001/XMLSchema#",
|
|
4242
|
+
"translations": {
|
|
4243
|
+
"@id": "fep-22cd:translations",
|
|
4244
|
+
"@container": "@set"
|
|
4245
|
+
},
|
|
4246
|
+
"Translation": "fep-22cd:Translation",
|
|
4247
|
+
"sourceUpdated": {
|
|
4248
|
+
"@id": "fep-22cd:sourceUpdated",
|
|
4249
|
+
"@type": "xsd:dateTime"
|
|
4250
|
+
},
|
|
4251
|
+
"translator": {
|
|
4252
|
+
"@id": "schema:translator",
|
|
4253
|
+
"@type": "@id",
|
|
4254
|
+
"@container": "@set"
|
|
4255
|
+
},
|
|
4256
|
+
"inLanguage": "schema:inLanguage",
|
|
4257
|
+
"translationOfWork": {
|
|
4258
|
+
"@id": "schema:translationOfWork",
|
|
4259
|
+
"@type": "@id"
|
|
4260
|
+
},
|
|
4261
|
+
"isBasedOn": {
|
|
4262
|
+
"@id": "schema:isBasedOn",
|
|
4263
|
+
"@type": "@id"
|
|
4264
|
+
}
|
|
4265
|
+
} },
|
|
4242
4266
|
"https://w3id.org/fep/5711": { "@context": {
|
|
4243
4267
|
"likesOf": {
|
|
4244
4268
|
"@id": "https://w3id.org/fep/5711#likesOf",
|
|
@@ -4273,6 +4297,125 @@ const preloadedContexts = {
|
|
|
4273
4297
|
"@type": "@id"
|
|
4274
4298
|
}
|
|
4275
4299
|
} },
|
|
4300
|
+
"https://www.w3.org/ns/cid/v1": { "@context": {
|
|
4301
|
+
"@protected": true,
|
|
4302
|
+
"id": "@id",
|
|
4303
|
+
"type": "@type",
|
|
4304
|
+
"alsoKnownAs": {
|
|
4305
|
+
"@id": "https://www.w3.org/ns/activitystreams#alsoKnownAs",
|
|
4306
|
+
"@type": "@id"
|
|
4307
|
+
},
|
|
4308
|
+
"assertionMethod": {
|
|
4309
|
+
"@id": "https://w3id.org/security#assertionMethod",
|
|
4310
|
+
"@type": "@id",
|
|
4311
|
+
"@container": "@set"
|
|
4312
|
+
},
|
|
4313
|
+
"authentication": {
|
|
4314
|
+
"@id": "https://w3id.org/security#authenticationMethod",
|
|
4315
|
+
"@type": "@id",
|
|
4316
|
+
"@container": "@set"
|
|
4317
|
+
},
|
|
4318
|
+
"capabilityDelegation": {
|
|
4319
|
+
"@id": "https://w3id.org/security#capabilityDelegationMethod",
|
|
4320
|
+
"@type": "@id",
|
|
4321
|
+
"@container": "@set"
|
|
4322
|
+
},
|
|
4323
|
+
"capabilityInvocation": {
|
|
4324
|
+
"@id": "https://w3id.org/security#capabilityInvocationMethod",
|
|
4325
|
+
"@type": "@id",
|
|
4326
|
+
"@container": "@set"
|
|
4327
|
+
},
|
|
4328
|
+
"controller": {
|
|
4329
|
+
"@id": "https://w3id.org/security#controller",
|
|
4330
|
+
"@type": "@id"
|
|
4331
|
+
},
|
|
4332
|
+
"keyAgreement": {
|
|
4333
|
+
"@id": "https://w3id.org/security#keyAgreementMethod",
|
|
4334
|
+
"@type": "@id",
|
|
4335
|
+
"@container": "@set"
|
|
4336
|
+
},
|
|
4337
|
+
"service": {
|
|
4338
|
+
"@id": "https://www.w3.org/ns/did#service",
|
|
4339
|
+
"@type": "@id",
|
|
4340
|
+
"@context": {
|
|
4341
|
+
"@protected": true,
|
|
4342
|
+
"id": "@id",
|
|
4343
|
+
"type": "@type",
|
|
4344
|
+
"serviceEndpoint": {
|
|
4345
|
+
"@id": "https://www.w3.org/ns/did#serviceEndpoint",
|
|
4346
|
+
"@type": "@id"
|
|
4347
|
+
}
|
|
4348
|
+
}
|
|
4349
|
+
},
|
|
4350
|
+
"verificationMethod": {
|
|
4351
|
+
"@id": "https://w3id.org/security#verificationMethod",
|
|
4352
|
+
"@type": "@id"
|
|
4353
|
+
},
|
|
4354
|
+
"Multikey": {
|
|
4355
|
+
"@id": "https://w3id.org/security#Multikey",
|
|
4356
|
+
"@context": {
|
|
4357
|
+
"@protected": true,
|
|
4358
|
+
"id": "@id",
|
|
4359
|
+
"type": "@type",
|
|
4360
|
+
"controller": {
|
|
4361
|
+
"@id": "https://w3id.org/security#controller",
|
|
4362
|
+
"@type": "@id"
|
|
4363
|
+
},
|
|
4364
|
+
"revoked": {
|
|
4365
|
+
"@id": "https://w3id.org/security#revoked",
|
|
4366
|
+
"@type": "http://www.w3.org/2001/XMLSchema#dateTime"
|
|
4367
|
+
},
|
|
4368
|
+
"expires": {
|
|
4369
|
+
"@id": "https://w3id.org/security#expiration",
|
|
4370
|
+
"@type": "http://www.w3.org/2001/XMLSchema#dateTime"
|
|
4371
|
+
},
|
|
4372
|
+
"publicKeyMultibase": {
|
|
4373
|
+
"@id": "https://w3id.org/security#publicKeyMultibase",
|
|
4374
|
+
"@type": "https://w3id.org/security#multibase"
|
|
4375
|
+
},
|
|
4376
|
+
"secretKeyMultibase": {
|
|
4377
|
+
"@id": "https://w3id.org/security#secretKeyMultibase",
|
|
4378
|
+
"@type": "https://w3id.org/security#multibase"
|
|
4379
|
+
}
|
|
4380
|
+
}
|
|
4381
|
+
},
|
|
4382
|
+
"JsonWebKey": {
|
|
4383
|
+
"@id": "https://w3id.org/security#JsonWebKey",
|
|
4384
|
+
"@context": {
|
|
4385
|
+
"@protected": true,
|
|
4386
|
+
"id": "@id",
|
|
4387
|
+
"type": "@type",
|
|
4388
|
+
"controller": {
|
|
4389
|
+
"@id": "https://w3id.org/security#controller",
|
|
4390
|
+
"@type": "@id"
|
|
4391
|
+
},
|
|
4392
|
+
"revoked": {
|
|
4393
|
+
"@id": "https://w3id.org/security#revoked",
|
|
4394
|
+
"@type": "http://www.w3.org/2001/XMLSchema#dateTime"
|
|
4395
|
+
},
|
|
4396
|
+
"expires": {
|
|
4397
|
+
"@id": "https://w3id.org/security#expiration",
|
|
4398
|
+
"@type": "http://www.w3.org/2001/XMLSchema#dateTime"
|
|
4399
|
+
},
|
|
4400
|
+
"publicKeyJwk": {
|
|
4401
|
+
"@id": "https://w3id.org/security#publicKeyJwk",
|
|
4402
|
+
"@type": "@json"
|
|
4403
|
+
},
|
|
4404
|
+
"secretKeyJwk": {
|
|
4405
|
+
"@id": "https://w3id.org/security#secretKeyJwk",
|
|
4406
|
+
"@type": "@json"
|
|
4407
|
+
}
|
|
4408
|
+
}
|
|
4409
|
+
}
|
|
4410
|
+
} },
|
|
4411
|
+
"https://w3id.org/fep/ef61": { "@context": {
|
|
4412
|
+
"gateways": {
|
|
4413
|
+
"@id": "https://w3id.org/fep/ef61/gateways",
|
|
4414
|
+
"@type": "@id",
|
|
4415
|
+
"@container": "@list"
|
|
4416
|
+
},
|
|
4417
|
+
"digestMultibase": "https://www.w3.org/ns/credentials/v2#digestMultibase"
|
|
4418
|
+
} },
|
|
4276
4419
|
"https://w3id.org/fep/7aa9": { "@context": {
|
|
4277
4420
|
"FeaturedCollection": "https://w3id.org/fep/7aa9#FeaturedCollection",
|
|
4278
4421
|
"FeaturedItem": "https://w3id.org/fep/7aa9#FeaturedItem",
|
|
@@ -4295,14 +4438,6 @@ const preloadedContexts = {
|
|
|
4295
4438
|
"@type": "@id"
|
|
4296
4439
|
}
|
|
4297
4440
|
} },
|
|
4298
|
-
"https://w3id.org/fep/ef61": { "@context": {
|
|
4299
|
-
"gateways": {
|
|
4300
|
-
"@id": "https://w3id.org/fep/ef61/gateways",
|
|
4301
|
-
"@type": "@id",
|
|
4302
|
-
"@container": "@list"
|
|
4303
|
-
},
|
|
4304
|
-
"digestMultibase": "https://www.w3.org/ns/credentials/v2#digestMultibase"
|
|
4305
|
-
} },
|
|
4306
4441
|
"https://join-lemmy.org/context.json": { "@context": ["https://w3id.org/security/v1", {
|
|
4307
4442
|
"as": "https://www.w3.org/ns/activitystreams#",
|
|
4308
4443
|
"lemmy": "https://join-lemmy.org/ns#",
|
|
@@ -4356,269 +4491,23 @@ const preloadedContexts = {
|
|
|
4356
4491
|
"@id": "toot:attributionDomains",
|
|
4357
4492
|
"@type": "@id"
|
|
4358
4493
|
}
|
|
4494
|
+
} },
|
|
4495
|
+
"https://purl.archive.org/miscellany": { "@context": {
|
|
4496
|
+
"as": "https://www.w3.org/ns/activitystreams#",
|
|
4497
|
+
"xsd": "http://www.w3.org/2001/XMLSchema#",
|
|
4498
|
+
"Hashtag": "as:Hashtag",
|
|
4499
|
+
"manuallyApprovesFollowers": { "@id": "as:manuallyApprovesFollowers" },
|
|
4500
|
+
"movedTo": {
|
|
4501
|
+
"@id": "as:movedTo",
|
|
4502
|
+
"@type": "@id"
|
|
4503
|
+
},
|
|
4504
|
+
"sensitive": { "@id": "as:sensitive" }
|
|
4359
4505
|
} }
|
|
4360
4506
|
};
|
|
4361
4507
|
//#endregion
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
"docloader"
|
|
4367
|
-
]);
|
|
4368
|
-
const DEFAULT_MAX_REDIRECTION = 20;
|
|
4369
|
-
const MAX_HTML_SIZE = 1024 * 1024;
|
|
4370
|
-
function createResponseMetadata(response) {
|
|
4371
|
-
return new Response(null, {
|
|
4372
|
-
headers: response.headers,
|
|
4373
|
-
status: response.status,
|
|
4374
|
-
statusText: response.statusText
|
|
4375
|
-
});
|
|
4376
|
-
}
|
|
4377
|
-
async function cancelResponseBody(response) {
|
|
4378
|
-
if (response.body != null) await response.body.cancel();
|
|
4379
|
-
}
|
|
4380
|
-
async function readBoundedText(response, maxBytes) {
|
|
4381
|
-
const contentLength = response.headers.get("Content-Length");
|
|
4382
|
-
if (contentLength != null) {
|
|
4383
|
-
const size = Number(contentLength);
|
|
4384
|
-
if (size > maxBytes) {
|
|
4385
|
-
await cancelResponseBody(response);
|
|
4386
|
-
return {
|
|
4387
|
-
text: "",
|
|
4388
|
-
size,
|
|
4389
|
-
tooLarge: true
|
|
4390
|
-
};
|
|
4391
|
-
}
|
|
4392
|
-
}
|
|
4393
|
-
if (response.body == null) return {
|
|
4394
|
-
text: "",
|
|
4395
|
-
size: 0,
|
|
4396
|
-
tooLarge: false
|
|
4397
|
-
};
|
|
4398
|
-
const reader = response.body.getReader();
|
|
4399
|
-
const decoder = new TextDecoder();
|
|
4400
|
-
let text = "";
|
|
4401
|
-
let size = 0;
|
|
4402
|
-
try {
|
|
4403
|
-
while (true) {
|
|
4404
|
-
const result = await reader.read();
|
|
4405
|
-
if (result.done) break;
|
|
4406
|
-
const chunkSize = result.value.byteLength;
|
|
4407
|
-
if (size + chunkSize > maxBytes) {
|
|
4408
|
-
size += chunkSize;
|
|
4409
|
-
await reader.cancel();
|
|
4410
|
-
return {
|
|
4411
|
-
text: "",
|
|
4412
|
-
size,
|
|
4413
|
-
tooLarge: true
|
|
4414
|
-
};
|
|
4415
|
-
}
|
|
4416
|
-
size += chunkSize;
|
|
4417
|
-
text += decoder.decode(result.value, { stream: true });
|
|
4418
|
-
}
|
|
4419
|
-
text += decoder.decode();
|
|
4420
|
-
return {
|
|
4421
|
-
text,
|
|
4422
|
-
size,
|
|
4423
|
-
tooLarge: false
|
|
4424
|
-
};
|
|
4425
|
-
} finally {
|
|
4426
|
-
reader.releaseLock();
|
|
4508
|
+
Object.defineProperty(exports, "preloadedContexts", {
|
|
4509
|
+
enumerable: true,
|
|
4510
|
+
get: function() {
|
|
4511
|
+
return preloadedContexts;
|
|
4427
4512
|
}
|
|
4428
|
-
}
|
|
4429
|
-
/**
|
|
4430
|
-
* Gets a {@link RemoteDocument} from the given response.
|
|
4431
|
-
* @param url The URL of the document to load.
|
|
4432
|
-
* @param response The response to get the document from.
|
|
4433
|
-
* @param fetch The function to fetch the document.
|
|
4434
|
-
* @returns The loaded remote document.
|
|
4435
|
-
* @throws {FetchError} If the response is not OK.
|
|
4436
|
-
* @internal
|
|
4437
|
-
*/
|
|
4438
|
-
async function getRemoteDocument(url, response, fetch) {
|
|
4439
|
-
const documentUrl = response.url === "" ? url : response.url;
|
|
4440
|
-
const docUrl = new URL(documentUrl);
|
|
4441
|
-
if (!response.ok) {
|
|
4442
|
-
logger.error("Failed to fetch document: {status} {url} {headers}", {
|
|
4443
|
-
status: response.status,
|
|
4444
|
-
url: documentUrl,
|
|
4445
|
-
headers: Object.fromEntries(response.headers.entries())
|
|
4446
|
-
});
|
|
4447
|
-
throw new FetchError(documentUrl, `HTTP ${response.status}: ${documentUrl}`, response.clone());
|
|
4448
|
-
}
|
|
4449
|
-
const contentType = response.headers.get("Content-Type");
|
|
4450
|
-
const jsonLd = contentType == null || contentType === "application/activity+json" || contentType.startsWith("application/activity+json;") || contentType === "application/ld+json" || contentType.startsWith("application/ld+json;");
|
|
4451
|
-
const linkHeader = response.headers.get("Link");
|
|
4452
|
-
let contextUrl = null;
|
|
4453
|
-
if (linkHeader != null) {
|
|
4454
|
-
let link;
|
|
4455
|
-
try {
|
|
4456
|
-
link = new HttpHeaderLink(linkHeader);
|
|
4457
|
-
} catch (e) {
|
|
4458
|
-
if (e instanceof SyntaxError) link = new HttpHeaderLink();
|
|
4459
|
-
else throw e;
|
|
4460
|
-
}
|
|
4461
|
-
if (jsonLd) {
|
|
4462
|
-
const entries = link.getByRel("http://www.w3.org/ns/json-ld#context");
|
|
4463
|
-
for (const [uri, params] of entries) if ("type" in params && params.type === "application/ld+json") {
|
|
4464
|
-
contextUrl = uri;
|
|
4465
|
-
break;
|
|
4466
|
-
}
|
|
4467
|
-
} else {
|
|
4468
|
-
const entries = link.getByRel("alternate");
|
|
4469
|
-
for (const [uri, params] of entries) {
|
|
4470
|
-
const altUri = new URL(uri, docUrl);
|
|
4471
|
-
if ("type" in params && (params.type === "application/activity+json" || params.type === "application/ld+json" || params.type.startsWith("application/ld+json;")) && altUri.href !== docUrl.href) {
|
|
4472
|
-
logger.debug("Found alternate document: {alternateUrl} from {url}", {
|
|
4473
|
-
alternateUrl: altUri.href,
|
|
4474
|
-
url: documentUrl
|
|
4475
|
-
});
|
|
4476
|
-
return await fetch(altUri.href);
|
|
4477
|
-
}
|
|
4478
|
-
}
|
|
4479
|
-
}
|
|
4480
|
-
}
|
|
4481
|
-
let document;
|
|
4482
|
-
if (!jsonLd && (contentType === "text/html" || contentType?.startsWith("text/html;") || contentType === "application/xhtml+xml" || contentType?.startsWith("application/xhtml+xml;"))) {
|
|
4483
|
-
const errorResponse = createResponseMetadata(response);
|
|
4484
|
-
const html = await readBoundedText(response, MAX_HTML_SIZE);
|
|
4485
|
-
if (html.tooLarge) {
|
|
4486
|
-
logger.warn("HTML response too large, skipping alternate link discovery: {url}", {
|
|
4487
|
-
url: documentUrl,
|
|
4488
|
-
size: html.size
|
|
4489
|
-
});
|
|
4490
|
-
throw new FetchError(documentUrl, `HTML document is too large to scan for an ActivityPub alternate link (Content-Type: ${contentType})`, errorResponse);
|
|
4491
|
-
} else {
|
|
4492
|
-
const tagPattern = /<(a|link)\s+([^>]*?)\s*\/?>/gi;
|
|
4493
|
-
const attrPattern = /([a-z][a-z:_-]*)=(?:"([^"]*)"|'([^']*)'|([^\s>]+))/gi;
|
|
4494
|
-
let tagMatch;
|
|
4495
|
-
while ((tagMatch = tagPattern.exec(html.text)) !== null) {
|
|
4496
|
-
const tagContent = tagMatch[2];
|
|
4497
|
-
let attrMatch;
|
|
4498
|
-
const attribs = {};
|
|
4499
|
-
attrPattern.lastIndex = 0;
|
|
4500
|
-
while ((attrMatch = attrPattern.exec(tagContent)) !== null) {
|
|
4501
|
-
const key = attrMatch[1].toLowerCase();
|
|
4502
|
-
attribs[key] = attrMatch[2] ?? attrMatch[3] ?? attrMatch[4] ?? "";
|
|
4503
|
-
}
|
|
4504
|
-
if (attribs.rel === "alternate" && "type" in attribs && (attribs.type === "application/activity+json" || attribs.type === "application/ld+json" || attribs.type.startsWith("application/ld+json;")) && "href" in attribs && new URL(attribs.href, docUrl).href !== docUrl.href) {
|
|
4505
|
-
logger.debug("Found alternate document: {alternateUrl} from {url}", {
|
|
4506
|
-
alternateUrl: attribs.href,
|
|
4507
|
-
url: documentUrl
|
|
4508
|
-
});
|
|
4509
|
-
return await fetch(new URL(attribs.href, docUrl).href);
|
|
4510
|
-
}
|
|
4511
|
-
}
|
|
4512
|
-
try {
|
|
4513
|
-
document = JSON.parse(html.text);
|
|
4514
|
-
} catch (error) {
|
|
4515
|
-
if (!(error instanceof SyntaxError)) throw error;
|
|
4516
|
-
throw new FetchError(documentUrl, `HTML document has no ActivityPub alternate link (Content-Type: ${contentType})`, errorResponse);
|
|
4517
|
-
}
|
|
4518
|
-
}
|
|
4519
|
-
} else document = await response.json();
|
|
4520
|
-
logger.debug("Fetched document: {status} {url} {headers}", {
|
|
4521
|
-
status: response.status,
|
|
4522
|
-
url: documentUrl,
|
|
4523
|
-
headers: Object.fromEntries(response.headers.entries())
|
|
4524
|
-
});
|
|
4525
|
-
return {
|
|
4526
|
-
contextUrl,
|
|
4527
|
-
document,
|
|
4528
|
-
documentUrl
|
|
4529
|
-
};
|
|
4530
|
-
}
|
|
4531
|
-
/**
|
|
4532
|
-
* Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
|
|
4533
|
-
*
|
|
4534
|
-
* The created loader preloads the below frequently used contexts by default
|
|
4535
|
-
* (unless `options.skipPreloadedContexts` is set to `true`):
|
|
4536
|
-
*
|
|
4537
|
-
* - <https://www.w3.org/ns/activitystreams>
|
|
4538
|
-
* - <https://w3id.org/security/v1>
|
|
4539
|
-
* - <https://w3id.org/security/data-integrity/v1>
|
|
4540
|
-
* - <https://w3id.org/security/data-integrity/v2>
|
|
4541
|
-
* - <https://www.w3.org/ns/did/v1>
|
|
4542
|
-
* - <https://w3id.org/security/multikey/v1>
|
|
4543
|
-
* - <https://w3id.org/fep/ef61>
|
|
4544
|
-
* - <https://purl.archive.org/socialweb/webfinger>
|
|
4545
|
-
* - <http://schema.org/>
|
|
4546
|
-
* @param options Options for the document loader.
|
|
4547
|
-
* @returns The document loader.
|
|
4548
|
-
* @since 1.3.0
|
|
4549
|
-
*/
|
|
4550
|
-
function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedContexts, userAgent } = {}) {
|
|
4551
|
-
const tracer = trace.getTracerProvider().getTracer(name, version);
|
|
4552
|
-
const maximumRedirection = maxRedirection ?? DEFAULT_MAX_REDIRECTION;
|
|
4553
|
-
async function load(url, options, redirected = 0, visited = /* @__PURE__ */ new Set()) {
|
|
4554
|
-
options?.signal?.throwIfAborted();
|
|
4555
|
-
const currentUrl = new URL(url).href;
|
|
4556
|
-
if (!skipPreloadedContexts && currentUrl in preloadedContexts) {
|
|
4557
|
-
logger.debug("Using preloaded context: {url}.", { url: currentUrl });
|
|
4558
|
-
return {
|
|
4559
|
-
contextUrl: null,
|
|
4560
|
-
document: preloadedContexts[currentUrl],
|
|
4561
|
-
documentUrl: currentUrl
|
|
4562
|
-
};
|
|
4563
|
-
}
|
|
4564
|
-
if (!allowPrivateAddress) try {
|
|
4565
|
-
await validatePublicUrl(currentUrl);
|
|
4566
|
-
} catch (error) {
|
|
4567
|
-
if (error instanceof UrlError) logger.error("Disallowed private URL: {url}", {
|
|
4568
|
-
url: currentUrl,
|
|
4569
|
-
error
|
|
4570
|
-
});
|
|
4571
|
-
throw error;
|
|
4572
|
-
}
|
|
4573
|
-
visited.add(currentUrl);
|
|
4574
|
-
return await tracer.startActiveSpan("activitypub.fetch_document", {
|
|
4575
|
-
kind: SpanKind.CLIENT,
|
|
4576
|
-
attributes: { "url.full": currentUrl }
|
|
4577
|
-
}, async (span) => {
|
|
4578
|
-
try {
|
|
4579
|
-
const request = createActivityPubRequest(currentUrl, { userAgent });
|
|
4580
|
-
logRequest(logger, request);
|
|
4581
|
-
const response = await fetch(request, {
|
|
4582
|
-
redirect: "manual",
|
|
4583
|
-
signal: options?.signal
|
|
4584
|
-
});
|
|
4585
|
-
span.setAttribute("http.response.status_code", response.status);
|
|
4586
|
-
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
|
|
4587
|
-
if (redirected >= maximumRedirection) {
|
|
4588
|
-
logger.error("Too many redirections ({redirections}) while fetching document.", {
|
|
4589
|
-
redirections: redirected + 1,
|
|
4590
|
-
url: currentUrl
|
|
4591
|
-
});
|
|
4592
|
-
throw new FetchError(currentUrl, `Too many redirections (${redirected + 1})`);
|
|
4593
|
-
}
|
|
4594
|
-
const redirectUrl = new URL(response.headers.get("Location"), response.url === "" ? currentUrl : response.url).href;
|
|
4595
|
-
span.setAttribute("http.redirect.url", redirectUrl);
|
|
4596
|
-
if (visited.has(redirectUrl)) {
|
|
4597
|
-
logger.error("Detected a redirect loop while fetching document: {url} -> {redirectUrl}", {
|
|
4598
|
-
url: currentUrl,
|
|
4599
|
-
redirectUrl
|
|
4600
|
-
});
|
|
4601
|
-
throw new FetchError(currentUrl, `Redirect loop detected: ${redirectUrl}`);
|
|
4602
|
-
}
|
|
4603
|
-
return await load(redirectUrl, options, redirected + 1, visited);
|
|
4604
|
-
}
|
|
4605
|
-
const result = await getRemoteDocument(currentUrl, response, load);
|
|
4606
|
-
span.setAttribute("docloader.document_url", result.documentUrl);
|
|
4607
|
-
if (result.contextUrl != null) span.setAttribute("docloader.context_url", result.contextUrl);
|
|
4608
|
-
return result;
|
|
4609
|
-
} catch (error) {
|
|
4610
|
-
span.recordException(error);
|
|
4611
|
-
span.setStatus({
|
|
4612
|
-
code: SpanStatusCode.ERROR,
|
|
4613
|
-
message: String(error)
|
|
4614
|
-
});
|
|
4615
|
-
throw error;
|
|
4616
|
-
} finally {
|
|
4617
|
-
span.end();
|
|
4618
|
-
}
|
|
4619
|
-
});
|
|
4620
|
-
}
|
|
4621
|
-
return load;
|
|
4622
|
-
}
|
|
4623
|
-
//#endregion
|
|
4624
|
-
export { getRemoteDocument as n, preloadedContexts as r, getDocumentLoader as t };
|
|
4513
|
+
});
|