@oxy.so/federation 3.1.0 → 3.2.0
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/dist/cjs/index.js +17 -30
- package/dist/cjs/network.js +43 -0
- package/dist/esm/index.js +2 -11
- package/dist/esm/network.js +22 -0
- package/dist/types/index.d.ts +2 -11
- package/dist/types/network.d.ts +12 -0
- package/package.json +12 -1
- package/src/__tests__/networkEntry.test.ts +26 -0
- package/src/index.ts +2 -40
- package/src/network.ts +51 -0
package/dist/cjs/index.js
CHANGED
|
@@ -21,8 +21,22 @@
|
|
|
21
21
|
* the consuming app (Mention passes its `PostContent`). The engine holds no
|
|
22
22
|
* knowledge of any app's post shape.
|
|
23
23
|
*/
|
|
24
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
27
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
28
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
29
|
+
}
|
|
30
|
+
Object.defineProperty(o, k2, desc);
|
|
31
|
+
}) : (function(o, m, k, k2) {
|
|
32
|
+
if (k2 === undefined) k2 = k;
|
|
33
|
+
o[k2] = m[k];
|
|
34
|
+
}));
|
|
35
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
+
};
|
|
24
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.groupFollowersCollection = exports.groupOutboxCollection = exports.isGroupActorKind = exports.GROUP_OUTBOX_SIZE = exports.LOCAL_ACTOR_TYPE_BY_ACCOUNT_KIND = exports.AP_ACTOR_TYPES = exports.isApActorType = exports.accountKindForActor = exports.localActorTypeForAccountKind = exports.normalizeAlsoKnownAs = exports.createLocalActorBuilder = exports.apDate = exports.isActivityPubMediaType = exports.apMediaTypeBase = exports.apImageUrl = exports.apIriList = exports.apIri = exports.apList = exports.createDomainPolicy = exports.extractActorUriFromActivityId = exports.isSameFederationHost = exports.canonicalFederationHost = exports.AP_CONTEXT = exports.
|
|
39
|
+
exports.groupFollowersCollection = exports.groupOutboxCollection = exports.isGroupActorKind = exports.GROUP_OUTBOX_SIZE = exports.LOCAL_ACTOR_TYPE_BY_ACCOUNT_KIND = exports.AP_ACTOR_TYPES = exports.isApActorType = exports.accountKindForActor = exports.localActorTypeForAccountKind = exports.normalizeAlsoKnownAs = exports.createLocalActorBuilder = exports.apDate = exports.isActivityPubMediaType = exports.apMediaTypeBase = exports.apImageUrl = exports.apIriList = exports.apIri = exports.apList = exports.createDomainPolicy = exports.extractActorUriFromActivityId = exports.isSameFederationHost = exports.canonicalFederationHost = exports.AP_CONTEXT = exports.INSTANCE_ACTOR_USERNAME = exports.normalizeActorUsername = exports.createUrlBuilders = exports.DEFAULT_SIGNED_CONTENT_TYPE = exports.HTTP_SIGNATURE_ALGORITHM = exports.verifyHttpSignature = exports.signRequest = void 0;
|
|
26
40
|
/**
|
|
27
41
|
* HTTP Signatures (draft-cavage) — the pure sign/verify crypto every Oxy app's
|
|
28
42
|
* ActivityPub federation shares. Private-key custody is injected; the key never
|
|
@@ -41,35 +55,8 @@ var urls_1 = require("./urls");
|
|
|
41
55
|
Object.defineProperty(exports, "createUrlBuilders", { enumerable: true, get: function () { return urls_1.createUrlBuilders; } });
|
|
42
56
|
Object.defineProperty(exports, "normalizeActorUsername", { enumerable: true, get: function () { return urls_1.normalizeActorUsername; } });
|
|
43
57
|
Object.defineProperty(exports, "INSTANCE_ACTOR_USERNAME", { enumerable: true, get: function () { return urls_1.INSTANCE_ACTOR_USERNAME; } });
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
* bridge onto the network it actually came from, plus the network vocabulary and
|
|
47
|
-
* the bidirectional upstream-profile-URL rule.
|
|
48
|
-
*
|
|
49
|
-
* The mechanism is here; the ENTRIES are not, and must not be. Which operators
|
|
50
|
-
* may be trusted to re-attribute somebody's account is a moderation judgement an
|
|
51
|
-
* app commits and answers for — `createBridgeRelabeller` takes them as a
|
|
52
|
-
* parameter so no app inherits another's.
|
|
53
|
-
*/
|
|
54
|
-
var networkIdentity_1 = require("./networkIdentity");
|
|
55
|
-
Object.defineProperty(exports, "FEDERATION_NETWORKS", { enumerable: true, get: function () { return networkIdentity_1.FEDERATION_NETWORKS; } });
|
|
56
|
-
Object.defineProperty(exports, "BSKY_NETWORK_DOMAIN", { enumerable: true, get: function () { return networkIdentity_1.BSKY_NETWORK_DOMAIN; } });
|
|
57
|
-
Object.defineProperty(exports, "blueskyUsernameFromHandle", { enumerable: true, get: function () { return networkIdentity_1.blueskyUsernameFromHandle; } });
|
|
58
|
-
Object.defineProperty(exports, "blueskyHandleFromUsername", { enumerable: true, get: function () { return networkIdentity_1.blueskyHandleFromUsername; } });
|
|
59
|
-
Object.defineProperty(exports, "UNRESOLVED_ATPROTO_HANDLE", { enumerable: true, get: function () { return networkIdentity_1.UNRESOLVED_ATPROTO_HANDLE; } });
|
|
60
|
-
Object.defineProperty(exports, "isUnresolvedAtprotoHandle", { enumerable: true, get: function () { return networkIdentity_1.isUnresolvedAtprotoHandle; } });
|
|
61
|
-
Object.defineProperty(exports, "atprotoIdentityHandle", { enumerable: true, get: function () { return networkIdentity_1.atprotoIdentityHandle; } });
|
|
62
|
-
Object.defineProperty(exports, "createBridgeRelabeller", { enumerable: true, get: function () { return networkIdentity_1.createBridgeRelabeller; } });
|
|
63
|
-
Object.defineProperty(exports, "stripBridgeBoilerplate", { enumerable: true, get: function () { return networkIdentity_1.stripBridgeBoilerplate; } });
|
|
64
|
-
Object.defineProperty(exports, "upstreamProfileUrl", { enumerable: true, get: function () { return networkIdentity_1.upstreamProfileUrl; } });
|
|
65
|
-
Object.defineProperty(exports, "parseUpstreamProfileUrl", { enumerable: true, get: function () { return networkIdentity_1.parseUpstreamProfileUrl; } });
|
|
66
|
-
Object.defineProperty(exports, "federatedUsernameFromUpstreamUrl", { enumerable: true, get: function () { return networkIdentity_1.federatedUsernameFromUpstreamUrl; } });
|
|
67
|
-
Object.defineProperty(exports, "upstreamHandleFromProfileField", { enumerable: true, get: function () { return networkIdentity_1.upstreamHandleFromProfileField; } });
|
|
68
|
-
Object.defineProperty(exports, "upstreamHandleFromAlsoKnownAs", { enumerable: true, get: function () { return networkIdentity_1.upstreamHandleFromAlsoKnownAs; } });
|
|
69
|
-
Object.defineProperty(exports, "upstreamHandleFromAutomatedActor", { enumerable: true, get: function () { return networkIdentity_1.upstreamHandleFromAutomatedActor; } });
|
|
70
|
-
Object.defineProperty(exports, "upstreamHandleFromPreferredUsername", { enumerable: true, get: function () { return networkIdentity_1.upstreamHandleFromPreferredUsername; } });
|
|
71
|
-
Object.defineProperty(exports, "upstreamHandleFromProxyOf", { enumerable: true, get: function () { return networkIdentity_1.upstreamHandleFromProxyOf; } });
|
|
72
|
-
Object.defineProperty(exports, "readProxyDeclarations", { enumerable: true, get: function () { return networkIdentity_1.readProxyDeclarations; } });
|
|
58
|
+
/** Network identity — see `./network`, the Node-free entry it is also served from. */
|
|
59
|
+
__exportStar(require("./network"), exports);
|
|
73
60
|
/**
|
|
74
61
|
* The shared JSON-LD `@context` (load-bearing term declarations) and the
|
|
75
62
|
* ActivityPub URI helpers (actor-uri extraction + the per-instance domain policy:
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readProxyDeclarations = exports.upstreamHandleFromProxyOf = exports.upstreamHandleFromPreferredUsername = exports.upstreamHandleFromAutomatedActor = exports.upstreamHandleFromAlsoKnownAs = exports.upstreamHandleFromProfileField = exports.federatedUsernameFromUpstreamUrl = exports.parseUpstreamProfileUrl = exports.upstreamProfileUrl = exports.stripBridgeBoilerplate = exports.createBridgeRelabeller = exports.atprotoIdentityHandle = exports.isUnresolvedAtprotoHandle = exports.UNRESOLVED_ATPROTO_HANDLE = exports.blueskyHandleFromUsername = exports.blueskyUsernameFromHandle = exports.BSKY_NETWORK_DOMAIN = exports.FEDERATION_NETWORKS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* `@oxy.so/federation/network` — the network vocabulary and the network-identity
|
|
6
|
+
* rules, with nothing that needs Node.
|
|
7
|
+
*
|
|
8
|
+
* The package root also exports HTTP signatures, which import `node:crypto`, so a
|
|
9
|
+
* web or React Native bundle cannot import the root. A client that has to
|
|
10
|
+
* recognise an upstream profile URL the same way the server does (a composer
|
|
11
|
+
* deciding which links become mentions) imports this entry instead, and reads
|
|
12
|
+
* the same declaration rather than a copy of it. Everything here is also exported
|
|
13
|
+
* from the root.
|
|
14
|
+
*/
|
|
15
|
+
/*
|
|
16
|
+
* Network identity: the MECHANISM for re-labelling an account republished by a
|
|
17
|
+
* bridge onto the network it actually came from, plus the network vocabulary and
|
|
18
|
+
* the bidirectional upstream-profile-URL rule.
|
|
19
|
+
*
|
|
20
|
+
* The mechanism is here; the ENTRIES are not, and must not be. Which operators
|
|
21
|
+
* may be trusted to re-attribute somebody's account is a moderation judgement an
|
|
22
|
+
* app commits and answers for — `createBridgeRelabeller` takes them as a
|
|
23
|
+
* parameter so no app inherits another's.
|
|
24
|
+
*/
|
|
25
|
+
var networkIdentity_1 = require("./networkIdentity");
|
|
26
|
+
Object.defineProperty(exports, "FEDERATION_NETWORKS", { enumerable: true, get: function () { return networkIdentity_1.FEDERATION_NETWORKS; } });
|
|
27
|
+
Object.defineProperty(exports, "BSKY_NETWORK_DOMAIN", { enumerable: true, get: function () { return networkIdentity_1.BSKY_NETWORK_DOMAIN; } });
|
|
28
|
+
Object.defineProperty(exports, "blueskyUsernameFromHandle", { enumerable: true, get: function () { return networkIdentity_1.blueskyUsernameFromHandle; } });
|
|
29
|
+
Object.defineProperty(exports, "blueskyHandleFromUsername", { enumerable: true, get: function () { return networkIdentity_1.blueskyHandleFromUsername; } });
|
|
30
|
+
Object.defineProperty(exports, "UNRESOLVED_ATPROTO_HANDLE", { enumerable: true, get: function () { return networkIdentity_1.UNRESOLVED_ATPROTO_HANDLE; } });
|
|
31
|
+
Object.defineProperty(exports, "isUnresolvedAtprotoHandle", { enumerable: true, get: function () { return networkIdentity_1.isUnresolvedAtprotoHandle; } });
|
|
32
|
+
Object.defineProperty(exports, "atprotoIdentityHandle", { enumerable: true, get: function () { return networkIdentity_1.atprotoIdentityHandle; } });
|
|
33
|
+
Object.defineProperty(exports, "createBridgeRelabeller", { enumerable: true, get: function () { return networkIdentity_1.createBridgeRelabeller; } });
|
|
34
|
+
Object.defineProperty(exports, "stripBridgeBoilerplate", { enumerable: true, get: function () { return networkIdentity_1.stripBridgeBoilerplate; } });
|
|
35
|
+
Object.defineProperty(exports, "upstreamProfileUrl", { enumerable: true, get: function () { return networkIdentity_1.upstreamProfileUrl; } });
|
|
36
|
+
Object.defineProperty(exports, "parseUpstreamProfileUrl", { enumerable: true, get: function () { return networkIdentity_1.parseUpstreamProfileUrl; } });
|
|
37
|
+
Object.defineProperty(exports, "federatedUsernameFromUpstreamUrl", { enumerable: true, get: function () { return networkIdentity_1.federatedUsernameFromUpstreamUrl; } });
|
|
38
|
+
Object.defineProperty(exports, "upstreamHandleFromProfileField", { enumerable: true, get: function () { return networkIdentity_1.upstreamHandleFromProfileField; } });
|
|
39
|
+
Object.defineProperty(exports, "upstreamHandleFromAlsoKnownAs", { enumerable: true, get: function () { return networkIdentity_1.upstreamHandleFromAlsoKnownAs; } });
|
|
40
|
+
Object.defineProperty(exports, "upstreamHandleFromAutomatedActor", { enumerable: true, get: function () { return networkIdentity_1.upstreamHandleFromAutomatedActor; } });
|
|
41
|
+
Object.defineProperty(exports, "upstreamHandleFromPreferredUsername", { enumerable: true, get: function () { return networkIdentity_1.upstreamHandleFromPreferredUsername; } });
|
|
42
|
+
Object.defineProperty(exports, "upstreamHandleFromProxyOf", { enumerable: true, get: function () { return networkIdentity_1.upstreamHandleFromProxyOf; } });
|
|
43
|
+
Object.defineProperty(exports, "readProxyDeclarations", { enumerable: true, get: function () { return networkIdentity_1.readProxyDeclarations; } });
|
package/dist/esm/index.js
CHANGED
|
@@ -31,17 +31,8 @@ export { signRequest, verifyHttpSignature, HTTP_SIGNATURE_ALGORITHM, DEFAULT_SIG
|
|
|
31
31
|
* with its own `FEDERATION_DOMAIN` so every actor stays `@user@its-own-domain`.
|
|
32
32
|
*/
|
|
33
33
|
export { createUrlBuilders, normalizeActorUsername, INSTANCE_ACTOR_USERNAME, } from './urls.js';
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
* bridge onto the network it actually came from, plus the network vocabulary and
|
|
37
|
-
* the bidirectional upstream-profile-URL rule.
|
|
38
|
-
*
|
|
39
|
-
* The mechanism is here; the ENTRIES are not, and must not be. Which operators
|
|
40
|
-
* may be trusted to re-attribute somebody's account is a moderation judgement an
|
|
41
|
-
* app commits and answers for — `createBridgeRelabeller` takes them as a
|
|
42
|
-
* parameter so no app inherits another's.
|
|
43
|
-
*/
|
|
44
|
-
export { FEDERATION_NETWORKS, BSKY_NETWORK_DOMAIN, blueskyUsernameFromHandle, blueskyHandleFromUsername, UNRESOLVED_ATPROTO_HANDLE, isUnresolvedAtprotoHandle, atprotoIdentityHandle, createBridgeRelabeller, stripBridgeBoilerplate, upstreamProfileUrl, parseUpstreamProfileUrl, federatedUsernameFromUpstreamUrl, upstreamHandleFromProfileField, upstreamHandleFromAlsoKnownAs, upstreamHandleFromAutomatedActor, upstreamHandleFromPreferredUsername, upstreamHandleFromProxyOf, readProxyDeclarations, } from './networkIdentity.js';
|
|
34
|
+
/** Network identity — see `./network`, the Node-free entry it is also served from. */
|
|
35
|
+
export * from './network.js';
|
|
45
36
|
/**
|
|
46
37
|
* The shared JSON-LD `@context` (load-bearing term declarations) and the
|
|
47
38
|
* ActivityPub URI helpers (actor-uri extraction + the per-instance domain policy:
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@oxy.so/federation/network` — the network vocabulary and the network-identity
|
|
3
|
+
* rules, with nothing that needs Node.
|
|
4
|
+
*
|
|
5
|
+
* The package root also exports HTTP signatures, which import `node:crypto`, so a
|
|
6
|
+
* web or React Native bundle cannot import the root. A client that has to
|
|
7
|
+
* recognise an upstream profile URL the same way the server does (a composer
|
|
8
|
+
* deciding which links become mentions) imports this entry instead, and reads
|
|
9
|
+
* the same declaration rather than a copy of it. Everything here is also exported
|
|
10
|
+
* from the root.
|
|
11
|
+
*/
|
|
12
|
+
/*
|
|
13
|
+
* Network identity: the MECHANISM for re-labelling an account republished by a
|
|
14
|
+
* bridge onto the network it actually came from, plus the network vocabulary and
|
|
15
|
+
* the bidirectional upstream-profile-URL rule.
|
|
16
|
+
*
|
|
17
|
+
* The mechanism is here; the ENTRIES are not, and must not be. Which operators
|
|
18
|
+
* may be trusted to re-attribute somebody's account is a moderation judgement an
|
|
19
|
+
* app commits and answers for — `createBridgeRelabeller` takes them as a
|
|
20
|
+
* parameter so no app inherits another's.
|
|
21
|
+
*/
|
|
22
|
+
export { FEDERATION_NETWORKS, BSKY_NETWORK_DOMAIN, blueskyUsernameFromHandle, blueskyHandleFromUsername, UNRESOLVED_ATPROTO_HANDLE, isUnresolvedAtprotoHandle, atprotoIdentityHandle, createBridgeRelabeller, stripBridgeBoilerplate, upstreamProfileUrl, parseUpstreamProfileUrl, federatedUsernameFromUpstreamUrl, upstreamHandleFromProfileField, upstreamHandleFromAlsoKnownAs, upstreamHandleFromAutomatedActor, upstreamHandleFromPreferredUsername, upstreamHandleFromProxyOf, readProxyDeclarations, } from './networkIdentity.js';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -31,17 +31,8 @@ export { signRequest, verifyHttpSignature, HTTP_SIGNATURE_ALGORITHM, DEFAULT_SIG
|
|
|
31
31
|
* with its own `FEDERATION_DOMAIN` so every actor stays `@user@its-own-domain`.
|
|
32
32
|
*/
|
|
33
33
|
export { createUrlBuilders, normalizeActorUsername, INSTANCE_ACTOR_USERNAME, type UrlBuilders, } from './urls';
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
* bridge onto the network it actually came from, plus the network vocabulary and
|
|
37
|
-
* the bidirectional upstream-profile-URL rule.
|
|
38
|
-
*
|
|
39
|
-
* The mechanism is here; the ENTRIES are not, and must not be. Which operators
|
|
40
|
-
* may be trusted to re-attribute somebody's account is a moderation judgement an
|
|
41
|
-
* app commits and answers for — `createBridgeRelabeller` takes them as a
|
|
42
|
-
* parameter so no app inherits another's.
|
|
43
|
-
*/
|
|
44
|
-
export { FEDERATION_NETWORKS, BSKY_NETWORK_DOMAIN, blueskyUsernameFromHandle, blueskyHandleFromUsername, UNRESOLVED_ATPROTO_HANDLE, isUnresolvedAtprotoHandle, atprotoIdentityHandle, createBridgeRelabeller, stripBridgeBoilerplate, upstreamProfileUrl, parseUpstreamProfileUrl, federatedUsernameFromUpstreamUrl, upstreamHandleFromProfileField, upstreamHandleFromAlsoKnownAs, upstreamHandleFromAutomatedActor, upstreamHandleFromPreferredUsername, upstreamHandleFromProxyOf, readProxyDeclarations, type FederationNetwork, type FederationBridgeEntry, type BridgeRelabeller, type BridgeConsentModel, type BridgeDerivation, type BridgedActorField, type DeriveNetworkIdentity, type NetworkIdentity, type NetworkIdentityCandidate, type ProxyDeclaration, } from './networkIdentity';
|
|
34
|
+
/** Network identity — see `./network`, the Node-free entry it is also served from. */
|
|
35
|
+
export * from './network';
|
|
45
36
|
/**
|
|
46
37
|
* The shared JSON-LD `@context` (load-bearing term declarations) and the
|
|
47
38
|
* ActivityPub URI helpers (actor-uri extraction + the per-instance domain policy:
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@oxy.so/federation/network` — the network vocabulary and the network-identity
|
|
3
|
+
* rules, with nothing that needs Node.
|
|
4
|
+
*
|
|
5
|
+
* The package root also exports HTTP signatures, which import `node:crypto`, so a
|
|
6
|
+
* web or React Native bundle cannot import the root. A client that has to
|
|
7
|
+
* recognise an upstream profile URL the same way the server does (a composer
|
|
8
|
+
* deciding which links become mentions) imports this entry instead, and reads
|
|
9
|
+
* the same declaration rather than a copy of it. Everything here is also exported
|
|
10
|
+
* from the root.
|
|
11
|
+
*/
|
|
12
|
+
export { FEDERATION_NETWORKS, BSKY_NETWORK_DOMAIN, blueskyUsernameFromHandle, blueskyHandleFromUsername, UNRESOLVED_ATPROTO_HANDLE, isUnresolvedAtprotoHandle, atprotoIdentityHandle, createBridgeRelabeller, stripBridgeBoilerplate, upstreamProfileUrl, parseUpstreamProfileUrl, federatedUsernameFromUpstreamUrl, upstreamHandleFromProfileField, upstreamHandleFromAlsoKnownAs, upstreamHandleFromAutomatedActor, upstreamHandleFromPreferredUsername, upstreamHandleFromProxyOf, readProxyDeclarations, type FederationNetwork, type FederationBridgeEntry, type BridgeRelabeller, type BridgeConsentModel, type BridgeDerivation, type BridgedActorField, type DeriveNetworkIdentity, type NetworkIdentity, type NetworkIdentityCandidate, type ProxyDeclaration, } from './networkIdentity';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxy.so/federation",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Oxy Federation — the app-agnostic ActivityPub identity + follow engine substrate: the network-connector contract, normalized cross-network DTOs, HTTP signatures, actor resolution, the outbound delivery transport + follow lifecycle, the inbound dispatcher, and the webfinger/actor/inbox Express routers. Domain-parameterized so every Oxy app backend federates under its own domain.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -29,6 +29,17 @@
|
|
|
29
29
|
},
|
|
30
30
|
"default": "./dist/esm/index.js"
|
|
31
31
|
},
|
|
32
|
+
"./network": {
|
|
33
|
+
"import": {
|
|
34
|
+
"types": "./dist/types/network.d.ts",
|
|
35
|
+
"default": "./dist/esm/network.js"
|
|
36
|
+
},
|
|
37
|
+
"require": {
|
|
38
|
+
"types": "./dist/types/network.d.ts",
|
|
39
|
+
"default": "./dist/cjs/network.js"
|
|
40
|
+
},
|
|
41
|
+
"default": "./dist/esm/network.js"
|
|
42
|
+
},
|
|
32
43
|
"./node": {
|
|
33
44
|
"import": {
|
|
34
45
|
"types": "./dist/types/node/index.d.ts",
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { builtinModules } from 'node:module';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
|
|
5
|
+
/** Every specifier the module at `file` imports, following relative imports. */
|
|
6
|
+
function importGraph(file: string, seen = new Set<string>()): string[] {
|
|
7
|
+
if (seen.has(file)) return [];
|
|
8
|
+
seen.add(file);
|
|
9
|
+
const source = readFileSync(file, 'utf8');
|
|
10
|
+
const specifiers = [...source.matchAll(/^(?:import|export)[^'"]*from\s+'([^']+)'/gm)].map(
|
|
11
|
+
(match) => match[1],
|
|
12
|
+
);
|
|
13
|
+
return specifiers.flatMap((specifier) =>
|
|
14
|
+
specifier.startsWith('.')
|
|
15
|
+
? importGraph(join(file, '..', `${specifier}.ts`), seen)
|
|
16
|
+
: [specifier],
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe('@oxy.so/federation/network', () => {
|
|
21
|
+
it('imports nothing from Node, so a web or React Native bundle can use it', () => {
|
|
22
|
+
const external = importGraph(join(__dirname, '..', 'network.ts'));
|
|
23
|
+
const node = new Set([...builtinModules, ...builtinModules.map((name) => `node:${name}`)]);
|
|
24
|
+
expect(external.filter((specifier) => node.has(specifier))).toEqual([]);
|
|
25
|
+
});
|
|
26
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -51,46 +51,8 @@ export {
|
|
|
51
51
|
type UrlBuilders,
|
|
52
52
|
} from './urls';
|
|
53
53
|
|
|
54
|
-
/**
|
|
55
|
-
*
|
|
56
|
-
* bridge onto the network it actually came from, plus the network vocabulary and
|
|
57
|
-
* the bidirectional upstream-profile-URL rule.
|
|
58
|
-
*
|
|
59
|
-
* The mechanism is here; the ENTRIES are not, and must not be. Which operators
|
|
60
|
-
* may be trusted to re-attribute somebody's account is a moderation judgement an
|
|
61
|
-
* app commits and answers for — `createBridgeRelabeller` takes them as a
|
|
62
|
-
* parameter so no app inherits another's.
|
|
63
|
-
*/
|
|
64
|
-
export {
|
|
65
|
-
FEDERATION_NETWORKS,
|
|
66
|
-
BSKY_NETWORK_DOMAIN,
|
|
67
|
-
blueskyUsernameFromHandle,
|
|
68
|
-
blueskyHandleFromUsername,
|
|
69
|
-
UNRESOLVED_ATPROTO_HANDLE,
|
|
70
|
-
isUnresolvedAtprotoHandle,
|
|
71
|
-
atprotoIdentityHandle,
|
|
72
|
-
createBridgeRelabeller,
|
|
73
|
-
stripBridgeBoilerplate,
|
|
74
|
-
upstreamProfileUrl,
|
|
75
|
-
parseUpstreamProfileUrl,
|
|
76
|
-
federatedUsernameFromUpstreamUrl,
|
|
77
|
-
upstreamHandleFromProfileField,
|
|
78
|
-
upstreamHandleFromAlsoKnownAs,
|
|
79
|
-
upstreamHandleFromAutomatedActor,
|
|
80
|
-
upstreamHandleFromPreferredUsername,
|
|
81
|
-
upstreamHandleFromProxyOf,
|
|
82
|
-
readProxyDeclarations,
|
|
83
|
-
type FederationNetwork,
|
|
84
|
-
type FederationBridgeEntry,
|
|
85
|
-
type BridgeRelabeller,
|
|
86
|
-
type BridgeConsentModel,
|
|
87
|
-
type BridgeDerivation,
|
|
88
|
-
type BridgedActorField,
|
|
89
|
-
type DeriveNetworkIdentity,
|
|
90
|
-
type NetworkIdentity,
|
|
91
|
-
type NetworkIdentityCandidate,
|
|
92
|
-
type ProxyDeclaration,
|
|
93
|
-
} from './networkIdentity';
|
|
54
|
+
/** Network identity — see `./network`, the Node-free entry it is also served from. */
|
|
55
|
+
export * from './network';
|
|
94
56
|
|
|
95
57
|
/**
|
|
96
58
|
* The shared JSON-LD `@context` (load-bearing term declarations) and the
|
package/src/network.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@oxy.so/federation/network` — the network vocabulary and the network-identity
|
|
3
|
+
* rules, with nothing that needs Node.
|
|
4
|
+
*
|
|
5
|
+
* The package root also exports HTTP signatures, which import `node:crypto`, so a
|
|
6
|
+
* web or React Native bundle cannot import the root. A client that has to
|
|
7
|
+
* recognise an upstream profile URL the same way the server does (a composer
|
|
8
|
+
* deciding which links become mentions) imports this entry instead, and reads
|
|
9
|
+
* the same declaration rather than a copy of it. Everything here is also exported
|
|
10
|
+
* from the root.
|
|
11
|
+
*/
|
|
12
|
+
/*
|
|
13
|
+
* Network identity: the MECHANISM for re-labelling an account republished by a
|
|
14
|
+
* bridge onto the network it actually came from, plus the network vocabulary and
|
|
15
|
+
* the bidirectional upstream-profile-URL rule.
|
|
16
|
+
*
|
|
17
|
+
* The mechanism is here; the ENTRIES are not, and must not be. Which operators
|
|
18
|
+
* may be trusted to re-attribute somebody's account is a moderation judgement an
|
|
19
|
+
* app commits and answers for — `createBridgeRelabeller` takes them as a
|
|
20
|
+
* parameter so no app inherits another's.
|
|
21
|
+
*/
|
|
22
|
+
export {
|
|
23
|
+
FEDERATION_NETWORKS,
|
|
24
|
+
BSKY_NETWORK_DOMAIN,
|
|
25
|
+
blueskyUsernameFromHandle,
|
|
26
|
+
blueskyHandleFromUsername,
|
|
27
|
+
UNRESOLVED_ATPROTO_HANDLE,
|
|
28
|
+
isUnresolvedAtprotoHandle,
|
|
29
|
+
atprotoIdentityHandle,
|
|
30
|
+
createBridgeRelabeller,
|
|
31
|
+
stripBridgeBoilerplate,
|
|
32
|
+
upstreamProfileUrl,
|
|
33
|
+
parseUpstreamProfileUrl,
|
|
34
|
+
federatedUsernameFromUpstreamUrl,
|
|
35
|
+
upstreamHandleFromProfileField,
|
|
36
|
+
upstreamHandleFromAlsoKnownAs,
|
|
37
|
+
upstreamHandleFromAutomatedActor,
|
|
38
|
+
upstreamHandleFromPreferredUsername,
|
|
39
|
+
upstreamHandleFromProxyOf,
|
|
40
|
+
readProxyDeclarations,
|
|
41
|
+
type FederationNetwork,
|
|
42
|
+
type FederationBridgeEntry,
|
|
43
|
+
type BridgeRelabeller,
|
|
44
|
+
type BridgeConsentModel,
|
|
45
|
+
type BridgeDerivation,
|
|
46
|
+
type BridgedActorField,
|
|
47
|
+
type DeriveNetworkIdentity,
|
|
48
|
+
type NetworkIdentity,
|
|
49
|
+
type NetworkIdentityCandidate,
|
|
50
|
+
type ProxyDeclaration,
|
|
51
|
+
} from './networkIdentity';
|