@capawesome/capacitor-apple-sign-in 0.0.1 â 0.1.1
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 +20 -1
- package/ios/Plugin/AppleSignIn.swift +11 -5
- package/ios/Plugin/AppleSignInPlugin.swift +2 -0
- package/package.json +1 -4
package/README.md
CHANGED
|
@@ -18,12 +18,16 @@ We are proud to offer one of the most complete and feature-rich Capacitor plugin
|
|
|
18
18
|
- ð§ **Scope support**: Request email and full name on all platforms.
|
|
19
19
|
- ð **Nonce & state**: Supports nonce for replay protection and state for CSRF protection.
|
|
20
20
|
- ðŠķ **Lightweight**: Just a single dependency and zero unnecessary bloat.
|
|
21
|
-
- ðĪ **Compatibility**: Compatible with the [Google Sign-In](https://capawesome.io/plugins/google-sign-in) and [OAuth](https://capawesome.io/plugins/oauth) plugins.
|
|
21
|
+
- ðĪ **Compatibility**: Compatible with the [Google Sign-In](https://capawesome.io/docs/plugins/google-sign-in/) and [OAuth](https://capawesome.io/docs/plugins/oauth/) plugins.
|
|
22
22
|
- ðĶ **CocoaPods & SPM**: Supports CocoaPods and Swift Package Manager for iOS.
|
|
23
23
|
- ð **Up-to-date**: Always supports the latest Capacitor version.
|
|
24
24
|
|
|
25
25
|
Missing a feature? Just [open an issue](https://github.com/capawesome-team/capacitor-plugins/issues) and we'll take a look!
|
|
26
26
|
|
|
27
|
+
## Newsletter
|
|
28
|
+
|
|
29
|
+
Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our [Capawesome Newsletter](https://cloud.capawesome.io/newsletter/).
|
|
30
|
+
|
|
27
31
|
## Compatibility
|
|
28
32
|
|
|
29
33
|
| Plugin Version | Capacitor Version | Status |
|
|
@@ -36,6 +40,21 @@ Missing a feature? Just [open an issue](https://github.com/capawesome-team/capac
|
|
|
36
40
|
|
|
37
41
|
## Installation
|
|
38
42
|
|
|
43
|
+
You can use our **AI-Assisted Setup** to install the plugin.
|
|
44
|
+
Add the [Capawesome Skills](https://github.com/capawesome-team/skills) to your AI tool using the following command:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npx skills add capawesome-team/skills --skill capacitor-plugins
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Then use the following prompt:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
Use the `capacitor-plugins` skill from `capawesome-team/skills` to install the `@capawesome/capacitor-apple-sign-in` plugin in my project.
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
If you prefer **Manual Setup**, install the plugin by running the following commands and follow the platform-specific instructions below:
|
|
57
|
+
|
|
39
58
|
```bash
|
|
40
59
|
npm install @capawesome/capacitor-apple-sign-in
|
|
41
60
|
npx cap sync
|
|
@@ -4,6 +4,7 @@ import AuthenticationServices
|
|
|
4
4
|
@objc public class AppleSignIn: NSObject {
|
|
5
5
|
|
|
6
6
|
private var completion: ((_ result: SignInResult?, _ error: Error?) -> Void)?
|
|
7
|
+
private var authorizationController: ASAuthorizationController?
|
|
7
8
|
|
|
8
9
|
@objc public func signIn(_ options: SignInOptions, presentationContextProvider: ASAuthorizationControllerPresentationContextProviding, completion: @escaping (_ result: SignInResult?, _ error: Error?) -> Void) {
|
|
9
10
|
self.completion = completion
|
|
@@ -17,15 +18,19 @@ import AuthenticationServices
|
|
|
17
18
|
request.nonce = nonce
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
DispatchQueue.main.async {
|
|
22
|
+
let controller = ASAuthorizationController(authorizationRequests: [request])
|
|
23
|
+
controller.delegate = self
|
|
24
|
+
controller.presentationContextProvider = presentationContextProvider
|
|
25
|
+
self.authorizationController = controller
|
|
26
|
+
controller.performRequests()
|
|
27
|
+
}
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
extension AppleSignIn: ASAuthorizationControllerDelegate {
|
|
28
32
|
public func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
|
|
33
|
+
authorizationController = nil
|
|
29
34
|
guard let credential = authorization.credential as? ASAuthorizationAppleIDCredential else {
|
|
30
35
|
completion?(nil, CustomError.signInFailed)
|
|
31
36
|
completion = nil
|
|
@@ -37,11 +42,12 @@ extension AppleSignIn: ASAuthorizationControllerDelegate {
|
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
public func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) {
|
|
45
|
+
authorizationController = nil
|
|
40
46
|
let asError = error as? ASAuthorizationError
|
|
41
47
|
if asError?.code == .canceled {
|
|
42
48
|
completion?(nil, CustomError.signInCanceled)
|
|
43
49
|
} else {
|
|
44
|
-
completion?(nil,
|
|
50
|
+
completion?(nil, error)
|
|
45
51
|
}
|
|
46
52
|
completion = nil
|
|
47
53
|
}
|
|
@@ -43,6 +43,8 @@ public class AppleSignInPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
43
43
|
var code: String?
|
|
44
44
|
if let customError = error as? CustomError {
|
|
45
45
|
code = customError.code
|
|
46
|
+
} else if let authorizationError = error as? ASAuthorizationError {
|
|
47
|
+
code = String(authorizationError.code.rawValue)
|
|
46
48
|
}
|
|
47
49
|
call.reject(error.localizedDescription, code)
|
|
48
50
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capawesome/capacitor-apple-sign-in",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Capacitor plugin to sign-in with Apple.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -63,9 +63,7 @@
|
|
|
63
63
|
"@capacitor/docgen": "0.3.1",
|
|
64
64
|
"@capacitor/ios": "8.0.0",
|
|
65
65
|
"@ionic/eslint-config": "0.4.0",
|
|
66
|
-
"@ionic/swiftlint-config": "2.0.0",
|
|
67
66
|
"eslint": "8.57.0",
|
|
68
|
-
"prettier": "3.4.2",
|
|
69
67
|
"prettier-plugin-java": "2.6.7",
|
|
70
68
|
"rimraf": "6.1.2",
|
|
71
69
|
"rollup": "4.53.3",
|
|
@@ -75,7 +73,6 @@
|
|
|
75
73
|
"peerDependencies": {
|
|
76
74
|
"@capacitor/core": ">=8.0.0"
|
|
77
75
|
},
|
|
78
|
-
"swiftlint": "@ionic/swiftlint-config",
|
|
79
76
|
"eslintConfig": {
|
|
80
77
|
"extends": "@ionic/eslint-config/recommended"
|
|
81
78
|
},
|