@capgo/capacitor-social-login 8.5.9 → 8.5.10
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.
|
@@ -24,7 +24,7 @@ import org.json.JSONObject;
|
|
|
24
24
|
@CapacitorPlugin(name = "SocialLogin")
|
|
25
25
|
public class SocialLoginPlugin extends Plugin {
|
|
26
26
|
|
|
27
|
-
private final String pluginVersion = "8.5.
|
|
27
|
+
private final String pluginVersion = "8.5.10";
|
|
28
28
|
|
|
29
29
|
public static String LOG_TAG = "CapgoSocialLogin";
|
|
30
30
|
public HashMap<String, SocialProvider> socialProviderHashMap = new HashMap<>();
|
|
@@ -575,22 +575,31 @@ public class SocialLoginPlugin extends Plugin {
|
|
|
575
575
|
return;
|
|
576
576
|
}
|
|
577
577
|
try {
|
|
578
|
-
|
|
579
|
-
if (parts.length < 2) {
|
|
580
|
-
call.reject("Invalid JWT");
|
|
581
|
-
return;
|
|
582
|
-
}
|
|
583
|
-
byte[] decoded = Base64.decode(parts[1], Base64.URL_SAFE | Base64.NO_PADDING | Base64.NO_WRAP);
|
|
584
|
-
String json = new String(decoded, StandardCharsets.UTF_8);
|
|
585
|
-
JSONObject claims = new JSONObject(json);
|
|
578
|
+
JSONObject claims = decodeJwtClaims(idToken);
|
|
586
579
|
JSObject ret = new JSObject();
|
|
587
580
|
ret.put("claims", claims);
|
|
588
581
|
call.resolve(ret);
|
|
582
|
+
} catch (JSONException e) {
|
|
583
|
+
call.reject("Invalid JWT");
|
|
589
584
|
} catch (Exception e) {
|
|
590
585
|
call.reject("Failed to decode idToken", e);
|
|
591
586
|
}
|
|
592
587
|
}
|
|
593
588
|
|
|
589
|
+
static JSONObject decodeJwtClaims(String idToken) throws JSONException {
|
|
590
|
+
byte[] decoded = Base64.decode(getJwtPayloadSegment(idToken), Base64.URL_SAFE | Base64.NO_PADDING | Base64.NO_WRAP);
|
|
591
|
+
String json = new String(decoded, StandardCharsets.UTF_8);
|
|
592
|
+
return new JSONObject(json);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
static String getJwtPayloadSegment(String idToken) throws JSONException {
|
|
596
|
+
String[] parts = idToken.split("\\.");
|
|
597
|
+
if (parts.length < 2) {
|
|
598
|
+
throw new JSONException("Invalid JWT");
|
|
599
|
+
}
|
|
600
|
+
return parts[1];
|
|
601
|
+
}
|
|
602
|
+
|
|
594
603
|
// Capacitor's PluginCall.getLong() only reads Java Long values. JS numbers that
|
|
595
604
|
// fit in 32 bits cross the bridge as Integer, so Number coercion is required.
|
|
596
605
|
static Long longOptionFromCall(PluginCall call, String key) {
|
|
@@ -16,7 +16,7 @@ import GoogleSignIn
|
|
|
16
16
|
*/
|
|
17
17
|
@objc(SocialLoginPlugin)
|
|
18
18
|
public class SocialLoginPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
19
|
-
private let pluginVersion: String = "8.5.
|
|
19
|
+
private let pluginVersion: String = "8.5.10"
|
|
20
20
|
public let identifier = "SocialLoginPlugin"
|
|
21
21
|
public let jsName = "SocialLogin"
|
|
22
22
|
private static let userCancelledCode = "USER_CANCELLED"
|