@aiveth/nextjs 0.4.0 → 0.5.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0 — 2026-11-26
4
+
5
+ - `audience` / env `AIVETH_API_AUDIENCE`: your own API's address. `getAccessToken()` then gives a signed token for that API, which it checks with `verifyAccessToken` (`@aiveth/node`).
6
+
7
+ ## 0.4.1 — 2026-11-25
8
+
9
+ - `/auth/branding` is never cached (it was 5 minutes): a Save in Aiveth → Branding shows on
10
+ `AivethButton` at the next page load.
11
+
3
12
  ## 0.4.0 — 2026-11-25
4
13
 
5
14
  - `<AivethButton>` (`@aiveth/nextjs/client`): "Sign in" in the organization's own look
package/README.md CHANGED
@@ -16,6 +16,7 @@ AIVETH_CLIENT_ID=okc_...
16
16
  AIVETH_CLIENT_SECRET=oks_...
17
17
  AIVETH_COOKIE_SECRET=$(openssl rand -base64 32) # at least 32 characters
18
18
  AIVETH_APP_URL=https://your-app.com
19
+ # AIVETH_API_AUDIENCE=https://api.your-app.com # optional: a signed token for your own API (Developers → Your APIs)
19
20
  ```
20
21
 
21
22
  3. `proxy.ts` (Next.js 16) — or `middleware.ts` (15):
@@ -82,4 +83,4 @@ read by the proxy from Aiveth on the server at `/auth/branding`.
82
83
  | `/auth/callback` | Aiveth's answer: checks it and writes the session |
83
84
  | `/auth/logout` | Clears the session, then signs out at Aiveth and comes back |
84
85
  | `/auth/session` | `{ user }` for the browser — never a token |
85
- | `/auth/branding` | The organization's look for `AivethButton` (public, cached 5 minutes) |
86
+ | `/auth/branding` | The organization's look for `AivethButton` (public, never cached: a Save in Aiveth shows at once) |
package/dist/config.d.ts CHANGED
@@ -11,6 +11,10 @@ export interface AivethNextConfig {
11
11
  appUrl: string;
12
12
  /** Space-separated. `offline_access` keeps the person signed in past the access token. */
13
13
  scope: string;
14
+ /** Your own API's address, as registered under Developers → Your APIs (env
15
+ * `AIVETH_API_AUDIENCE`). Set it and `getAccessToken()` gives a signed token for that API, which
16
+ * it checks with `verifyAccessToken` (`@aiveth/node`) — no call to Aiveth. */
17
+ audience?: string;
14
18
  /** For tests, or a runtime without a global fetch. */
15
19
  fetch?: typeof fetch;
16
20
  }
package/dist/config.js CHANGED
@@ -49,6 +49,7 @@ function fromEnv() {
49
49
  cookieSecret: env.AIVETH_COOKIE_SECRET ?? '',
50
50
  appUrl: env.AIVETH_APP_URL ?? '',
51
51
  scope: env.AIVETH_SCOPES || DEFAULT_SCOPE,
52
+ audience: env.AIVETH_API_AUDIENCE || undefined,
52
53
  };
53
54
  }
54
55
  export function config() {
package/dist/handlers.js CHANGED
@@ -65,7 +65,8 @@ export async function sessionJson(req, c) {
65
65
  * `/v1/branding/public` for THIS app, fetched here so the browser never needs the client id or
66
66
  * another site. Aiveth's own look when it can't be read; nothing secret either way. */
67
67
  export async function brandingJson(_req, c) {
68
- const headers = { 'Cache-Control': 'public, max-age=300' };
68
+ // Never the old look after a Save in Aiveth (0.4.1; 0.4.0 kept it 5 minutes).
69
+ const headers = { 'Cache-Control': 'no-cache' };
69
70
  try {
70
71
  const res = await (c.fetch ?? fetch)(`${c.baseUrl}/v1/branding/public?${new URLSearchParams({ client_id: c.clientId })}`, { cache: 'no-store' });
71
72
  return NextResponse.json(res.ok ? await res.json() : { custom: false }, { headers });
package/dist/oidc.js CHANGED
@@ -54,6 +54,8 @@ export async function authorizeUrl(c, a) {
54
54
  });
55
55
  if (a.loginHint)
56
56
  q.set('login_hint', a.loginHint);
57
+ if (c.audience)
58
+ q.set('resource', c.audience); // RFC 8707: a signed access token for that API
57
59
  return `${d.authorization_endpoint}?${q}`;
58
60
  }
59
61
  async function token(c, form) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiveth/nextjs",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Aiveth by Gooclaim for Next.js: sign in on Aiveth's page, an encrypted session cookie, the user on the server and in the browser.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Gooclaim",