@open-webapp/drive-sync 0.5.5 → 0.5.6

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.
@@ -15,8 +15,9 @@ export interface ConnectOptions {
15
15
  fetchEmail: (accessToken: string) => Promise<string>;
16
16
  }
17
17
  /**
18
- * Interactive connection flow: acquires a token with prompt: 'consent',
19
- * resolves the account email, and persists the durable Connection record.
18
+ * Interactive connection flow: acquires a token without forcing a consent
19
+ * screen, resolves the account email, and persists the durable Connection
20
+ * record.
20
21
  */
21
22
  export declare function connect(opts: ConnectOptions): Promise<Connection>;
22
23
  export interface RefreshSilentlyOptions {
@@ -5,8 +5,9 @@ import { WrongAccountError } from './errors.js';
5
5
  /** Mirrors refresh.ts's own buffer: a cached token this close to expiry is treated as unusable. */
6
6
  const TOKEN_REUSE_BUFFER_MS = 5 * 60 * 1000;
7
7
  /**
8
- * Interactive connection flow: acquires a token with prompt: 'consent',
9
- * resolves the account email, and persists the durable Connection record.
8
+ * Interactive connection flow: acquires a token without forcing a consent
9
+ * screen, resolves the account email, and persists the durable Connection
10
+ * record.
10
11
  */
11
12
  export async function connect(opts) {
12
13
  // On a re-auth the previous connection's email is the account the user is
package/dist/token.d.ts CHANGED
@@ -33,9 +33,10 @@ export interface AcquireTokenOptions {
33
33
  export declare function notifyExternalTokenRefresh(projectId: string): void;
34
34
  /**
35
35
  * Single entry point for acquiring a Drive access token, used by BOTH the
36
- * interactive "connect" path (interactive: true -> prompt: 'consent', no
37
- * hint) and the silent "refresh" path (interactive: false -> prompt: 'none',
38
- * hint: the connection's known email).
36
+ * interactive "connect" path (interactive: true -> prompt: '', i.e. no
37
+ * forced consent screen) and the silent "refresh" path (interactive: false
38
+ * -> prompt: 'none'). Both pass `hint`: the connection's known email, when
39
+ * there is one.
39
40
  *
40
41
  * Design contract (see report): if `interactive` is false and GIS reports an
41
42
  * error on the silent attempt, this function throws a NeedsReauthError
package/dist/token.js CHANGED
@@ -71,9 +71,10 @@ export function notifyExternalTokenRefresh(projectId) {
71
71
  }
72
72
  /**
73
73
  * Single entry point for acquiring a Drive access token, used by BOTH the
74
- * interactive "connect" path (interactive: true -> prompt: 'consent', no
75
- * hint) and the silent "refresh" path (interactive: false -> prompt: 'none',
76
- * hint: the connection's known email).
74
+ * interactive "connect" path (interactive: true -> prompt: '', i.e. no
75
+ * forced consent screen) and the silent "refresh" path (interactive: false
76
+ * -> prompt: 'none'). Both pass `hint`: the connection's known email, when
77
+ * there is one.
77
78
  *
78
79
  * Design contract (see report): if `interactive` is false and GIS reports an
79
80
  * error on the silent attempt, this function throws a NeedsReauthError
@@ -248,8 +249,19 @@ async function acquireTokenUncoalesced(opts) {
248
249
  let response;
249
250
  try {
250
251
  response = await requestGisToken(initTokenClient, opts, {
251
- prompt: opts.interactive ? 'consent' : 'none',
252
- hint: !opts.interactive ? opts.hint : undefined,
252
+ // The interactive path deliberately does NOT force `prompt: 'consent'`.
253
+ // Forcing the full consent screen on every connect buys nothing in the
254
+ // implicit (token) flow — there is no refresh token to obtain — while
255
+ // holding a popup open for seconds. That popup lifetime IS the window
256
+ // in which GIS's popup-closed poll beats delivery of the token, so
257
+ // forcing consent manufactures the very race the probe below recovers
258
+ // from. `prompt: ''` lets Google skip straight through when the grant
259
+ // already exists (and still shows consent on the first grant, or when
260
+ // new scopes are requested), which closes the race instead of racing
261
+ // it. The hint goes on both paths so an already-known account can skip
262
+ // the chooser too.
263
+ prompt: opts.interactive ? '' : 'none',
264
+ hint: opts.hint,
253
265
  });
254
266
  }
255
267
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-webapp/drive-sync",
3
- "version": "0.5.5",
3
+ "version": "0.5.6",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",