authing_ruby 1.0.7 → 1.1.2
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.
- checksums.yaml +4 -4
- data/lib/authing_ruby/GraphQLAPI.rb +13 -2
- data/lib/authing_ruby/authentication/AuthenticationClient.rb +66 -60
- data/lib/authing_ruby/common/GraphqlClient.rb +42 -4
- data/lib/authing_ruby/graphql/mutations/updatePhone.gql +63 -0
- data/lib/authing_ruby/management/ManagementClient.rb +1 -1
- data/lib/authing_ruby/management/ManagementTokenProvider.rb +9 -8
- data/lib/authing_ruby/management/UsersManagementClient.rb +4 -6
- data/lib/authing_ruby/test/helper.rb +6 -2
- data/lib/authing_ruby/test/js_sdk_test/2.registerByPhoneCode.js +130 -0
- data/lib/authing_ruby/test/js_sdk_test/3.sendSMS.js +23 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/browser/index.min.js +1 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/AuthenticationClient.d.ts +41 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/AuthenticationClient.js +60 -2
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/QrCodeAuthenticationClient.js +6 -3
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/SocialAuthenticationClient.d.ts +4 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/SocialAuthenticationClient.js +6 -5
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/types.d.ts +10 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/types.js +1 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/common/GraphqlClient.js +10 -8
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/common/HttpClient.js +17 -15
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/graphqlapi.d.ts +12 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/graphqlapi.js +192 -2
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/ApplicationsManagementClient.js +5 -3
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/GroupsManagementClient.d.ts +5 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/GroupsManagementClient.js +29 -11
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/ManagementClient.d.ts +5 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/ManagementClient.js +15 -2
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/OrgManagementClient.d.ts +34 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/OrgManagementClient.js +71 -3
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/RolesManagementClient.d.ts +6 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/RolesManagementClient.js +45 -10
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/UsersManagementClient.d.ts +34 -3
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/UsersManagementClient.js +189 -52
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/types.d.ts +10 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/types.js +1 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/utils.d.ts +1 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/utils.js +1 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/version.d.ts +1 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/version.js +2 -2
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/types/graphql.v2.d.ts +661 -32
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/types/graphql.v2.js +30 -19
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/AuthenticationClient.d.ts +41 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/AuthenticationClient.js +61 -3
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/QrCodeAuthenticationClient.js +6 -3
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/SocialAuthenticationClient.d.ts +4 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/SocialAuthenticationClient.js +6 -5
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/types.d.ts +10 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/types.js +1 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/common/GraphqlClient.js +10 -8
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/common/HttpClient.js +17 -15
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/graphqlapi.d.ts +12 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/graphqlapi.js +192 -2
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/ApplicationsManagementClient.js +5 -3
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/GroupsManagementClient.d.ts +5 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/GroupsManagementClient.js +30 -12
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/ManagementClient.d.ts +5 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/ManagementClient.js +15 -2
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/OrgManagementClient.d.ts +34 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/OrgManagementClient.js +72 -4
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/RolesManagementClient.d.ts +6 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/RolesManagementClient.js +46 -11
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/UsersManagementClient.d.ts +34 -3
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/UsersManagementClient.js +190 -53
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/types.d.ts +10 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/types.js +1 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/utils.d.ts +1 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/utils.js +1 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/version.d.ts +1 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/version.js +2 -2
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/types/graphql.v2.d.ts +661 -32
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/types/graphql.v2.js +29 -18
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/AuthenticationClient.d.ts +41 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/AuthenticationClient.js +60 -2
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/QrCodeAuthenticationClient.js +6 -3
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/SocialAuthenticationClient.d.ts +4 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/SocialAuthenticationClient.js +6 -5
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/types.d.ts +10 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/types.js +1 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/common/GraphqlClient.js +10 -8
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/common/HttpClient.js +17 -15
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/graphqlapi.d.ts +12 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/graphqlapi.js +192 -2
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/ApplicationsManagementClient.js +5 -3
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/GroupsManagementClient.d.ts +5 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/GroupsManagementClient.js +29 -11
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/ManagementClient.d.ts +5 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/ManagementClient.js +15 -2
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/OrgManagementClient.d.ts +34 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/OrgManagementClient.js +71 -3
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/RolesManagementClient.d.ts +6 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/RolesManagementClient.js +45 -10
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/UsersManagementClient.d.ts +34 -3
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/UsersManagementClient.js +189 -52
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/types.d.ts +10 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/types.js +1 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/utils.d.ts +1 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/utils.js +1 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/version.d.ts +1 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/version.js +2 -2
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/types/graphql.v2.d.ts +661 -32
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/types/graphql.v2.js +30 -19
- data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/package.json +1 -1
- data/lib/authing_ruby/test/js_sdk_test/node_modules/dotenv/CHANGELOG.md +210 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/dotenv/LICENSE +23 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/dotenv/README.md +275 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/dotenv/config.js +11 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/dotenv/lib/cli-options.js +13 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/dotenv/lib/env-options.js +18 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/dotenv/lib/main.js +118 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/dotenv/package.json +57 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/dotenv/types/index.d.ts +59 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/dotenv/types/test.ts +19 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/dotenv/types/tsconfig.json +15 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/dotenv/types/tslint.json +6 -0
- data/lib/authing_ruby/test/js_sdk_test/node_modules/follow-redirects/index.js +0 -4
- data/lib/authing_ruby/test/js_sdk_test/node_modules/follow-redirects/package.json +1 -1
- data/lib/authing_ruby/test/js_sdk_test/package-lock.json +7 -7
- data/lib/authing_ruby/test/js_sdk_test/package.json +3 -2
- data/lib/authing_ruby/test/js_sdk_test/yarn.lock +71 -0
- data/lib/authing_ruby/test/mini_test/TestApplicationsManagementClient.rb +2 -2
- data/lib/authing_ruby/test/mini_test/TestAuthenticationClient.rb +27 -13
- data/lib/authing_ruby/test/mini_test/TestManagementClient.rb +31 -43
- data/lib/authing_ruby/test/mini_test/TestSMSandEmail.rb +47 -3
- data/lib/authing_ruby/test/sms.rb +18 -0
- data/lib/authing_ruby/utils/utils.rb +68 -0
- data/lib/authing_ruby/version.rb +1 -1
- metadata +23 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4203f8f2932fcacc6405c533a530d779fef455827507dbb35292813d4c916244
|
|
4
|
+
data.tar.gz: d62015f96cd7b5ffb283dcc69db496954632f3468894fd2ddf189a3f71dc8ba3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a31bd62c0ddcf683dfb87427e241f24ccf32582d8848cc14764c2b0f496e6f10d49aa691cfb09a820fbfffcddb54ca67f0a82a307e125dcf4fa5dcc8bfe5e4e7
|
|
7
|
+
data.tar.gz: 24a19d114a8a24a4438e32c9d3b4c1209e1f75c7ec81efb068ce0fe4da0417bfd6279a65150f48f0c66f89f292aab6c3f21afee38dac754b8fe3840aeb54f5e8
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
#
|
|
2
|
-
# 把一些 garpqhlClient.request 封装起来,里面包含了 const query = AccessTokenDocument;
|
|
1
|
+
# 类似 JS SDK 里 src/lib/graphqlapi.ts 的用途,把请求进行封装
|
|
3
2
|
|
|
4
3
|
# 使用示例
|
|
5
4
|
# graphqlAPI = AuthingRuby::GraphQLAPI.new
|
|
6
5
|
# graphqlAPI.getAccessToken(graphqlClient, variables)
|
|
7
6
|
|
|
7
|
+
# 一共有三个参数
|
|
8
|
+
# (garpqhlClient, tokenProvider = nil, variables = nil)
|
|
9
|
+
# garpqhlClient 是 lib/authing_ruby/common/GraphqlClient.rb
|
|
10
|
+
# tokenProvider 是 lib/authing_ruby/authentication/AuthenticationTokenProvider.rb
|
|
11
|
+
# variables 就是参数
|
|
12
|
+
|
|
8
13
|
module AuthingRuby
|
|
9
14
|
class GraphQLAPI
|
|
10
15
|
|
|
@@ -112,12 +117,18 @@ module AuthingRuby
|
|
|
112
117
|
return _graphql_mutation_request("resetPassword", garpqhlClient, tokenProvider, variables)
|
|
113
118
|
end
|
|
114
119
|
|
|
120
|
+
# 更新用户手机号码
|
|
121
|
+
def updatePhone(garpqhlClient, tokenProvider = nil, variables = nil)
|
|
122
|
+
return _graphql_mutation_request("updatePhone", garpqhlClient, tokenProvider, variables)
|
|
123
|
+
end
|
|
124
|
+
|
|
115
125
|
def bindPhone(garpqhlClient, tokenProvider = nil, variables = nil)
|
|
116
126
|
return _graphql_mutation_request("bindPhone", garpqhlClient, tokenProvider, variables)
|
|
117
127
|
end
|
|
118
128
|
|
|
119
129
|
# 太多同样写法的 method 了,稍微抽象一下
|
|
120
130
|
# 这个负责发 mutation 的 request
|
|
131
|
+
# 第一个参数 gql_file_name 就是文件名
|
|
121
132
|
def _graphql_mutation_request(gql_file_name, garpqhlClient, tokenProvider, variables)
|
|
122
133
|
file = File.open("#{@folder_mutation}/#{gql_file_name}.gql");
|
|
123
134
|
return _graphql_request(file, garpqhlClient, tokenProvider, variables)
|
|
@@ -68,11 +68,10 @@ module AuthingRuby
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
graphqlAPI = AuthingRuby::GraphQLAPI.new
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
user = json.dig('data', 'registerByEmail')
|
|
71
|
+
hash = graphqlAPI.registerByEmail(@graphqlClient, variables)
|
|
72
|
+
user = hash.dig('data', 'registerByEmail')
|
|
74
73
|
return user if user
|
|
75
|
-
return
|
|
74
|
+
return hash
|
|
76
75
|
end
|
|
77
76
|
|
|
78
77
|
# 使用用户名注册
|
|
@@ -96,11 +95,10 @@ module AuthingRuby
|
|
|
96
95
|
}
|
|
97
96
|
}
|
|
98
97
|
graphqlAPI = AuthingRuby::GraphQLAPI.new
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
user = json.dig('data', 'registerByUsername')
|
|
98
|
+
hash = graphqlAPI.registerByUsername(@graphqlClient, variables)
|
|
99
|
+
user = hash.dig('data', 'registerByUsername')
|
|
102
100
|
return user if user
|
|
103
|
-
return
|
|
101
|
+
return hash
|
|
104
102
|
end
|
|
105
103
|
|
|
106
104
|
# 发送短信验证码
|
|
@@ -138,11 +136,10 @@ module AuthingRuby
|
|
|
138
136
|
}
|
|
139
137
|
}
|
|
140
138
|
graphqlAPI = AuthingRuby::GraphQLAPI.new
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
user = json.dig('data', 'registerByPhoneCode')
|
|
139
|
+
hash = graphqlAPI.registerByPhoneCode(@graphqlClient, variables)
|
|
140
|
+
user = hash.dig('data', 'registerByPhoneCode')
|
|
144
141
|
return user if user
|
|
145
|
-
return
|
|
142
|
+
return hash
|
|
146
143
|
end
|
|
147
144
|
|
|
148
145
|
# 使用邮箱登录
|
|
@@ -163,14 +160,13 @@ module AuthingRuby
|
|
|
163
160
|
}
|
|
164
161
|
}
|
|
165
162
|
graphqlAPI = AuthingRuby::GraphQLAPI.new
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
user = json.dig('data', 'loginByEmail')
|
|
163
|
+
hash = graphqlAPI.loginByEmail(@graphqlClient, variables)
|
|
164
|
+
user = hash.dig('data', 'loginByEmail')
|
|
169
165
|
if user
|
|
170
166
|
setCurrentUser(user);
|
|
171
167
|
return user
|
|
172
168
|
end
|
|
173
|
-
return
|
|
169
|
+
return hash
|
|
174
170
|
end
|
|
175
171
|
|
|
176
172
|
# 使用用户名登录
|
|
@@ -191,14 +187,13 @@ module AuthingRuby
|
|
|
191
187
|
}
|
|
192
188
|
}
|
|
193
189
|
graphqlAPI = AuthingRuby::GraphQLAPI.new
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
user = json.dig('data', 'loginByUsername')
|
|
190
|
+
hash = graphqlAPI.loginByUsername(@graphqlClient, variables)
|
|
191
|
+
user = hash.dig('data', 'loginByUsername')
|
|
197
192
|
if user
|
|
198
193
|
setCurrentUser(user);
|
|
199
194
|
return user
|
|
200
195
|
end
|
|
201
|
-
return
|
|
196
|
+
return hash
|
|
202
197
|
end
|
|
203
198
|
|
|
204
199
|
# 使用手机号验证码登录
|
|
@@ -215,14 +210,13 @@ module AuthingRuby
|
|
|
215
210
|
}
|
|
216
211
|
}
|
|
217
212
|
graphqlAPI = AuthingRuby::GraphQLAPI.new
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
user = json.dig('data', 'loginByPhoneCode')
|
|
213
|
+
hash = graphqlAPI.loginByPhoneCode(@graphqlClient, variables)
|
|
214
|
+
user = hash.dig('data', 'loginByPhoneCode')
|
|
221
215
|
if user
|
|
222
216
|
setCurrentUser(user);
|
|
223
217
|
return user
|
|
224
218
|
end
|
|
225
|
-
return
|
|
219
|
+
return hash
|
|
226
220
|
end
|
|
227
221
|
|
|
228
222
|
# 使用手机号密码登录
|
|
@@ -242,17 +236,13 @@ module AuthingRuby
|
|
|
242
236
|
}
|
|
243
237
|
}
|
|
244
238
|
graphqlAPI = AuthingRuby::GraphQLAPI.new
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
user = json.dig('data', 'loginByPhonePassword')
|
|
239
|
+
hash = graphqlAPI.loginByPhonePassword(@graphqlClient, variables)
|
|
240
|
+
user = hash.dig('data', 'loginByPhonePassword')
|
|
248
241
|
if user
|
|
249
242
|
setCurrentUser(user);
|
|
250
243
|
return user
|
|
251
244
|
end
|
|
252
|
-
return
|
|
253
|
-
end
|
|
254
|
-
|
|
255
|
-
def checkLoginStatus
|
|
245
|
+
return hash
|
|
256
246
|
end
|
|
257
247
|
|
|
258
248
|
# 发送邮件
|
|
@@ -265,11 +255,10 @@ module AuthingRuby
|
|
|
265
255
|
"scene": scene,
|
|
266
256
|
}
|
|
267
257
|
graphqlAPI = AuthingRuby::GraphQLAPI.new
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
data = json.dig('data')
|
|
258
|
+
hash = graphqlAPI.sendEmail(@graphqlClient, variables)
|
|
259
|
+
data = hash.dig('data')
|
|
271
260
|
return data if data
|
|
272
|
-
return
|
|
261
|
+
return hash
|
|
273
262
|
# {"sendEmail":{"message":"","code":200}}
|
|
274
263
|
end
|
|
275
264
|
|
|
@@ -277,14 +266,13 @@ module AuthingRuby
|
|
|
277
266
|
# 返回:用户信息
|
|
278
267
|
def getCurrentUser()
|
|
279
268
|
graphqlAPI = AuthingRuby::GraphQLAPI.new
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
user = json.dig("data", "user")
|
|
269
|
+
hash = graphqlAPI.getCurrentUser(@graphqlClient, @tokenProvider, {})
|
|
270
|
+
user = hash.dig("data", "user")
|
|
283
271
|
if user
|
|
284
272
|
setCurrentUser(user)
|
|
285
273
|
return user
|
|
286
274
|
else
|
|
287
|
-
return
|
|
275
|
+
return hash
|
|
288
276
|
end
|
|
289
277
|
end
|
|
290
278
|
|
|
@@ -609,9 +597,8 @@ module AuthingRuby
|
|
|
609
597
|
"id": userId,
|
|
610
598
|
"input": updates
|
|
611
599
|
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
updated_user = json.dig('data', 'updateUser')
|
|
600
|
+
hash = graphqlAPI.updateUser(@graphqlClient, @tokenProvider, variables)
|
|
601
|
+
updated_user = hash.dig('data', 'updateUser')
|
|
615
602
|
if updated_user
|
|
616
603
|
# 如果更新成功,返回更新后的用户
|
|
617
604
|
setCurrentUser(updated_user)
|
|
@@ -619,7 +606,7 @@ module AuthingRuby
|
|
|
619
606
|
else
|
|
620
607
|
# 如果更新失败,返回原结果
|
|
621
608
|
# {"errors"=>[{"message"=>{"code"=>2020, "message"=>"尚未登录,无访问权限"}, "locations"=>[{"line"=>2, "column"=>3}], "path"=>["updateUser"], "extensions"=>{"code"=>"INTERNAL_SERVER_ERROR"}}], "data"=>nil}
|
|
622
|
-
return
|
|
609
|
+
return hash
|
|
623
610
|
end
|
|
624
611
|
end
|
|
625
612
|
|
|
@@ -661,18 +648,16 @@ module AuthingRuby
|
|
|
661
648
|
def checkPasswordStrength(password)
|
|
662
649
|
graphqlAPI = AuthingRuby::GraphQLAPI.new
|
|
663
650
|
variables = { "password": password }
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
return json.dig("data", "checkPasswordStrength")
|
|
651
|
+
hash = graphqlAPI.checkPasswordStrength(@graphqlClient, @tokenProvider, variables)
|
|
652
|
+
return hash.dig("data", "checkPasswordStrength")
|
|
667
653
|
end
|
|
668
654
|
|
|
669
655
|
# 检测 Token 登录状态
|
|
670
656
|
def checkLoginStatus(token)
|
|
671
657
|
graphqlAPI = AuthingRuby::GraphQLAPI.new
|
|
672
658
|
variables = { "token": token }
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
return json.dig("data", "checkLoginStatus")
|
|
659
|
+
hash = graphqlAPI.checkLoginStatus(@graphqlClient, @tokenProvider, variables)
|
|
660
|
+
return hash.dig("data", "checkLoginStatus")
|
|
676
661
|
end
|
|
677
662
|
|
|
678
663
|
# 更新用户密码
|
|
@@ -685,9 +670,8 @@ module AuthingRuby
|
|
|
685
670
|
"oldPassword": oldPasswordEncrypted,
|
|
686
671
|
}
|
|
687
672
|
graphqlAPI = AuthingRuby::GraphQLAPI.new
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
return json.dig("data", "updatePassword")
|
|
673
|
+
hash = graphqlAPI.updatePassword(@graphqlClient, @tokenProvider, variables)
|
|
674
|
+
return hash.dig("data", "updatePassword")
|
|
691
675
|
end
|
|
692
676
|
|
|
693
677
|
# 绑定手机号
|
|
@@ -698,14 +682,37 @@ module AuthingRuby
|
|
|
698
682
|
"phone": phone,
|
|
699
683
|
"phoneCode": phoneCode,
|
|
700
684
|
}
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
user = json.dig("data", "bindPhone")
|
|
685
|
+
hash = graphqlAPI.bindPhone(@graphqlClient, @tokenProvider, variables)
|
|
686
|
+
user = hash.dig("data", "bindPhone")
|
|
704
687
|
if user
|
|
705
688
|
setCurrentUser(user);
|
|
706
689
|
return user;
|
|
707
690
|
else
|
|
708
|
-
return
|
|
691
|
+
return hash
|
|
692
|
+
end
|
|
693
|
+
end
|
|
694
|
+
|
|
695
|
+
# 更新用户手机号
|
|
696
|
+
# 更新用户手机号。和修改邮箱一样,默认情况下,如果用户当前已经绑定了手机号,需要同时验证原有手机号(目前账号绑定的手机号)和当前邮箱(将要绑定的手机号)。
|
|
697
|
+
# 也就是说,用户 A 当前绑定的手机号为 15888888888,想修改为 15899999999,那么就需要同时验证这两个手机号。
|
|
698
|
+
# 开发者也可以选择不开启 “验证原有手机号“ ,可以在 Authing 控制台 的 设置目录下的安全信息模块进行关闭。
|
|
699
|
+
# 用户首次绑定手机号请使用 bindPhone 接口。
|
|
700
|
+
def updatePhone(phone, phoneCode, oldPhone, oldPhoneCode)
|
|
701
|
+
graphqlAPI = AuthingRuby::GraphQLAPI.new
|
|
702
|
+
variables = {
|
|
703
|
+
"phone": phone,
|
|
704
|
+
"phoneCode": phoneCode,
|
|
705
|
+
}
|
|
706
|
+
variables['oldPhone'] = oldPhone if oldPhone
|
|
707
|
+
variables['oldPhoneCode'] = oldPhoneCode if oldPhoneCode
|
|
708
|
+
|
|
709
|
+
hash = graphqlAPI.updatePhone(@graphqlClient, @tokenProvider, variables)
|
|
710
|
+
user = hash.dig("data", "updatePhone")
|
|
711
|
+
if user
|
|
712
|
+
setCurrentUser(user)
|
|
713
|
+
return user
|
|
714
|
+
else
|
|
715
|
+
return hash
|
|
709
716
|
end
|
|
710
717
|
end
|
|
711
718
|
|
|
@@ -720,11 +727,10 @@ module AuthingRuby
|
|
|
720
727
|
"newPassword": newPasswordEncrypted,
|
|
721
728
|
}
|
|
722
729
|
graphqlAPI = AuthingRuby::GraphQLAPI.new
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
result = json.dig("data", "resetPassword") # {"message":"重置密码成功!","code":200}
|
|
730
|
+
hash = graphqlAPI.resetPassword(@graphqlClient, @tokenProvider, variables)
|
|
731
|
+
result = hash.dig("data", "resetPassword") # {"message":"重置密码成功!","code":200}
|
|
726
732
|
return result if result
|
|
727
|
-
return
|
|
733
|
+
return hash
|
|
728
734
|
end
|
|
729
735
|
|
|
730
736
|
def generateCodeChallenge()
|
|
@@ -14,6 +14,8 @@ module AuthingRuby
|
|
|
14
14
|
@options = options
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
# 发请求
|
|
18
|
+
# 成功或失败都返回 Hash
|
|
17
19
|
def request(options)
|
|
18
20
|
headers = {
|
|
19
21
|
'content-type': 'application/json',
|
|
@@ -28,10 +30,46 @@ module AuthingRuby
|
|
|
28
30
|
headers['Authorization'] = "Bearer #{token}"
|
|
29
31
|
end
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
option_json = options.fetch(:json, nil)
|
|
34
|
+
response = HTTP.headers(headers).post(@endpoint, json: option_json)
|
|
35
|
+
|
|
36
|
+
# 如果直接拿 body,它的类型是:
|
|
37
|
+
# puts response.body
|
|
38
|
+
# puts response.body.class.name # HTTP::Response::Body
|
|
39
|
+
|
|
40
|
+
# 如果转成 String:
|
|
41
|
+
# puts response.body.to_s
|
|
42
|
+
# puts response.body.to_s.class.name # String
|
|
43
|
+
|
|
44
|
+
hash = JSON.parse(response.body.to_s)
|
|
45
|
+
|
|
46
|
+
# 这里的错误处理代码参照的 JS SDK (src/lib/common/GraphqlClient.ts)
|
|
47
|
+
if hash['errors'] == nil
|
|
48
|
+
# 如果没错误
|
|
49
|
+
return hash
|
|
50
|
+
else
|
|
51
|
+
# 如果有错误, 最后返回这3个字段就行
|
|
52
|
+
code = nil
|
|
53
|
+
message = nil
|
|
54
|
+
data = nil
|
|
55
|
+
|
|
56
|
+
hash['errors'].each do |e|
|
|
57
|
+
if e['message']
|
|
58
|
+
message = e['message']
|
|
59
|
+
code = message['code']
|
|
60
|
+
message = message['message']
|
|
61
|
+
data = message['data']
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# 返回 Hash
|
|
66
|
+
obj = {
|
|
67
|
+
code: code,
|
|
68
|
+
message: message,
|
|
69
|
+
data: data
|
|
70
|
+
}
|
|
71
|
+
return obj
|
|
72
|
+
end
|
|
35
73
|
end
|
|
36
74
|
|
|
37
75
|
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
mutation updatePhone(
|
|
2
|
+
$phone: String!
|
|
3
|
+
$phoneCode: String!
|
|
4
|
+
$oldPhone: String
|
|
5
|
+
$oldPhoneCode: String
|
|
6
|
+
) {
|
|
7
|
+
updatePhone(
|
|
8
|
+
phone: $phone
|
|
9
|
+
phoneCode: $phoneCode
|
|
10
|
+
oldPhone: $oldPhone
|
|
11
|
+
oldPhoneCode: $oldPhoneCode
|
|
12
|
+
) {
|
|
13
|
+
id
|
|
14
|
+
arn
|
|
15
|
+
userPoolId
|
|
16
|
+
status
|
|
17
|
+
username
|
|
18
|
+
email
|
|
19
|
+
emailVerified
|
|
20
|
+
phone
|
|
21
|
+
phoneVerified
|
|
22
|
+
unionid
|
|
23
|
+
openid
|
|
24
|
+
nickname
|
|
25
|
+
registerSource
|
|
26
|
+
photo
|
|
27
|
+
password
|
|
28
|
+
oauth
|
|
29
|
+
token
|
|
30
|
+
tokenExpiredAt
|
|
31
|
+
loginsCount
|
|
32
|
+
lastLogin
|
|
33
|
+
lastIP
|
|
34
|
+
signedUp
|
|
35
|
+
blocked
|
|
36
|
+
isDeleted
|
|
37
|
+
device
|
|
38
|
+
browser
|
|
39
|
+
company
|
|
40
|
+
name
|
|
41
|
+
givenName
|
|
42
|
+
familyName
|
|
43
|
+
middleName
|
|
44
|
+
profile
|
|
45
|
+
preferredUsername
|
|
46
|
+
website
|
|
47
|
+
gender
|
|
48
|
+
birthdate
|
|
49
|
+
zoneinfo
|
|
50
|
+
locale
|
|
51
|
+
address
|
|
52
|
+
formatted
|
|
53
|
+
streetAddress
|
|
54
|
+
locality
|
|
55
|
+
region
|
|
56
|
+
postalCode
|
|
57
|
+
city
|
|
58
|
+
province
|
|
59
|
+
country
|
|
60
|
+
createdAt
|
|
61
|
+
updatedAt
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -16,8 +16,8 @@ module AuthingRuby
|
|
|
16
16
|
@_accessToken = nil
|
|
17
17
|
@_accessTokenExpriredAt = nil # 过期时间
|
|
18
18
|
|
|
19
|
-
accessToken = options.fetch(:accessToken, nil)
|
|
20
19
|
# 如果 options 里传入了 accessToken
|
|
20
|
+
accessToken = options.fetch(:accessToken, nil)
|
|
21
21
|
if accessToken
|
|
22
22
|
@_accessToken = accessToken;
|
|
23
23
|
decoded_token_array = JWT.decode @_accessToken, nil, false # 试着解析一下
|
|
@@ -46,6 +46,7 @@ module AuthingRuby
|
|
|
46
46
|
def _getAccessTokenFromServer
|
|
47
47
|
accessToken = nil;
|
|
48
48
|
secret = @options.fetch(:secret, nil)
|
|
49
|
+
|
|
49
50
|
if secret
|
|
50
51
|
accessToken = getClientWhenSdkInit()
|
|
51
52
|
else
|
|
@@ -68,20 +69,20 @@ module AuthingRuby
|
|
|
68
69
|
secret: @options.fetch(:secret, nil),
|
|
69
70
|
}
|
|
70
71
|
api = AuthingRuby::GraphQLAPI.new
|
|
71
|
-
|
|
72
|
+
hash = api.getAccessToken(@graphqlClient, variables)
|
|
72
73
|
# {"data":{"accessToken":{"accessToken":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InR5cGUiOiJ1[省略]ZWE2NjE3IiwidXNlcks2lkIjoiNjA3YjBiMTVhYWIzYTgwNWY3ZWE2NjE3IiwiX2lkIjoiNjA3YjBiMTVhYWIzYTgwNWY3ZWE2NjE3IiwicGhvbmz3Mzk5M30.K7pwyvbxypeiOlYRsTIlLXY2xyk94tTd-CATQ85jYqM","exp":1620873993,"iat":1619577993}}}
|
|
73
|
-
hash = JSON.parse(res)
|
|
74
74
|
return hash.dig("data", "accessToken", "accessToken")
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
-
# TODO 还需要做什么?
|
|
78
77
|
def refreshToken
|
|
79
78
|
api = AuthingRuby::GraphQLAPI.new
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
accessToken = @options.fetch(:accessToken, nil)
|
|
80
|
+
if accessToken == nil
|
|
81
|
+
raise "无法刷新 token, 因为初始化时没有传入 accessToken"
|
|
82
|
+
end
|
|
83
|
+
hash = api.refreshAccessToken(@graphqlClient, {
|
|
84
|
+
accessToken: accessToken
|
|
82
85
|
})
|
|
83
|
-
hash = JSON.parse(res)
|
|
84
|
-
# puts hash
|
|
85
86
|
# {"errors"=>[{"message"=>{"code"=>500, "message"=>"该 token 在黑名单中"}, "locations"=>[{"line"=>2, "column"=>5}], "path"=>["refreshAccessToken"], "extensions"=>{"code"=>"INTERNAL_SERVER_ERROR", "exception"=>{"name"=>"TokenInBlackListError"}}}], "data"=>nil}
|
|
86
87
|
if hash.dig("errors")
|
|
87
88
|
return hash
|