@cloudbase/oauth 1.0.0-alpha.4 → 1.2.0-beta

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.
Files changed (102) hide show
  1. package/app/index.d.ts +29 -0
  2. package/app/index.js +50 -0
  3. package/app/index.js.map +1 -0
  4. package/app/internal.d.ts +12 -0
  5. package/app/internal.js +25 -0
  6. package/app/internal.js.map +1 -0
  7. package/app/openuri.d.ts +20 -0
  8. package/app/openuri.js +106 -0
  9. package/app/openuri.js.map +1 -0
  10. package/app/request.d.ts +19 -0
  11. package/app/request.js +52 -0
  12. package/app/request.js.map +1 -0
  13. package/app/storage.d.ts +41 -0
  14. package/app/storage.js +35 -0
  15. package/app/storage.js.map +1 -0
  16. package/{dist/auth → auth}/consts.d.ts +21 -9
  17. package/auth/consts.js +79 -0
  18. package/auth/consts.js.map +1 -0
  19. package/auth/index.d.ts +242 -0
  20. package/auth/index.js +550 -0
  21. package/auth/index.js.map +1 -0
  22. package/auth/models.d.ts +284 -0
  23. package/auth/models.js +4 -0
  24. package/auth/models.js.map +1 -0
  25. package/captcha/index.d.ts +45 -0
  26. package/captcha/index.js +135 -0
  27. package/captcha/index.js.map +1 -0
  28. package/function/index.d.ts +38 -0
  29. package/function/index.js +80 -0
  30. package/function/index.js.map +1 -0
  31. package/index.d.ts +8 -0
  32. package/index.js +17 -0
  33. package/index.js.map +1 -0
  34. package/{dist/oauth2client → oauthclient}/consts.d.ts +1 -22
  35. package/oauthclient/consts.js +53 -0
  36. package/oauthclient/consts.js.map +1 -0
  37. package/oauthclient/index.d.ts +18 -0
  38. package/oauthclient/index.js +21 -0
  39. package/oauthclient/index.js.map +1 -0
  40. package/oauthclient/interface.d.ts +29 -0
  41. package/oauthclient/interface.js +10 -0
  42. package/oauthclient/interface.js.map +1 -0
  43. package/oauthclient/models.d.ts +40 -0
  44. package/oauthclient/models.js +3 -0
  45. package/oauthclient/models.js.map +1 -0
  46. package/oauthclient/oauthclient.d.ts +146 -0
  47. package/oauthclient/oauthclient.js +414 -0
  48. package/oauthclient/oauthclient.js.map +1 -0
  49. package/package.json +14 -26
  50. package/utils/promise.d.ts +18 -0
  51. package/utils/promise.js +48 -0
  52. package/utils/promise.js.map +1 -0
  53. package/utils/uuid.d.ts +5 -0
  54. package/utils/uuid.js +16 -0
  55. package/utils/uuid.js.map +1 -0
  56. package/.eslintignore +0 -2
  57. package/.eslintrc +0 -26
  58. package/CHANGELOG.md +0 -30
  59. package/Dockerfile +0 -15
  60. package/README.md +0 -183
  61. package/_exmaple/assets/scripts/function/function.ts +0 -99
  62. package/_exmaple/assets/scripts/index.ts +0 -101
  63. package/_exmaple/assets/scripts/request.ts +0 -11
  64. package/_exmaple/index.html +0 -15
  65. package/_exmaple/package.json +0 -33
  66. package/_exmaple/tsconfig.json +0 -71
  67. package/_exmaple/typings.d.ts +0 -0
  68. package/_exmaple/webpack.config.js +0 -42
  69. package/dist/auth/apis.d.ts +0 -55
  70. package/dist/auth/apis.js +0 -572
  71. package/dist/auth/consts.js +0 -61
  72. package/dist/auth/models.d.ts +0 -355
  73. package/dist/auth/models.js +0 -3
  74. package/dist/captcha/captcha.d.ts +0 -35
  75. package/dist/captcha/captcha.js +0 -267
  76. package/dist/index.d.ts +0 -14
  77. package/dist/index.js +0 -63
  78. package/dist/oauth2client/consts.js +0 -73
  79. package/dist/oauth2client/interface.d.ts +0 -15
  80. package/dist/oauth2client/interface.js +0 -10
  81. package/dist/oauth2client/models.d.ts +0 -47
  82. package/dist/oauth2client/models.js +0 -3
  83. package/dist/oauth2client/oauth2client.d.ts +0 -71
  84. package/dist/oauth2client/oauth2client.js +0 -634
  85. package/dist/utils/function/single-promise.d.ts +0 -5
  86. package/dist/utils/function/single-promise.js +0 -89
  87. package/dist/utils/uuid.d.ts +0 -1
  88. package/dist/utils/uuid.js +0 -12
  89. package/publish.sh +0 -2
  90. package/src/auth/apis.ts +0 -646
  91. package/src/auth/consts.ts +0 -57
  92. package/src/auth/models.ts +0 -445
  93. package/src/captcha/captcha.ts +0 -222
  94. package/src/index.ts +0 -49
  95. package/src/oauth2client/consts.ts +0 -69
  96. package/src/oauth2client/interface.ts +0 -57
  97. package/src/oauth2client/models.ts +0 -61
  98. package/src/oauth2client/oauth2client.ts +0 -615
  99. package/src/utils/function/single-promise.ts +0 -40
  100. package/src/utils/uuid.ts +0 -11
  101. package/tsconfig.json +0 -44
  102. package/wiki/README.md +0 -75
package/README.md DELETED
@@ -1,183 +0,0 @@
1
- # Oauth
2
-
3
- 提供 oauth2 的登录相关功能。
4
-
5
- ## 主要模块
6
-
7
- OAuth2Client oauth2 基础模块
8
-
9
- Auth 登录相关模块
10
-
11
- ## 使用示例
12
-
13
- ### 初始化对象
14
-
15
- ```typescript
16
- const authOptions = {
17
- apiOrigin: "服务域名",
18
- clientId: "客户端ID"
19
- }
20
- const auth = new Auth(authOptions)
21
- ```
22
-
23
- ```typescript
24
- import { initializeClient } from "@xbasesdk/xbase"
25
- const config = {
26
- env: "xbase-4gh5dh6nf62145a9"
27
- }
28
- const client = initializeClient(config)
29
- // 调用API
30
- const loginState = await client.auth.hasLoginState()
31
- // 获取 accessToken
32
- const accessToken = await client.oAuth2Client.getAccessToken()
33
-
34
- // 用 OIDC Token 用自己的API
35
- export interface ExampleData {
36
- result?: string
37
- }
38
- const data = await client.oAuth2Client.request<ExampleData>(
39
- "https://example.com",
40
- { withCredentials: true }
41
- )
42
- console.log(data.result)
43
-
44
-
45
-
46
- import {initializeApp} from '@clodbasesdk/oauth/app';
47
- import {getAuth} from '@clodbasesdk/oauth/auth';
48
- export const config = {
49
- env: 'env-4gh5dh6nf62145a9'
50
- };
51
- const app = initializeApp(config)
52
- const auth = getAuth(app)
53
- // 调用API
54
- const loginState = await auth.hasLoginState()
55
- ```
56
-
57
- ### 账号登录
58
-
59
- ```typescript
60
- auth.signIn({
61
- username: "test",
62
- password: "test"
63
- })
64
- ```
65
-
66
- ### 手机验证码登录/注册
67
-
68
- ```typescript
69
- const phoneNumber = "10012341234"
70
- // 短信验证码
71
- const verificationCode = "******"
72
- const verification = await auth.getVerification({
73
- phone_number: "+86 " + phoneNumber,
74
- target: "ANY"
75
- })
76
-
77
- let verifyResult = await auth.verify({
78
- verification_code: verificationCode,
79
- verification_id: verification ? verification.verification_id : ""
80
- })
81
- let isUser = verification ? verification.is_user : false
82
-
83
- let result
84
- if (isUser) {
85
- result = await auth.signIn({
86
- username: "+86 " + phoneNumber,
87
- verification_code: verificationCode,
88
- verification_token: verifyResult.verification_token
89
- })
90
- } else {
91
- result = await auth.signUp({
92
- phone_number: "+86 " + phoneNumber,
93
- password: "*******",
94
- verification_code: verificationCode,
95
- verification_token: verifyResult.verification_token,
96
- local: "zh-cn",
97
- name: "100****1234"
98
- })
99
- }
100
- ```
101
-
102
- ### 错误处理
103
-
104
- ```typescript
105
- try {
106
- await auth.verify({
107
- verification_code: verificationCode,
108
- verification_id: verification ? verification.verification_id : ""
109
- })
110
- } catch (error) {
111
- if (error && error.error_uri === "/v1/auth/verification/verify") {
112
- switch (error.error) {
113
- case "not_found": {
114
- result = i18n.translate("error", "User Not Found")
115
- break
116
- }
117
- case "invalid_password": {
118
- if (error.details !== undefined && error.details.length > 0) {
119
- result =
120
- i18n.translate("error", "Certification failed, you still have") +
121
- error.details[0].limit_remaining +
122
- i18n.translate("error", "chances. You can also") +
123
- "" +
124
- i18n.translate("error", "Reset Login Password") +
125
- "</a>"
126
- } else {
127
- result = i18n.translate("error", "Password does not match")
128
- }
129
- break
130
- }
131
- case "user_pending": {
132
- result = i18n.translate("error", "The account is not activated")
133
- break
134
- }
135
- case "user_blocked": {
136
- result = i18n.translate("error", "Account has been disabled")
137
- break
138
- }
139
- case "invalid_status": {
140
- if (error.details !== undefined && error.details.length > 0) {
141
- let s = error.details[0].retry_delay
142
- s = s.substring(0, s.length - 1)
143
- s = parseInt(s)
144
- result =
145
- i18n.translate(
146
- "error",
147
- "The password input error has reached the upper limit and the account will be locked "
148
- ) +
149
- (s < 3600
150
- ? s / 60 + i18n.translate("error", "minute")
151
- : s / 3600 + i18n.translate("error", "hour"))
152
- } else {
153
- result = i18n.translate(
154
- "error",
155
- "Account has been temporarily locked"
156
- )
157
- }
158
- break
159
- }
160
- case "invalid_two_factor": {
161
- result = i18n.translate(
162
- "error",
163
- "Secondary authentication code does not match or has expired"
164
- )
165
- break
166
- }
167
- case "invalid_two_factor_recovery": {
168
- result = i18n.translate(
169
- "error",
170
- "Recovery code does not match or has expired"
171
- )
172
- break
173
- }
174
- default: {
175
- result = i18n.translate("error", "unknown")
176
- break
177
- }
178
- }
179
- }
180
- }
181
- ```
182
-
183
- ## [更新日志](./CHANGELOG.md)
@@ -1,99 +0,0 @@
1
- import { App } from "@xbasesdk/xbase/app";
2
- import { getOAuthClient, AuthClient, ErrorType } from "@xbasesdk/xbase/oauthclient";
3
- import { uuidv4 } from "@xbasesdk/xbase/utils/uuid";
4
-
5
- export interface FunctionOptions {
6
- credentialsClient: AuthClient;
7
- env: string
8
- }
9
-
10
- /**
11
- * Returns the existing `Auth` instance that is associated with the app
12
- */
13
- export function getFunction(app: App): Function {
14
- const credentialsClient = getOAuthClient(app)
15
- return new Function({
16
- credentialsClient: credentialsClient,
17
- env: app.options.clientId
18
- })
19
- }
20
-
21
-
22
- export class Function {
23
-
24
- private _config: FunctionOptions;
25
-
26
- /**
27
- * constructor
28
- * @param {AuthOptions} opts
29
- */
30
- constructor(opts: FunctionOptions) {
31
- this._config = {
32
- credentialsClient: opts.credentialsClient,
33
- env: opts.env,
34
- }
35
- }
36
- /**
37
- * callFunction call function
38
- * @param {SignInRequest} params A SignInRequest Object.
39
- * @return {Promise<Credentials>} A Promise<Credentials> object.
40
- */
41
- public async callFunction(params: FunctionRequest): Promise<FunctionResponse> {
42
- let accessToken: string
43
- try {
44
- accessToken = await this._config.credentialsClient.getAccessToken()
45
- } catch (e) {
46
- if (e.error === ErrorType.UNAUTHENTICATED) {
47
- accessToken = ""
48
- } else {
49
- return Promise.reject(e)
50
- }
51
- }
52
- const requestId = uuidv4()
53
- var reqBody = {
54
- "action": "functions.invokeFunction",
55
- "dataVersion": "2020-01-10",
56
- "env": this._config.env,
57
- "function_name": params.name,
58
- "request_data": JSON.stringify(params.data),
59
- "seqId": requestId,
60
- "access_token": accessToken
61
- }
62
- const url = "/web?env=" + this._config.env
63
- const resp = await this._config.credentialsClient.request<functionHTTPResponse>(url, {
64
- method: 'POST',
65
- body: reqBody,
66
- headers: {
67
- 'content-type': 'application/json'
68
- }
69
- })
70
- if (resp.code) {
71
- return Promise.reject({
72
- error: resp.code,
73
- error_description: resp.message
74
- })
75
- }
76
- return {
77
- requestId: resp.requestId,
78
- result: resp.data.response_data,
79
- }
80
- }
81
- }
82
-
83
-
84
- export interface FunctionRequest {
85
- name: string;
86
- data: any;
87
- }
88
-
89
- export interface FunctionResponse {
90
- requestId: string;
91
- result: any;
92
- }
93
-
94
- export interface functionHTTPResponse {
95
- requestId: string;
96
- data: any
97
- code: string
98
- message: string
99
- }
@@ -1,101 +0,0 @@
1
- import { client, fn } from "./request";
2
-
3
- async function init() {
4
- try {
5
- signInWithUserNameAndPassword()
6
- } catch (error) {
7
- // 获取用户信息失败
8
- console.log('test error: ', error);
9
- }
10
-
11
- // try {
12
- // console.log("rest password")
13
- // const verificationToken = await client.auth.getVerification({
14
- // phone_number: "+86 16622002084",
15
- // })
16
- // console.log(verificationToken.verification_id, verificationToken.is_user)
17
- // } catch (error) {
18
- // // 获取用户信息失败
19
- // console.log('发送失败 error: ', error);
20
- // }
21
- try {
22
- signInWithProviderToken()
23
- } catch (error) {
24
- // 获取用户信息失败
25
- console.log('grant error error: ', error);
26
- }
27
-
28
- const resp = await fn.callFunction({
29
- name: "test", data: {
30
- name: "ok"
31
- }
32
- })
33
- console.log(resp.result)
34
- }
35
-
36
- init();
37
-
38
-
39
-
40
- async function signInWithUserNameAndPassword(): Promise<void> {
41
- // 判断是否已经登录过了
42
- const loginState = await client.auth.hasLoginState()
43
- if (!loginState) {
44
- // 用户名密码登录
45
- await client.auth.signIn({
46
- username: "leenanxi",
47
- password: "qw0000"
48
- })
49
- }
50
- // 获取用户信息,相当于 auth.signInWithUsernameAndPassword
51
- const userInfoA = await client.auth.getUserProfile()
52
- console.log(userInfoA)
53
-
54
- // 修改密码
55
-
56
- }
57
-
58
-
59
- async function signInWithProviderToken(): Promise<void> {
60
- // 判断是否已经登录过了
61
- const loginState = await client.auth.hasLoginState()
62
-
63
- console.log("test", loginState)
64
-
65
- return
66
-
67
- // if (!loginState) {
68
- // const crd = await client.auth.signInAnonymously()
69
- // console.log(crd)
70
- // }
71
-
72
- const userInfoA = await client.auth.getUserProfile()
73
- console.log(userInfoA)
74
- //
75
- // // 获取provider token
76
- // const providerToken = await client.auth.grantProviderToken({
77
- // provider_id: "weda",
78
- // provider_access_token: "ya29.a0ARrdaM8nNGa2g3eNWok38QWChn5hcOMZIXIbV48LxcEIt7lSfOt2ERLVRMQh9-iOxMy9anVtVV20ONWWyIHKxeA68D8FlpSZIazLfscLDOY8X1IjzF7kfhLiQwVbPYVeVsj7prOacREaICaaYO632za8bLSp2RU",
79
- // });
80
- // // 用provider token 登录
81
- // client.auth.signInWithProvider({
82
- // provider_token: providerToken.provider_token,
83
- // })
84
-
85
- // 调用云函数
86
-
87
-
88
-
89
- // 登录成功后,获取用户信息
90
- const userInfo = await client.auth.getUserProfile()
91
- console.log(userInfo)
92
- // 获取 accessToken
93
- const accessToken = await client.auth.credentialsClient.getAccessToken();
94
- console.log(accessToken)
95
- // 用 OIDC 请求信息
96
- // export interface ExampleData {
97
- // result?: string;
98
- // }
99
- // const data = await client.oAuth2Client.request<ExampleData>("https://example.com", {withCredentials:true})
100
- // console.log(data.result)
101
- }
@@ -1,11 +0,0 @@
1
- import {initializeClient} from '@cloudbase/cloudbase';
2
- import {getFunction} from './function/function';
3
-
4
- export const config = {
5
- apiOrigin: "https://xbase-4gh5dh6nf62145a9.ap-shanghai.tcb-api.tencentcloudapi.com",
6
- clientId: "xbase-4gh5dh6nf62145a9",
7
- };
8
- const client = initializeClient(config);
9
- const fn = getFunction(client.app);
10
-
11
- export {client, fn}
@@ -1,15 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <meta http-equiv="Pragma" content="no-cache">
7
- <meta http-equiv="Cache-Control" content="no-cache">
8
- <meta http-equiv="Expires" content="0">
9
- <title>Demo</title>
10
- </head>
11
- <body>
12
- <div>loading...</div>
13
- <div>test</div>
14
- </body>
15
- </html>
@@ -1,33 +0,0 @@
1
- {
2
- "name": "device",
3
- "version": "1.0.0",
4
- "description": "",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1",
8
- "build": "cross-env NODE_ENV=production webpack",
9
- "start": "cross-env NODE_ENV=development webpack-dev-server"
10
- },
11
- "author": "",
12
- "license": "ISC",
13
- "dependencies": {
14
- "@types/qs": "^6.9.1",
15
- "@xbasesdk/xbase": "file://Users/nx/Documents/go/xbase/src/gitlab.xunlei.cn/xbase/sdk/xbasesdk/dist",
16
- "cross-env": "^7.0.2",
17
- "firebase": "^9.0.2",
18
- "qs": "^6.9.3",
19
- "webpack": "^4.39.3",
20
- "webpack-cli": "^4.8.0"
21
- },
22
- "devDependencies": {
23
- "@babel/cli": "^7.14.8",
24
- "@babel/core": "^7.15.0",
25
- "clean-webpack-plugin": "^4.0.0-alpha.0",
26
- "copy-webpack-plugin": "^9.0.1",
27
- "html-webpack-plugin": "^3.2.0",
28
- "ts-loader": "^6.1.0",
29
- "typescript": "^3.8.3",
30
- "webpack-cli": "^4.8.0",
31
- "webpack-dev-server": "^4.1.0"
32
- }
33
- }
@@ -1,71 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- /* Basic Options */
4
- // "incremental": true, /* Enable incremental compilation */
5
- "target": "es2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
6
- "module": "es2020", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
7
- // "lib": [], /* Specify library files to be included in the compilation. */
8
- "allowJs": true, /* Allow javascript files to be compiled. */
9
- // "checkJs": true, /* Report errors in .js files. */
10
- // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
11
- // "declaration": true, /* Generates corresponding '.d.ts' file. */
12
- // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
13
- // "sourceMap": true, /* Generates corresponding '.map' file. */
14
- // "outFile": "./", /* Concatenate and emit output to single file. */
15
- "outDir": "./dist/", /* Redirect output structure to the directory. */
16
- // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
17
- // "composite": true, /* Enable project compilation */
18
- // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
19
- // "removeComments": true, /* Do not emit comments to output. */
20
- // "noEmit": true, /* Do not emit outputs. */
21
- // "importHelpers": true, /* Import emit helpers from 'tslib'. */
22
- // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
23
- // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
24
-
25
- /* Strict Type-Checking Options */
26
- "strict": true, /* Enable all strict type-checking options. */
27
- "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
28
- // "strictNullChecks": true, /* Enable strict null checks. */
29
- // "strictFunctionTypes": true, /* Enable strict checking of function types. */
30
- // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
31
- // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
32
- // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
33
- // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
34
-
35
- /* Additional Checks */
36
- // "noUnusedLocals": true, /* Report errors on unused locals. */
37
- // "noUnusedParameters": true, /* Report errors on unused parameters. */
38
- // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
39
- // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
40
-
41
- /* Module Resolution Options */
42
- "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
43
- // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
44
- // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
45
- // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
46
- // "typeRoots": [], /* List of folders to include type definitions from. */
47
- // "types": [], /* Type declaration files to be included in compilation. */
48
- // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
49
- "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
50
- // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
51
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
52
-
53
- /* Source Map Options */
54
- // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
55
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
56
- // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
57
- // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
58
-
59
- /* Experimental Options */
60
- // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
61
- // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
62
-
63
-
64
-
65
- "strictPropertyInitialization": false,
66
- "experimentalDecorators": true,
67
- "strictNullChecks": false,
68
- "noUnusedLocals": true,
69
- "declaration": true
70
- }
71
- }
File without changes
@@ -1,42 +0,0 @@
1
- const path = require('path');
2
- const { CleanWebpackPlugin } = require('clean-webpack-plugin');
3
- const CopyPlugin = require('copy-webpack-plugin');
4
- const HtmlWebpackPlugin = require('html-webpack-plugin');
5
-
6
- const mode = process.env.NODE_ENV;
7
-
8
- console.log('环境:', mode);
9
-
10
- module.exports = {
11
- entry: {
12
- main: './assets/scripts/index.ts',
13
- },
14
- mode,
15
- devServer: {
16
- contentBase: path.join(__dirname, 'dist'),
17
- port: 4000,
18
- hot: true,
19
- },
20
- module: {
21
- rules: [
22
- {
23
- test: /\.tsx?$/,
24
- use: 'ts-loader',
25
- exclude: /node_modules/
26
- }
27
- ]
28
- },
29
- resolve: {
30
- extensions: [ '.ts', '.tsx', '.js' ]
31
- },
32
- output: {
33
- filename: '[name].[hash:5].js',
34
- path: path.resolve(__dirname, 'dist')
35
- },
36
- plugins: [
37
- new CleanWebpackPlugin(),
38
- new HtmlWebpackPlugin({
39
- template: "./index.html"
40
- })
41
- ],
42
- };
@@ -1,55 +0,0 @@
1
- import { GetVerificationRequest, GetVerificationResponse, UserProfile, UserInfo, SignInRequest, SignUpRequest, VerifyRequest, VerifyResponse, GenProviderRedirectUriRequest, GenProviderRedirectUriResponse, GrantProviderTokenRequest, GrantProviderTokenResponse, PatchProviderTokenRequest, PatchProviderTokenResponse, SignInWithProviderRequest, BindWithProviderRequest, TransByProviderRequest, GrantTokenRequest, UserProfileProvider, UnbindProviderRequest, CheckPasswordrRequest, BindPhoneRequest, BindEmailRequest, SetPasswordRequest, ChangeBindedProviderRequest, ChangeBindedProviderResponse, UpdatePasswordRequest, SudoResponse, SudoRequest, GetCustomSignTicketFn, QueryUserProfileRequest, QueryUserProfileResponse, ResetPasswordRequest, DeviceAuthorizeRequest, DeviceAuthorizeResponse, CheckUsernameRequest, CheckIfUserExistRequest, CheckIfUserExistResponse, WithSudoRequest } from './models';
2
- import { SimpleStorage, RequestFunction } from '../oauth2client/interface';
3
- import { OAuth2Client } from '../oauth2client/oauth2client';
4
- import { Credentials } from '../oauth2client/models';
5
- export interface AuthOptions {
6
- apiOrigin: string;
7
- clientId: string;
8
- credentialsClient?: OAuth2Client;
9
- request?: RequestFunction;
10
- storage?: SimpleStorage;
11
- }
12
- export declare class Auth {
13
- private _config;
14
- private _getCustomSignTicketFn?;
15
- constructor(opts: AuthOptions);
16
- signIn(params: SignInRequest): Promise<Credentials>;
17
- signInAnonymously(): Promise<Credentials>;
18
- signUp(params: SignUpRequest): Promise<Credentials>;
19
- signOut(): Promise<any>;
20
- getVerification(params: GetVerificationRequest): Promise<GetVerificationResponse>;
21
- verify(params: VerifyRequest): Promise<VerifyResponse>;
22
- genProviderRedirectUri(params: GenProviderRedirectUriRequest): Promise<GenProviderRedirectUriResponse>;
23
- grantProviderToken(params: GrantProviderTokenRequest): Promise<GrantProviderTokenResponse>;
24
- patchProviderToken(params: PatchProviderTokenRequest): Promise<PatchProviderTokenResponse>;
25
- signInWithProvider(params: SignInWithProviderRequest): Promise<Credentials>;
26
- bindWithProvider(params: BindWithProviderRequest): Promise<void>;
27
- getUserProfile(): Promise<UserProfile>;
28
- getUserInfo(): Promise<UserInfo>;
29
- deleteMe(params: WithSudoRequest): Promise<UserProfile>;
30
- hasLoginState(): Promise<boolean>;
31
- hasLoginStateSync(): Credentials | null;
32
- getLoginState(): Promise<Credentials | null>;
33
- transByProvider(params: TransByProviderRequest): Promise<Credentials>;
34
- grantToken(params: GrantTokenRequest): Promise<Credentials>;
35
- getProviders(): Promise<UserProfileProvider>;
36
- unbindProvider(params: UnbindProviderRequest): Promise<void>;
37
- checkPassword(params: CheckPasswordrRequest): Promise<void>;
38
- bindPhone(params: BindPhoneRequest): Promise<void>;
39
- bindEmail(params: BindEmailRequest): Promise<void>;
40
- setPassword(params: SetPasswordRequest): Promise<void>;
41
- updatePasswordByOld(params: UpdatePasswordRequest): Promise<void>;
42
- sudo(params: SudoRequest): Promise<SudoResponse>;
43
- getCurUserVerification(params: GetVerificationRequest): Promise<GetVerificationResponse>;
44
- changeBindedProvider(params: ChangeBindedProviderRequest): Promise<ChangeBindedProviderResponse>;
45
- setUserProfile(params: UserProfile): Promise<UserProfile>;
46
- queryUserProfile(params: QueryUserProfileRequest): Promise<QueryUserProfileResponse>;
47
- setCustomSignFunc(getTickFn: GetCustomSignTicketFn): void;
48
- signInWithCustomTicket(): Promise<Credentials>;
49
- resetPassword(params: ResetPasswordRequest): Promise<void>;
50
- deviceAuthorize(params: DeviceAuthorizeRequest): Promise<DeviceAuthorizeResponse>;
51
- checkUsername(params: CheckUsernameRequest): Promise<void>;
52
- checkIfUserExist(params: CheckIfUserExistRequest): Promise<CheckIfUserExistResponse>;
53
- loginScope(): Promise<string>;
54
- private static parseParamsToSearch;
55
- }