authing_ruby 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (505) hide show
  1. checksums.yaml +7 -0
  2. data/authing_ruby.gemspec +30 -0
  3. data/lib/authing_ruby/GraphQLAPI.rb +151 -0
  4. data/lib/authing_ruby/authentication/AuthenticationClient.rb +801 -0
  5. data/lib/authing_ruby/authentication/AuthenticationTokenProvider.rb +42 -0
  6. data/lib/authing_ruby/authentication/BaseAuthenticationClient.rb +28 -0
  7. data/lib/authing_ruby/common/GraphqlClient.rb +39 -0
  8. data/lib/authing_ruby/common/HttpClient.rb +247 -0
  9. data/lib/authing_ruby/common/PublicKeyManager.rb +42 -0
  10. data/lib/authing_ruby/graphql/mutations/bindPhone.gql +53 -0
  11. data/lib/authing_ruby/graphql/mutations/createUser.gql +54 -0
  12. data/lib/authing_ruby/graphql/mutations/deleteUser.gql +6 -0
  13. data/lib/authing_ruby/graphql/mutations/deleteUsers.gql +6 -0
  14. data/lib/authing_ruby/graphql/mutations/loginByEmail.gql +54 -0
  15. data/lib/authing_ruby/graphql/mutations/loginByPhoneCode.gql +54 -0
  16. data/lib/authing_ruby/graphql/mutations/loginByPhonePassword.gql +54 -0
  17. data/lib/authing_ruby/graphql/mutations/loginByUsername.gql +54 -0
  18. data/lib/authing_ruby/graphql/mutations/refreshAccessToken.gql +7 -0
  19. data/lib/authing_ruby/graphql/mutations/registerByEmail.gql +54 -0
  20. data/lib/authing_ruby/graphql/mutations/registerByPhoneCode.gql +54 -0
  21. data/lib/authing_ruby/graphql/mutations/registerByUsername.gql +54 -0
  22. data/lib/authing_ruby/graphql/mutations/resetPassword.gql +6 -0
  23. data/lib/authing_ruby/graphql/mutations/sendEmail.gql +6 -0
  24. data/lib/authing_ruby/graphql/mutations/updatePassword.gql +53 -0
  25. data/lib/authing_ruby/graphql/mutations/updateUser.gql +54 -0
  26. data/lib/authing_ruby/graphql/queries/accessToken.gql +7 -0
  27. data/lib/authing_ruby/graphql/queries/checkLoginStatus.gql +14 -0
  28. data/lib/authing_ruby/graphql/queries/checkPasswordStrength.gql +6 -0
  29. data/lib/authing_ruby/graphql/queries/findUser.gql +64 -0
  30. data/lib/authing_ruby/graphql/queries/isUserExists.gql +13 -0
  31. data/lib/authing_ruby/graphql/queries/user.gql +63 -0
  32. data/lib/authing_ruby/graphql/queries/users.gql +57 -0
  33. data/lib/authing_ruby/management/AclManagementClient.rb +47 -0
  34. data/lib/authing_ruby/management/ApplicationsManagementClient.rb +79 -0
  35. data/lib/authing_ruby/management/ManagementClient.rb +66 -0
  36. data/lib/authing_ruby/management/ManagementTokenProvider.rb +92 -0
  37. data/lib/authing_ruby/management/RolesManagementClient.rb +38 -0
  38. data/lib/authing_ruby/management/UserpoolManagementClient.rb +15 -0
  39. data/lib/authing_ruby/management/UsersManagementClient.rb +161 -0
  40. data/lib/authing_ruby/management/WhitelistManagementClient.rb +1 -0
  41. data/lib/authing_ruby/test/RSA.rb +18 -0
  42. data/lib/authing_ruby/test/helper.rb +15 -0
  43. data/lib/authing_ruby/test/js_sdk_test/1.buildAuthorizeUrl.js +43 -0
  44. data/lib/authing_ruby/test/js_sdk_test/2.buildAuthorizeUrl_PKCE.js +47 -0
  45. data/lib/authing_ruby/test/js_sdk_test/README.md +5 -0
  46. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/CONTRIBUTION.md +23 -0
  47. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/LICENSE +21 -0
  48. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/README.md +303 -0
  49. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/browser/index.min.js +2 -0
  50. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/browser/index.min.js.LICENSE.txt +91 -0
  51. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/index.d.ts +7 -0
  52. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/index.js +20 -0
  53. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/AuthenticationClient.d.ts +1078 -0
  54. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/AuthenticationClient.js +2801 -0
  55. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/AuthenticationTokenProvider.d.ts +13 -0
  56. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/AuthenticationTokenProvider.js +56 -0
  57. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/BaseAuthenticationClient.d.ts +6 -0
  58. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/BaseAuthenticationClient.js +31 -0
  59. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/EnterpriseAuthenticationClient.d.ts +92 -0
  60. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/EnterpriseAuthenticationClient.js +250 -0
  61. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/MfaAuthenticationClient.d.ts +303 -0
  62. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/MfaAuthenticationClient.js +665 -0
  63. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/QrCodeAuthenticationClient.d.ts +232 -0
  64. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/QrCodeAuthenticationClient.js +619 -0
  65. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/SocialAuthenticationClient.d.ts +100 -0
  66. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/SocialAuthenticationClient.js +179 -0
  67. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/types.d.ts +331 -0
  68. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/authentication/types.js +69 -0
  69. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/common/GraphqlClient.d.ts +14 -0
  70. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/common/GraphqlClient.js +125 -0
  71. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/common/HttpClient.d.ts +19 -0
  72. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/common/HttpClient.js +149 -0
  73. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/common/PublicKeyManager.d.ts +18 -0
  74. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/common/PublicKeyManager.js +81 -0
  75. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/graphqlapi.d.ts +110 -0
  76. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/graphqlapi.js +1812 -0
  77. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/AclManagementClient.d.ts +236 -0
  78. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/AclManagementClient.js +863 -0
  79. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/AgreementManagementClient.d.ts +65 -0
  80. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/AgreementManagementClient.js +195 -0
  81. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/ApplicationsManagementClient.d.ts +216 -0
  82. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/ApplicationsManagementClient.js +531 -0
  83. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/GroupsManagementClient.d.ts +184 -0
  84. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/GroupsManagementClient.js +386 -0
  85. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/MFAManagementClient.d.ts +58 -0
  86. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/MFAManagementClient.js +126 -0
  87. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/ManagementClient.d.ts +74 -0
  88. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/ManagementClient.js +190 -0
  89. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/ManagementTokenProvider.d.ts +39 -0
  90. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/ManagementTokenProvider.js +159 -0
  91. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/OrgManagementClient.d.ts +488 -0
  92. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/OrgManagementClient.js +772 -0
  93. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/PoliciesManagementClient.d.ts +304 -0
  94. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/PoliciesManagementClient.js +512 -0
  95. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/RolesManagementClient.d.ts +291 -0
  96. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/RolesManagementClient.js +676 -0
  97. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/StatisticsManagementClient.d.ts +56 -0
  98. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/StatisticsManagementClient.js +198 -0
  99. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/UdfManagementClient.d.ts +146 -0
  100. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/UdfManagementClient.js +264 -0
  101. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/UserActionManagementClient.d.ts +44 -0
  102. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/UserActionManagementClient.js +106 -0
  103. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/UserpoolManagementClient.d.ts +142 -0
  104. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/UserpoolManagementClient.js +241 -0
  105. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/UsersManagementClient.d.ts +753 -0
  106. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/UsersManagementClient.js +1114 -0
  107. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/WhitelistManagementClient.d.ts +114 -0
  108. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/WhitelistManagementClient.js +259 -0
  109. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/types.d.ts +982 -0
  110. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/management/types.js +96 -0
  111. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/platform/express/index.d.ts +30 -0
  112. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/platform/express/index.js +126 -0
  113. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/testing-helper.d.ts +31 -0
  114. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/testing-helper.js +67 -0
  115. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/utils.d.ts +53 -0
  116. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/utils.js +343 -0
  117. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/version.d.ts +1 -0
  118. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/lib/version.js +5 -0
  119. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/types/graphql.v2.d.ts +5612 -0
  120. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/types/graphql.v2.js +240 -0
  121. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/types/index.d.ts +7 -0
  122. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/main/types/index.js +3 -0
  123. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/index.d.ts +7 -0
  124. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/index.js +8 -0
  125. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/AuthenticationClient.d.ts +1078 -0
  126. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/AuthenticationClient.js +2795 -0
  127. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/AuthenticationTokenProvider.d.ts +13 -0
  128. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/AuthenticationTokenProvider.js +53 -0
  129. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/BaseAuthenticationClient.d.ts +6 -0
  130. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/BaseAuthenticationClient.js +28 -0
  131. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/EnterpriseAuthenticationClient.d.ts +92 -0
  132. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/EnterpriseAuthenticationClient.js +247 -0
  133. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/MfaAuthenticationClient.d.ts +303 -0
  134. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/MfaAuthenticationClient.js +662 -0
  135. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/QrCodeAuthenticationClient.d.ts +232 -0
  136. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/QrCodeAuthenticationClient.js +616 -0
  137. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/SocialAuthenticationClient.d.ts +100 -0
  138. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/SocialAuthenticationClient.js +176 -0
  139. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/types.d.ts +331 -0
  140. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/authentication/types.js +66 -0
  141. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/common/GraphqlClient.d.ts +14 -0
  142. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/common/GraphqlClient.js +119 -0
  143. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/common/HttpClient.d.ts +19 -0
  144. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/common/HttpClient.js +143 -0
  145. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/common/PublicKeyManager.d.ts +18 -0
  146. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/common/PublicKeyManager.js +78 -0
  147. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/graphqlapi.d.ts +110 -0
  148. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/graphqlapi.js +1809 -0
  149. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/AclManagementClient.d.ts +236 -0
  150. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/AclManagementClient.js +860 -0
  151. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/AgreementManagementClient.d.ts +65 -0
  152. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/AgreementManagementClient.js +192 -0
  153. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/ApplicationsManagementClient.d.ts +216 -0
  154. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/ApplicationsManagementClient.js +528 -0
  155. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/GroupsManagementClient.d.ts +184 -0
  156. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/GroupsManagementClient.js +383 -0
  157. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/MFAManagementClient.d.ts +58 -0
  158. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/MFAManagementClient.js +123 -0
  159. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/ManagementClient.d.ts +74 -0
  160. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/ManagementClient.js +184 -0
  161. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/ManagementTokenProvider.d.ts +39 -0
  162. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/ManagementTokenProvider.js +153 -0
  163. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/OrgManagementClient.d.ts +488 -0
  164. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/OrgManagementClient.js +750 -0
  165. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/PoliciesManagementClient.d.ts +304 -0
  166. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/PoliciesManagementClient.js +509 -0
  167. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/RolesManagementClient.d.ts +291 -0
  168. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/RolesManagementClient.js +673 -0
  169. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/StatisticsManagementClient.d.ts +56 -0
  170. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/StatisticsManagementClient.js +195 -0
  171. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/UdfManagementClient.d.ts +146 -0
  172. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/UdfManagementClient.js +261 -0
  173. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/UserActionManagementClient.d.ts +44 -0
  174. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/UserActionManagementClient.js +103 -0
  175. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/UserpoolManagementClient.d.ts +142 -0
  176. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/UserpoolManagementClient.js +238 -0
  177. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/UsersManagementClient.d.ts +753 -0
  178. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/UsersManagementClient.js +1111 -0
  179. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/WhitelistManagementClient.d.ts +114 -0
  180. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/WhitelistManagementClient.js +256 -0
  181. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/types.d.ts +982 -0
  182. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/management/types.js +93 -0
  183. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/platform/express/index.d.ts +30 -0
  184. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/platform/express/index.js +123 -0
  185. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/testing-helper.d.ts +31 -0
  186. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/testing-helper.js +62 -0
  187. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/utils.d.ts +53 -0
  188. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/utils.js +336 -0
  189. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/version.d.ts +1 -0
  190. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/lib/version.js +2 -0
  191. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/types/graphql.v2.d.ts +5612 -0
  192. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/types/graphql.v2.js +237 -0
  193. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/types/index.d.ts +7 -0
  194. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/module/types/index.js +1 -0
  195. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/index.d.ts +7 -0
  196. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/index.js +30 -0
  197. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/AuthenticationClient.d.ts +1078 -0
  198. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/AuthenticationClient.js +2811 -0
  199. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/AuthenticationTokenProvider.d.ts +13 -0
  200. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/AuthenticationTokenProvider.js +66 -0
  201. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/BaseAuthenticationClient.d.ts +6 -0
  202. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/BaseAuthenticationClient.js +41 -0
  203. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/EnterpriseAuthenticationClient.d.ts +92 -0
  204. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/EnterpriseAuthenticationClient.js +260 -0
  205. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/MfaAuthenticationClient.d.ts +303 -0
  206. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/MfaAuthenticationClient.js +675 -0
  207. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/QrCodeAuthenticationClient.d.ts +232 -0
  208. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/QrCodeAuthenticationClient.js +629 -0
  209. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/SocialAuthenticationClient.d.ts +100 -0
  210. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/SocialAuthenticationClient.js +189 -0
  211. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/types.d.ts +331 -0
  212. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/authentication/types.js +79 -0
  213. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/common/GraphqlClient.d.ts +14 -0
  214. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/common/GraphqlClient.js +135 -0
  215. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/common/HttpClient.d.ts +19 -0
  216. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/common/HttpClient.js +159 -0
  217. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/common/PublicKeyManager.d.ts +18 -0
  218. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/common/PublicKeyManager.js +91 -0
  219. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/graphqlapi.d.ts +110 -0
  220. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/graphqlapi.js +1822 -0
  221. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/AclManagementClient.d.ts +236 -0
  222. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/AclManagementClient.js +873 -0
  223. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/AgreementManagementClient.d.ts +65 -0
  224. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/AgreementManagementClient.js +205 -0
  225. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/ApplicationsManagementClient.d.ts +216 -0
  226. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/ApplicationsManagementClient.js +541 -0
  227. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/GroupsManagementClient.d.ts +184 -0
  228. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/GroupsManagementClient.js +396 -0
  229. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/MFAManagementClient.d.ts +58 -0
  230. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/MFAManagementClient.js +136 -0
  231. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/ManagementClient.d.ts +74 -0
  232. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/ManagementClient.js +200 -0
  233. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/ManagementTokenProvider.d.ts +39 -0
  234. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/ManagementTokenProvider.js +169 -0
  235. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/OrgManagementClient.d.ts +488 -0
  236. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/OrgManagementClient.js +782 -0
  237. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/PoliciesManagementClient.d.ts +304 -0
  238. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/PoliciesManagementClient.js +522 -0
  239. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/RolesManagementClient.d.ts +291 -0
  240. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/RolesManagementClient.js +686 -0
  241. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/StatisticsManagementClient.d.ts +56 -0
  242. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/StatisticsManagementClient.js +208 -0
  243. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/UdfManagementClient.d.ts +146 -0
  244. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/UdfManagementClient.js +274 -0
  245. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/UserActionManagementClient.d.ts +44 -0
  246. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/UserActionManagementClient.js +116 -0
  247. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/UserpoolManagementClient.d.ts +142 -0
  248. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/UserpoolManagementClient.js +251 -0
  249. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/UsersManagementClient.d.ts +753 -0
  250. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/UsersManagementClient.js +1124 -0
  251. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/WhitelistManagementClient.d.ts +114 -0
  252. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/WhitelistManagementClient.js +269 -0
  253. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/types.d.ts +982 -0
  254. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/management/types.js +106 -0
  255. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/platform/express/index.d.ts +30 -0
  256. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/platform/express/index.js +136 -0
  257. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/testing-helper.d.ts +31 -0
  258. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/testing-helper.js +77 -0
  259. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/utils.d.ts +53 -0
  260. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/utils.js +353 -0
  261. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/version.d.ts +1 -0
  262. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/lib/version.js +15 -0
  263. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/types/graphql.v2.d.ts +5612 -0
  264. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/types/graphql.v2.js +250 -0
  265. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/types/index.d.ts +7 -0
  266. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build/umd/types/index.js +13 -0
  267. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/build-doc.js +520 -0
  268. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/CHANGELOG.md +413 -0
  269. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/LICENSE +19 -0
  270. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/README.md +709 -0
  271. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/UPGRADE_GUIDE.md +162 -0
  272. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/dist/axios.js +1715 -0
  273. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/dist/axios.map +1 -0
  274. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/dist/axios.min.js +3 -0
  275. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/dist/axios.min.map +1 -0
  276. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/index.d.ts +157 -0
  277. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/index.js +1 -0
  278. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/adapters/README.md +37 -0
  279. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/adapters/http.js +279 -0
  280. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/adapters/xhr.js +180 -0
  281. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/axios.js +53 -0
  282. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/cancel/Cancel.js +19 -0
  283. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/cancel/CancelToken.js +57 -0
  284. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/cancel/isCancel.js +5 -0
  285. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/core/Axios.js +94 -0
  286. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/core/InterceptorManager.js +52 -0
  287. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/core/README.md +7 -0
  288. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/core/buildFullPath.js +20 -0
  289. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/core/createError.js +18 -0
  290. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/core/dispatchRequest.js +79 -0
  291. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/core/enhanceError.js +42 -0
  292. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/core/mergeConfig.js +73 -0
  293. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/core/settle.js +25 -0
  294. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/core/transformData.js +20 -0
  295. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/defaults.js +97 -0
  296. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/helpers/README.md +7 -0
  297. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/helpers/bind.js +11 -0
  298. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/helpers/buildURL.js +71 -0
  299. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/helpers/combineURLs.js +14 -0
  300. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/helpers/cookies.js +53 -0
  301. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/helpers/deprecatedMethod.js +24 -0
  302. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/helpers/isAbsoluteURL.js +14 -0
  303. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/helpers/isURLSameOrigin.js +68 -0
  304. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/helpers/normalizeHeaderName.js +12 -0
  305. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/helpers/parseHeaders.js +53 -0
  306. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/helpers/spread.js +27 -0
  307. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/utils.js +344 -0
  308. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/package.json +84 -0
  309. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/follow-redirects/LICENSE +18 -0
  310. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/follow-redirects/README.md +155 -0
  311. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/follow-redirects/http.js +1 -0
  312. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/follow-redirects/https.js +1 -0
  313. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/follow-redirects/index.js +322 -0
  314. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/follow-redirects/package.json +60 -0
  315. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/package.json +129 -0
  316. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/tests/index.html +21 -0
  317. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/tsconfig.brower.json +45 -0
  318. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/tsconfig.node.json +0 -0
  319. data/lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/webpack.config.js +41 -0
  320. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/CHANGELOG.md +685 -0
  321. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/LICENSE +19 -0
  322. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/README.md +800 -0
  323. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/UPGRADE_GUIDE.md +162 -0
  324. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/dist/axios.js +1756 -0
  325. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/dist/axios.map +1 -0
  326. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/dist/axios.min.js +3 -0
  327. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/dist/axios.min.map +1 -0
  328. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/index.d.ts +161 -0
  329. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/index.js +1 -0
  330. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/adapters/README.md +37 -0
  331. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/adapters/http.js +303 -0
  332. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/adapters/xhr.js +179 -0
  333. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/axios.js +56 -0
  334. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/cancel/Cancel.js +19 -0
  335. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/cancel/CancelToken.js +57 -0
  336. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/cancel/isCancel.js +5 -0
  337. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/core/Axios.js +95 -0
  338. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/core/InterceptorManager.js +52 -0
  339. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/core/README.md +7 -0
  340. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/core/buildFullPath.js +20 -0
  341. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/core/createError.js +18 -0
  342. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/core/dispatchRequest.js +79 -0
  343. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/core/enhanceError.js +42 -0
  344. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/core/mergeConfig.js +87 -0
  345. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/core/settle.js +25 -0
  346. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/core/transformData.js +20 -0
  347. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/defaults.js +98 -0
  348. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/helpers/README.md +7 -0
  349. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/helpers/bind.js +11 -0
  350. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/helpers/buildURL.js +70 -0
  351. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/helpers/combineURLs.js +14 -0
  352. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/helpers/cookies.js +53 -0
  353. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/helpers/deprecatedMethod.js +24 -0
  354. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/helpers/isAbsoluteURL.js +14 -0
  355. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/helpers/isAxiosError.js +11 -0
  356. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/helpers/isURLSameOrigin.js +68 -0
  357. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/helpers/normalizeHeaderName.js +12 -0
  358. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/helpers/parseHeaders.js +53 -0
  359. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/helpers/spread.js +27 -0
  360. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/utils.js +351 -0
  361. data/lib/authing_ruby/test/js_sdk_test/node_modules/axios/package.json +86 -0
  362. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/CONTRIBUTING.md +28 -0
  363. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/LICENSE +24 -0
  364. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/README.md +249 -0
  365. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/aes.js +234 -0
  366. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/bower.json +35 -0
  367. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/cipher-core.js +890 -0
  368. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/core.js +797 -0
  369. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/crypto-js.js +6059 -0
  370. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/docs/QuickStartGuide.wiki +470 -0
  371. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/enc-base64.js +136 -0
  372. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/enc-hex.js +18 -0
  373. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/enc-latin1.js +18 -0
  374. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/enc-utf16.js +149 -0
  375. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/enc-utf8.js +18 -0
  376. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/evpkdf.js +134 -0
  377. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/format-hex.js +66 -0
  378. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/format-openssl.js +18 -0
  379. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/hmac-md5.js +18 -0
  380. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/hmac-ripemd160.js +18 -0
  381. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/hmac-sha1.js +18 -0
  382. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/hmac-sha224.js +18 -0
  383. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/hmac-sha256.js +18 -0
  384. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/hmac-sha3.js +18 -0
  385. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/hmac-sha384.js +18 -0
  386. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/hmac-sha512.js +18 -0
  387. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/hmac.js +143 -0
  388. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/index.js +18 -0
  389. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/lib-typedarrays.js +76 -0
  390. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/md5.js +268 -0
  391. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/mode-cfb.js +80 -0
  392. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/mode-ctr-gladman.js +116 -0
  393. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/mode-ctr.js +58 -0
  394. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/mode-ecb.js +40 -0
  395. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/mode-ofb.js +54 -0
  396. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/package.json +38 -0
  397. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/pad-ansix923.js +49 -0
  398. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/pad-iso10126.js +44 -0
  399. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/pad-iso97971.js +40 -0
  400. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/pad-nopadding.js +30 -0
  401. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/pad-pkcs7.js +18 -0
  402. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/pad-zeropadding.js +47 -0
  403. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/pbkdf2.js +145 -0
  404. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/rabbit-legacy.js +190 -0
  405. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/rabbit.js +192 -0
  406. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/rc4.js +139 -0
  407. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/ripemd160.js +267 -0
  408. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/sha1.js +150 -0
  409. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/sha224.js +80 -0
  410. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/sha256.js +199 -0
  411. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/sha3.js +326 -0
  412. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/sha384.js +83 -0
  413. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/sha512.js +326 -0
  414. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/tripledes.js +779 -0
  415. data/lib/authing_ruby/test/js_sdk_test/node_modules/crypto-js/x64-core.js +304 -0
  416. data/lib/authing_ruby/test/js_sdk_test/node_modules/debug/CHANGELOG.md +395 -0
  417. data/lib/authing_ruby/test/js_sdk_test/node_modules/debug/LICENSE +19 -0
  418. data/lib/authing_ruby/test/js_sdk_test/node_modules/debug/Makefile +58 -0
  419. data/lib/authing_ruby/test/js_sdk_test/node_modules/debug/README.md +368 -0
  420. data/lib/authing_ruby/test/js_sdk_test/node_modules/debug/karma.conf.js +70 -0
  421. data/lib/authing_ruby/test/js_sdk_test/node_modules/debug/node.js +1 -0
  422. data/lib/authing_ruby/test/js_sdk_test/node_modules/debug/package.json +43 -0
  423. data/lib/authing_ruby/test/js_sdk_test/node_modules/debug/src/browser.js +195 -0
  424. data/lib/authing_ruby/test/js_sdk_test/node_modules/debug/src/debug.js +225 -0
  425. data/lib/authing_ruby/test/js_sdk_test/node_modules/debug/src/index.js +10 -0
  426. data/lib/authing_ruby/test/js_sdk_test/node_modules/debug/src/node.js +186 -0
  427. data/lib/authing_ruby/test/js_sdk_test/node_modules/follow-redirects/LICENSE +18 -0
  428. data/lib/authing_ruby/test/js_sdk_test/node_modules/follow-redirects/README.md +148 -0
  429. data/lib/authing_ruby/test/js_sdk_test/node_modules/follow-redirects/debug.js +14 -0
  430. data/lib/authing_ruby/test/js_sdk_test/node_modules/follow-redirects/http.js +1 -0
  431. data/lib/authing_ruby/test/js_sdk_test/node_modules/follow-redirects/https.js +1 -0
  432. data/lib/authing_ruby/test/js_sdk_test/node_modules/follow-redirects/index.js +535 -0
  433. data/lib/authing_ruby/test/js_sdk_test/node_modules/follow-redirects/package.json +59 -0
  434. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/LICENSE.txt +107 -0
  435. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/README.md +192 -0
  436. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/bin/jsencrypt.js +249 -0
  437. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/bin/jsencrypt.min.js +2 -0
  438. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/bin/jsencrypt.min.js.LICENSE.txt +8 -0
  439. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/JSEncrypt.d.ts +116 -0
  440. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/JSEncrypt.js +186 -0
  441. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/JSEncryptRSAKey.d.ts +142 -0
  442. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/JSEncryptRSAKey.js +315 -0
  443. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/index.d.ts +3 -0
  444. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/index.js +3 -0
  445. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/asn1js/asn1.d.ts +51 -0
  446. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/asn1js/asn1.js +565 -0
  447. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/asn1js/base64.d.ts +5 -0
  448. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/asn1js/base64.js +88 -0
  449. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/asn1js/hex.d.ts +3 -0
  450. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/asn1js/hex.js +64 -0
  451. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/asn1js/int10.d.ts +9 -0
  452. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/asn1js/int10.js +87 -0
  453. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/asn1js/oids.d.ts +9778 -0
  454. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/asn1js/oids.js +1962 -0
  455. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/jsbn/base64.d.ts +3 -0
  456. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/jsbn/base64.js +76 -0
  457. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/jsbn/jsbn.d.ts +98 -0
  458. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/jsbn/jsbn.js +1754 -0
  459. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/jsbn/prng4.d.ts +10 -0
  460. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/jsbn/prng4.js +46 -0
  461. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/jsbn/rng.d.ts +3 -0
  462. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/jsbn/rng.js +76 -0
  463. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/jsbn/rsa.d.ts +23 -0
  464. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/jsbn/rsa.js +373 -0
  465. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/jsbn/util.d.ts +7 -0
  466. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/jsbn/util.js +58 -0
  467. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/jsrsasign/asn1-1.0.js +1593 -0
  468. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/lib/jsrsasign/yahoo.js +69 -0
  469. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/lib/version.json +1 -0
  470. data/lib/authing_ruby/test/js_sdk_test/node_modules/jsencrypt/package.json +49 -0
  471. data/lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/Gruntfile.js +78 -0
  472. data/lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/LICENSE +21 -0
  473. data/lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/README.md +55 -0
  474. data/lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/bower.json +20 -0
  475. data/lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/build/jwt-decode.js +125 -0
  476. data/lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/build/jwt-decode.min.js +1 -0
  477. data/lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/jwt-decode.html +2 -0
  478. data/lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/lib/atob.js +38 -0
  479. data/lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/lib/base64_url_decode.js +33 -0
  480. data/lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/lib/index.js +26 -0
  481. data/lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/package.json +37 -0
  482. data/lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/standalone.js +16 -0
  483. data/lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/test/tests.js +53 -0
  484. data/lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/test_harness.html +29 -0
  485. data/lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/testem.yml +46 -0
  486. data/lib/authing_ruby/test/js_sdk_test/node_modules/jwt-decode/testem_dev.yml +1 -0
  487. data/lib/authing_ruby/test/js_sdk_test/node_modules/ms/index.js +152 -0
  488. data/lib/authing_ruby/test/js_sdk_test/node_modules/ms/license.md +21 -0
  489. data/lib/authing_ruby/test/js_sdk_test/node_modules/ms/package.json +37 -0
  490. data/lib/authing_ruby/test/js_sdk_test/node_modules/ms/readme.md +51 -0
  491. data/lib/authing_ruby/test/js_sdk_test/package-lock.json +177 -0
  492. data/lib/authing_ruby/test/js_sdk_test/package.json +15 -0
  493. data/lib/authing_ruby/test/mini_test/TestApplicationsManagementClient.rb +85 -0
  494. data/lib/authing_ruby/test/mini_test/TestAuthenticationClient.rb +232 -0
  495. data/lib/authing_ruby/test/mini_test/TestAuthenticationClientProtocal.rb +238 -0
  496. data/lib/authing_ruby/test/mini_test/TestHttpClient.rb +53 -0
  497. data/lib/authing_ruby/test/mini_test/TestManagementClient.rb +193 -0
  498. data/lib/authing_ruby/test/mini_test/TestManagementTokenProvider.rb +49 -0
  499. data/lib/authing_ruby/test/mini_test/TestNaiveHttpClient.rb +33 -0
  500. data/lib/authing_ruby/test/mini_test/TestSMSandEmail.rb +101 -0
  501. data/lib/authing_ruby/test/mini_test/TestUtils.rb +35 -0
  502. data/lib/authing_ruby/utils/utils.rb +40 -0
  503. data/lib/authing_ruby/version.rb +6 -0
  504. data/lib/authing_ruby.rb +14 -0
  505. metadata +694 -0
@@ -0,0 +1,801 @@
1
+ require_relative './BaseAuthenticationClient.rb'
2
+ require 'jwt'
3
+ require 'uri/query_params'
4
+ require 'digest'
5
+ require "base64"
6
+
7
+ module AuthingRuby
8
+ class AuthenticationClient
9
+ def initialize(options = {})
10
+ @options = options
11
+
12
+ @appId = options.fetch(:appId, nil) # 应用 ID
13
+ @secret = options.fetch(:secret, nil) # 应用密钥
14
+ @appHost = options.fetch(:appHost, nil) # 该应用的域名
15
+ @redirectUri = options.fetch(:redirectUri, nil) # 业务回调地址
16
+ @protocol = options.fetch(:protocol, 'oidc') # 协议类型,可选值为 oidc、oauth、saml、cas
17
+
18
+ # 公钥加密
19
+ @publicKeyManager = AuthingRuby::Common::PublicKeyManager.new(options)
20
+
21
+ # 负责发送 GraphQL (其实就是 http) 请求的工具
22
+ graphqlEndpoint = "#{@appHost}/graphql/v2"
23
+ @graphqlClient = AuthingRuby::Common::GraphqlClient.new(graphqlEndpoint, @options)
24
+
25
+ # tokenProvider 只是存取一下 user 和 token
26
+ @tokenProvider = Authentication::AuthenticationTokenProvider.new()
27
+
28
+ @httpClient = AuthingRuby::Common::HttpClient.new(options, @tokenProvider)
29
+ @naiveHttpClient = AuthingRuby::Common::NaiveHttpClient.new(options, @tokenProvider)
30
+
31
+ # 把 GraphQL 文件夹路径放这里, 这些是私有变量
32
+ @folder_graphql = "./lib/graphql"
33
+ @folder_graphql_mutation = "#{@folder_graphql}/mutations"
34
+ @folder_graphql_query = "#{@folder_graphql}/queries"
35
+
36
+ @baseClient = Authentication::BaseAuthenticationClient.new(options)
37
+
38
+ # 以下几个参数主要用于 "标准协议认证模块"
39
+ @tokenEndPointAuthMethod = options.fetch(:tokenEndPointAuthMethod, 'client_secret_post')
40
+ @introspectionEndPointAuthMethod = options.fetch(:introspectionEndPointAuthMethod, 'client_secret_post')
41
+ @revocationEndPointAuthMethod = options.fetch(:revocationEndPointAuthMethod, 'client_secret_post')
42
+ end
43
+
44
+ # 使用邮箱+密码注册 (完成, 测试通过)
45
+ # 参照: https://docs.authing.cn/v2/reference/sdk-for-node/authentication/AuthenticationClient.html
46
+ # 测试代码:
47
+ # a = AuthingRuby::AuthenticationClient.new({appHost: "https://rails-demo.authing.cn", appId: "60800b9151d040af9016d60b"})
48
+ # a.registerByEmail('301@qq.com', "123456789")
49
+ def registerByEmail(email, password, profile = {}, options = {})
50
+ # 第一步:构建 variables
51
+ publicKey = @publicKeyManager.getPublicKey()
52
+ encryptedPassword = AuthingRuby::Utils.encrypt(password, publicKey)
53
+ variables = {
54
+ "input": {
55
+ "email": email,
56
+ "password": encryptedPassword,
57
+
58
+ "profile": profile,
59
+ "forceLogin": options.fetch(:forceLogin, false),
60
+ "clientIp": options.fetch(:clientIp, nil),
61
+ "context": options.fetch(:context, nil),
62
+ "generateToken": options.fetch(:generateToken, nil),
63
+ }
64
+ }
65
+ graphqlAPI = AuthingRuby::GraphQLAPI.new
66
+ res = graphqlAPI.registerByEmail(@graphqlClient, variables)
67
+ json = JSON.parse(res)
68
+ user = json.dig('data', 'registerByEmail')
69
+ return user if user
70
+ return json
71
+ end
72
+
73
+ # 使用用户名注册
74
+ # https://docs.authing.cn/v2/reference/sdk-for-node/authentication/AuthenticationClient.html#%E4%BD%BF%E7%94%A8%E7%94%A8%E6%88%B7%E5%90%8D%E6%B3%A8%E5%86%8C
75
+ # a = AuthingRuby::AuthenticationClient.new({appHost: "https://rails-demo.authing.cn", appId: "60800b9151d040af9016d60b"})
76
+ # a.registerByUsername('agoodob', "123456789")
77
+ def registerByUsername(username, password, profile = {}, options = {})
78
+ # 第一步:构建 variables
79
+ publicKey = @publicKeyManager.getPublicKey()
80
+ encryptedPassword = AuthingRuby::Utils.encrypt(password, publicKey)
81
+ variables = {
82
+ "input": {
83
+ "username": username,
84
+ "password": encryptedPassword,
85
+
86
+ "profile": profile,
87
+ "forceLogin": options.fetch(:forceLogin, false),
88
+ "clientIp": options.fetch(:clientIp, nil),
89
+ "context": options.fetch(:context, nil),
90
+ "generateToken": options.fetch(:generateToken, nil),
91
+ }
92
+ }
93
+ graphqlAPI = AuthingRuby::GraphQLAPI.new
94
+ res = graphqlAPI.registerByUsername(@graphqlClient, variables)
95
+ json = JSON.parse(res)
96
+ user = json.dig('data', 'registerByUsername')
97
+ return user if user
98
+ return json
99
+ end
100
+
101
+ # 发送短信验证码
102
+ # a = AuthingRuby::AuthenticationClient.new({appHost: "https://rails-demo.authing.cn", appId: "60800b9151d040af9016d60b", userPoolId: "60800b8ee5b66b23128b4980"})
103
+ # a.sendSmsCode("13556136684")
104
+ def sendSmsCode(phone)
105
+ url = "#{@appHost}/api/v2/sms/send"
106
+ graphqlClient = AuthingRuby::Common::GraphqlClient.new(url, @options)
107
+ json = {
108
+ "phone": phone
109
+ }
110
+ response = graphqlClient.request({json: json})
111
+ # {"code":200,"message":"发送成功"}
112
+ return response
113
+ end
114
+
115
+ # 使用手机号注册
116
+ # a = AuthingRuby::AuthenticationClient.new({appHost: "https://rails-demo.authing.cn", appId: "60800b9151d040af9016d60b", userPoolId: "60800b8ee5b66b23128b4980"})
117
+ # a.registerByPhoneCode("13556136684", "6330", "123456")
118
+ def registerByPhoneCode(phone, code, password, profile = {}, options = {})
119
+ # 第一步:构建 variables
120
+ publicKey = @publicKeyManager.getPublicKey()
121
+ encryptedPassword = AuthingRuby::Utils.encrypt(password, publicKey)
122
+ variables = {
123
+ "input": {
124
+ "phone": phone,
125
+ "code": code,
126
+ "password": encryptedPassword,
127
+
128
+ "profile": profile,
129
+ "forceLogin": options.fetch(:forceLogin, false),
130
+ "clientIp": options.fetch(:clientIp, nil),
131
+ "context": options.fetch(:context, nil),
132
+ "generateToken": options.fetch(:generateToken, nil),
133
+ }
134
+ }
135
+ graphqlAPI = AuthingRuby::GraphQLAPI.new
136
+ res = graphqlAPI.registerByPhoneCode(@graphqlClient, variables)
137
+ json = JSON.parse(res)
138
+ user = json.dig('data', 'registerByPhoneCode')
139
+ return user if user
140
+ return json
141
+ end
142
+
143
+ # 使用邮箱登录
144
+ # a = AuthingRuby::AuthenticationClient.new({appHost: "https://rails-demo.authing.cn", appId: "60800b9151d040af9016d60b", userPoolId: "60800b8ee5b66b23128b4980"})
145
+ # a.loginByEmail('301@qq.com', "123456789")
146
+ def loginByEmail(email, password, options = {})
147
+ # 第一步:构建 variables
148
+ publicKey = @publicKeyManager.getPublicKey()
149
+ encryptedPassword = AuthingRuby::Utils.encrypt(password, publicKey)
150
+ variables = {
151
+ "input": {
152
+ "email": email,
153
+ "password": encryptedPassword,
154
+
155
+ "autoRegister": options.fetch(:autoRegister, nil),
156
+ "captchaCode": options.fetch(:captchaCode, nil),
157
+ "clientIp": options.fetch(:clientIp, nil),
158
+ }
159
+ }
160
+ graphqlAPI = AuthingRuby::GraphQLAPI.new
161
+ res = graphqlAPI.loginByEmail(@graphqlClient, variables)
162
+ json = JSON.parse(res)
163
+ user = json.dig('data', 'loginByEmail')
164
+ if user
165
+ setCurrentUser(user);
166
+ return user
167
+ end
168
+ return json
169
+ end
170
+
171
+ # 使用用户名登录
172
+ # a = AuthingRuby::AuthenticationClient.new({appHost: "https://rails-demo.authing.cn", appId: "60800b9151d040af9016d60b"})
173
+ # a.loginByUsername('agoodob', "123456789")
174
+ def loginByUsername(username, password, options = {})
175
+ # 第一步:构建 variables
176
+ publicKey = @publicKeyManager.getPublicKey()
177
+ encryptedPassword = AuthingRuby::Utils.encrypt(password, publicKey)
178
+ variables = {
179
+ "input": {
180
+ "username": username,
181
+ "password": encryptedPassword,
182
+
183
+ "autoRegister": options.fetch(:autoRegister, nil),
184
+ "captchaCode": options.fetch(:captchaCode, nil),
185
+ "clientIp": options.fetch(:clientIp, nil),
186
+ }
187
+ }
188
+ graphqlAPI = AuthingRuby::GraphQLAPI.new
189
+ res = graphqlAPI.loginByUsername(@graphqlClient, variables)
190
+ json = JSON.parse(res)
191
+ user = json.dig('data', 'loginByUsername')
192
+ if user
193
+ setCurrentUser(user);
194
+ return user
195
+ end
196
+ return json
197
+ end
198
+
199
+ # 使用手机号验证码登录
200
+ # a = AuthingRuby::AuthenticationClient.new({appHost: "https://rails-demo.authing.cn", appId: "60800b9151d040af9016d60b"})
201
+ # a.sendSmsCode("13556136684")
202
+ # a.loginByPhoneCode("13556136684", "1347")
203
+ def loginByPhoneCode(phone, code, options = {})
204
+ # 第一步:构建 variables
205
+ variables = {
206
+ "input": {
207
+ "phone": phone,
208
+ "code": code,
209
+ "clientIp": options.fetch(:clientIp, nil),
210
+ }
211
+ }
212
+ graphqlAPI = AuthingRuby::GraphQLAPI.new
213
+ res = graphqlAPI.loginByPhoneCode(@graphqlClient, variables)
214
+ json = JSON.parse(res)
215
+ user = json.dig('data', 'loginByPhoneCode')
216
+ if user
217
+ setCurrentUser(user);
218
+ return user
219
+ end
220
+ return json
221
+ end
222
+
223
+ # 使用手机号密码登录
224
+ # a = AuthingRuby::AuthenticationClient.new({appHost: "https://rails-demo.authing.cn", appId: "60800b9151d040af9016d60b"})
225
+ # a.loginByPhonePassword("13556136684", "123456")
226
+ def loginByPhonePassword(phone, password, options = {})
227
+ # 第一步:构建 variables
228
+ publicKey = @publicKeyManager.getPublicKey()
229
+ encryptedPassword = AuthingRuby::Utils.encrypt(password, publicKey)
230
+ variables = {
231
+ "input": {
232
+ "phone": phone,
233
+ "password": encryptedPassword,
234
+
235
+ "captchaCode": options.fetch(:captchaCode, nil),
236
+ "clientIp": options.fetch(:clientIp, nil),
237
+ }
238
+ }
239
+ graphqlAPI = AuthingRuby::GraphQLAPI.new
240
+ res = graphqlAPI.loginByPhonePassword(@graphqlClient, variables)
241
+ json = JSON.parse(res)
242
+ user = json.dig('data', 'loginByPhonePassword')
243
+ if user
244
+ setCurrentUser(user);
245
+ return user
246
+ end
247
+ return json
248
+ end
249
+
250
+ def checkLoginStatus
251
+ end
252
+
253
+ # 发送邮件
254
+ # a = AuthingRuby::AuthenticationClient.new({appHost: "https://rails-demo.authing.cn", appId: "60800b9151d040af9016d60b"})
255
+ # a.sendEmail('guokrfans@gmail.com', "VERIFY_EMAIL")
256
+ # * @param {EmailScene} scene 发送场景,可选值为 RESET_PASSWORD(发送重置密码邮件,邮件中包含验证码)、VerifyEmail(发送验证邮箱的邮件)、ChangeEmail(发送修改邮箱邮件,邮件中包含验证码)
257
+ def sendEmail(email, scene)
258
+ variables = {
259
+ "email": email,
260
+ "scene": scene,
261
+ }
262
+ graphqlAPI = AuthingRuby::GraphQLAPI.new
263
+ res = graphqlAPI.sendEmail(@graphqlClient, variables)
264
+ json = JSON.parse(res)
265
+ data = json.dig('data')
266
+ return data if data
267
+ return json
268
+ # {"sendEmail":{"message":"","code":200}}
269
+ end
270
+
271
+ # 获取当前登录的用户信息
272
+ # 返回:用户信息
273
+ def getCurrentUser()
274
+ graphqlAPI = AuthingRuby::GraphQLAPI.new
275
+ res = graphqlAPI.getCurrentUser(@graphqlClient, @tokenProvider, variables)
276
+ json = JSON.parse(res)
277
+ user = json.dig("data", "user")
278
+ if user
279
+ setCurrentUser(user)
280
+ return user
281
+ else
282
+ return json
283
+ end
284
+ end
285
+
286
+ def setCurrentUser(user)
287
+ @tokenProvider.setUser(user);
288
+ end
289
+
290
+ def setToken(token)
291
+ @tokenProvider.setToken(token);
292
+ end
293
+
294
+ # 退出登录
295
+ def logout()
296
+ url = "#{@appHost}/api/v2/logout?app_id=#{@appId}"
297
+ @httpClient.request({
298
+ method: 'GET',
299
+ url: url,
300
+ });
301
+ @tokenProvider.clearUser();
302
+ end
303
+
304
+ # 私有函数,用于 buildAuthorizeUrl 处理 OIDC 协议
305
+ # 写法是完全参照的 JS SDK
306
+ def _buildOidcAuthorizeUrl(options = {})
307
+ # 名字的映射
308
+ map = {
309
+ appId: 'client_id',
310
+ scope: 'scope',
311
+ state: 'state',
312
+ nonce: 'nonce',
313
+ responseMode: 'response_mode',
314
+ responseType: 'response_type',
315
+ redirectUri: 'redirect_uri',
316
+ codeChallenge: 'code_challenge',
317
+ codeChallengeMethod: 'code_challenge_method'
318
+ };
319
+ # 用来构造 url
320
+ res = {
321
+ nonce: AuthingRuby::Utils.randomNumberString(16),
322
+ state: AuthingRuby::Utils.randomNumberString(16),
323
+ scope: 'openid profile email phone address',
324
+ client_id: @appId,
325
+ redirect_uri: @redirectUri,
326
+ response_type: 'code',
327
+ };
328
+
329
+ map.each do |key, value|
330
+ if options[key.to_sym]
331
+ # 如果 scope 的值里有 offline_access
332
+ if value == 'scope' && options.fetch(:scope, []).split(' ').include?("offline_access")
333
+ res[:prompt] = 'consent'
334
+ end
335
+ res[value.to_sym] = options[key]
336
+ end
337
+ end
338
+
339
+ authorizeUrl = @baseClient.appHost + '/oidc/auth?' + URI::QueryParams.dump(res)
340
+ return authorizeUrl
341
+ end
342
+
343
+ # TODO
344
+ # 生成 OIDC 协议的用户登录链接
345
+ # 文档: https://docs.authing.cn/v2/reference/sdk-for-node/authentication/StandardProtocol.html#%E7%94%9F%E6%88%90-oidc-%E5%8D%8F%E8%AE%AE%E7%9A%84%E7%94%A8%E6%88%B7%E7%99%BB%E5%BD%95%E9%93%BE%E6%8E%A5
346
+ # 代码: https://github.com/Authing/authing.js/blob/cf4757d09de3b44c3c3f4509ae8c8715c9f302a2/src/lib/authentication/AuthenticationClient.ts#L2098
347
+ def buildAuthorizeUrl(options = {})
348
+ unless @appHost
349
+ raise '请在初始化 AuthenticationClient 时传入应用域名 appHost 参数,形如:https://app1.authing.cn'
350
+ end
351
+ protocol = @options.fetch(:protocol, nil)
352
+ if protocol == 'oidc'
353
+ return _buildOidcAuthorizeUrl(options);
354
+ end
355
+ if protocol == 'oauth'
356
+ throw "oauth 协议暂未实现"
357
+ end
358
+ if protocol == 'saml'
359
+ throw "saml 协议暂未实现"
360
+ end
361
+ if protocol == 'cas'
362
+ throw "cas 协议暂未实现"
363
+ end
364
+ raise '不支持的协议类型,请在初始化 AuthenticationClient 时传入 protocol 参数,可选值为 oidc、oauth、saml、cas'
365
+ end
366
+
367
+ # 逻辑参照 JS SDK
368
+ # 目的: 把 params 这个 hash 里 value 为空的值全部删掉
369
+ # 最后返回一个 url params 字符串
370
+ def _generateTokenRequest(params)
371
+ ret = {}
372
+ params.each do |key, value|
373
+ if value
374
+ ret[key] = value
375
+ end
376
+ end
377
+ return URI::QueryParams.dump(ret)
378
+ end
379
+
380
+ def _getAccessTokenByCodeWithClientSecretPost(code, options = {})
381
+ codeVerifier = options.fetch(:codeVerifier, nil)
382
+ qstr = _generateTokenRequest({
383
+ client_id: @appId,
384
+ client_secret: @secret,
385
+ grant_type: 'authorization_code',
386
+ code: code,
387
+ redirect_uri: @redirectUri,
388
+ code_verifier: codeVerifier,
389
+ })
390
+
391
+ api = ''
392
+ if @protocol == 'oidc'
393
+ api = "#{@baseClient.appHost}/oidc/token"
394
+ elsif @protocol == 'oauth'
395
+ api = "#{@baseClient.appHost}/oauth/token"
396
+ end
397
+ tokenSet = @naiveHttpClient.request({
398
+ method: 'POST',
399
+ url: api,
400
+ data: qstr,
401
+ headers: {
402
+ 'Content-Type': 'application/x-www-form-urlencoded'
403
+ }
404
+ })
405
+ return tokenSet
406
+ end
407
+
408
+ # Code 换 Token
409
+ # 使用授权码 Code 获取用户的 Token 信息。
410
+ # res = a.getAccessTokenByCode('授权码 code');
411
+ # 参照: https://github.com/Authing/authing.js/blob/cf4757d09de3b44c3c3f4509ae8c8715c9f302a2/src/lib/authentication/AuthenticationClient.ts#L1977
412
+ def getAccessTokenByCode(code, options = {})
413
+ # 检查参数合法性
414
+ if ['oauth', 'oidc'].include?(@protocol) == false
415
+ raise '初始化 AuthenticationClient 时传入的 protocol 参数必须为 oauth 或 oidc,请检查参数'
416
+ end
417
+ if !@secret && @tokenEndPointAuthMethod != nil
418
+ raise '请在初始化 AuthenticationClient 时传入 appId 和 secret 参数'
419
+ end
420
+
421
+ if @tokenEndPointAuthMethod == 'client_secret_post'
422
+ return _getAccessTokenByCodeWithClientSecretPost(code, options)
423
+ end
424
+
425
+ if @tokenEndPointAuthMethod == 'client_secret_basic'
426
+ # TODO
427
+ raise "client_secret_basic 还未实现"
428
+ # return _getAccessTokenByCodeWithClientSecretBasic(code, options.fetch(:codeVerifier, nil))
429
+ end
430
+
431
+ if @tokenEndPointAuthMethod == nil
432
+ # TODO
433
+ raise "还未实现"
434
+ # return _getAccessTokenByCodeWithNone(code, options.fetch(:codeVerifier, nil))
435
+ end
436
+ end
437
+
438
+ # Token 换用户信息
439
+ # 文档: https://docs.authing.cn/v2/reference/sdk-for-node/authentication/StandardProtocol.html#token-%E6%8D%A2%E7%94%A8%E6%88%B7%E4%BF%A1%E6%81%AF
440
+ # 参考: https://github.com/Authing/authing.js/blob/cf4757d09de3b44c3c3f4509ae8c8715c9f302a2/src/lib/authentication/AuthenticationClient.ts#L2082
441
+ def getUserInfoByAccessToken(access_token)
442
+ api = nil;
443
+ if @protocol == 'oidc'
444
+ api = "#{@appHost}/oidc/me";
445
+ elsif @protocol == 'oauth'
446
+ api = "#{@appHost}/oauth/me";
447
+ end
448
+
449
+ userInfo = @naiveHttpClient.request({
450
+ method: 'POST',
451
+ url: api,
452
+ headers: {
453
+ Authorization: 'Bearer ' + access_token
454
+ }
455
+ });
456
+ return userInfo
457
+ end
458
+
459
+ def _getNewAccessTokenByRefreshTokenWithClientSecretPost(refreshToken)
460
+ qstr = _generateTokenRequest({
461
+ client_id: @appId,
462
+ client_secret: @secret,
463
+ grant_type: 'refresh_token',
464
+ refresh_token: refreshToken
465
+ });
466
+
467
+ api = ''
468
+ if @protocol == 'oidc'
469
+ api = "#{@baseClient.appHost}/oidc/token"
470
+ elsif @protocol == 'oauth'
471
+ api = "#{@baseClient.appHost}/oauth/token"
472
+ end
473
+
474
+ tokenSet = @naiveHttpClient.request({
475
+ method: 'POST',
476
+ url: api,
477
+ data: qstr,
478
+ headers: {
479
+ 'Content-Type': 'application/x-www-form-urlencoded'
480
+ }
481
+ });
482
+ return tokenSet;
483
+ end
484
+
485
+ # TODO
486
+ # 刷新 Access Token
487
+ # 使用 Refresh token 获取新的 Access token。
488
+ # 代码参考: https://github.com/Authing/authing.js/blob/cf4757d09de3b44c3c3f4509ae8c8715c9f302a2/src/lib/authentication/AuthenticationClient.ts#L2296
489
+ def getNewAccessTokenByRefreshToken(refreshToken)
490
+ # 检查参数合法性
491
+ if ['oauth', 'oidc'].include?(@protocol) == false
492
+ raise '初始化 AuthenticationClient 时传入的 protocol 参数必须为 oauth 或 oidc,请检查参数'
493
+ end
494
+ if !@secret && @tokenEndPointAuthMethod != nil
495
+ raise '请在初始化 AuthenticationClient 时传入 appId 和 secret 参数'
496
+ end
497
+
498
+ if @tokenEndPointAuthMethod == 'client_secret_post'
499
+ return _getNewAccessTokenByRefreshTokenWithClientSecretPost(
500
+ refreshToken
501
+ );
502
+ end
503
+ if @tokenEndPointAuthMethod == 'client_secret_basic'
504
+ # return await this._getNewAccessTokenByRefreshTokenWithClientSecretBasic(
505
+ # refreshToken
506
+ # );
507
+ end
508
+ if @tokenEndPointAuthMethod == 'none'
509
+ # return await this._getNewAccessTokenByRefreshTokenWithNone(refreshToken);
510
+ end
511
+ end
512
+
513
+ def _introspectTokenWithClientSecretPost(token)
514
+ qstr = _generateTokenRequest({
515
+ client_id: @appId,
516
+ client_secret: @secret,
517
+ token: token,
518
+ })
519
+ api = ''
520
+ if @protocol == 'oidc'
521
+ api = "#{@baseClient.appHost}/oidc/token/introspection"
522
+ elsif @protocol == 'oauth'
523
+ api = "#{@baseClient.appHost}/oauth/token/introspection"
524
+ end
525
+ tokenSet = @naiveHttpClient.request({
526
+ method: 'POST',
527
+ url: api,
528
+ data: qstr,
529
+ headers: {
530
+ 'Content-Type': 'application/x-www-form-urlencoded'
531
+ }
532
+ });
533
+ return tokenSet;
534
+ end
535
+
536
+ # TODO
537
+ # 检查 Access Token 或 Refresh token 的状态
538
+ # 文档: https://docs.authing.cn/v2/reference/sdk-for-node/authentication/StandardProtocol.html#%E6%A3%80%E6%9F%A5-access-token
539
+ # 代码参考: https://github.com/Authing/authing.js/blob/cf4757d09de3b44c3c3f4509ae8c8715c9f302a2/src/lib/authentication/AuthenticationClient.ts#L2479
540
+ def introspectToken(token)
541
+ # 检查参数合法性
542
+ if ['oauth', 'oidc'].include?(@protocol) == false
543
+ raise '初始化 AuthenticationClient 时传入的 protocol 参数必须为 oauth 或 oidc,请检查参数'
544
+ end
545
+ if !@secret && @tokenEndPointAuthMethod != nil
546
+ raise '请在初始化 AuthenticationClient 时传入 appId 和 secret 参数'
547
+ end
548
+
549
+ if @introspectionEndPointAuthMethod == 'client_secret_post'
550
+ return _introspectTokenWithClientSecretPost(token)
551
+ end
552
+ if @introspectionEndPointAuthMethod == 'client_secret_basic'
553
+ # return await this._introspectTokenWithClientSecretBasic(token);
554
+ end
555
+ if @introspectionEndPointAuthMethod == 'none'
556
+ # return await this._introspectTokenWithNone(token);
557
+ end
558
+ raise '初始化 AuthenticationClient 时传入的 introspectionEndPointAuthMethod 参数可选值为 client_secret_base、client_secret_post、none,请检查参数'
559
+ end
560
+
561
+ # TODO
562
+ # 检验 Id Token 合法性
563
+ # 通过 Authing 提供的在线接口验证 Id token 或 Access token。会产生网络请求。
564
+ # 文档: https://docs.authing.cn/v2/reference/sdk-for-node/authentication/StandardProtocol.html#%E6%A3%80%E9%AA%8C-id-token-%E5%90%88%E6%B3%95%E6%80%A7
565
+ # 代码参考: https://github.com/Authing/authing.js/blob/cf4757d09de3b44c3c3f4509ae8c8715c9f302a2/src/lib/authentication/AuthenticationClient.ts#L2582
566
+ def validateToken(options = {})
567
+ if options.empty?
568
+ raise '请在传入的参数对象中包含 accessToken 或 idToken 字段'
569
+ end
570
+
571
+ accessToken = options.fetch(:accessToken, nil)
572
+ idToken = options.fetch(:idToken, nil)
573
+
574
+ if accessToken != nil && idToken != nil
575
+ raise "accessToken 和 idToken 只能传入一个,不能同时传入"
576
+ end
577
+
578
+ if idToken
579
+ data = @naiveHttpClient.request({
580
+ url: "#{@baseClient.appHost}/api/v2/oidc/validate_token",
581
+ method: 'GET',
582
+ params: {
583
+ id_token: idToken
584
+ }
585
+ })
586
+ return data
587
+ elsif accessToken
588
+ data = @naiveHttpClient.request({
589
+ url: "#{@baseClient.appHost}/api/v2/oidc/validate_token",
590
+ method: 'GET',
591
+ params: {
592
+ access_token: accessToken
593
+ }
594
+ });
595
+ return data
596
+ end
597
+ end
598
+
599
+ # 修改用户资料
600
+ def updateProfile(updates = {})
601
+ userId = checkLoggedIn()
602
+ graphqlAPI = AuthingRuby::GraphQLAPI.new
603
+ variables = {
604
+ "id": userId,
605
+ "input": updates
606
+ }
607
+ res = graphqlAPI.updateUser(@graphqlClient, @tokenProvider, variables)
608
+ json = JSON.parse(res)
609
+ updated_user = json.dig('data', 'updateUser')
610
+ if updated_user
611
+ # 如果更新成功,返回更新后的用户
612
+ setCurrentUser(updated_user)
613
+ return updated_user
614
+ else
615
+ # 如果更新失败,返回原结果
616
+ # {"errors"=>[{"message"=>{"code"=>2020, "message"=>"尚未登录,无访问权限"}, "locations"=>[{"line"=>2, "column"=>3}], "path"=>["updateUser"], "extensions"=>{"code"=>"INTERNAL_SERVER_ERROR"}}], "data"=>nil}
617
+ return json
618
+ end
619
+ end
620
+
621
+ # checkLoggedIn 解释:
622
+ # 如果登录了,会返回唯一 id (userId)
623
+ # 如果没登录,会抛出错误
624
+ def checkLoggedIn()
625
+ # 有 user 就直接返回 id
626
+ user = @tokenProvider.getUser()
627
+ if user
628
+ return user.fetch("id", nil) # 608966b08b4af522620d2e59
629
+ end
630
+
631
+ # 尝试获取 token
632
+ token = @tokenProvider.getToken()
633
+ if !token
634
+ raise '请先登录!' # 例子: 如果 logout 了再次调用 checkLoggedIn 会报错,就是这里报错
635
+ end
636
+
637
+ # 解码 token
638
+ decoded_token_array = JWT.decode token, nil, false
639
+ payload = decoded_token_array[0]
640
+
641
+ # 从 token 中获取 user_id 并返回
642
+ userId = nil
643
+ authing_sub = payload.fetch("sub", nil)
644
+ id = payload.dig("data", "id")
645
+
646
+ if authing_sub
647
+ userId = authing_sub
648
+ else
649
+ userId = id
650
+ end
651
+
652
+ return userId
653
+ end
654
+
655
+ # 检查密码强度
656
+ def checkPasswordStrength(password)
657
+ graphqlAPI = AuthingRuby::GraphQLAPI.new
658
+ variables = { "password": password }
659
+ res = graphqlAPI.checkPasswordStrength(@graphqlClient, @tokenProvider, variables)
660
+ json = JSON.parse(res)
661
+ return json.dig("data", "checkPasswordStrength")
662
+ end
663
+
664
+ # 检测 Token 登录状态
665
+ def checkLoginStatus(token)
666
+ graphqlAPI = AuthingRuby::GraphQLAPI.new
667
+ variables = { "token": token }
668
+ res = graphqlAPI.checkLoginStatus(@graphqlClient, @tokenProvider, variables)
669
+ json = JSON.parse(res)
670
+ return json.dig("data", "checkLoginStatus")
671
+ end
672
+
673
+ # 更新用户密码
674
+ def updatePassword(newPassword, oldPassword)
675
+ publicKey = @publicKeyManager.getPublicKey()
676
+ newPasswordEncrypted = AuthingRuby::Utils.encrypt(newPassword, publicKey)
677
+ oldPasswordEncrypted = AuthingRuby::Utils.encrypt(oldPassword, publicKey)
678
+ variables = {
679
+ "newPassword": newPasswordEncrypted,
680
+ "oldPassword": oldPasswordEncrypted,
681
+ }
682
+ graphqlAPI = AuthingRuby::GraphQLAPI.new
683
+ res = graphqlAPI.updatePassword(@graphqlClient, @tokenProvider, variables)
684
+ json = JSON.parse(res)
685
+ return json.dig("data", "updatePassword")
686
+ end
687
+
688
+ # 绑定手机号
689
+ # 用户初次绑定手机号,如果需要修改手机号请使用 updatePhone 方法。如果该手机号已被绑定,将会绑定失败。发送验证码请使用 sendSmsCode 方法。
690
+ def bindPhone(phone, phoneCode)
691
+ graphqlAPI = AuthingRuby::GraphQLAPI.new
692
+ variables = {
693
+ "phone": phone,
694
+ "phoneCode": phoneCode,
695
+ }
696
+ res = graphqlAPI.bindPhone(@graphqlClient, @tokenProvider, variables)
697
+ json = JSON.parse(res)
698
+ user = json.dig("data", "bindPhone")
699
+ if user
700
+ setCurrentUser(user);
701
+ return user;
702
+ else
703
+ return json
704
+ end
705
+ end
706
+
707
+ # 通过短信验证码重置密码
708
+ def resetPasswordByPhoneCode(phone, code, newPassword)
709
+ publicKey = @publicKeyManager.getPublicKey()
710
+ newPasswordEncrypted = AuthingRuby::Utils.encrypt(newPassword, publicKey)
711
+
712
+ variables = {
713
+ "phone": phone,
714
+ "code": code,
715
+ "newPassword": newPasswordEncrypted,
716
+ }
717
+ graphqlAPI = AuthingRuby::GraphQLAPI.new
718
+ resp = graphqlAPI.resetPassword(@graphqlClient, @tokenProvider, variables)
719
+ json = JSON.parse(resp)
720
+ result = json.dig("data", "resetPassword") # {"message":"重置密码成功!","code":200}
721
+ return result if result
722
+ return json
723
+ end
724
+
725
+ def generateCodeChallenge()
726
+ return AuthingRuby::Utils.generateRandomString(43);
727
+ end
728
+
729
+ # 照搬 JS SDK 的逻辑
730
+ def getCodeChallengeDigest(options = {})
731
+ if options.empty?
732
+ raise '请提供 options 参数,options.codeChallenge 为一个长度大于等于 43 的字符串,options.method 可选值为 S256、plain'
733
+ end
734
+ codeChallenge = options.fetch(:codeChallenge, nil)
735
+ method = options.fetch(:method, 'S256')
736
+
737
+ if codeChallenge == nil
738
+ raise '请提供 options.codeChallenge,值为一个长度大于等于 43 的字符串'
739
+ end
740
+
741
+ if method == 'S256'
742
+ base64 = Digest::SHA256.base64digest codeChallenge
743
+ result = base64.gsub(/\+/, '-').gsub(/\//, '-').gsub(/=/, '')
744
+ return result
745
+ end
746
+ if method == 'plain'
747
+ return options.codeChallenge;
748
+ end
749
+ raise '不支持的 options.method,可选值为 S256、plain'
750
+ end
751
+
752
+ def _revokeTokenWithClientSecretPost(token)
753
+ qstr = _generateTokenRequest({
754
+ client_id: @appId,
755
+ client_secret: @secret,
756
+ token: token,
757
+ });
758
+ api = '';
759
+ if @protocol === 'oidc'
760
+ api = "#{@baseClient.appHost}/oidc/token/revocation";
761
+ elsif @protocol === 'oauth'
762
+ api = "#{@baseClient.appHost}/oauth/token/revocation";
763
+ end
764
+ tokenSet = @naiveHttpClient.request({
765
+ method: 'POST',
766
+ url: api,
767
+ data: qstr,
768
+ headers: {
769
+ 'Content-Type': 'application/x-www-form-urlencoded'
770
+ }
771
+ });
772
+ return tokenSet;
773
+ end
774
+
775
+ # 撤回 Access Token 或 Refresh token
776
+ def revokeToken(token)
777
+ # 检查参数合法性
778
+ if ['oauth', 'oidc'].include?(@protocol) == false
779
+ raise '初始化 AuthenticationClient 时传入的 protocol 参数必须为 oauth 或 oidc,请检查参数'
780
+ end
781
+ if !@secret && @tokenEndPointAuthMethod != nil
782
+ raise '请在初始化 AuthenticationClient 时传入 appId 和 secret 参数'
783
+ end
784
+
785
+ if @revocationEndPointAuthMethod == 'client_secret_post'
786
+ _revokeTokenWithClientSecretPost(token) # 实测这个请求啥也不返回, 空的, 所以把这个直接 return 返回没啥用
787
+ return true;
788
+ end
789
+ if @revocationEndPointAuthMethod == 'client_secret_basic'
790
+ # await this._revokeTokenWithClientSecretBasic(token);
791
+ # return true;
792
+ end
793
+ if @revocationEndPointAuthMethod == 'none'
794
+ # await this._revokeTokenWithNone(token);
795
+ # return true;
796
+ end
797
+ raise '初始化 AuthenticationClient 时传入的 revocationEndPointAuthMethod 参数可选值为 client_secret_base、client_secret_post、none,请检查参数'
798
+ end
799
+
800
+ end
801
+ end