@netacea/netaceaintegrationbase 2.0.111 → 2.0.112
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/dist/index.cjs +27 -12
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +27 -12
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -129,7 +129,12 @@ const captchaMap = {
|
|
|
129
129
|
4: 'captcha_cookiepass',
|
|
130
130
|
5: 'captcha_cookiefail',
|
|
131
131
|
6: 'checkpoint_signal',
|
|
132
|
-
7: 'checkpoint_post'
|
|
132
|
+
7: 'checkpoint_post',
|
|
133
|
+
a: 'checkpoint_serve',
|
|
134
|
+
b: 'checkpoint_pass',
|
|
135
|
+
c: 'checkpoint_fail',
|
|
136
|
+
d: 'checkpoint_cookiepass',
|
|
137
|
+
e: 'checkpoint_cookiefail'
|
|
133
138
|
};
|
|
134
139
|
const captchaStatusCodes = {
|
|
135
140
|
'': 0,
|
|
@@ -139,7 +144,12 @@ const captchaStatusCodes = {
|
|
|
139
144
|
captchaCookiePass: 4,
|
|
140
145
|
captchaCookieFail: 5,
|
|
141
146
|
checkpointSignal: 6,
|
|
142
|
-
checkpointPost: 7
|
|
147
|
+
checkpointPost: 7,
|
|
148
|
+
checkpointServe: 'a',
|
|
149
|
+
checkpointPass: 'b',
|
|
150
|
+
checkpointFail: 'c',
|
|
151
|
+
checkpointCookiePass: 'd',
|
|
152
|
+
checkpointCookieFail: 'e'
|
|
143
153
|
};
|
|
144
154
|
const bestMitigationMap = {
|
|
145
155
|
0: mitigationTypes.none,
|
|
@@ -154,8 +164,13 @@ const bestMitigationCaptchaMap = {
|
|
|
154
164
|
3: mitigationTypes.captcha,
|
|
155
165
|
4: mitigationTypes.allow,
|
|
156
166
|
5: mitigationTypes.captcha,
|
|
157
|
-
6: mitigationTypes.
|
|
158
|
-
7: mitigationTypes.captcha
|
|
167
|
+
6: mitigationTypes.allow,
|
|
168
|
+
7: mitigationTypes.captcha,
|
|
169
|
+
a: mitigationTypes.captcha,
|
|
170
|
+
b: mitigationTypes.captchaPass,
|
|
171
|
+
c: mitigationTypes.captcha,
|
|
172
|
+
d: mitigationTypes.allow,
|
|
173
|
+
e: mitigationTypes.captcha
|
|
159
174
|
};
|
|
160
175
|
const netaceaCookieV3KeyMap = {
|
|
161
176
|
clientIP: 'cip',
|
|
@@ -198,12 +213,12 @@ var dictionary = /*#__PURE__*/Object.freeze({
|
|
|
198
213
|
// & a new MITIGATE cookie will be set
|
|
199
214
|
const ingestIgnoredIpValue = 'ignored';
|
|
200
215
|
const BASE_62_CHARSET = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
|
|
201
|
-
const
|
|
216
|
+
const sessionCookieRegExp = /^(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/((\d|[a-z])(\d)(\d|[a-z]))$/i;
|
|
202
217
|
function matchMitataCookie(netaceaCookie) {
|
|
203
218
|
if (netaceaCookie === undefined) {
|
|
204
219
|
return undefined;
|
|
205
220
|
}
|
|
206
|
-
const matches = netaceaCookie.match(
|
|
221
|
+
const matches = netaceaCookie.match(sessionCookieRegExp);
|
|
207
222
|
if (matches !== null && matches !== undefined) {
|
|
208
223
|
const [, signature, expiry, userId, ipHash, mitigationType, match, mitigate, captcha] = matches;
|
|
209
224
|
return {
|
|
@@ -275,10 +290,10 @@ function checkMitataCookie(netaceaCookie, clientIP, secretKey) {
|
|
|
275
290
|
].join(COOKIEDELIMITER);
|
|
276
291
|
const currentUnixTime = Math.floor(Date.now() / 1000);
|
|
277
292
|
const isExpired = parseInt(mitata.expiry) < currentUnixTime;
|
|
278
|
-
// serve, fail, cookiefail
|
|
279
|
-
const
|
|
293
|
+
// serve, fail, cookiefail, checkpoint_serve, checkpoint_fail, checkpoint_cookiefail
|
|
294
|
+
const isCaptchaOrCheckpointServe = ['1', '3', '5', 'a', 'c', 'e'].includes(mitata.captcha);
|
|
280
295
|
const isHardBlocked = mitata.mitigate === '3';
|
|
281
|
-
const shouldExpire =
|
|
296
|
+
const shouldExpire = isCaptchaOrCheckpointServe || isHardBlocked;
|
|
282
297
|
const currentIPHash = hexSha256(clientIP + '|' + mitata.expiry, secretKey);
|
|
283
298
|
const isSameIP = mitata.ipHash === currentIPHash;
|
|
284
299
|
const valid = mitata.signature === hexSha256(mitSvcStringValue, secretKey);
|
|
@@ -343,10 +358,10 @@ function checkNetaceaCookieV3(netaceaCookie, clientIP) {
|
|
|
343
358
|
const expiryTimestamp = netaceaCookieV3.issueTimestamp + netaceaCookieV3.gracePeriod;
|
|
344
359
|
const isExpired = expiryTimestamp < currentUnixTime;
|
|
345
360
|
const isSameIP = clientIP === netaceaCookieV3.clientIP;
|
|
346
|
-
// serve, fail, cookiefail
|
|
347
|
-
const
|
|
361
|
+
// serve, fail, cookiefail, checkpoint_serve, checkpoint_fail, checkpoint_cookiefail
|
|
362
|
+
const isCaptchaOrCheckpointServe = ['1', '3', '5', 'a', 'c', 'e'].includes(netaceaCookieV3.captcha);
|
|
348
363
|
const isHardBlocked = netaceaCookieV3.mitigate === '3';
|
|
349
|
-
const shouldExpire =
|
|
364
|
+
const shouldExpire = isCaptchaOrCheckpointServe || isHardBlocked;
|
|
350
365
|
return {
|
|
351
366
|
mitata: netaceaCookieV3,
|
|
352
367
|
requiresReissue: isExpired || !isSameIP,
|
package/dist/index.d.ts
CHANGED
|
@@ -489,7 +489,7 @@ declare const netaceaHeaders: {
|
|
|
489
489
|
declare const matchMap: Record<string, string | undefined>;
|
|
490
490
|
declare const mitigateMap: Record<string, string | undefined>;
|
|
491
491
|
declare const captchaMap: Record<string, string | undefined>;
|
|
492
|
-
declare const captchaStatusCodes: Record<string, number | undefined>;
|
|
492
|
+
declare const captchaStatusCodes: Record<string, number | string | undefined>;
|
|
493
493
|
declare const bestMitigationMap: Record<string, string>;
|
|
494
494
|
declare const bestMitigationCaptchaMap: Record<string, string | undefined>;
|
|
495
495
|
declare const netaceaCookieV3KeyMap: Record<string, string>;
|
package/dist/index.mjs
CHANGED
|
@@ -127,7 +127,12 @@ const captchaMap = {
|
|
|
127
127
|
4: 'captcha_cookiepass',
|
|
128
128
|
5: 'captcha_cookiefail',
|
|
129
129
|
6: 'checkpoint_signal',
|
|
130
|
-
7: 'checkpoint_post'
|
|
130
|
+
7: 'checkpoint_post',
|
|
131
|
+
a: 'checkpoint_serve',
|
|
132
|
+
b: 'checkpoint_pass',
|
|
133
|
+
c: 'checkpoint_fail',
|
|
134
|
+
d: 'checkpoint_cookiepass',
|
|
135
|
+
e: 'checkpoint_cookiefail'
|
|
131
136
|
};
|
|
132
137
|
const captchaStatusCodes = {
|
|
133
138
|
'': 0,
|
|
@@ -137,7 +142,12 @@ const captchaStatusCodes = {
|
|
|
137
142
|
captchaCookiePass: 4,
|
|
138
143
|
captchaCookieFail: 5,
|
|
139
144
|
checkpointSignal: 6,
|
|
140
|
-
checkpointPost: 7
|
|
145
|
+
checkpointPost: 7,
|
|
146
|
+
checkpointServe: 'a',
|
|
147
|
+
checkpointPass: 'b',
|
|
148
|
+
checkpointFail: 'c',
|
|
149
|
+
checkpointCookiePass: 'd',
|
|
150
|
+
checkpointCookieFail: 'e'
|
|
141
151
|
};
|
|
142
152
|
const bestMitigationMap = {
|
|
143
153
|
0: mitigationTypes.none,
|
|
@@ -152,8 +162,13 @@ const bestMitigationCaptchaMap = {
|
|
|
152
162
|
3: mitigationTypes.captcha,
|
|
153
163
|
4: mitigationTypes.allow,
|
|
154
164
|
5: mitigationTypes.captcha,
|
|
155
|
-
6: mitigationTypes.
|
|
156
|
-
7: mitigationTypes.captcha
|
|
165
|
+
6: mitigationTypes.allow,
|
|
166
|
+
7: mitigationTypes.captcha,
|
|
167
|
+
a: mitigationTypes.captcha,
|
|
168
|
+
b: mitigationTypes.captchaPass,
|
|
169
|
+
c: mitigationTypes.captcha,
|
|
170
|
+
d: mitigationTypes.allow,
|
|
171
|
+
e: mitigationTypes.captcha
|
|
157
172
|
};
|
|
158
173
|
const netaceaCookieV3KeyMap = {
|
|
159
174
|
clientIP: 'cip',
|
|
@@ -196,12 +211,12 @@ var dictionary = /*#__PURE__*/Object.freeze({
|
|
|
196
211
|
// & a new MITIGATE cookie will be set
|
|
197
212
|
const ingestIgnoredIpValue = 'ignored';
|
|
198
213
|
const BASE_62_CHARSET = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
|
|
199
|
-
const
|
|
214
|
+
const sessionCookieRegExp = /^(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/((\d|[a-z])(\d)(\d|[a-z]))$/i;
|
|
200
215
|
function matchMitataCookie(netaceaCookie) {
|
|
201
216
|
if (netaceaCookie === undefined) {
|
|
202
217
|
return undefined;
|
|
203
218
|
}
|
|
204
|
-
const matches = netaceaCookie.match(
|
|
219
|
+
const matches = netaceaCookie.match(sessionCookieRegExp);
|
|
205
220
|
if (matches !== null && matches !== undefined) {
|
|
206
221
|
const [, signature, expiry, userId, ipHash, mitigationType, match, mitigate, captcha] = matches;
|
|
207
222
|
return {
|
|
@@ -273,10 +288,10 @@ function checkMitataCookie(netaceaCookie, clientIP, secretKey) {
|
|
|
273
288
|
].join(COOKIEDELIMITER);
|
|
274
289
|
const currentUnixTime = Math.floor(Date.now() / 1000);
|
|
275
290
|
const isExpired = parseInt(mitata.expiry) < currentUnixTime;
|
|
276
|
-
// serve, fail, cookiefail
|
|
277
|
-
const
|
|
291
|
+
// serve, fail, cookiefail, checkpoint_serve, checkpoint_fail, checkpoint_cookiefail
|
|
292
|
+
const isCaptchaOrCheckpointServe = ['1', '3', '5', 'a', 'c', 'e'].includes(mitata.captcha);
|
|
278
293
|
const isHardBlocked = mitata.mitigate === '3';
|
|
279
|
-
const shouldExpire =
|
|
294
|
+
const shouldExpire = isCaptchaOrCheckpointServe || isHardBlocked;
|
|
280
295
|
const currentIPHash = hexSha256(clientIP + '|' + mitata.expiry, secretKey);
|
|
281
296
|
const isSameIP = mitata.ipHash === currentIPHash;
|
|
282
297
|
const valid = mitata.signature === hexSha256(mitSvcStringValue, secretKey);
|
|
@@ -341,10 +356,10 @@ function checkNetaceaCookieV3(netaceaCookie, clientIP) {
|
|
|
341
356
|
const expiryTimestamp = netaceaCookieV3.issueTimestamp + netaceaCookieV3.gracePeriod;
|
|
342
357
|
const isExpired = expiryTimestamp < currentUnixTime;
|
|
343
358
|
const isSameIP = clientIP === netaceaCookieV3.clientIP;
|
|
344
|
-
// serve, fail, cookiefail
|
|
345
|
-
const
|
|
359
|
+
// serve, fail, cookiefail, checkpoint_serve, checkpoint_fail, checkpoint_cookiefail
|
|
360
|
+
const isCaptchaOrCheckpointServe = ['1', '3', '5', 'a', 'c', 'e'].includes(netaceaCookieV3.captcha);
|
|
346
361
|
const isHardBlocked = netaceaCookieV3.mitigate === '3';
|
|
347
|
-
const shouldExpire =
|
|
362
|
+
const shouldExpire = isCaptchaOrCheckpointServe || isHardBlocked;
|
|
348
363
|
return {
|
|
349
364
|
mitata: netaceaCookieV3,
|
|
350
365
|
requiresReissue: isExpired || !isSameIP,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netacea/netaceaintegrationbase",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.112",
|
|
4
4
|
"description": "Base package for Netacea CDN integrations.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"license": "UNLICENSED",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@netacea/kinesisingest": "^1.5.
|
|
27
|
+
"@netacea/kinesisingest": "^1.5.130"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "e67582bc480520a13813be839e8e0b9acaba7548"
|
|
30
30
|
}
|