@sanoma-ai/connector-better-auth 0.2.2 → 0.2.3

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
@@ -1,6 +1,6 @@
1
1
  # @sanoma-ai/connector-better-auth
2
2
 
3
- [Better Auth](https://www.better-auth.com) as a visitor login for a [Sanoma](https://github.com/Sanoma-AI/sanoma) public site, and as the app's staff sign-in on a host: visitors sign up and sign in with an email and a password (or an email code, or GitHub), staff by an email code, an invite link or GitHub, and the accounts live on the company's own database. It has no operations and no credential; it attaches a login half (`withSetup({ login })`, see [`@sanoma-ai/workflows`](https://www.npmjs.com/package/@sanoma-ai/workflows#usage)), which the app calls once for each public site that names it.
3
+ [Better Auth](https://www.better-auth.com) as a visitor login for a [Sanoma](https://github.com/Sanoma-AI/sanoma) public site, and as the app's staff sign-in on a host: visitors sign up and sign in with an email and a password, an email code or GitHub, staff by an email code, an invite link or GitHub, and the accounts live on the company's own database. It has no operations and no credential; it attaches a login half (`withSetup({ login })`, see [`@sanoma-ai/workflows`](https://www.npmjs.com/package/@sanoma-ai/workflows#usage)), which the app calls once for each public site that names it.
4
4
 
5
5
  ## Usage
6
6
 
@@ -66,25 +66,37 @@ When the company's config names a sender (`login: { sender: resend.emails.send,
66
66
 
67
67
  ### GitHub
68
68
 
69
- When the app has the company's GitHub App client (`SANOMA_GITHUB_CLIENT_ID` and `SANOMA_GITHUB_CLIENT_SECRET`, which `sanoma` reads on a host, the staff login's too), the login offers GitHub (`methods` lists `"github"`): a visitor signed in links their GitHub account, and is then said to be that GitHub login (`ctx.startedBy.github` in a run they start, `user.github` in the session). Add `https://<site host>/auth/better-auth/callback/github` to the App's callback URLs (its settings, "Callback URL"), one for each site's host.
69
+ When the app has the company's GitHub App client (`SANOMA_GITHUB_CLIENT_ID` and `SANOMA_GITHUB_CLIENT_SECRET`, which `sanoma` reads on a host, the staff login's too), the login offers GitHub (`methods` lists `"github"`): a visitor signs up or in with GitHub ("Continue with GitHub", beside the email code), or, signed in, links their GitHub account, and is then said to be that GitHub login (`ctx.startedBy.github` in a run they start, `user.github` in the session). Add `https://<site host>/auth/better-auth/callback/github` to the App's callback URLs (its settings, "Callback URL"), one for each site's host; signing in and linking come back to the same one.
70
70
 
71
- | Route | Body | What it does |
72
- | --------------------------------------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
73
- | `POST /auth/better-auth/link-social` | `{ provider: "github", callbackURL }` | Signed in: answers `{ url, redirect: true }`, GitHub's authorize page to send the browser to; back at `/callback/github`, it links the account, then `callbackURL`. |
74
- | `POST /auth/better-auth/sign-in/social` | `{ provider: "github", callbackURL }` | The same, signed out: signs in a visitor who linked that GitHub account. GitHub links to an existing account and signs a linked account in; it never makes one (`?error=signup_disabled`). |
75
- | `GET /auth/better-auth/get-session` | | `{ session, user }`, `user.github` the linked login, or null when signed out. |
71
+ | Route | Body | What it does |
72
+ | --------------------------------------- | ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
73
+ | `POST /auth/better-auth/sign-in/social` | `{ provider: "github", callbackURL }` | Answers `{ url, redirect: true }`, GitHub's authorize page to send the browser to; back at `/callback/github`, it signs the visitor in (making the account on first use), then `callbackURL`. |
74
+ | `POST /auth/better-auth/link-social` | `{ provider: "github", callbackURL }` | The same, signed in: links the GitHub account to the visitor's, then `callbackURL`. |
75
+ | `GET /auth/better-auth/get-session` | | `{ session, user }`, `user.github` the GitHub login, or null when signed out. |
76
76
 
77
77
  ```ts
78
- const response = await fetch("/auth/better-auth/link-social", {
78
+ // "Continue with GitHub" on the sign-in page, when the login offers it
79
+ const response = await fetch("/auth/better-auth/sign-in/social", {
79
80
  method: "POST",
80
81
  headers: { "content-type": "application/json" },
81
82
  body: JSON.stringify({ provider: "github", callbackURL: location.pathname }),
82
83
  });
83
84
  const { url } = await response.json();
84
- window.location.assign(url); // GitHub, then back on this page with the account linked
85
+ window.location.assign(url); // GitHub, then back on this page signed in
85
86
  ```
86
87
 
87
- Each `callbackURL` (and `errorCallbackURL`, where an error goes as `?error=<code>`) is a path on the site's host. A GitHub account links to one visitor only (`?error=account_already_linked_to_different_user` for another), its email may differ from the visitor's, and GitHub must have verified it. The login is GitHub's answer for the account's own token when Better Auth links it (Better Auth sets no field a person may not set from a provider's profile), and is cleared when the visitor unlinks it (`POST /unlink-account { accountId }`, the account's id in `GET /list-accounts`). Linked, the account keeps no GitHub token: its login is read once, at each link or sign-in, and its tokens dropped, as a GitHub App's user token reaches what the App and the person both reach. A visitor links one GitHub account at most (another is `?error=unable_to_link_account`).
88
+ Each `callbackURL` (and `errorCallbackURL`, where an error goes as `?error=<code>`, and `newUserCallbackURL`, where a new account goes) is a path on the site's host.
89
+
90
+ - **One person, one account.** A GitHub sign-in whose email matches a visitor's account signs into that account when GitHub verified the email and the account's own is verified (by a code, or by GitHub at sign-up); otherwise it is refused, so an email nobody proved never joins someone's account.
91
+ - **A new account by GitHub** has its email verified only when GitHub verified it, and `verify` says the email only then. An email code to that address later proves it, and drops the GitHub account that had not.
92
+ - **A link** may use a GitHub account of another email, which GitHub must have verified.
93
+ - **The login** is GitHub's answer for the account's own token at each sign-in or link (Better Auth sets no field a person may not set from a provider's profile), and is cleared when the visitor unlinks it (`POST /unlink-account { accountId }`, the account's id in `GET /list-accounts`). The account's tokens are dropped then, as a GitHub App's user token reaches what the App and the person both reach.
94
+
95
+ | `?error=` | When |
96
+ | ------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------- |
97
+ | `account_not_linked` | A sign-in's email matches an account, but one side has not verified it. |
98
+ | `account_already_linked_to_different_user` | A link of a GitHub account that is another visitor's. |
99
+ | `unable_to_link_account` | A second GitHub account for a visitor who has one (by link or by sign-in), or a link whose GitHub email GitHub has not verified. |
88
100
 
89
101
  ## The staff sign-in
90
102
 
package/dist/login.d.ts CHANGED
@@ -2,11 +2,12 @@ import type { LoginContext, LoginHalf } from "@sanoma-ai/workflows";
2
2
  /**
3
3
  * Better Auth's login half for one public site: email and password, and an email code when the
4
4
  * app can send one (`context.sendCode`); every email may sign up. With the company's GitHub client
5
- * (`context.social.github`), a visitor signed in links their GitHub account
6
- * (`/link-social`), then may sign in with it (`/sign-in/social`, which never makes an account), and is then said to be that GitHub
7
- * login (`verify`'s `github`). Its tables are in schema `better_auth` on the company's database,
8
- * migrated here before the first site starts, its cookies signed with the app's key for it
9
- * (`context.key`). The site's origins are its allowed hosts (a request for another host is
10
- * refused) and set the cookie's `Secure` flag: an `https` origin's is.
5
+ * (`context.social.github`), a visitor also signs up and in with GitHub (`/sign-in/social`, which
6
+ * joins the account of GitHub's verified email), or links it once signed in (`/link-social`), and
7
+ * is then said to be that GitHub login (`verify`'s `github`). Its tables are in schema
8
+ * `better_auth` on the company's database, migrated here before the first site starts, its
9
+ * cookies signed with the app's key for it (`context.key`). The site's origins are its allowed
10
+ * hosts (a request for another host is refused) and set the cookie's `Secure` flag: an `https`
11
+ * origin's is.
11
12
  */
12
13
  export declare function betterAuthLogin({ databaseUrl, key, origins, sendCode, social, }: LoginContext): Promise<LoginHalf>;
package/dist/login.js CHANGED
@@ -8,12 +8,13 @@ const SIGN_OUT = `${BASE_PATH}/sign-out`;
8
8
  /**
9
9
  * Better Auth's login half for one public site: email and password, and an email code when the
10
10
  * app can send one (`context.sendCode`); every email may sign up. With the company's GitHub client
11
- * (`context.social.github`), a visitor signed in links their GitHub account
12
- * (`/link-social`), then may sign in with it (`/sign-in/social`, which never makes an account), and is then said to be that GitHub
13
- * login (`verify`'s `github`). Its tables are in schema `better_auth` on the company's database,
14
- * migrated here before the first site starts, its cookies signed with the app's key for it
15
- * (`context.key`). The site's origins are its allowed hosts (a request for another host is
16
- * refused) and set the cookie's `Secure` flag: an `https` origin's is.
11
+ * (`context.social.github`), a visitor also signs up and in with GitHub (`/sign-in/social`, which
12
+ * joins the account of GitHub's verified email), or links it once signed in (`/link-social`), and
13
+ * is then said to be that GitHub login (`verify`'s `github`). Its tables are in schema
14
+ * `better_auth` on the company's database, migrated here before the first site starts, its
15
+ * cookies signed with the app's key for it (`context.key`). The site's origins are its allowed
16
+ * hosts (a request for another host is refused) and set the cookie's `Secure` flag: an `https`
17
+ * origin's is.
17
18
  */
18
19
  export async function betterAuthLogin({ databaseUrl, key, origins, sendCode, social, }) {
19
20
  const github = social?.github;
@@ -32,14 +33,11 @@ export async function betterAuthLogin({ databaseUrl, key, origins, sendCode, soc
32
33
  plugins: sendCode ? [emailCode(sendCode)] : [],
33
34
  user: { additionalFields: GITHUB_FIELD },
34
35
  ...(github && {
35
- // GitHub never makes an account, nor joins one by its email: a visitor signs up by email,
36
- // links GitHub (`/link-social`), and may then sign in with it.
37
- socialProviders: {
38
- github: { clientId: github.clientId, clientSecret: github.clientSecret, disableSignUp: true },
39
- },
40
- // A visitor's GitHub email is seldom the one they signed in with. Linking still needs
41
- // GitHub to have verified its email (GitHub is no trusted provider).
42
- account: { accountLinking: { allowDifferentEmails: true, disableImplicitLinking: true } },
36
+ socialProviders: { github: { clientId: github.clientId, clientSecret: github.clientSecret } },
37
+ // GitHub stays untrusted, and the account's own email must be verified (Better Auth's
38
+ // default, pinned): a sign-in joins an account only by an email both sides verified
39
+ // (AGENTS.md). A link's may differ.
40
+ account: { accountLinking: { allowDifferentEmails: true, requireLocalEmailVerified: true } },
43
41
  databaseHooks: {
44
42
  account: {
45
43
  create: { before: oneGitHub, after: noteLogin },
@@ -99,23 +97,30 @@ async function oneGitHub(account, ctx) {
99
97
  return false;
100
98
  }
101
99
  /**
102
- * Keeps a GitHub account's login on its user, once Better Auth has linked it or signed its user
100
+ * Keeps a GitHub account's login on its user, once Better Auth has made, linked or signed its user
103
101
  * in with it (GitHub's redirect back, `/callback/:id`), then drops the account's tokens, which
104
102
  * nothing here uses again: a GitHub App's user token reaches what the App and the person both
105
- * reach. The login is the provider's profile for that token, since Better Auth sets no field from
106
- * a profile that a person may not set (`input: false`), the GitHub login among them.
103
+ * reach. The tokens go even when GitHub does not answer: the hook runs once the account is
104
+ * written, so its error undoes nothing. The login is GitHub's `/user` for that token, since
105
+ * Better Auth sets no field from a profile that a person may not set (`input: false`), the GitHub
106
+ * login among them.
107
107
  */
108
108
  async function noteLogin(account, ctx) {
109
109
  if (account?.providerId !== "github" || !account.accessToken || ctx?.path !== "/callback/:id")
110
110
  return;
111
- const { internalAdapter, socialProviders } = ctx.context;
112
- const provider = socialProviders.find((p) => p.id === "github");
113
- const info = (await provider.getUserInfo({ accessToken: account.accessToken }));
114
- const login = info?.data?.login;
115
- if (typeof login !== "string")
116
- throw new Error("better-auth: GitHub did not say whose account was linked");
117
- await internalAdapter.updateUser(account.userId, { github: login });
118
- await internalAdapter.updateAccount(account.id, { accessToken: null, refreshToken: null, idToken: null });
111
+ const { internalAdapter } = ctx.context;
112
+ try {
113
+ const answer = await fetch("https://api.github.com/user", {
114
+ headers: { authorization: `Bearer ${account.accessToken}`, "user-agent": "sanoma" },
115
+ });
116
+ const { login } = (answer.ok ? await answer.json() : {});
117
+ if (typeof login !== "string")
118
+ throw new Error("better-auth: GitHub did not say whose account it is");
119
+ await internalAdapter.updateUser(account.userId, { github: login });
120
+ }
121
+ finally {
122
+ await internalAdapter.updateAccount(account.id, { accessToken: null, refreshToken: null, idToken: null });
123
+ }
119
124
  }
120
125
  /** A GitHub account unlinked: its user is no longer that login. */
121
126
  async function forgetLogin(account, ctx) {
package/dist/login.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"login.js","sourceRoot":"","sources":["../src/login.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EACL,SAAS,EACT,YAAY,EACZ,UAAU,EACV,cAAc,EACd,cAAc,EAGd,eAAe,GAChB,MAAM,eAAe,CAAC;AAEvB,yHAAyH;AACzH,MAAM,MAAM,GAAG,aAAa,CAAC;AAC7B,wHAAwH;AACxH,MAAM,SAAS,GAAG,mBAAmB,CAAC;AACtC,MAAM,QAAQ,GA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AAI,CAAC,GAAG,wBAAwB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACvE,IAAI,CAAC,IAAI;YACP,MAAM,IAAI,KAAK,CACb,yFAAyF,MAAM,EAAE,CAClG,CAAC;QACJ,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAoB,EAAE,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanoma-ai/connector-better-auth",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Better Auth for Sanoma: the visitor login of public sites (email and password, or an email code) and the staff sign-in on a host (email code, invite links, GitHub), on the company's own database",
5
5
  "keywords": [
6
6
  "auth",
@@ -44,13 +44,13 @@
44
44
  "pg": "^8.23.1"
45
45
  },
46
46
  "devDependencies": {
47
- "@sanoma-ai/app": "0.10.5",
48
- "@sanoma-ai/testing": "0.1.0",
49
- "@sanoma-ai/workflows": "0.11.0",
47
+ "@sanoma-ai/app": "0.10.8",
48
+ "@sanoma-ai/testing": "0.1.1",
49
+ "@sanoma-ai/workflows": "0.11.4",
50
50
  "@types/pg": "^8.23.1"
51
51
  },
52
52
  "peerDependencies": {
53
- "@sanoma-ai/workflows": "^0.11.0"
53
+ "@sanoma-ai/workflows": "^0.11.4"
54
54
  },
55
55
  "engines": {
56
56
  "node": ">=26"