@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
package/brokers.ts ADDED
@@ -0,0 +1,423 @@
1
+ // Brokers: services that hold an OAuth grant for us and hand back a fresh
2
+ // access token. A broker signs a person in through its own app with the
3
+ // service (Nango's CASA-verified Google app, for Gmail), keeps the refresh
4
+ // token, and answers the current access token when asked. Our egress still
5
+ // sends that token straight to the integration's hosts: a broker is a source
6
+ // of credentials, never a proxy.
7
+ //
8
+ // An integration names its broker as data (`integration.broker{name,
9
+ // integration}`), and a connection made through one says so
10
+ // (`connection.broker`), so swapping an integration's broker changes no
11
+ // caller and leaves every connection working through what made it. A broker
12
+ // is implemented once, here, and each integration it serves is a row. Its key
13
+ // is the secret `broker <name>`, kept the way an OAuth client is.
14
+
15
+ import { reveal, sealed, type Vault } from '@yaks/secrets'
16
+ import type { Bundle } from 'jsr:@yaks/graph@0.2.36'
17
+ import type { Field } from './integrations.ts'
18
+
19
+ /** What a broker answers for a connection: its access token, when it
20
+ * expires (epoch milliseconds), what it grants, and an id token or address
21
+ * naming the account where the broker knows one. */
22
+ export type Grant = {
23
+ access_token: string
24
+ expires_at?: number
25
+ scopes?: string[]
26
+ id_token?: string
27
+ account?: string
28
+ }
29
+
30
+ /** A broker's refusal. `refused` is the broker saying the grant is gone or
31
+ * revoked, which means connect again; anything else is a failure on the wire
32
+ * or of our own key. */
33
+ export class BrokerError extends Error {
34
+ status: number
35
+ refused: boolean
36
+ constructor(status: number, message: string) {
37
+ super(message)
38
+ this.name = 'BrokerError'
39
+ this.status = status
40
+ this.refused = status >= 400 && status < 500 &&
41
+ ![401, 403, 429].includes(status)
42
+ }
43
+ }
44
+
45
+ /** A service a broker can connect, as its catalog lists it: what the broker
46
+ * calls it, what a person calls it, the address of its logo (an SVG), the
47
+ * kinds of service it is, and the API hosts a credential for it goes to
48
+ * (none where they depend on the account). `connects` is how: signing in
49
+ * through the broker's own app with the service, giving the broker an OAuth
50
+ * client of the person's own, or a key, as the `fields` it names (none is
51
+ * one key). `keyGuide` links to where a person can get the credential.
52
+ * `popular` is one the broker features. */
53
+ export type Listing = {
54
+ name: string
55
+ title: string
56
+ logo: string
57
+ categories: string[]
58
+ hosts: string[]
59
+ connects: 'signin' | 'client' | 'key'
60
+ fields?: Field[]
61
+ keyGuide?: string
62
+ popular?: boolean
63
+ }
64
+
65
+ /** A sign-in that finished at a broker: the broker's own id for it, and the
66
+ * address of the person who began it, as `begin` was told. */
67
+ export type Found = { id: string; began?: string }
68
+
69
+ /** One broker, for the integration it calls `integration`, and our
70
+ * connection's eid as the tag it finds a sign-in by. */
71
+ export type Broker = {
72
+ /** every service it can connect: one it signs in to and hands back an
73
+ * access token for, or one reached with a plain key */
74
+ catalog(): Promise<Listing[]>
75
+ /** make ready to sign people in to the service it calls `integration`, as
76
+ * `listing` says it connects; one already ready is left as it is */
77
+ enable(integration: string, connects: Listing['connects']): Promise<void>
78
+ /** the link a person follows to sign in for connection `eid`, begun by
79
+ * the person whose verified address is `began` */
80
+ begin(
81
+ integration: string,
82
+ eid: string,
83
+ began?: string,
84
+ scopes?: string[],
85
+ ): Promise<string>
86
+ /** the newest sign-in made for `eid`, once one finished */
87
+ found(integration: string, eid: string): Promise<Found | undefined>
88
+ /** every sign-in it holds for `eid`, newest first */
89
+ grants(integration: string, eid: string): Promise<Found[]>
90
+ /** the grant's current token, refreshed by the broker when it is due, or
91
+ * at once with `fresh` */
92
+ grant(integration: string, id: string, fresh?: boolean): Promise<Grant>
93
+ /** end the broker's connection; one already gone is no failure */
94
+ forget(integration: string, id: string): Promise<void>
95
+ }
96
+
97
+ type Fetch = typeof fetch
98
+
99
+ let NANGO = 'https://api.nango.dev'
100
+
101
+ // How Nango says a service is reached, as what a connection through it is:
102
+ // a sign-in its own app makes (a Nango-managed OAuth app), one with the
103
+ // person's own OAuth client, or a key. Nango hands back an access token for
104
+ // the first two, and a key is ours to keep. Any other way is left out.
105
+ let CONNECTS: Record<string, Listing['connects']> = {
106
+ OAUTH2: 'signin',
107
+ OAUTH2_CC: 'client',
108
+ API_KEY: 'key',
109
+ BASIC: 'key',
110
+ }
111
+
112
+ // Nango's own categories that say nothing of what a service is.
113
+ let UNSAID = new Set(['popular', 'other', 'mcp'])
114
+
115
+ // A credential's name as a field's: Nango's apiKey is api_key.
116
+ let snake = (name: string) =>
117
+ name.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`).replace(/^_/, '')
118
+
119
+ // A field typed in the open, where its name and its label both say so.
120
+ let OPEN = /^(username|user|email|region|account|subdomain)$/
121
+
122
+ type Provider = {
123
+ name: string
124
+ display_name: string
125
+ logo_url?: string
126
+ categories?: string[]
127
+ auth_mode?: string
128
+ proxy?: { base_url?: string }
129
+ docs?: string
130
+ docs_connect?: string
131
+ credentials?: Record<string, { title?: string }>
132
+ }
133
+
134
+ // Direct key pages where we know them. The broker also publishes guides
135
+ // about getting the credential, separately from its field labels.
136
+ let KEY_PAGES = new Map([
137
+ ['resend', 'https://resend.com/api-keys'],
138
+ ])
139
+
140
+ /** A Nango provider (GET /providers) as the listing it is, or none where
141
+ * Nango hands back nothing a connection here can use: a sign-in needs an app
142
+ * of Nango's own with the service, which only the providers `managed` names
143
+ * have. Its hosts are its API's, none where the account names them
144
+ * (`${connectionConfig.subdomain}`). */
145
+ export let listingOf = (
146
+ p: Provider,
147
+ managed: ReadonlySet<string>,
148
+ ): Listing | undefined => {
149
+ let connects = CONNECTS[p.auth_mode ?? '']
150
+ if (!connects || !p.name || !p.display_name) return undefined
151
+ if (connects == 'signin' && !managed.has(p.name)) return undefined
152
+ let base = p.proxy?.base_url ?? ''
153
+ let host = !base.includes('${') && URL.canParse(base)
154
+ ? new URL(base).hostname
155
+ : ''
156
+ let given = connects == 'key' ? Object.entries(p.credentials ?? {}) : []
157
+ let fields = given.map(([name, f]): Field => {
158
+ let label = f.title || name
159
+ let shown = OPEN.test(name) && !/key|secret|token|password/i.test(label)
160
+ return { name: snake(name), label, ...shown ? { shown } : {} }
161
+ })
162
+ let keyGuide = connects == 'key'
163
+ ? KEY_PAGES.get(p.name) || p.docs_connect || p.docs
164
+ : undefined
165
+ return {
166
+ name: p.name,
167
+ title: p.display_name,
168
+ logo: p.logo_url ?? '',
169
+ categories: (p.categories ?? []).filter((c) => !UNSAID.has(c)),
170
+ hosts: host ? [host] : [],
171
+ connects,
172
+ ...fields.length > 1 ? { fields } : {},
173
+ ...keyGuide ? { keyGuide } : {},
174
+ ...p.categories?.includes('popular') ? { popular: true } : {},
175
+ }
176
+ }
177
+
178
+ // Where a logo a broker names is also kept: Nango's CDN can answer a missing
179
+ // one with its web app's page, and cache that error for hours, so the same
180
+ // file in Nango's repository stands behind it.
181
+ let NANGO_LOGOS = 'https://app.nango.dev/images/template-logos/'
182
+ let MIRRORS: [from: string, to: string][] = [[
183
+ NANGO_LOGOS,
184
+ 'https://raw.githubusercontent.com/NangoHQ/nango/master/packages/webapp/public/images/template-logos/',
185
+ ]]
186
+
187
+ // These example services are pictured on public pages even on deployments
188
+ // with no broker catalog. Their artwork is available without broker access.
189
+ let EXAMPLE_LOGOS = new Set([
190
+ 'airtable',
191
+ 'calendly',
192
+ 'google-sheet',
193
+ 'hubspot',
194
+ 'mailchimp',
195
+ 'notion',
196
+ 'quickbooks',
197
+ ])
198
+
199
+ export let exampleLogo = (name: string): string | undefined =>
200
+ EXAMPLE_LOGOS.has(name) ? NANGO_LOGOS + name + '.svg' : undefined
201
+
202
+ // Where Nango says which providers it has an OAuth app of its own with: its
203
+ // guide's list, the one place it publishes them (its API says so only to its
204
+ // dashboard).
205
+ let MANAGED =
206
+ 'https://raw.githubusercontent.com/NangoHQ/nango/master/docs/guides/auth/overview.mdx'
207
+
208
+ /** The providers Nango's guide lists as having an OAuth app of Nango's own:
209
+ * the last part of each link in its list of them. */
210
+ /// managedIn('<a id="apis-with-a-nango-managed-oauth-app"></a>\n- [Gmail](/api-integrations/google-mail)\n- [Box](/integrations/all/box)\n</Accordion>\n- [Other](/x/other)') -> new Set(['google-mail', 'box'])
211
+ export let managedIn = (guide: string): Set<string> => {
212
+ let list = guide.split('apis-with-a-nango-managed-oauth-app')[1]
213
+ ?.split('</Accordion>')[0] ?? ''
214
+ return new Set(
215
+ [...list.matchAll(/\]\(([^)\s]+)\)/g)]
216
+ .map((m) => m[1].replace(/\/$/, '').split('/').at(-1)!),
217
+ )
218
+ }
219
+
220
+ /** Every address a listing's logo may be fetched from, its own first. */
221
+ /// logoSources('https://logos.example/hub.svg') -> ['https://logos.example/hub.svg']
222
+ export let logoSources = (at: string): string[] => [
223
+ at,
224
+ ...MIRRORS.filter(([from]) => at.startsWith(from))
225
+ .map(([from, to]) => to + at.slice(from.length)),
226
+ ]
227
+
228
+ let strs = (v: unknown): string[] =>
229
+ Array.isArray(v)
230
+ ? v.map(String)
231
+ : typeof v == 'string'
232
+ ? v.split(/[\s,]+/).filter(Boolean)
233
+ : []
234
+
235
+ // Nango's managed providers, from its guide; a guide that can't be read
236
+ // fails the catalog, so the list kept before stands.
237
+ let guide = async (fetcher: Fetch) => {
238
+ let res = await fetcher(MANAGED, { signal: AbortSignal.timeout(30_000) })
239
+ if (!res.ok) throw new Error(`Nango's guide answered ${res.status}`)
240
+ let managed = managedIn(await res.text())
241
+ if (!managed.size) throw new Error("Nango's guide lists no managed app")
242
+ return managed
243
+ }
244
+
245
+ /** Nango (nango.dev), reached with an environment's secret key. */
246
+ export let nango = (key: string, fetcher: Fetch = fetch): Broker => {
247
+ let ask = async (path: string, init: RequestInit = {}) => {
248
+ let res = await fetcher(`${NANGO}${path}`, {
249
+ ...init,
250
+ headers: {
251
+ authorization: `Bearer ${key}`,
252
+ 'content-type': 'application/json',
253
+ accept: 'application/json',
254
+ },
255
+ redirect: 'manual',
256
+ signal: AbortSignal.timeout(30_000),
257
+ })
258
+ let body = await res.json().catch(() => ({})) as Record<string, unknown>
259
+ if (!res.ok) {
260
+ let error = body.error as Record<string, unknown> | string | undefined
261
+ let said = typeof error == 'string'
262
+ ? error
263
+ : error?.message ?? error?.code
264
+ throw new BrokerError(
265
+ res.status,
266
+ `Nango refused ${init.method ?? 'GET'} ${
267
+ path.split('?')[0]
268
+ }: ${res.status}${said ? ` ${said}` : ''}`,
269
+ )
270
+ }
271
+ return body
272
+ }
273
+ let of = (integration: string) =>
274
+ `provider_config_key=${encodeURIComponent(integration)}`
275
+ let broker: Broker = {
276
+ catalog: async () => {
277
+ let [{ data }, managed] = await Promise.all([
278
+ ask('/providers') as Promise<{ data?: Provider[] }>,
279
+ guide(fetcher),
280
+ ])
281
+ return (data ?? []).flatMap((p) => listingOf(p, managed) ?? [])
282
+ },
283
+ enable: async (integration, connects) => {
284
+ let at = `/integrations/${encodeURIComponent(integration)}`
285
+ try {
286
+ await ask(at)
287
+ return
288
+ } catch (e) {
289
+ if (!(e instanceof BrokerError && e.status == 404)) throw e
290
+ }
291
+ // A sign-in goes through Nango's own app with the service; a client
292
+ // of the person's own, or a key, is given when they connect.
293
+ await ask('/integrations', {
294
+ method: 'POST',
295
+ body: JSON.stringify({
296
+ unique_key: integration,
297
+ provider: integration,
298
+ ...connects == 'signin'
299
+ ? { credentials: { type: 'NANGO_MANAGED' } }
300
+ : {},
301
+ }),
302
+ })
303
+ },
304
+ // Nango's link opens in any browser, so whoever follows it may not be
305
+ // who began it. The session's tags name both the connection and the
306
+ // beginner's address (Nango's `end_user_email`), and each connection made
307
+ // through it carries them back.
308
+ begin: async (integration, eid, began, scopes) => {
309
+ let made = await ask('/connect/sessions', {
310
+ method: 'POST',
311
+ body: JSON.stringify({
312
+ tags: { end_user_id: eid, ...began ? { end_user_email: began } : {} },
313
+ allowed_integrations: [integration],
314
+ ...scopes?.length
315
+ ? {
316
+ integrations_config_defaults: {
317
+ [integration]: {
318
+ connection_config: {
319
+ oauth_scopes_override: scopes.join(','),
320
+ },
321
+ },
322
+ },
323
+ }
324
+ : {},
325
+ }),
326
+ })
327
+ let link = ((made.data ?? made) as Record<string, unknown>).connect_link
328
+ if (typeof link != 'string') {
329
+ throw new Error('Nango answered no connect link')
330
+ }
331
+ return link
332
+ },
333
+ grants: async (integration, eid) => {
334
+ let q = new URLSearchParams({
335
+ 'tags[end_user_id]': eid,
336
+ integrationId: integration,
337
+ })
338
+ let { connections } = await ask(`/connections?${q}`) as {
339
+ connections?: Record<string, unknown>[]
340
+ }
341
+ let tags = (c: Record<string, unknown>) =>
342
+ (c.tags ?? {}) as Record<string, unknown>
343
+ return (connections ?? [])
344
+ .filter((c) =>
345
+ c.provider_config_key == integration && tags(c).end_user_id == eid
346
+ )
347
+ .sort((a, b) => String(b.created).localeCompare(String(a.created)))
348
+ .map((c) => {
349
+ let began = tags(c).end_user_email
350
+ return {
351
+ id: String(c.connection_id),
352
+ ...typeof began == 'string' ? { began: began.toLowerCase() } : {},
353
+ }
354
+ })
355
+ },
356
+ found: async (integration, eid) =>
357
+ (await broker.grants(integration, eid))[0],
358
+ grant: async (integration, id, fresh) => {
359
+ let c = await ask(
360
+ `/connections/${encodeURIComponent(id)}?${of(integration)}${
361
+ fresh ? '&force_refresh=true' : ''
362
+ }`,
363
+ )
364
+ let creds = (c.credentials ?? {}) as Record<string, unknown>
365
+ let raw = (creds.raw ?? {}) as Record<string, unknown>
366
+ if (typeof creds.access_token != 'string') {
367
+ throw new Error(`Nango holds no access token for ${integration}`)
368
+ }
369
+ let at = Date.parse(String(creds.expires_at ?? ''))
370
+ let config = {
371
+ ...c.metadata as Record<string, unknown> ?? {},
372
+ ...c.connection_config as Record<string, unknown> ?? {},
373
+ }
374
+ let account = [config.emailAddress, config.email]
375
+ .find((a) => typeof a == 'string' && a.includes('@')) as
376
+ | string
377
+ | undefined
378
+ return {
379
+ access_token: creds.access_token,
380
+ ...isNaN(at) ? {} : { expires_at: at },
381
+ ...raw.scope ? { scopes: strs(raw.scope) } : {},
382
+ ...typeof raw.id_token == 'string' ? { id_token: raw.id_token } : {},
383
+ ...account ? { account: account.toLowerCase() } : {},
384
+ }
385
+ },
386
+ forget: async (integration, id) => {
387
+ try {
388
+ await ask(`/connections/${encodeURIComponent(id)}?${of(integration)}`, {
389
+ method: 'DELETE',
390
+ })
391
+ } catch (e) {
392
+ if (!(e instanceof BrokerError && e.status == 404)) throw e
393
+ }
394
+ },
395
+ }
396
+ return broker
397
+ }
398
+
399
+ /** The brokers this package implements, by the name an integration gives. */
400
+ export let BROKERS: Record<string, (key: string, f?: Fetch) => Broker> = {
401
+ nango,
402
+ }
403
+
404
+ // The name a broker's key is kept under among the graph's secrets.
405
+ export let brokerSecret = (name: string) => `broker ${name}`
406
+
407
+ /** The bundle that keeps a broker's key: the vault holds it, and the graph
408
+ * its handle. */
409
+ export let brokerKey = (name: string, key: string): Bundle =>
410
+ sealed(brokerSecret(name), key)
411
+
412
+ /** The broker named `name`, ready to ask, once its key is kept; none while it
413
+ * is not, or for a name this package does not implement. */
414
+ export let brokerOf = async (
415
+ vault: Vault,
416
+ name: string,
417
+ fetcher?: Fetch,
418
+ ): Promise<Broker | undefined> => {
419
+ let make = BROKERS[name]
420
+ if (!make) return undefined
421
+ let key = await reveal(vault, brokerSecret(name), { env: () => undefined })
422
+ return key ? make(key, fetcher) : undefined
423
+ }
package/canva.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "canva",
3
+ "visitors": "never",
4
+ "title": "Canva",
5
+ "tagline": "Your Canva designs: found, made, filled in and exported.",
6
+ "site": "https://www.canva.com",
7
+ "image": "https://app.nango.dev/images/template-logos/canva.svg",
8
+ "categories": [
9
+ "design"
10
+ ],
11
+ "authorize": "https://www.canva.com/api/oauth/authorize",
12
+ "token": "https://api.canva.com/rest/v1/oauth/token",
13
+ "client": "canva",
14
+ "scopes": [
15
+ "profile:read",
16
+ "design:meta:read",
17
+ "design:content:read",
18
+ "design:content:write",
19
+ "brandtemplate:meta:read",
20
+ "brandtemplate:content:read",
21
+ "asset:read"
22
+ ],
23
+ "hosts": [
24
+ "api.canva.com"
25
+ ],
26
+ "api": {
27
+ "base": "https://api.canva.com/rest/v1",
28
+ "docs": "https://www.canva.dev/docs/connect/api-reference/"
29
+ },
30
+ "userinfo": "https://api.canva.com/rest/v1/users/me/profile",
31
+ "account": "profile.display_name"
32
+ }
package/catalog.js ADDED
@@ -0,0 +1,178 @@
1
+ // The catalog: every service a person can be offered, whether or not anything
2
+ // is connected to it yet. It is the built integrations (./integrations.ts)
3
+ // and every service a broker lists (./brokers.ts `catalog`), as one list of
4
+ // offers, each the integration it would be once someone connects it.
5
+ //
6
+ // Direct comes first. A built integration stands in for the broker's listing
7
+ // of the same service: one by its name, and one whose broker is the listing
8
+ // (Gmail for Nango's google-mail). A listing reached with a key is direct
9
+ // too: the key is kept here and sent only to the listing's hosts, so the
10
+ // broker is never asked. Only a service signed in to through the broker's
11
+ // own app, or with a client of the person's own, is brokered. A listing whose
12
+ // hosts depend on the account names none, and is left out until it can say
13
+ // them.
14
+ //
15
+ // Every offer can have its own integration row before anyone connects it.
16
+ // Connecting marks it built only once its broker is ready (`adopted`).
17
+ import { cmp } from "@yaks/fp";
18
+ import { standIn, visitorPolicy } from "./integrations.js";
19
+ // A kind of service as a person reads it: "crm" as CRM, "dev-tools" as Dev
20
+ // tools.
21
+ let WORDS = {
22
+ crm: 'CRM',
23
+ hr: 'HR',
24
+ ats: 'Hiring',
25
+ erp: 'ERP',
26
+ iam: 'Identity',
27
+ cms: 'CMS'
28
+ };
29
+ /// kind('dev-tools') -> 'Dev tools'
30
+ /// kind('crm') -> 'CRM'
31
+ export let kind = (category)=>WORDS[category] ?? category.charAt(0).toUpperCase() + category.slice(1).replaceAll('-', ' ');
32
+ /** Whether an integration can take credential help from the broker catalog. */ export let catalogKey = (i)=>!i.owner && i.connects == 'key' && Array.isArray(i.categories);
33
+ /** Instructions someone wrote, ignoring old imports of credential field
34
+ * descriptions from the broker catalog. */ export let keyHelp = (i)=>{
35
+ let source = i?.instructions ?? '';
36
+ return !source.trim() || i && catalogKey(i) && /^(?:- \*\*[^\n]+?\*\*:|\*\*[^\n]+?\*\*\r?\n[ \t]*:)/.test(source.trimStart()) ? '' : source;
37
+ };
38
+ /** A link to the credential page or guide, for a listing with no written
39
+ * steps. */ export let keyGuide = (l)=>{
40
+ let url = l?.keyGuide && URL.canParse(l.keyGuide) && new URL(l.keyGuide);
41
+ return l?.connects == 'key' && url && url.protocol == 'https:' && !url.username && !url.password ? `[Where to get your key](<${url.href}>)` : '';
42
+ };
43
+ /** The integration a broker's listing would be: brokered where it is signed
44
+ * in to through the broker, a pasted key where it is reached with one. */ export let offerOf = (l, broker)=>{
45
+ let instructions = keyGuide(l);
46
+ let i = {
47
+ name: l.name,
48
+ title: l.title,
49
+ tagline: l.categories.slice(0, 3).map(kind).join(' · '),
50
+ hosts: l.hosts,
51
+ connects: l.connects,
52
+ ...l.connects == 'key' ? {
53
+ ...l.fields ? {
54
+ fields: l.fields
55
+ } : {}
56
+ } : {
57
+ broker: {
58
+ name: broker,
59
+ integration: l.name
60
+ }
61
+ },
62
+ ...instructions ? {
63
+ instructions
64
+ } : {},
65
+ categories: l.categories,
66
+ ...l.logo ? {
67
+ image: l.logo
68
+ } : {},
69
+ ...l.popular ? {
70
+ featured: true
71
+ } : {}
72
+ };
73
+ return {
74
+ ...i,
75
+ visitors: visitorPolicy(i)
76
+ };
77
+ };
78
+ /** The catalog: the built integrations a person may be offered unasked (none
79
+ * in its service's testing mode), each featured, and every listing of
80
+ * `broker` that no built one stands in for and that names its hosts, featured
81
+ * where the broker features it, by title. A built integration takes the kinds
82
+ * of the listing it stands in for. */ export let catalogue = (integrations, listings, broker)=>{
83
+ let built = integrations.filter((i)=>i.built);
84
+ let by = new Map(listings.map((l)=>[
85
+ l.name,
86
+ l
87
+ ]));
88
+ let standing = (i)=>by.get(i.broker?.name == broker ? i.broker.integration : i.name) ?? by.get(i.name);
89
+ let taken = (name)=>!!standIn(built, name, broker);
90
+ // A described one the broker signs in to is offered only while the broker
91
+ // lists it: it can connect nothing else.
92
+ let pending = integrations.filter((i)=>!i.built && !i.owner && !i.testing && i.hosts.length && Array.isArray(i.categories) && !taken(i.name) && (i.broker?.name != broker || by.has(i.broker.integration))).map((i)=>({
93
+ ...i,
94
+ visitors: visitorPolicy(i),
95
+ categories: i.categories ?? []
96
+ }));
97
+ let described = new Set(pending.map((i)=>i.name));
98
+ return [
99
+ ...built.filter((i)=>!i.testing).map((i)=>{
100
+ let l = standing(i);
101
+ return {
102
+ ...i,
103
+ visitors: visitorPolicy(i),
104
+ categories: i.categories ?? l?.categories ?? [],
105
+ ...!i.logo && !i.image && l?.logo ? {
106
+ image: l.logo
107
+ } : {},
108
+ featured: true
109
+ };
110
+ }),
111
+ ...pending,
112
+ ...listings.filter((l)=>!taken(l.name) && !described.has(l.name) && l.hosts.length).map((l)=>offerOf(l, broker))
113
+ ].sort((a, b)=>cmp((a.title || a.name).toLowerCase(), (b.title || b.name).toLowerCase()));
114
+ };
115
+ // How well an offer answers one word: its title starting with it, a word of
116
+ // its title starting with it, its name or kinds holding it, or not at all.
117
+ let fit = (o, word)=>{
118
+ let title = (o.title || o.name).toLowerCase();
119
+ if (title.startsWith(word)) return 3;
120
+ if (title.split(/[^a-z0-9]+/).some((w)=>w.startsWith(word))) return 2;
121
+ return [
122
+ o.name,
123
+ ...o.categories,
124
+ ...o.categories.map(kind),
125
+ o.tagline ?? ''
126
+ ].some((t)=>t.toLowerCase().includes(word)) ? 1 : 0;
127
+ };
128
+ /** The offers that hold every word of `words`, best first: by how well each
129
+ * word fits, then featured, then by title. No words is every offer. */ export let find = (offers, words)=>{
130
+ let terms = words.toLowerCase().split(/\s+/).filter(Boolean);
131
+ return offers.map((o)=>({
132
+ o,
133
+ score: terms.map((t)=>fit(o, t))
134
+ })).filter(({ score })=>score.every((s)=>s > 0)).sort((a, b)=>b.score.reduce((n, s)=>n + s, 0) - a.score.reduce((n, s)=>n + s, 0) || Number(!!b.o.featured) - Number(!!a.o.featured)).map(({ o })=>o);
135
+ };
136
+ /** The kinds of service the catalog holds, the most common first. */ export let kinds = (offers)=>{
137
+ let n = new Map();
138
+ for (let c of offers.flatMap((o)=>o.categories)){
139
+ n.set(c, (n.get(c) ?? 0) + 1);
140
+ }
141
+ return [
142
+ ...n
143
+ ].sort((a, b)=>b[1] - a[1] || cmp(a[0], b[0])).map(([c])=>c);
144
+ };
145
+ /** The integration an offer is written as once someone connects it, with
146
+ * its logo as an SVG document where one was fetched: only the host writes
147
+ * it, so it is `built`. Whether it is featured is the platform's mark, never
148
+ * the integration's own word. */ export let adopted = (o, logo)=>{
149
+ let { featured: _, ...i } = o;
150
+ return {
151
+ ...i,
152
+ ...logo ? {
153
+ logo
154
+ } : {},
155
+ built: true
156
+ };
157
+ };
158
+ // What may stand before an SVG document's root: a byte-order mark, space, an
159
+ // XML declaration, comments and its doctype.
160
+ let PROLOG = /^(?:\uFEFF|\s|<\?xml[^>]*\?>|<!--[\s\S]*?-->|<!DOCTYPE svg[^>]*>)*/i;
161
+ /** Whether `text` is an SVG document: its root is `<svg>`. A page that holds
162
+ * an SVG is not one. */ /// isSvg('<?xml version="1.0"?>\n<svg xmlns="http://www.w3.org/2000/svg"/>') -> true
163
+ /// isSvg('<!-- drawn --><svg><path/></svg>') -> true
164
+ /// isSvg('<!doctype html><html><body><svg></svg></body></html>') -> false
165
+ export let isSvg = (text)=>/^<svg[\s>/]/.test(text.replace(PROLOG, ''));
166
+ let XML = {
167
+ '&': '&amp;',
168
+ '<': '&lt;',
169
+ '>': '&gt;'
170
+ };
171
+ /** The logo a service with no image of its own wears: the first letter of
172
+ * its title on a rounded square, as an SVG document. */ export let initialLogo = (title)=>{
173
+ let first = ([
174
+ ...title.trim()
175
+ ][0] ?? '?').toUpperCase();
176
+ return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">' + '<rect width="24" height="24" rx="6" fill="#8882"/>' + '<text x="12" y="16.5" text-anchor="middle" font-size="13" ' + 'font-family="system-ui,sans-serif" font-weight="600" fill="#888">' + `${first.replace(/[&<>]/g, (c)=>XML[c])}</text></svg>`;
177
+ };
178
+ //# sourceMappingURL=catalog.js.map
package/catalog.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.js","sources":["./catalog.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,2EAA2E;AAC3E,4EAA4E;AAC5E,qEAAqE;AACrE,EAAE;AACF,6EAA6E;AAC7E,4EAA4E;AAC5E,0EAA0E;AAC1E,yEAAyE;AACzE,0EAA0E;AAC1E,8EAA8E;AAC9E,2EAA2E;AAC3E,QAAQ;AACR,EAAE;AACF,0EAA0E;AAC1E,uEAAuE;AAEvE,SAAS,GAAG,wBAA6B;AAEzC,SAGE,OAAO,EACP,aAAa,4BACW;AAU1B,2EAA2E;AAC3E,SAAS;AACT,IAAI,QAAgC;EAClC,KAAK;EACL,IAAI;EACJ,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;AACP;AAEA,oCAAoC;AACpC,wBAAwB;AACxB,OAAO,IAAI,OAAO,CAAC,WACjB,KAAK,CAAC,SAAS,IACb,SAAS,MAAM,CAAC,GAAG,WAAW,KAAK,SAAS,KAAK,CAAC,GAAG,UAAU,CAAC,KAAK,KAAI;AAE7E,6EA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