@yaks/connections 0.0.0-stage → 0.2.36

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 (184) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +609 -2
  3. package/_dist/authorize.d.ts +38 -0
  4. package/_dist/authorize.d.ts.map +1 -0
  5. package/_dist/authorize_cli.d.ts +12 -0
  6. package/_dist/authorize_cli.d.ts.map +1 -0
  7. package/_dist/brokers.d.ts +66 -0
  8. package/_dist/brokers.d.ts.map +1 -0
  9. package/_dist/catalog.d.ts +33 -0
  10. package/_dist/catalog.d.ts.map +1 -0
  11. package/_dist/cli.d.ts +3 -0
  12. package/_dist/cli.d.ts.map +1 -0
  13. package/_dist/clients.d.ts +18 -0
  14. package/_dist/clients.d.ts.map +1 -0
  15. package/_dist/connections.d.ts +296 -0
  16. package/_dist/connections.d.ts.map +1 -0
  17. package/_dist/effects.d.ts +15 -0
  18. package/_dist/effects.d.ts.map +1 -0
  19. package/_dist/field.d.ts +17 -0
  20. package/_dist/field.d.ts.map +1 -0
  21. package/_dist/form.d.ts +49 -0
  22. package/_dist/form.d.ts.map +1 -0
  23. package/_dist/given.d.ts +10 -0
  24. package/_dist/given.d.ts.map +1 -0
  25. package/_dist/graph.d.ts +15 -0
  26. package/_dist/graph.d.ts.map +1 -0
  27. package/_dist/history.d.ts +4 -0
  28. package/_dist/history.d.ts.map +1 -0
  29. package/_dist/identity.d.ts +9 -0
  30. package/_dist/identity.d.ts.map +1 -0
  31. package/_dist/integrations.d.ts +196 -0
  32. package/_dist/integrations.d.ts.map +1 -0
  33. package/_dist/loopback.d.ts +7 -0
  34. package/_dist/loopback.d.ts.map +1 -0
  35. package/_dist/mcp-retirement.d.ts +33 -0
  36. package/_dist/mcp-retirement.d.ts.map +1 -0
  37. package/_dist/mcp.d.ts +179 -0
  38. package/_dist/mcp.d.ts.map +1 -0
  39. package/_dist/mod.d.ts +70 -0
  40. package/_dist/mod.d.ts.map +1 -0
  41. package/_dist/paste.d.ts +13 -0
  42. package/_dist/paste.d.ts.map +1 -0
  43. package/_dist/requests.d.ts +30 -0
  44. package/_dist/requests.d.ts.map +1 -0
  45. package/_dist/services.d.ts +25 -0
  46. package/_dist/services.d.ts.map +1 -0
  47. package/_dist/sign-in.d.ts +9 -0
  48. package/_dist/sign-in.d.ts.map +1 -0
  49. package/_dist/signin-mail.d.ts +12 -0
  50. package/_dist/signin-mail.d.ts.map +1 -0
  51. package/_dist/signin.d.ts +19 -0
  52. package/_dist/signin.d.ts.map +1 -0
  53. package/_dist/sources.d.ts +61 -0
  54. package/_dist/sources.d.ts.map +1 -0
  55. package/_dist/tools.d.ts +3 -0
  56. package/_dist/tools.d.ts.map +1 -0
  57. package/_dist/views.d.ts +3 -0
  58. package/_dist/views.d.ts.map +1 -0
  59. package/_dist/vocab.d.ts +6 -0
  60. package/_dist/vocab.d.ts.map +1 -0
  61. package/_dist/yaks-app.d.ts +29 -0
  62. package/_dist/yaks-app.d.ts.map +1 -0
  63. package/anthropic.json +12 -0
  64. package/auth_command.js +69 -0
  65. package/auth_command.js.map +1 -0
  66. package/auth_command.ts +74 -0
  67. package/authorize.js +89 -0
  68. package/authorize.js.map +1 -0
  69. package/authorize.ts +138 -0
  70. package/authorize_cli.js +167 -0
  71. package/authorize_cli.js.map +1 -0
  72. package/authorize_cli.ts +211 -0
  73. package/brokers.js +318 -0
  74. package/brokers.js.map +1 -0
  75. package/brokers.ts +423 -0
  76. package/canva.json +32 -0
  77. package/catalog.js +178 -0
  78. package/catalog.js.map +1 -0
  79. package/catalog.ts +216 -0
  80. package/cli.js +30 -0
  81. package/cli.js.map +1 -0
  82. package/cli.ts +26 -0
  83. package/clients.js +34 -0
  84. package/clients.js.map +1 -0
  85. package/clients.ts +65 -0
  86. package/connections.js +1961 -0
  87. package/connections.js.map +1 -0
  88. package/connections.ts +2561 -0
  89. package/deno.json +1 -0
  90. package/discord-account.json +22 -0
  91. package/discord-bot.json +20 -0
  92. package/discord.json +26 -0
  93. package/effects.js +168 -0
  94. package/effects.js.map +1 -0
  95. package/effects.ts +160 -0
  96. package/elevenlabs.json +18 -0
  97. package/facebook.json +18 -0
  98. package/field.js +19 -0
  99. package/field.js.map +1 -0
  100. package/field.ts +31 -0
  101. package/form.js +112 -0
  102. package/form.js.map +1 -0
  103. package/form.ts +178 -0
  104. package/git-config.js +44 -0
  105. package/git-config.js.map +1 -0
  106. package/git-config.ts +26 -0
  107. package/given.js +83 -0
  108. package/given.js.map +1 -0
  109. package/given.ts +88 -0
  110. package/gmail-mailbox.json +29 -0
  111. package/gmail.json +31 -0
  112. package/google-calendar.json +31 -0
  113. package/google-drive.json +31 -0
  114. package/google-search-console.json +29 -0
  115. package/graph.js +36 -0
  116. package/graph.js.map +1 -0
  117. package/graph.ts +52 -0
  118. package/history.js +31 -0
  119. package/history.js.map +1 -0
  120. package/history.ts +32 -0
  121. package/identity.js +15 -0
  122. package/identity.js.map +1 -0
  123. package/identity.ts +18 -0
  124. package/integrations.js +493 -0
  125. package/integrations.js.map +1 -0
  126. package/integrations.ts +725 -0
  127. package/loopback.js +72 -0
  128. package/loopback.js.map +1 -0
  129. package/loopback.ts +89 -0
  130. package/lulu.json +32 -0
  131. package/mcp-retirement.js +133 -0
  132. package/mcp-retirement.js.map +1 -0
  133. package/mcp-retirement.ts +200 -0
  134. package/mcp-signin.js +14 -0
  135. package/mcp-signin.js.map +1 -0
  136. package/mcp-signin.ts +13 -0
  137. package/mcp.js +1036 -0
  138. package/mcp.js.map +1 -0
  139. package/mcp.ts +1283 -0
  140. package/mod.js +70 -0
  141. package/mod.js.map +1 -0
  142. package/mod.ts +216 -0
  143. package/openai-api.json +12 -0
  144. package/openai.json +25 -0
  145. package/openrouter.json +14 -0
  146. package/package.json +89 -4
  147. package/paste.js +36 -0
  148. package/paste.js.map +1 -0
  149. package/paste.ts +55 -0
  150. package/requests.js +137 -0
  151. package/requests.js.map +1 -0
  152. package/requests.ts +200 -0
  153. package/services.js +84 -0
  154. package/services.js.map +1 -0
  155. package/services.ts +111 -0
  156. package/sign-in.js +36 -0
  157. package/sign-in.js.map +1 -0
  158. package/sign-in.ts +53 -0
  159. package/signin-mail.js +29 -0
  160. package/signin-mail.js.map +1 -0
  161. package/signin-mail.ts +56 -0
  162. package/signin.js +68 -0
  163. package/signin.js.map +1 -0
  164. package/signin.ts +109 -0
  165. package/slack.json +90 -0
  166. package/sources.js +178 -0
  167. package/sources.js.map +1 -0
  168. package/sources.ts +237 -0
  169. package/tools.js +39 -0
  170. package/tools.js.map +1 -0
  171. package/tools.ts +46 -0
  172. package/views.js +85 -0
  173. package/views.js.map +1 -0
  174. package/views.ts +89 -0
  175. package/visitor-defaults.json +8 -0
  176. package/vocab.js +17 -0
  177. package/vocab.js.map +1 -0
  178. package/vocab.json +863 -0
  179. package/vocab.ts +18 -0
  180. package/voipms.json +32 -0
  181. package/yaks-app.js +159 -0
  182. package/yaks-app.js.map +1 -0
  183. package/yaks-app.ts +177 -0
  184. package/youtube.json +26 -0
@@ -0,0 +1,12 @@
1
+ import type { Authorization } from "./authorize.js";
2
+ import { type Listen } from "./loopback.js";
3
+ export type { Authorization } from "./authorize.js";
4
+ export type AuthIO = {
5
+ say: (line: string) => void;
6
+ /** Read a masked line. `onEnd` signals EOF without a line. */ hidden: (signal?: AbortSignal, onEnd?: () => void) => Promise<string>;
7
+ listen?: Listen;
8
+ };
9
+ /** Read one private line, including a terminal's bracketed paste protocol. */ export declare let readHidden: (read: () => Promise<Uint8Array | null>, mask?: (shown: boolean) => void) => Promise<string>;
10
+ export declare let authIO: AuthIO;
11
+ /** List available targets, or authorize one without storing the callback. */ export declare let authorizeCLI: (auth: Authorization, name?: string, io?: AuthIO, as?: string) => Promise<string>;
12
+ //# sourceMappingURL=authorize_cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorize_cli.d.ts","sources":["../authorize_cli.ts"],"names":[],"mappings":"AAMA,cAAc,aAAa,yBAAmC;AAC9D,SAEE,KAAK,MAAM,wBAGS;AAEtB,cAAc,aAAa,yBAAwB;AAEnD,YAAY;EACV,MAAM,MAAM,MAAM,KAAK,IAAI;EAC3B,4DAA4D,GAC5D,SAAS,SAAS,aAAa,cAAc,IAAI,KAAK,QAAQ,MAAM;EACpE,SAAS;;AAMX,4EAA4E,GAC5E,OAAO,YAAI,aACT,YAAY,QAAQ,aAAa,IAAI,GACrC,QAAO,OAAO,OAAO,KAAK,IAAI,KAC7B,QAAQ,MAAM,EAwChB;AA+BD,OAAO,YAAI,QAAQ,OAIlB;AA8ED,2EAA2E,GAC3E,OAAO,YAAI,eACT,MAAM,eACN,OAAO,MAAM,EACb,KAAI,QACJ,KAAK,MAAM,KACV,QAAQ,MAAM,EAqBhB"}
@@ -0,0 +1,66 @@
1
+ import { type Vault } from "@yaks/secrets";
2
+ import type { Bundle } from "@yaks/graph";
3
+ import type { Field } from "./integrations.js";
4
+ /** What a broker answers for a connection: its access token, when it
5
+ * expires (epoch milliseconds), what it grants, and an id token or address
6
+ * naming the account where the broker knows one. */ export type Grant = {
7
+ access_token: string;
8
+ expires_at?: number;
9
+ scopes?: string[];
10
+ id_token?: string;
11
+ account?: string;
12
+ };
13
+ /** A broker's refusal. `refused` is the broker saying the grant is gone or
14
+ * revoked, which means connect again; anything else is a failure on the wire
15
+ * or of our own key. */ export declare class BrokerError extends Error {
16
+ status: number;
17
+ refused: boolean;
18
+ constructor(status: number, message: string);
19
+ }
20
+ /** A service a broker can connect, as its catalog lists it: what the broker
21
+ * calls it, what a person calls it, the address of its logo (an SVG), the
22
+ * kinds of service it is, and the API hosts a credential for it goes to
23
+ * (none where they depend on the account). `connects` is how: signing in
24
+ * through the broker's own app with the service, giving the broker an OAuth
25
+ * client of the person's own, or a key, as the `fields` it names (none is
26
+ * one key). `keyGuide` links to where a person can get the credential.
27
+ * `popular` is one the broker features. */ export type Listing = {
28
+ name: string;
29
+ title: string;
30
+ logo: string;
31
+ categories: string[];
32
+ hosts: string[];
33
+ connects: 'signin' | 'client' | 'key';
34
+ fields?: Field[];
35
+ keyGuide?: string;
36
+ popular?: boolean;
37
+ };
38
+ /** A sign-in that finished at a broker: the broker's own id for it, and the
39
+ * address of the person who began it, as `begin` was told. */ export type Found = {
40
+ id: string;
41
+ began?: string;
42
+ };
43
+ /** One broker, for the integration it calls `integration`, and our
44
+ * connection's eid as the tag it finds a sign-in by. */ export type Broker = {
45
+ /** every service it can connect: one it signs in to and hands back an
46
+ * access token for, or one reached with a plain key */ catalog(): Promise<Listing[]>;
47
+ /** make ready to sign people in to the service it calls `integration`, as
48
+ * `listing` says it connects; one already ready is left as it is */ enable(integration: string, connects: Listing['connects']): Promise<void>;
49
+ /** the link a person follows to sign in for connection `eid`, begun by
50
+ * the person whose verified address is `began` */ begin(integration: string, eid: string, began?: string, scopes?: string[]): Promise<string>;
51
+ /** the newest sign-in made for `eid`, once one finished */ found(integration: string, eid: string): Promise<Found | undefined>;
52
+ /** every sign-in it holds for `eid`, newest first */ grants(integration: string, eid: string): Promise<Found[]>;
53
+ /** the grant's current token, refreshed by the broker when it is due, or
54
+ * at once with `fresh` */ grant(integration: string, id: string, fresh?: boolean): Promise<Grant>;
55
+ /** end the broker's connection; one already gone is no failure */ forget(integration: string, id: string): Promise<void>;
56
+ };
57
+ type Fetch = typeof fetch;
58
+ export declare let exampleLogo: (name: string) => string | undefined;
59
+ /** Every address a listing's logo may be fetched from, its own first. */ export declare let logoSources: (at: string) => string[];
60
+ /** Nango (nango.dev), reached with an environment's secret key. */ export declare let nango: (key: string, fetcher?: Fetch) => Broker;
61
+ /** The brokers this package implements, by the name an integration gives. */ export declare let BROKERS: Record<string, (key: string, f?: Fetch) => Broker>;
62
+ /** The bundle that keeps a broker's key: the vault holds it, and the graph
63
+ * its handle. */ export declare let brokerKey: (name: string, key: string) => Bundle;
64
+ /** The broker named `name`, ready to ask, once its key is kept; none while it
65
+ * is not, or for a name this package does not implement. */ export declare let brokerOf: (vault: Vault, name: string, fetcher?: Fetch) => Promise<Broker |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,MAAM,EAAE,IAAI,MAAM,GAAG,QAAQ,IAAI;;KAGlD,eAAe;AAsGpB,OAAO,YAAI,cAAe,MAAM,MAAM,KAAG,MAAM,GAAG,SAAS,CACQ;AAoBnE,uEAAuE,GAEvE,OAAO,YAAI,cAAe,IAAI,MAAM,KAAG,MAAM,GAI5C;AAmBD,iEAAiE,GACjE,OAAO,YAAI,QAAS,KAAK,MAAM,EAAE,UAAS,UAAgB,OAuJzD;AAED,2EAA2E,GAC3E,OAAO,YAAI,SAAS,OAAO,MAAM,GAAG,KAAK,MAAM,EAAE,IAAI,UAAU,QAE9D;AAKD;eACe,GACf,OAAO,YAAI,YAAa,MAAM,MAAM,EAAE,KAAK,MAAM,KAAG,OACnB;AAEjC;0DAC0D,GAC1D,OAAO,YAAI,WACT,OAAO,OACP,MAAM,MAAM,EACZ,UAAU,UACT,QAAQ,SAAS,SAAS,EAK5B"}
@@ -0,0 +1,33 @@
1
+ import type { Listing } from "./brokers.js";
2
+ import { type Integration, type Marked } from "./integrations.js";
3
+ /** A service as the catalog offers it: the integration it is or would be,
4
+ * the kinds of service it is, the address of its logo where it has no SVG of
5
+ * its own, and whether it is featured. */ export type Offer = Marked & {
6
+ categories: string[];
7
+ image?: string;
8
+ };
9
+ export declare let kind: (category: string) => string;
10
+ /** Whether an integration can take credential help from the broker catalog. */ export declare let catalogKey: (i: Integration) => boolean;
11
+ /** Instructions someone wrote, ignoring old imports of credential field
12
+ * descriptions from the broker catalog. */ export declare let keyHelp: (i?: Integration) => string;
13
+ /** A link to the credential page or guide, for a listing with no written
14
+ * steps. */ export declare let keyGuide: (l?: Listing) => string;
15
+ /** The integration a broker's listing would be: brokered where it is signed
16
+ * in to through the broker, a pasted key where it is reached with one. */ export declare let offerOf: (l: Listing, broker: string) => Offer;
17
+ /** The catalog: the built integrations a person may be offered unasked (none
18
+ * in its service's testing mode), each featured, and every listing of
19
+ * `broker` that no built one stands in for and that names its hosts, featured
20
+ * where the broker features it, by title. A built integration takes the kinds
21
+ * of the listing it stands in for. */ export declare let catalogue: (integrations: Marked[], listings: Listing[], broker: string) => Offer[];
22
+ /** The offers that hold every word of `words`, best first: by how well each
23
+ * word fits, then featured, then by title. No words is every offer. */ export declare let find: (offers: Offer[], words: string) => Offer[];
24
+ /** The kinds of service the catalog holds, the most common first. */ export declare let kinds: (offers: Offer[]) => string[];
25
+ /** The integration an offer is written as once someone connects it, with
26
+ * its logo as an SVG document where one was fetched: only the host writes
27
+ * it, so it is `built`. Whether it is featured is the platform's mark, never
28
+ * the integration's own word. */ export declare let adopted: (o: Offer, logo?: string) => Integration;
29
+ /** Whether `text` is an SVG document: its root is `<svg>`. A page that holds
30
+ * an SVG is not one. */ export declare let isSvg: (text: string) => boolean;
31
+ /** The logo a service with no image of its own wears: the first letter of
32
+ * its title on a rounded square, as an SVG document. */ export declare let initialLogo: (title: string) => string;
33
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sources":["../catalog.ts"],"names":[],"mappings":"AAkBA,cAAc,OAAO,uBAAsB;AAC3C,SACE,KAAK,WAAW,EAChB,KAAK,MAAM,4BAGa;AAE1B;;wCAEwC,GACxC,YAAY,QAAQ;EAClB,YAAY,MAAM;EAClB,QAAQ,MAAM;;AAgBhB,OAAO,YAAI,OAAQ,UAAU,MAAM,KAAG,MAAM,CAEiC;AAE7E,6EAA6E,GAC7E,OAAO,YAAI,aAAc,GAAG,gBAAc,OAAO,CACe;AAEhE;yCACyC,GACzC,OAAO,YAAI,UAAW,IAAI,gBAAc,MAAM,CAQ7C;AAED;UACU,GACV,OAAO,YAAI,WAAY,IAAI,YAAU,MAAM,CAM1C;AAED;wEACwE,GACxE,OAAO,YAAI,UAAW,GAAG,SAAS,QAAQ,MAAM,KAAG,MAiBlD;AAED;;;;oCAIoC,GACpC,OAAO,YAAI,YACT,cAAc,UACd,UAAU,WACV,QAAQ,MAAM,KACb,QAsCF;AAcD;qEACqE,GACrE,OAAO,YAAI,OAAQ,QAAQ,SAAS,OAAO,MAAM,KAAG,QAUnD;AAED,mEAAmE,GACnE,OAAO,YAAI,QAAS,QAAQ,YAAU,MAAM,GAM3C;AAED;;;+BAG+B,GAC/B,OAAO,YAAI,UAAW,GAAG,OAAO,OAAO,MAAM,KAAG,YAG/C;AAOD;sBACsB,GAItB,OAAO,YAAI,QAAS,MAAM,MAAM,KAAG,OAAO,CACI;AAI9C;sDACsD,GACtD,OAAO,YAAI,cAAe,OAAO,MAAM,KAAG,MAAM,CAO/C"}
package/_dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import type { CliCommand } from "@yaks/cli/host";
2
+ export declare let commands: CliCommand[];
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sources":["../cli.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,8BAAmC;AAE3D,OAAO,YAAI,UAAU,aAsBnB"}
@@ -0,0 +1,18 @@
1
+ import type { Bundle } from "@yaks/graph";
2
+ import { type Vault } from "@yaks/secrets";
3
+ import { type Integration, type Read } from "./integrations.js";
4
+ /** A client registered with a service: its id, a confidential client's
5
+ * secret, and the token of the bot its application speaks as on a chat
6
+ * platform (Discord's), for an integration that `chat`s. */ export type Registered = {
7
+ id: string;
8
+ secret?: string;
9
+ bot?: string;
10
+ /** The signing secret for events sent by the application's chat provider. */ signing?: string;
11
+ };
12
+ /** The bundle that keeps `client` under `name`: the id and the secret go to
13
+ * the vault, and the graph holds the handle. */ export declare let registration: (name: string, client: Registered) => Bundle;
14
+ /** The client kept under `name`, if one is. */ export declare let registered: (vault: Vault, name: string) => Promise<Registered | undefined>;
15
+ /** The client an integration signs in as. A custom integration never signs in
16
+ * as a client a built one names: that client's secret would go to whatever
17
+ * token endpoint the custom integration gives. */ export declare let clientOf: (vault: Vault, read: Read, i: Integration) => Promise<Registered | undefined>;
18
+ //# sourceMappingURL=clients.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clients.d.ts","sources":["../clients.ts"],"names":[],"mappings":"AAUA,cAAc,MAAM,2BAAgC;AACpD,SAAyB,KAAK,KAAK,6BAAkC;AACrE,SAAoB,KAAK,WAAW,EAAE,KAAK,IAAI,4BAA2B;AAE1E;;0DAE0D,GAC1D,YAAY;EACV,IAAI,MAAM;EACV,SAAS,MAAM;EACf,MAAM,MAAM;EACZ,2EAA2E,GAC3E,UAAU,MAAM;;AAMlB;8CAC8C,GAC9C,OAAO,YAAI,eAAgB,MAAM,MAAM,EAAE,QAAQ,eAAa,OACV;AAEpD,6CAA6C,GAC7C,OAAO,YAAI,aACT,OAAO,OACP,MAAM,MAAM,KACX,QAAQ,aAAa,SAAS,EAWhC;AAED;;gDAEgD,GAChD,OAAO,YAAI,WACT,OAAO,OACP,MAAM,MACN,GAAG,gBACF,QAAQ,aAAa,SAAS,EAOhC"}
@@ -0,0 +1,296 @@
1
+ import { type Built } from "@yaks/query";
2
+ import { CallError } from "@yaks/tools/errors";
3
+ import type { Bundle, Comp, Eid } from "@yaks/graph";
4
+ import { type Attempt, type Tokens } from "@yaks/oauth";
5
+ import { type Vault } from "@yaks/secrets";
6
+ import { type About, type Field, type Integration, type Read } from "./integrations.js";
7
+ import type { Place } from "@yaks/host/keepers";
8
+ import { type Grant } from "./brokers.js";
9
+ /** An explicit account name did not select one connection: a refusal of the
10
+ * caller's own input, not a fault. */ export declare class AccountError extends CallError {
11
+ constructor(message: string);
12
+ }
13
+ /** needed: no credential yet; connected: one is kept; broken: the service
14
+ * refused it. */ export type Status = 'needed' | 'connected' | 'broken';
15
+ /** What an app, or a person, asks for, and for a custom integration what a
16
+ * person reads about it: its owner's to say, when it is made or later. */ export type Need = About & {
17
+ /** the space or person it belongs to */ owner: Eid;
18
+ /** the integration, by name */ integration: string;
19
+ /** the app that needs it; none when a person connects first */ app?: Eid;
20
+ scopes?: string[];
21
+ /** for a custom key: the hosts it may be sent to */ hosts?: string[];
22
+ /** for a custom key: what a person gives to connect it, when it is more
23
+ * than one key */ fields?: Field[];
24
+ /** each person connects their own, and only they call out through it */ each?: boolean;
25
+ /** the name the app's code reads it by (default: the integration's name in
26
+ * capitals) */ binding?: string;
27
+ /** ask for a separate shared connection under this binding */ separate?: boolean;
28
+ /** hand the app's code the key itself rather than a sentinel */ direct?: boolean;
29
+ /** the task that asks a person for the key, linked to it by `asks` */ task?: Eid;
30
+ /** where else the key goes once it is given, besides the vault */ keep?: Place[];
31
+ };
32
+ /** What the acting verbs work with. */ export type Ctx = {
33
+ graph: {
34
+ read: Read;
35
+ apply: (bundles: Bundle[]) => Bundle[] | Promise<Bundle[]>;
36
+ };
37
+ vault: Vault;
38
+ /** where the service sends the person back after they sign in */ redirect?: string;
39
+ /** where the host serves its OAuth client's metadata document, whose URL
40
+ * is the client's id at a service that takes one (@yaks/mcp-client/oauth
41
+ * `client`) */ document?: string;
42
+ fetch?: typeof fetch;
43
+ now?: () => number;
44
+ /** where a failure is reported that the verb answering is not stopped by:
45
+ * a broker's connection left behind by a disconnect */ report?: (e: unknown) => void;
46
+ /** asked before `owner` comes to hold one more connection with a key or a
47
+ * grant: before a needed one's sign-in begins, and before its key or grant
48
+ * is kept. It throws to refuse, as a host's plan limit does; signing in
49
+ * again, or a connection that already holds one, is not asked. */ admit?: (owner: Eid) => Promise<void>;
50
+ };
51
+ /** Whose space each app is in, by its eid: who is asked for what it needs. The
52
+ * host says, since an app is its word; an app it does not know is missing. */ export type Owners = (apps: Eid[]) => Promise<Record<Eid, Eid>>;
53
+ /** What a caller calling out through a connection is given: the connection,
54
+ * the `uses` link to it from the app, and the sentinel for each field of its
55
+ * credential, by the field's name: `key` for one key or a sign-in's token. */ export type Resolved = {
56
+ connection: Bundle;
57
+ link: Bundle;
58
+ sentinels: Record<string, string>;
59
+ };
60
+ /** How a connection's credential arrives: a pasted key, each field its
61
+ * integration names, or the return from the service's sign-in page with the
62
+ * attempt `begin` gave. */ export type Given = {
63
+ key: string;
64
+ expect?: Status;
65
+ } | {
66
+ fields: Record<string, string>;
67
+ } | {
68
+ attempt: Attempt;
69
+ callback: string | URL;
70
+ /** A website session obtained alongside a bot OAuth sign-in, kept only in the vault. */ session?: string;
71
+ /** the person who signed in, whose own account the sign-in also names
72
+ * where its integration `links` one */ person?: Eid;
73
+ } | {
74
+ /** the broker's own id for a sign-in that finished there (`settle`) */ brokered: string;
75
+ /** its grant, where the broker was already asked for it */ grant?: Grant;
76
+ };
77
+ /** A direct sign-in started without an app's existing connection request. */ export type NewSignIn = {
78
+ owner: Eid;
79
+ integration: string;
80
+ };
81
+ type Use = {
82
+ app: Eid;
83
+ integration: string;
84
+ owner?: Eid;
85
+ each?: boolean;
86
+ binding?: string;
87
+ };
88
+ /** The connection an app uses through an integration, optionally by binding.
89
+ * With `each`, it is the one `owner` holds. */ export declare let using: (read: Read, a: Use) => Promise<Bundle | undefined>;
90
+ /** The names an app's code reads a connection by, by field name: its
91
+ * binding, for one key or a sign-in, or for several fields the binding and
92
+ * each field's name in capitals, `S3_ACCESS_KEY_ID`. */ export declare let namesOf: (binding: string, fields: string[]) => Record<string, string>;
93
+ /** The name an app reads an integration's connection by when it names none:
94
+ * `google-calendar` is `GOOGLE_CALENDAR`. */ export declare let bindingOf: (integration: string) => string;
95
+ /** Make a connection needing a credential, linked from the app that needs it,
96
+ * with the custom integration a key for an unbuilt service needs — made only
97
+ * where no integration holds the name, so it never writes over one, and owned
98
+ * by whoever made it. Its hosts may wait: a key kept before anyone uses it is
99
+ * sent nowhere, and its owner may name them once. On a new integration the
100
+ * owner can correct hosts until its first credential. What is said about it (`About`) is written with it, or
101
+ * changed by its owner asking again. An ask the owner already has standing
102
+ * through that integration for the same scopes is reused. With `separate`,
103
+ * the binding also identifies the ask. With `each`, each owner asks for
104
+ * their own. The connection comes first. */ export declare let need: (read: Read, a: Need, request?: boolean) => Promise<Bundle[]>;
105
+ /** What a copy of an app asks for, read off the app it was copied from: for
106
+ * each connection the source uses and the copy does not yet, a connection
107
+ * needing a credential, owned by `owner`, the copy's space, and linked from the
108
+ * copy as `need` makes one. It goes through the same integration, is read by
109
+ * the same binding, as directly, for each person where the source asks each,
110
+ * and asks for the same scopes. A credential never travels, and neither does a
111
+ * link opened to anyone, which is the person's act. Where the source lends a
112
+ * connected connection (`lend`), the copy borrows it instead: a link to that
113
+ * same connection, capped at what the source lends and naming it the
114
+ * `lender`, which the host writes as itself since only it sets a cap. An
115
+ * install and an update both ask it, so an update adds what its version gained
116
+ * and leaves what the copy already uses as its person made it. */ export declare let carry: (read: Read, a: {
117
+ source: Eid;
118
+ app: Eid;
119
+ owner: Eid;
120
+ }) => Promise<Bundle[]>;
121
+ /** Lend the connection an app uses through an integration to every copy
122
+ * installed from it, from then on: each copy borrows it at install (`carry`)
123
+ * under a cap of `cap` calls per month, and a new cap moves every copy already
124
+ * borrowing it. `null` stops lending it, and every copy borrowing it through
125
+ * this app asks for its own (`recall`). The cap a copy borrows under is the
126
+ * host's to write, so the host applies this as itself, once it has checked
127
+ * that the actor owns the app's space and the connection. Refused for a key
128
+ * handed to the app's code, a link where each person connects their own, and
129
+ * a connection the app itself borrows. */ export declare let lend: (read: Read, a: {
130
+ app: Eid;
131
+ integration: string;
132
+ binding?: string;
133
+ cap: number | null;
134
+ }, owners: Owners) => Promise<Bundle[]>;
135
+ /** Stop lending a connection: to the one copy `app`, to every copy borrowing
136
+ * it through the `lender` app's lend, or with neither to every copy borrowing
137
+ * it. Each copy's link gives way to a connection needing a credential of its
138
+ * own, in the copy's own space (`owners`), linked by the same name, as
139
+ * `disconnect` leaves the apps that shared one. The connection lent stays as
140
+ * it was. */ export declare let recall: (read: Read, a: {
141
+ connection: Eid;
142
+ app?: Eid;
143
+ lender?: Eid;
144
+ }, owners: Owners) => Promise<Bundle[]>;
145
+ /** The connections some apps borrow rather than hold, from the `uses` links
146
+ * out of them, each with the link borrowing it and the integration it goes
147
+ * through: what the apps' own space reads beside the connections it keeps.
148
+ * The host reads the links however it names its apps, so they can be asked
149
+ * beside everything else it shows. A borrowed connection is read without its
150
+ * secret, which is the lender's. */ export declare let borrowed: (read: Read, out: Bundle[]) => Promise<Bundle[]>;
151
+ /** Link an app to a connection its space already owns and has connected.
152
+ * The host verifies that the actor owns both. A previous unmet ask is
153
+ * replaced, with its binding kept, and an unused ask is removed. `anyone`
154
+ * opens the link to visitors or keeps it to the app's members within the
155
+ * integration's visitor policy. When omitted, the link keeps any explicit
156
+ * choice and otherwise follows the integration's default. The app gets a
157
+ * sentinel. */ export declare let attach: (read: Read, a: {
158
+ owner: Eid;
159
+ app: Eid;
160
+ connection: Eid;
161
+ binding?: string;
162
+ anyone?: boolean;
163
+ }) => Promise<Bundle[]>;
164
+ /** An owner named before its eid is known: the walk from a reference to it
165
+ * to what names it, as `.space.slug=ada` names a space by its address, and
166
+ * its eid as whatever learns it answers. The host spells the walk, and one
167
+ * may reach more than one owner: only the eid's are kept. */ export type Path = {
168
+ path: Built;
169
+ eid: Promise<Eid>;
170
+ };
171
+ /** An owner's connected chat integrations and their connection rows. A
172
+ * {@link Path} lets both reads start while the owner is still being read. */ export declare let chatConnections: (read: Read, owner: Eid | Path) => Promise<{
173
+ row: Bundle;
174
+ integration: Integration;
175
+ }[]>;
176
+ /** A space's or a person's connections, the `uses` links from the apps that
177
+ * use them, and the integrations they go through. Each is asked by the owner,
178
+ * so all three are asked at once, and a host whose reads asked together
179
+ * travel together answers them in one trip: the integrations among the built
180
+ * ones (the line `installed` asks) and the owner's own. Only one another owner
181
+ * listed is asked after. An owner named by a {@link Path} is asked before its
182
+ * eid is known, beside whatever learns it. */ export declare let list: (read: Read, owner: Eid | Path) => Promise<Bundle[]>;
183
+ /** Every connected connection an app calls out through for a person, or for
184
+ * nobody in particular: those it shares with every caller, and that person's
185
+ * own where each person connects their own. Each comes with its `uses` link
186
+ * and the sentinel for its credential: what the egress finds a request's
187
+ * sentinels among. */ export declare let used: (c: Ctx, app: Eid, person?: Eid | null) => Promise<Resolved[]>;
188
+ /** What an app's code is handed for each connected connection it uses, for a
189
+ * person or for nobody in particular, by the name it reads it by: the sentinel
190
+ * for its credential, or the credential itself where the link is direct. */ export declare let envOf: (c: Ctx, app: Eid, person?: Eid | null) => Promise<Record<string, string>>;
191
+ /** What the host's own code reads for each connected connection an app of the
192
+ * host's uses, by the name it reads it by: the credential itself, whatever the
193
+ * link says, since that code is the host's and the key goes nowhere else.
194
+ * yaks.app's own provider keys are its `platform` app's. When `unread` is
195
+ * supplied, it hears a failed credential lookup and the other bindings still
196
+ * answer. */ export declare let keysOf: (c: Ctx, app: Eid, unread?: (binding: string, error: unknown) => void) => Promise<Record<string, string>>;
197
+ /** The connection an app calls out through for an integration, for a person
198
+ * or for nobody in particular, optionally by binding. It includes the
199
+ * credential's sentinel. Whether the caller may use it is the egress's
200
+ * question. */ export declare let resolve: (c: Ctx, app: Eid, integration: string, person?: Eid | null, binding?: string) => Promise<Resolved | undefined>;
201
+ /** Choose an owner's account. Without a name, the person's own address wins,
202
+ * otherwise the oldest connection. No remembered selection can let a newer
203
+ * throwaway change what unattended commands use. */ export declare let pick: (read: Read, owner: Eid, integration: string, as?: string) => Promise<Bundle | undefined>;
204
+ /** Every connection to one account of an integration, by its whole address,
205
+ * whoever owns it: what goes when the account does. */ export declare let toAccount: (read: Read, integration: string, address: string) => Promise<Bundle[]>;
206
+ /** The address the provider returned. An id_token is used only to name an
207
+ * account after the authenticated code exchange, never as authorization. */ export declare let accountOf: (integration: Integration, tokens: Tokens, fetcher?: typeof fetch) => Promise<string | undefined>;
208
+ /** The scopes `i` now asks for that a connection holding `scopes` lacks, so
209
+ * signing in again would give it more; none when what it holds is unknown. */ export declare let lacking: (i: Integration, scopes: string[]) => string[];
210
+ /** The link to send a person to, to connect by signing in, and the attempt to
211
+ * hold until they return. `again` signs a connection in again in place,
212
+ * asking for every scope its integration now asks for: the same row, the
213
+ * apps using it and its account, with a new grant. A brokered one is marked
214
+ * `reconnecting` until `settle` finds the new grant at the broker. `began` is
215
+ * the verified address of the person beginning it, which a brokered sign-in
216
+ * must come back from to attach at once (`settle`). */ export declare let begin: (c: Ctx, connection: Eid | NewSignIn, again?: boolean, began?: string) => Promise<{
217
+ url: string;
218
+ attempt?: Attempt & {
219
+ verifier: string;
220
+ };
221
+ }>;
222
+ /** An MCP server's sign-in page `url`, which `begin` gave for `connection`,
223
+ * opened once before a person's browser is sent there. A server that takes
224
+ * only the OAuth clients it lists can fail its page for any other:
225
+ * mcp.canva.com answers 500 to a client from Canva's Developer Portal. That
226
+ * refuses here in words, naming a built integration for the same service that
227
+ * signs in another way, instead of sending them to the server's error page. A
228
+ * page that can't be reached from here is left for the browser to try. */ export declare let opens: (c: Ctx, connection: Eid | NewSignIn, url: string) => Promise<void>;
229
+ /** What an integration signs in with, where it is kept: its broker, when it
230
+ * names one, else the OAuth client it names. `connectable` says whether
231
+ * either is enough. */ export declare let signsInWith: (vault: Vault, read: Read, i: Integration) => Promise<unknown>;
232
+ /** Connect a connection whose sign-in finished at its integration's broker,
233
+ * once it has; nothing while it has not, or for one that is not needed or
234
+ * not brokered. A broker's sign-in never returns to us, so whoever reads a
235
+ * needed connection settles it: nothing waits on the broker telling us.
236
+ *
237
+ * A broker's link opens in any browser, so the account that approved there
238
+ * may not be the beginner's. A grant attaches at once only when the account
239
+ * it names is the address `begin` was given. Any other is held, attaching
240
+ * nothing, and the connection is marked `approving` with the account that
241
+ * approved, for that account to confirm (`approve`) or decline (`decline`).
242
+ * The answer is the bundles written: the mark, when one is new, is the
243
+ * caller's cue to ask the account. A hold unanswered for a day (`HOLD`) is
244
+ * forgotten at the broker: by the run its write owes (`lapse`,
245
+ * `connection_hold_lapse`), or by a read here or a press of `approve`,
246
+ * whichever comes first. */ export declare let settle: (c: Ctx, connection: Eid) => Promise<Bundle[]>;
247
+ /** Connect the grant held for its approver (`settle`), once the account that
248
+ * approved confirms it: `id` is the broker's id the hold names. Nothing for a
249
+ * hold that is gone or names another grant. A hold past its day connects
250
+ * nothing, and is forgotten: the answer is empty then too. */ export declare let approve: (c: Ctx, connection: Eid, id: string) => Promise<Bundle[]>;
251
+ /** Forget the grant held for its approver at the broker, when the account
252
+ * that approved declines it. Nothing for a hold that is gone or names
253
+ * another grant. */ export declare let decline: (c: Ctx, connection: Eid, id: string) => Promise<Bundle[]>;
254
+ /** Whether the hold `waiting` (a connection's `approving` mark) is a day old
255
+ * at `now`: one `approve` connects nothing by. */ export declare let lapsedHold: (waiting: Comp, now: number) => boolean;
256
+ /** Exchange an installation begun at a provider. The grant is still unowned. */ export declare let redeemInstallation: (c: Ctx, i: Integration, code: string) => Promise<Tokens>;
257
+ /** Bind a redeemed installation to the workspace's chosen space. */ export declare let attachInstallation: (c: Ctx, owner: Eid, integration: string, grant: Tokens) => Promise<Bundle[]>;
258
+ /** Keep a connection's credential — a pasted key, or the grant a finished
259
+ * sign-in returns — and mark it connected. */ export declare let connect: (c: Ctx, connection: Eid | NewSignIn, given: Given, account?: string) => Promise<Bundle[]>;
260
+ /** Forget any grant held for its approver, then trash the connection. A
261
+ * broker that does not answer stops neither: the run the connection's death
262
+ * owes (`ended`) forgets what is left. Its attached credential and kept broker
263
+ * grant stay available for restoration. The
264
+ * apps that shared it are linked to a new connection. A copy that borrowed
265
+ * it is linked to one in its own space, which `owners` says. An app that asks
266
+ * each person for their own connection continues to ask them. */ export declare let disconnect: (c: Ctx, connection: Eid, owners?: Owners) => Promise<Bundle[]>;
267
+ /** What a call out sends in a sentinel's place: the pasted key, one `field` of
268
+ * several by name, or an access token, refreshed first when it is about to
269
+ * expire. A credential kept as several fields is only ever read one at a
270
+ * time. */ /**
271
+ * The bot token that speaks for a chat connection (`integration.chat`): the
272
+ * pasted key of a bot the space brought, or, for one that added the
273
+ * platform's own bot to a server, the bot of the OAuth client its
274
+ * integration signs in as. None for a connection that does not chat, is not
275
+ * connected (or not there at all), or whose bot is not kept yet.
276
+ */ export declare let botOf: (c: Ctx, connection: Eid) => Promise<string | undefined>;
277
+ /** The bot token for a connection and integration already read together. */ export declare let botFrom: (c: Ctx, b: Bundle, i: Integration | undefined) => Promise<string | undefined>;
278
+ export declare let credential: (c: Ctx, connection: Eid, field?: string) => Promise<string | undefined>;
279
+ /** Read both site sign-in fields from one version of the vaulted credential. */ export declare let loginCredential: (c: Ctx, connection: Bundle) => Promise<{
280
+ username: string;
281
+ password: string;
282
+ } | undefined>;
283
+ /** A new access token behind the same handle, after the service refused
284
+ * `stale`, unless another caller already replaced it. A grant the service
285
+ * refuses marks the connection broken; a failure on the wire leaves it be. */ export declare let refresh: (c: Ctx, connection: Eid, stale: string) => Promise<string | undefined>;
286
+ /** Send a request through a connection for the one who holds it, its
287
+ * credential as the bearer: over https to a host its integration names, and
288
+ * to no other, following no redirect. A service that refuses the access token
289
+ * (401) is asked once more with a refreshed one. */ export declare let call: (c: Ctx, connection: Eid, req: Request) => Promise<Response>;
290
+ /** A selected account's bearer and optional website session, read privately
291
+ * from its vault. The session is not handed to browser-only API doors. */ export declare let accountCredential: (ctx: Ctx, owner: Eid, integration: string, as?: string) => Promise<{
292
+ connection: Bundle;
293
+ bearer: string;
294
+ session?: string;
295
+ } | undefined>;
296
+ //# sourceMappingURL=connections.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connections.d.ts","sources":["../connections.ts"],"names":[],"mappings":"AA8DA,SAAS,KAAK,KAAK,2BAA2C;AAC9D,SAAS,SAAS,kCAAuC;AACzD,cAAc,MAAM,EAAE,IAAI,EAAE,GAAG,2BAAgC;AAK/D,SACE,KAAK,OAAO,EAKZ,KAAK,MAAM,2BACkB;AAC/B,SAME,KAAK,KAAK,6BACqB;AACjC,SACE,KAAK,KAAK,EAEV,KAAK,KAAK,EAGV,KAAK,WAAW,EAKhB,KAAK,IAAI,4BAGe;AAC1B,cAAc,KAAK,kCAAuC;AAa1D,SAA6C,KAAK,KAAK,uBAAsB;AAO7E;oCACoC,GACpC,OAAO,cAAM,qBAAqB;EAChC,YAAY,SAAS,MAAM;AAI7B;AAEA;eACe,GACf,YAAY,SAAS,WAAW,cAAc;AAE9C;wEACwE,GACxE,YAAY,OAAO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G,KACH,YAAY,KACZ,OAAO,MAAM,KACZ,QAAQ,MAAM,GAAG,SAAS,EAO5B;AAED;;;kDAGkD,GAClD,OAAO,YAAI,OACT,GAAG,KACH,YAAY,KACZ,KAAK,YACJ,QAAQ,UA8BV;AAED;wEACwE,GACxE,OAAO,YAAI,oBACT,KAAK,KACL,OAAO,KACP,aAAa,MAAM,EACnB,KAAK,MAAM,KACV;EACC,YAAY;EAAQ,QAAQ,MAAM;EAAE,UAAU,MAAM;IAAK,SAAS,EAiBrE"}
@@ -0,0 +1,15 @@
1
+ import { type Handlers } from "@yaks/effects";
2
+ import { type Bundle, type Graph } from "@yaks/graph";
3
+ import type { Sealed } from "@yaks/secrets";
4
+ import { type Host as Giving } from "./given.js";
5
+ /** What the handlers are given: the graph, its vault, the keepers the host
6
+ * lends, and its clock. */ export type Host = Giving & {
7
+ graph: Graph;
8
+ now?: () => number;
9
+ };
10
+ /** Record broker cleanup before permanently removing a saved version. */ export declare let purgingCredential: (connection: string, version: string, saved: Sealed | undefined, broker: unknown) => Bundle[];
11
+ /** The built integrations installed, whenever a process starts working the
12
+ * effects, a given key kept, checked and its asks completed, a grant held
13
+ * for its approver forgotten once its day is out, and what a connection held
14
+ * at the broker forgotten once it dies. */ export declare let effects: (host: Host) => Handlers;
15
+ //# sourceMappingURL=effects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effects.d.ts","sources":["../effects.ts"],"names":[],"mappings":"AAyBA,SAA2B,KAAK,QAAQ,6BAAkC;AAC1E,SAAS,KAAK,MAAM,EAAa,KAAK,KAAK,2BAAsC;AAEjF,cAAc,MAAM,6BAAkC;AAGtD,SAAgB,KAAK,QAAQ,MAAM,qBAAoB;AAKvD;yBACyB,GACzB,YAAY,OAAO;EAAW,OAAO;EAAO,YAAY,MAAM;;AAqB9D,uEAAuE,GACvE,OAAO,YAAI,oBACT,YAAY,MAAM,EAClB,SAAS,MAAM,EACf,OAAO,SAAS,SAAS,EACzB,QAAQ,OAAO,KACd,SAYF;AA0BD;;;yCAGyC,GACzC,OAAO,YAAI,UAAW,MAAM,SAAO,SAoDjC"}
@@ -0,0 +1,17 @@
1
+ /** One thing a person gives to connect a pasted-key integration: what an app
2
+ * reads it by, what the page asks for it by, whether it is typed in the open,
3
+ * as a username or a region is, and what it looks like. */ export type Field = {
4
+ name: string;
5
+ label: string;
6
+ shown?: boolean;
7
+ example?: string;
8
+ };
9
+ /** The one field of an integration that declares none: its key. */ export declare let KEY: Field;
10
+ /** The field names shared by site sign-ins and their vault credentials. */ export declare let loginFields: (fields: Field[]) => boolean;
11
+ /** What a person gives to connect a pasted-key integration, in the order the
12
+ * page asks for it: the fields it declares, or its one key, shaped as the
13
+ * integration says. */ export declare let fieldsOf: (i?: {
14
+ fields?: Field[];
15
+ example?: string;
16
+ }) => Field[];
17
+ //# sourceMappingURL=field.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field.d.ts","sources":["../field.ts"],"names":[],"mappings":"AAIA;;yDAEyD,GACzD,YAAY;EACV,MAAM,MAAM;EACZ,OAAO,MAAM;EACb,QAAQ,OAAO;EACf,UAAU,MAAM;;AAGlB,iEAAiE,GACjE,OAAO,YAAI,KAAK,MAAqC;AAErD,yEAAyE,GACzE,OAAO,YAAI,cAAe,QAAQ,YAAU,OAAO,CAET;AAE1C;;qBAEqB,GACrB,OAAO,YAAI,WACT;EAAM,SAAS;EAAS,UAAU,MAAM;MACvC,QAGsD"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The box a key is pasted in, wherever a person is asked for one: a task
3
+ * asking for a connection (`asks`), a connections page, a sign-in page. It is
4
+ * plain markup for a server's page and a component for a live one, shared by
5
+ * every host; what saving does is the host's (`save`), and a page writes
6
+ * {@link pasted} through the graph, which seals the value out of the write.
7
+ * The key is never prefilled, drawn back, or kept in the page's state.
8
+ *
9
+ * @module
10
+ */ import { type JSX, type ReactNode as Kids } from "@types/react";
11
+ import { type Field, fieldsOf, KEY, loginFields } from "./field.js";
12
+ import type { Pasted } from "./paste.js";
13
+ export { type Pasted, pasted } from "./paste.js";
14
+ export { type Field, fieldsOf, KEY, loginFields };
15
+ /** The box a key is pasted in and the button that saves it, one line under
16
+ * its label; or, for a service that asks for several fields, a box for each
17
+ * under its own label, masked unless the field is shown, and the button under
18
+ * them. Each box shows what its field looks like, where the integration says,
19
+ * and a row of dots where it does not. {@link givenOf} reads what was typed. */ export declare let keyBox: (id: string, label: Kids, send: Kids, hint?: Kids, fields?: Field[]) => Kids;
20
+ /** What a person typed into a {@link keyBox}, read from its form by name
21
+ * (a posted `FormData`, or the boxes themselves): the one key, or each field
22
+ * by name; or what the page says when one was left empty.
23
+ *
24
+ * ```ts
25
+ * import { assertEquals } from '@std/assert'
26
+ * let form = new FormData()
27
+ * form.set('key', ' k ')
28
+ * assertEquals(givenOf(form, [{ name: 'key', label: 'Key' }]), { key: 'k' })
29
+ * assertEquals(givenOf(new FormData(), [{ name: 'key', label: 'API key' }]), 'Enter the API key.')
30
+ * ```
31
+ */ export declare let givenOf: (form: {
32
+ get: (name: string) => unknown;
33
+ }, fields: Field[]) => Pasted | string;
34
+ /** A connection a person is asked to paste a key for, as a live page draws
35
+ * it: what it is for, how to get the key (`howTo`, drawn by the host), the
36
+ * box, anything the host adds under it (`children`), and what came of
37
+ * saving. A connection whose last key the service refused (`broken`) asks
38
+ * again; once connected, only what came of saving stays, and no box. `save`
39
+ * keeps what was given and resolves once the write is answered; what the page
40
+ * says after is its own. */ export declare let KeyForm: ({}: {
41
+ id: string;
42
+ title: Kids;
43
+ fields: Field[];
44
+ status: string;
45
+ howTo?: Kids;
46
+ save: (given: Pasted) => Promise<unknown>;
47
+ /** more the host draws inside the form, under the box */ children?: Kids;
48
+ }) => JSX.Element | null;
49
+ //# sourceMappingURL=form.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form.d.ts","sources":["../form.ts"],"names":[],"mappings":"AAAA;;;;;;;;;CASC,GACyC,SAExC,KAAK,GAAG,EACR,KAAK,aAAa,IAAI,uBAEC;AAEzB,SAAS,KAAK,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,WAAW,qBAAoB;AACnE,cAAc,MAAM,qBAAoB;AAExC,SAAS,KAAK,MAAM,EAAE,MAAM,qBAAoB;AAChD,SAAS,KAAK,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,WAAW,GAAE;AAWjD;;;;8EAI8E,GAC9E,OAAO,YAAI,SACT,IAAI,MAAM,EACV,OAAO,MACP,MAAM,MACN,OAAM,MACN,SAAQ,YACP,KA+BF;AAED;;;;;;;;;;;CAWC,GACD,OAAO,YAAI,UACT;EAAQ,MAAM,MAAM,MAAM,KAAK,OAAO;GACtC,QAAQ,YACP,SAAS,MAAM,CAUjB;AAED;;;;;;0BAM0B,GAC1B,OAAO,YAAI,UACT;EACE,IAAI,MAAM;EACV,OAAO;EACP,QAAQ;EACR,QAAQ,MAAM;EACd,QAAQ;EACR,OAAO,OAAO,WAAW,QAAQ,OAAO;EACxC,uDAAuD,GACvD,WAAW;CACZ,KACA,IAAI,UAAU,IAAI,CAwDpB"}
@@ -0,0 +1,10 @@
1
+ import type { Keeper } from "@yaks/host/keepers";
2
+ import { type Vault } from "@yaks/secrets";
3
+ import { type Ctx } from "./connections.js";
4
+ /** What it needs of the host: its graph, its vault, and the keepers it lends. */ export type Host = {
5
+ graph: Ctx['graph'];
6
+ vault: Vault;
7
+ keepers?: Readonly<Record<string, Keeper>>;
8
+ fetch?: typeof fetch;
9
+ };
10
+ //# sourceMappingURL=given.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"given.d.ts","sources":["../given.ts"],"names":[],"mappings":"AAcA,cAAc,MAAM,kCAA8C;AAElE,SAAiB,KAAK,KAAK,6BAAkC;AAC7D,SAAe,KAAK,GAAG,2BAA0B;AAIjD,+EAA+E,GAC/E,YAAY;EACV,OAAO,IAAI;EACX,OAAO;EACP,UAAU,SAAS,OAAO,MAAM,EAAE;EAClC,eAAe"}
@@ -0,0 +1,15 @@
1
+ import type { Bundle } from "@yaks/graph";
2
+ import type { Reply } from "@yaks/tools";
3
+ import type { Read } from "./integrations.js";
4
+ /** What this needs of the host: a read of its graph. */ export type Host = {
5
+ graph: {
6
+ read: Read;
7
+ };
8
+ };
9
+ /** The integrations the connections among `bundles` go through, as the graph
10
+ * holds them, but for any `bundles` already carry: what a person and their
11
+ * agent read beside a connection, how to get its key among it. A `uses` link
12
+ * whose connection is not among them is read to find which. */ export declare let through: (read: Read, bundles: Bundle[]) => Promise<Bundle[]>;
13
+ /** Beside a direct call's answer: the integrations its connections go
14
+ * through, but for those it already carries. */ export declare let reply: (host: Host) => Reply;
15
+ //# sourceMappingURL=graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.d.ts","sources":["../graph.ts"],"names":[],"mappings":"AAWA,cAAc,MAAM,2BAA2C;AAC/D,cAAc,KAAK,2BAAgC;AACnD,cAAc,IAAI,4BAA2B;AAG7C,sDAAsD,GACtD,YAAY;EAAS;IAAS,MAAM;;;AAEpC;;;6DAG6D,GAC7D,OAAO,YAAI,UACT,MAAM,MACN,SAAS,aACR,QAAQ,UAoBV;AAED;8CAC8C,GAC9C,OAAO,YAAI,QAAS,MAAM,SAAO,MACC"}
@@ -0,0 +1,4 @@
1
+ import type { Bundle, Storage } from "@yaks/graph";
2
+ /** The most recent archived connection that held a credential for each id.
3
+ * A snapshot from before sign-in can sort first when writes share a timestamp. */ export declare let connectionHistory: (trash: NonNullable<Storage['trash']>, eids: string[]) => Promise<Map<string, Bundle>>;
4
+ //# sourceMappingURL=history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.d.ts","sources":["../history.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,EAAQ,OAAO,2BAAgC;AAInE;gFACgF,GAChF,OAAO,YAAI,oBACT,OAAO,YAAY,QAAQ,WAC3B,MAAM,MAAM,OACX,QAAQ,IAAI,MAAM,EAAE,SAsBtB"}
@@ -0,0 +1,9 @@
1
+ import type { Eid } from "@yaks/graph/bundle";
2
+ export declare let INTEGRATION: string;
3
+ export declare let CONNECTION: string;
4
+ export declare let USES: string;
5
+ export declare let ASKS: string;
6
+ /** The mark on a connection whose brokered grant is held for the account
7
+ * that approved it (@yaks/connections `settle`). */ export declare let APPROVING: string;
8
+ /** An integration's entity: one name identifies one integration. */ export declare let integrationEid: (name: string) => Eid;
9
+ //# sourceMappingURL=identity.d.ts.map