@kubun/provider-google 0.17.1 → 0.18.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/lib/index.d.ts +6 -0
- package/lib/index.js +8 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { OAuthProviderDefinition } from '@kokuin/oauth';
|
|
2
2
|
export { createGoogleAPIClient, type GoogleAPIClient, type GoogleAPIClientConfig, type GoogleAPIFailure, type GoogleAPIGetOptions, type GoogleAPISendOptions, type GoogleErrorBody, parseGoogleErrorBody, } from './api.js';
|
|
3
3
|
export declare const googleAuthorizationParams: Record<string, string>;
|
|
4
|
+
type GoogleExistingCredential = {
|
|
5
|
+
accessToken: string;
|
|
6
|
+
scopes: Array<string>;
|
|
7
|
+
metadata?: Record<string, unknown>;
|
|
8
|
+
};
|
|
4
9
|
type CreateGoogleProviderParams = {
|
|
5
10
|
mode: 'confidential';
|
|
6
11
|
clientID: string;
|
|
@@ -12,4 +17,5 @@ type CreateGoogleProviderParams = {
|
|
|
12
17
|
};
|
|
13
18
|
export declare function createGoogleProvider(params: CreateGoogleProviderParams): OAuthProviderDefinition & {
|
|
14
19
|
authorizationParams?: Record<string, string>;
|
|
20
|
+
incrementalAuthorizationParams?: (existing: GoogleExistingCredential) => Record<string, string>;
|
|
15
21
|
};
|
package/lib/index.js
CHANGED
|
@@ -22,7 +22,14 @@ export function createGoogleProvider(params) {
|
|
|
22
22
|
'profile',
|
|
23
23
|
'email'
|
|
24
24
|
],
|
|
25
|
-
authorizationParams: googleAuthorizationParams
|
|
25
|
+
authorizationParams: googleAuthorizationParams,
|
|
26
|
+
incrementalAuthorizationParams: (existing)=>({
|
|
27
|
+
include_granted_scopes: 'true',
|
|
28
|
+
prompt: 'consent',
|
|
29
|
+
...typeof existing.metadata?.googleAccountEmail === 'string' ? {
|
|
30
|
+
login_hint: existing.metadata.googleAccountEmail
|
|
31
|
+
} : {}
|
|
32
|
+
})
|
|
26
33
|
};
|
|
27
34
|
return params.mode === 'confidential' ? {
|
|
28
35
|
...base,
|