@tokenite/sdk 2.2.0 → 2.3.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/README.md CHANGED
@@ -223,7 +223,7 @@ for await (const event of stream) {
223
223
  <!-- GEN:API -->
224
224
  ### `.getAuthorizeUrl(options?: AuthorizeOptions) => string`
225
225
 
226
- Build the authorization URL for a full-page redirect. Supports optional suggested budget that pre-fills the consent screen.
226
+ Build the authorization URL for a full-page redirect.
227
227
 
228
228
  ### `.popup(options?: PopupOptions) => Promise<PopupResult>`
229
229
 
@@ -267,11 +267,43 @@ export type TokeniteConfig = {
267
267
  readonly proxyUrl?: string;
268
268
  };
269
269
 
270
+ /**
271
+ * OAuth 2.0 / OIDC `prompt` parameter. Tells Tokenite whether to
272
+ * re-prompt the user even when they have an existing session and/or
273
+ * an existing grant for this app.
274
+ *
275
+ * - `'consent'` — re-show the consent screen even if the user has
276
+ * already authorized this app. Use this on "Sign in with Tokenite"
277
+ * buttons that follow a sign-out, so users don't silently
278
+ * re-authorize without a chance to pick a different account or
279
+ * cancel.
280
+ * - `'login'` — request that the user re-authenticate. Today this
281
+ * behaves the same as `'consent'` on Tokenite (full session-cookie
282
+ * clear is a TODO); the consent screen still shows.
283
+ * - `'select_account'` — show the account picker. Tokenite already
284
+ * does this automatically when the user has multiple accounts;
285
+ * passing it explicitly is a hint for future apps that always want
286
+ * the picker.
287
+ * - `'none'` — never show UI; fail if interaction is required.
288
+ * Currently treated as the default (silent reauth).
289
+ *
290
+ * The OAuth 2.0 spec allows a space-separated combination
291
+ * (e.g. `'login consent'`); for that, pass the raw string. The
292
+ * union above is just for autocomplete on the common values.
293
+ */
294
+ export type OAuthPrompt = 'login' | 'consent' | 'select_account' | 'none' | (string & {});
295
+
270
296
  export type AuthorizeOptions = {
271
297
  /** Custom state parameter for CSRF protection. Auto-generated if not provided. */
272
298
  readonly state?: string;
273
299
  /** Suggested budget amount (user can override on consent screen) */
274
300
  readonly suggestedBudget?: number;
301
+ /**
302
+ * OAuth `prompt` parameter. Most common use: pass `'consent'` to
303
+ * force a fresh consent screen on sign-in (prevents silent reauth
304
+ * after the user signed out of the app). See {@link OAuthPrompt}.
305
+ */
306
+ readonly prompt?: OAuthPrompt;
275
307
  };
276
308
 
277
309
  export type PopupOptions = {
@@ -293,6 +325,12 @@ export type PopupOptions = {
293
325
  readonly width?: number;
294
326
  /** Modal/popup height in pixels. Default: 620 */
295
327
  readonly height?: number;
328
+ /**
329
+ * OAuth `prompt` parameter. Most common use: pass `'consent'` to
330
+ * force a fresh consent screen on sign-in (prevents silent reauth
331
+ * after the user signed out of the app). See {@link OAuthPrompt}.
332
+ */
333
+ readonly prompt?: OAuthPrompt;
296
334
  };
297
335
 
298
336
  export type PopupResult = {
package/dist/client.d.ts CHANGED
@@ -40,7 +40,13 @@ import type { TokeniteConfig, AuthorizeOptions, PopupOptions, PopupResult, Token
40
40
  export declare const Tokenite: (config: TokeniteConfig) => {
41
41
  /**
42
42
  * Build the authorization URL for a full-page redirect.
43
- * Supports optional suggested budget that pre-fills the consent screen.
43
+ *
44
+ * Pass `prompt: 'consent'` on "Sign in with Tokenite" buttons that
45
+ * follow a sign-out, so the user sees the consent screen again
46
+ * instead of being silently re-authorized:
47
+ * ```typescript
48
+ * res.redirect(tk.getAuthorizeUrl({ prompt: 'consent' }));
49
+ * ```
44
50
  */
45
51
  getAuthorizeUrl: (options?: AuthorizeOptions) => string;
46
52
  /**
@@ -64,6 +70,13 @@ export declare const Tokenite: (config: TokeniteConfig) => {
64
70
  * body: JSON.stringify({ code }),
65
71
  * });
66
72
  * ```
73
+ *
74
+ * Pass `prompt: 'consent'` to force a fresh consent screen — use on
75
+ * the "Sign in with Tokenite" button shown after the user signed out
76
+ * of your app, so they don't silently re-authorize:
77
+ * ```typescript
78
+ * const { code } = await tk.popup({ prompt: 'consent' });
79
+ * ```
67
80
  */
68
81
  popup: (options?: PopupOptions) => Promise<PopupResult>;
69
82
  /**
package/dist/client.js CHANGED
@@ -92,12 +92,20 @@ export const Tokenite = (config) => {
92
92
  params.set('suggested_budget', String(options.suggestedBudget));
93
93
  if (options?.mode)
94
94
  params.set('mode', options.mode);
95
+ if (options?.prompt)
96
+ params.set('prompt', options.prompt);
95
97
  return `${baseUrl}/oauth/authorize?${params}`;
96
98
  };
97
99
  return {
98
100
  /**
99
101
  * Build the authorization URL for a full-page redirect.
100
- * Supports optional suggested budget that pre-fills the consent screen.
102
+ *
103
+ * Pass `prompt: 'consent'` on "Sign in with Tokenite" buttons that
104
+ * follow a sign-out, so the user sees the consent screen again
105
+ * instead of being silently re-authorized:
106
+ * ```typescript
107
+ * res.redirect(tk.getAuthorizeUrl({ prompt: 'consent' }));
108
+ * ```
101
109
  */
102
110
  getAuthorizeUrl: (options) => buildAuthorizeUrl(options),
103
111
  /**
@@ -121,6 +129,13 @@ export const Tokenite = (config) => {
121
129
  * body: JSON.stringify({ code }),
122
130
  * });
123
131
  * ```
132
+ *
133
+ * Pass `prompt: 'consent'` to force a fresh consent screen — use on
134
+ * the "Sign in with Tokenite" button shown after the user signed out
135
+ * of your app, so they don't silently re-authorize:
136
+ * ```typescript
137
+ * const { code } = await tk.popup({ prompt: 'consent' });
138
+ * ```
124
139
  */
125
140
  popup: (options) => {
126
141
  const mode = options?.mode ?? 'iframe';
@@ -133,6 +148,7 @@ export const Tokenite = (config) => {
133
148
  const url = buildAuthorizeUrl({
134
149
  suggestedBudget: options?.suggestedBudget,
135
150
  mode: mode === 'window' ? 'popup' : 'iframe',
151
+ prompt: options?.prompt,
136
152
  });
137
153
  return mode === 'window'
138
154
  ? openWindowPopup(url, width, height, baseUrl, config.redirectUri)
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { Tokenite } from './client.js';
2
- export type { TokeniteConfig, AuthorizeOptions, PopupOptions, PopupResult, TokenResponse, Provider, ProxyCallOptions, ProxyUsage, ProxySuccess, ProxyError, ProxyResponse, ErrorSource, ProviderInfo, AppInfo, UserInfo, AccessContext, TopUpOptions, TopUpResult, CallWithRecoveryOptions, } from './types.js';
2
+ export type { TokeniteConfig, AuthorizeOptions, OAuthPrompt, PopupOptions, PopupResult, TokenResponse, Provider, ProxyCallOptions, ProxyUsage, ProxySuccess, ProxyError, ProxyResponse, ErrorSource, ProviderInfo, AppInfo, UserInfo, AccessContext, TopUpOptions, TopUpResult, CallWithRecoveryOptions, } from './types.js';
3
3
  export { isProxyError, isProxySuccess } from './types.js';
4
4
  export { parseCallback } from './parse-callback.js';
5
5
  export type { CallbackResult, CallbackSuccess, CallbackError, CallbackReason, ParseCallbackOptions, } from './parse-callback.js';
package/dist/types.d.ts CHANGED
@@ -10,11 +10,42 @@ export type TokeniteConfig = {
10
10
  /** Tokenite proxy URL. Default: https://api.tokenite.ai */
11
11
  readonly proxyUrl?: string;
12
12
  };
13
+ /**
14
+ * OAuth 2.0 / OIDC `prompt` parameter. Tells Tokenite whether to
15
+ * re-prompt the user even when they have an existing session and/or
16
+ * an existing grant for this app.
17
+ *
18
+ * - `'consent'` — re-show the consent screen even if the user has
19
+ * already authorized this app. Use this on "Sign in with Tokenite"
20
+ * buttons that follow a sign-out, so users don't silently
21
+ * re-authorize without a chance to pick a different account or
22
+ * cancel.
23
+ * - `'login'` — request that the user re-authenticate. Today this
24
+ * behaves the same as `'consent'` on Tokenite (full session-cookie
25
+ * clear is a TODO); the consent screen still shows.
26
+ * - `'select_account'` — show the account picker. Tokenite already
27
+ * does this automatically when the user has multiple accounts;
28
+ * passing it explicitly is a hint for future apps that always want
29
+ * the picker.
30
+ * - `'none'` — never show UI; fail if interaction is required.
31
+ * Currently treated as the default (silent reauth).
32
+ *
33
+ * The OAuth 2.0 spec allows a space-separated combination
34
+ * (e.g. `'login consent'`); for that, pass the raw string. The
35
+ * union above is just for autocomplete on the common values.
36
+ */
37
+ export type OAuthPrompt = 'login' | 'consent' | 'select_account' | 'none' | (string & {});
13
38
  export type AuthorizeOptions = {
14
39
  /** Custom state parameter for CSRF protection. Auto-generated if not provided. */
15
40
  readonly state?: string;
16
41
  /** Suggested budget amount (user can override on consent screen) */
17
42
  readonly suggestedBudget?: number;
43
+ /**
44
+ * OAuth `prompt` parameter. Most common use: pass `'consent'` to
45
+ * force a fresh consent screen on sign-in (prevents silent reauth
46
+ * after the user signed out of the app). See {@link OAuthPrompt}.
47
+ */
48
+ readonly prompt?: OAuthPrompt;
18
49
  };
19
50
  export type PopupOptions = {
20
51
  /** Suggested budget amount (user can override on consent screen) */
@@ -35,6 +66,12 @@ export type PopupOptions = {
35
66
  readonly width?: number;
36
67
  /** Modal/popup height in pixels. Default: 620 */
37
68
  readonly height?: number;
69
+ /**
70
+ * OAuth `prompt` parameter. Most common use: pass `'consent'` to
71
+ * force a fresh consent screen on sign-in (prevents silent reauth
72
+ * after the user signed out of the app). See {@link OAuthPrompt}.
73
+ */
74
+ readonly prompt?: OAuthPrompt;
38
75
  };
39
76
  export type PopupResult = {
40
77
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenite/sdk",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "SDK for integrating \"Login with Tokenite\" into your app. Your users bring their own AI tokens — you pay nothing.",
5
5
  "type": "module",
6
6
  "exports": {