@ghostlytools/sdk 1.10.2 → 1.10.4

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 (30) hide show
  1. package/dist/core.js +2 -2
  2. package/dist/{fakes-Bj5HAJFV.js → fakes-r4tfM7wk.js} +2 -2
  3. package/dist/{fakes-Bj5HAJFV.js.map → fakes-r4tfM7wk.js.map} +1 -1
  4. package/dist/fakes.js +1 -1
  5. package/dist/index.js +2 -2
  6. package/dist/index.js.map +1 -1
  7. package/dist/{keet-identity-key-BgbqG2dL.js → keet-identity-key-CIwy3XtG.js} +2 -2
  8. package/dist/{keet-identity-key-BgbqG2dL.js.map → keet-identity-key-CIwy3XtG.js.map} +1 -1
  9. package/dist/{src-DHR2fUGx.js → src-0lxL4lAH.js} +930 -199
  10. package/dist/src-0lxL4lAH.js.map +1 -0
  11. package/dist/testing.js +3 -3
  12. package/dist/types/browser/src/proofs/contract.d.ts +4 -1
  13. package/dist/types/core/src/chatFiles.d.ts +6 -0
  14. package/dist/types/core/src/dhtDelivery.d.ts +52 -0
  15. package/dist/types/core/src/frames.d.ts +6 -0
  16. package/dist/types/core/src/ghostlink.d.ts +4 -0
  17. package/dist/types/core/src/groupCommunity.d.ts +26 -3
  18. package/dist/types/core/src/groupSession.d.ts +46 -3
  19. package/dist/types/core/src/http.d.ts +1 -0
  20. package/dist/types/core/src/identityProofs.d.ts +17 -0
  21. package/dist/types/core/src/identityTimeline.d.ts +8 -2
  22. package/dist/types/core/src/link.d.ts +8 -0
  23. package/dist/types/core/src/relay.d.ts +46 -7
  24. package/dist/types/core/src/transport.d.ts +29 -0
  25. package/dist/types/core/src/transportSwitch.d.ts +2 -0
  26. package/dist/{verify-aVAh4GtV.js → verify-DyjsMutX.js} +3 -2
  27. package/dist/verify-DyjsMutX.js.map +1 -0
  28. package/package.json +1 -1
  29. package/dist/src-DHR2fUGx.js.map +0 -1
  30. package/dist/verify-aVAh4GtV.js.map +0 -1
@@ -55,6 +55,11 @@ export interface PkarrRequestOptions {
55
55
  * restarts publishes its offer then. A few may go over the relay's minute (`DEPARTED_READS` in relay.ts).
56
56
  */
57
57
  departed?: boolean;
58
+ /**
59
+ * A 1:1 chat's read of an invite this side made, while its joiner is due (`AWAITING_PEER_MS` in link.ts) and has not
60
+ * shown: the joiner's knock is read there. A few may go over the relay's minute (`AWAITED_READS` in relay.ts).
61
+ */
62
+ awaited?: boolean;
58
63
  /**
59
64
  * A read of a contact that was live when this app last ran, made before any read of it this run was answered
60
65
  * (`LinkSessionOptions.resumed`): the link's offer waits on it. A group edge's goes on the edges' floor
@@ -99,6 +104,25 @@ export declare class DiscoveryBudgetError extends Error {
99
104
  }
100
105
  /** Whether `error` is a request the budget held back (`DiscoveryBudgetError`), also from another copy of this module. */
101
106
  export declare function isDiscoveryBudgetError(error: unknown): error is DiscoveryBudgetError;
107
+ /**
108
+ * A publish no relay took (`RelayTransport`), saying whether one of them may hold the packet all the same. Not
109
+ * `mayBeStored` only when every relay was not asked now (its budget, its rate limit, its breaker, its network
110
+ * cooldown), answered that it did not take it (a 4xx), or could not be reached before the request went (a refused
111
+ * connection or a name that does not resolve, where the runtime says so: Node does, a browser does not), or when there
112
+ * is no relay at all. A relay that did not answer in time, dropped the connection, or answered with a server error
113
+ * may have stored it. The message is the publish's usual one.
114
+ */
115
+ export declare class PublishFailedError extends Error {
116
+ readonly mayBeStored: boolean;
117
+ readonly code = "publish-failed";
118
+ constructor(message: string, mayBeStored: boolean);
119
+ }
120
+ /**
121
+ * Whether `error` is a publish that went nowhere (`PublishFailedError` with `mayBeStored` false), also from another
122
+ * copy of this module. Anything else (a timeout, the DHT's own failure beside the relays', a Desktop's error in
123
+ * words) may have left this device.
124
+ */
125
+ export declare function publishedNowhere(error: unknown): boolean;
102
126
  /**
103
127
  * A publish Ghostly Desktop's Rust relay client held back, as it says it in words (`pkarr_network.rs`
104
128
  * `publish_failure`: "Publish held back on every relay…; retry in N ms: …"), as the `DiscoveryBudgetError` it is: every
@@ -191,4 +215,9 @@ export interface PkarrTransport {
191
215
  turnPut?(pubKeyZ32: string, payload: Uint8Array, conditions: TurnConditions): Promise<TurnSourcePut[]>;
192
216
  /** The profile has a device set: the turn's sources are made ready ahead of the first read (`TurnNetwork.turnWarm`). */
193
217
  turnWarm?(): Promise<void>;
218
+ /**
219
+ * Nothing will be put or read under these keys any more (a spare invite replaced unused): what the transport kept
220
+ * per key for them (the last packet put, its dates, each relay's last put) goes. Absent where nothing is kept.
221
+ */
222
+ forget?(keys: Iterable<string>): void;
194
223
  }
@@ -52,6 +52,8 @@ export declare class TransportSwitch {
52
52
  /** This side chose while no session was open: the next one begins with it as a choice. */
53
53
  private apart;
54
54
  private readonly policiesRead;
55
+ /** The session on which the contact's policy, the one read already, was said again and read for free (`handle`). */
56
+ private repeatRead;
55
57
  private policyHeld;
56
58
  constructor(options: {
57
59
  key: string;
@@ -1,4 +1,4 @@
1
- import { Au as IdentityCheckUnavailable, Mu as boundVerifiedIdentity } from "./src-DHR2fUGx.js";
1
+ import { Fu as boundVerifiedIdentity, Mu as IdentityCheckUnavailable } from "./src-0lxL4lAH.js";
2
2
  //#region ../browser/src/proofs/verify.ts
3
3
  var DAY = 86400;
4
4
  /**
@@ -31,6 +31,7 @@ function descriptorProblems(p) {
31
31
  const { defaultDays, maxDays } = p.validity;
32
32
  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");
33
33
  if (p.recheck && !(Number.isInteger(p.recheck.afterSeconds) && p.recheck.afterSeconds >= 60)) problems.push("recheck.afterSeconds must be at least 60");
34
+ if (p.recheck?.perHour !== void 0 && !(Number.isInteger(p.recheck.perHour) && p.recheck.perHour >= 1)) problems.push("recheck.perHour must be a whole number, at least 1");
34
35
  if (!p.signers.length) problems.push("no signers");
35
36
  const ids = p.signers.map((s) => s.id);
36
37
  if (new Set(ids).size !== ids.length) problems.push("signer ids are not unique");
@@ -103,4 +104,4 @@ function boundedIdentityFetch(options = { online: () => true }) {
103
104
  //#endregion
104
105
  export { verifyIdentity as i, boundedIdentityFetch as n, descriptorProblems as r, availableSigners as t };
105
106
 
106
- //# sourceMappingURL=verify-aVAh4GtV.js.map
107
+ //# sourceMappingURL=verify-DyjsMutX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-DyjsMutX.js","names":[],"sources":["../../browser/src/proofs/verify.ts"],"sourcesContent":["import { boundVerifiedIdentity, IdentityCheckUnavailable, 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.recheck?.perHour !== undefined && !(Number.isInteger(p.recheck.perHour) && p.recheck.perHour >= 1)) problems.push(\"recheck.perHour must be a whole number, at least 1\");\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 IdentityCheckUnavailable(\"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"],"mappings":";;AAGA,IAAM,MAAM;;;;;;;AAQZ,eAAsB,eAAe,WAA6C,WAA8B,UAAmB,KAA+C;CAChL,MAAM,EAAE,YAA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AO,KAAK;GAAG;EAAM;CAC1I;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ghostlytools/sdk",
3
- "version": "1.10.2",
3
+ "version": "1.10.4",
4
4
  "type": "module",
5
5
  "description": "Build a wallet source, an identity proof, a mini-app or a client for Ghostly without reading its internals: the adapter contracts, their fakes and contract test suites, the plugin registry, and the mini-app API types (Apps run in Ghostly 1.2 and later).",
6
6
  "license": "MIT",