@ghostlytools/cli 1.13.2 → 1.13.3

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.
Files changed (83) hide show
  1. package/README.md +9 -8
  2. package/dist/assets/{api-DV52o7A8.js → api-DO0YMLiB.js} +2 -2
  3. package/dist/assets/{api-O57SNJcb.js → api-Dz2cw7WD.js} +155 -44
  4. package/dist/assets/api-Dz2cw7WD.js.map +1 -0
  5. package/dist/assets/{apiKit-CPTFJHA7.js → apiKit-DAFsWtyk.js} +17 -3
  6. package/dist/assets/apiKit-DAFsWtyk.js.map +1 -0
  7. package/dist/assets/{appFetch-Ca9DNQQ2.js → appFetch-BQO5Pk7W.js} +2 -2
  8. package/dist/assets/{appFetch-Ca9DNQQ2.js.map → appFetch-BQO5Pk7W.js.map} +1 -1
  9. package/dist/assets/{apps-gXpGFPiv.js → apps-B88rYWRm.js} +45 -19
  10. package/dist/assets/apps-B88rYWRm.js.map +1 -0
  11. package/dist/assets/{apps-uZTu5FlR.js → apps-D4KRpZB4.js} +1 -1
  12. package/dist/assets/{backup-Di2U6QVH.js → backup-BeXBtbVL.js} +1 -1
  13. package/dist/assets/{backup-CxH3auHB.js → backup-CNLY905d.js} +10 -5
  14. package/dist/assets/backup-CNLY905d.js.map +1 -0
  15. package/dist/assets/bark_ffi_wasm_bg-CjjCN3FD.js +5 -0
  16. package/dist/assets/{bitcoind-BpZn3bRN.js → bitcoind-BXZdQ1wZ.js} +2 -2
  17. package/dist/assets/{bitcoind-BpZn3bRN.js.map → bitcoind-BXZdQ1wZ.js.map} +1 -1
  18. package/dist/assets/bitcoindevkit_bg-D6IFIaJi.js +5 -0
  19. package/dist/assets/{buttons-D4udKEvT.js → buttons-BKojbx0Q.js} +4 -4
  20. package/dist/assets/{buttons-D4udKEvT.js.map → buttons-BKojbx0Q.js.map} +1 -1
  21. package/dist/assets/buttons-_5Fw8uHn.js +1 -0
  22. package/dist/assets/{client-DGx7E8b3.js → client-BtPhfWjK.js} +2 -2
  23. package/dist/assets/{client-DGx7E8b3.js.map → client-BtPhfWjK.js.map} +1 -1
  24. package/dist/assets/{fedimintSdk-D-6H9Pe7.js → fedimintSdk-eLXBrj9i.js} +2 -2
  25. package/dist/assets/{fedimintSdk-D-6H9Pe7.js.map → fedimintSdk-eLXBrj9i.js.map} +1 -1
  26. package/dist/assets/fedimint_client_wasm_bg-CRQlnJdu.js +5 -0
  27. package/dist/assets/{fixedHosts-CODN2pTL.js → fixedHosts-BJFL8Ell.js} +3 -3
  28. package/dist/assets/{fixedHosts-CODN2pTL.js.map → fixedHosts-BJFL8Ell.js.map} +1 -1
  29. package/dist/assets/{groupMeta-CeZpqVVC.js → groupMeta-Cz95F6sX.js} +98 -9
  30. package/dist/assets/groupMeta-Cz95F6sX.js.map +1 -0
  31. package/dist/assets/{host-CRA7h5A2.js → host-BsBWxTtW.js} +172 -22
  32. package/dist/assets/host-BsBWxTtW.js.map +1 -0
  33. package/dist/assets/{identityProofs-B8zCp5_0.js → identityProofs-zI_Iy9uI.js} +15 -1
  34. package/dist/assets/identityProofs-zI_Iy9uI.js.map +1 -0
  35. package/dist/assets/{irohWeb-mnOi2Jp7.js → irohWeb-BLDcHwYz.js} +50 -13
  36. package/dist/assets/irohWeb-BLDcHwYz.js.map +1 -0
  37. package/dist/assets/{main-Chc871HV.js → main-D48Ben7C.js} +68 -28
  38. package/dist/assets/main-D48Ben7C.js.map +1 -0
  39. package/dist/assets/{ownDid-BOuSlDv-.js → ownDid-CwxFBzOH.js} +5 -4
  40. package/dist/assets/ownDid-CwxFBzOH.js.map +1 -0
  41. package/dist/assets/{ownStatus-CLA1VPkL.js → ownStatus-DjD0sQKF.js} +34 -11
  42. package/dist/assets/ownStatus-DjD0sQKF.js.map +1 -0
  43. package/dist/assets/{profiles-BH1bH9aE.js → profiles-BAJf0c9E.js} +33 -8
  44. package/dist/assets/profiles-BAJf0c9E.js.map +1 -0
  45. package/dist/assets/{registry-DAq16T-V.js → registry-CHwHTWbK.js} +1 -1
  46. package/dist/assets/{registry-DP_-RA-v.js → registry-CPuexTle.js} +25 -13
  47. package/dist/assets/registry-CPuexTle.js.map +1 -0
  48. package/dist/assets/{resolve-B1eQ4dVQ.js → resolve-BqmGXKn4.js} +2 -2
  49. package/dist/assets/{resolve-B1eQ4dVQ.js.map → resolve-BqmGXKn4.js.map} +1 -1
  50. package/dist/assets/{server-Bd2ofxc1.js → server-e4oKeNez.js} +399 -88
  51. package/dist/assets/server-e4oKeNez.js.map +1 -0
  52. package/dist/assets/{sshForges-As7dbGXM.js → sshForges-Cqt3qfWe.js} +2 -2
  53. package/dist/assets/{sshForges-As7dbGXM.js.map → sshForges-Cqt3qfWe.js.map} +1 -1
  54. package/dist/assets/translate-DnuQMfj0.js.map +1 -1
  55. package/dist/assets/{waitNotice-BHuMofaH.js → waitNotice-mB0Ym145.js} +2 -2
  56. package/dist/assets/{waitNotice-BHuMofaH.js.map → waitNotice-mB0Ym145.js.map} +1 -1
  57. package/dist/ghostly.mjs +1 -1
  58. package/npm-shrinkwrap.json +2 -2
  59. package/package.json +1 -1
  60. package/dist/assets/api-O57SNJcb.js.map +0 -1
  61. package/dist/assets/apiKit-CPTFJHA7.js.map +0 -1
  62. package/dist/assets/apps-gXpGFPiv.js.map +0 -1
  63. package/dist/assets/backup-CxH3auHB.js.map +0 -1
  64. package/dist/assets/bark_ffi_wasm_bg-CcafsJla.js +0 -5
  65. package/dist/assets/bark_ffi_wasm_bg-CcafsJla.js.map +0 -1
  66. package/dist/assets/bark_ffi_wasm_bg-VNmaJsc9.wasm +0 -0
  67. package/dist/assets/bitcoindevkit_bg-BWQHx7vd.js +0 -5
  68. package/dist/assets/bitcoindevkit_bg-BWQHx7vd.js.map +0 -1
  69. package/dist/assets/bitcoindevkit_bg-DXil67yS.wasm +0 -0
  70. package/dist/assets/buttons-YTYEqvGC.js +0 -1
  71. package/dist/assets/fedimint_client_wasm_bg-Cr5xGD-w.js +0 -5
  72. package/dist/assets/fedimint_client_wasm_bg-Cr5xGD-w.js.map +0 -1
  73. package/dist/assets/fedimint_client_wasm_bg-DeFtkIv6.wasm +0 -0
  74. package/dist/assets/groupMeta-CeZpqVVC.js.map +0 -1
  75. package/dist/assets/host-CRA7h5A2.js.map +0 -1
  76. package/dist/assets/identityProofs-B8zCp5_0.js.map +0 -1
  77. package/dist/assets/irohWeb-mnOi2Jp7.js.map +0 -1
  78. package/dist/assets/main-Chc871HV.js.map +0 -1
  79. package/dist/assets/ownDid-BOuSlDv-.js.map +0 -1
  80. package/dist/assets/ownStatus-CLA1VPkL.js.map +0 -1
  81. package/dist/assets/profiles-BH1bH9aE.js.map +0 -1
  82. package/dist/assets/registry-DP_-RA-v.js.map +0 -1
  83. package/dist/assets/server-Bd2ofxc1.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { c as toBase64, d as utf8Decode, f as utf8Encode, n as concatBytes, r as fromBase64, t as bytesEqual } from "./bytes-C1DNGY18.js";
2
- import { s as IdentityCheckUnavailable } from "./identityProofs-B8zCp5_0.js";
2
+ import { s as IdentityCheckUnavailable } from "./identityProofs-zI_Iy9uI.js";
3
3
  import { ed25519 } from "@noble/curves/ed25519.js";
4
4
  import { sha256, sha512 } from "@noble/hashes/sha2.js";
5
5
  import { p256, p384, p521 } from "@noble/curves/nist.js";
@@ -536,4 +536,4 @@ async function checkSshForge(forge, login, key, fetcher, signal) {
536
536
  }
537
537
  export { sshSignCommand as _, PUBKY_RELAYS as a, isConfigured as c, providerForIssuer as d, SSHSIG_MAX_ARMOR as f, parseSshSignature as g, parseSshPublicKey as h, validForgeLogin as i, issuerFor as l, SshSigError as m, SSH_FORGE_LABEL as n, audiences as o, SSHSIG_NAMESPACE as p, checkSshForge as r, clientIdFor as s, SSH_FORGE_HOST as t, oidcProviders as u, verifySshSignature as v };
538
538
 
539
- //# sourceMappingURL=sshForges-As7dbGXM.js.map
539
+ //# sourceMappingURL=sshForges-Cqt3qfWe.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sshForges-As7dbGXM.js","names":[],"sources":["../../../core/src/sshsig.ts","../../../browser/src/proofs/oidc/providers.ts","../../../browser/src/proofs/pubkyRelays.ts","../../../browser/src/proofs/sshForges.ts"],"sourcesContent":["import { ed25519 } from '@noble/curves/ed25519.js';\nimport { p256, p384, p521 } from '@noble/curves/nist.js';\nimport { sha256, sha512 } from '@noble/hashes/sha2.js';\nimport { bytesEqual, concatBytes, fromBase64, toBase64, utf8Decode, utf8Encode } from './bytes';\n\n/** OpenSSH signatures over a Ghostly statement (`ssh-keygen -Y sign -n ghostly`),\n * following PROTOCOL.sshsig. Everything here is local: parsing, the public key\n * the signature names and the signature itself. Which key a person *should*\n * have signed with is the caller's question (an expected fingerprint, or a\n * key list published by a forge; see the browser proof provider). */\n\nexport const SSHSIG_NAMESPACE = 'ghostly';\n/** A pasted armored signature: an 8192-bit RSA key plus its signature is ~3 KB. */\nexport const SSHSIG_MAX_ARMOR = 6144;\n/** A pasted `.pub` line; comments are dropped. */\nexport const SSH_PUBLIC_KEY_MAX = 4096;\nconst RSA_MIN_BITS = 2048;\nconst RSA_MAX_BITS = 8192;\nconst SK_APPLICATION_MAX = 256;\nconst SK_USER_PRESENT = 0x01;\nconst SK_USER_VERIFIED = 0x04;\n\nexport type SshKeyType =\n | 'ssh-ed25519' | 'ecdsa-sha2-nistp256' | 'ecdsa-sha2-nistp384' | 'ecdsa-sha2-nistp521' | 'ssh-rsa'\n | 'sk-ssh-ed25519@openssh.com' | 'sk-ecdsa-sha2-nistp256@openssh.com';\nexport const SSH_KEY_TYPES: readonly SshKeyType[] = ['ssh-ed25519', 'ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp384', 'ecdsa-sha2-nistp521',\n 'ssh-rsa', 'sk-ssh-ed25519@openssh.com', 'sk-ecdsa-sha2-nistp256@openssh.com'];\n\nexport interface SshPublicKey {\n type: SshKeyType;\n /** The wire-format key blob, which is what fingerprints and forge key lists name. */\n blob: Uint8Array;\n /** `SHA256:` + unpadded base64, exactly as `ssh-keygen -l` prints it. */\n fingerprint: string;\n /** `type base64`, the form `.pub` files and forge key lists use (no comment). */\n line: string;\n /** Security keys only: the FIDO application, `ssh:` unless chosen at creation. */\n application?: string;\n /** RSA modulus size. */\n bits?: number;\n}\nexport interface SshSignatureCheck {\n key: SshPublicKey;\n hashAlgorithm: 'sha256' | 'sha512';\n /** Security keys only: what the authenticator asserted for this signature. */\n securityKey?: { userPresent: boolean; userVerified: boolean; counter: number };\n}\n\nexport class SshSigError extends Error {}\nconst fail = (message: string): never => { throw new SshSigError(message); };\n\nclass Reader {\n private at = 0;\n constructor(private bytes: Uint8Array) {}\n get done() { return this.at === this.bytes.length; }\n raw(n: number): Uint8Array {\n if (n > this.bytes.length - this.at) fail('Truncated SSH data');\n return this.bytes.subarray(this.at, this.at += n);\n }\n u8(): number { return this.raw(1)[0]; }\n u32(): number { const b = this.raw(4); return ((b[0] << 24) >>> 0) + (b[1] << 16) + (b[2] << 8) + b[3]; }\n string(max = this.bytes.length): Uint8Array {\n const n = this.u32();\n if (n > max) fail('SSH field too long');\n return this.raw(n);\n }\n text(max: number): string {\n const b = this.string(max);\n if (!b.every(c => c >= 0x20 && c < 0x7f)) fail('SSH name is not printable ASCII');\n return utf8Decode(b);\n }\n /** Positive mpint in canonical form: no redundant leading zero, sign bit clear. */\n mpint(maxBytes: number): Uint8Array {\n const b = this.string(maxBytes + 1);\n if (!b.length || b[0] & 0x80 || (b[0] === 0 && (b.length === 1 || !(b[1] & 0x80)))) fail('Non-canonical SSH integer');\n return b[0] === 0 ? b.subarray(1) : b;\n }\n end() { if (!this.done) fail('Trailing bytes in SSH data'); }\n}\nconst u32 = (n: number) => Uint8Array.of(n >>> 24, (n >>> 16) & 255, (n >>> 8) & 255, n & 255);\nconst sshString = (b: Uint8Array) => concatBytes(u32(b.length), b);\n\nfunction strictBase64(text: string, max: number): Uint8Array {\n if (text.length > max || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(text)) fail('Invalid base64');\n const bytes = fromBase64(text);\n if (toBase64(bytes) !== text) fail('Non-canonical base64');\n return bytes;\n}\nexport function sshFingerprint(blob: Uint8Array): string {\n return `SHA256:${toBase64(sha256(blob)).replace(/=+$/, '')}`;\n}\n\ninterface CurveInfo { name: string; curve: typeof p256 | typeof p384 | typeof p521; size: number }\nconst CURVES: Record<string, CurveInfo> = {\n 'ecdsa-sha2-nistp256': { name: 'nistp256', curve: p256, size: 32 },\n 'ecdsa-sha2-nistp384': { name: 'nistp384', curve: p384, size: 48 },\n 'ecdsa-sha2-nistp521': { name: 'nistp521', curve: p521, size: 66 },\n 'sk-ecdsa-sha2-nistp256@openssh.com': { name: 'nistp256', curve: p256, size: 32 },\n};\ninterface ParsedKey extends SshPublicKey { point?: Uint8Array; rsa?: { n: Uint8Array; e: Uint8Array } }\n\nfunction parseKeyBlob(blob: Uint8Array): ParsedKey {\n if (blob.length > 1100) fail('SSH public key too large');\n const r = new Reader(blob);\n const type = r.text(64) as SshKeyType;\n // Named only when it is DSA, a type older OpenSSH made: any other type is words the key's owner chose.\n if (!SSH_KEY_TYPES.includes(type)) fail(`Unsupported SSH key type${(type as string) === 'ssh-dss' ? ' \"ssh-dss\"' : ''}`);\n const key: ParsedKey = { type, blob, fingerprint: sshFingerprint(blob), line: `${type} ${toBase64(blob)}` };\n if (type === 'ssh-ed25519' || type === 'sk-ssh-ed25519@openssh.com') {\n key.point = r.string(32);\n if (key.point.length !== 32) fail('Invalid Ed25519 public key');\n try { ed25519.Point.fromBytes(key.point, false).assertValidity(); } catch { fail('Invalid Ed25519 public key'); }\n } else if (type === 'ssh-rsa') {\n const e = r.mpint(8), n = r.mpint(RSA_MAX_BITS / 8);\n const bits = (n.length - 1) * 8 + (32 - Math.clz32(n[0]));\n if (bits < RSA_MIN_BITS || bits > RSA_MAX_BITS) fail(`RSA keys must be ${RSA_MIN_BITS}-${RSA_MAX_BITS} bits`);\n if (!(e[e.length - 1] & 1) || (e.length === 1 && e[0] < 3)) fail('Invalid RSA exponent');\n key.rsa = { n, e }; key.bits = bits;\n } else {\n const info = CURVES[type];\n if (r.text(16) !== info.name) fail('ECDSA curve does not match the key type');\n key.point = r.string(1 + 2 * info.size);\n if (key.point.length !== 1 + 2 * info.size || key.point[0] !== 4) fail('Invalid ECDSA public key');\n try { info.curve.Point.fromBytes(key.point).assertValidity(); } catch { fail('Invalid ECDSA public key'); }\n }\n if (type.startsWith('sk-')) key.application = r.text(SK_APPLICATION_MAX);\n r.end();\n return key;\n}\n\n/** Parses one `.pub` style line (`type base64 [comment]`). */\nexport function parseSshPublicKey(line: string): SshPublicKey {\n if (typeof line !== 'string' || line.length > SSH_PUBLIC_KEY_MAX) fail('SSH public key too long');\n // Trimmed first: a pattern that ends in `[^\\n]*\\s*` tries every split of a run of spaces between the two.\n const m = /^(\\S+)\\s+(\\S+)(?:\\s[^\\n]*)?$/.exec(line.trim());\n if (!m) fail('Paste one SSH public key line (the contents of a .pub file)');\n const key = parseKeyBlob(strictBase64(m![2], SSH_PUBLIC_KEY_MAX));\n if (key.type !== m![1]) fail('SSH key type does not match its data');\n return publicView(key);\n}\nconst publicView = ({ type, blob, fingerprint, line, application, bits }: ParsedKey): SshPublicKey =>\n ({ type, blob, fingerprint, line, ...(application !== undefined ? { application } : {}), ...(bits ? { bits } : {}) });\n\ninterface ParsedSignature { key: ParsedKey; namespace: string; hashAlgorithm: 'sha256' | 'sha512'; signature: Uint8Array }\n\n/** Unwraps `-----BEGIN SSH SIGNATURE-----` armor and the SSHSIG envelope, without verifying. */\nexport function parseSshSignature(armored: string): ParsedSignature {\n if (typeof armored !== 'string' || armored.length > SSHSIG_MAX_ARMOR) fail('SSH signature too long');\n const lines = armored.replace(/\\r\\n/g, '\\n').trim().split('\\n').map(l => l.trim());\n if (lines.length < 3 || lines[0] !== '-----BEGIN SSH SIGNATURE-----' || lines[lines.length - 1] !== '-----END SSH SIGNATURE-----')\n fail('Paste the whole signature, from -----BEGIN SSH SIGNATURE----- to -----END SSH SIGNATURE-----');\n const r = new Reader(strictBase64(lines.slice(1, -1).join(''), SSHSIG_MAX_ARMOR));\n if (!bytesEqual(r.raw(6), utf8Encode('SSHSIG'))) fail('Not an SSH signature');\n if (r.u32() !== 1) fail('Unsupported SSH signature version');\n const key = parseKeyBlob(r.string(1100));\n const namespace = r.text(64);\n if (r.string(64).length) fail('Unsupported SSH signature extension');\n const hashAlgorithm = r.text(16) as ParsedSignature['hashAlgorithm'];\n if (hashAlgorithm !== 'sha256' && hashAlgorithm !== 'sha512') fail('SSH signature hash must be sha256 or sha512');\n const signature = r.string(1200);\n r.end();\n return { key, namespace, hashAlgorithm, signature };\n}\n\nasync function verifyRsa(key: ParsedKey, hash: 'SHA-256' | 'SHA-512', sig: Uint8Array, data: Uint8Array): Promise<boolean> {\n const n = key.rsa!.n, size = n.length;\n if (sig.length > size) return false;\n const padded = new Uint8Array(size); padded.set(sig, size - sig.length);\n const b64u = (b: Uint8Array) => toBase64(b).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '');\n const cryptoKey = await crypto.subtle.importKey('jwk', { kty: 'RSA', n: b64u(n), e: b64u(key.rsa!.e), ext: true },\n { name: 'RSASSA-PKCS1-v1_5', hash }, false, ['verify']);\n return crypto.subtle.verify('RSASSA-PKCS1-v1_5', cryptoKey, padded, new Uint8Array(data));\n}\n\nfunction ecdsaSignature(blob: Uint8Array, size: number): Uint8Array {\n const r = new Reader(blob);\n const a = r.mpint(size), b = r.mpint(size);\n r.end();\n const out = new Uint8Array(2 * size);\n out.set(a, size - a.length); out.set(b, 2 * size - b.length);\n return out;\n}\n\n/** Verifies an armored SSHSIG over `message` in `namespace` and returns the key that\n * made it. Throws SshSigError for anything malformed, mismatched or unverifiable.\n * Security-key signatures must assert user presence (a touch) unless explicitly\n * allowed otherwise, matching OpenSSH's default for keys created without\n * `no-touch-required`. */\nexport async function verifySshSignature(armored: string, message: Uint8Array | string, options: { namespace?: string; allowNoTouch?: boolean } = {}): Promise<SshSignatureCheck> {\n const parsed = parseSshSignature(armored);\n const namespace = options.namespace ?? SSHSIG_NAMESPACE;\n // Never the signature's own namespace: the reason is shown on the checking side, and the signer chose those words.\n if (parsed.namespace !== namespace) fail(`Signed for another namespace, not ${JSON.stringify(namespace)}. Use -n ${namespace}.`);\n const bytes = typeof message === 'string' ? utf8Encode(message) : message;\n const digest = parsed.hashAlgorithm === 'sha512' ? sha512(bytes) : sha256(bytes);\n const signed = concatBytes(utf8Encode('SSHSIG'), sshString(utf8Encode(parsed.namespace)), sshString(new Uint8Array()),\n sshString(utf8Encode(parsed.hashAlgorithm)), sshString(digest));\n const { key } = parsed;\n const r = new Reader(parsed.signature);\n const algorithm = r.text(64);\n const blob = r.string(RSA_MAX_BITS / 8);\n let securityKey: SshSignatureCheck['securityKey'];\n let data = signed;\n if (key.type.startsWith('sk-')) {\n const flags = r.u8(), counter = r.u32();\n securityKey = { userPresent: !!(flags & SK_USER_PRESENT), userVerified: !!(flags & SK_USER_VERIFIED), counter };\n data = concatBytes(sha256(utf8Encode(key.application!)), Uint8Array.of(flags), u32(counter), sha256(signed));\n }\n r.end();\n const verifyWith = async (): Promise<boolean> => {\n if (key.type === 'ssh-rsa') {\n if (algorithm !== 'rsa-sha2-512' && algorithm !== 'rsa-sha2-256') fail('RSA signatures must use rsa-sha2-256 or rsa-sha2-512');\n return verifyRsa(key, algorithm === 'rsa-sha2-512' ? 'SHA-512' : 'SHA-256', blob, data);\n }\n if (algorithm !== key.type) fail('Signature algorithm does not match the key');\n if (key.type === 'ssh-ed25519' || key.type === 'sk-ssh-ed25519@openssh.com')\n return blob.length === 64 && ed25519.verify(blob, data, key.point!, { zip215: false });\n const info = CURVES[key.type];\n return info.curve.verify(ecdsaSignature(blob, info.size), data, key.point!, { lowS: false, prehash: true });\n };\n let ok: boolean;\n try { ok = await verifyWith(); } catch (e) { if (e instanceof SshSigError) throw e; ok = false; }\n if (!ok) fail('The signature does not match this statement');\n if (securityKey && !securityKey.userPresent && !options.allowNoTouch) fail('The security key did not confirm a touch for this signature');\n return { key: publicView(key), hashAlgorithm: parsed.hashAlgorithm, ...(securityKey ? { securityKey } : {}) };\n}\n\n/** Whether two keys are the same, comparing wire blobs (comments never matter). */\nexport const sameSshKey = (a: Pick<SshPublicKey, 'blob'>, b: Pick<SshPublicKey, 'blob'>) => bytesEqual(a.blob, b.blob);\n\n/** 32-byte digest of the key blob as lowercase hex: the fingerprint's bytes, in the\n * shape peer-proof external keys already use. */\nexport const sshKeyDigestHex = (key: Pick<SshPublicKey, 'blob'>) =>\n Array.from(sha256(key.blob), b => b.toString(16).padStart(2, '0')).join('');\n\n/** A POSIX shell one-liner that signs `statement` exactly (no trailing newline) and\n * prints the armored signature. Refuses anything that would need escaping, so what\n * is shown is what gets signed. */\nexport function sshSignCommand(statement: string, keyPath = '~/.ssh/id_ed25519'): string {\n if (/['\\\\\\n\\r]/.test(statement)) fail('Statement cannot be quoted for a shell');\n if (!/^[\\w~./@+-]{1,256}$/.test(keyPath)) fail('Use a plain key path without spaces or quotes');\n return `printf '%s' '${statement}' | ssh-keygen -Y sign -n ${SSHSIG_NAMESPACE} -f ${keyPath}`;\n}\n","/**\n * The OpenID Connect providers Ghostly can ask for a signed ID token. A contact\n * verifies that token against the provider's published keys, with no Ghostly\n * server in between, so a provider is only listed when its ID tokens are signed\n * and its keys and sign-in page are reachable from a browser without a client\n * secret. See docs/wisps/3xx-oidc-proofs.md for the providers that are not\n * (Facebook, X, LinkedIn, GitHub) and why.\n *\n * Client IDs are public configuration, identical in every build, because the\n * contact's app checks `aud` against them. They stay empty until the OAuth\n * clients are registered (docs/OIDC-PROVIDERS.md); a provider without a client\n * ID is neither offered nor accepted.\n */\n\nexport type OidcProviderId = 'google' | 'microsoft' | 'apple' | 'gitlab' | 'twitch' | 'test';\nexport type OidcAlg = 'RS256' | 'ES256';\nexport type OidcPlatform = 'web' | 'extension' | 'desktop';\n/** What the person chooses to put in the token beyond the account identifier. */\nexport type OidcReveal = 'email' | 'profile';\n\nexport interface OidcProvider {\n id: OidcProviderId;\n name: string;\n /** Exact `iss`. Microsoft's contains the tenant: see `issuerFor`. */\n issuer: string;\n /** Other spellings the provider documents for the same issuer. */\n issuerAliases?: string[];\n discovery: string;\n authorizationEndpoint: string;\n /** Pinned rather than discovered, so a changed discovery document cannot redirect key lookup. */\n jwksUri: string;\n /** Only for `code`: the token endpoint, reached with PKCE and no secret. */\n tokenEndpoint?: string;\n /** Best effort after a `code` exchange: the access token Ghostly never wanted is revoked at once. */\n revocationEndpoint?: string;\n /** Pinned per provider; the token header's `alg` must be one of these. */\n algs: OidcAlg[];\n /**\n * `id_token` returns only the signed ID token in the fragment: no access\n * token, no code, nothing to exchange, so no secret. `code id_token` is\n * Apple's shape (its code needs a secret; Ghostly drops it). `code` is for\n * providers without an ID-token-only response, exchanged with PKCE.\n */\n responseType: 'id_token' | 'code id_token' | 'code';\n /** Which extra claims this provider can add, and the scope (or claims request) for each. */\n reveal: Partial<Record<OidcReveal, { scope?: string; claims?: string[] }>>;\n /** What the provider puts in the token whatever the person picks. Shown before sign-in. */\n alwaysIncluded: string;\n /**\n * Claims the provider adds on its own for some accounts that say more than the account, each with the\n * choice that already shares as much. The signature covers the whole token, so such a claim cannot be\n * stripped: a token carrying one the person did not choose to share is turned down before it is used.\n */\n disclosing?: Record<string, OidcReveal>;\n /** Extra authorization parameters, e.g. an account chooser. */\n extraParams?: Record<string, string>;\n /** Client IDs per platform. Desktop signs in through the web callback page, so it uses the web client. */\n clientIds: Partial<Record<OidcPlatform, string>>;\n}\n\nexport const TEST_ISSUER = /^https:\\/\\/[a-z0-9-]+(\\.[a-z0-9-]+)*\\.test$/;\nconst MICROSOFT_TENANT = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;\n\nexport const OIDC_PROVIDERS: Record<Exclude<OidcProviderId, 'test'>, OidcProvider> = {\n google: {\n id: 'google', name: 'Google',\n issuer: 'https://accounts.google.com', issuerAliases: ['accounts.google.com'],\n discovery: 'https://accounts.google.com/.well-known/openid-configuration',\n authorizationEndpoint: 'https://accounts.google.com/o/oauth2/v2/auth',\n jwksUri: 'https://www.googleapis.com/oauth2/v3/certs',\n algs: ['RS256'], responseType: 'id_token',\n reveal: { email: { scope: 'email' }, profile: { scope: 'profile' } },\n alwaysIncluded: 'A Google account identifier. For a work or school account Google also adds its organisation’s domain, so one is only accepted with your email shared.',\n // `hd`: a Workspace or Cloud organisation account's domain, in every token Google signs for it.\n disclosing: { hd: 'email' },\n extraParams: { prompt: 'select_account' },\n clientIds: { web: '', extension: '' },\n },\n microsoft: {\n // `common` takes work, school and personal accounts; the issuer names the account's tenant.\n id: 'microsoft', name: 'Microsoft',\n issuer: 'https://login.microsoftonline.com/{tenantid}/v2.0',\n discovery: 'https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration',\n authorizationEndpoint: 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',\n jwksUri: 'https://login.microsoftonline.com/common/discovery/v2.0/keys',\n algs: ['RS256'], responseType: 'id_token',\n reveal: { email: { scope: 'email' }, profile: { scope: 'profile' } },\n alwaysIncluded: 'A Microsoft account identifier and the directory (tenant) the account belongs to.',\n extraParams: { prompt: 'select_account', response_mode: 'fragment' },\n clientIds: { web: '', extension: '' },\n },\n apple: {\n // Apple only returns the ID token in the fragment when no scope is asked\n // for; name and email need `form_post`, which a static page cannot read.\n id: 'apple', name: 'Apple',\n issuer: 'https://appleid.apple.com',\n discovery: 'https://appleid.apple.com/.well-known/openid-configuration',\n authorizationEndpoint: 'https://appleid.apple.com/auth/authorize',\n jwksUri: 'https://appleid.apple.com/auth/keys',\n algs: ['RS256'], responseType: 'code id_token',\n reveal: {},\n alwaysIncluded: 'An Apple ID identifier that only Ghostly sees. Apple cannot add your email here without a Ghostly server.',\n extraParams: { response_mode: 'fragment' },\n clientIds: { web: '', extension: '' },\n },\n gitlab: {\n id: 'gitlab', name: 'GitLab',\n issuer: 'https://gitlab.com',\n discovery: 'https://gitlab.com/.well-known/openid-configuration',\n authorizationEndpoint: 'https://gitlab.com/oauth/authorize',\n tokenEndpoint: 'https://gitlab.com/oauth/token',\n revocationEndpoint: 'https://gitlab.com/oauth/revoke',\n jwksUri: 'https://gitlab.com/oauth/discovery/keys',\n algs: ['RS256'], responseType: 'code',\n reveal: { email: { scope: 'email' }, profile: { scope: 'profile' } },\n alwaysIncluded: 'A GitLab.com user ID and the groups you belong to directly: GitLab adds them to every ID token.',\n clientIds: { web: '', extension: '' },\n },\n twitch: {\n // Twitch's email claim needs `user:read:email`, an API scope: not asked for.\n id: 'twitch', name: 'Twitch',\n issuer: 'https://id.twitch.tv/oauth2',\n discovery: 'https://id.twitch.tv/oauth2/.well-known/openid-configuration',\n authorizationEndpoint: 'https://id.twitch.tv/oauth2/authorize',\n jwksUri: 'https://id.twitch.tv/oauth2/keys',\n algs: ['RS256'], responseType: 'id_token',\n reveal: { profile: { claims: ['preferred_username'] } },\n alwaysIncluded: 'A Twitch user ID.',\n extraParams: { force_verify: 'true' },\n clientIds: { web: '', extension: '' },\n },\n};\n\n/**\n * The local issuer the e2e suite runs (e2e/support/oidcIssuer.ts). It exists\n * only in a build made with VITE_OIDC_TEST_ISSUER, and only on a `.test` host\n * (a name reserved for testing, never a real issuer); a release build has no\n * such provider, so a token from it is refused like any unknown issuer.\n */\nexport function testProvider(issuer: string): OidcProvider {\n if (!TEST_ISSUER.test(issuer)) throw new Error('A test issuer lives on a .test host');\n const base = issuer;\n return {\n id: 'test', name: 'Test issuer', issuer: base,\n discovery: `${base}/.well-known/openid-configuration`,\n authorizationEndpoint: `${base}/authorize`,\n jwksUri: `${base}/jwks`,\n algs: ['RS256', 'ES256'], responseType: 'id_token',\n reveal: { email: { scope: 'email' }, profile: { scope: 'profile' } },\n alwaysIncluded: 'A test account identifier.',\n clientIds: { web: 'ghostly-e2e', extension: 'ghostly-e2e', desktop: 'ghostly-e2e' },\n };\n}\n\nfunction configuredTestIssuer(): string | undefined {\n try {\n const value = import.meta.env?.VITE_OIDC_TEST_ISSUER as string | undefined;\n return value && TEST_ISSUER.test(value) ? value : undefined;\n } catch { return undefined; }\n}\n\n/** Every provider this build knows, configured or not. */\nexport function oidcProviders(testIssuer = configuredTestIssuer()): OidcProvider[] {\n return [...Object.values(OIDC_PROVIDERS), ...(testIssuer ? [testProvider(testIssuer)] : [])];\n}\n\nexport function oidcProvider(id: string, testIssuer = configuredTestIssuer()): OidcProvider | undefined {\n return oidcProviders(testIssuer).find(p => p.id === id);\n}\n\n/** Every client ID this provider has, on any platform: a contact may use another platform than the prover. */\nexport function audiences(provider: OidcProvider): string[] {\n return [...new Set(Object.values(provider.clientIds).filter((id): id is string => !!id))];\n}\n\nexport function clientIdFor(provider: OidcProvider, platform: OidcPlatform): string {\n return provider.clientIds[platform] || provider.clientIds.web || '';\n}\n\n/** A provider is offered only once its client ID for this platform exists. */\nexport function isConfigured(provider: OidcProvider, platform: OidcPlatform): boolean {\n return !!clientIdFor(provider, platform);\n}\n\n/** The exact issuer a token from this provider must carry, or undefined when its claims do not name one. */\nexport function issuerFor(provider: OidcProvider, claims: { tid?: unknown }): string[] {\n if (provider.id !== 'microsoft') return [provider.issuer, ...(provider.issuerAliases ?? [])];\n return typeof claims.tid === 'string' && MICROSOFT_TENANT.test(claims.tid) ? [provider.issuer.replace('{tenantid}', claims.tid)] : [];\n}\n\n/** The provider a proof's subject (an issuer, as `OidcProvider.issuer` spells it) names. */\nexport function providerForIssuer(issuer: string, list = oidcProviders()): OidcProvider | undefined {\n return list.find(p => p.issuer === issuer);\n}\n","/**\n * Pkarr relays a Pubky key's records are read from: Pubky's own, the ones the Pubky SDK uses. A module of its own so\n * that naming them (`fixedHosts.ts`) does not bring `./pubky` into the entry: the web app's install leaves that chunk\n * to its first use (`apps/web/src/sw/policy.ts`).\n */\nexport const PUBKY_RELAYS: readonly string[] = [\"https://pkarr.pubky.org\", \"https://pkarr.pubky.app\"];\n","import { IdentityCheckUnavailable, parseSshPublicKey, sameSshKey, type SshPublicKey } from '@ghostly/core';\nimport type { IdentityFetch } from './contract';\n\n/** \"This account publishes that key\", without OAuth: GitHub and GitLab publish every account's SSH\n * public keys, and only the account holder can add one. The verifier's own lookup, through the\n * engine's bounded `ctx.fetch`; it tells the forge (and the network) which account was checked. */\n\nexport type SshForge = 'github' | 'gitlab';\nexport const SSH_FORGE_LABEL: Record<SshForge, string> = { github: 'GitHub', gitlab: 'GitLab' };\n/** The only host each forge lookup contacts, for the privacy line. */\nexport const SSH_FORGE_HOST: Record<SshForge, string> = { github: 'api.github.com', gitlab: 'gitlab.com' };\n\nexport type SshForgeStatus = 'linked' | 'not-listed' | 'no-account';\n\nconst MAX_BODY = 256 * 1024;\nconst MAX_KEYS = 200;\n\nexport function validForgeLogin(forge: SshForge, login: string): boolean {\n if (typeof login !== 'string') return false;\n // GitHub: 1-39 alphanumerics or single inner hyphens. GitLab: letters, digits, _ . - ;\n // not starting with - and not ending in .git/.atom. Capped at 64 so it fits every label.\n return forge === 'github'\n ? /^[A-Za-z0-9](?:[A-Za-z0-9]|-(?=[A-Za-z0-9])){0,38}$/.test(login)\n : /^[A-Za-z0-9_.][A-Za-z0-9_.-]{0,63}$/.test(login) && !/\\.(?:git|atom)$/i.test(login);\n}\n\n/** A forge that could not be asked (not reached, limiting lookups, an error or a page that is not its API) is IdentityCheckUnavailable: it says nothing about the key. */\nasync function get(fetcher: IdentityFetch, url: string, signal?: AbortSignal): Promise<{ status: 404 } | { status: 200; body: unknown }> {\n const host = new URL(url).host;\n let response: Awaited<ReturnType<IdentityFetch>>;\n try { response = await fetcher(url, { maxBytes: MAX_BODY, signal }); }\n catch (e) { throw e instanceof IdentityCheckUnavailable ? e : new IdentityCheckUnavailable(`${host} could not be reached: ${e instanceof Error ? e.message : String(e)}`); }\n if (response.status === 404) return { status: 404 };\n if (response.status === 403 || response.status === 429) throw new IdentityCheckUnavailable(`${host} is limiting lookups; check again later`);\n if (response.status !== 200) throw new IdentityCheckUnavailable(`${host} answered HTTP ${response.status}`);\n try { return { status: 200, body: JSON.parse(response.text) }; } catch { throw new IdentityCheckUnavailable(`Unexpected answer from ${host}`); }\n}\n\nfunction keysFrom(body: unknown): SshPublicKey[] {\n if (!Array.isArray(body)) throw new Error('Unexpected key list');\n const keys: SshPublicKey[] = [];\n for (const entry of body.slice(0, MAX_KEYS)) {\n const line = (entry as { key?: unknown } | null)?.key;\n if (typeof line !== 'string') continue;\n try { keys.push(parseSshPublicKey(line)); } catch { /* A key type Ghostly cannot verify never matches. */ }\n }\n return keys;\n}\n\n/** The account's published keys, or null when there is no such account. */\nasync function listKeys(forge: SshForge, login: string, fetcher: IdentityFetch, signal?: AbortSignal): Promise<SshPublicKey[] | null> {\n if (forge === 'github') {\n const r = await get(fetcher, `https://api.github.com/users/${encodeURIComponent(login)}/keys?per_page=100`, signal);\n return r.status === 404 ? null : keysFrom(r.body);\n }\n const users = await get(fetcher, `https://gitlab.com/api/v4/users?username=${encodeURIComponent(login)}`, signal);\n const list = users.status === 200 && Array.isArray(users.body) ? users.body as { id?: unknown; username?: unknown }[] : [];\n const user = list.find(u => typeof u?.username === 'string' && u.username.toLowerCase() === login.toLowerCase());\n if (!user) return null;\n if (!Number.isSafeInteger(user.id) || (user.id as number) <= 0) throw new Error('Unexpected answer from gitlab.com');\n const r = await get(fetcher, `https://gitlab.com/api/v4/users/${user.id as number}/keys?per_page=100`, signal);\n return r.status === 404 ? null : keysFrom(r.body);\n}\n\n// Only concurrent identical lookups share a request. What stays checked is the verifier's stored\n// result, which the app offers to re-check once the provider's `recheck` time has passed.\nconst inFlight = new WeakMap<IdentityFetch, Map<string, Promise<SshPublicKey[] | null>>>();\n\n/** Whether `key` is one of `login`'s published SSH keys. Throws when the forge cannot be asked. */\nexport async function checkSshForge(forge: SshForge, login: string, key: Pick<SshPublicKey, 'blob'>, fetcher: IdentityFetch, signal?: AbortSignal): Promise<SshForgeStatus> {\n if (!validForgeLogin(forge, login)) throw new Error(`Not a ${SSH_FORGE_LABEL[forge]} username`);\n let pending = inFlight.get(fetcher);\n if (!pending) inFlight.set(fetcher, pending = new Map());\n const map = pending, id = `${forge}:${login.toLowerCase()}`;\n let lookup = map.get(id);\n if (!lookup) {\n lookup = listKeys(forge, login, fetcher, signal).finally(() => map.delete(id));\n map.set(id, lookup);\n }\n const keys = await lookup;\n if (!keys) return 'no-account';\n return keys.some(k => sameSshKey(k, key)) ? 'linked' : 'not-listed';\n}\n"],"mappings":";;;;;;;;;;;AAWA,IAAa,mBAAmB;;AAEhC,IAAa,mBAAmB;;AAEhC,IAAa,qBAAqB;AAClC,IAAM,eAAe;AACrB,IAAM,eAAe;AACrB,IAAM,qBAAqB;AAC3B,IAAM,kBAAkB;AACxB,IAAM,mBAAmB;AAKzB,IAAa,gBAAuC;CAAC;CAAe;CAAuB;CAAuB;CAChH;CAAW;CAA8B;AAAoC;AAsB/E,IAAa,cAAb,cAAiC,MAAM,CAAC;AACxC,IAAM,QAAQ,YAA2B;CAAE,MAAM,IAAI,YAAY,OAAO;AAAG;AAE3E,IAAM,SAAN,MAAa;CAES;CADpB,KAAa;CACb,YAAY,OAA2B;EAAnB,KAAA,QAAA;CAAoB;CACxC,IAAI,OAAO;EAAE,OAAO,KAAK,OAAO,KAAK,MAAM;CAAQ;CACnD,IAAI,GAAuB;EACzB,IAAI,IAAI,KAAK,MAAM,SAAS,KAAK,IAAI,KAAK,oBAAoB;EAC9D,OAAO,KAAK,MAAM,SAAS,KAAK,IAAI,KAAK,MAAM,CAAC;CAClD;CACA,KAAa;EAAE,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC;CAAI;CACtC,MAAc;EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;EAAG,QAAS,EAAE,MAAM,OAAQ,MAAM,EAAE,MAAM,OAAO,EAAE,MAAM,KAAK,EAAE;CAAI;CACxG,OAAO,MAAM,KAAK,MAAM,QAAoB;EAC1C,MAAM,IAAI,KAAK,IAAI;EACnB,IAAI,IAAI,KAAK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I,CAAC,gBAAgB,OAAO,KAAK,GAAG,MAAM,IAAI,MAAM,SAAS,gBAAgB,OAAO,UAAU;CAC9F,IAAI,UAAU,SAAS,IAAI,OAAO;CAClC,IAAI,CAAC,SAAS,SAAS,IAAI,SAAS,0BAAU,IAAI,IAAI,CAAC;CACvD,MAAM,MAAM,SAAS,KAAK,GAAG,MAAM,GAAG,MAAM,YAAY;CACxD,IAAI,SAAS,IAAI,IAAI,EAAE;CACvB,IAAI,CAAC,QAAQ;EACX,SAAS,SAAS,OAAO,OAAO,SAAS,MAAM,CAAC,CAAC,cAAc,IAAI,OAAO,EAAE,CAAC;EAC7E,IAAI,IAAI,IAAI,MAAM;CACpB;CACA,MAAM,OAAO,MAAM;CACnB,IAAI,CAAC,MAAM,OAAO;CAClB,OAAO,KAAK,MAAK,MAAK,WAAW,GAAG,GAAG,CAAC,IAAI,WAAW;AACzD"}
1
+ {"version":3,"file":"sshForges-Cqt3qfWe.js","names":[],"sources":["../../../core/src/sshsig.ts","../../../browser/src/proofs/oidc/providers.ts","../../../browser/src/proofs/pubkyRelays.ts","../../../browser/src/proofs/sshForges.ts"],"sourcesContent":["import { ed25519 } from '@noble/curves/ed25519.js';\nimport { p256, p384, p521 } from '@noble/curves/nist.js';\nimport { sha256, sha512 } from '@noble/hashes/sha2.js';\nimport { bytesEqual, concatBytes, fromBase64, toBase64, utf8Decode, utf8Encode } from './bytes';\n\n/** OpenSSH signatures over a Ghostly statement (`ssh-keygen -Y sign -n ghostly`),\n * following PROTOCOL.sshsig. Everything here is local: parsing, the public key\n * the signature names and the signature itself. Which key a person *should*\n * have signed with is the caller's question (an expected fingerprint, or a\n * key list published by a forge; see the browser proof provider). */\n\nexport const SSHSIG_NAMESPACE = 'ghostly';\n/** A pasted armored signature: an 8192-bit RSA key plus its signature is ~3 KB. */\nexport const SSHSIG_MAX_ARMOR = 6144;\n/** A pasted `.pub` line; comments are dropped. */\nexport const SSH_PUBLIC_KEY_MAX = 4096;\nconst RSA_MIN_BITS = 2048;\nconst RSA_MAX_BITS = 8192;\nconst SK_APPLICATION_MAX = 256;\nconst SK_USER_PRESENT = 0x01;\nconst SK_USER_VERIFIED = 0x04;\n\nexport type SshKeyType =\n | 'ssh-ed25519' | 'ecdsa-sha2-nistp256' | 'ecdsa-sha2-nistp384' | 'ecdsa-sha2-nistp521' | 'ssh-rsa'\n | 'sk-ssh-ed25519@openssh.com' | 'sk-ecdsa-sha2-nistp256@openssh.com';\nexport const SSH_KEY_TYPES: readonly SshKeyType[] = ['ssh-ed25519', 'ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp384', 'ecdsa-sha2-nistp521',\n 'ssh-rsa', 'sk-ssh-ed25519@openssh.com', 'sk-ecdsa-sha2-nistp256@openssh.com'];\n\nexport interface SshPublicKey {\n type: SshKeyType;\n /** The wire-format key blob, which is what fingerprints and forge key lists name. */\n blob: Uint8Array;\n /** `SHA256:` + unpadded base64, exactly as `ssh-keygen -l` prints it. */\n fingerprint: string;\n /** `type base64`, the form `.pub` files and forge key lists use (no comment). */\n line: string;\n /** Security keys only: the FIDO application, `ssh:` unless chosen at creation. */\n application?: string;\n /** RSA modulus size. */\n bits?: number;\n}\nexport interface SshSignatureCheck {\n key: SshPublicKey;\n hashAlgorithm: 'sha256' | 'sha512';\n /** Security keys only: what the authenticator asserted for this signature. */\n securityKey?: { userPresent: boolean; userVerified: boolean; counter: number };\n}\n\nexport class SshSigError extends Error {}\nconst fail = (message: string): never => { throw new SshSigError(message); };\n\nclass Reader {\n private at = 0;\n constructor(private bytes: Uint8Array) {}\n get done() { return this.at === this.bytes.length; }\n raw(n: number): Uint8Array {\n if (n > this.bytes.length - this.at) fail('Truncated SSH data');\n return this.bytes.subarray(this.at, this.at += n);\n }\n u8(): number { return this.raw(1)[0]; }\n u32(): number { const b = this.raw(4); return ((b[0] << 24) >>> 0) + (b[1] << 16) + (b[2] << 8) + b[3]; }\n string(max = this.bytes.length): Uint8Array {\n const n = this.u32();\n if (n > max) fail('SSH field too long');\n return this.raw(n);\n }\n text(max: number): string {\n const b = this.string(max);\n if (!b.every(c => c >= 0x20 && c < 0x7f)) fail('SSH name is not printable ASCII');\n return utf8Decode(b);\n }\n /** Positive mpint in canonical form: no redundant leading zero, sign bit clear. */\n mpint(maxBytes: number): Uint8Array {\n const b = this.string(maxBytes + 1);\n if (!b.length || b[0] & 0x80 || (b[0] === 0 && (b.length === 1 || !(b[1] & 0x80)))) fail('Non-canonical SSH integer');\n return b[0] === 0 ? b.subarray(1) : b;\n }\n end() { if (!this.done) fail('Trailing bytes in SSH data'); }\n}\nconst u32 = (n: number) => Uint8Array.of(n >>> 24, (n >>> 16) & 255, (n >>> 8) & 255, n & 255);\nconst sshString = (b: Uint8Array) => concatBytes(u32(b.length), b);\n\nfunction strictBase64(text: string, max: number): Uint8Array {\n if (text.length > max || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(text)) fail('Invalid base64');\n const bytes = fromBase64(text);\n if (toBase64(bytes) !== text) fail('Non-canonical base64');\n return bytes;\n}\nexport function sshFingerprint(blob: Uint8Array): string {\n return `SHA256:${toBase64(sha256(blob)).replace(/=+$/, '')}`;\n}\n\ninterface CurveInfo { name: string; curve: typeof p256 | typeof p384 | typeof p521; size: number }\nconst CURVES: Record<string, CurveInfo> = {\n 'ecdsa-sha2-nistp256': { name: 'nistp256', curve: p256, size: 32 },\n 'ecdsa-sha2-nistp384': { name: 'nistp384', curve: p384, size: 48 },\n 'ecdsa-sha2-nistp521': { name: 'nistp521', curve: p521, size: 66 },\n 'sk-ecdsa-sha2-nistp256@openssh.com': { name: 'nistp256', curve: p256, size: 32 },\n};\ninterface ParsedKey extends SshPublicKey { point?: Uint8Array; rsa?: { n: Uint8Array; e: Uint8Array } }\n\nfunction parseKeyBlob(blob: Uint8Array): ParsedKey {\n if (blob.length > 1100) fail('SSH public key too large');\n const r = new Reader(blob);\n const type = r.text(64) as SshKeyType;\n // Named only when it is DSA, a type older OpenSSH made: any other type is words the key's owner chose.\n if (!SSH_KEY_TYPES.includes(type)) fail(`Unsupported SSH key type${(type as string) === 'ssh-dss' ? ' \"ssh-dss\"' : ''}`);\n const key: ParsedKey = { type, blob, fingerprint: sshFingerprint(blob), line: `${type} ${toBase64(blob)}` };\n if (type === 'ssh-ed25519' || type === 'sk-ssh-ed25519@openssh.com') {\n key.point = r.string(32);\n if (key.point.length !== 32) fail('Invalid Ed25519 public key');\n try { ed25519.Point.fromBytes(key.point, false).assertValidity(); } catch { fail('Invalid Ed25519 public key'); }\n } else if (type === 'ssh-rsa') {\n const e = r.mpint(8), n = r.mpint(RSA_MAX_BITS / 8);\n const bits = (n.length - 1) * 8 + (32 - Math.clz32(n[0]));\n if (bits < RSA_MIN_BITS || bits > RSA_MAX_BITS) fail(`RSA keys must be ${RSA_MIN_BITS}-${RSA_MAX_BITS} bits`);\n if (!(e[e.length - 1] & 1) || (e.length === 1 && e[0] < 3)) fail('Invalid RSA exponent');\n key.rsa = { n, e }; key.bits = bits;\n } else {\n const info = CURVES[type];\n if (r.text(16) !== info.name) fail('ECDSA curve does not match the key type');\n key.point = r.string(1 + 2 * info.size);\n if (key.point.length !== 1 + 2 * info.size || key.point[0] !== 4) fail('Invalid ECDSA public key');\n try { info.curve.Point.fromBytes(key.point).assertValidity(); } catch { fail('Invalid ECDSA public key'); }\n }\n if (type.startsWith('sk-')) key.application = r.text(SK_APPLICATION_MAX);\n r.end();\n return key;\n}\n\n/** Parses one `.pub` style line (`type base64 [comment]`). */\nexport function parseSshPublicKey(line: string): SshPublicKey {\n if (typeof line !== 'string' || line.length > SSH_PUBLIC_KEY_MAX) fail('SSH public key too long');\n // Trimmed first: a pattern that ends in `[^\\n]*\\s*` tries every split of a run of spaces between the two.\n const m = /^(\\S+)\\s+(\\S+)(?:\\s[^\\n]*)?$/.exec(line.trim());\n if (!m) fail('Paste one SSH public key line (the contents of a .pub file)');\n const key = parseKeyBlob(strictBase64(m![2], SSH_PUBLIC_KEY_MAX));\n if (key.type !== m![1]) fail('SSH key type does not match its data');\n return publicView(key);\n}\nconst publicView = ({ type, blob, fingerprint, line, application, bits }: ParsedKey): SshPublicKey =>\n ({ type, blob, fingerprint, line, ...(application !== undefined ? { application } : {}), ...(bits ? { bits } : {}) });\n\ninterface ParsedSignature { key: ParsedKey; namespace: string; hashAlgorithm: 'sha256' | 'sha512'; signature: Uint8Array }\n\n/** Unwraps `-----BEGIN SSH SIGNATURE-----` armor and the SSHSIG envelope, without verifying. */\nexport function parseSshSignature(armored: string): ParsedSignature {\n if (typeof armored !== 'string' || armored.length > SSHSIG_MAX_ARMOR) fail('SSH signature too long');\n const lines = armored.replace(/\\r\\n/g, '\\n').trim().split('\\n').map(l => l.trim());\n if (lines.length < 3 || lines[0] !== '-----BEGIN SSH SIGNATURE-----' || lines[lines.length - 1] !== '-----END SSH SIGNATURE-----')\n fail('Paste the whole signature, from -----BEGIN SSH SIGNATURE----- to -----END SSH SIGNATURE-----');\n const r = new Reader(strictBase64(lines.slice(1, -1).join(''), SSHSIG_MAX_ARMOR));\n if (!bytesEqual(r.raw(6), utf8Encode('SSHSIG'))) fail('Not an SSH signature');\n if (r.u32() !== 1) fail('Unsupported SSH signature version');\n const key = parseKeyBlob(r.string(1100));\n const namespace = r.text(64);\n if (r.string(64).length) fail('Unsupported SSH signature extension');\n const hashAlgorithm = r.text(16) as ParsedSignature['hashAlgorithm'];\n if (hashAlgorithm !== 'sha256' && hashAlgorithm !== 'sha512') fail('SSH signature hash must be sha256 or sha512');\n const signature = r.string(1200);\n r.end();\n return { key, namespace, hashAlgorithm, signature };\n}\n\nasync function verifyRsa(key: ParsedKey, hash: 'SHA-256' | 'SHA-512', sig: Uint8Array, data: Uint8Array): Promise<boolean> {\n const n = key.rsa!.n, size = n.length;\n if (sig.length > size) return false;\n const padded = new Uint8Array(size); padded.set(sig, size - sig.length);\n const b64u = (b: Uint8Array) => toBase64(b).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '');\n const cryptoKey = await crypto.subtle.importKey('jwk', { kty: 'RSA', n: b64u(n), e: b64u(key.rsa!.e), ext: true },\n { name: 'RSASSA-PKCS1-v1_5', hash }, false, ['verify']);\n return crypto.subtle.verify('RSASSA-PKCS1-v1_5', cryptoKey, padded, new Uint8Array(data));\n}\n\nfunction ecdsaSignature(blob: Uint8Array, size: number): Uint8Array {\n const r = new Reader(blob);\n const a = r.mpint(size), b = r.mpint(size);\n r.end();\n const out = new Uint8Array(2 * size);\n out.set(a, size - a.length); out.set(b, 2 * size - b.length);\n return out;\n}\n\n/** Verifies an armored SSHSIG over `message` in `namespace` and returns the key that\n * made it. Throws SshSigError for anything malformed, mismatched or unverifiable.\n * Security-key signatures must assert user presence (a touch) unless explicitly\n * allowed otherwise, matching OpenSSH's default for keys created without\n * `no-touch-required`. */\nexport async function verifySshSignature(armored: string, message: Uint8Array | string, options: { namespace?: string; allowNoTouch?: boolean } = {}): Promise<SshSignatureCheck> {\n const parsed = parseSshSignature(armored);\n const namespace = options.namespace ?? SSHSIG_NAMESPACE;\n // Never the signature's own namespace: the reason is shown on the checking side, and the signer chose those words.\n if (parsed.namespace !== namespace) fail(`Signed for another namespace, not ${JSON.stringify(namespace)}. Use -n ${namespace}.`);\n const bytes = typeof message === 'string' ? utf8Encode(message) : message;\n const digest = parsed.hashAlgorithm === 'sha512' ? sha512(bytes) : sha256(bytes);\n const signed = concatBytes(utf8Encode('SSHSIG'), sshString(utf8Encode(parsed.namespace)), sshString(new Uint8Array()),\n sshString(utf8Encode(parsed.hashAlgorithm)), sshString(digest));\n const { key } = parsed;\n const r = new Reader(parsed.signature);\n const algorithm = r.text(64);\n const blob = r.string(RSA_MAX_BITS / 8);\n let securityKey: SshSignatureCheck['securityKey'];\n let data = signed;\n if (key.type.startsWith('sk-')) {\n const flags = r.u8(), counter = r.u32();\n securityKey = { userPresent: !!(flags & SK_USER_PRESENT), userVerified: !!(flags & SK_USER_VERIFIED), counter };\n data = concatBytes(sha256(utf8Encode(key.application!)), Uint8Array.of(flags), u32(counter), sha256(signed));\n }\n r.end();\n const verifyWith = async (): Promise<boolean> => {\n if (key.type === 'ssh-rsa') {\n if (algorithm !== 'rsa-sha2-512' && algorithm !== 'rsa-sha2-256') fail('RSA signatures must use rsa-sha2-256 or rsa-sha2-512');\n return verifyRsa(key, algorithm === 'rsa-sha2-512' ? 'SHA-512' : 'SHA-256', blob, data);\n }\n if (algorithm !== key.type) fail('Signature algorithm does not match the key');\n if (key.type === 'ssh-ed25519' || key.type === 'sk-ssh-ed25519@openssh.com')\n return blob.length === 64 && ed25519.verify(blob, data, key.point!, { zip215: false });\n const info = CURVES[key.type];\n return info.curve.verify(ecdsaSignature(blob, info.size), data, key.point!, { lowS: false, prehash: true });\n };\n let ok: boolean;\n try { ok = await verifyWith(); } catch (e) { if (e instanceof SshSigError) throw e; ok = false; }\n if (!ok) fail('The signature does not match this statement');\n if (securityKey && !securityKey.userPresent && !options.allowNoTouch) fail('The security key did not confirm a touch for this signature');\n return { key: publicView(key), hashAlgorithm: parsed.hashAlgorithm, ...(securityKey ? { securityKey } : {}) };\n}\n\n/** Whether two keys are the same, comparing wire blobs (comments never matter). */\nexport const sameSshKey = (a: Pick<SshPublicKey, 'blob'>, b: Pick<SshPublicKey, 'blob'>) => bytesEqual(a.blob, b.blob);\n\n/** 32-byte digest of the key blob as lowercase hex: the fingerprint's bytes, in the\n * shape peer-proof external keys already use. */\nexport const sshKeyDigestHex = (key: Pick<SshPublicKey, 'blob'>) =>\n Array.from(sha256(key.blob), b => b.toString(16).padStart(2, '0')).join('');\n\n/** A POSIX shell one-liner that signs `statement` exactly (no trailing newline) and\n * prints the armored signature. Refuses anything that would need escaping, so what\n * is shown is what gets signed. */\nexport function sshSignCommand(statement: string, keyPath = '~/.ssh/id_ed25519'): string {\n if (/['\\\\\\n\\r]/.test(statement)) fail('Statement cannot be quoted for a shell');\n if (!/^[\\w~./@+-]{1,256}$/.test(keyPath)) fail('Use a plain key path without spaces or quotes');\n return `printf '%s' '${statement}' | ssh-keygen -Y sign -n ${SSHSIG_NAMESPACE} -f ${keyPath}`;\n}\n","/**\n * The OpenID Connect providers Ghostly can ask for a signed ID token. A contact\n * verifies that token against the provider's published keys, with no Ghostly\n * server in between, so a provider is only listed when its ID tokens are signed\n * and its keys and sign-in page are reachable from a browser without a client\n * secret. See docs/wisps/3xx-oidc-proofs.md for the providers that are not\n * (Facebook, X, LinkedIn, GitHub) and why.\n *\n * Client IDs are public configuration, identical in every build, because the\n * contact's app checks `aud` against them. They stay empty until the OAuth\n * clients are registered (docs/OIDC-PROVIDERS.md); a provider without a client\n * ID is neither offered nor accepted.\n */\n\nexport type OidcProviderId = 'google' | 'microsoft' | 'apple' | 'gitlab' | 'twitch' | 'test';\nexport type OidcAlg = 'RS256' | 'ES256';\nexport type OidcPlatform = 'web' | 'extension' | 'desktop';\n/** What the person chooses to put in the token beyond the account identifier. */\nexport type OidcReveal = 'email' | 'profile';\n\nexport interface OidcProvider {\n id: OidcProviderId;\n name: string;\n /** Exact `iss`. Microsoft's contains the tenant: see `issuerFor`. */\n issuer: string;\n /** Other spellings the provider documents for the same issuer. */\n issuerAliases?: string[];\n discovery: string;\n authorizationEndpoint: string;\n /** Pinned rather than discovered, so a changed discovery document cannot redirect key lookup. */\n jwksUri: string;\n /** Only for `code`: the token endpoint, reached with PKCE and no secret. */\n tokenEndpoint?: string;\n /** Best effort after a `code` exchange: the access token Ghostly never wanted is revoked at once. */\n revocationEndpoint?: string;\n /** Pinned per provider; the token header's `alg` must be one of these. */\n algs: OidcAlg[];\n /**\n * `id_token` returns only the signed ID token in the fragment: no access\n * token, no code, nothing to exchange, so no secret. `code id_token` is\n * Apple's shape (its code needs a secret; Ghostly drops it). `code` is for\n * providers without an ID-token-only response, exchanged with PKCE.\n */\n responseType: 'id_token' | 'code id_token' | 'code';\n /** Which extra claims this provider can add, and the scope (or claims request) for each. */\n reveal: Partial<Record<OidcReveal, { scope?: string; claims?: string[] }>>;\n /** What the provider puts in the token whatever the person picks. Shown before sign-in. */\n alwaysIncluded: string;\n /**\n * Claims the provider adds on its own for some accounts that say more than the account, each with the\n * choice that already shares as much. The signature covers the whole token, so such a claim cannot be\n * stripped: a token carrying one the person did not choose to share is turned down before it is used.\n */\n disclosing?: Record<string, OidcReveal>;\n /** Extra authorization parameters, e.g. an account chooser. */\n extraParams?: Record<string, string>;\n /** Client IDs per platform. Desktop signs in through the web callback page, so it uses the web client. */\n clientIds: Partial<Record<OidcPlatform, string>>;\n}\n\nexport const TEST_ISSUER = /^https:\\/\\/[a-z0-9-]+(\\.[a-z0-9-]+)*\\.test$/;\nconst MICROSOFT_TENANT = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;\n\nexport const OIDC_PROVIDERS: Record<Exclude<OidcProviderId, 'test'>, OidcProvider> = {\n google: {\n id: 'google', name: 'Google',\n issuer: 'https://accounts.google.com', issuerAliases: ['accounts.google.com'],\n discovery: 'https://accounts.google.com/.well-known/openid-configuration',\n authorizationEndpoint: 'https://accounts.google.com/o/oauth2/v2/auth',\n jwksUri: 'https://www.googleapis.com/oauth2/v3/certs',\n algs: ['RS256'], responseType: 'id_token',\n reveal: { email: { scope: 'email' }, profile: { scope: 'profile' } },\n alwaysIncluded: 'A Google account identifier. For a work or school account Google also adds its organisation’s domain, so one is only accepted with your email shared.',\n // `hd`: a Workspace or Cloud organisation account's domain, in every token Google signs for it.\n disclosing: { hd: 'email' },\n extraParams: { prompt: 'select_account' },\n clientIds: { web: '', extension: '' },\n },\n microsoft: {\n // `common` takes work, school and personal accounts; the issuer names the account's tenant.\n id: 'microsoft', name: 'Microsoft',\n issuer: 'https://login.microsoftonline.com/{tenantid}/v2.0',\n discovery: 'https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration',\n authorizationEndpoint: 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',\n jwksUri: 'https://login.microsoftonline.com/common/discovery/v2.0/keys',\n algs: ['RS256'], responseType: 'id_token',\n reveal: { email: { scope: 'email' }, profile: { scope: 'profile' } },\n alwaysIncluded: 'A Microsoft account identifier and the directory (tenant) the account belongs to.',\n extraParams: { prompt: 'select_account', response_mode: 'fragment' },\n clientIds: { web: '', extension: '' },\n },\n apple: {\n // Apple only returns the ID token in the fragment when no scope is asked\n // for; name and email need `form_post`, which a static page cannot read.\n id: 'apple', name: 'Apple',\n issuer: 'https://appleid.apple.com',\n discovery: 'https://appleid.apple.com/.well-known/openid-configuration',\n authorizationEndpoint: 'https://appleid.apple.com/auth/authorize',\n jwksUri: 'https://appleid.apple.com/auth/keys',\n algs: ['RS256'], responseType: 'code id_token',\n reveal: {},\n alwaysIncluded: 'An Apple ID identifier that only Ghostly sees. Apple cannot add your email here without a Ghostly server.',\n extraParams: { response_mode: 'fragment' },\n clientIds: { web: '', extension: '' },\n },\n gitlab: {\n id: 'gitlab', name: 'GitLab',\n issuer: 'https://gitlab.com',\n discovery: 'https://gitlab.com/.well-known/openid-configuration',\n authorizationEndpoint: 'https://gitlab.com/oauth/authorize',\n tokenEndpoint: 'https://gitlab.com/oauth/token',\n revocationEndpoint: 'https://gitlab.com/oauth/revoke',\n jwksUri: 'https://gitlab.com/oauth/discovery/keys',\n algs: ['RS256'], responseType: 'code',\n reveal: { email: { scope: 'email' }, profile: { scope: 'profile' } },\n alwaysIncluded: 'A GitLab.com user ID and the groups you belong to directly: GitLab adds them to every ID token.',\n clientIds: { web: '', extension: '' },\n },\n twitch: {\n // Twitch's email claim needs `user:read:email`, an API scope: not asked for.\n id: 'twitch', name: 'Twitch',\n issuer: 'https://id.twitch.tv/oauth2',\n discovery: 'https://id.twitch.tv/oauth2/.well-known/openid-configuration',\n authorizationEndpoint: 'https://id.twitch.tv/oauth2/authorize',\n jwksUri: 'https://id.twitch.tv/oauth2/keys',\n algs: ['RS256'], responseType: 'id_token',\n reveal: { profile: { claims: ['preferred_username'] } },\n alwaysIncluded: 'A Twitch user ID.',\n extraParams: { force_verify: 'true' },\n clientIds: { web: '', extension: '' },\n },\n};\n\n/**\n * The local issuer the e2e suite runs (e2e/support/oidcIssuer.ts). It exists\n * only in a build made with VITE_OIDC_TEST_ISSUER, and only on a `.test` host\n * (a name reserved for testing, never a real issuer); a release build has no\n * such provider, so a token from it is refused like any unknown issuer.\n */\nexport function testProvider(issuer: string): OidcProvider {\n if (!TEST_ISSUER.test(issuer)) throw new Error('A test issuer lives on a .test host');\n const base = issuer;\n return {\n id: 'test', name: 'Test issuer', issuer: base,\n discovery: `${base}/.well-known/openid-configuration`,\n authorizationEndpoint: `${base}/authorize`,\n jwksUri: `${base}/jwks`,\n algs: ['RS256', 'ES256'], responseType: 'id_token',\n reveal: { email: { scope: 'email' }, profile: { scope: 'profile' } },\n alwaysIncluded: 'A test account identifier.',\n clientIds: { web: 'ghostly-e2e', extension: 'ghostly-e2e', desktop: 'ghostly-e2e' },\n };\n}\n\nfunction configuredTestIssuer(): string | undefined {\n try {\n const value = import.meta.env?.VITE_OIDC_TEST_ISSUER as string | undefined;\n return value && TEST_ISSUER.test(value) ? value : undefined;\n } catch { return undefined; }\n}\n\n/** Every provider this build knows, configured or not. */\nexport function oidcProviders(testIssuer = configuredTestIssuer()): OidcProvider[] {\n return [...Object.values(OIDC_PROVIDERS), ...(testIssuer ? [testProvider(testIssuer)] : [])];\n}\n\nexport function oidcProvider(id: string, testIssuer = configuredTestIssuer()): OidcProvider | undefined {\n return oidcProviders(testIssuer).find(p => p.id === id);\n}\n\n/** Every client ID this provider has, on any platform: a contact may use another platform than the prover. */\nexport function audiences(provider: OidcProvider): string[] {\n return [...new Set(Object.values(provider.clientIds).filter((id): id is string => !!id))];\n}\n\nexport function clientIdFor(provider: OidcProvider, platform: OidcPlatform): string {\n return provider.clientIds[platform] || provider.clientIds.web || '';\n}\n\n/** A provider is offered only once its client ID for this platform exists. */\nexport function isConfigured(provider: OidcProvider, platform: OidcPlatform): boolean {\n return !!clientIdFor(provider, platform);\n}\n\n/** The exact issuer a token from this provider must carry, or undefined when its claims do not name one. */\nexport function issuerFor(provider: OidcProvider, claims: { tid?: unknown }): string[] {\n if (provider.id !== 'microsoft') return [provider.issuer, ...(provider.issuerAliases ?? [])];\n return typeof claims.tid === 'string' && MICROSOFT_TENANT.test(claims.tid) ? [provider.issuer.replace('{tenantid}', claims.tid)] : [];\n}\n\n/** The provider a proof's subject (an issuer, as `OidcProvider.issuer` spells it) names. */\nexport function providerForIssuer(issuer: string, list = oidcProviders()): OidcProvider | undefined {\n return list.find(p => p.issuer === issuer);\n}\n","/**\n * Pkarr relays a Pubky key's records are read from: Pubky's own, the ones the Pubky SDK uses. A module of its own so\n * that naming them (`fixedHosts.ts`) does not bring `./pubky` into the entry: the web app's install leaves that chunk\n * to its first use (`apps/web/src/sw/policy.ts`).\n */\nexport const PUBKY_RELAYS: readonly string[] = [\"https://pkarr.pubky.org\", \"https://pkarr.pubky.app\"];\n","import { IdentityCheckUnavailable, parseSshPublicKey, sameSshKey, type SshPublicKey } from '@ghostly/core';\nimport type { IdentityFetch } from './contract';\n\n/** \"This account publishes that key\", without OAuth: GitHub and GitLab publish every account's SSH\n * public keys, and only the account holder can add one. The verifier's own lookup, through the\n * engine's bounded `ctx.fetch`; it tells the forge (and the network) which account was checked. */\n\nexport type SshForge = 'github' | 'gitlab';\nexport const SSH_FORGE_LABEL: Record<SshForge, string> = { github: 'GitHub', gitlab: 'GitLab' };\n/** The only host each forge lookup contacts, for the privacy line. */\nexport const SSH_FORGE_HOST: Record<SshForge, string> = { github: 'api.github.com', gitlab: 'gitlab.com' };\n\nexport type SshForgeStatus = 'linked' | 'not-listed' | 'no-account';\n\nconst MAX_BODY = 256 * 1024;\nconst MAX_KEYS = 200;\n\nexport function validForgeLogin(forge: SshForge, login: string): boolean {\n if (typeof login !== 'string') return false;\n // GitHub: 1-39 alphanumerics or single inner hyphens. GitLab: letters, digits, _ . - ;\n // not starting with - and not ending in .git/.atom. Capped at 64 so it fits every label.\n return forge === 'github'\n ? /^[A-Za-z0-9](?:[A-Za-z0-9]|-(?=[A-Za-z0-9])){0,38}$/.test(login)\n : /^[A-Za-z0-9_.][A-Za-z0-9_.-]{0,63}$/.test(login) && !/\\.(?:git|atom)$/i.test(login);\n}\n\n/** A forge that could not be asked (not reached, limiting lookups, an error or a page that is not its API) is IdentityCheckUnavailable: it says nothing about the key. */\nasync function get(fetcher: IdentityFetch, url: string, signal?: AbortSignal): Promise<{ status: 404 } | { status: 200; body: unknown }> {\n const host = new URL(url).host;\n let response: Awaited<ReturnType<IdentityFetch>>;\n try { response = await fetcher(url, { maxBytes: MAX_BODY, signal }); }\n catch (e) { throw e instanceof IdentityCheckUnavailable ? e : new IdentityCheckUnavailable(`${host} could not be reached: ${e instanceof Error ? e.message : String(e)}`); }\n if (response.status === 404) return { status: 404 };\n if (response.status === 403 || response.status === 429) throw new IdentityCheckUnavailable(`${host} is limiting lookups; check again later`);\n if (response.status !== 200) throw new IdentityCheckUnavailable(`${host} answered HTTP ${response.status}`);\n try { return { status: 200, body: JSON.parse(response.text) }; } catch { throw new IdentityCheckUnavailable(`Unexpected answer from ${host}`); }\n}\n\nfunction keysFrom(body: unknown): SshPublicKey[] {\n if (!Array.isArray(body)) throw new Error('Unexpected key list');\n const keys: SshPublicKey[] = [];\n for (const entry of body.slice(0, MAX_KEYS)) {\n const line = (entry as { key?: unknown } | null)?.key;\n if (typeof line !== 'string') continue;\n try { keys.push(parseSshPublicKey(line)); } catch { /* A key type Ghostly cannot verify never matches. */ }\n }\n return keys;\n}\n\n/** The account's published keys, or null when there is no such account. */\nasync function listKeys(forge: SshForge, login: string, fetcher: IdentityFetch, signal?: AbortSignal): Promise<SshPublicKey[] | null> {\n if (forge === 'github') {\n const r = await get(fetcher, `https://api.github.com/users/${encodeURIComponent(login)}/keys?per_page=100`, signal);\n return r.status === 404 ? null : keysFrom(r.body);\n }\n const users = await get(fetcher, `https://gitlab.com/api/v4/users?username=${encodeURIComponent(login)}`, signal);\n const list = users.status === 200 && Array.isArray(users.body) ? users.body as { id?: unknown; username?: unknown }[] : [];\n const user = list.find(u => typeof u?.username === 'string' && u.username.toLowerCase() === login.toLowerCase());\n if (!user) return null;\n if (!Number.isSafeInteger(user.id) || (user.id as number) <= 0) throw new Error('Unexpected answer from gitlab.com');\n const r = await get(fetcher, `https://gitlab.com/api/v4/users/${user.id as number}/keys?per_page=100`, signal);\n return r.status === 404 ? null : keysFrom(r.body);\n}\n\n// Only concurrent identical lookups share a request. What stays checked is the verifier's stored\n// result, which the app offers to re-check once the provider's `recheck` time has passed.\nconst inFlight = new WeakMap<IdentityFetch, Map<string, Promise<SshPublicKey[] | null>>>();\n\n/** Whether `key` is one of `login`'s published SSH keys. Throws when the forge cannot be asked. */\nexport async function checkSshForge(forge: SshForge, login: string, key: Pick<SshPublicKey, 'blob'>, fetcher: IdentityFetch, signal?: AbortSignal): Promise<SshForgeStatus> {\n if (!validForgeLogin(forge, login)) throw new Error(`Not a ${SSH_FORGE_LABEL[forge]} username`);\n let pending = inFlight.get(fetcher);\n if (!pending) inFlight.set(fetcher, pending = new Map());\n const map = pending, id = `${forge}:${login.toLowerCase()}`;\n let lookup = map.get(id);\n if (!lookup) {\n lookup = listKeys(forge, login, fetcher, signal).finally(() => map.delete(id));\n map.set(id, lookup);\n }\n const keys = await lookup;\n if (!keys) return 'no-account';\n return keys.some(k => sameSshKey(k, key)) ? 'linked' : 'not-listed';\n}\n"],"mappings":";;;;;;;;;;;AAWA,IAAa,mBAAmB;;AAEhC,IAAa,mBAAmB;;AAEhC,IAAa,qBAAqB;AAClC,IAAM,eAAe;AACrB,IAAM,eAAe;AACrB,IAAM,qBAAqB;AAC3B,IAAM,kBAAkB;AACxB,IAAM,mBAAmB;AAKzB,IAAa,gBAAuC;CAAC;CAAe;CAAuB;CAAuB;CAChH;CAAW;CAA8B;AAAoC;AAsB/E,IAAa,cAAb,cAAiC,MAAM,CAAC;AACxC,IAAM,QAAQ,YAA2B;CAAE,MAAM,IAAI,YAAY,OAAO;AAAG;AAE3E,IAA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