@netacea/netaceaintegrationbase 2.0.63 → 2.0.65

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 CHANGED
@@ -112,7 +112,7 @@ const matchMap = {
112
112
  7: 'asn_',
113
113
  8: 'country_',
114
114
  9: 'combination_',
115
- 11: 'headerFP_' // b (base36)
115
+ b: 'headerFP_'
116
116
  };
117
117
  const mitigateMap = {
118
118
  0: '',
@@ -206,9 +206,9 @@ function matchMitataCookie(netaceaCookie) {
206
206
  userId,
207
207
  ipHash,
208
208
  mitigationType,
209
- match: parseInt(match, 36),
210
- mitigate: parseInt(mitigate),
211
- captcha: parseInt(captcha)
209
+ match,
210
+ mitigate,
211
+ captcha
212
212
  };
213
213
  }
214
214
  return undefined;
@@ -254,9 +254,9 @@ function checkMitataCookie(netaceaCookie, clientIP, secretKey) {
254
254
  shouldExpire: false,
255
255
  isSameIP: false,
256
256
  isPrimaryHashValid: false,
257
- captcha: 0,
258
- match: 0,
259
- mitigate: 0
257
+ captcha: '0',
258
+ match: '0',
259
+ mitigate: '0'
260
260
  };
261
261
  if (typeof netaceaCookie !== 'string' || netaceaCookie === '') {
262
262
  return defaultInvalidResponse;
@@ -270,8 +270,8 @@ function checkMitataCookie(netaceaCookie, clientIP, secretKey) {
270
270
  const currentUnixTime = Math.floor(Date.now() / 1000);
271
271
  const isExpired = parseInt(mitata.expiry) < currentUnixTime;
272
272
  // serve, fail, cookiefail
273
- const isCaptchaServe = [1, 3, 5].includes(mitata.captcha);
274
- const isHardBlocked = mitata.mitigate === 3;
273
+ const isCaptchaServe = ['1', '3', '5'].includes(mitata.captcha);
274
+ const isHardBlocked = mitata.mitigate === '3';
275
275
  const shouldExpire = isCaptchaServe || isHardBlocked;
276
276
  const currentIPHash = hexSha256(clientIP + '|' + mitata.expiry, secretKey);
277
277
  const isSameIP = mitata.ipHash === currentIPHash;
@@ -338,8 +338,8 @@ function checkNetaceaCookieV3(netaceaCookie, clientIP) {
338
338
  const isExpired = expiryTimestamp < currentUnixTime;
339
339
  const isSameIP = clientIP === netaceaCookieV3.clientIP;
340
340
  // serve, fail, cookiefail
341
- const isCaptchaServe = [1, 3, 5].includes(netaceaCookieV3.captcha);
342
- const isHardBlocked = netaceaCookieV3.mitigate === 3;
341
+ const isCaptchaServe = ['1', '3', '5'].includes(netaceaCookieV3.captcha);
342
+ const isHardBlocked = netaceaCookieV3.mitigate === '3';
343
343
  const shouldExpire = isCaptchaServe || isHardBlocked;
344
344
  return {
345
345
  mitata: netaceaCookieV3,
@@ -366,9 +366,9 @@ function matchNetaceaCookieV3(netaceaCookie) {
366
366
  userId: '',
367
367
  cookieId: '',
368
368
  gracePeriod: 0,
369
- match: 0,
370
- mitigate: 0,
371
- captcha: 0,
369
+ match: '0',
370
+ mitigate: '0',
371
+ captcha: '0',
372
372
  issueTimestamp: 0,
373
373
  issueReason: '',
374
374
  checkAllPostRequests: undefined
@@ -380,8 +380,14 @@ function matchNetaceaCookieV3(netaceaCookie) {
380
380
  if (fullKey === undefined) {
381
381
  fullKey = Object.keys(netaceaCookieV3OptionalKeyMap).find(k => netaceaCookieV3OptionalKeyMap[k] === key);
382
382
  }
383
- let parsedValue = value === '' ? undefined : Number(value);
384
- if (parsedValue !== undefined && isNaN(parsedValue)) {
383
+ let parsedValue;
384
+ if (fullKey !== undefined && ['match', 'mitigate', 'captcha'].includes(fullKey)) {
385
+ parsedValue = value === '' ? undefined : value;
386
+ }
387
+ else {
388
+ parsedValue = value === '' ? undefined : Number(value);
389
+ }
390
+ if (parsedValue !== undefined && typeof parsedValue !== 'string' && isNaN(parsedValue)) {
385
391
  parsedValue = value;
386
392
  }
387
393
  cookieParams[fullKey] = parsedValue;
@@ -396,9 +402,9 @@ function defaultInvalidResponse() {
396
402
  shouldExpire: false,
397
403
  isSameIP: false,
398
404
  isPrimaryHashValid: false,
399
- captcha: 0,
400
- match: 0,
401
- mitigate: 0,
405
+ captcha: '0',
406
+ match: '0',
407
+ mitigate: '0',
402
408
  issueReason: exports.NetaceaCookieV3IssueReason.NO_SESSION
403
409
  };
404
410
  }
package/dist/index.d.ts CHANGED
@@ -367,32 +367,32 @@ interface NetaceaCookieV3 extends NetaceaCookieV3OptionalFeatures {
367
367
  userId: string;
368
368
  cookieId: string;
369
369
  gracePeriod: number;
370
- match: number;
371
- mitigate: number;
372
- captcha: number;
370
+ match: string;
371
+ mitigate: string;
372
+ captcha: string;
373
373
  issueTimestamp: number;
374
374
  issueReason: string;
375
375
  }
376
- interface MitataCookie$1 {
376
+ interface MitataCookie {
377
377
  signature: string;
378
378
  expiry: string;
379
379
  userId: string;
380
380
  ipHash: string;
381
381
  mitigationType: string;
382
- match: number;
383
- mitigate: number;
384
- captcha: number;
382
+ match: string;
383
+ mitigate: string;
384
+ captcha: string;
385
385
  }
386
386
  interface CheckCookieResponse$1 {
387
- mitata: MitataCookie$1 | NetaceaCookieV3 | undefined;
387
+ mitata: MitataCookie | NetaceaCookieV3 | undefined;
388
388
  requiresReissue: boolean;
389
389
  isExpired: boolean;
390
390
  shouldExpire: boolean;
391
391
  isSameIP: boolean;
392
392
  isPrimaryHashValid: boolean;
393
- match: number;
394
- mitigate: number;
395
- captcha: number;
393
+ match: string;
394
+ mitigate: string;
395
+ captcha: string;
396
396
  issueReason: NetaceaCookieV3IssueReason;
397
397
  }
398
398
  interface FindBestMitigationResponse {
@@ -401,9 +401,9 @@ interface FindBestMitigationResponse {
401
401
  parts: NetaceaParts;
402
402
  }
403
403
  interface NetaceaParts {
404
- match: number;
405
- mitigate: number;
406
- captcha: number;
404
+ match: string;
405
+ mitigate: string;
406
+ captcha: string;
407
407
  }
408
408
  interface APICallResponse {
409
409
  status: number;
@@ -427,16 +427,6 @@ interface ProcessMitigateRequestArgs {
427
427
  }
428
428
 
429
429
  declare const ingestIgnoredIpValue = "ignored";
430
- interface MitataCookie {
431
- signature: string;
432
- expiry: string;
433
- userId: string;
434
- ipHash: string;
435
- mitigationType: string;
436
- match: number;
437
- mitigate: number;
438
- captcha: number;
439
- }
440
430
  interface CheckCookieResponse {
441
431
  mitata: MitataCookie | NetaceaCookieV3 | undefined;
442
432
  requiresReissue: boolean;
@@ -444,9 +434,9 @@ interface CheckCookieResponse {
444
434
  shouldExpire: boolean;
445
435
  isSameIP: boolean;
446
436
  isPrimaryHashValid: boolean;
447
- match: number;
448
- mitigate: number;
449
- captcha: number;
437
+ match: string;
438
+ mitigate: string;
439
+ captcha: string;
450
440
  issueReason?: NetaceaCookieV3IssueReason;
451
441
  userId?: string | undefined;
452
442
  }
@@ -487,12 +477,12 @@ declare const netaceaHeaders: {
487
477
  mitataCaptchaExpiry: string;
488
478
  eventId: string;
489
479
  };
490
- declare const matchMap: Record<number, string | undefined>;
491
- declare const mitigateMap: Record<number, string | undefined>;
492
- declare const captchaMap: Record<number, string | undefined>;
480
+ declare const matchMap: Record<string, string | undefined>;
481
+ declare const mitigateMap: Record<string, string | undefined>;
482
+ declare const captchaMap: Record<string, string | undefined>;
493
483
  declare const captchaStatusCodes: Record<string, number | undefined>;
494
- declare const bestMitigationMap: Record<number, string>;
495
- declare const bestMitigationCaptchaMap: Record<number, string | undefined>;
484
+ declare const bestMitigationMap: Record<string, string>;
485
+ declare const bestMitigationCaptchaMap: Record<string, string | undefined>;
496
486
  declare const netaceaCookieV3KeyMap: Record<string, string>;
497
487
  declare const netaceaCookieV3OptionalKeyMap: Record<string, string>;
498
488
  declare const netaceaSettingsMap: Record<string, string>;
package/dist/index.mjs CHANGED
@@ -110,7 +110,7 @@ const matchMap = {
110
110
  7: 'asn_',
111
111
  8: 'country_',
112
112
  9: 'combination_',
113
- 11: 'headerFP_' // b (base36)
113
+ b: 'headerFP_'
114
114
  };
115
115
  const mitigateMap = {
116
116
  0: '',
@@ -204,9 +204,9 @@ function matchMitataCookie(netaceaCookie) {
204
204
  userId,
205
205
  ipHash,
206
206
  mitigationType,
207
- match: parseInt(match, 36),
208
- mitigate: parseInt(mitigate),
209
- captcha: parseInt(captcha)
207
+ match,
208
+ mitigate,
209
+ captcha
210
210
  };
211
211
  }
212
212
  return undefined;
@@ -252,9 +252,9 @@ function checkMitataCookie(netaceaCookie, clientIP, secretKey) {
252
252
  shouldExpire: false,
253
253
  isSameIP: false,
254
254
  isPrimaryHashValid: false,
255
- captcha: 0,
256
- match: 0,
257
- mitigate: 0
255
+ captcha: '0',
256
+ match: '0',
257
+ mitigate: '0'
258
258
  };
259
259
  if (typeof netaceaCookie !== 'string' || netaceaCookie === '') {
260
260
  return defaultInvalidResponse;
@@ -268,8 +268,8 @@ function checkMitataCookie(netaceaCookie, clientIP, secretKey) {
268
268
  const currentUnixTime = Math.floor(Date.now() / 1000);
269
269
  const isExpired = parseInt(mitata.expiry) < currentUnixTime;
270
270
  // serve, fail, cookiefail
271
- const isCaptchaServe = [1, 3, 5].includes(mitata.captcha);
272
- const isHardBlocked = mitata.mitigate === 3;
271
+ const isCaptchaServe = ['1', '3', '5'].includes(mitata.captcha);
272
+ const isHardBlocked = mitata.mitigate === '3';
273
273
  const shouldExpire = isCaptchaServe || isHardBlocked;
274
274
  const currentIPHash = hexSha256(clientIP + '|' + mitata.expiry, secretKey);
275
275
  const isSameIP = mitata.ipHash === currentIPHash;
@@ -336,8 +336,8 @@ function checkNetaceaCookieV3(netaceaCookie, clientIP) {
336
336
  const isExpired = expiryTimestamp < currentUnixTime;
337
337
  const isSameIP = clientIP === netaceaCookieV3.clientIP;
338
338
  // serve, fail, cookiefail
339
- const isCaptchaServe = [1, 3, 5].includes(netaceaCookieV3.captcha);
340
- const isHardBlocked = netaceaCookieV3.mitigate === 3;
339
+ const isCaptchaServe = ['1', '3', '5'].includes(netaceaCookieV3.captcha);
340
+ const isHardBlocked = netaceaCookieV3.mitigate === '3';
341
341
  const shouldExpire = isCaptchaServe || isHardBlocked;
342
342
  return {
343
343
  mitata: netaceaCookieV3,
@@ -364,9 +364,9 @@ function matchNetaceaCookieV3(netaceaCookie) {
364
364
  userId: '',
365
365
  cookieId: '',
366
366
  gracePeriod: 0,
367
- match: 0,
368
- mitigate: 0,
369
- captcha: 0,
367
+ match: '0',
368
+ mitigate: '0',
369
+ captcha: '0',
370
370
  issueTimestamp: 0,
371
371
  issueReason: '',
372
372
  checkAllPostRequests: undefined
@@ -378,8 +378,14 @@ function matchNetaceaCookieV3(netaceaCookie) {
378
378
  if (fullKey === undefined) {
379
379
  fullKey = Object.keys(netaceaCookieV3OptionalKeyMap).find(k => netaceaCookieV3OptionalKeyMap[k] === key);
380
380
  }
381
- let parsedValue = value === '' ? undefined : Number(value);
382
- if (parsedValue !== undefined && isNaN(parsedValue)) {
381
+ let parsedValue;
382
+ if (fullKey !== undefined && ['match', 'mitigate', 'captcha'].includes(fullKey)) {
383
+ parsedValue = value === '' ? undefined : value;
384
+ }
385
+ else {
386
+ parsedValue = value === '' ? undefined : Number(value);
387
+ }
388
+ if (parsedValue !== undefined && typeof parsedValue !== 'string' && isNaN(parsedValue)) {
383
389
  parsedValue = value;
384
390
  }
385
391
  cookieParams[fullKey] = parsedValue;
@@ -394,9 +400,9 @@ function defaultInvalidResponse() {
394
400
  shouldExpire: false,
395
401
  isSameIP: false,
396
402
  isPrimaryHashValid: false,
397
- captcha: 0,
398
- match: 0,
399
- mitigate: 0,
403
+ captcha: '0',
404
+ match: '0',
405
+ mitigate: '0',
400
406
  issueReason: NetaceaCookieV3IssueReason.NO_SESSION
401
407
  };
402
408
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netacea/netaceaintegrationbase",
3
- "version": "2.0.63",
3
+ "version": "2.0.65",
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.81"
27
+ "@netacea/kinesisingest": "^1.5.83"
28
28
  },
29
- "gitHead": "af8b8bad7175e58592762d5e08f3fca0751bb071"
29
+ "gitHead": "e14ae9cf5c67bb25f961aeed0ba51f13f2ee230c"
30
30
  }