dánwòdánwò

Connectors

Nango

Nango integrations, connect sessions with the hosted Connect UI, connections whose tokens refresh, the proxy, actions and records, routed to danwo's other emulators.

danwo's Nango emulator answers Nango's API and its hosted Connect UI. @nangohq/node and @nangohq/frontend work against it unchanged.

Like Composio, it can route to danwo's other emulators: give it the Google, Microsoft, Slack or GitHub service as a backend, and a connection's proxied calls reach that emulator with the connection's token.

Set up

List the backends before Nango, and pass them in backends:

danwo.config.ts
import { appEnvironment, defineConfig, githubService, nangoService } from "@danwo/sdk"

const url = "http://localhost:3000"

export default defineConfig({
  testDir: "tests",
  readiness: { mode: "page+backend", settle: true },
  environment: () => {
    const github = githubService({
      seed: {
        users: [{ login: "ada" }],
        repos: [{ repo: "ada/notes" }],
        tokens: [{ token: "gho_danwo", login: "ada", scopes: ["repo"] }],
      },
    })

    return appEnvironment({
      app: { command: "npm run dev", url, env: { NANGO_SECRET_KEY: "danwo-nango-key" } },
      services: [
        github,
        nangoService({
          backends: [github],
          seed: {
            secretKeys: ["danwo-nango-key"],
            integrations: [{ key: "github", provider: "github" }],
            connections: [{ integration: "github", connectionId: "ada", accessToken: "gho_danwo" }],
            webhook: { url: `${url}/api/webhooks/nango` },
          },
        }),
      ],
    })
  },
})

Seed it

FieldWhat it seeds
secretKeysThe environment's secret keys; without any, any non-empty key works.
integrationsIntegrations by unique key, and the provider each connects to.
connectionsConnections already made, with an end user, metadata and a token a backend issued.
webhookThe environment's webhook URL and the secret that signs it.
proxyAnswers for proxied calls to integrations without a backend.
actionsWhat each action returns.
recordsSynced records by connection and model.

Use it in a test

Revoke the connection mid-test, as when the user removes your app on GitHub. Once the token is due to refresh, the refresh fails and Nango sends its auth webhook:

tests/reconnect.danwo.ts
import { type NangoFixtures, nangoProject, test as base } from "@danwo/sdk"

const test = base.extend<NangoFixtures>()

test("asks to reconnect when access is revoked", async ({ app, screen, expect, time, nango }) => {
  nangoProject(nango).revoke("github", "ada")
  await time.travel({ hours: 2 })

  await app.open("/repos")
  await expect(screen.getByRole("button", { name: "Reconnect GitHub" })).toBeVisible()
  expect(nangoProject(nango).connections()).toHaveLength(1)
})
nangoProject(nango)What it's for
connections(), connection(…)The connections.
calls()Every proxied call and action run, with its status.
revoke(integration, id)Make a connection's next token refresh fail.

What's covered

AreaCovered
IntegrationsThe environment's integrations.
ConnectConnect and reconnect sessions, and the hosted Connect UI.
ConnectionsConnections and metadata, with tokens that refresh on the emulator's clock.
ProxyCalls forwarded to a backend emulator, or answered from the seed.
Actions and recordsRunning actions and reading synced records.

Faults

CallFaults the matrix tries
A proxied write429, 424 when the token refresh failed, a 30-second delay, 500, connection reset, answer lost after the call
A read424, 500, connection reset
Every webhook deliveryarrives twice, arrives 10 minutes late, forged signature, 1 hour stale

Webhooks

auth webhooks, sent when a connection is made or fails, carry X-Nango-Signature, signed with the webhook's secret or else the first secret key, as Nango signs them.

Fidelity

Live, reads only. danwo fidelity nango runs 2 scenarios against a real environment: errors, and listing integrations and connections. Both match.

Not covered yet

  • Running your own syncs and actions' code: their output comes from the seed
  • sync and forward webhooks
  • Nango's self-hosted admin API

Next

On this page

Run it on every pull request

A GitHub check and one comment per pull request, with the flight records attached.

Set up CI