yakuza0 2.23.44 → 2.23.45-beta.8
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/nuxt/plugins/init_server.js +2 -2
- package/package.json +3 -2
- package/template/http.plugin.js +16 -0
- package/template/init.plugin.js +3 -3
- package/utils/httpDebug.js +31 -3
|
@@ -93,8 +93,8 @@ exports.default = function () {
|
|
|
93
93
|
_context.prev = 9;
|
|
94
94
|
_context.t0 = _context['catch'](3);
|
|
95
95
|
|
|
96
|
-
(0, _httpDebug.
|
|
97
|
-
|
|
96
|
+
(0, _httpDebug.httpSsrFailureLog)({
|
|
97
|
+
req: ctx.req,
|
|
98
98
|
stage: 'NUXT_SERVER_INIT_ACTION_ERROR',
|
|
99
99
|
data: {
|
|
100
100
|
action: key,
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yakuza0",
|
|
3
|
-
"version": "2.23.
|
|
3
|
+
"version": "2.23.45-beta.8",
|
|
4
4
|
"description": "yakuza0 with nuxt",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"base": "babel --no-babelrc src -d /Users/ningfujun/work/repo/web/CLN_BASE_TEST/node_modules/yakuza0 -w --presets=env --plugins=transform-runtime,transform-object-rest-spread,add-module-exports",
|
|
8
8
|
"build": "babel --no-babelrc src -d . --presets=env --plugins=transform-runtime,transform-object-rest-spread,add-module-exports",
|
|
9
|
-
"pub:beta": "npm run build && npm version prerelease --preid=beta &&
|
|
9
|
+
"pub:beta": "npm run build && npm version prerelease --preid=beta && npm publish --no-git-check",
|
|
10
10
|
"pub:hotfix": "npm run build && npm version prerelease --preid=hotfix && npm publish --tag hotfix",
|
|
11
11
|
"pub": "npm run build && npm version patch && npm publish",
|
|
12
12
|
"test": "jest",
|
|
13
|
+
"test:ssr": "node tests/zunir-ssr.js",
|
|
13
14
|
"postinstall": "yk init"
|
|
14
15
|
},
|
|
15
16
|
"author": "nfjbill",
|
package/template/http.plugin.js
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
getHttpDebugTrace,
|
|
9
9
|
HTTP_DEBUG_HEADER,
|
|
10
10
|
httpDebugLog,
|
|
11
|
+
httpSsrFailureLog,
|
|
11
12
|
sanitizeHttpDebugHeaders,
|
|
12
13
|
} from 'yakuza0/utils/httpDebug';
|
|
13
14
|
|
|
@@ -213,6 +214,7 @@ export default (ctx, inject) => {
|
|
|
213
214
|
: undefined,
|
|
214
215
|
status: res.response && res.response.status,
|
|
215
216
|
responseType: typeof res.data,
|
|
217
|
+
fromCache: Boolean((res.data && res.data.isUseFeCache) || (res.headers && res.headers.get('x-slc') === '1')),
|
|
216
218
|
headers: sanitizeHttpDebugHeaders(res.headers),
|
|
217
219
|
},
|
|
218
220
|
});
|
|
@@ -226,6 +228,20 @@ export default (ctx, inject) => {
|
|
|
226
228
|
},
|
|
227
229
|
async error(err) {
|
|
228
230
|
const responseConfig = err.response && err.response.config || {};
|
|
231
|
+
if (checkServer() && /(?:^|\/)(?:auth\/isc\/ticket|(?:open\/)?system\/fornt\/params)(?:[?]|$)/.test(responseConfig.url || '')) {
|
|
232
|
+
httpSsrFailureLog({
|
|
233
|
+
req,
|
|
234
|
+
stage: 'SSR_PLATFORM_REQUEST_FAILED',
|
|
235
|
+
data: {
|
|
236
|
+
method: responseConfig.method,
|
|
237
|
+
url: responseConfig.url,
|
|
238
|
+
prefixUrl: responseConfig.prefixUrl || prefixUrl,
|
|
239
|
+
status: err.response && err.response.status,
|
|
240
|
+
apiCode: err.response && err.response.data && err.response.data.code,
|
|
241
|
+
},
|
|
242
|
+
error: err,
|
|
243
|
+
});
|
|
244
|
+
}
|
|
229
245
|
httpDebugLog({
|
|
230
246
|
trace: httpDebugTrace,
|
|
231
247
|
stage: 'HTTP_ERROR',
|
package/template/init.plugin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {set} from 'yakuza0/utils/secret';
|
|
2
|
-
import {getHttpDebugTrace, httpDebugLog} from 'yakuza0/utils/httpDebug';
|
|
2
|
+
import {getHttpDebugTrace, httpDebugLog, httpSsrFailureLog} from 'yakuza0/utils/httpDebug';
|
|
3
3
|
|
|
4
4
|
export default async (ctx, inject) => {
|
|
5
5
|
const trace = getHttpDebugTrace({req: ctx.req});
|
|
@@ -23,8 +23,8 @@ export default async (ctx, inject) => {
|
|
|
23
23
|
},
|
|
24
24
|
});
|
|
25
25
|
} catch (error) {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
httpSsrFailureLog({
|
|
27
|
+
req: ctx.req,
|
|
28
28
|
stage: 'SECRET_INIT_ERROR',
|
|
29
29
|
data: {
|
|
30
30
|
elapsedMs: Date.now() - startedAt,
|
package/utils/httpDebug.js
CHANGED
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.httpDebugLog = exports.sanitizeHttpDebugHeaders = exports.isHttpDebugEnabled = exports.getHttpDebugTrace = exports.HTTP_DEBUG_HEADER = exports.HTTP_DEBUG_COOKIE_KEY = undefined;
|
|
6
|
+
exports.httpSsrFailureLog = exports.httpDebugLog = exports.sanitizeHttpDebugData = exports.sanitizeHttpDebugHeaders = exports.isHttpDebugEnabled = exports.getHttpDebugTrace = exports.HTTP_DEBUG_HEADER = exports.HTTP_DEBUG_COOKIE_KEY = undefined;
|
|
7
7
|
|
|
8
8
|
var _extends2 = require('babel-runtime/helpers/extends');
|
|
9
9
|
|
|
10
10
|
var _extends3 = _interopRequireDefault(_extends2);
|
|
11
11
|
|
|
12
|
+
var _typeof2 = require('babel-runtime/helpers/typeof');
|
|
13
|
+
|
|
14
|
+
var _typeof3 = _interopRequireDefault(_typeof2);
|
|
15
|
+
|
|
12
16
|
var _keys = require('babel-runtime/core-js/object/keys');
|
|
13
17
|
|
|
14
18
|
var _keys2 = _interopRequireDefault(_keys);
|
|
@@ -74,7 +78,7 @@ var isHttpDebugEnabled = exports.isHttpDebugEnabled = function isHttpDebugEnable
|
|
|
74
78
|
};
|
|
75
79
|
|
|
76
80
|
var sensitiveHeader = function sensitiveHeader(key) {
|
|
77
|
-
return (/cookie|authorization|token|secret|password|csrf|signature|x-xss-sm|x-rpk|x-ssr-verify/i.test(key)
|
|
81
|
+
return (/cookie|authorization|token|secret|password|csrf|signature|x-xss-sm|x-rpk|x-ssr-verify|x-verify-ssr/i.test(key)
|
|
78
82
|
);
|
|
79
83
|
};
|
|
80
84
|
|
|
@@ -110,6 +114,21 @@ var sanitizeHttpDebugHeaders = exports.sanitizeHttpDebugHeaders = function sanit
|
|
|
110
114
|
return result;
|
|
111
115
|
};
|
|
112
116
|
|
|
117
|
+
// Trace URLs can contain one-use ISC tickets; mask these even in opt-in logs.
|
|
118
|
+
var sanitizeHttpDebugData = exports.sanitizeHttpDebugData = function sanitizeHttpDebugData(value) {
|
|
119
|
+
if (typeof value === 'string') {
|
|
120
|
+
return value.replace(/(^|[?&])((?:ticket|access_token|refresh_token|token|password|secret|csrf|signature)=)[^&#\s]*/gi, '$1$2[redacted]');
|
|
121
|
+
}
|
|
122
|
+
if (Array.isArray(value)) return value.map(sanitizeHttpDebugData);
|
|
123
|
+
if (value && (typeof value === 'undefined' ? 'undefined' : (0, _typeof3.default)(value)) === 'object') {
|
|
124
|
+
return (0, _keys2.default)(value).reduce(function (result, key) {
|
|
125
|
+
result[key] = /^(?:ticket|access_token|refresh_token|token|password|secret|csrf|signature)$/i.test(key) ? '[redacted]' : sanitizeHttpDebugData(value[key]);
|
|
126
|
+
return result;
|
|
127
|
+
}, {});
|
|
128
|
+
}
|
|
129
|
+
return value;
|
|
130
|
+
};
|
|
131
|
+
|
|
113
132
|
var serializeError = function serializeError(error) {
|
|
114
133
|
if (!error) {
|
|
115
134
|
return error;
|
|
@@ -147,7 +166,7 @@ var httpDebugLog = exports.httpDebugLog = function httpDebugLog(_ref2) {
|
|
|
147
166
|
pid: typeof process !== 'undefined' && process ? process.pid : undefined,
|
|
148
167
|
stage: stage
|
|
149
168
|
}, data || {}, error ? { error: serializeError(error) } : {});
|
|
150
|
-
var output = '[YK_HTTP_DEBUG][' + debugTrace + '][' + stage + '] ' + (0, _stringify2.default)(payload);
|
|
169
|
+
var output = '[YK_HTTP_DEBUG][' + debugTrace + '][' + stage + '] ' + (0, _stringify2.default)(sanitizeHttpDebugData(payload));
|
|
151
170
|
|
|
152
171
|
if (error) {
|
|
153
172
|
nativeConsole.error(output);
|
|
@@ -156,4 +175,13 @@ var httpDebugLog = exports.httpDebugLog = function httpDebugLog(_ref2) {
|
|
|
156
175
|
}
|
|
157
176
|
|
|
158
177
|
return true;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// Failures before a business API reaches platform must remain visible even
|
|
181
|
+
// when the temporary debug cookie is absent. Successful requests stay quiet.
|
|
182
|
+
var httpSsrFailureLog = exports.httpSsrFailureLog = function httpSsrFailureLog(options) {
|
|
183
|
+
if (!(0, _yakuza.checkServer)()) return false;
|
|
184
|
+
return httpDebugLog((0, _extends3.default)({}, options, {
|
|
185
|
+
trace: getHttpDebugTrace(options) || 'SSR_FAILURE'
|
|
186
|
+
}));
|
|
159
187
|
};
|