@withone/connect 0.16.0 → 0.16.1

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.
package/README.md CHANGED
@@ -45,7 +45,7 @@ later: oneConnect.runAction(userId, …) ──► One, gr
45
45
  - [5 · Using the grant](#5--using-the-grant)
46
46
  - [6 · Errors](#6--errors)
47
47
  - [7 · Token mode](#7--token-mode)
48
- - [Security](#security) · [Troubleshooting](#troubleshooting) · [API reference](#api-reference)
48
+ - [Security](#security) · [Troubleshooting](#troubleshooting) · [Supported versions](#supported-versions) · [API reference](#api-reference) · [Support](#support)
49
49
 
50
50
  ## Choose how your server holds the grant
51
51
 
@@ -122,6 +122,16 @@ export const { GET } = createOneConnectRoutes(oneConnect, {
122
122
  });
123
123
  ```
124
124
 
125
+ `identifyUser` answers one question: which of **your** app's users clicked Connect? Return the id from your own session. One's page then signs the person in to **One** with their email and a code. Those are two different accounts, and the callback joins them:
126
+
127
+ ```
128
+ your session ── identifyUser ──► "user_123" which of your users is this?
129
+ One's page ── email + code ──► Maya on One whose tools are these?
130
+ callback ── saves Maya's grant on user_123 ──► later: runAction("user_123", …)
131
+ ```
132
+
133
+ `loginHintFor` only pre-fills the email on One's page. Nobody signed in? `identifyUser` returns null and the route sends them to `signInUrl` (or answers `401`).
134
+
125
135
  That file serves `/api/one/authorize` and `/api/one/callback`. For Express, Fastify, Koa or plain Node, `createOneConnectHandlers` from `@withone/connect/node` takes the same options and returns `{ authorize, callback }` to mount on those two paths.
126
136
 
127
137
  ## 4 · The button
@@ -356,11 +366,26 @@ The job renews both tokens when either is within 3 days of expiring. Without it,
356
366
  |---|---|
357
367
  | Signed-out users see "Sign in to your account before connecting One." | `identifyUser` returned null. Set `signInUrl` to send them to your sign-in page. |
358
368
  | Every attempt ends with `expired` | The state cookie did not reach the callback. Serve both routes from the same directory (`/api/one/authorize` and `/api/one/callback`) on the origin of `ONE_REDIRECT_URI`. An attempt also expires after 30 minutes. |
359
- | Every attempt ends with `failed` | Usually One refused the code exchange. Check that `ONE_REDIRECT_URI` matches the registered URL exactly and that the client secret is current. Log `result.message` with `onComplete` on the routes to see why. |
369
+ | One answers `invalid redirect_uri` instead of showing its page | `ONE_REDIRECT_URI` is not registered on the app character for character (scheme, host, port, path). Register it, or fix the variable. |
370
+ | Every attempt ends with `failed` | One refused the code exchange, most often because the client secret is wrong or was rotated. Log `result.message` with `onComplete` on the routes to see the reason. |
360
371
  | Every call fails with `request_failed`: "One did not accept the connect key" | The key is not this app's, or it was revoked. Create a key on the app's page and update `ONE_CONNECT_KEY`. |
361
372
  | Every user's calls throw `reconnect_required` | The app is deactivated. Check that it is active in the dashboard. |
362
373
  | A call returns `403` with `blockedByGrant: true` | The action is outside what the user granted. Ask for it in your permission set; users see new tools the next time they connect. |
363
374
 
375
+ ## Supported versions
376
+
377
+ | | |
378
+ |---|---|
379
+ | Node.js | 18 or later |
380
+ | React | 17 or later (optional peer dependency) |
381
+ | Vue | 3 or later (optional peer dependency) |
382
+ | Svelte | 3 or later (the `use:` action); no peer dependency |
383
+ | `@withone/connect/next` | Any server with web `Request` and `Response`: Next.js App Router, Remix, SvelteKit, Hono, Bun |
384
+ | `@withone/connect/node` | Node's `http` request and response: Express, Fastify (`reply.raw`), Koa (`ctx.req`/`ctx.res`), plain Node |
385
+ | Browsers | Any browser with Shadow DOM and custom elements; the build targets `> 0.25%, not dead` |
386
+
387
+ **Versioning.** Until 1.0, a minor version may remove an API that an earlier minor deprecated; every deprecation is marked in the types and in the [release notes](CHANGELOG.md), and stays for at least one minor. Patch versions only fix bugs or docs.
388
+
364
389
  ## API reference
365
390
 
366
391
  ### `createOneConnect(config)` · `@withone/connect/server`
@@ -411,6 +436,12 @@ The job renews both tokens when either is within 3 days of expiring. Without it,
411
436
  | `createConnectFlow(options)` | Your own button anywhere. |
412
437
  | `readConnectReturn()` | How this page load ended a flow, or null. |
413
438
 
439
+ ## Support
440
+
441
+ - Bugs and questions: [GitHub issues](https://github.com/withoneai/connect/issues).
442
+ - Security issues: see [SECURITY.md](SECURITY.md). Please don't open a public issue.
443
+ - Everything else: hello@withone.ai.
444
+
414
445
  ## License
415
446
 
416
447
  GPL-3.0. See [LICENSE](LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@withone/connect",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "description": "One Connect for your app: the button your users press, the two backend routes as one import, and a server client that calls One with the grant. Users keep their connections in One; your app holds only what they granted.",
5
5
  "files": [
6
6
  "dist",
@@ -115,6 +115,14 @@ export const { GET } = createOneConnectRoutes(oneConnect, {
115
115
  });
116
116
  ```
117
117
 
118
+ `identifyUser` returns the id of the app's own signed-in user, from the
119
+ app's existing session. It is not the email: One's page signs the person
120
+ in to One with their email and a code; this id is which of the app's
121
+ accounts the grant is saved under, and the `userId` every later call
122
+ takes. `loginHintFor` only pre-fills that email. If the app has no
123
+ sign-in, ask the human what to use; for a throwaway demo, one fixed id
124
+ is fine.
125
+
118
126
  Express, Fastify, Koa or plain Node: `createOneConnectHandlers(oneConnect,
119
127
  options)` from `@withone/connect/node` takes the same options and returns
120
128
  `{ authorize, callback }`, mounted at `/api/one/authorize` and
@@ -254,7 +262,10 @@ Rules:
254
262
  - Connect keys work in Production only; the human creates the key with
255
263
  the dashboard on Production.
256
264
  - Store the per-user string as given.
257
- - The registered redirect URI and `ONE_REDIRECT_URI` must be identical.
265
+ - The registered redirect URI and `ONE_REDIRECT_URI` must be identical;
266
+ otherwise One answers `invalid redirect_uri` and never shows its page.
267
+ - A flow that ends with `failed` is usually a wrong or rotated client
268
+ secret; log `result.message` from `onComplete` to see why.
258
269
  - Do not write OAuth steps or One request headers by hand; use the package.
259
270
  - Never show `result.message` or any URL text to users; log it.
260
271