@ghostlytools/cli 1.8.0 → 1.9.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/README.md +11 -8
- package/SKILL.md +4 -3
- package/dist/assets/{api-I_KbuXHa.js → api-DFCgr6RH.js} +94 -35
- package/dist/assets/api-DFCgr6RH.js.map +1 -0
- package/dist/assets/{api-Dj1yn0px.js → api-raWw9j_m.js} +2 -2
- package/dist/assets/{apiKit-C-_PWZvy.js → apiKit-CCavJJcl.js} +2 -2
- package/dist/assets/{apiKit-C-_PWZvy.js.map → apiKit-CCavJJcl.js.map} +1 -1
- package/dist/assets/{apps-DbEfL_3b.js → apps-B7o2BPj6.js} +1 -1
- package/dist/assets/{apps-DKIe8VjF.js → apps-DmxEG147.js} +2 -2
- package/dist/assets/{apps-DKIe8VjF.js.map → apps-DmxEG147.js.map} +1 -1
- package/dist/assets/{arkade-k1bdSm70.js → arkade-DtYR9H0c.js} +2 -2
- package/dist/assets/{arkade-k1bdSm70.js.map → arkade-DtYR9H0c.js.map} +1 -1
- package/dist/assets/{backup-Cdd6-HNu.js → backup-BserdrNk.js} +1 -1
- package/dist/assets/{backup-beKfbfNk.js → backup-YIB2XIES.js} +4 -4
- package/dist/assets/{backup-beKfbfNk.js.map → backup-YIB2XIES.js.map} +1 -1
- package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js.map +1 -1
- package/dist/assets/buttons-CuRfKnPI.js +1331 -0
- package/dist/assets/buttons-CuRfKnPI.js.map +1 -0
- package/dist/assets/buttons-De3LPdSG.js +2 -0
- package/dist/assets/{envelope-B88yiCQj.js → envelope-Dt75vrmY.js} +2 -2
- package/dist/assets/{envelope-B88yiCQj.js.map → envelope-Dt75vrmY.js.map} +1 -1
- package/dist/assets/fedimint_client_wasm_bg-BtHHlFpp.js.map +1 -1
- package/dist/assets/fixedHosts-B598JzbC.js +24 -0
- package/dist/assets/fixedHosts-B598JzbC.js.map +1 -0
- package/dist/assets/{ghostly_iroh_web-CO0onry8.js → ghostly_iroh_web-BzAXJUYH.js} +10 -10
- package/dist/assets/{ghostly_iroh_web-CO0onry8.js.map → ghostly_iroh_web-BzAXJUYH.js.map} +1 -1
- package/dist/assets/ghostly_iroh_web_bg.wasm +0 -0
- package/dist/assets/{groupFiles-DjQc5XXv.js → groupFiles-FXel6zIc.js} +41 -11
- package/dist/assets/groupFiles-FXel6zIc.js.map +1 -0
- package/dist/assets/{host-CNWGB3-j.js → host-DIBeK_c_.js} +95 -28
- package/dist/assets/host-DIBeK_c_.js.map +1 -0
- package/dist/assets/hyperdhtRelay-1wzya_0L.js +25 -0
- package/dist/assets/hyperdhtRelay-1wzya_0L.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-g7eXzf5h.js → hyperdhtRelay-D185dETu.js} +15 -3
- package/dist/assets/hyperdhtRelay-D185dETu.js.map +1 -0
- package/dist/assets/{irohWeb-Bx8dI4be.js → irohWeb-BSv_BWyG.js} +25 -8
- package/dist/assets/{irohWeb-Bx8dI4be.js.map → irohWeb-BSv_BWyG.js.map} +1 -1
- package/dist/assets/{main-BRxhBctJ.js → main-BbhfMTt8.js} +50 -22
- package/dist/assets/main-BbhfMTt8.js.map +1 -0
- package/dist/assets/{mainline-CwuS6ngj.js → mainline-9Vc3c3SA.js} +2 -2
- package/dist/assets/{mainline-CwuS6ngj.js.map → mainline-9Vc3c3SA.js.map} +1 -1
- package/dist/assets/{networkReason-CIAMieQm.js → networkReason-BncJ9KSM.js} +2 -2
- package/dist/assets/{networkReason-CIAMieQm.js.map → networkReason-BncJ9KSM.js.map} +1 -1
- package/dist/assets/{nwc-C9JLJJkL.js → nwc-QX3Yt1Sb.js} +3 -3
- package/dist/assets/{nwc-C9JLJJkL.js.map → nwc-QX3Yt1Sb.js.map} +1 -1
- package/dist/assets/{nwcProvider-pFMrsUJh.js → nwcProvider-CzX3xH47.js} +2 -2
- package/dist/assets/{nwcProvider-pFMrsUJh.js.map → nwcProvider-CzX3xH47.js.map} +1 -1
- package/dist/assets/ownDid-D8z5gwGI.js +281 -0
- package/dist/assets/ownDid-D8z5gwGI.js.map +1 -0
- package/dist/assets/{registry-Cks7FA_o.js → registry-B2Dtnibo.js} +5 -246
- package/dist/assets/registry-B2Dtnibo.js.map +1 -0
- package/dist/assets/{registry-DY2ixQfU.js → registry-PTtBMaYZ.js} +1 -1
- package/dist/assets/{resolve-C4Y2HPqQ.js → resolve-ZxVzwFNA.js} +3 -280
- package/dist/assets/resolve-ZxVzwFNA.js.map +1 -0
- package/dist/assets/{server-D9RAmGdm.js → server-Dw1o8z1o.js} +1144 -359
- package/dist/assets/server-Dw1o8z1o.js.map +1 -0
- package/dist/assets/{src-1RU4TilT.js → src-BD8RBVEp.js} +1269 -134
- package/dist/assets/src-BD8RBVEp.js.map +1 -0
- package/dist/assets/sshForges-DWrESWkK.js +253 -0
- package/dist/assets/sshForges-DWrESWkK.js.map +1 -0
- package/dist/assets/{translate-od5GbpvR.js → translate-D1uP0q32.js} +17 -5
- package/dist/assets/translate-D1uP0q32.js.map +1 -0
- package/dist/assets/{usdt-DldXV0MR.js → usdt-DhVN8geQ.js} +3 -3
- package/dist/assets/{usdt-DldXV0MR.js.map → usdt-DhVN8geQ.js.map} +1 -1
- package/dist/assets/{waitNotice-Ck3el3_Z.js → waitNotice-B8D8WhbE.js} +2 -2
- package/dist/assets/waitNotice-B8D8WhbE.js.map +1 -0
- package/dist/assets/{words-BS2qq_vV.js → words-DdXPkB3n.js} +3 -2
- package/dist/assets/words-DdXPkB3n.js.map +1 -0
- package/dist/ghostly.mjs +1 -1
- package/examples/call-echo.mjs +7 -5
- package/package.json +1 -1
- package/dist/assets/api-I_KbuXHa.js.map +0 -1
- package/dist/assets/buttons-BO1_7V4L.js +0 -2
- package/dist/assets/buttons-ClI13rdv.js +0 -545
- package/dist/assets/buttons-ClI13rdv.js.map +0 -1
- package/dist/assets/groupFiles-DjQc5XXv.js.map +0 -1
- package/dist/assets/host-CNWGB3-j.js.map +0 -1
- package/dist/assets/hyperdhtRelay-BT_wRxab.js +0 -21
- package/dist/assets/hyperdhtRelay-BT_wRxab.js.map +0 -1
- package/dist/assets/hyperdhtRelay-g7eXzf5h.js.map +0 -1
- package/dist/assets/main-BRxhBctJ.js.map +0 -1
- package/dist/assets/registry-Cks7FA_o.js.map +0 -1
- package/dist/assets/resolve-C4Y2HPqQ.js.map +0 -1
- package/dist/assets/server-D9RAmGdm.js.map +0 -1
- package/dist/assets/src-1RU4TilT.js.map +0 -1
- package/dist/assets/translate-od5GbpvR.js.map +0 -1
- package/dist/assets/waitNotice-Ck3el3_Z.js.map +0 -1
- package/dist/assets/words-BS2qq_vV.js.map +0 -1
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { Xi as boundVerifiedIdentity } from "./src-BD8RBVEp.js";
|
|
2
|
+
import { l as providerDescriptorProblems } from "./types-C4_KafL_.js";
|
|
3
|
+
//#region ../browser/src/shared/features.ts
|
|
4
|
+
/**
|
|
5
|
+
* A build that may be put into test mode: a development build (`import.meta.env.DEV`, which vitest also sets) or the
|
|
6
|
+
* e2e suite's build (`VITE_APPS_TEST`, fixed when the build is made, as the mini-app switch is). A release build is
|
|
7
|
+
* neither: Vite folds this to `false` there, so the storage flags the test fakes answer to are ignored. The fakes
|
|
8
|
+
* themselves are still in the bundle (the registries import them); plugins may still pass fakes to the registry.
|
|
9
|
+
*/
|
|
10
|
+
var testBuild = () => {
|
|
11
|
+
try {
|
|
12
|
+
return false;
|
|
13
|
+
} catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A suite's switch in the page's storage (`localStorage["ghostly-test-…"]`), read only in a test build (`testBuild`): a
|
|
19
|
+
* release build reads none, so a leftover or pasted key changes nothing there. Null when unset, unreadable or released.
|
|
20
|
+
*/
|
|
21
|
+
var testSwitch = (key) => {
|
|
22
|
+
if (!testBuild()) return null;
|
|
23
|
+
try {
|
|
24
|
+
return globalThis.localStorage?.getItem(key) ?? null;
|
|
25
|
+
} catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region ../browser/src/proofs/verify.ts
|
|
31
|
+
var DAY = 86400;
|
|
32
|
+
/**
|
|
33
|
+
* The checks every proof goes through, whatever its provider: known provider, validity within the
|
|
34
|
+
* provider's limit, bounded evidence, strict parsing, the provider's own check, and the category rule
|
|
35
|
+
* (a self-custodied proof proves exactly the subject it names; an attested one says who attests it).
|
|
36
|
+
* The engine verifies a contact's proof, and the person's own proof before saving it, only through this.
|
|
37
|
+
*/
|
|
38
|
+
async function verifyIdentity(providers, statement, evidence, ctx) {
|
|
39
|
+
const { binding } = statement;
|
|
40
|
+
const provider = providers.find((p) => p.id === binding.provider);
|
|
41
|
+
if (!provider) throw new Error("This app cannot verify this kind of identity");
|
|
42
|
+
if (binding.expiresAt - binding.issuedAt > Math.min(provider.validity.maxDays * DAY, 3456e4)) throw new Error("The proof lasts longer than this kind of identity allows");
|
|
43
|
+
if (JSON.stringify(evidence ?? null).length > 16384) throw new Error("Evidence too large");
|
|
44
|
+
const parsed = provider.parseEvidence(evidence);
|
|
45
|
+
const verified = boundVerifiedIdentity(await provider.verify(statement, parsed, ctx));
|
|
46
|
+
if (provider.category === "self-custodied" && verified.subject !== binding.subject) throw new Error("The evidence is for another identity");
|
|
47
|
+
if (provider.category === "provider-attested" && !verified.attester) throw new Error("The evidence does not say who attests it");
|
|
48
|
+
return verified;
|
|
49
|
+
}
|
|
50
|
+
/** Problems with a provider's descriptor, empty when it is well-formed. The registry and the contract suite use it. */
|
|
51
|
+
function descriptorProblems(p) {
|
|
52
|
+
const problems = [];
|
|
53
|
+
if (!/^[a-z][a-z0-9-]{0,31}$/.test(p.id)) problems.push("id must match ^[a-z][a-z0-9-]{0,31}$");
|
|
54
|
+
if (!p.label?.trim()) problems.push("label is empty");
|
|
55
|
+
if (!p.description?.trim()) problems.push("description is empty");
|
|
56
|
+
if (!p.privacy?.trim()) problems.push("privacy is empty: say what verify contacts");
|
|
57
|
+
if (p.category !== "self-custodied" && p.category !== "provider-attested") problems.push("category is unknown");
|
|
58
|
+
if (!p.platforms.length) problems.push("no platforms");
|
|
59
|
+
const { defaultDays, maxDays } = p.validity;
|
|
60
|
+
if (!(Number.isInteger(defaultDays) && Number.isInteger(maxDays) && defaultDays >= 1 && defaultDays <= maxDays && maxDays * DAY <= 3456e4)) problems.push("validity must be whole days, 1 ≤ default ≤ max ≤ 400");
|
|
61
|
+
if (p.recheck && !(Number.isInteger(p.recheck.afterSeconds) && p.recheck.afterSeconds >= 60)) problems.push("recheck.afterSeconds must be at least 60");
|
|
62
|
+
if (!p.signers.length) problems.push("no signers");
|
|
63
|
+
const ids = p.signers.map((s) => s.id);
|
|
64
|
+
if (new Set(ids).size !== ids.length) problems.push("signer ids are not unique");
|
|
65
|
+
for (const s of p.signers) {
|
|
66
|
+
if (![
|
|
67
|
+
"in-app",
|
|
68
|
+
"external-tool",
|
|
69
|
+
"redirect",
|
|
70
|
+
"publish"
|
|
71
|
+
].includes(s.kind)) problems.push(`signer ${s.id} has an unknown kind`);
|
|
72
|
+
if (s.kind === "in-app" && typeof s.run !== "function") problems.push(`signer ${s.id} has no run()`);
|
|
73
|
+
if (s.kind === "external-tool" && (typeof s.instructions !== "function" || typeof s.parse !== "function")) problems.push(`signer ${s.id} needs instructions() and parse()`);
|
|
74
|
+
if (s.kind === "redirect" && typeof s.start !== "function") problems.push(`signer ${s.id} has no start()`);
|
|
75
|
+
if (s.kind === "publish" && (typeof s.instructions !== "function" || typeof s.evidence !== "function")) problems.push(`signer ${s.id} needs instructions() and evidence()`);
|
|
76
|
+
}
|
|
77
|
+
return problems;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The engine's `ctx.fetch`: HTTPS GET only, no credentials or referrer, a time-out, a size cap,
|
|
81
|
+
* redirects refused unless asked for.
|
|
82
|
+
* `online` false refuses everything (the person turned the network off).
|
|
83
|
+
*/
|
|
84
|
+
function boundedIdentityFetch(options = { online: () => true }) {
|
|
85
|
+
return async (url, { headers, maxBytes = 65536, signal, redirect = "error" } = {}) => {
|
|
86
|
+
if (!options.online()) throw new Error("Offline: this identity cannot be checked now");
|
|
87
|
+
const target = new URL(url);
|
|
88
|
+
if (target.protocol !== "https:" || target.username || target.password) throw new Error("Identity checks use HTTPS only");
|
|
89
|
+
const timeout = AbortSignal.timeout(options.timeoutMs ?? 1e4);
|
|
90
|
+
const response = await (options.fetcher ?? fetch)(target.href, {
|
|
91
|
+
headers,
|
|
92
|
+
signal: signal ? AbortSignal.any([signal, timeout]) : timeout,
|
|
93
|
+
credentials: "omit",
|
|
94
|
+
referrerPolicy: "no-referrer",
|
|
95
|
+
cache: "no-store",
|
|
96
|
+
redirect
|
|
97
|
+
});
|
|
98
|
+
if (Number(response.headers.get("content-length")) > maxBytes) throw new Error("Identity check response too large");
|
|
99
|
+
const reader = response.body?.getReader();
|
|
100
|
+
const parts = [];
|
|
101
|
+
let length = 0;
|
|
102
|
+
if (reader) try {
|
|
103
|
+
for (;;) {
|
|
104
|
+
const { done, value } = await reader.read();
|
|
105
|
+
if (done) break;
|
|
106
|
+
length += value.length;
|
|
107
|
+
if (length > maxBytes) throw new Error("Identity check response too large");
|
|
108
|
+
parts.push(value);
|
|
109
|
+
}
|
|
110
|
+
} finally {
|
|
111
|
+
await reader.cancel().catch(() => {});
|
|
112
|
+
}
|
|
113
|
+
const bytes = new Uint8Array(length);
|
|
114
|
+
let offset = 0;
|
|
115
|
+
for (const part of parts) {
|
|
116
|
+
bytes.set(part, offset);
|
|
117
|
+
offset += part.length;
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
status: response.status,
|
|
121
|
+
contentType: response.headers.get("content-type") ?? "",
|
|
122
|
+
text: new TextDecoder().decode(bytes),
|
|
123
|
+
bytes
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region ../browser/src/plugins/bundled.ts
|
|
129
|
+
/**
|
|
130
|
+
* The adapter plugins compiled into this build. Empty unless the build lists some: `GHOSTLY_PLUGINS`
|
|
131
|
+
* names their modules (comma-separated paths from the repository root, each default-exporting a
|
|
132
|
+
* `GhostlyAdapterPlugin`), and the Vite plugin in `packages/browser/vite-plugin.ts` swaps this module
|
|
133
|
+
* for one that imports them. Release builds never set it; the e2e build carries the SDK example.
|
|
134
|
+
*/
|
|
135
|
+
var BUNDLED_PLUGINS = [];
|
|
136
|
+
var PLUGIN_ID = /^[a-z][a-z0-9-]{0,63}$/;
|
|
137
|
+
var KEY = Symbol.for("ghostly.adapters/1");
|
|
138
|
+
function store() {
|
|
139
|
+
const g = globalThis;
|
|
140
|
+
return g[KEY] ??= {
|
|
141
|
+
plugins: /* @__PURE__ */ new Map(),
|
|
142
|
+
reserved: {
|
|
143
|
+
lightning: /* @__PURE__ */ new Set(),
|
|
144
|
+
onchain: /* @__PURE__ */ new Set(),
|
|
145
|
+
identity: /* @__PURE__ */ new Set()
|
|
146
|
+
},
|
|
147
|
+
listeners: /* @__PURE__ */ new Set(),
|
|
148
|
+
seeded: false
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
var ids = (kind, plugin) => {
|
|
152
|
+
const list = kind === "identity" ? plugin.identities : kind === "lightning" ? plugin.lightning : plugin.onchain;
|
|
153
|
+
return Array.isArray(list) ? list.map((a) => a?.id) : [];
|
|
154
|
+
};
|
|
155
|
+
var KINDS = [
|
|
156
|
+
"lightning",
|
|
157
|
+
"onchain",
|
|
158
|
+
"identity"
|
|
159
|
+
];
|
|
160
|
+
/** Problems with a plugin, empty when it can be registered. Does not look at what is already registered. */
|
|
161
|
+
function pluginProblems(plugin) {
|
|
162
|
+
const problems = [];
|
|
163
|
+
if (!plugin || typeof plugin !== "object") return ["not a plugin object"];
|
|
164
|
+
if (!PLUGIN_ID.test(plugin.id ?? "")) problems.push("plugin id must match ^[a-z][a-z0-9-]{0,63}$");
|
|
165
|
+
if (plugin.sdk !== 1) problems.push(`plugin was written for SDK API ${String(plugin.sdk)}; this app speaks 1`);
|
|
166
|
+
if (plugin.version !== void 0 && (typeof plugin.version !== "string" || plugin.version.length > 64)) problems.push("version must be a short string");
|
|
167
|
+
for (const kind of ["lightning", "onchain"]) {
|
|
168
|
+
const list = plugin[kind];
|
|
169
|
+
if (list === void 0) continue;
|
|
170
|
+
if (!Array.isArray(list)) {
|
|
171
|
+
problems.push(`${kind} must be a list of descriptors`);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
for (const d of list) {
|
|
175
|
+
if (!d || typeof d !== "object") {
|
|
176
|
+
problems.push(`${kind} ${String(d)}: not a descriptor`);
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
const own = providerDescriptorProblems(d);
|
|
180
|
+
if (d?.kind && d.kind !== kind) own.push(`is listed under ${kind} but says kind ${String(d.kind)}`);
|
|
181
|
+
problems.push(...own.map((p) => `${kind} ${String(d?.id)}: ${p}`));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (plugin.identities !== void 0) {
|
|
185
|
+
if (!Array.isArray(plugin.identities)) problems.push("identities must be a list of providers");
|
|
186
|
+
else for (const p of plugin.identities) if (!p || typeof p !== "object") problems.push(`identity ${String(p)}: not a provider`);
|
|
187
|
+
else problems.push(...descriptorProblems(p).map((m) => `identity ${String(p.id)}: ${m}`));
|
|
188
|
+
}
|
|
189
|
+
for (const kind of KINDS) {
|
|
190
|
+
const list = ids(kind, plugin);
|
|
191
|
+
if (new Set(list).size !== list.length) problems.push(`${kind} ids are not unique within the plugin`);
|
|
192
|
+
}
|
|
193
|
+
if (!KINDS.some((kind) => ids(kind, plugin).length)) problems.push("the plugin brings no adapter");
|
|
194
|
+
return problems;
|
|
195
|
+
}
|
|
196
|
+
/** The built-in registries say which ids are theirs. A plugin using one is refused. */
|
|
197
|
+
function reserveAdapterIds(kind, list) {
|
|
198
|
+
const s = store();
|
|
199
|
+
for (const id of list) s.reserved[kind].add(id);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Registers a plugin's adapters. Throws, registering nothing, when the plugin is malformed, its id or
|
|
203
|
+
* one of its adapters' ids is taken (by a built-in or by another plugin), or its contract generation
|
|
204
|
+
* is another one. Returns the function that unregisters it.
|
|
205
|
+
*/
|
|
206
|
+
function registerAdapters(plugin) {
|
|
207
|
+
const problems = pluginProblems(plugin);
|
|
208
|
+
const s = store();
|
|
209
|
+
if (!problems.length) {
|
|
210
|
+
if (s.plugins.has(plugin.id)) problems.push(`a plugin with id ${plugin.id} is already registered`);
|
|
211
|
+
for (const kind of KINDS) for (const id of ids(kind, plugin)) {
|
|
212
|
+
if (s.reserved[kind].has(id)) problems.push(`${kind} ${id} is a built-in of this app`);
|
|
213
|
+
for (const other of s.plugins.values()) if (ids(kind, other).includes(id)) problems.push(`${kind} ${id} is already registered by plugin ${other.id}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (problems.length) throw new Error(`Cannot register plugin ${String(plugin?.id)}: ${problems.join("; ")}`);
|
|
217
|
+
s.plugins.set(plugin.id, plugin);
|
|
218
|
+
notify(s);
|
|
219
|
+
return () => {
|
|
220
|
+
if (s.plugins.get(plugin.id) === plugin) {
|
|
221
|
+
s.plugins.delete(plugin.id);
|
|
222
|
+
notify(s);
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
function notify(s) {
|
|
227
|
+
for (const listener of s.listeners) try {
|
|
228
|
+
listener();
|
|
229
|
+
} catch {}
|
|
230
|
+
}
|
|
231
|
+
/** Called when a plugin registers or unregisters: the engine re-reads the lists. */
|
|
232
|
+
function onAdaptersChanged(listener) {
|
|
233
|
+
const s = store();
|
|
234
|
+
s.listeners.add(listener);
|
|
235
|
+
return () => {
|
|
236
|
+
s.listeners.delete(listener);
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
/** Every registered plugin, in registration order (bundled ones first). */
|
|
240
|
+
function registeredPlugins() {
|
|
241
|
+
seed();
|
|
242
|
+
return [...store().plugins.values()];
|
|
243
|
+
}
|
|
244
|
+
function registeredLightningProviders() {
|
|
245
|
+
return registeredPlugins().flatMap((p) => p.lightning ?? []);
|
|
246
|
+
}
|
|
247
|
+
function registeredOnchainProviders() {
|
|
248
|
+
return registeredPlugins().flatMap((p) => p.onchain ?? []);
|
|
249
|
+
}
|
|
250
|
+
function registeredIdentityProviders() {
|
|
251
|
+
return registeredPlugins().flatMap((p) => p.identities ?? []);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* The plugins compiled into this build register once, when they are first asked for. A broken one is
|
|
255
|
+
* reported and skipped rather than taking the app down with it; the e2e that expects it fails instead.
|
|
256
|
+
*/
|
|
257
|
+
function seed() {
|
|
258
|
+
const s = store();
|
|
259
|
+
if (s.seeded) return;
|
|
260
|
+
s.seeded = true;
|
|
261
|
+
for (const plugin of BUNDLED_PLUGINS) try {
|
|
262
|
+
registerAdapters(plugin);
|
|
263
|
+
} catch (error) {
|
|
264
|
+
console.error(`[ghostly] a bundled adapter plugin was not loaded: ${error instanceof Error ? error.message : String(error)}`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
//#endregion
|
|
268
|
+
//#region ../browser/src/proofs/ownDid.ts
|
|
269
|
+
/**
|
|
270
|
+
* The profile's own Ghostly did:dht, which the DID provider refuses as an external identity. The UI and the engine each
|
|
271
|
+
* set where to read it. Here, not in the provider, so setting it does not load the providers.
|
|
272
|
+
*/
|
|
273
|
+
var source = () => void 0;
|
|
274
|
+
function setOwnDidSource(read) {
|
|
275
|
+
source = read;
|
|
276
|
+
}
|
|
277
|
+
var ownDid = () => source();
|
|
278
|
+
//#endregion
|
|
279
|
+
export { registeredLightningProviders as a, boundedIdentityFetch as c, testSwitch as d, registeredIdentityProviders as i, verifyIdentity as l, setOwnDidSource as n, registeredOnchainProviders as o, onAdaptersChanged as r, reserveAdapterIds as s, ownDid as t, testBuild as u };
|
|
280
|
+
|
|
281
|
+
//# sourceMappingURL=ownDid-D8z5gwGI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ownDid-D8z5gwGI.js","names":[],"sources":["../../../browser/src/shared/features.ts","../../../browser/src/proofs/verify.ts","../../../browser/src/plugins/bundled.ts","../../../browser/src/plugins/registry.ts","../../../browser/src/proofs/ownDid.ts"],"sourcesContent":["/** Release policy: external identity experiments are retained for future work,\n * but must not advertise capabilities, start network lookups, or expose cached\n * external profiles. This does not gate Ghostly participation authentication. */\nexport const EXTERNAL_IDENTITIES_ENABLED: boolean = false;\n\n/** Mini-apps (WISP 1200): `apps/1` on paired sessions and the engine's `app*` calls. On from release 1.2 (a version\n * before 1.2.0 is never cut with it on: `RELEASE_GUARDS` in tools/scripts/changes.mjs). Off, nothing is offered to\n * contacts and every call is refused; a host that runs no apps pins its engine off (`NodeOptions.apps`). */\nexport const APPS_ENABLED: boolean = true;\n\n/**\n * A build that may be put into test mode: a development build (`import.meta.env.DEV`, which vitest also sets) or the\n * e2e suite's build (`VITE_APPS_TEST`, fixed when the build is made, as the mini-app switch is). A release build is\n * neither: Vite folds this to `false` there, so the storage flags the test fakes answer to are ignored. The fakes\n * themselves are still in the bundle (the registries import them); plugins may still pass fakes to the registry.\n */\nexport const testBuild = (): boolean => { try { return !!import.meta.env?.DEV || import.meta.env?.VITE_APPS_TEST === \"1\"; } catch { return false; } };\n\n/**\n * A suite's switch in the page's storage (`localStorage[\"ghostly-test-…\"]`), read only in a test build (`testBuild`): a\n * release build reads none, so a leftover or pasted key changes nothing there. Null when unset, unreadable or released.\n */\nexport const testSwitch = (key: string): string | null => {\n if (!testBuild()) return null;\n try { return globalThis.localStorage?.getItem(key) ?? null; } catch { return null; }\n};\n","import { boundVerifiedIdentity, IDENTITY_MAX_EVIDENCE, IDENTITY_MAX_VALIDITY, type IdentityStatement, type VerifiedIdentity } from \"@ghostly/core\";\nimport type { IdentityFetch, IdentityProofProvider, IdentitySigner, VerifyContext } from \"./contract\";\n\nconst DAY = 86_400;\n\n/**\n * The checks every proof goes through, whatever its provider: known provider, validity within the\n * provider's limit, bounded evidence, strict parsing, the provider's own check, and the category rule\n * (a self-custodied proof proves exactly the subject it names; an attested one says who attests it).\n * The engine verifies a contact's proof, and the person's own proof before saving it, only through this.\n */\nexport async function verifyIdentity(providers: readonly IdentityProofProvider[], statement: IdentityStatement, evidence: unknown, ctx: VerifyContext): Promise<VerifiedIdentity> {\n const { binding } = statement;\n const provider = providers.find(p => p.id === binding.provider);\n if (!provider) throw new Error(\"This app cannot verify this kind of identity\");\n if (binding.expiresAt - binding.issuedAt > Math.min(provider.validity.maxDays * DAY, IDENTITY_MAX_VALIDITY)) throw new Error(\"The proof lasts longer than this kind of identity allows\");\n if (JSON.stringify(evidence ?? null).length > IDENTITY_MAX_EVIDENCE) throw new Error(\"Evidence too large\");\n const parsed = provider.parseEvidence(evidence);\n const verified = boundVerifiedIdentity(await provider.verify(statement, parsed, ctx));\n if (provider.category === \"self-custodied\" && verified.subject !== binding.subject) throw new Error(\"The evidence is for another identity\");\n if (provider.category === \"provider-attested\" && !verified.attester) throw new Error(\"The evidence does not say who attests it\");\n return verified;\n}\n\n/** Problems with a provider's descriptor, empty when it is well-formed. The registry and the contract suite use it. */\nexport function descriptorProblems(p: IdentityProofProvider): string[] {\n const problems: string[] = [];\n if (!/^[a-z][a-z0-9-]{0,31}$/.test(p.id)) problems.push(\"id must match ^[a-z][a-z0-9-]{0,31}$\");\n if (!p.label?.trim()) problems.push(\"label is empty\");\n if (!p.description?.trim()) problems.push(\"description is empty\");\n if (!p.privacy?.trim()) problems.push(\"privacy is empty: say what verify contacts\");\n if (p.category !== \"self-custodied\" && p.category !== \"provider-attested\") problems.push(\"category is unknown\");\n if (!p.platforms.length) problems.push(\"no platforms\");\n const { defaultDays, maxDays } = p.validity;\n if (!(Number.isInteger(defaultDays) && Number.isInteger(maxDays) && defaultDays >= 1 && defaultDays <= maxDays && maxDays * DAY <= IDENTITY_MAX_VALIDITY)) problems.push(\"validity must be whole days, 1 ≤ default ≤ max ≤ 400\");\n if (p.recheck && !(Number.isInteger(p.recheck.afterSeconds) && p.recheck.afterSeconds >= 60)) problems.push(\"recheck.afterSeconds must be at least 60\");\n if (!p.signers.length) problems.push(\"no signers\");\n const ids = p.signers.map(s => s.id);\n if (new Set(ids).size !== ids.length) problems.push(\"signer ids are not unique\");\n for (const s of p.signers as readonly IdentitySigner<unknown>[]) {\n if (![\"in-app\", \"external-tool\", \"redirect\", \"publish\"].includes(s.kind)) problems.push(`signer ${s.id} has an unknown kind`);\n if (s.kind === \"in-app\" && typeof s.run !== \"function\") problems.push(`signer ${s.id} has no run()`);\n if (s.kind === \"external-tool\" && (typeof s.instructions !== \"function\" || typeof s.parse !== \"function\")) problems.push(`signer ${s.id} needs instructions() and parse()`);\n if (s.kind === \"redirect\" && typeof s.start !== \"function\") problems.push(`signer ${s.id} has no start()`);\n if (s.kind === \"publish\" && (typeof s.instructions !== \"function\" || typeof s.evidence !== \"function\")) problems.push(`signer ${s.id} needs instructions() and evidence()`);\n }\n return problems;\n}\n\n/** Signers of a provider that run on this platform and are available in this window. */\nexport function availableSigners<E>(p: IdentityProofProvider<E>, platform: IdentityProofProvider[\"platforms\"][number]): IdentitySigner<E>[] {\n return p.signers.filter(s => (s.platforms ?? p.platforms).includes(platform) && (s.available?.() ?? true));\n}\n\n/**\n * The engine's `ctx.fetch`: HTTPS GET only, no credentials or referrer, a time-out, a size cap,\n * redirects refused unless asked for.\n * `online` false refuses everything (the person turned the network off).\n */\nexport function boundedIdentityFetch(options: { online: () => boolean; timeoutMs?: number; fetcher?: typeof fetch } = { online: () => true }): IdentityFetch {\n return async (url, { headers, maxBytes = 64 * 1024, signal, redirect = \"error\" } = {}) => {\n if (!options.online()) throw new Error(\"Offline: this identity cannot be checked now\");\n const target = new URL(url);\n if (target.protocol !== \"https:\" || target.username || target.password) throw new Error(\"Identity checks use HTTPS only\");\n const timeout = AbortSignal.timeout(options.timeoutMs ?? 10_000);\n const response = await (options.fetcher ?? fetch)(target.href, {\n headers, signal: signal ? AbortSignal.any([signal, timeout]) : timeout,\n credentials: \"omit\", referrerPolicy: \"no-referrer\", cache: \"no-store\", redirect,\n });\n if (Number(response.headers.get(\"content-length\")) > maxBytes) throw new Error(\"Identity check response too large\");\n const reader = response.body?.getReader();\n const parts: Uint8Array[] = [];\n let length = 0;\n if (reader) {\n try {\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n length += value.length;\n if (length > maxBytes) throw new Error(\"Identity check response too large\");\n parts.push(value);\n }\n } finally { await reader.cancel().catch(() => {}); }\n }\n const bytes = new Uint8Array(length);\n let offset = 0;\n for (const part of parts) { bytes.set(part, offset); offset += part.length; }\n return { status: response.status, contentType: response.headers.get(\"content-type\") ?? \"\", text: new TextDecoder().decode(bytes), bytes };\n };\n}\n","import type { GhostlyAdapterPlugin } from \"./registry\";\n\n/**\n * The adapter plugins compiled into this build. Empty unless the build lists some: `GHOSTLY_PLUGINS`\n * names their modules (comma-separated paths from the repository root, each default-exporting a\n * `GhostlyAdapterPlugin`), and the Vite plugin in `packages/browser/vite-plugin.ts` swaps this module\n * for one that imports them. Release builds never set it; the e2e build carries the SDK example.\n */\nexport const BUNDLED_PLUGINS: readonly GhostlyAdapterPlugin[] = [];\n","import type { LightningProviderDescriptor } from \"../engine/paymentAdapters/providers/lightning\";\nimport type { OnchainProviderDescriptor } from \"../engine/paymentAdapters/providers/onchain\";\nimport { providerDescriptorProblems, type ProviderDescriptor, type ProviderKind } from \"../engine/paymentAdapters/providers/types\";\nimport type { IdentityProofProvider } from \"../proofs/contract\";\nimport { descriptorProblems } from \"../proofs/verify\";\nimport { BUNDLED_PLUGINS } from \"./bundled\";\n\n/**\n * Adapters written outside the app: wallet sources (Lightning, on-chain) and identity-proof providers\n * that register here instead of being added to the built-in lists. A plugin is a plain object naming\n * its adapters; the registries (`providers/registry.ts`, `proofs/registry.ts`) list what is registered\n * after the built-ins and before the test fakes, and the same platform and mode rules apply to all.\n *\n * Two ways in:\n * - at build time: `GHOSTLY_PLUGINS` lists the modules and `bundled.ts` is swapped for them;\n * - at run time: code already running in the engine's realm calls `registerAdapters` before the\n * pickers are shown (or after: the engine re-reads the lists when something registers).\n *\n * Trust: a plugin runs with the app's privileges, in the app's own JavaScript realm. There is no\n * sandbox, no permission prompt and no store; whoever builds a plugin in, or loads one, trusts its\n * author with everything the app can do, keys and sats included. A manifest with permissions and an\n * isolated runtime are a later phase (docs/wisps/ADAPTER-ROADMAP.md, \"Plugins, apps, catalogs\").\n *\n * The state lives on `globalThis` under a well-known symbol, so a plugin bundled with its own copy of\n * the SDK (a second copy of this module) still registers into the same lists the app reads.\n */\n\n/** The generation of the adapter contracts. A plugin says which one it was written against. */\nexport const SDK_API = 1;\nexport const PLUGIN_ID = /^[a-z][a-z0-9-]{0,63}$/;\n\nexport interface GhostlyAdapterPlugin {\n /** Stable, unique among plugins: `^[a-z][a-z0-9-]{0,63}$`. */\n id: string;\n /** The plugin's own version, for people. */\n version?: string;\n /** The contract generation it was written against: `SDK_API`. Another one is refused. */\n sdk: number;\n lightning?: readonly LightningProviderDescriptor[];\n onchain?: readonly OnchainProviderDescriptor[];\n identities?: readonly IdentityProofProvider[];\n}\n\nexport type AdapterKind = ProviderKind | \"identity\";\n\ninterface Store {\n plugins: Map<string, GhostlyAdapterPlugin>;\n /** Ids the built-in registries own, per kind: a plugin cannot take one. */\n reserved: Record<AdapterKind, Set<string>>;\n listeners: Set<() => void>;\n seeded: boolean;\n}\n\nconst KEY = Symbol.for(\"ghostly.adapters/1\");\nfunction store(): Store {\n const g = globalThis as unknown as Record<symbol, Store | undefined>;\n return (g[KEY] ??= { plugins: new Map(), reserved: { lightning: new Set(), onchain: new Set(), identity: new Set() }, listeners: new Set(), seeded: false });\n}\n\nconst ids = (kind: AdapterKind, plugin: GhostlyAdapterPlugin): string[] => {\n // Not trusted to be well formed: pluginProblems reads it before saying what is wrong with it.\n const list: unknown = kind === \"identity\" ? plugin.identities : kind === \"lightning\" ? plugin.lightning : plugin.onchain;\n return Array.isArray(list) ? list.map((a: { id?: string } | null) => a?.id as string) : [];\n};\nconst KINDS: readonly AdapterKind[] = [\"lightning\", \"onchain\", \"identity\"];\n\n/** Problems with a plugin, empty when it can be registered. Does not look at what is already registered. */\nexport function pluginProblems(plugin: GhostlyAdapterPlugin): string[] {\n const problems: string[] = [];\n if (!plugin || typeof plugin !== \"object\") return [\"not a plugin object\"];\n if (!PLUGIN_ID.test(plugin.id ?? \"\")) problems.push(\"plugin id must match ^[a-z][a-z0-9-]{0,63}$\");\n if (plugin.sdk !== SDK_API) problems.push(`plugin was written for SDK API ${String(plugin.sdk)}; this app speaks ${SDK_API}`);\n if (plugin.version !== undefined && (typeof plugin.version !== \"string\" || plugin.version.length > 64)) problems.push(\"version must be a short string\");\n for (const kind of [\"lightning\", \"onchain\"] as const) {\n const list = plugin[kind];\n if (list === undefined) continue;\n if (!Array.isArray(list)) { problems.push(`${kind} must be a list of descriptors`); continue; }\n for (const d of list as ProviderDescriptor<unknown>[]) {\n if (!d || typeof d !== \"object\") { problems.push(`${kind} ${String(d)}: not a descriptor`); continue; }\n const own = providerDescriptorProblems(d);\n if (d?.kind && d.kind !== kind) own.push(`is listed under ${kind} but says kind ${String(d.kind)}`);\n problems.push(...own.map((p) => `${kind} ${String(d?.id)}: ${p}`));\n }\n }\n if (plugin.identities !== undefined) {\n if (!Array.isArray(plugin.identities)) problems.push(\"identities must be a list of providers\");\n else for (const p of plugin.identities) {\n if (!p || typeof p !== \"object\") problems.push(`identity ${String(p)}: not a provider`);\n else problems.push(...descriptorProblems(p).map((m) => `identity ${String(p.id)}: ${m}`));\n }\n }\n for (const kind of KINDS) {\n const list = ids(kind, plugin);\n if (new Set(list).size !== list.length) problems.push(`${kind} ids are not unique within the plugin`);\n }\n if (!KINDS.some((kind) => ids(kind, plugin).length)) problems.push(\"the plugin brings no adapter\");\n return problems;\n}\n\n/** The built-in registries say which ids are theirs. A plugin using one is refused. */\nexport function reserveAdapterIds(kind: AdapterKind, list: readonly string[]): void {\n const s = store();\n for (const id of list) s.reserved[kind].add(id);\n}\n\n/**\n * Registers a plugin's adapters. Throws, registering nothing, when the plugin is malformed, its id or\n * one of its adapters' ids is taken (by a built-in or by another plugin), or its contract generation\n * is another one. Returns the function that unregisters it.\n */\nexport function registerAdapters(plugin: GhostlyAdapterPlugin): () => void {\n const problems = pluginProblems(plugin);\n const s = store();\n if (!problems.length) {\n if (s.plugins.has(plugin.id)) problems.push(`a plugin with id ${plugin.id} is already registered`);\n for (const kind of KINDS) for (const id of ids(kind, plugin)) {\n if (s.reserved[kind].has(id)) problems.push(`${kind} ${id} is a built-in of this app`);\n for (const other of s.plugins.values()) if (ids(kind, other).includes(id)) problems.push(`${kind} ${id} is already registered by plugin ${other.id}`);\n }\n }\n if (problems.length) throw new Error(`Cannot register plugin ${String(plugin?.id)}: ${problems.join(\"; \")}`);\n s.plugins.set(plugin.id, plugin);\n notify(s);\n return () => { if (s.plugins.get(plugin.id) === plugin) { s.plugins.delete(plugin.id); notify(s); } };\n}\n\nfunction notify(s: Store) { for (const listener of s.listeners) { try { listener(); } catch { /* a listener's problem */ } } }\n\n/** Called when a plugin registers or unregisters: the engine re-reads the lists. */\nexport function onAdaptersChanged(listener: () => void): () => void {\n const s = store();\n s.listeners.add(listener);\n return () => { s.listeners.delete(listener); };\n}\n\n/** Every registered plugin, in registration order (bundled ones first). */\nexport function registeredPlugins(): readonly GhostlyAdapterPlugin[] { seed(); return [...store().plugins.values()]; }\nexport function registeredLightningProviders(): readonly LightningProviderDescriptor[] { return registeredPlugins().flatMap((p) => p.lightning ?? []); }\nexport function registeredOnchainProviders(): readonly OnchainProviderDescriptor[] { return registeredPlugins().flatMap((p) => p.onchain ?? []); }\nexport function registeredIdentityProviders(): readonly IdentityProofProvider[] { return registeredPlugins().flatMap((p) => p.identities ?? []); }\n\n/**\n * The plugins compiled into this build register once, when they are first asked for. A broken one is\n * reported and skipped rather than taking the app down with it; the e2e that expects it fails instead.\n */\nfunction seed() {\n const s = store();\n if (s.seeded) return;\n s.seeded = true;\n for (const plugin of BUNDLED_PLUGINS) {\n try { registerAdapters(plugin); }\n catch (error) { console.error(`[ghostly] a bundled adapter plugin was not loaded: ${error instanceof Error ? error.message : String(error)}`); }\n }\n}\n\n/** Tests only: forget every registration, including the bundled ones. */\nexport function resetAdapterRegistry(): void {\n const s = store();\n s.plugins.clear(); s.seeded = false;\n for (const kind of KINDS) s.reserved[kind].clear();\n notify(s);\n}\n","/**\n * The profile's own Ghostly did:dht, which the DID provider refuses as an external identity. The UI and the engine each\n * set where to read it. Here, not in the provider, so setting it does not load the providers.\n */\nlet source: () => string | undefined = () => undefined;\nexport function setOwnDidSource(read: () => string | undefined): void { source = read; }\nexport const ownDid = (): string | undefined => source();\n"],"mappings":";;;;;;;;;AAgBA,IAAa,kBAA2B;CAAE,IAAI;EAAE,OAAiC;CAAyC,QAAQ;EAAE,OAAO;CAAO;AAAE;;;;;AAMpJ,IAAa,cAAc,QAA+B;CACxD,IAAI,CAAC,UAAU,GAAG,OAAO;CACzB,IAAI;EAAE,OAAO,WAAW,cAAc,QAAQ,GAAG,KAAK;CAAM,QAAQ;EAAE,OAAO;CAAM;AACrF;;;ACtBA,IAAM,MAAM;;;;;;;AAQZ,eAAsB,eAAe,WAA6C,WAA8B,UAAmB,KAA+C;CAChL,MAAM,EAAE,YAAY;CACpB,MAAM,WAAW,UAAU,MAAK,MAAK,EAAE,OAAO,QAAQ,QAAQ;CAC9D,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,8CAA8C;CAC7E,IAAI,QAAQ,YAAY,QAAQ,WAAW,KAAK,IAAI,SAAS,SAAS,UAAU,KAAA,MAA0B,GAAG,MAAM,IAAI,MAAM,0DAA0D;CACvL,IAAI,KAAK,UAAU,YAAY,IAAI,CAAC,CAAC,SAAA,OAAgC,MAAM,IAAI,MAAM,oBAAoB;CACzG,MAAM,SAAS,SAAS,cAAc,QAAQ;CAC9C,MAAM,W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as signingKeys, Bu as utf8Decode, Cn as homeserverWebEndpoint, Ct as DID_FILE_MAX_BYTES, Dt as checkDidSignature, Et as checkDidJws, Fi as normalizeDomain, Ft as didWebHost, Fu as fromBase64Url, Ht as strictBase64Url, It as normalizeDid, Ji as IdentityCheckUnavailable, Lt as parseDid, Lu as randomBytes, Mt as didWebFile, Nt as didWebFileNames, Ot as didGhostlyServiceEntry, Pt as didWebFileUrl, Q as SSHSIG_NAMESPACE, Rt as parseDidDocument, Ru as toBase64Url, Sn as pubkyProofPath, St as DID_DOCUMENT_MAX_BYTES, Tt as DidError, Vt as staticDidDocument, Vu as utf8Encode, _n as isPubkyProofFolder, _t as normalizeAtprotoHandle, at as verifyBitcoinMessage, bn as pubkyProofCapability, bt as AtprotoProofError, ct as ATPROTO_DECLARED_SCOPE, dt as ATPROTO_PROOF_SCOPE, et as parseSshPublicKey, gn as isPubkyKey, gt as isAtprotoDid, hn as PUBKY_PROOF_MAX_BYTES, ht as checkAtprotoProofRecord, it as verifySshSignature, ji as domainWellKnownFile, jt as didWebDocumentUrl, ki as dnsProofName, kt as didJwsAlg, lt as ATPROTO_FULL_SCOPE, mt as atprotoProofRkey, ot as BitcoinAddressError, pt as atprotoProofRecord, qt as resolveDidDht, rt as sshSignCommand, st as decodeAnyBitcoinAddress, tt as parseSshSignature, ut as ATPROTO_PROOF_COLLECTION, vn as newPubkyProofFolder, wn as pubkyHomeserverOf, wu as openRelayPayload, xn as pubkyProofFile, xt as verifyAtprotoRecordProof, xu as RELAY_PAYLOAD_MAX_BYTES, yn as normalizePubkyKey, yt as shortAtprotoDid, zt as parseDidSignaturePaste } from "./src-BD8RBVEp.js";
|
|
2
|
+
import { c as boundedIdentityFetch, i as registeredIdentityProviders, s as reserveAdapterIds, t as ownDid, u as testBuild } from "./ownDid-D8z5gwGI.js";
|
|
3
|
+
import { a as verifiedAtprotoHandle, c as assertDomainRecord, d as chosenResolver, f as resolverById, i as resolveAtprotoHandle, l as assertNip05, r as resolveAtprotoDid, s as DomainCheckError, t as assertPublicServer, u as assertPublicHost } from "./resolve-ZxVzwFNA.js";
|
|
4
|
+
import { a as PUBKY_RELAYS, c as isConfigured, d as providerForIssuer, i as validForgeLogin, l as issuerFor, n as SSH_FORGE_LABEL, o as audiences, r as checkSshForge, s as clientIdFor, t as SSH_FORGE_HOST, u as oidcProviders } from "./sshForges-DWrESWkK.js";
|
|
3
5
|
import { ed25519 } from "@noble/curves/ed25519.js";
|
|
4
6
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
5
7
|
import { schnorr } from "@noble/curves/secp256k1.js";
|
|
@@ -1271,81 +1273,6 @@ var openpgp = {
|
|
|
1271
1273
|
}
|
|
1272
1274
|
};
|
|
1273
1275
|
//#endregion
|
|
1274
|
-
//#region ../browser/src/proofs/sshForges.ts
|
|
1275
|
-
var SSH_FORGE_LABEL = {
|
|
1276
|
-
github: "GitHub",
|
|
1277
|
-
gitlab: "GitLab"
|
|
1278
|
-
};
|
|
1279
|
-
/** The only host each forge lookup contacts, for the privacy line. */
|
|
1280
|
-
var SSH_FORGE_HOST = {
|
|
1281
|
-
github: "api.github.com",
|
|
1282
|
-
gitlab: "gitlab.com"
|
|
1283
|
-
};
|
|
1284
|
-
var MAX_BODY = 262144;
|
|
1285
|
-
var MAX_KEYS = 200;
|
|
1286
|
-
function validForgeLogin(forge, login) {
|
|
1287
|
-
if (typeof login !== "string") return false;
|
|
1288
|
-
return forge === "github" ? /^[A-Za-z0-9](?:[A-Za-z0-9]|-(?=[A-Za-z0-9])){0,38}$/.test(login) : /^[A-Za-z0-9_.][A-Za-z0-9_.-]{0,63}$/.test(login) && !/\.(?:git|atom)$/i.test(login);
|
|
1289
|
-
}
|
|
1290
|
-
async function get(fetcher, url, signal) {
|
|
1291
|
-
const response = await fetcher(url, {
|
|
1292
|
-
maxBytes: MAX_BODY,
|
|
1293
|
-
signal
|
|
1294
|
-
});
|
|
1295
|
-
if (response.status === 404) return { status: 404 };
|
|
1296
|
-
if (response.status === 403 || response.status === 429) throw new Error(`${new URL(url).host} is limiting lookups; check again later`);
|
|
1297
|
-
if (response.status !== 200) throw new Error(`${new URL(url).host} answered HTTP ${response.status}`);
|
|
1298
|
-
try {
|
|
1299
|
-
return {
|
|
1300
|
-
status: 200,
|
|
1301
|
-
body: JSON.parse(response.text)
|
|
1302
|
-
};
|
|
1303
|
-
} catch {
|
|
1304
|
-
throw new Error(`Unexpected answer from ${new URL(url).host}`);
|
|
1305
|
-
}
|
|
1306
|
-
}
|
|
1307
|
-
function keysFrom(body) {
|
|
1308
|
-
if (!Array.isArray(body)) throw new Error("Unexpected key list");
|
|
1309
|
-
const keys = [];
|
|
1310
|
-
for (const entry of body.slice(0, MAX_KEYS)) {
|
|
1311
|
-
const line = entry?.key;
|
|
1312
|
-
if (typeof line !== "string") continue;
|
|
1313
|
-
try {
|
|
1314
|
-
keys.push(parseSshPublicKey(line));
|
|
1315
|
-
} catch {}
|
|
1316
|
-
}
|
|
1317
|
-
return keys;
|
|
1318
|
-
}
|
|
1319
|
-
/** The account's published keys, or null when there is no such account. */
|
|
1320
|
-
async function listKeys(forge, login, fetcher, signal) {
|
|
1321
|
-
if (forge === "github") {
|
|
1322
|
-
const r = await get(fetcher, `https://api.github.com/users/${encodeURIComponent(login)}/keys?per_page=100`, signal);
|
|
1323
|
-
return r.status === 404 ? null : keysFrom(r.body);
|
|
1324
|
-
}
|
|
1325
|
-
const users = await get(fetcher, `https://gitlab.com/api/v4/users?username=${encodeURIComponent(login)}`, signal);
|
|
1326
|
-
const user = (users.status === 200 && Array.isArray(users.body) ? users.body : []).find((u) => typeof u?.username === "string" && u.username.toLowerCase() === login.toLowerCase());
|
|
1327
|
-
if (!user) return null;
|
|
1328
|
-
if (!Number.isSafeInteger(user.id) || user.id <= 0) throw new Error("Unexpected answer from gitlab.com");
|
|
1329
|
-
const r = await get(fetcher, `https://gitlab.com/api/v4/users/${user.id}/keys?per_page=100`, signal);
|
|
1330
|
-
return r.status === 404 ? null : keysFrom(r.body);
|
|
1331
|
-
}
|
|
1332
|
-
var inFlight = /* @__PURE__ */ new WeakMap();
|
|
1333
|
-
/** Whether `key` is one of `login`'s published SSH keys. Throws when the forge cannot be asked. */
|
|
1334
|
-
async function checkSshForge(forge, login, key, fetcher, signal) {
|
|
1335
|
-
if (!validForgeLogin(forge, login)) throw new Error(`Not a ${SSH_FORGE_LABEL[forge]} username`);
|
|
1336
|
-
let pending = inFlight.get(fetcher);
|
|
1337
|
-
if (!pending) inFlight.set(fetcher, pending = /* @__PURE__ */ new Map());
|
|
1338
|
-
const map = pending, id = `${forge}:${login.toLowerCase()}`;
|
|
1339
|
-
let lookup = map.get(id);
|
|
1340
|
-
if (!lookup) {
|
|
1341
|
-
lookup = listKeys(forge, login, fetcher, signal).finally(() => map.delete(id));
|
|
1342
|
-
map.set(id, lookup);
|
|
1343
|
-
}
|
|
1344
|
-
const keys = await lookup;
|
|
1345
|
-
if (!keys) return "no-account";
|
|
1346
|
-
return keys.some((k) => sameSshKey(k, key)) ? "linked" : "not-listed";
|
|
1347
|
-
}
|
|
1348
|
-
//#endregion
|
|
1349
1276
|
//#region ../browser/src/proofs/providers/ssh.ts
|
|
1350
1277
|
var FINGERPRINT = /^SHA256:[A-Za-z0-9+/]{43}$/;
|
|
1351
1278
|
function normalizeKeySubject(input) {
|
|
@@ -1518,172 +1445,6 @@ function getBrowserHost() {
|
|
|
1518
1445
|
return current;
|
|
1519
1446
|
}
|
|
1520
1447
|
//#endregion
|
|
1521
|
-
//#region ../browser/src/proofs/oidc/providers.ts
|
|
1522
|
-
var TEST_ISSUER = /^https:\/\/[a-z0-9-]+(\.[a-z0-9-]+)*\.test$/;
|
|
1523
|
-
var MICROSOFT_TENANT = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
1524
|
-
var OIDC_PROVIDERS = {
|
|
1525
|
-
google: {
|
|
1526
|
-
id: "google",
|
|
1527
|
-
name: "Google",
|
|
1528
|
-
issuer: "https://accounts.google.com",
|
|
1529
|
-
issuerAliases: ["accounts.google.com"],
|
|
1530
|
-
discovery: "https://accounts.google.com/.well-known/openid-configuration",
|
|
1531
|
-
authorizationEndpoint: "https://accounts.google.com/o/oauth2/v2/auth",
|
|
1532
|
-
jwksUri: "https://www.googleapis.com/oauth2/v3/certs",
|
|
1533
|
-
algs: ["RS256"],
|
|
1534
|
-
responseType: "id_token",
|
|
1535
|
-
reveal: {
|
|
1536
|
-
email: { scope: "email" },
|
|
1537
|
-
profile: { scope: "profile" }
|
|
1538
|
-
},
|
|
1539
|
-
alwaysIncluded: "A Google account identifier.",
|
|
1540
|
-
extraParams: { prompt: "select_account" },
|
|
1541
|
-
clientIds: {
|
|
1542
|
-
web: "",
|
|
1543
|
-
extension: ""
|
|
1544
|
-
}
|
|
1545
|
-
},
|
|
1546
|
-
microsoft: {
|
|
1547
|
-
id: "microsoft",
|
|
1548
|
-
name: "Microsoft",
|
|
1549
|
-
issuer: "https://login.microsoftonline.com/{tenantid}/v2.0",
|
|
1550
|
-
discovery: "https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration",
|
|
1551
|
-
authorizationEndpoint: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
|
|
1552
|
-
jwksUri: "https://login.microsoftonline.com/common/discovery/v2.0/keys",
|
|
1553
|
-
algs: ["RS256"],
|
|
1554
|
-
responseType: "id_token",
|
|
1555
|
-
reveal: {
|
|
1556
|
-
email: { scope: "email" },
|
|
1557
|
-
profile: { scope: "profile" }
|
|
1558
|
-
},
|
|
1559
|
-
alwaysIncluded: "A Microsoft account identifier and the directory (tenant) the account belongs to.",
|
|
1560
|
-
extraParams: {
|
|
1561
|
-
prompt: "select_account",
|
|
1562
|
-
response_mode: "fragment"
|
|
1563
|
-
},
|
|
1564
|
-
clientIds: {
|
|
1565
|
-
web: "",
|
|
1566
|
-
extension: ""
|
|
1567
|
-
}
|
|
1568
|
-
},
|
|
1569
|
-
apple: {
|
|
1570
|
-
id: "apple",
|
|
1571
|
-
name: "Apple",
|
|
1572
|
-
issuer: "https://appleid.apple.com",
|
|
1573
|
-
discovery: "https://appleid.apple.com/.well-known/openid-configuration",
|
|
1574
|
-
authorizationEndpoint: "https://appleid.apple.com/auth/authorize",
|
|
1575
|
-
jwksUri: "https://appleid.apple.com/auth/keys",
|
|
1576
|
-
algs: ["RS256"],
|
|
1577
|
-
responseType: "code id_token",
|
|
1578
|
-
reveal: {},
|
|
1579
|
-
alwaysIncluded: "An Apple ID identifier that only Ghostly sees. Apple cannot add your email here without a Ghostly server.",
|
|
1580
|
-
extraParams: { response_mode: "fragment" },
|
|
1581
|
-
clientIds: {
|
|
1582
|
-
web: "",
|
|
1583
|
-
extension: ""
|
|
1584
|
-
}
|
|
1585
|
-
},
|
|
1586
|
-
gitlab: {
|
|
1587
|
-
id: "gitlab",
|
|
1588
|
-
name: "GitLab",
|
|
1589
|
-
issuer: "https://gitlab.com",
|
|
1590
|
-
discovery: "https://gitlab.com/.well-known/openid-configuration",
|
|
1591
|
-
authorizationEndpoint: "https://gitlab.com/oauth/authorize",
|
|
1592
|
-
tokenEndpoint: "https://gitlab.com/oauth/token",
|
|
1593
|
-
revocationEndpoint: "https://gitlab.com/oauth/revoke",
|
|
1594
|
-
jwksUri: "https://gitlab.com/oauth/discovery/keys",
|
|
1595
|
-
algs: ["RS256"],
|
|
1596
|
-
responseType: "code",
|
|
1597
|
-
reveal: {
|
|
1598
|
-
email: { scope: "email" },
|
|
1599
|
-
profile: { scope: "profile" }
|
|
1600
|
-
},
|
|
1601
|
-
alwaysIncluded: "A GitLab.com user ID and the groups you belong to directly: GitLab adds them to every ID token.",
|
|
1602
|
-
clientIds: {
|
|
1603
|
-
web: "",
|
|
1604
|
-
extension: ""
|
|
1605
|
-
}
|
|
1606
|
-
},
|
|
1607
|
-
twitch: {
|
|
1608
|
-
id: "twitch",
|
|
1609
|
-
name: "Twitch",
|
|
1610
|
-
issuer: "https://id.twitch.tv/oauth2",
|
|
1611
|
-
discovery: "https://id.twitch.tv/oauth2/.well-known/openid-configuration",
|
|
1612
|
-
authorizationEndpoint: "https://id.twitch.tv/oauth2/authorize",
|
|
1613
|
-
jwksUri: "https://id.twitch.tv/oauth2/keys",
|
|
1614
|
-
algs: ["RS256"],
|
|
1615
|
-
responseType: "id_token",
|
|
1616
|
-
reveal: { profile: { claims: ["preferred_username"] } },
|
|
1617
|
-
alwaysIncluded: "A Twitch user ID.",
|
|
1618
|
-
extraParams: { force_verify: "true" },
|
|
1619
|
-
clientIds: {
|
|
1620
|
-
web: "",
|
|
1621
|
-
extension: ""
|
|
1622
|
-
}
|
|
1623
|
-
}
|
|
1624
|
-
};
|
|
1625
|
-
/**
|
|
1626
|
-
* The local issuer the e2e suite runs (e2e/support/oidcIssuer.ts). It exists
|
|
1627
|
-
* only in a build made with VITE_OIDC_TEST_ISSUER, and only on a `.test` host
|
|
1628
|
-
* (a name reserved for testing, never a real issuer); a release build has no
|
|
1629
|
-
* such provider, so a token from it is refused like any unknown issuer.
|
|
1630
|
-
*/
|
|
1631
|
-
function testProvider(issuer) {
|
|
1632
|
-
if (!TEST_ISSUER.test(issuer)) throw new Error("A test issuer lives on a .test host");
|
|
1633
|
-
const base = issuer;
|
|
1634
|
-
return {
|
|
1635
|
-
id: "test",
|
|
1636
|
-
name: "Test issuer",
|
|
1637
|
-
issuer: base,
|
|
1638
|
-
discovery: `${base}/.well-known/openid-configuration`,
|
|
1639
|
-
authorizationEndpoint: `${base}/authorize`,
|
|
1640
|
-
jwksUri: `${base}/jwks`,
|
|
1641
|
-
algs: ["RS256", "ES256"],
|
|
1642
|
-
responseType: "id_token",
|
|
1643
|
-
reveal: {
|
|
1644
|
-
email: { scope: "email" },
|
|
1645
|
-
profile: { scope: "profile" }
|
|
1646
|
-
},
|
|
1647
|
-
alwaysIncluded: "A test account identifier.",
|
|
1648
|
-
clientIds: {
|
|
1649
|
-
web: "ghostly-e2e",
|
|
1650
|
-
extension: "ghostly-e2e",
|
|
1651
|
-
desktop: "ghostly-e2e"
|
|
1652
|
-
}
|
|
1653
|
-
};
|
|
1654
|
-
}
|
|
1655
|
-
function configuredTestIssuer() {
|
|
1656
|
-
try {
|
|
1657
|
-
return;
|
|
1658
|
-
} catch {
|
|
1659
|
-
return;
|
|
1660
|
-
}
|
|
1661
|
-
}
|
|
1662
|
-
/** Every provider this build knows, configured or not. */
|
|
1663
|
-
function oidcProviders(testIssuer = configuredTestIssuer()) {
|
|
1664
|
-
return [...Object.values(OIDC_PROVIDERS), ...testIssuer ? [testProvider(testIssuer)] : []];
|
|
1665
|
-
}
|
|
1666
|
-
/** Every client ID this provider has, on any platform: a contact may use another platform than the prover. */
|
|
1667
|
-
function audiences(provider) {
|
|
1668
|
-
return [...new Set(Object.values(provider.clientIds).filter((id) => !!id))];
|
|
1669
|
-
}
|
|
1670
|
-
function clientIdFor(provider, platform) {
|
|
1671
|
-
return provider.clientIds[platform] || provider.clientIds.web || "";
|
|
1672
|
-
}
|
|
1673
|
-
/** A provider is offered only once its client ID for this platform exists. */
|
|
1674
|
-
function isConfigured(provider, platform) {
|
|
1675
|
-
return !!clientIdFor(provider, platform);
|
|
1676
|
-
}
|
|
1677
|
-
/** The exact issuer a token from this provider must carry, or undefined when its claims do not name one. */
|
|
1678
|
-
function issuerFor(provider, claims) {
|
|
1679
|
-
if (provider.id !== "microsoft") return [provider.issuer, ...provider.issuerAliases ?? []];
|
|
1680
|
-
return typeof claims.tid === "string" && MICROSOFT_TENANT.test(claims.tid) ? [provider.issuer.replace("{tenantid}", claims.tid)] : [];
|
|
1681
|
-
}
|
|
1682
|
-
/** The provider a proof's subject (an issuer, as `OidcProvider.issuer` spells it) names. */
|
|
1683
|
-
function providerForIssuer(issuer, list = oidcProviders()) {
|
|
1684
|
-
return list.find((p) => p.issuer === issuer);
|
|
1685
|
-
}
|
|
1686
|
-
//#endregion
|
|
1687
1448
|
//#region ../browser/src/proofs/oidc/jwks.ts
|
|
1688
1449
|
var JWKS_MAX_BYTES = 65536;
|
|
1689
1450
|
var MIN_TTL_MS = 3e5;
|
|
@@ -3066,8 +2827,6 @@ var atproto = createAtprotoIdentityProvider();
|
|
|
3066
2827
|
* contract's bounded `ctx.fetch` only), and asking the person to approve one Pubky auth request in Pubky Ring or
|
|
3067
2828
|
* Pubky Passport (https://github.com/pubky/pubky-passport/blob/main/docs/integration.md). See WISP 302.
|
|
3068
2829
|
*/
|
|
3069
|
-
/** Pkarr relays the records are read from: Pubky's own, the ones the Pubky SDK uses. */
|
|
3070
|
-
var PUBKY_RELAYS = ["https://pkarr.pubky.org", "https://pkarr.pubky.app"];
|
|
3071
2830
|
/**
|
|
3072
2831
|
* The newest DNS packet the relays hold for `key`, its signature checked against `key`. Every relay is asked; one
|
|
3073
2832
|
* that is down, answers garbage or holds an older packet does not count. Throws when none has a valid one.
|
|
@@ -3806,4 +3565,4 @@ function identityProvider(id, providers = identityProviders()) {
|
|
|
3806
3565
|
//#endregion
|
|
3807
3566
|
export { identityProvider as n, identityProviders as r, IDENTITY_PROVIDERS as t };
|
|
3808
3567
|
|
|
3809
|
-
//# sourceMappingURL=registry-
|
|
3568
|
+
//# sourceMappingURL=registry-B2Dtnibo.js.map
|