@capgo/capacitor-social-login 0.0.65 → 0.0.67
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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Capgo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -264,7 +264,6 @@ public class AppleProvider implements SocialProvider {
|
|
|
264
264
|
result.put("accessToken", createAccessTokenObject(accessToken));
|
|
265
265
|
result.put("profile", createProfileObject(idToken));
|
|
266
266
|
result.put("idToken", idToken);
|
|
267
|
-
result.put("authorizationCode", ""); // Apple doesn't provide this in the response
|
|
268
267
|
|
|
269
268
|
JSObject response = new JSObject();
|
|
270
269
|
response.put("provider", "apple");
|
|
@@ -7,7 +7,6 @@ struct AppleProviderResponse: Codable {
|
|
|
7
7
|
let accessToken: AccessTokenApple?
|
|
8
8
|
let profile: AppleProfile
|
|
9
9
|
let idToken: String?
|
|
10
|
-
let authorizationCode: String?
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
struct AppleProfile: Codable {
|
|
@@ -236,7 +235,7 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
|
|
|
236
235
|
|
|
237
236
|
// Create proper access token
|
|
238
237
|
let accessToken = AccessTokenApple(
|
|
239
|
-
token: String(data: appleIDCredential.
|
|
238
|
+
token: String(data: appleIDCredential.identityToken ?? Data(), encoding: .utf8) ?? "",
|
|
240
239
|
expiresIn: 3600, // Default 1 hour
|
|
241
240
|
refreshToken: nil // Apple doesn't provide refresh token directly
|
|
242
241
|
)
|
|
@@ -250,8 +249,7 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
|
|
|
250
249
|
givenName: fullName?.givenName ?? savedUserInfo?.profile.givenName,
|
|
251
250
|
familyName: fullName?.familyName ?? savedUserInfo?.profile.familyName
|
|
252
251
|
),
|
|
253
|
-
idToken: String(data: appleIDCredential.
|
|
254
|
-
authorizationCode: String(data: appleIDCredential.authorizationCode ?? Data(), encoding: .utf8)
|
|
252
|
+
idToken: String(data: appleIDCredential.authorizationCode ?? Data(), encoding: .utf8) ?? ""
|
|
255
253
|
)
|
|
256
254
|
|
|
257
255
|
// Persist user info
|
|
@@ -261,7 +259,7 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
|
|
|
261
259
|
let firstName = fullName?.givenName ?? ""
|
|
262
260
|
let lastName = fullName?.familyName ?? ""
|
|
263
261
|
|
|
264
|
-
self.sendRequest(code: response.
|
|
262
|
+
self.sendRequest(code: response.accessToken?.token ?? "", identityToken: response.idToken ?? "", email: email ?? "", firstName: firstName, lastName: lastName, completion: { result in
|
|
265
263
|
switch result {
|
|
266
264
|
case .success(let appleResponse):
|
|
267
265
|
self.completion?(.success(appleResponse))
|
|
@@ -382,8 +380,7 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
|
|
|
382
380
|
givenName: nil,
|
|
383
381
|
familyName: nil
|
|
384
382
|
),
|
|
385
|
-
idToken: idToken
|
|
386
|
-
authorizationCode: ""
|
|
383
|
+
idToken: idToken
|
|
387
384
|
)
|
|
388
385
|
completion(.success(appleResponse))
|
|
389
386
|
return
|
|
@@ -406,8 +403,7 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
|
|
|
406
403
|
givenName: firstName,
|
|
407
404
|
familyName: lastName
|
|
408
405
|
),
|
|
409
|
-
idToken: identityToken
|
|
410
|
-
authorizationCode: code
|
|
406
|
+
idToken: identityToken
|
|
411
407
|
)
|
|
412
408
|
|
|
413
409
|
do {
|
|
@@ -510,8 +506,7 @@ class AppleProvider: NSObject, ASAuthorizationControllerDelegate, ASAuthorizatio
|
|
|
510
506
|
givenName: nil,
|
|
511
507
|
familyName: nil
|
|
512
508
|
),
|
|
513
|
-
idToken: idToken
|
|
514
|
-
authorizationCode: code
|
|
509
|
+
idToken: idToken
|
|
515
510
|
)
|
|
516
511
|
|
|
517
512
|
// Log the tokens (replace with your logging mechanism)
|
|
@@ -270,7 +270,6 @@ public class SocialLoginPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
270
270
|
"accessToken": accessTokenObject ?? NSNull(),
|
|
271
271
|
"profile": profileObject,
|
|
272
272
|
"idToken": appleResponse.idToken ?? "",
|
|
273
|
-
"authorizationCode": appleResponse.authorizationCode ?? ""
|
|
274
273
|
]
|
|
275
274
|
|
|
276
275
|
call.resolve([
|