@jetthai/cuora 1.0.102 → 1.0.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/package.json +2 -8
- package/src/api/user.js +3 -4
- package/src/machine/auth.js +4 -10
- package/src/machine/auth_otp_v2.js +6 -2
- package/src/machine/common.js +19 -1
- package/src/machine/user_sign_up.js +12 -1
- package/src/machine/withdraw_fc.js +11 -0
- package/webpack.config.js +0 -33
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.0.104](https://github.com/jetthai/cuora-module/compare/v1.0.103...v1.0.104) (2022-03-21)
|
|
6
|
+
|
|
7
|
+
### [1.0.103](https://github.com/jetthai/cuora-module/compare/v1.0.102...v1.0.103) (2022-03-17)
|
|
8
|
+
|
|
5
9
|
### [1.0.102](https://github.com/jetthai/cuora-module/compare/v1.0.101...v1.0.102) (2022-03-17)
|
|
6
10
|
|
|
7
11
|
### [1.0.101](https://github.com/jetthai/cuora-module/compare/v1.0.100...v1.0.101) (2022-03-17)
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jetthai/cuora",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.104",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "webpack",
|
|
8
7
|
"release": "standard-version && git push --follow-tags origin master && npm publish"
|
|
9
8
|
},
|
|
10
9
|
"repository": {
|
|
@@ -14,13 +13,8 @@
|
|
|
14
13
|
"author": "Neil",
|
|
15
14
|
"license": "ISC",
|
|
16
15
|
"devDependencies": {
|
|
17
|
-
"@babel/core": "^7.15.8",
|
|
18
|
-
"@babel/preset-env": "^7.15.8",
|
|
19
|
-
"babel-loader": "^8.2.2",
|
|
20
16
|
"prettier": "^2.3.0",
|
|
21
|
-
"standard-version": "^9.3.1"
|
|
22
|
-
"webpack": "^5.58.2",
|
|
23
|
-
"webpack-cli": "^4.9.0"
|
|
17
|
+
"standard-version": "^9.3.1"
|
|
24
18
|
},
|
|
25
19
|
"dependencies": {
|
|
26
20
|
"@fingerprintjs/fingerprintjs-pro": "^3.5.5",
|
package/src/api/user.js
CHANGED
|
@@ -34,18 +34,17 @@ export default {
|
|
|
34
34
|
params: { requestId, target, newPassword },
|
|
35
35
|
isPublic: true,
|
|
36
36
|
}),
|
|
37
|
-
// /verify/v2/* 為已登入時的otp驗證
|
|
38
37
|
verifyV2Initiate: ({ strategy }) => ({
|
|
39
38
|
// strategy: 'phone' | 'email'
|
|
40
39
|
url: '/verify/v2/initiate',
|
|
41
40
|
method: 'post',
|
|
42
41
|
params: { strategy },
|
|
43
42
|
}),
|
|
44
|
-
|
|
45
|
-
url: '/
|
|
43
|
+
otpAcknowledge: ({ requestId, target, code }) => ({
|
|
44
|
+
url: '/otpsso/acknowledge',
|
|
46
45
|
method: 'post',
|
|
47
46
|
params: { requestId, target, code },
|
|
48
47
|
isPublic: true,
|
|
49
48
|
}),
|
|
50
|
-
|
|
49
|
+
otpReset: ({ requestId, target }) => ({ url: '/otpsso/reset', method: 'post', params: { requestId, target }, isPublic: true }),
|
|
51
50
|
}
|
package/src/machine/auth.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import urljoin from 'url-join'
|
|
2
2
|
import Cookies from 'universal-cookie'
|
|
3
3
|
import qs from 'qs'
|
|
4
|
-
import
|
|
5
|
-
import isNull from 'lodash/isNull'
|
|
6
|
-
import isUndefined from 'lodash/isUndefined'
|
|
7
|
-
import { assign, createMachine, send } from 'xstate'
|
|
4
|
+
import { assign, createMachine } from 'xstate'
|
|
8
5
|
import auth from '../api/auth'
|
|
9
6
|
import user from '../api/user'
|
|
10
7
|
import { getDeviceToken } from '../util/deviceToken'
|
|
@@ -252,17 +249,14 @@ export default function (request) {
|
|
|
252
249
|
redirectTo3Party: async (context, event) => {
|
|
253
250
|
const { provider, channel, subchannel } = event.data
|
|
254
251
|
const dt = await getDeviceToken({ fpToken, sentry, apiURL: request.config.apiURL })
|
|
255
|
-
const redirectParams = omitBy(omitBy({ channel, subchannel }, isUndefined), isNull)
|
|
256
|
-
const query = new URLSearchParams(redirectParams).toString()
|
|
257
|
-
const redirectURI = urljoin(`${window.location.protocol}//${window.location.host}`, query ? `?${query}` : '')
|
|
258
252
|
const redirectURL = urljoin(
|
|
259
253
|
request.config.fullURL,
|
|
260
254
|
'login?' +
|
|
261
255
|
qs.stringify({
|
|
262
256
|
provider,
|
|
263
|
-
redirectURI
|
|
264
|
-
channel: channel || 'official',
|
|
265
|
-
subchannel: subchannel || 'pwa',
|
|
257
|
+
redirectURI: `${window.location.protocol}//${window.location.host}`,
|
|
258
|
+
channel: cookies.get('channel') || channel || 'official',
|
|
259
|
+
subchannel: cookies.get('subchannel') || subchannel || 'pwa',
|
|
266
260
|
dt,
|
|
267
261
|
platform: 'pwa',
|
|
268
262
|
})
|
|
@@ -17,6 +17,10 @@ export default function (request) {
|
|
|
17
17
|
states: {
|
|
18
18
|
idle: {
|
|
19
19
|
on: {
|
|
20
|
+
SET_OTP_INITIALIZATION: {
|
|
21
|
+
target: 'otp',
|
|
22
|
+
actions: 'setOtpResult',
|
|
23
|
+
},
|
|
20
24
|
SEND_OTP_EMAIL: {
|
|
21
25
|
target: 'otpFetching',
|
|
22
26
|
actions: 'setStrategyEmail',
|
|
@@ -154,12 +158,12 @@ export default function (request) {
|
|
|
154
158
|
},
|
|
155
159
|
resetOtp: async (context, event) => {
|
|
156
160
|
const { requestId, target } = context
|
|
157
|
-
return await request.send(user.
|
|
161
|
+
return await request.send(user.otpReset({ requestId, target }))
|
|
158
162
|
},
|
|
159
163
|
acknowledge: async (context, event) => {
|
|
160
164
|
const { requestId, target } = context
|
|
161
165
|
const code = event.data
|
|
162
|
-
return await request.send(user.
|
|
166
|
+
return await request.send(user.otpAcknowledge({ requestId, target, code }))
|
|
163
167
|
},
|
|
164
168
|
},
|
|
165
169
|
}
|
package/src/machine/common.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import UAParser from 'ua-parser-js'
|
|
2
|
+
import Cookies from 'universal-cookie'
|
|
2
3
|
import { assign, createMachine } from 'xstate'
|
|
3
4
|
import api from '../api/common'
|
|
5
|
+
const cookies = new Cookies()
|
|
4
6
|
|
|
5
7
|
export default function (request) {
|
|
6
8
|
const { appSecret } = request.config
|
|
@@ -45,7 +47,7 @@ export default function (request) {
|
|
|
45
47
|
},
|
|
46
48
|
},
|
|
47
49
|
fetching: {
|
|
48
|
-
entry: 'setUA',
|
|
50
|
+
entry: ['setUA', 'setAgent'],
|
|
49
51
|
invoke: {
|
|
50
52
|
src: 'fetchSiteConfig',
|
|
51
53
|
onDone: {
|
|
@@ -136,6 +138,22 @@ export default function (request) {
|
|
|
136
138
|
isMobile: userAgent?.device?.type,
|
|
137
139
|
}
|
|
138
140
|
}),
|
|
141
|
+
setAgent: (context, event) => {
|
|
142
|
+
let urlParams = new URLSearchParams(window.location.search)
|
|
143
|
+
const channel = urlParams.get('channel')
|
|
144
|
+
const subchannel = urlParams.get('subchannel')
|
|
145
|
+
|
|
146
|
+
if (channel && subchannel) {
|
|
147
|
+
cookies.set('channel', channel, {
|
|
148
|
+
path: '/',
|
|
149
|
+
maxAge: 60 * 60 * 24 * 7,
|
|
150
|
+
})
|
|
151
|
+
cookies.set('subchannel', subchannel, {
|
|
152
|
+
path: '/',
|
|
153
|
+
maxAge: 60 * 60 * 24 * 7,
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
},
|
|
139
157
|
setFeeds: assign((context, event) => {
|
|
140
158
|
const { announcementList, broadcastList, mailBoxInfo } = event.data
|
|
141
159
|
const promotions = announcementList?.announcements?.filter?.((item) => item.category === 3) || []
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { createMachine, assign } from 'xstate'
|
|
2
|
+
import Cookies from 'universal-cookie'
|
|
2
3
|
import auth from '../api/auth'
|
|
3
4
|
import { getDeviceToken } from '../util/deviceToken'
|
|
5
|
+
const cookies = new Cookies()
|
|
4
6
|
|
|
5
7
|
export default function (request) {
|
|
6
8
|
const { fpToken, sentry } = request.config
|
|
@@ -92,7 +94,16 @@ export default function (request) {
|
|
|
92
94
|
signUp: async (context, event) => {
|
|
93
95
|
const { email, password, channel, subchannel } = context
|
|
94
96
|
const dt = await getDeviceToken({ fpToken, sentry, apiURL: request.config.apiURL })
|
|
95
|
-
return await request.send(
|
|
97
|
+
return await request.send(
|
|
98
|
+
auth.register({
|
|
99
|
+
provider: 'email',
|
|
100
|
+
email,
|
|
101
|
+
password,
|
|
102
|
+
channel: cookies.get('channel') || channel,
|
|
103
|
+
subchannel: cookies.get('subchannel') || subchannel,
|
|
104
|
+
dt,
|
|
105
|
+
})
|
|
106
|
+
)
|
|
96
107
|
},
|
|
97
108
|
},
|
|
98
109
|
}
|
|
@@ -92,6 +92,7 @@ export default function (request) {
|
|
|
92
92
|
src: 'submitWithdrawFree',
|
|
93
93
|
onDone: {
|
|
94
94
|
target: 'transferred',
|
|
95
|
+
actions: 'setOtp',
|
|
95
96
|
},
|
|
96
97
|
onError: {
|
|
97
98
|
target: 'transferable.operation',
|
|
@@ -103,6 +104,7 @@ export default function (request) {
|
|
|
103
104
|
src: 'submitWithdraw',
|
|
104
105
|
onDone: {
|
|
105
106
|
target: 'transferred',
|
|
107
|
+
actions: 'setOtp',
|
|
106
108
|
},
|
|
107
109
|
onError: {
|
|
108
110
|
target: 'transferable.operation',
|
|
@@ -179,6 +181,15 @@ export default function (request) {
|
|
|
179
181
|
}
|
|
180
182
|
}
|
|
181
183
|
}),
|
|
184
|
+
setOtp: assign((context, event) => {
|
|
185
|
+
const { requestId, status, target, ttl } = event.data
|
|
186
|
+
return {
|
|
187
|
+
requestId,
|
|
188
|
+
status,
|
|
189
|
+
target,
|
|
190
|
+
ttl,
|
|
191
|
+
}
|
|
192
|
+
}),
|
|
182
193
|
},
|
|
183
194
|
guards: {
|
|
184
195
|
isFree: (context, event) => {
|
package/webpack.config.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
mode: 'production',
|
|
5
|
-
entry: {
|
|
6
|
-
main: './src/index.js',
|
|
7
|
-
},
|
|
8
|
-
output: {
|
|
9
|
-
filename: 'index.js',
|
|
10
|
-
path: path.resolve(__dirname, 'dist'),
|
|
11
|
-
clean: true,
|
|
12
|
-
library: {
|
|
13
|
-
type: 'module',
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
experiments: {
|
|
17
|
-
outputModule: true,
|
|
18
|
-
},
|
|
19
|
-
module: {
|
|
20
|
-
rules: [
|
|
21
|
-
{
|
|
22
|
-
test: /\.m?js$/,
|
|
23
|
-
exclude: /node_modules/,
|
|
24
|
-
use: {
|
|
25
|
-
loader: 'babel-loader',
|
|
26
|
-
options: {
|
|
27
|
-
presets: [['@babel/preset-env', { targets: 'defaults' }]],
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
},
|
|
33
|
-
}
|