@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.
- package/dist/connection.d.ts +3 -2
- package/dist/connection.js +3 -2
- package/dist/token.d.ts +4 -3
- package/dist/token.js +17 -5
- package/package.json +1 -1
package/dist/connection.d.ts
CHANGED
|
@@ -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
|
|
19
|
-
* resolves the account email, and persists the durable Connection
|
|
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 {
|
package/dist/connection.js
CHANGED
|
@@ -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
|
|
9
|
-
* resolves the account email, and persists the durable Connection
|
|
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: '
|
|
37
|
-
*
|
|
38
|
-
*
|
|
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: '
|
|
75
|
-
*
|
|
76
|
-
*
|
|
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
|
-
|
|
252
|
-
|
|
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) {
|