@ray-js/lock-sdk 1.1.3-beta.7 → 1.1.3-beta.9
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/lib/temporary.js +71 -67
- package/package.json +1 -1
package/lib/temporary.js
CHANGED
|
@@ -13,7 +13,11 @@ const PASSWORD_REGEX = /^[0-9]+$/;
|
|
|
13
13
|
const isValidPassword = async (params) => {
|
|
14
14
|
const validateResult = await validateTempPwd(params);
|
|
15
15
|
if (!validateResult.valid) {
|
|
16
|
-
handleCloudError(
|
|
16
|
+
handleCloudError({
|
|
17
|
+
innerError: {
|
|
18
|
+
errorCode: validateResult.errorCode,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
17
21
|
}
|
|
18
22
|
return true;
|
|
19
23
|
};
|
|
@@ -49,71 +53,71 @@ export const createTempCustom = parallelOnly(async (params) => {
|
|
|
49
53
|
password: aesPwd,
|
|
50
54
|
schedule,
|
|
51
55
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const targetDpCode = config.supportBigData
|
|
84
|
-
? dpCodes.tempPwdCreateW
|
|
85
|
-
: dpCodes.tempPwdCreate;
|
|
86
|
-
const result = await publishDps({
|
|
87
|
-
[targetDpCode]: dpUtils.format(dpData, (config.supportBigData
|
|
88
|
-
? addTempPwdBigDpMap
|
|
89
|
-
: addTempPwdDpMap)),
|
|
90
|
-
}, {
|
|
91
|
-
checkReport: (dpData) => {
|
|
92
|
-
const reportData = dpData[targetDpCode];
|
|
93
|
-
if (reportData) {
|
|
94
|
-
const data = dpUtils.parse(dpData[targetDpCode], (config.supportBigData
|
|
95
|
-
? reportAddTempPwdDBigpMap
|
|
96
|
-
: reportAddTempPwdDpMap));
|
|
97
|
-
if (data.cloudNo === tyNum) {
|
|
98
|
-
return data;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return false;
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
if (result.status === 0) {
|
|
105
|
-
return {
|
|
106
|
-
type: "custom",
|
|
107
|
-
name: name,
|
|
108
|
-
password: password,
|
|
109
|
-
unlockBindingId: result.unlockBindingId,
|
|
110
|
-
effectiveConfig: effective,
|
|
56
|
+
try {
|
|
57
|
+
if (useNear) {
|
|
58
|
+
await isValidPassword(baseData);
|
|
59
|
+
const { tyNum, name } = await createTemporaryPassword({
|
|
60
|
+
...baseData,
|
|
61
|
+
sn: 0,
|
|
62
|
+
availTime: 0,
|
|
63
|
+
symbolic: false,
|
|
64
|
+
dpTunnel: 2,
|
|
65
|
+
});
|
|
66
|
+
if (!tyNum) {
|
|
67
|
+
throw getError(1043);
|
|
68
|
+
}
|
|
69
|
+
const dpData = {
|
|
70
|
+
cloudNo: tyNum,
|
|
71
|
+
valid: true,
|
|
72
|
+
validConfig: {
|
|
73
|
+
startTime: effective.effectiveDate,
|
|
74
|
+
endTime: effective.expiredDate,
|
|
75
|
+
loop: loopType,
|
|
76
|
+
loopConfig: 0,
|
|
77
|
+
weeks: effective.weeks ? effective.weeks : [0, 0, 0, 0, 0, 0, 0],
|
|
78
|
+
days: [],
|
|
79
|
+
startHour: Math.floor(effectiveTime / 60),
|
|
80
|
+
startMinute: effectiveTime % 60,
|
|
81
|
+
endHour: Math.floor(expiredTime / 60),
|
|
82
|
+
endMinute: expiredTime % 60,
|
|
83
|
+
},
|
|
84
|
+
validNum: 0,
|
|
85
|
+
pwdLength: params.password.length,
|
|
86
|
+
pwd: params.password.split("").map(Number),
|
|
111
87
|
};
|
|
88
|
+
const targetDpCode = config.supportBigData
|
|
89
|
+
? dpCodes.tempPwdCreateW
|
|
90
|
+
: dpCodes.tempPwdCreate;
|
|
91
|
+
const result = await publishDps({
|
|
92
|
+
[targetDpCode]: dpUtils.format(dpData, (config.supportBigData
|
|
93
|
+
? addTempPwdBigDpMap
|
|
94
|
+
: addTempPwdDpMap)),
|
|
95
|
+
}, {
|
|
96
|
+
checkReport: (dpData) => {
|
|
97
|
+
const reportData = dpData[targetDpCode];
|
|
98
|
+
if (reportData) {
|
|
99
|
+
const data = dpUtils.parse(dpData[targetDpCode], (config.supportBigData
|
|
100
|
+
? reportAddTempPwdDBigpMap
|
|
101
|
+
: reportAddTempPwdDpMap));
|
|
102
|
+
if (data.cloudNo === tyNum) {
|
|
103
|
+
return data;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return false;
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
if (result.status === 0) {
|
|
110
|
+
return {
|
|
111
|
+
type: "custom",
|
|
112
|
+
name: name,
|
|
113
|
+
password: password,
|
|
114
|
+
unlockBindingId: result.unlockBindingId,
|
|
115
|
+
effectiveConfig: effective,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
throw getError(result.status === 2 ? 1041 : 1042);
|
|
112
119
|
}
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
try {
|
|
120
|
+
else {
|
|
117
121
|
const res = await createTemporaryPassword({
|
|
118
122
|
...baseData,
|
|
119
123
|
sn: 0,
|
|
@@ -129,9 +133,9 @@ export const createTempCustom = parallelOnly(async (params) => {
|
|
|
129
133
|
effectiveConfig: effective,
|
|
130
134
|
};
|
|
131
135
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
throw handleCloudError(error);
|
|
135
139
|
}
|
|
136
140
|
});
|
|
137
141
|
export const removeTempCustom = async (params) => {
|