react-native-bootpay-api 1.4.4 → 4.0.0-beta.0
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/package.json +54 -97
- package/src/BootpayWebView.js +105 -42
- package/{lib/typescript → src}/UserInfo.d.ts +0 -0
- package/src/UserInfo.d.ts.map +1 -0
- package/src/UserInfo.js +67 -0
- package/CHANGELOG.md +0 -20
- package/lib/commonjs/BootpayAnalytics.js +0 -131
- package/lib/commonjs/BootpayAnalytics.js.map +0 -1
- package/lib/commonjs/BootpayWebView.js +0 -264
- package/lib/commonjs/BootpayWebView.js.map +0 -1
- package/lib/commonjs/UserInfo.js +0 -94
- package/lib/commonjs/UserInfo.js.map +0 -1
- package/lib/commonjs/index.d.js +0 -28
- package/lib/commonjs/index.d.js.map +0 -1
- package/lib/commonjs/index.js +0 -28
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/useBootpay.js +0 -44
- package/lib/commonjs/useBootpay.js.map +0 -1
- package/lib/module/BootpayAnalytics.js +0 -115
- package/lib/module/BootpayAnalytics.js.map +0 -1
- package/lib/module/BootpayWebView.js +0 -242
- package/lib/module/BootpayWebView.js.map +0 -1
- package/lib/module/UserInfo.js +0 -79
- package/lib/module/UserInfo.js.map +0 -1
- package/lib/module/index.d.js +0 -28
- package/lib/module/index.d.js.map +0 -1
- package/lib/module/index.js +0 -21
- package/lib/module/index.js.map +0 -1
- package/lib/module/useBootpay.js +0 -43
- package/lib/module/useBootpay.js.map +0 -1
- package/lib/typescript/UserInfo.d.ts.map +0 -1
- package/src/useBootpay.js +0 -51
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-bootpay-api",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "4.0.0-beta.0",
|
|
4
|
+
"description": "React Native를 위한 bootpay 라이브러리 입니다.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
7
|
-
"types": "src/index.d.ts",
|
|
7
|
+
"types": "src/index.d.ts",
|
|
8
8
|
"react-native": "src/index",
|
|
9
9
|
"source": "src/index",
|
|
10
|
+
"contributors": [
|
|
11
|
+
"Bootpay <bootpay.co.kr@gmail.com>"
|
|
12
|
+
],
|
|
10
13
|
"files": [
|
|
11
14
|
"src",
|
|
12
15
|
"lib",
|
|
@@ -23,14 +26,18 @@
|
|
|
23
26
|
"!**/__mocks__"
|
|
24
27
|
],
|
|
25
28
|
"scripts": {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
29
|
+
"android": "react-native run-android",
|
|
30
|
+
"ios": "react-native run-ios --project-path example/ios",
|
|
31
|
+
"macos": "react-native run-macos --scheme WebviewExample --project-path example/macos",
|
|
32
|
+
"start": "cd example && react-native start",
|
|
33
|
+
"windows": "install-windows-test-app --project-directory example/windows && react-native run-windows --root example --arch x64",
|
|
34
|
+
"ci": "CI=true && yarn lint",
|
|
35
|
+
"ci:publish": "yarn semantic-release",
|
|
36
|
+
"lint": "yarn tsc --noEmit && yarn eslint ./src --ext .ts,.tsx",
|
|
37
|
+
"build": "yarn tsc",
|
|
38
|
+
"prepare": "yarn build",
|
|
39
|
+
"appium": "appium",
|
|
40
|
+
"test:windows": "yarn jest --setupFiles=./jest-setups/jest.setup.js"
|
|
34
41
|
},
|
|
35
42
|
"keywords": [
|
|
36
43
|
"react-native",
|
|
@@ -41,103 +48,53 @@
|
|
|
41
48
|
"author": "bootpay <bootpay.co.kr@gmail.com> (https://github.com/bootpay)",
|
|
42
49
|
"license": "MIT",
|
|
43
50
|
"bugs": {
|
|
44
|
-
"url": "https://
|
|
51
|
+
"url": "https://bootpay.channel.io/"
|
|
45
52
|
},
|
|
46
|
-
"homepage": "https://
|
|
53
|
+
"homepage": "https://www.bootpay.co.kr/",
|
|
47
54
|
"publishConfig": {
|
|
48
55
|
"registry": "https://registry.npmjs.org/"
|
|
49
56
|
},
|
|
50
57
|
"devDependencies": {
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
53
|
-
"@
|
|
58
|
+
"@babel/core": "^7.0.0",
|
|
59
|
+
"@babel/runtime": "^7.0.0",
|
|
60
|
+
"@react-native-community/cli": "^6.0.0",
|
|
61
|
+
"@react-native-community/cli-platform-android": "^6.0.0",
|
|
62
|
+
"@react-native-community/cli-platform-ios": "^6.0.0",
|
|
63
|
+
"@semantic-release/git": "7.0.16",
|
|
64
|
+
"@types/invariant": "^2.2.30",
|
|
54
65
|
"@types/jest": "^26.0.0",
|
|
55
|
-
"@types/react": "^
|
|
56
|
-
"@types/react-native": "0.
|
|
57
|
-
"
|
|
58
|
-
"eslint": "
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"react-native
|
|
68
|
-
"
|
|
66
|
+
"@types/react": "^17.0.0",
|
|
67
|
+
"@types/react-native": "^0.64.0",
|
|
68
|
+
"@types/selenium-webdriver": "4.0.9",
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "2.1.0",
|
|
70
|
+
"@typescript-eslint/parser": "2.1.0",
|
|
71
|
+
"appium": "1.17.0",
|
|
72
|
+
"eslint": "6.3.0",
|
|
73
|
+
"eslint-config-airbnb": "18.0.1",
|
|
74
|
+
"eslint-config-prettier": "6.2.0",
|
|
75
|
+
"eslint-plugin-import": "2.18.2",
|
|
76
|
+
"eslint-plugin-jsx-a11y": "6.2.3",
|
|
77
|
+
"eslint-plugin-react": "7.14.3",
|
|
78
|
+
"eslint-plugin-react-native": "3.7.0",
|
|
79
|
+
"jest": "^26.6.3",
|
|
80
|
+
"metro-react-native-babel-preset": "^0.66.2",
|
|
81
|
+
"react": "17.0.2",
|
|
82
|
+
"react-native": "^0.66.0-0",
|
|
83
|
+
"react-native-macos": "^0.66.0-0",
|
|
84
|
+
"react-native-test-app": "^1.3.2",
|
|
85
|
+
"react-native-windows": "^0.66.0-0",
|
|
86
|
+
"selenium-appium": "1.0.2",
|
|
87
|
+
"selenium-webdriver": "4.0.0-alpha.7",
|
|
88
|
+
"semantic-release": "15.13.24",
|
|
89
|
+
"typescript": "^4.0.0",
|
|
90
|
+
"react-native-webview-bootpay": "^11.18.13",
|
|
91
|
+
"react-native-device-info": "^8.7.0",
|
|
69
92
|
"react-native-sensitive-info": "^5.5.8",
|
|
70
93
|
"react-native-base64": "^0.2.1",
|
|
71
|
-
"react-native-aes-crypto": "^1.
|
|
94
|
+
"react-native-aes-crypto": "^2.1.0"
|
|
72
95
|
},
|
|
73
96
|
"peerDependencies": {
|
|
74
97
|
"react": "*",
|
|
75
98
|
"react-native": "*"
|
|
76
|
-
},
|
|
77
|
-
"jest": {
|
|
78
|
-
"preset": "react-native",
|
|
79
|
-
"modulePathIgnorePatterns": [
|
|
80
|
-
"<rootDir>/example/node_modules",
|
|
81
|
-
"<rootDir>/lib/"
|
|
82
|
-
]
|
|
83
|
-
},
|
|
84
|
-
"commitlint": {
|
|
85
|
-
"extends": [
|
|
86
|
-
"@commitlint/config-conventional"
|
|
87
|
-
]
|
|
88
|
-
},
|
|
89
|
-
"release-it": {
|
|
90
|
-
"git": {
|
|
91
|
-
"commitMessage": "chore: release ${version}",
|
|
92
|
-
"tagName": "v${version}"
|
|
93
|
-
},
|
|
94
|
-
"npm": {
|
|
95
|
-
"publish": true
|
|
96
|
-
},
|
|
97
|
-
"github": {
|
|
98
|
-
"release": true
|
|
99
|
-
},
|
|
100
|
-
"plugins": {
|
|
101
|
-
"@release-it/conventional-changelog": {
|
|
102
|
-
"preset": "angular"
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
"eslintConfig": {
|
|
107
|
-
"root": true,
|
|
108
|
-
"extends": [
|
|
109
|
-
"@react-native-community",
|
|
110
|
-
"prettier"
|
|
111
|
-
],
|
|
112
|
-
"rules": {
|
|
113
|
-
"prettier/prettier": [
|
|
114
|
-
"error",
|
|
115
|
-
{
|
|
116
|
-
"quoteProps": "consistent",
|
|
117
|
-
"singleQuote": true,
|
|
118
|
-
"tabWidth": 2,
|
|
119
|
-
"trailingComma": "es5",
|
|
120
|
-
"useTabs": false
|
|
121
|
-
}
|
|
122
|
-
]
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
"eslintIgnore": [
|
|
126
|
-
"node_modules/",
|
|
127
|
-
"lib/"
|
|
128
|
-
],
|
|
129
|
-
"react-native-builder-bob": {
|
|
130
|
-
"source": "src",
|
|
131
|
-
"output": "lib",
|
|
132
|
-
"targets": [
|
|
133
|
-
"commonjs",
|
|
134
|
-
"module",
|
|
135
|
-
[
|
|
136
|
-
"typescript",
|
|
137
|
-
{
|
|
138
|
-
"project": "tsconfig.build.json"
|
|
139
|
-
}
|
|
140
|
-
]
|
|
141
|
-
]
|
|
142
99
|
}
|
|
143
100
|
}
|
package/src/BootpayWebView.js
CHANGED
|
@@ -1,19 +1,37 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
import React, { Component, useRef } from 'react';
|
|
4
|
-
import { SafeAreaView, Modal, Platform, TouchableOpacity, Image, StyleSheet
|
|
3
|
+
import React, { Component, useRef, useEffect } from 'react';
|
|
4
|
+
import { SafeAreaView, Modal, Platform, TouchableOpacity, Image, StyleSheet, BackHandler} from 'react-native';
|
|
5
5
|
import WebView from 'react-native-webview-bootpay';
|
|
6
6
|
import UserInfo from './UserInfo'
|
|
7
7
|
|
|
8
8
|
export class BootpayWebView extends Component {
|
|
9
|
+
|
|
10
|
+
|
|
9
11
|
webView = useRef<WebView>(null);
|
|
10
12
|
|
|
13
|
+
|
|
11
14
|
state = {
|
|
12
15
|
visibility: false,
|
|
13
16
|
script: '',
|
|
14
17
|
firstLoad: false
|
|
15
18
|
}
|
|
16
|
-
|
|
19
|
+
|
|
20
|
+
// canGoBack() {
|
|
21
|
+
// console.log('canGoBack');
|
|
22
|
+
// if(this.webView.current) {
|
|
23
|
+
// return this.webView.current.canGoBack();
|
|
24
|
+
// }
|
|
25
|
+
// return false;
|
|
26
|
+
// }
|
|
27
|
+
|
|
28
|
+
// goBack() {
|
|
29
|
+
// console.log('GoBack');
|
|
30
|
+
// if(this.webView.goBack) {
|
|
31
|
+
// this.webView.current.goBack();
|
|
32
|
+
// }
|
|
33
|
+
// }
|
|
34
|
+
|
|
17
35
|
async componentWillUnmount() {
|
|
18
36
|
this.setState(
|
|
19
37
|
{
|
|
@@ -25,12 +43,13 @@ s
|
|
|
25
43
|
UserInfo.setBootpayLastTime(Date.now());
|
|
26
44
|
}
|
|
27
45
|
|
|
28
|
-
render() {
|
|
29
|
-
|
|
30
|
-
|
|
46
|
+
render() {
|
|
31
47
|
return <Modal
|
|
32
48
|
animationType={'slide'}
|
|
33
|
-
transparent={false}
|
|
49
|
+
transparent={false}
|
|
50
|
+
onRequestClose={()=> {
|
|
51
|
+
this.dismiss();
|
|
52
|
+
}}
|
|
34
53
|
visible={this.state.visibility}>
|
|
35
54
|
<SafeAreaView style={{ flex: 1 }}>
|
|
36
55
|
{
|
|
@@ -58,15 +77,20 @@ s
|
|
|
58
77
|
}
|
|
59
78
|
<WebView
|
|
60
79
|
ref={(wv) => this.webView = wv}
|
|
80
|
+
// ref={btWebView}
|
|
61
81
|
useWebKit={true}
|
|
62
82
|
originWhitelist={['*']}
|
|
63
83
|
source={{
|
|
64
|
-
uri: 'https://
|
|
84
|
+
uri: 'https://webview.bootpay.co.kr/4.0.0/'
|
|
85
|
+
}}
|
|
86
|
+
onRequestClose={()=> {
|
|
87
|
+
console.log('onRequestClose');
|
|
88
|
+
this.dismiss();
|
|
65
89
|
}}
|
|
66
90
|
injectedJavaScript={this.state.script}
|
|
67
91
|
javaScriptEnabled={true}
|
|
68
92
|
javaScriptCanOpenWindowsAutomatically={true}
|
|
69
|
-
scalesPageToFit={true}
|
|
93
|
+
// scalesPageToFit={true}
|
|
70
94
|
onMessage={this.onMessage}
|
|
71
95
|
onShouldStartLoadWithRequest={this.onShouldStartLoadWithRequest}
|
|
72
96
|
/>
|
|
@@ -75,22 +99,24 @@ s
|
|
|
75
99
|
</Modal>
|
|
76
100
|
}
|
|
77
101
|
|
|
78
|
-
|
|
102
|
+
requestPayment = async (payload, items, user, extra) => {
|
|
103
|
+
this.bootpayRequest(payload, items, user, extra, "requestPayment");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
requestSubscription = async (payload, items, user, extra) => {
|
|
107
|
+
this.bootpayRequest(payload, items, user, extra, "requestSubscription");
|
|
108
|
+
}
|
|
79
109
|
|
|
110
|
+
requestAuthentication = async (payload, items, user, extra) => {
|
|
111
|
+
this.bootpayRequest(payload, items, user, extra, "requestAuthentication");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
bootpayRequest = async (payload, items, user, extra, requestMethod) => {
|
|
80
115
|
payload.application_id = Platform.OS == 'ios' ? this.props.ios_application_id : this.props.android_application_id;
|
|
81
116
|
payload.items = items;
|
|
82
117
|
payload.user_info = user;
|
|
83
118
|
payload.extra = extra;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
var quickPopup = '';
|
|
87
|
-
|
|
88
|
-
if(extra != undefined && extra.quick_popup != undefined) {
|
|
89
|
-
if(extra.quick_popup == 1) {
|
|
90
|
-
quickPopup = 'BootPay.startQuickPopup();';
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
119
|
+
|
|
94
120
|
|
|
95
121
|
//visibility가 true가 되면 webview onLoaded가 실행됨
|
|
96
122
|
this.setState(
|
|
@@ -99,15 +125,17 @@ s
|
|
|
99
125
|
script: `
|
|
100
126
|
${await this.getMountJavascript()}
|
|
101
127
|
${quickPopup}
|
|
102
|
-
${this.generateScript(payload)}
|
|
128
|
+
${this.generateScript(payload, requestMethod)}
|
|
103
129
|
`,
|
|
104
130
|
firstLoad: false,
|
|
105
131
|
showCloseButton: extra.show_close_button || false
|
|
106
132
|
}
|
|
107
133
|
)
|
|
108
134
|
|
|
109
|
-
UserInfo.updateInfo();
|
|
135
|
+
UserInfo.updateInfo();
|
|
110
136
|
}
|
|
137
|
+
|
|
138
|
+
|
|
111
139
|
|
|
112
140
|
dismiss = () => {
|
|
113
141
|
this.setState(
|
|
@@ -127,15 +155,21 @@ s
|
|
|
127
155
|
}
|
|
128
156
|
|
|
129
157
|
|
|
130
|
-
generateScript= (payload) => {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
158
|
+
generateScript= (payload, requestMethod) => {
|
|
159
|
+
var requestMethod = "requestPayment";
|
|
160
|
+
|
|
161
|
+
const script = "Bootpay." + requestMethod +
|
|
162
|
+
`(${JSON.stringify(payload)})` +
|
|
163
|
+
".then( function (res) {" +
|
|
164
|
+
confirm() +
|
|
165
|
+
issued() +
|
|
166
|
+
done() +
|
|
167
|
+
"}, function (res) {" +
|
|
168
|
+
error() +
|
|
169
|
+
cancel() +
|
|
170
|
+
"})";
|
|
137
171
|
|
|
138
|
-
|
|
172
|
+
this.callJavaScript(script);
|
|
139
173
|
}
|
|
140
174
|
|
|
141
175
|
onMessage = ({ nativeEvent }) => {
|
|
@@ -193,9 +227,9 @@ s
|
|
|
193
227
|
|
|
194
228
|
getBootpayPlatform = () => {
|
|
195
229
|
if(Platform.OS == 'ios') {
|
|
196
|
-
return "
|
|
230
|
+
return "Bootpay.setDevice('IOS');";
|
|
197
231
|
} else if(Platform.OS == 'android'){
|
|
198
|
-
return "
|
|
232
|
+
return "Bootpay.setDevice('ANDROID');";
|
|
199
233
|
}
|
|
200
234
|
}
|
|
201
235
|
|
|
@@ -208,18 +242,23 @@ s
|
|
|
208
242
|
// }
|
|
209
243
|
// }
|
|
210
244
|
|
|
211
|
-
transactionConfirm = (
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
245
|
+
transactionConfirm = () => {
|
|
246
|
+
const script = "Bootpay.confirm()" +
|
|
247
|
+
".then( function (res) {" +
|
|
248
|
+
confirm() +
|
|
249
|
+
issued() +
|
|
250
|
+
done() +
|
|
251
|
+
"}, function (res) {" +
|
|
252
|
+
error() +
|
|
253
|
+
cancel() +
|
|
254
|
+
"})";
|
|
255
|
+
|
|
256
|
+
this.callJavaScript(script);
|
|
218
257
|
}
|
|
219
258
|
|
|
220
259
|
removePaymentWindow = () => {
|
|
221
260
|
this.callJavaScript(`
|
|
222
|
-
|
|
261
|
+
Bootpay.removePaymentWindow();
|
|
223
262
|
`);
|
|
224
263
|
}
|
|
225
264
|
|
|
@@ -236,14 +275,38 @@ s
|
|
|
236
275
|
|
|
237
276
|
getAnalyticsData = async () => {
|
|
238
277
|
const uuid = await UserInfo.getBootpayUUID();
|
|
239
|
-
const bootpaySK = await UserInfo.getBootpaySK();
|
|
278
|
+
// const bootpaySK = await UserInfo.getBootpaySK();
|
|
240
279
|
const bootLastTime = await UserInfo.getBootpayLastTime();
|
|
241
280
|
|
|
242
281
|
|
|
243
282
|
const elaspedTime = Date.now() - bootLastTime;
|
|
244
|
-
return `window.
|
|
283
|
+
return `window.Bootpay.$analytics.setAnalyticsData({uuid:'${uuid}', time:${elaspedTime}});`;
|
|
245
284
|
// this.callJavaScript(`window.BootPay.setAnalyticsData({uuid:'${uuid}',sk:'${bootpaySK}',sk_time:${bootLastTime},time:${elaspedTime}});`);
|
|
246
285
|
}
|
|
286
|
+
|
|
287
|
+
confirm = () => {
|
|
288
|
+
return "if (res.event === 'confirm') { window.BootpayRNWebView.postMessage( JSON.stringify(res) ); }";
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
done = () => {
|
|
292
|
+
return "else if (res.event === 'done') { window.BootpayRNWebView.postMessage( JSON.stringify(res) ); }";
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
issued = () => {
|
|
296
|
+
return "else if (res.event === 'issued') { window.BootpayRNWebView.postMessage( JSON.stringify(res) ); }";
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
error = () => {
|
|
300
|
+
return "if (res.event === 'error') { window.BootpayRNWebView.postMessage( JSON.stringify(res) ); }";
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
cancel = () => {
|
|
304
|
+
return "else if (res.event === 'cancel') { window.BootpayRNWebView.postMessage( JSON.stringify(res) ); }";
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
close = () => {
|
|
308
|
+
return "document.addEventListener('bootpayclose', function (e) { window.BootpayRNWebView.postMessage('close'); });";
|
|
309
|
+
}
|
|
247
310
|
}
|
|
248
311
|
|
|
249
312
|
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserInfo.d.ts","sourceRoot":"","sources":["UserInfo.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlC,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,SAAS;IAC3C,MAAM,CAAC,cAAc,QAAS,MAAM,cAAc,GAAG,sBAYpD;IAED,MAAM,CAAC,cAAc,QAAS,MAAM,OAAO,GAAG,sBAW7C;IAED,MAAM,CAAC,cAAc,yBAGpB;IAED,MAAM,CAAC,YAAY,yBAElB;IAED,MAAM,CAAC,YAAY,QAAS,MAAM,sBAEjC;IAED,MAAM,CAAC,YAAY,SAAU,MAAM,QAAQ,MAAM,sBAEhD;IAED,MAAM,CAAC,kBAAkB,yBAExB;IAED,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,MAAM;IAIrC,MAAM,CAAC,gBAAgB;IAIvB,MAAM,CAAC,gBAAgB,QAAS,MAAM,sBAErC;IAED,MAAM,CAAC,UAAU,sBAWhB;CACJ"}
|
package/src/UserInfo.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Component } from 'react';
|
|
2
|
+
import DeviceInfo from 'react-native-device-info';
|
|
3
|
+
import SInfo from 'react-native-sensitive-info';
|
|
4
|
+
export default class UserInfo extends Component {
|
|
5
|
+
static getBootpayInfo = (key, defaultVal) => {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
SInfo.getItem(key, {
|
|
8
|
+
sharedPreferencesName: 'bootpaySharedPrefs',
|
|
9
|
+
keychainService: 'bootpayKeychain'
|
|
10
|
+
}).then((res) => {
|
|
11
|
+
res == undefined ? resolve(defaultVal) : resolve(res);
|
|
12
|
+
resolve(res);
|
|
13
|
+
}).catch((error) => {
|
|
14
|
+
reject(error);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
static setBootpayInfo = (key, val) => {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
SInfo.setItem(String(key), String(val), {
|
|
21
|
+
sharedPreferencesName: 'bootpaySharedPrefs',
|
|
22
|
+
keychainService: 'bootpayKeychain'
|
|
23
|
+
}).then((res) => {
|
|
24
|
+
resolve(res);
|
|
25
|
+
}).catch((error) => {
|
|
26
|
+
reject(error);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
static getBootpayUUID = () => {
|
|
31
|
+
let uuid = DeviceInfo.getUniqueId();
|
|
32
|
+
return UserInfo.setBootpayInfo('uuid', uuid);
|
|
33
|
+
};
|
|
34
|
+
static getBootpaySK = () => {
|
|
35
|
+
return UserInfo.getBootpayInfo('bootpay_sk', '');
|
|
36
|
+
};
|
|
37
|
+
static setBootpaySK = (val) => {
|
|
38
|
+
return UserInfo.setBootpayInfo('bootpay_sk', val);
|
|
39
|
+
};
|
|
40
|
+
static newBootpaySK = (uuid, time) => {
|
|
41
|
+
return UserInfo.setBootpaySK(`${uuid}_${time}`);
|
|
42
|
+
};
|
|
43
|
+
static getBootpayLastTime = async () => {
|
|
44
|
+
return await UserInfo.getBootpayInfo('bootpay_last_time', 0);
|
|
45
|
+
};
|
|
46
|
+
static setBootpayLastTime(val) {
|
|
47
|
+
return UserInfo.setBootpayInfo('bootpay_last_time', val);
|
|
48
|
+
}
|
|
49
|
+
static getBootpayUserId() {
|
|
50
|
+
return UserInfo.getBootpayInfo('bootpay_user_id', '');
|
|
51
|
+
}
|
|
52
|
+
static setBootpayUserId = (val) => {
|
|
53
|
+
return UserInfo.setBootpayInfo('bootpay_user_id', val);
|
|
54
|
+
};
|
|
55
|
+
static updateInfo = async () => {
|
|
56
|
+
const uuid = await UserInfo.getBootpayUUID();
|
|
57
|
+
const bootpaySK = await UserInfo.getBootpaySK();
|
|
58
|
+
const lastTime = await UserInfo.getBootpayLastTime();
|
|
59
|
+
let current = Date.now();
|
|
60
|
+
if (bootpaySK == '')
|
|
61
|
+
await UserInfo.newBootpaySK(uuid, current);
|
|
62
|
+
const isExpired = current - lastTime > 30 * 60 * 1000;
|
|
63
|
+
if (isExpired)
|
|
64
|
+
await UserInfo.newBootpaySK(uuid, current);
|
|
65
|
+
await UserInfo.setBootpayLastTime(current);
|
|
66
|
+
};
|
|
67
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
### 1.4.4
|
|
2
|
-
- 사용하지 않은 패키지 제거
|
|
3
|
-
|
|
4
|
-
### 1.4.3
|
|
5
|
-
- bootpay anlaytics api 추가
|
|
6
|
-
|
|
7
|
-
### 1.0.4
|
|
8
|
-
- typescript declare 적용
|
|
9
|
-
|
|
10
|
-
### 1.0.3
|
|
11
|
-
- close button 클릭시 onCancel, onClose 이벤트 호출
|
|
12
|
-
|
|
13
|
-
### 1.0.2
|
|
14
|
-
- callJavascript 버그 수정
|
|
15
|
-
|
|
16
|
-
### 1.0.1
|
|
17
|
-
- close.png 못찾는 버그 수정
|
|
18
|
-
|
|
19
|
-
### 1.0.0
|
|
20
|
-
- first release
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.pageTrace = exports.userTrace = void 0;
|
|
7
|
-
|
|
8
|
-
var _reactNativeBase = _interopRequireDefault(require("react-native-base64"));
|
|
9
|
-
|
|
10
|
-
var _reactNativeDeviceInfo = _interopRequireDefault(require("react-native-device-info"));
|
|
11
|
-
|
|
12
|
-
var _reactNative = require("react-native");
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
// import CryptoJS from 'crypto-js';
|
|
17
|
-
var Aes = _reactNative.NativeModules.Aes;
|
|
18
|
-
|
|
19
|
-
const userTrace = async (applicationId, userId, phone, email, gender, birth, area) => {
|
|
20
|
-
try {
|
|
21
|
-
const payload = {
|
|
22
|
-
"id": userId,
|
|
23
|
-
"ver": _reactNativeDeviceInfo.default.getVersion(),
|
|
24
|
-
"application_id": applicationId,
|
|
25
|
-
"phone": phone,
|
|
26
|
-
"email": email,
|
|
27
|
-
"gender": gender,
|
|
28
|
-
"birth": birth,
|
|
29
|
-
"area": area
|
|
30
|
-
};
|
|
31
|
-
var key = getRandomKey(32);
|
|
32
|
-
var iv = getRandomKey(16);
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
const data = await Aes.encrypt(JSON.stringify(payload), stringToHex(key), stringToHex(iv)).then(cipher => cipher);
|
|
36
|
-
const response = await fetch('https://analytics.bootpay.co.kr/login', {
|
|
37
|
-
method: 'POST',
|
|
38
|
-
headers: {
|
|
39
|
-
Accept: 'application/json',
|
|
40
|
-
'Content-Type': 'application/json'
|
|
41
|
-
},
|
|
42
|
-
body: JSON.stringify({
|
|
43
|
-
data: data,
|
|
44
|
-
session_key: await getSessionKey(key, iv)
|
|
45
|
-
})
|
|
46
|
-
});
|
|
47
|
-
const json = await response.json();
|
|
48
|
-
return json;
|
|
49
|
-
} catch (e) {
|
|
50
|
-
console.log(e);
|
|
51
|
-
}
|
|
52
|
-
} catch (error) {
|
|
53
|
-
console.error(error);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
exports.userTrace = userTrace;
|
|
58
|
-
|
|
59
|
-
const pageTrace = async (applicationId, url, pageType, items) => {
|
|
60
|
-
try {
|
|
61
|
-
const payload = {
|
|
62
|
-
"application_id": applicationId,
|
|
63
|
-
"url": url,
|
|
64
|
-
"page_type": pageType,
|
|
65
|
-
"items": items,
|
|
66
|
-
"referer": ''
|
|
67
|
-
};
|
|
68
|
-
var key = getRandomKey(32);
|
|
69
|
-
var iv = getRandomKey(16);
|
|
70
|
-
|
|
71
|
-
try {
|
|
72
|
-
const data = await Aes.encrypt(JSON.stringify(payload), stringToHex(key), stringToHex(iv)).then(cipher => cipher);
|
|
73
|
-
const response = await fetch('https://analytics.bootpay.co.kr/call', {
|
|
74
|
-
method: 'POST',
|
|
75
|
-
headers: {
|
|
76
|
-
Accept: 'application/json',
|
|
77
|
-
'Content-Type': 'application/json'
|
|
78
|
-
},
|
|
79
|
-
body: JSON.stringify({
|
|
80
|
-
data: data,
|
|
81
|
-
session_key: await getSessionKey(key, iv)
|
|
82
|
-
})
|
|
83
|
-
});
|
|
84
|
-
const json = await response.json();
|
|
85
|
-
return json;
|
|
86
|
-
} catch (e) {
|
|
87
|
-
console.log(e);
|
|
88
|
-
}
|
|
89
|
-
} catch (error) {
|
|
90
|
-
console.error(error);
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
exports.pageTrace = pageTrace;
|
|
95
|
-
|
|
96
|
-
const stringToHex = str => {
|
|
97
|
-
var hex = '';
|
|
98
|
-
|
|
99
|
-
for (var i = 0, l = str.length; i < l; i++) {
|
|
100
|
-
hex += str.charCodeAt(i).toString(16);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return hex;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const getRandomKey = length => {
|
|
107
|
-
var text = '';
|
|
108
|
-
var keys = 'abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
109
|
-
|
|
110
|
-
for (var i = 0; i < length; i++) text += keys.charAt(Math.floor(Math.random() * keys.length));
|
|
111
|
-
|
|
112
|
-
return text;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const getSessionKey = async (key, iv) => {
|
|
116
|
-
const keyValue = _reactNativeBase.default.encode(key);
|
|
117
|
-
|
|
118
|
-
const ivValue = _reactNativeBase.default.encode(iv);
|
|
119
|
-
|
|
120
|
-
return `${keyValue}##${ivValue}`;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const strEncode = async (str, key, iv) => {
|
|
124
|
-
return await Aes.encrypt(str, key, iv).then(cipher => {
|
|
125
|
-
Aes.hmac256(cipher, key).then(hash => {
|
|
126
|
-
console.log('HMAC', hash);
|
|
127
|
-
return hash;
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
};
|
|
131
|
-
//# sourceMappingURL=BootpayAnalytics.js.map
|