@logto/connector-apple 1.0.0-beta.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.
- package/LICENSE +21 -0
- package/README.md +164 -0
- package/docs/config-template.json +3 -0
- package/docs/domain-and-url.png +0 -0
- package/docs/enable-sign-in-with-apple-in-xcode.png +0 -0
- package/docs/enable-sign-in-with-apple.png +0 -0
- package/lib/index.js +8355 -0
- package/lib/jest.config.d.ts +3 -0
- package/lib/src/constant.d.ts +8 -0
- package/lib/src/index.d.ts +3 -0
- package/lib/src/index.test.d.ts +1 -0
- package/lib/src/mock.d.ts +4 -0
- package/lib/src/types.d.ts +16 -0
- package/logo-dark.svg +3 -0
- package/logo.svg +3 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Silverhand
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Apple connector
|
|
2
|
+
|
|
3
|
+
The official Logto connector for Apple social sign-in.
|
|
4
|
+
|
|
5
|
+
Apple 社交登录 Logto 官方连接器 [中文文档](#apple-连接器)
|
|
6
|
+
|
|
7
|
+
**Table of contents**
|
|
8
|
+
|
|
9
|
+
- [Apple connector](#apple-connector)
|
|
10
|
+
- [Get started](#get-started)
|
|
11
|
+
- [Enable Sign in with Apple for your app](#enable-sign-in-with-apple-for-your-app)
|
|
12
|
+
- [Create an identifier](#create-an-identifier)
|
|
13
|
+
- [Enable Sign in with Apple for your identifier](#enable-sign-in-with-apple-for-your-identifier)
|
|
14
|
+
- [Compose the connector JSON](#compose-the-connector-json)
|
|
15
|
+
- [Test Apple connector](#test-apple-connector)
|
|
16
|
+
- [Apple 连接器](#apple-连接器)
|
|
17
|
+
- [开始上手](#开始上手)
|
|
18
|
+
- [为你的应用启用「通过 Apple 登录」](#为你的应用启用通过-apple-登录)
|
|
19
|
+
- [创建一个 identifier](#创建一个-identifier)
|
|
20
|
+
- [为你的 identifier 启用「通过 Apple 登录」](#为你的-identifier-启用通过-apple-登录)
|
|
21
|
+
- [编写连接器的 JSON](#编写连接器的-json)
|
|
22
|
+
- [测试 Apple 连接器](#测试-apple-连接器)
|
|
23
|
+
|
|
24
|
+
## Get started
|
|
25
|
+
|
|
26
|
+
If you don't know the concept of the connector or don't know how to add this connector to your Sign-in experience, please see [Logto tutorial](https://docs.logto.io/docs/tutorials/get-started/enable-social-sign-in).
|
|
27
|
+
|
|
28
|
+
> ℹ️ **Note**
|
|
29
|
+
>
|
|
30
|
+
> Apple sign-in is required for AppStore if you have other social sign-in methods in your app.
|
|
31
|
+
> Having Apple sign-in on Android devices is great if you also provide an Android app.
|
|
32
|
+
|
|
33
|
+
You need to enroll [Apple Developer Program](https://developer.apple.com/programs/) before continuing.
|
|
34
|
+
|
|
35
|
+
### Enable Sign in with Apple for your app
|
|
36
|
+
|
|
37
|
+
> ⚠️ **Caution**
|
|
38
|
+
>
|
|
39
|
+
> Even if you want to implement Sign in with Apple on a web app only, you still need to have an existing app that embraces the AppStore ecosystem (i.e., have a valid App ID).
|
|
40
|
+
|
|
41
|
+
You can do it via Xcode -> Project settings -> Signing & Capabilities, or visit [Certificates, Identifiers & Profiles](https://developer.apple.com/account/resources/identifiers/list/bundleId).
|
|
42
|
+
|
|
43
|
+

|
|
44
|
+
|
|
45
|
+
See the "Enable an App ID" section in [Apple official docs](https://developer.apple.com/documentation/sign_in_with_apple/configuring_your_environment_for_sign_in_with_apple) for more info.
|
|
46
|
+
|
|
47
|
+
### Create an identifier
|
|
48
|
+
|
|
49
|
+
1. Visit [Certificates, Identifiers & Profiles](https://developer.apple.com/account/resources/identifiers/list/serviceId), then click the "+" button next to "Identifier".
|
|
50
|
+
2. In the "Register a new identifier" page, choose "Services IDs" and click "Continue".
|
|
51
|
+
3. Fill out "Description" and "Identifier" (E.g., `Logto Test` and `io.logto.test`), then click "Continue".
|
|
52
|
+
4. Double-check the info and click "Register".
|
|
53
|
+
|
|
54
|
+
### Enable Sign in with Apple for your identifier
|
|
55
|
+
|
|
56
|
+
Click the identifier you just created. Check "Sign in with Apple" on the details page and click "Configure".
|
|
57
|
+
|
|
58
|
+

|
|
59
|
+
|
|
60
|
+
In the opening modal, select the App ID you just enabled Sign in with Apple.
|
|
61
|
+
|
|
62
|
+
Enter the domain of your Logto instance without protocol and port, e.g., `your.logto.domain`; then enter the "Return URL" (i.e., Redirect URI), which is the Logto URL with `/callback/apple-universal`, e.g., `https://your.logto.domain/callback/apple-universal`.
|
|
63
|
+
|
|
64
|
+

|
|
65
|
+
|
|
66
|
+
Click "Next" then "Done" to close the modal. Click "Continue" on the top-right corner, then click "Save" to save your configuration.
|
|
67
|
+
|
|
68
|
+
> ⚠️ **Caution**
|
|
69
|
+
>
|
|
70
|
+
> Apple does NOT allow Return URLs with HTTP protocol and `localhost` domain.
|
|
71
|
+
>
|
|
72
|
+
> If you want to test locally, you need to edit `/etc/hosts` file to map localhost to a custom domain and set up a local HTTPS environment. [mkcert](https://github.com/FiloSottile/mkcert) can help you for setting up local HTTPS.
|
|
73
|
+
|
|
74
|
+
## Compose the connector JSON
|
|
75
|
+
|
|
76
|
+
You need to use the identifier that fills in the [Create an identifier](#create-an-identifier) section to compose the JSON:
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"clientId": "io.logto.test"
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
> ℹ️ **Note**
|
|
85
|
+
>
|
|
86
|
+
> This connector doesn't support customizing `scope` (e.g., name, email) yet since Apple requires `form_post` response mode when `scope` is not empty, which is incompatible with the current connector design.
|
|
87
|
+
>
|
|
88
|
+
> We'll figure out this later.
|
|
89
|
+
|
|
90
|
+
## Test Apple connector
|
|
91
|
+
|
|
92
|
+
That's it. The Apple connector should be available in both web and native apps. Don't forget to [Enable connector in sign-in experience](https://docs.logto.io/docs/tutorials/get-started/enable-social-sign-in#enable-connector-in-sign-in-experience).
|
|
93
|
+
|
|
94
|
+
# Apple 连接器
|
|
95
|
+
|
|
96
|
+
## 开始上手
|
|
97
|
+
|
|
98
|
+
如果你还不知道连接器的概念,或者还不知道如何将本连接器添加至你的「登录体验」,请先参见 [Logto 教程](https://docs.logto.io/zh-cn/docs/tutorials/get-started/enable-social-sign-in)。
|
|
99
|
+
|
|
100
|
+
> ℹ️ **Note**
|
|
101
|
+
>
|
|
102
|
+
> 如果你的应用有其他的社交登录方式,AppStore 要求必须同时有 Apple 登录。
|
|
103
|
+
> 如果同时提供 Android 应用,在 Android 设备上同时提供 Apple 登录会让用户体验很棒。
|
|
104
|
+
|
|
105
|
+
在继续前,你需要加入 [Apple Developer Program](https://developer.apple.com/programs/)。
|
|
106
|
+
|
|
107
|
+
### 为你的应用启用「通过 Apple 登录」
|
|
108
|
+
|
|
109
|
+
> ⚠️ **Caution**
|
|
110
|
+
>
|
|
111
|
+
> 即使你只想在 web 应用中实现「通过 Apple 登录」,你仍需要拥有一个拥抱 AppStore 生态的应用(即:有一个有效的 App ID)。
|
|
112
|
+
|
|
113
|
+
你可以通过 Xcode -> Project settings -> Signing & Capabilities 来启用,或者访问 [Certificates, Identifiers & Profiles](https://developer.apple.com/account/resources/identifiers/list/bundleId)。
|
|
114
|
+
|
|
115
|
+

|
|
116
|
+
|
|
117
|
+
参见 [Apple 官方文档](https://developer.apple.com/documentation/sign_in_with_apple/configuring_your_environment_for_sign_in_with_apple) 里的「Enable an App ID」章节以了解更多。
|
|
118
|
+
|
|
119
|
+
### 创建一个 identifier
|
|
120
|
+
|
|
121
|
+
1. 访问 [Certificates, Identifiers & Profiles](https://developer.apple.com/account/resources/identifiers/list/serviceId),并点按在「Identifier」旁边的「+」按钮。
|
|
122
|
+
2. 在「Register a new identifier」页面,选择「Services IDs」并点按「Continue」。
|
|
123
|
+
3. 填写「Description」与「Identifier」(例如 `Logto Test` 和 `io.logto.test`),并点按「Continue」。
|
|
124
|
+
4. 再次检查相关信息并点按「Register」。
|
|
125
|
+
|
|
126
|
+
### 为你的 identifier 启用「通过 Apple 登录」
|
|
127
|
+
|
|
128
|
+
点按你刚刚创建的 identifier。在详情页勾选「Sign in with Apple」并点按「Configure」。
|
|
129
|
+
|
|
130
|
+

|
|
131
|
+
|
|
132
|
+
在打开的对话框中,选择刚刚启用了「通过 Apple 登录」的 App ID。
|
|
133
|
+
|
|
134
|
+
输入你的 Logto 实例域名(不含协议和端口),例如 `your.logto.domain`;并输入「Return URL」(即 Redirect URI)。Return URL 的值是 Logto URL 加上 `/callback/apple-universal`,例如 `https://your.logto.domain/callback/apple-universal`。
|
|
135
|
+
|
|
136
|
+

|
|
137
|
+
|
|
138
|
+
点按「Next」以及「Done」以关闭对话框。点按右上角的「Continue」,接着点按「Save」以保存你的配置。
|
|
139
|
+
|
|
140
|
+
> ⚠️ **Caution**
|
|
141
|
+
>
|
|
142
|
+
> Apple _不允许_ HTTP 协议或 `localhost` 域名作为 Return URL。
|
|
143
|
+
>
|
|
144
|
+
> 如果你想在本地进行测试,你需要编辑 `/etc/hosts` 文件以映射 localhost 到一个自定义域名,并设置一个本地的 HTTPS 环境。[mkcert](https://github.com/FiloSottile/mkcert) 可以帮助你设置本地 HTTPS。
|
|
145
|
+
|
|
146
|
+
## 编写连接器的 JSON
|
|
147
|
+
|
|
148
|
+
你需要使用在 [创建一个 identifier](#创建一个-identifier) 章节中填写的 identifier 来编写此 JSON:
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"clientId": "io.logto.test"
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
> ℹ️ **Note**
|
|
157
|
+
>
|
|
158
|
+
> 本连接器暂时不支持自定义 `scope`(例如 name,email)。因为在 `scope` 非空时,Apple 要求 `response_mode` 为 `form_post`,与现在连接器的设计不兼容。
|
|
159
|
+
>
|
|
160
|
+
> 我们将稍后解决这个问题。
|
|
161
|
+
|
|
162
|
+
## 测试 Apple 连接器
|
|
163
|
+
|
|
164
|
+
大功告成。Apple 连接器应该在 web 和原生应用中都可用了。别忘了 [在登录体验中启用本连接器](https://docs.logto.io/zh-cn/docs/tutorials/get-started/enable-social-sign-in/#%E5%9C%A8%E7%99%BB%E5%BD%95%E4%BD%93%E9%AA%8C%E4%B8%AD%E5%90%AF%E7%94%A8%E8%BF%9E%E6%8E%A5%E5%99%A8)。
|
|
Binary file
|
|
Binary file
|
|
Binary file
|