capacitor-native-google-one-tap-signin 0.5.2 → 0.5.3
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 +6 -0
- package/android/src/main/java/com/proventask/capacitor/GoogleOneTapAuth/GoogleOneTapAuth.java +0 -29
- package/dist/docs.json +3 -3
- package/dist/esm/GoogleOneTapAuth.d.ts +10 -3
- package/dist/esm/GoogleOneTapAuth.js +130 -32
- package/dist/esm/GoogleOneTapAuth.js.map +1 -1
- package/dist/esm/definitions.d.ts +7 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/definitionsInternal.d.ts +7 -0
- package/dist/esm/definitionsInternal.js +2 -0
- package/dist/esm/definitionsInternal.js.map +1 -0
- package/dist/esm/web.d.ts +4 -5
- package/dist/esm/web.js +28 -20
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +155 -51
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +155 -51
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Plugin.swift +26 -39
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -96,7 +96,11 @@ See `src/definitions.ts` for a complete definition.
|
|
|
96
96
|
|
|
97
97
|
```TypeScript
|
|
98
98
|
/**
|
|
99
|
+
* Performs common or one-time initializations.
|
|
99
100
|
* For the web platform, starts pre-loading the google one tap JavaScript library.
|
|
101
|
+
* initialize must be called before any other method.
|
|
102
|
+
* initialize remembers if it was called so it is safe to be called multiple times.
|
|
103
|
+
* Other methods wait till initialize is finished so you must not await initialize.
|
|
100
104
|
* @param options
|
|
101
105
|
*/
|
|
102
106
|
initialize(options: InitializeOptions): Promise<void>;
|
|
@@ -122,6 +126,8 @@ tryAutoOrOneTapSignIn()
|
|
|
122
126
|
/**
|
|
123
127
|
* Renders the sign-in button.
|
|
124
128
|
* The returned promise will only resolve if successful.
|
|
129
|
+
* The returned promise is rejected for unrecoverable errors as 'unregistered_origin'
|
|
130
|
+
* for the web platform.
|
|
125
131
|
* @param parentElementId
|
|
126
132
|
* @param options
|
|
127
133
|
* @param gsiButtonConfiguration Not all button configuration options are supported on android.
|
package/android/src/main/java/com/proventask/capacitor/GoogleOneTapAuth/GoogleOneTapAuth.java
CHANGED
|
@@ -38,7 +38,6 @@ import java.util.concurrent.Future;
|
|
|
38
38
|
|
|
39
39
|
@CapacitorPlugin()
|
|
40
40
|
public class GoogleOneTapAuth extends Plugin {
|
|
41
|
-
private enum SignInMethod {NotSignedIn, OneTap, GoogleSignIn}
|
|
42
41
|
private static final String TAG = "GoogleOneTapAuth Plugin";
|
|
43
42
|
private String clientId;
|
|
44
43
|
private String nonce;
|
|
@@ -47,7 +46,6 @@ public class GoogleOneTapAuth extends Plugin {
|
|
|
47
46
|
private ActivityResultLauncher<IntentSenderRequest> googleOneTapSignInActivityResultHandlerIntentSenderRequest;
|
|
48
47
|
private CompletableFuture<JSObject> oneTapSignInFuture;
|
|
49
48
|
private CompletableFuture<JSObject> googleSignInFuture;
|
|
50
|
-
private SignInMethod signInMethod = SignInMethod.NotSignedIn;
|
|
51
49
|
|
|
52
50
|
@Override
|
|
53
51
|
public void load() {
|
|
@@ -82,7 +80,6 @@ public class GoogleOneTapAuth extends Plugin {
|
|
|
82
80
|
try {
|
|
83
81
|
Intent data = result.getData();
|
|
84
82
|
var credential = oneTapClient.getSignInCredentialFromIntent(data);
|
|
85
|
-
signInMethod = SignInMethod.OneTap;
|
|
86
83
|
oneTapSignInFuture.complete(createSuccessResponse(credential.getGoogleIdToken()));
|
|
87
84
|
} catch (ApiException e) {
|
|
88
85
|
oneTapSignInFuture.complete(createErrorResponse(null, e.toString()));
|
|
@@ -187,30 +184,11 @@ public class GoogleOneTapAuth extends Plugin {
|
|
|
187
184
|
}
|
|
188
185
|
|
|
189
186
|
private JSObject createSuccessResponse(String idToken) {
|
|
190
|
-
var decodedIdToken = decodeJwtBody(idToken);
|
|
191
|
-
JSONObject decodedIdTokenJson = null;
|
|
192
|
-
String userId = null;
|
|
193
|
-
String email = null;
|
|
194
|
-
try {
|
|
195
|
-
decodedIdTokenJson = new JSONObject(decodedIdToken);
|
|
196
|
-
userId = decodedIdTokenJson.getString("sub");
|
|
197
|
-
email = decodedIdTokenJson.getString("email");
|
|
198
|
-
} catch (JSONException e) {
|
|
199
|
-
// Do nothing.
|
|
200
|
-
}
|
|
201
187
|
var result = new JSObject();
|
|
202
188
|
result.put("idToken", idToken);
|
|
203
|
-
result.put("userId", userId);
|
|
204
|
-
result.put("email", email);
|
|
205
|
-
result.put("decodedIdToken", decodedIdTokenJson);
|
|
206
189
|
return result;
|
|
207
190
|
}
|
|
208
191
|
|
|
209
|
-
private String decodeJwtBody(String jwtToken) {
|
|
210
|
-
var parts = jwtToken.split("\\.");
|
|
211
|
-
return new String(android.util.Base64.decode(parts[1], android.util.Base64.DEFAULT));
|
|
212
|
-
}
|
|
213
|
-
|
|
214
192
|
private boolean isGooglePlayServicesAvailable(Context context) {
|
|
215
193
|
var googleApiAvailability = GoogleApiAvailability.getInstance();
|
|
216
194
|
int resultCode = googleApiAvailability.isGooglePlayServicesAvailable(context);
|
|
@@ -237,12 +215,6 @@ public class GoogleOneTapAuth extends Plugin {
|
|
|
237
215
|
return signOutResult;
|
|
238
216
|
}
|
|
239
217
|
|
|
240
|
-
private JSObject createSuccessResult() {
|
|
241
|
-
var jsObject = new JSObject();
|
|
242
|
-
jsObject.put("isSuccess", true);
|
|
243
|
-
return jsObject;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
218
|
private Future<JSObject> googleSilentSignIn(final PluginCall call) {
|
|
247
219
|
googleSignInFuture = new CompletableFuture<>();
|
|
248
220
|
googleSignInClient.silentSignIn()
|
|
@@ -271,7 +243,6 @@ public class GoogleOneTapAuth extends Plugin {
|
|
|
271
243
|
String triggerMethodName) {
|
|
272
244
|
try {
|
|
273
245
|
var account = completedTask.getResult(ApiException.class);
|
|
274
|
-
signInMethod = SignInMethod.GoogleSignIn;
|
|
275
246
|
Log.i(TAG, triggerMethodName + " result " + account.toString());
|
|
276
247
|
googleSignInFuture.complete(createSuccessResponse(account.getIdToken()));
|
|
277
248
|
} catch (ApiException e) {
|
package/dist/docs.json
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"text": "options"
|
|
23
23
|
}
|
|
24
24
|
],
|
|
25
|
-
"docs": "
|
|
25
|
+
"docs": "Performs common or one-time initializations.\nFor the web platform, starts pre-loading the google one tap JavaScript library.\ninitialize must be called before any other method.\ninitialize remembers if it was called so it is safe to be called multiple times.\nOther methods wait till initialize is finished so you must not await initialize.",
|
|
26
26
|
"complexTypes": [
|
|
27
27
|
"InitializeOptions"
|
|
28
28
|
],
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"text": "gsiButtonConfiguration Not all button configuration options are supported on android."
|
|
83
83
|
}
|
|
84
84
|
],
|
|
85
|
-
"docs": "Renders the sign-in button.\nThe returned promise will only resolve if successful.",
|
|
85
|
+
"docs": "Renders the sign-in button.\nThe returned promise will only resolve if successful.\nThe returned promise is rejected for unrecoverable errors as 'unregistered_origin' \nfor the web platform.",
|
|
86
86
|
"complexTypes": [
|
|
87
87
|
"SuccessSignInResult",
|
|
88
88
|
"RenderSignInButtonOptions",
|
|
@@ -193,7 +193,7 @@
|
|
|
193
193
|
{
|
|
194
194
|
"name": "noSuccessReasonCode",
|
|
195
195
|
"tags": [],
|
|
196
|
-
"docs": "A reason code as 'opt_out_or_no_session'.\nFor the js library see google.PromptMomentNotification for possible values.\nFor android '
|
|
196
|
+
"docs": "A reason code as 'opt_out_or_no_session'.\nFor the js library see google.PromptMomentNotification for possible values.\nFor android 'SIGN_IN_CANCELLED' are currently set.",
|
|
197
197
|
"complexTypes": [],
|
|
198
198
|
"type": "string | undefined"
|
|
199
199
|
},
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import type { InitializeOptions, GoogleOneTapAuthPlugin, SignInResultPromises, SuccessSignInResult, SignOutResult, RenderSignInButtonOptions } from './definitions';
|
|
2
2
|
declare class GoogleOneTapAuth implements GoogleOneTapAuthPlugin {
|
|
3
|
-
nonce
|
|
4
|
-
|
|
3
|
+
private nonce?;
|
|
4
|
+
private initializeStatus;
|
|
5
|
+
private isInitializedPromise;
|
|
6
|
+
private resolveIsInitializedPromise;
|
|
7
|
+
private authenticatedUserId?;
|
|
8
|
+
constructor();
|
|
5
9
|
initialize(options: InitializeOptions): Promise<void>;
|
|
10
|
+
private ensureInitialized;
|
|
6
11
|
tryAutoOrOneTapSignIn(): Promise<SignInResultPromises>;
|
|
7
12
|
signOut(): Promise<SignOutResult>;
|
|
8
13
|
renderSignInButton(parentElementId: string, options: RenderSignInButtonOptions, gsiButtonConfiguration?: google.GsiButtonConfiguration): Promise<SuccessSignInResult>;
|
|
9
14
|
getNonce(): string;
|
|
10
|
-
|
|
15
|
+
private enrichOptionResultWithDecodedIdToken;
|
|
16
|
+
private enrichSuccessResultWithDecodedIdToken;
|
|
17
|
+
private getSignInButtonHtml;
|
|
11
18
|
}
|
|
12
19
|
declare const googleOneTapAuth: GoogleOneTapAuth;
|
|
13
20
|
export { googleOneTapAuth as GoogleOneTapAuth };
|
|
@@ -1,70 +1,168 @@
|
|
|
1
1
|
import { Capacitor, registerPlugin } from '@capacitor/core';
|
|
2
2
|
import { assert, randomHexString } from './helpers';
|
|
3
3
|
import { GoogleOneTapAuthWeb } from './web';
|
|
4
|
+
import jwt_decode from 'jwt-decode';
|
|
4
5
|
const GoogleOneTapAuthPlatform = registerPlugin('GoogleOneTapAuth', {
|
|
5
6
|
web: () => new GoogleOneTapAuthWeb(),
|
|
6
7
|
});
|
|
8
|
+
var InitializeStatus;
|
|
9
|
+
(function (InitializeStatus) {
|
|
10
|
+
InitializeStatus[InitializeStatus["NotInitialized"] = 0] = "NotInitialized";
|
|
11
|
+
InitializeStatus[InitializeStatus["Initializing"] = 1] = "Initializing";
|
|
12
|
+
InitializeStatus[InitializeStatus["Initialized"] = 2] = "Initialized";
|
|
13
|
+
})(InitializeStatus || (InitializeStatus = {}));
|
|
7
14
|
// This file is the entry point for all plugin methods. It contains common logic to web, android, iOS or delegates to the specific implementation.
|
|
8
15
|
class GoogleOneTapAuth {
|
|
16
|
+
//private notificationCallback: ((notification: string) => void) | undefined;
|
|
9
17
|
constructor() {
|
|
10
|
-
this.
|
|
18
|
+
this.initializeStatus = InitializeStatus.NotInitialized;
|
|
19
|
+
this.authenticatedUserId = undefined;
|
|
20
|
+
this.isInitializedPromise = new Promise((resolve) => {
|
|
21
|
+
this.resolveIsInitializedPromise = resolve;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/// Performs common or one-time initialization. Can be called multiple times.
|
|
25
|
+
initialize(options) {
|
|
26
|
+
if (this.initializeStatus === InitializeStatus.NotInitialized) {
|
|
27
|
+
this.initializeStatus = InitializeStatus.Initializing;
|
|
28
|
+
if (!options.clientId || options.clientId.endsWith("apps.googleusercontent.com") == false) {
|
|
29
|
+
throw new Error("clientId must end with 'apps.googleusercontent.com' but is: " + options.clientId);
|
|
30
|
+
}
|
|
31
|
+
this.nonce = options.nonce = options.nonce || randomHexString(10);
|
|
32
|
+
GoogleOneTapAuthPlatform.initialize(options).then(() => {
|
|
33
|
+
this.initializeStatus = InitializeStatus.Initialized;
|
|
34
|
+
this.resolveIsInitializedPromise();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return this.isInitializedPromise;
|
|
11
38
|
}
|
|
12
|
-
async
|
|
13
|
-
|
|
14
|
-
|
|
39
|
+
async ensureInitialized() {
|
|
40
|
+
assert(() => this.initializeStatus !== InitializeStatus.NotInitialized, 'Must call initialize first.');
|
|
41
|
+
if (this.initializeStatus === InitializeStatus.Initializing) {
|
|
42
|
+
await this.isInitializedPromise;
|
|
15
43
|
}
|
|
16
|
-
this.nonce = options.nonce = options.nonce || randomHexString(10);
|
|
17
|
-
await GoogleOneTapAuthPlatform.initialize(options);
|
|
18
|
-
this.isInitialized = true;
|
|
19
44
|
}
|
|
20
45
|
async tryAutoOrOneTapSignIn() {
|
|
21
|
-
|
|
46
|
+
await this.ensureInitialized();
|
|
22
47
|
const signInResultOptionPromise = GoogleOneTapAuthPlatform.tryAutoOrOneTapSignIn();
|
|
23
|
-
|
|
24
|
-
|
|
48
|
+
const notEnrichtedSignInResultOption = (await signInResultOptionPromise);
|
|
49
|
+
const enrichtedSignInResultOption = this.enrichOptionResultWithDecodedIdToken(notEnrichtedSignInResultOption);
|
|
50
|
+
if (enrichtedSignInResultOption.isSuccess) {
|
|
51
|
+
this.authenticatedUserId = enrichtedSignInResultOption.success.userId;
|
|
25
52
|
return {
|
|
26
|
-
successPromise: Promise.resolve(
|
|
53
|
+
successPromise: Promise.resolve(enrichtedSignInResultOption.success),
|
|
27
54
|
noSuccess: new Promise(() => { }),
|
|
28
|
-
signInResultOptionPromise:
|
|
55
|
+
signInResultOptionPromise: Promise.resolve(enrichtedSignInResultOption)
|
|
29
56
|
};
|
|
30
57
|
}
|
|
31
58
|
else {
|
|
32
59
|
return {
|
|
33
60
|
successPromise: new Promise(() => { }),
|
|
34
|
-
noSuccess: Promise.resolve(
|
|
35
|
-
signInResultOptionPromise:
|
|
61
|
+
noSuccess: Promise.resolve(enrichtedSignInResultOption.noSuccess),
|
|
62
|
+
signInResultOptionPromise: Promise.resolve(enrichtedSignInResultOption)
|
|
36
63
|
};
|
|
37
64
|
}
|
|
38
65
|
}
|
|
39
|
-
signOut() {
|
|
40
|
-
|
|
66
|
+
async signOut() {
|
|
67
|
+
const result = await GoogleOneTapAuthPlatform.signOut(this.authenticatedUserId);
|
|
68
|
+
this.authenticatedUserId = undefined;
|
|
69
|
+
return result;
|
|
41
70
|
}
|
|
42
|
-
renderSignInButton(parentElementId, options, gsiButtonConfiguration) {
|
|
43
|
-
|
|
44
|
-
options.webOptions = options.webOptions || {};
|
|
45
|
-
if (Capacitor.getPlatform() === 'web') {
|
|
46
|
-
return GoogleOneTapAuthPlatform.renderSignInButton(parentElementId, options, gsiButtonConfiguration);
|
|
47
|
-
}
|
|
71
|
+
async renderSignInButton(parentElementId, options, gsiButtonConfiguration) {
|
|
72
|
+
await this.ensureInitialized();
|
|
48
73
|
const parentElem = document.getElementById(parentElementId);
|
|
49
74
|
assert(() => !!parentElem);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (
|
|
54
|
-
|
|
75
|
+
options.webOptions = options.webOptions || {};
|
|
76
|
+
return new Promise(async (resolve, reject) => {
|
|
77
|
+
try {
|
|
78
|
+
if (Capacitor.getPlatform() === 'web') {
|
|
79
|
+
const notEnrichedSuccessSignInResult = await GoogleOneTapAuthPlatform.renderSignInButton(parentElementId, options, gsiButtonConfiguration);
|
|
80
|
+
console.log('notEnrichedSuccessSignInResult', notEnrichedSuccessSignInResult);
|
|
81
|
+
const enrichtedSuccessSignInResult = this.enrichSuccessResultWithDecodedIdToken(notEnrichedSuccessSignInResult);
|
|
82
|
+
this.authenticatedUserId = enrichtedSuccessSignInResult.userId;
|
|
83
|
+
resolve(enrichtedSuccessSignInResult);
|
|
84
|
+
return;
|
|
55
85
|
}
|
|
56
|
-
|
|
57
|
-
|
|
86
|
+
console.log('no onlick');
|
|
87
|
+
const onClickAction = async () => {
|
|
88
|
+
try {
|
|
89
|
+
let notEnrichedSuccessSignInResult = await GoogleOneTapAuthPlatform.triggerGoogleSignIn(options);
|
|
90
|
+
if (Boolean(notEnrichedSuccessSignInResult.idToken)) {
|
|
91
|
+
const enrichtedSuccessSignInResult = this.enrichSuccessResultWithDecodedIdToken(notEnrichedSuccessSignInResult);
|
|
92
|
+
this.authenticatedUserId = enrichtedSuccessSignInResult.userId;
|
|
93
|
+
resolve(enrichtedSuccessSignInResult);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
reject(e);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
parentElem.appendChild(this.getSignInButtonHtml(onClickAction, gsiButtonConfiguration));
|
|
101
|
+
}
|
|
102
|
+
catch (e) {
|
|
103
|
+
reject(e);
|
|
104
|
+
}
|
|
58
105
|
});
|
|
59
106
|
}
|
|
107
|
+
// user_cancel,
|
|
108
|
+
// registerNotificationCallback(callback: (notification: string) => void) {
|
|
109
|
+
// //this.notificationCallback = callback;
|
|
110
|
+
// }
|
|
60
111
|
getNonce() {
|
|
61
112
|
assert(() => !!this.nonce, `The nonce is only set after ${() => this.initialize} was called.`);
|
|
62
113
|
return this.nonce;
|
|
63
114
|
}
|
|
64
|
-
|
|
115
|
+
enrichOptionResultWithDecodedIdToken(signInResultOption) {
|
|
116
|
+
if (signInResultOption.isSuccess === false) {
|
|
117
|
+
return signInResultOption;
|
|
118
|
+
}
|
|
119
|
+
return Object.assign(Object.assign({}, signInResultOption), { success: this.enrichSuccessResultWithDecodedIdToken(signInResultOption.success) });
|
|
120
|
+
}
|
|
121
|
+
enrichSuccessResultWithDecodedIdToken(successSignInResult) {
|
|
122
|
+
const decodedJwt = jwt_decode(successSignInResult.idToken);
|
|
123
|
+
return Object.assign(Object.assign({}, successSignInResult), { decodedIdToken: decodedJwt, userId: decodedJwt.sub, email: decodedJwt.email });
|
|
124
|
+
}
|
|
125
|
+
getSignInButtonHtml(onClickAction, gsiButtonConfiguration) {
|
|
126
|
+
var _a;
|
|
127
|
+
// Note: Replacing double quotes with single quotes will break some strings.
|
|
128
|
+
const localizedStrings = {
|
|
129
|
+
en: { signin: 'Sign in', continue_with: 'Continue with Google', signin_with: 'Sign in with Google', signup_with: 'Sign up with Google' },
|
|
130
|
+
ar: { signin: '\u062a\u0633\u062c\u064a\u0644 \u0627\u0644\u062f\u062e\u0648\u0644', continue_with: '\u0627\u0644\u0645\u0648\u0627\u0635\u0644\u0629 \u0628\u0627\u0633\u062a\u062e\u062f\u0627\u0645 Google', signin_with: '\u062a\u0633\u062c\u064a\u0644 \u0627\u0644\u062f\u062e\u0648\u0644 \u0628\u0627\u0633\u062a\u062e\u062f\u0627\u0645 Google', signup_with: '\u0627\u0644\u0627\u0634\u062a\u0631\u0627\u0643 \u0645\u0646 \u062e\u0644\u0627\u0644 Google' },
|
|
131
|
+
sr: { signin: '\u041f\u0440\u0438\u0458\u0430\u0432\u0438 \u043c\u0435', continue_with: '\u041d\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u0435 \u0441\u0430 Google-\u043e\u043c', signin_with: '\u041f\u0440\u0438\u0458\u0430\u0432\u0438\u0442\u0435 \u0441\u0435 \u043f\u043e\u043c\u043e\u045b\u0443 Google-\u0430', signup_with: '\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0443\u0458\u0442\u0435 \u0441\u0435 \u043f\u043e\u043c\u043e\u045b\u0443 Google-\u0430' },
|
|
132
|
+
nb: { signin: 'Logg p\u00e5', continue_with: 'Fortsett med Google', signin_with: 'Logg p\u00e5 med Google', signup_with: 'Registrer deg med Google' },
|
|
133
|
+
pl: { signin: 'Zaloguj si\u0119', continue_with: 'Kontynuuj przy u\u017cyciu konta Google', signin_with: 'Zaloguj si\u0119 przez Google', signup_with: 'Zarejestruj si\u0119 przez Google' },
|
|
134
|
+
vi: { signin: '\u0110\u0103ng nh\u1eadp', continue_with: 'Ti\u1ebfp t\u1ee5c truy c\u1eadp Google', signin_with: '\u0110\u0103ng nh\u00e2\u0323p b\u0103\u0300ng Google', signup_with: '\u0110\u0103ng k\u00fd b\u1eb1ng Google' },
|
|
135
|
+
cs: { signin: 'P\u0159ihl\u00e1sit se', continue_with: 'Pokra\u010dovat pomoc\u00ed Googlu', signin_with: "P\u0159ihl\u00e1sit se p\u0159es Google", signup_with: 'Registrace pomoc\u00ed Googlu' },
|
|
136
|
+
id: { signin: 'Login', continue_with: 'Lanjutkan dengan Google', signin_with: 'Login dengan Google', signup_with: 'Daftar dengan Google' },
|
|
137
|
+
nl: { signin: 'Inloggen', continue_with: 'Doorgaan met Google', signin_with: 'Inloggen met Google', signup_with: 'Aanmelden bij Google' },
|
|
138
|
+
gl: { signin: 'Iniciar sesi\u00f3n', continue_with: 'Continuar con Google', signin_with: 'Iniciar sesi\u00f3n con Google', signup_with: 'Iniciar sesi\u00f3n con Google' },
|
|
139
|
+
sv: { signin: 'Logga in', continue_with: 'Forts\u00e4tt med Google', signin_with: 'Logga in med Google', signup_with: 'Registrera dig med Google' },
|
|
140
|
+
lv: { signin: 'Pierakst\u012b\u0161an\u0101s', continue_with: 'Turpin\u0101t darbu ar Google', signin_with: 'Pierakstieties ar Google', signup_with: 'Re\u0123istr\u0113\u0161an\u0101s, izmantojot Google' },
|
|
141
|
+
tr: { signin: 'Oturum a\u00e7\u0131n', continue_with: 'Google ile devam edin', signin_with: 'Google ile oturum a\u00e7\u0131n', signup_with: 'Google ile kaydolun' },
|
|
142
|
+
it: { signin: 'Accedi', continue_with: 'Continua con Google', signin_with: 'Accedi con Google', signup_with: 'Registrati con Google' },
|
|
143
|
+
sq: { signin: 'Identifikohu', continue_with: 'Vazhdo me Google', signin_with: 'Identifikohu me Google', signup_with: 'Regjistrohu me Google' },
|
|
144
|
+
ro: { signin: 'Conecteaz\u0103-te', continue_with: 'Continu\u0103 cu Google', signin_with: 'Conecteaz\u0103-te cu Google', signup_with: '\u00censcrie-te cu Google' },
|
|
145
|
+
de: { signin: 'Anmelden', continue_with: 'Weiter mit Google', signin_with: '\u00dcber Google anmelden', signup_with: 'Mit Google anmelden' },
|
|
146
|
+
ko: { signin: '\ub85c\uadf8\uc778', continue_with: 'Google \uacc4\uc815\uc73c\ub85c \uacc4\uc18d\ud558\uae30', signin_with: 'Google \uacc4\uc815\uc73c\ub85c \ub85c\uadf8\uc778', signup_with: 'Google \uacc4\uc815\uc73c\ub85c \uac00\uc785\ud558\uae30' },
|
|
147
|
+
fr: { signin: 'Se connecter', continue_with: 'Continuer avec Google', signin_with: 'Se connecter avec Google', signup_with: "S'inscrire avec Google" },
|
|
148
|
+
kmr: { signin: 'Oturum a\u00e7\u0131n', continue_with: 'Google ile devam edin', signin_with: 'Google ile oturum a\u00e7\u0131n', signup_with: 'Google ile kaydolun' },
|
|
149
|
+
zh: { signin: '\u767b\u5f55', continue_with: '\u901a\u8fc7 Google \u7ee7\u7eed\u64cd\u4f5c', signin_with: "\u4f7f\u7528 Google \u5e10\u53f7\u767b\u5f55", signup_with: '\u4f7f\u7528 Google \u5e10\u53f7\u6ce8\u518c' },
|
|
150
|
+
'zh-CN': { signin: '\u767b\u5f55', continue_with: '\u901a\u8fc7 Google \u7ee7\u7eed\u64cd\u4f5c', signin_with: "\u4f7f\u7528 Google \u5e10\u53f7\u767b\u5f55", signup_with: '\u4f7f\u7528 Google \u5e10\u53f7\u6ce8\u518c' },
|
|
151
|
+
'zh-HK': { signin: '\u767b\u5165', continue_with: '\u7e7c\u7e8c\u900f\u904e Google \u5e33\u6236\u64cd\u4f5c', signin_with: '\u4f7f\u7528 Google \u5e33\u6236\u767b\u5165', signup_with: '\u4f7f\u7528 Google \u5e33\u6236\u8a3b\u518a' },
|
|
152
|
+
pt: { signin: 'Fazer login', continue_with: 'Continuar com o Google', signin_with: 'Fazer login com o Google', signup_with: 'Inscrever-se no Google' },
|
|
153
|
+
es: { signin: 'Iniciar sesi\u00f3n', continue_with: 'Continuar con Google', signin_with: 'Iniciar sesi\u00f3n con Google', signup_with: 'Registrarse con Google' },
|
|
154
|
+
};
|
|
155
|
+
const locale = gsiButtonConfiguration === null || gsiButtonConfiguration === void 0 ? void 0 : gsiButtonConfiguration.locale;
|
|
156
|
+
let localeTexts = locale !== undefined && locale in localizedStrings ? (localizedStrings[locale]) : undefined;
|
|
157
|
+
if (localeTexts === undefined) {
|
|
158
|
+
const countryCode = (locale === null || locale === void 0 ? void 0 : locale.includes('-')) === true ? locale.split('-')[1] : (locale !== null && locale !== void 0 ? locale : '');
|
|
159
|
+
localeTexts = countryCode in localizedStrings ? localizedStrings[countryCode] : localizedStrings['en'];
|
|
160
|
+
}
|
|
161
|
+
const text = (_a = gsiButtonConfiguration === null || gsiButtonConfiguration === void 0 ? void 0 : gsiButtonConfiguration.text) !== null && _a !== void 0 ? _a : 'signin_with';
|
|
162
|
+
const buttonText = localeTexts[text];
|
|
65
163
|
// HTML from https://github.com/inouiw/ReactSignInWithGoogleButton
|
|
66
164
|
const button = document.createElement('button');
|
|
67
|
-
button.setAttribute("style", "border-radius: 4px; background-color: rgb(255, 255, 255); border: 1px solid rgb(218, 220, 224); color: rgb(60, 64, 67); cursor: pointer; font-family: Roboto; font-weight: 500; font-size: 14px; height: 40px; letter-spacing: 0.25px; padding: 0px 12px; position: relative; text-align: center; vertical-align: middle; width: auto;");
|
|
165
|
+
button.setAttribute("style", "border-radius: 4px; background-color: rgb(255, 255, 255); border: 1px solid rgb(218, 220, 224); color: rgb(60, 64, 67); cursor: pointer; font-family: Roboto, Verdana; font-weight: 500; font-size: 14px; height: 40px; letter-spacing: 0.25px; padding: 0px 12px; position: relative; text-align: center; vertical-align: middle; width: auto;");
|
|
68
166
|
button.onclick = onClickAction;
|
|
69
167
|
button.innerHTML = `
|
|
70
168
|
<div style="display: flex; align-items: center; flex-flow: row nowrap; justify-content: space-between; height: 100%; position: relative; width: 100%;">
|
|
@@ -79,7 +177,7 @@ class GoogleOneTapAuth {
|
|
|
79
177
|
</g>
|
|
80
178
|
</svg>
|
|
81
179
|
</div>
|
|
82
|
-
<p
|
|
180
|
+
<p>${buttonText}</p>
|
|
83
181
|
</div>`;
|
|
84
182
|
return button;
|
|
85
183
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleOneTapAuth.js","sourceRoot":"","sources":["../../src/GoogleOneTapAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAE5C,MAAM,wBAAwB,GAAG,cAAc,CAAsB,kBAAkB,EAAE;IACvF,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,mBAAmB,EAAE;CACrC,CAAC,CAAC;A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AC,CAAC;QAChD,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,wUAAwU,CAAC,CAAC;QACvW,MAAM,CAAC,OAAO,GAAG,aAAa,CAAC;QAC/B,MAAM,CAAC,SAAS,GAAG;;;;;;;;;;;;;;aAcV,CAAC;QACV,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAC;AAChD,OAAO,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,CAAA","sourcesContent":["import { Capacitor, registerPlugin } from '@capacitor/core';\nimport type { InitializeOptions, GoogleOneTapAuthPlugin, SignInResultPromises, SuccessSignInResult, SignOutResult, RenderSignInButtonOptions, NoSuccessSignInResult } from './definitions';\nimport { assert, randomHexString } from './helpers';\nimport { GoogleOneTapAuthWeb } from './web';\n\nconst GoogleOneTapAuthPlatform = registerPlugin<GoogleOneTapAuthWeb>('GoogleOneTapAuth', {\n web: () => new GoogleOneTapAuthWeb(),\n});\n\n// This file is the entry point for all plugin methods. It contains common logic to web, android, iOS or delegates to the specific implementation.\nclass GoogleOneTapAuth implements GoogleOneTapAuthPlugin {\n nonce?: string;\n isInitialized = false;\n\n async initialize(options: InitializeOptions): Promise<void> {\n if (!options.clientId || options.clientId.endsWith(\"apps.googleusercontent.com\") == false) {\n throw new Error(\"clientId must end with 'apps.googleusercontent.com' but is: \" + options.clientId);\n }\n this.nonce = options.nonce = options.nonce || randomHexString(10);\n await GoogleOneTapAuthPlatform.initialize(options);\n this.isInitialized = true;\n }\n\n async tryAutoOrOneTapSignIn(): Promise<SignInResultPromises> {\n assert(() => this.isInitialized, 'Must call and await initialize first.');\n const signInResultOptionPromise = GoogleOneTapAuthPlatform.tryAutoOrOneTapSignIn();\n let signInResultOption = await signInResultOptionPromise;\n\n if (signInResultOption.isSuccess) {\n return {\n successPromise: Promise.resolve(signInResultOption.success!),\n noSuccess: new Promise<NoSuccessSignInResult>(() => {}),\n signInResultOptionPromise: signInResultOptionPromise\n };\n } else {\n return {\n successPromise: new Promise<SuccessSignInResult>(() => {}),\n noSuccess: Promise.resolve(signInResultOption.noSuccess!),\n signInResultOptionPromise: signInResultOptionPromise\n };\n }\n }\n\n signOut(): Promise<SignOutResult> {\n return GoogleOneTapAuthPlatform.signOut();\n }\n \n renderSignInButton(parentElementId: string, options: RenderSignInButtonOptions, gsiButtonConfiguration?: google.GsiButtonConfiguration): Promise<SuccessSignInResult> {\n assert(() => this.isInitialized, 'Must call and await initialize first.');\n options.webOptions = options.webOptions || {};\n if (Capacitor.getPlatform() === 'web') {\n return GoogleOneTapAuthPlatform.renderSignInButton(parentElementId, options, gsiButtonConfiguration);\n }\n const parentElem = document.getElementById(parentElementId);\n assert(() => !!parentElem);\n return new Promise<SuccessSignInResult>((resolve) => {\n const onClickAction = async () => {\n let signInResult = await (GoogleOneTapAuthPlatform as any).triggerGoogleSignIn(options);\n if (Boolean(signInResult.idToken)) {\n resolve(signInResult);\n }\n };\n parentElem!.appendChild(this._getSignInButtonHtml(onClickAction));\n });\n }\n\n getNonce() {\n assert(() => !!this.nonce, `The nonce is only set after ${() => this.initialize} was called.`);\n return this.nonce!;\n }\n\n _getSignInButtonHtml(onClickAction: () => any) {\n // HTML from https://github.com/inouiw/ReactSignInWithGoogleButton\n const button = document.createElement('button');\n button.setAttribute(\"style\", \"border-radius: 4px; background-color: rgb(255, 255, 255); border: 1px solid rgb(218, 220, 224); color: rgb(60, 64, 67); cursor: pointer; font-family: Roboto; font-weight: 500; font-size: 14px; height: 40px; letter-spacing: 0.25px; padding: 0px 12px; position: relative; text-align: center; vertical-align: middle; width: auto;\");\n button.onclick = onClickAction;\n button.innerHTML = `\n <div style=\"display: flex; align-items: center; flex-flow: row nowrap; justify-content: space-between; height: 100%; position: relative; width: 100%;\">\n <div style=\"height: 18px; margin-right: 8px; min-width: 18px; width: 18px;\">\n <svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" width=\"18px\" height=\"18px\" viewBox=\"0 0 48 48\">\n <g>\n <path fill=\"#EA4335\" d=\"M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z\"></path>\n <path fill=\"#4285F4\" d=\"M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z\"></path>\n <path fill=\"#FBBC05\" d=\"M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z\"></path>\n <path fill=\"#34A853\" d=\"M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z\"></path>\n <path fill=\"none\" d=\"M0 0h48v48H0z\"></path>\n </g>\n </svg>\n </div>\n <p>Sign in with Google</p>\n </div>`;\n return button;\n }\n}\n\nconst googleOneTapAuth = new GoogleOneTapAuth();\nexport { googleOneTapAuth as GoogleOneTapAuth }"]}
|
|
1
|
+
{"version":3,"file":"GoogleOneTapAuth.js","sourceRoot":"","sources":["../../src/GoogleOneTapAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,UAAU,MAAM,YAAY,CAAC;AAGpC,MAAM,wBAAwB,GAAG,cAAc,CAAsB,kBAAkB,EAAE;IACvF,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,mBAAmB,EAAE;CACrC,CAAC,CAAC;AAEH,IAAK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AW,GAAG,WAAW,IAAI,gBAAgB,CAAC,CAAC,CAAE,gBAAgB,CAAC,WAAW,CAAY,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;SACpH;QACD,MAAM,IAAI,GAAG,MAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,IAAI,mCAAI,aAAa,CAAC;QAC3D,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QAErC,kEAAkE;QAClE,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,iVAAiV,CAAC,CAAC;QAChX,MAAM,CAAC,OAAO,GAAG,aAAa,CAAC;QAC/B,MAAM,CAAC,SAAS,GAAG;;;;;;;;;;;;;aAaV,UAAU;aACV,CAAC;QACV,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAC;AAChD,OAAO,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,CAAA","sourcesContent":["import { Capacitor, registerPlugin } from '@capacitor/core';\nimport type { InitializeOptions, GoogleOneTapAuthPlugin, SignInResultPromises, SuccessSignInResult, SignOutResult, RenderSignInButtonOptions, NoSuccessSignInResult, SignInResultOption } from './definitions';\nimport { assert, randomHexString } from './helpers';\nimport { GoogleOneTapAuthWeb } from './web';\nimport jwt_decode from 'jwt-decode';\nimport type { NotEnrichedSuccessSignInResult, NotEnrichtedSignInResultOption } from './definitionsInternal';\n\nconst GoogleOneTapAuthPlatform = registerPlugin<GoogleOneTapAuthWeb>('GoogleOneTapAuth', {\n web: () => new GoogleOneTapAuthWeb(),\n});\n\nenum InitializeStatus { NotInitialized, Initializing, Initialized }\n\n// This file is the entry point for all plugin methods. It contains common logic to web, android, iOS or delegates to the specific implementation.\nclass GoogleOneTapAuth implements GoogleOneTapAuthPlugin {\n private nonce?: string;\n private initializeStatus = InitializeStatus.NotInitialized;\n private isInitializedPromise: Promise<void>;\n private resolveIsInitializedPromise: (() => void) | undefined;\n private authenticatedUserId?: string = undefined;\n //private notificationCallback: ((notification: string) => void) | undefined;\n\n constructor() {\n this.isInitializedPromise = new Promise<void>((resolve) => {\n this.resolveIsInitializedPromise = resolve;\n });\n }\n\n /// Performs common or one-time initialization. Can be called multiple times.\n initialize(options: InitializeOptions): Promise<void> {\n if (this.initializeStatus === InitializeStatus.NotInitialized) {\n this.initializeStatus = InitializeStatus.Initializing;\n if (!options.clientId || options.clientId.endsWith(\"apps.googleusercontent.com\") == false) {\n throw new Error(\"clientId must end with 'apps.googleusercontent.com' but is: \" + options.clientId);\n }\n this.nonce = options.nonce = options.nonce || randomHexString(10);\n GoogleOneTapAuthPlatform.initialize(options).then(() => {\n this.initializeStatus = InitializeStatus.Initialized;\n this.resolveIsInitializedPromise!();\n });\n }\n return this.isInitializedPromise;\n }\n\n private async ensureInitialized() {\n assert(() => this.initializeStatus !== InitializeStatus.NotInitialized, 'Must call initialize first.');\n if (this.initializeStatus === InitializeStatus.Initializing) {\n await this.isInitializedPromise;\n }\n }\n\n async tryAutoOrOneTapSignIn(): Promise<SignInResultPromises> {\n await this.ensureInitialized();\n const signInResultOptionPromise = GoogleOneTapAuthPlatform.tryAutoOrOneTapSignIn();\n const notEnrichtedSignInResultOption = (await signInResultOptionPromise) as NotEnrichtedSignInResultOption;\n const enrichtedSignInResultOption = this.enrichOptionResultWithDecodedIdToken(notEnrichtedSignInResultOption);\n\n if (enrichtedSignInResultOption.isSuccess) {\n this.authenticatedUserId = enrichtedSignInResultOption.success!.userId;\n return {\n successPromise: Promise.resolve(enrichtedSignInResultOption.success!),\n noSuccess: new Promise<NoSuccessSignInResult>(() => { }),\n signInResultOptionPromise: Promise.resolve(enrichtedSignInResultOption)\n };\n } else {\n return {\n successPromise: new Promise<SuccessSignInResult>(() => { }),\n noSuccess: Promise.resolve(enrichtedSignInResultOption.noSuccess!),\n signInResultOptionPromise: Promise.resolve(enrichtedSignInResultOption)\n };\n }\n }\n\n async signOut(): Promise<SignOutResult> {\n const result = await (GoogleOneTapAuthPlatform as any).signOut(this.authenticatedUserId);\n this.authenticatedUserId = undefined;\n return result;\n }\n\n async renderSignInButton(parentElementId: string, options: RenderSignInButtonOptions, gsiButtonConfiguration?: google.GsiButtonConfiguration): Promise<SuccessSignInResult> {\n await this.ensureInitialized();\n const parentElem = document.getElementById(parentElementId);\n assert(() => !!parentElem);\n options.webOptions = options.webOptions || {};\n\n return new Promise<SuccessSignInResult>(async (resolve, reject) => {\n try {\n if (Capacitor.getPlatform() === 'web') {\n const notEnrichedSuccessSignInResult = await GoogleOneTapAuthPlatform.renderSignInButton(parentElementId, options, gsiButtonConfiguration);\n console.log('notEnrichedSuccessSignInResult', notEnrichedSuccessSignInResult);\n const enrichtedSuccessSignInResult = this.enrichSuccessResultWithDecodedIdToken(notEnrichedSuccessSignInResult);\n this.authenticatedUserId = enrichtedSuccessSignInResult.userId;\n resolve(enrichtedSuccessSignInResult);\n return;\n }\n\n console.log('no onlick');\n\n const onClickAction = async () => {\n try {\n let notEnrichedSuccessSignInResult = await (GoogleOneTapAuthPlatform as any).triggerGoogleSignIn(options);\n if (Boolean(notEnrichedSuccessSignInResult.idToken)) {\n const enrichtedSuccessSignInResult = this.enrichSuccessResultWithDecodedIdToken(notEnrichedSuccessSignInResult);\n this.authenticatedUserId = enrichtedSuccessSignInResult.userId;\n resolve(enrichtedSuccessSignInResult);\n }\n } catch (e) {\n reject(e);\n }\n };\n parentElem!.appendChild(this.getSignInButtonHtml(onClickAction, gsiButtonConfiguration));\n }\n catch (e) {\n reject(e);\n }\n });\n }\n\n // user_cancel, \n\n // registerNotificationCallback(callback: (notification: string) => void) {\n // //this.notificationCallback = callback;\n // }\n\n getNonce() {\n assert(() => !!this.nonce, `The nonce is only set after ${() => this.initialize} was called.`);\n return this.nonce!;\n }\n\n private enrichOptionResultWithDecodedIdToken(signInResultOption: NotEnrichtedSignInResultOption): SignInResultOption {\n if (signInResultOption.isSuccess === false) {\n return signInResultOption as SignInResultOption;\n }\n return {\n ...signInResultOption,\n success: this.enrichSuccessResultWithDecodedIdToken(signInResultOption.success!),\n } as SignInResultOption;\n }\n\n private enrichSuccessResultWithDecodedIdToken(successSignInResult: NotEnrichedSuccessSignInResult): SuccessSignInResult {\n const decodedJwt = jwt_decode(successSignInResult.idToken) as any;\n return {\n ...successSignInResult,\n decodedIdToken: decodedJwt,\n userId: decodedJwt.sub,\n email: decodedJwt.email,\n } as SuccessSignInResult;\n }\n\n private getSignInButtonHtml(onClickAction: () => any, gsiButtonConfiguration?: google.GsiButtonConfiguration) {\n // Note: Replacing double quotes with single quotes will break some strings.\n const localizedStrings = {\n en: { signin: 'Sign in', continue_with: 'Continue with Google', signin_with: 'Sign in with Google', signup_with: 'Sign up with Google' },\n ar: { signin: '\\u062a\\u0633\\u062c\\u064a\\u0644 \\u0627\\u0644\\u062f\\u062e\\u0648\\u0644', continue_with: '\\u0627\\u0644\\u0645\\u0648\\u0627\\u0635\\u0644\\u0629 \\u0628\\u0627\\u0633\\u062a\\u062e\\u062f\\u0627\\u0645 Google', signin_with: '\\u062a\\u0633\\u062c\\u064a\\u0644 \\u0627\\u0644\\u062f\\u062e\\u0648\\u0644 \\u0628\\u0627\\u0633\\u062a\\u062e\\u062f\\u0627\\u0645 Google', signup_with: '\\u0627\\u0644\\u0627\\u0634\\u062a\\u0631\\u0627\\u0643 \\u0645\\u0646 \\u062e\\u0644\\u0627\\u0644 Google' },\n sr: { signin: '\\u041f\\u0440\\u0438\\u0458\\u0430\\u0432\\u0438 \\u043c\\u0435', continue_with: '\\u041d\\u0430\\u0441\\u0442\\u0430\\u0432\\u0438\\u0442\\u0435 \\u0441\\u0430 Google-\\u043e\\u043c', signin_with: '\\u041f\\u0440\\u0438\\u0458\\u0430\\u0432\\u0438\\u0442\\u0435 \\u0441\\u0435 \\u043f\\u043e\\u043c\\u043e\\u045b\\u0443 Google-\\u0430', signup_with: '\\u0420\\u0435\\u0433\\u0438\\u0441\\u0442\\u0440\\u0443\\u0458\\u0442\\u0435 \\u0441\\u0435 \\u043f\\u043e\\u043c\\u043e\\u045b\\u0443 Google-\\u0430' },\n nb: { signin: 'Logg p\\u00e5', continue_with: 'Fortsett med Google', signin_with: 'Logg p\\u00e5 med Google', signup_with: 'Registrer deg med Google' },\n pl: { signin: 'Zaloguj si\\u0119', continue_with: 'Kontynuuj przy u\\u017cyciu konta Google', signin_with: 'Zaloguj si\\u0119 przez Google', signup_with: 'Zarejestruj si\\u0119 przez Google' },\n vi: { signin: '\\u0110\\u0103ng nh\\u1eadp', continue_with: 'Ti\\u1ebfp t\\u1ee5c truy c\\u1eadp Google', signin_with: '\\u0110\\u0103ng nh\\u00e2\\u0323p b\\u0103\\u0300ng Google', signup_with: '\\u0110\\u0103ng k\\u00fd b\\u1eb1ng Google' },\n cs: { signin: 'P\\u0159ihl\\u00e1sit se', continue_with: 'Pokra\\u010dovat pomoc\\u00ed Googlu', signin_with: \"P\\u0159ihl\\u00e1sit se p\\u0159es Google\", signup_with: 'Registrace pomoc\\u00ed Googlu' },\n id: { signin: 'Login', continue_with: 'Lanjutkan dengan Google', signin_with: 'Login dengan Google', signup_with: 'Daftar dengan Google' },\n nl: { signin: 'Inloggen', continue_with: 'Doorgaan met Google', signin_with: 'Inloggen met Google', signup_with: 'Aanmelden bij Google' },\n gl: { signin: 'Iniciar sesi\\u00f3n', continue_with: 'Continuar con Google', signin_with: 'Iniciar sesi\\u00f3n con Google', signup_with: 'Iniciar sesi\\u00f3n con Google' },\n sv: { signin: 'Logga in', continue_with: 'Forts\\u00e4tt med Google', signin_with: 'Logga in med Google', signup_with: 'Registrera dig med Google' },\n lv: { signin: 'Pierakst\\u012b\\u0161an\\u0101s', continue_with: 'Turpin\\u0101t darbu ar Google', signin_with: 'Pierakstieties ar Google', signup_with: 'Re\\u0123istr\\u0113\\u0161an\\u0101s, izmantojot Google' },\n tr: { signin: 'Oturum a\\u00e7\\u0131n', continue_with: 'Google ile devam edin', signin_with: 'Google ile oturum a\\u00e7\\u0131n', signup_with: 'Google ile kaydolun' },\n it: { signin: 'Accedi', continue_with: 'Continua con Google', signin_with: 'Accedi con Google', signup_with: 'Registrati con Google' },\n sq: { signin: 'Identifikohu', continue_with: 'Vazhdo me Google', signin_with: 'Identifikohu me Google', signup_with: 'Regjistrohu me Google' },\n ro: { signin: 'Conecteaz\\u0103-te', continue_with: 'Continu\\u0103 cu Google', signin_with: 'Conecteaz\\u0103-te cu Google', signup_with: '\\u00censcrie-te cu Google' },\n de: { signin: 'Anmelden', continue_with: 'Weiter mit Google', signin_with: '\\u00dcber Google anmelden', signup_with: 'Mit Google anmelden' },\n ko: { signin: '\\ub85c\\uadf8\\uc778', continue_with: 'Google \\uacc4\\uc815\\uc73c\\ub85c \\uacc4\\uc18d\\ud558\\uae30', signin_with: 'Google \\uacc4\\uc815\\uc73c\\ub85c \\ub85c\\uadf8\\uc778', signup_with: 'Google \\uacc4\\uc815\\uc73c\\ub85c \\uac00\\uc785\\ud558\\uae30' },\n fr: { signin: 'Se connecter', continue_with: 'Continuer avec Google', signin_with: 'Se connecter avec Google', signup_with: \"S'inscrire avec Google\" },\n kmr: { signin: 'Oturum a\\u00e7\\u0131n', continue_with: 'Google ile devam edin', signin_with: 'Google ile oturum a\\u00e7\\u0131n', signup_with: 'Google ile kaydolun' },\n zh: { signin: '\\u767b\\u5f55', continue_with: '\\u901a\\u8fc7 Google \\u7ee7\\u7eed\\u64cd\\u4f5c', signin_with: \"\\u4f7f\\u7528 Google \\u5e10\\u53f7\\u767b\\u5f55\", signup_with: '\\u4f7f\\u7528 Google \\u5e10\\u53f7\\u6ce8\\u518c' },\n 'zh-CN': { signin: '\\u767b\\u5f55', continue_with: '\\u901a\\u8fc7 Google \\u7ee7\\u7eed\\u64cd\\u4f5c', signin_with: \"\\u4f7f\\u7528 Google \\u5e10\\u53f7\\u767b\\u5f55\", signup_with: '\\u4f7f\\u7528 Google \\u5e10\\u53f7\\u6ce8\\u518c' },\n 'zh-HK': { signin: '\\u767b\\u5165', continue_with: '\\u7e7c\\u7e8c\\u900f\\u904e Google \\u5e33\\u6236\\u64cd\\u4f5c', signin_with: '\\u4f7f\\u7528 Google \\u5e33\\u6236\\u767b\\u5165', signup_with: '\\u4f7f\\u7528 Google \\u5e33\\u6236\\u8a3b\\u518a' },\n pt: { signin: 'Fazer login', continue_with: 'Continuar com o Google', signin_with: 'Fazer login com o Google', signup_with: 'Inscrever-se no Google' },\n es: { signin: 'Iniciar sesi\\u00f3n', continue_with: 'Continuar con Google', signin_with: 'Iniciar sesi\\u00f3n con Google', signup_with: 'Registrarse con Google' },\n } as any;\n const locale = gsiButtonConfiguration?.locale;\n let localeTexts = locale !== undefined && locale in localizedStrings ? (localizedStrings[locale]) : undefined;\n\n if (localeTexts === undefined) {\n const countryCode = locale?.includes('-') === true ? locale.split('-')[1] : (locale ?? '');\n localeTexts = countryCode in localizedStrings ? (localizedStrings[countryCode] as string) : localizedStrings['en'];\n }\n const text = gsiButtonConfiguration?.text ?? 'signin_with';\n const buttonText = localeTexts[text];\n\n // HTML from https://github.com/inouiw/ReactSignInWithGoogleButton\n const button = document.createElement('button');\n button.setAttribute(\"style\", \"border-radius: 4px; background-color: rgb(255, 255, 255); border: 1px solid rgb(218, 220, 224); color: rgb(60, 64, 67); cursor: pointer; font-family: Roboto, Verdana; font-weight: 500; font-size: 14px; height: 40px; letter-spacing: 0.25px; padding: 0px 12px; position: relative; text-align: center; vertical-align: middle; width: auto;\");\n button.onclick = onClickAction;\n button.innerHTML = `\n <div style=\"display: flex; align-items: center; flex-flow: row nowrap; justify-content: space-between; height: 100%; position: relative; width: 100%;\">\n <div style=\"height: 18px; margin-right: 8px; min-width: 18px; width: 18px;\">\n <svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" width=\"18px\" height=\"18px\" viewBox=\"0 0 48 48\">\n <g>\n <path fill=\"#EA4335\" d=\"M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z\"></path>\n <path fill=\"#4285F4\" d=\"M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z\"></path>\n <path fill=\"#FBBC05\" d=\"M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z\"></path>\n <path fill=\"#34A853\" d=\"M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z\"></path>\n <path fill=\"none\" d=\"M0 0h48v48H0z\"></path>\n </g>\n </svg>\n </div>\n <p>${buttonText}</p>\n </div>`;\n return button;\n }\n}\n\nconst googleOneTapAuth = new GoogleOneTapAuth();\nexport { googleOneTapAuth as GoogleOneTapAuth }"]}
|
|
@@ -59,7 +59,7 @@ export interface NoSuccessSignInResult {
|
|
|
59
59
|
/**
|
|
60
60
|
* A reason code as 'opt_out_or_no_session'.
|
|
61
61
|
* For the js library see google.PromptMomentNotification for possible values.
|
|
62
|
-
* For android '
|
|
62
|
+
* For android 'SIGN_IN_CANCELLED' are currently set.
|
|
63
63
|
*/
|
|
64
64
|
noSuccessReasonCode?: string;
|
|
65
65
|
/**
|
|
@@ -90,7 +90,11 @@ export interface SignOutResult {
|
|
|
90
90
|
}
|
|
91
91
|
export interface GoogleOneTapAuthPlugin {
|
|
92
92
|
/**
|
|
93
|
+
* Performs common or one-time initializations.
|
|
93
94
|
* For the web platform, starts pre-loading the google one tap JavaScript library.
|
|
95
|
+
* initialize must be called before any other method.
|
|
96
|
+
* initialize remembers if it was called so it is safe to be called multiple times.
|
|
97
|
+
* Other methods wait till initialize is finished so you must not await initialize.
|
|
94
98
|
* @param options
|
|
95
99
|
*/
|
|
96
100
|
initialize(options: InitializeOptions): Promise<void>;
|
|
@@ -115,6 +119,8 @@ export interface GoogleOneTapAuthPlugin {
|
|
|
115
119
|
/**
|
|
116
120
|
* Renders the sign-in button.
|
|
117
121
|
* The returned promise will only resolve if successful.
|
|
122
|
+
* The returned promise is rejected for unrecoverable errors as 'unregistered_origin'
|
|
123
|
+
* for the web platform.
|
|
118
124
|
* @param parentElementId
|
|
119
125
|
* @param options
|
|
120
126
|
* @param gsiButtonConfiguration Not all button configuration options are supported on android.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC","sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n\nexport interface InitializeOptions {\n /**\n * Your client ID of type Web application.\n */\n clientId: string;\n /**\n * A string that is included in the ID token if supported. It is auto-generated if not provided.\n * The com.google.android.gms.auth.api.identity api supports nonce, however the \n * com.google.android.gms.auth.api.signin does currently not, and for ios there is an open issue.\n * See https://github.com/google/GoogleSignIn-iOS/issues/135\n */\n nonce?: string;\n}\n\nexport interface SignInResultPromises {\n successPromise: Promise<SuccessSignInResult>;\n noSuccess: Promise<NoSuccessSignInResult>;\n signInResultOptionPromise: Promise<SignInResultOption>;\n}\n\nexport interface SignInResultOption {\n /**\n * Indicates if the success or noSuccess property is set.\n */\n isSuccess: boolean;\n /**\n * Success result.\n */\n success?: SuccessSignInResult;\n /**\n * NoSuccess result.\n */\n noSuccess?: NoSuccessSignInResult;\n}\n\nexport interface SuccessSignInResult {\n /**\n * How the credential was retrieved.\n * Currently not available for android, only if the js library is used.\n * For possible values see google.PromptMomentNotification.\n */\n selectBy?: \n | 'auto'\n | 'user'\n | 'user_1tap'\n | 'user_2tap'\n | 'btn'\n | 'btn_confirm'\n | 'btn_add_session'\n | 'btn_confirm_add_session' // see google.CredentialResponse.select_by\n /**\n * The JWT token base64 encoded.\n */\n idToken: string;\n /**\n * A permanent id for the user.\n */\n userId: string;\n /**\n * The email address.\n */\n email: string;\n /**\n * The decoded JWT token.\n * The signature is not verified when decoding the token.\n */\n decodedIdToken: any;\n}\n\nexport interface NoSuccessSignInResult {\n /**\n * A reason code as 'opt_out_or_no_session'.\n * For the js library see google.PromptMomentNotification for possible values.\n * For android '
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC","sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n\nexport interface InitializeOptions {\n /**\n * Your client ID of type Web application.\n */\n clientId: string;\n /**\n * A string that is included in the ID token if supported. It is auto-generated if not provided.\n * The com.google.android.gms.auth.api.identity api supports nonce, however the \n * com.google.android.gms.auth.api.signin does currently not, and for ios there is an open issue.\n * See https://github.com/google/GoogleSignIn-iOS/issues/135\n */\n nonce?: string;\n}\n\nexport interface SignInResultPromises {\n successPromise: Promise<SuccessSignInResult>;\n noSuccess: Promise<NoSuccessSignInResult>;\n signInResultOptionPromise: Promise<SignInResultOption>;\n}\n\nexport interface SignInResultOption {\n /**\n * Indicates if the success or noSuccess property is set.\n */\n isSuccess: boolean;\n /**\n * Success result.\n */\n success?: SuccessSignInResult;\n /**\n * NoSuccess result.\n */\n noSuccess?: NoSuccessSignInResult;\n}\n\nexport interface SuccessSignInResult {\n /**\n * How the credential was retrieved.\n * Currently not available for android, only if the js library is used.\n * For possible values see google.PromptMomentNotification.\n */\n selectBy?: \n | 'auto'\n | 'user'\n | 'user_1tap'\n | 'user_2tap'\n | 'btn'\n | 'btn_confirm'\n | 'btn_add_session'\n | 'btn_confirm_add_session' // see google.CredentialResponse.select_by\n /**\n * The JWT token base64 encoded.\n */\n idToken: string;\n /**\n * A permanent id for the user.\n */\n userId: string;\n /**\n * The email address.\n */\n email: string;\n /**\n * The decoded JWT token.\n * The signature is not verified when decoding the token.\n */\n decodedIdToken: any;\n}\n\nexport interface NoSuccessSignInResult {\n /**\n * A reason code as 'opt_out_or_no_session'.\n * For the js library see google.PromptMomentNotification for possible values.\n * For android 'SIGN_IN_CANCELLED' are currently set.\n */\n noSuccessReasonCode?: string;\n /**\n * A error message.\n * Set in case of error if the native android code is used.\n */\n noSuccessAdditionalInfo?: string;\n}\n\nexport interface RenderSignInButtonOptions {\n /**\n * \tWeb platform specific options..\n */\n webOptions?: RenderSignInButtonWebOptions;\n}\n\nexport interface RenderSignInButtonWebOptions {\n /**\n * \tEnables upgraded One Tap UX on ITP browsers. The default value is false.\n */\n itpSupport?: boolean;\n /**\n * \tThe Sign In With Google button UX flow. The default value is 'popup'.\n */\n uxMode?: 'popup' | 'redirect';\n}\n\nexport interface SignOutResult {\n isSuccess: boolean;\n error?: string;\n}\n\nexport interface GoogleOneTapAuthPlugin {\n /**\n * Performs common or one-time initializations.\n * For the web platform, starts pre-loading the google one tap JavaScript library.\n * initialize must be called before any other method.\n * initialize remembers if it was called so it is safe to be called multiple times.\n * Other methods wait till initialize is finished so you must not await initialize.\n * @param options \n */\n initialize(options: InitializeOptions): Promise<void>;\n /**\n * Tries to either auto-sign-in the user or sign-in the user with just one tap/click.\n * If there is a single google account and that account has previously signed into the app, \n * then that user is auto signed in. A short popover is displayed during sign-in.\n * If there are multiple google accounts and more than one have previously signed into the \n * app then a user selection screen is shown.\n * If there is no active google session or if no user session has logged in previously in \n * the app or if the user has opt out of One Tap, then the response will indicate that \n * the auto sign-in did not succeed.\n * See https://developers.google.com/identity/gsi/web/guides/features\n * @returns A Promise object that contains 3 properties with promises. One resolves only \n * when authentication succeeds, the second on error and the third on success or error.\n */\n tryAutoOrOneTapSignIn()\n : Promise<{\n successPromise: Promise<SuccessSignInResult>;\n noSuccess: Promise<NoSuccessSignInResult>;\n signInResultOptionPromise: Promise<SignInResultOption>;\n }>;\n /**\n * Renders the sign-in button.\n * The returned promise will only resolve if successful.\n * The returned promise is rejected for unrecoverable errors as 'unregistered_origin' \n * for the web platform.\n * @param parentElementId \n * @param options \n * @param gsiButtonConfiguration Not all button configuration options are supported on android.\n */\n renderSignInButton(\n parentElementId: string,\n options: RenderSignInButtonOptions,\n gsiButtonConfiguration?: google.GsiButtonConfiguration)\n : Promise<SuccessSignInResult>;\n /**\n * Ends the session.\n */\n signOut(): Promise<SignOutResult>;\n /**\n * Gets the last user defined or auto-created nonce.\n * Unfortunately not all google libraries support setting a nonce, so this is currently \n * not universally useful.\n */\n getNonce(): string;\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SuccessSignInResult, NoSuccessSignInResult } from './definitions';
|
|
2
|
+
export type NotEnrichedSuccessSignInResult = Omit<SuccessSignInResult, 'decodedIdToken' | 'userId' | 'email'>;
|
|
3
|
+
export interface NotEnrichtedSignInResultOption {
|
|
4
|
+
isSuccess: boolean;
|
|
5
|
+
success?: NotEnrichedSuccessSignInResult;
|
|
6
|
+
noSuccess?: NoSuccessSignInResult;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitionsInternal.js","sourceRoot":"","sources":["../../src/definitionsInternal.ts"],"names":[],"mappings":"","sourcesContent":["import type { SuccessSignInResult, NoSuccessSignInResult } from './definitions';\n\nexport type NotEnrichedSuccessSignInResult = Omit<SuccessSignInResult, 'decodedIdToken' | 'userId' | 'email'>;\nexport interface NotEnrichtedSignInResultOption {\n isSuccess: boolean;\n success?: NotEnrichedSuccessSignInResult;\n noSuccess?: NoSuccessSignInResult;\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import { InitializeOptions, SignInResultOption,
|
|
2
|
+
import { InitializeOptions, SignInResultOption, SignOutResult, RenderSignInButtonOptions } from './definitions';
|
|
3
|
+
import type { NotEnrichedSuccessSignInResult } from './definitionsInternal';
|
|
3
4
|
export declare class GoogleOneTapAuthWeb extends WebPlugin {
|
|
4
5
|
gsiScriptUrl: string;
|
|
5
6
|
gapiLoadedPromise?: Promise<void>;
|
|
6
|
-
authenticatedUserId?: string;
|
|
7
7
|
clientId?: string;
|
|
8
8
|
nonce?: string;
|
|
9
9
|
initialize(options: InitializeOptions): Promise<void>;
|
|
10
10
|
tryAutoOrOneTapSignIn(): Promise<SignInResultOption>;
|
|
11
|
-
renderSignInButton(parentElementId: string, options: RenderSignInButtonOptions, gsiButtonConfiguration?: google.GsiButtonConfiguration): Promise<
|
|
11
|
+
renderSignInButton(parentElementId: string, options: RenderSignInButtonOptions, gsiButtonConfiguration?: google.GsiButtonConfiguration): Promise<NotEnrichedSuccessSignInResult>;
|
|
12
12
|
private doSignIn;
|
|
13
13
|
private getMomentReason;
|
|
14
14
|
private oneTapInitialize;
|
|
15
15
|
private handleCredentialResponse;
|
|
16
|
-
signOut(): Promise<SignOutResult>;
|
|
17
|
-
getNonce(): string;
|
|
16
|
+
signOut(authenticatedUserId: string | undefined): Promise<SignOutResult>;
|
|
18
17
|
}
|