@purespectrum1/purescore-client 0.7.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.
Files changed (136) hide show
  1. package/README.md +55 -0
  2. package/lib/application/auto-init.d.ts +44 -0
  3. package/lib/application/auto-init.js +245 -0
  4. package/lib/application/device-identifier.d.ts +116 -0
  5. package/lib/application/device-identifier.js +169 -0
  6. package/lib/domain/models/crosscutting/device-intelligence.d.ts +11 -0
  7. package/lib/domain/models/crosscutting/device-intelligence.js +18 -0
  8. package/lib/domain/models/crosscutting/index.d.ts +1 -0
  9. package/lib/domain/models/crosscutting/index.js +17 -0
  10. package/lib/domain/protocols/cache/get-storage.d.ts +8 -0
  11. package/lib/domain/protocols/cache/get-storage.js +2 -0
  12. package/lib/domain/protocols/cache/index.d.ts +3 -0
  13. package/lib/domain/protocols/cache/index.js +19 -0
  14. package/lib/domain/protocols/cache/remove-storage.d.ts +6 -0
  15. package/lib/domain/protocols/cache/remove-storage.js +2 -0
  16. package/lib/domain/protocols/cache/set-storage.d.ts +7 -0
  17. package/lib/domain/protocols/cache/set-storage.js +2 -0
  18. package/lib/domain/protocols/http/http-client.d.ts +23 -0
  19. package/lib/domain/protocols/http/http-client.js +13 -0
  20. package/lib/domain/protocols/services/behavioural-biometrics/cursor-behavior.d.ts +63 -0
  21. package/lib/domain/protocols/services/behavioural-biometrics/cursor-behavior.js +2 -0
  22. package/lib/domain/protocols/services/behavioural-biometrics/index.d.ts +3 -0
  23. package/lib/domain/protocols/services/behavioural-biometrics/index.js +19 -0
  24. package/lib/domain/protocols/services/behavioural-biometrics/keystorke-metrics.d.ts +35 -0
  25. package/lib/domain/protocols/services/behavioural-biometrics/keystorke-metrics.js +2 -0
  26. package/lib/domain/protocols/services/behavioural-biometrics/touch-behavior.d.ts +88 -0
  27. package/lib/domain/protocols/services/behavioural-biometrics/touch-behavior.js +2 -0
  28. package/lib/domain/protocols/services/device-fingerprint/display.d.ts +22 -0
  29. package/lib/domain/protocols/services/device-fingerprint/display.js +2 -0
  30. package/lib/domain/protocols/services/device-fingerprint/index.d.ts +3 -0
  31. package/lib/domain/protocols/services/device-fingerprint/index.js +19 -0
  32. package/lib/domain/protocols/services/device-fingerprint/navigator.d.ts +63 -0
  33. package/lib/domain/protocols/services/device-fingerprint/navigator.js +2 -0
  34. package/lib/domain/protocols/services/device-fingerprint/utils.d.ts +40 -0
  35. package/lib/domain/protocols/services/device-fingerprint/utils.js +2 -0
  36. package/lib/domain/protocols/services/device-identifier.d.ts +96 -0
  37. package/lib/domain/protocols/services/device-identifier.js +2 -0
  38. package/lib/domain/protocols/services/device-intelligence.d.ts +5 -0
  39. package/lib/domain/protocols/services/device-intelligence.js +2 -0
  40. package/lib/domain/protocols/services/listeners.d.ts +9 -0
  41. package/lib/domain/protocols/services/listeners.js +2 -0
  42. package/lib/domain/protocols/services/single-script-injection/auto-init.d.ts +120 -0
  43. package/lib/domain/protocols/services/single-script-injection/auto-init.js +2 -0
  44. package/lib/domain/protocols/services/single-script-injection/index.d.ts +1 -0
  45. package/lib/domain/protocols/services/single-script-injection/index.js +17 -0
  46. package/lib/domain/services/behavioural-biometrics/collector.d.ts +94 -0
  47. package/lib/domain/services/behavioural-biometrics/collector.js +229 -0
  48. package/lib/domain/services/behavioural-biometrics/cursor-behavior.d.ts +87 -0
  49. package/lib/domain/services/behavioural-biometrics/cursor-behavior.js +369 -0
  50. package/lib/domain/services/behavioural-biometrics/index.d.ts +4 -0
  51. package/lib/domain/services/behavioural-biometrics/index.js +20 -0
  52. package/lib/domain/services/behavioural-biometrics/keystroke-metrics.d.ts +60 -0
  53. package/lib/domain/services/behavioural-biometrics/keystroke-metrics.js +213 -0
  54. package/lib/domain/services/behavioural-biometrics/touch-behavior.d.ts +125 -0
  55. package/lib/domain/services/behavioural-biometrics/touch-behavior.js +413 -0
  56. package/lib/domain/services/device-fingerprint/audio.d.ts +14 -0
  57. package/lib/domain/services/device-fingerprint/audio.js +109 -0
  58. package/lib/domain/services/device-fingerprint/canvas.d.ts +10 -0
  59. package/lib/domain/services/device-fingerprint/canvas.js +33 -0
  60. package/lib/domain/services/device-fingerprint/display.d.ts +49 -0
  61. package/lib/domain/services/device-fingerprint/display.js +88 -0
  62. package/lib/domain/services/device-fingerprint/hash.d.ts +14 -0
  63. package/lib/domain/services/device-fingerprint/hash.js +60 -0
  64. package/lib/domain/services/device-fingerprint/index.d.ts +8 -0
  65. package/lib/domain/services/device-fingerprint/index.js +24 -0
  66. package/lib/domain/services/device-fingerprint/navigator.d.ts +110 -0
  67. package/lib/domain/services/device-fingerprint/navigator.js +213 -0
  68. package/lib/domain/services/device-fingerprint/pointer-capability.d.ts +14 -0
  69. package/lib/domain/services/device-fingerprint/pointer-capability.js +42 -0
  70. package/lib/domain/services/device-fingerprint/storage.d.ts +44 -0
  71. package/lib/domain/services/device-fingerprint/storage.js +64 -0
  72. package/lib/domain/services/device-fingerprint/utils.d.ts +42 -0
  73. package/lib/domain/services/device-fingerprint/utils.js +95 -0
  74. package/lib/domain/services/device-intelligence.d.ts +10 -0
  75. package/lib/domain/services/device-intelligence.js +59 -0
  76. package/lib/domain/services/single-script-injection/checkpoint-scheduler.d.ts +37 -0
  77. package/lib/domain/services/single-script-injection/checkpoint-scheduler.js +94 -0
  78. package/lib/domain/services/single-script-injection/index.d.ts +3 -0
  79. package/lib/domain/services/single-script-injection/index.js +19 -0
  80. package/lib/domain/services/single-script-injection/response-delivery.d.ts +47 -0
  81. package/lib/domain/services/single-script-injection/response-delivery.js +115 -0
  82. package/lib/domain/services/single-script-injection/schedule-store.d.ts +69 -0
  83. package/lib/domain/services/single-script-injection/schedule-store.js +146 -0
  84. package/lib/domain/services/snapshot-store.d.ts +19 -0
  85. package/lib/domain/services/snapshot-store.js +36 -0
  86. package/lib/domain/services/spa-navigation.d.ts +15 -0
  87. package/lib/domain/services/spa-navigation.js +40 -0
  88. package/lib/index.d.ts +19 -0
  89. package/lib/index.js +27 -0
  90. package/lib/infra/cache/index.d.ts +3 -0
  91. package/lib/infra/cache/index.js +19 -0
  92. package/lib/infra/cache/local-storage-adapter.d.ts +8 -0
  93. package/lib/infra/cache/local-storage-adapter.js +14 -0
  94. package/lib/infra/cache/session-storage-adapter.d.ts +8 -0
  95. package/lib/infra/cache/session-storage-adapter.js +14 -0
  96. package/lib/infra/cache/web-storage-adapter.d.ts +13 -0
  97. package/lib/infra/cache/web-storage-adapter.js +33 -0
  98. package/lib/infra/http/axios-http-client.d.ts +4 -0
  99. package/lib/infra/http/axios-http-client.js +39 -0
  100. package/lib/validation/builder.d.ts +43 -0
  101. package/lib/validation/builder.js +85 -0
  102. package/lib/validation/composite.d.ts +13 -0
  103. package/lib/validation/composite.js +23 -0
  104. package/lib/validation/errors/index.d.ts +2 -0
  105. package/lib/validation/errors/index.js +18 -0
  106. package/lib/validation/errors/invalid-field-error.d.ts +7 -0
  107. package/lib/validation/errors/invalid-field-error.js +14 -0
  108. package/lib/validation/errors/required-field-error.d.ts +3 -0
  109. package/lib/validation/errors/required-field-error.js +10 -0
  110. package/lib/validation/index.d.ts +5 -0
  111. package/lib/validation/index.js +21 -0
  112. package/lib/validation/protocols/index.d.ts +1 -0
  113. package/lib/validation/protocols/index.js +17 -0
  114. package/lib/validation/protocols/validator.d.ts +11 -0
  115. package/lib/validation/protocols/validator.js +2 -0
  116. package/lib/validation/validators/behavioural-signal.d.ts +27 -0
  117. package/lib/validation/validators/behavioural-signal.js +56 -0
  118. package/lib/validation/validators/country-code.d.ts +14 -0
  119. package/lib/validation/validators/country-code.js +24 -0
  120. package/lib/validation/validators/global-function.d.ts +14 -0
  121. package/lib/validation/validators/global-function.js +29 -0
  122. package/lib/validation/validators/index.d.ts +9 -0
  123. package/lib/validation/validators/index.js +25 -0
  124. package/lib/validation/validators/interpolated-template.d.ts +14 -0
  125. package/lib/validation/validators/interpolated-template.js +28 -0
  126. package/lib/validation/validators/json-object.d.ts +14 -0
  127. package/lib/validation/validators/json-object.js +33 -0
  128. package/lib/validation/validators/language-code.d.ts +13 -0
  129. package/lib/validation/validators/language-code.js +23 -0
  130. package/lib/validation/validators/positive-number.d.ts +13 -0
  131. package/lib/validation/validators/positive-number.js +24 -0
  132. package/lib/validation/validators/required-string.d.ts +10 -0
  133. package/lib/validation/validators/required-string.js +19 -0
  134. package/lib/validation/validators/schedule-record.d.ts +26 -0
  135. package/lib/validation/validators/schedule-record.js +33 -0
  136. package/package.json +51 -0
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidationBuilder = void 0;
4
+ const validators_1 = require("./validators");
5
+ const composite_1 = require("./composite");
6
+ /**
7
+ * Fluent assembly of the rules that apply to one field.
8
+ *
9
+ * `ValidationBuilder.of({ value, fieldName }).required().interpolated().build()`
10
+ * reads as the requirement itself, and keeps the field name stated once instead
11
+ * of repeated into every rule.
12
+ */
13
+ class ValidationBuilder {
14
+ constructor(
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ value, fieldName, validators = [], skipWhenEmpty = false) {
17
+ this.value = value;
18
+ this.fieldName = fieldName;
19
+ this.validators = validators;
20
+ this.skipWhenEmpty = skipWhenEmpty;
21
+ }
22
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
+ static of({ value, fieldName }) {
24
+ return new ValidationBuilder(value, fieldName);
25
+ }
26
+ /**
27
+ * An absent or blank value passes every rule; the rules only apply to a value
28
+ * that is actually there.
29
+ */
30
+ optional() {
31
+ this.skipWhenEmpty = true;
32
+ return this;
33
+ }
34
+ /** The value must be a non-empty, non-whitespace string. */
35
+ required() {
36
+ this.validators.push(new validators_1.RequiredString(this.value, this.fieldName));
37
+ return this;
38
+ }
39
+ /** The value must be a finite number greater than zero. */
40
+ positiveNumber() {
41
+ this.validators.push(new validators_1.PositiveNumber(this.value, this.fieldName));
42
+ return this;
43
+ }
44
+ /** The survey platform must have interpolated the value. */
45
+ interpolated() {
46
+ this.validators.push(new validators_1.InterpolatedTemplate(this.value, this.fieldName));
47
+ return this;
48
+ }
49
+ /** When present, the value must parse to a JSON object. */
50
+ jsonObject() {
51
+ this.validators.push(new validators_1.JsonObject(this.value, this.fieldName));
52
+ return this;
53
+ }
54
+ /** The value must be shaped like an ISO 3166-1 alpha-2 country code. */
55
+ countryCode() {
56
+ this.validators.push(new validators_1.CountryCode(this.value, this.fieldName));
57
+ return this;
58
+ }
59
+ /** The value must be shaped like an ISO 639-1 language code. */
60
+ languageCode() {
61
+ this.validators.push(new validators_1.LanguageCode(this.value, this.fieldName));
62
+ return this;
63
+ }
64
+ /** The value must name a function on `window`. */
65
+ globalFunction() {
66
+ this.validators.push(new validators_1.GlobalFunction(this.value, this.fieldName));
67
+ return this;
68
+ }
69
+ /** The value must be a usable schedule record. */
70
+ scheduleRecord() {
71
+ this.validators.push(new validators_1.ScheduleRecordShape(this.value, this.fieldName));
72
+ return this;
73
+ }
74
+ build() {
75
+ const isEmpty = this.value === undefined || this.value === null || String(this.value).trim() === '';
76
+ if (this.skipWhenEmpty && isEmpty)
77
+ return [];
78
+ return this.validators;
79
+ }
80
+ /** Assembles the rules and runs them, reporting the first failure. */
81
+ validate() {
82
+ return new composite_1.ValidationComposite(this.build()).validate();
83
+ }
84
+ }
85
+ exports.ValidationBuilder = ValidationBuilder;
@@ -0,0 +1,13 @@
1
+ import { Validator } from './protocols';
2
+ /**
3
+ * Runs a list of rules and reports the first failure.
4
+ *
5
+ * Composing rather than chaining `if` statements is what lets a caller state
6
+ * *what* must hold and stay out of the business of *how* each rule is checked or
7
+ * in what order the failures are reported.
8
+ */
9
+ export declare class ValidationComposite implements Validator {
10
+ private readonly validators;
11
+ constructor(validators: Validator[]);
12
+ validate(): Error | undefined;
13
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidationComposite = void 0;
4
+ /**
5
+ * Runs a list of rules and reports the first failure.
6
+ *
7
+ * Composing rather than chaining `if` statements is what lets a caller state
8
+ * *what* must hold and stay out of the business of *how* each rule is checked or
9
+ * in what order the failures are reported.
10
+ */
11
+ class ValidationComposite {
12
+ constructor(validators) {
13
+ this.validators = validators;
14
+ }
15
+ validate() {
16
+ for (const validator of this.validators) {
17
+ const error = validator.validate();
18
+ if (error !== undefined)
19
+ return error;
20
+ }
21
+ }
22
+ }
23
+ exports.ValidationComposite = ValidationComposite;
@@ -0,0 +1,2 @@
1
+ export * from './required-field-error';
2
+ export * from './invalid-field-error';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./required-field-error"), exports);
18
+ __exportStar(require("./invalid-field-error"), exports);
@@ -0,0 +1,7 @@
1
+ export declare class InvalidFieldError extends Error {
2
+ /**
3
+ * @param fieldName - the field that failed, named as the buyer wrote it so the message points at their markup.
4
+ * @param reason - completes the sentence "<fieldName> <reason>".
5
+ */
6
+ constructor(fieldName: string, reason: string);
7
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InvalidFieldError = void 0;
4
+ class InvalidFieldError extends Error {
5
+ /**
6
+ * @param fieldName - the field that failed, named as the buyer wrote it so the message points at their markup.
7
+ * @param reason - completes the sentence "<fieldName> <reason>".
8
+ */
9
+ constructor(fieldName, reason) {
10
+ super(`${fieldName} ${reason}`);
11
+ this.name = 'InvalidFieldError';
12
+ }
13
+ }
14
+ exports.InvalidFieldError = InvalidFieldError;
@@ -0,0 +1,3 @@
1
+ export declare class RequiredFieldError extends Error {
2
+ constructor(fieldName: string);
3
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RequiredFieldError = void 0;
4
+ class RequiredFieldError extends Error {
5
+ constructor(fieldName) {
6
+ super(`${fieldName} is required`);
7
+ this.name = 'RequiredFieldError';
8
+ }
9
+ }
10
+ exports.RequiredFieldError = RequiredFieldError;
@@ -0,0 +1,5 @@
1
+ export * from './protocols';
2
+ export * from './errors';
3
+ export * from './validators';
4
+ export * from './composite';
5
+ export * from './builder';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./protocols"), exports);
18
+ __exportStar(require("./errors"), exports);
19
+ __exportStar(require("./validators"), exports);
20
+ __exportStar(require("./composite"), exports);
21
+ __exportStar(require("./builder"), exports);
@@ -0,0 +1 @@
1
+ export * from './validator';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./validator"), exports);
@@ -0,0 +1,11 @@
1
+ /**
2
+ * A single validation rule.
3
+ *
4
+ * The value under validation is handed to the concrete validator on
5
+ * construction, so `validate` takes no arguments: a validator is a rule already
6
+ * bound to its subject. It returns the `Error` describing the failure, or
7
+ * `undefined` when the value is acceptable.
8
+ */
9
+ export interface Validator {
10
+ validate: () => Error | undefined;
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,27 @@
1
+ import { Validator } from '../protocols';
2
+ /**
3
+ * A bucket of behavioural-biometrics metrics, as the trackers report it.
4
+ * Structural because every field is optional in practice — the point of this
5
+ * rule is to find out which of them the trackers actually filled in.
6
+ */
7
+ export type MetricsBucket = {
8
+ touchBehavior?: any;
9
+ cursorBehavior?: any;
10
+ keystrokeDynamics?: any;
11
+ };
12
+ /**
13
+ * Rejects a bucket that captured no behavioural signal of any kind.
14
+ *
15
+ * A bucket is only worthless when *both* halves are empty: every aggregate count
16
+ * is zero AND every detailed signal is empty. Either half alone is a real
17
+ * observation — a respondent who scrolled without typing still produced signal —
18
+ * so both are required before the bucket is thrown away.
19
+ */
20
+ export declare class BehaviouralSignal implements Validator {
21
+ private readonly bucket;
22
+ private readonly fieldName;
23
+ constructor(bucket: MetricsBucket | null | undefined, fieldName?: string);
24
+ validate(): Error | undefined;
25
+ private countsAreZero;
26
+ private detailsAreEmpty;
27
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BehaviouralSignal = void 0;
4
+ const errors_1 = require("../errors");
5
+ function isAllFalsy(obj) {
6
+ if (!obj)
7
+ return true;
8
+ return Object.values(obj).every(v => !v);
9
+ }
10
+ /**
11
+ * Rejects a bucket that captured no behavioural signal of any kind.
12
+ *
13
+ * A bucket is only worthless when *both* halves are empty: every aggregate count
14
+ * is zero AND every detailed signal is empty. Either half alone is a real
15
+ * observation — a respondent who scrolled without typing still produced signal —
16
+ * so both are required before the bucket is thrown away.
17
+ */
18
+ class BehaviouralSignal {
19
+ constructor(bucket, fieldName = 'behavioural biometrics bucket') {
20
+ this.bucket = bucket;
21
+ this.fieldName = fieldName;
22
+ }
23
+ validate() {
24
+ if (!this.bucket)
25
+ return new errors_1.InvalidFieldError(this.fieldName, 'is missing');
26
+ if (this.countsAreZero() && this.detailsAreEmpty()) {
27
+ return new errors_1.InvalidFieldError(this.fieldName, 'captured no behavioural signal');
28
+ }
29
+ }
30
+ countsAreZero() {
31
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
32
+ const cursor = (_a = this.bucket) === null || _a === void 0 ? void 0 : _a.cursorBehavior;
33
+ const touch = (_b = this.bucket) === null || _b === void 0 ? void 0 : _b.touchBehavior;
34
+ return ((_d = (_c = cursor === null || cursor === void 0 ? void 0 : cursor.accelerationMetrics) === null || _c === void 0 ? void 0 : _c.decelerationCount) !== null && _d !== void 0 ? _d : 0) === 0
35
+ && ((_f = (_e = cursor === null || cursor === void 0 ? void 0 : cursor.accelerationMetrics) === null || _e === void 0 ? void 0 : _e.accelerationCount) !== null && _f !== void 0 ? _f : 0) === 0
36
+ && ((_h = (_g = cursor === null || cursor === void 0 ? void 0 : cursor.trajectoryMetrics) === null || _g === void 0 ? void 0 : _g.angleChanges) !== null && _h !== void 0 ? _h : 0) === 0
37
+ && ((_k = (_j = cursor === null || cursor === void 0 ? void 0 : cursor.scrollMetrics) === null || _j === void 0 ? void 0 : _j.totalScrollDistance) !== null && _k !== void 0 ? _k : 0) === 0
38
+ && ((_m = (_l = cursor === null || cursor === void 0 ? void 0 : cursor.scrollMetrics) === null || _l === void 0 ? void 0 : _l.wheelScrollCount) !== null && _m !== void 0 ? _m : 0) === 0
39
+ && ((_p = (_o = cursor === null || cursor === void 0 ? void 0 : cursor.scrollMetrics) === null || _o === void 0 ? void 0 : _o.dragScrollCount) !== null && _p !== void 0 ? _p : 0) === 0
40
+ && ((_r = (_q = cursor === null || cursor === void 0 ? void 0 : cursor.sessionInfo) === null || _q === void 0 ? void 0 : _q.totalMovements) !== null && _r !== void 0 ? _r : 0) === 0
41
+ && ((_t = (_s = touch === null || touch === void 0 ? void 0 : touch.swipe) === null || _s === void 0 ? void 0 : _s.swipeCount) !== null && _t !== void 0 ? _t : 0) === 0;
42
+ }
43
+ detailsAreEmpty() {
44
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
45
+ const cursor = (_a = this.bucket) === null || _a === void 0 ? void 0 : _a.cursorBehavior;
46
+ const touch = (_b = this.bucket) === null || _b === void 0 ? void 0 : _b.touchBehavior;
47
+ const keyboard = (_c = this.bucket) === null || _c === void 0 ? void 0 : _c.keystrokeDynamics;
48
+ return isAllFalsy(cursor === null || cursor === void 0 ? void 0 : cursor.movementMetrics)
49
+ && ((_e = (_d = keyboard === null || keyboard === void 0 ? void 0 : keyboard.dwellTimes) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0) === 0
50
+ && ((_g = (_f = keyboard === null || keyboard === void 0 ? void 0 : keyboard.flightTimes) === null || _f === void 0 ? void 0 : _f.length) !== null && _g !== void 0 ? _g : 0) === 0
51
+ && isAllFalsy(touch === null || touch === void 0 ? void 0 : touch.pressure)
52
+ && isAllFalsy(touch === null || touch === void 0 ? void 0 : touch.fingerSize)
53
+ && ((_k = (_j = (_h = touch === null || touch === void 0 ? void 0 : touch.swipe) === null || _h === void 0 ? void 0 : _h.swipes) === null || _j === void 0 ? void 0 : _j.length) !== null && _k !== void 0 ? _k : 0) === 0;
54
+ }
55
+ }
56
+ exports.BehaviouralSignal = BehaviouralSignal;
@@ -0,0 +1,14 @@
1
+ import { Validator } from '../protocols';
2
+ /**
3
+ * Rejects anything that is not shaped like an ISO 3166-1 alpha-2 code (`US`,
4
+ * `GB`, `IN`).
5
+ *
6
+ * Only the shape is checked, case-insensitively: the caller normalises the case,
7
+ * and a full code list would cost bundle size for typos the service can report.
8
+ */
9
+ export declare class CountryCode implements Validator {
10
+ private readonly value;
11
+ private readonly fieldName;
12
+ constructor(value: string | undefined, fieldName: string);
13
+ validate(): Error | undefined;
14
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CountryCode = void 0;
4
+ const errors_1 = require("../errors");
5
+ /**
6
+ * Rejects anything that is not shaped like an ISO 3166-1 alpha-2 code (`US`,
7
+ * `GB`, `IN`).
8
+ *
9
+ * Only the shape is checked, case-insensitively: the caller normalises the case,
10
+ * and a full code list would cost bundle size for typos the service can report.
11
+ */
12
+ class CountryCode {
13
+ constructor(value, fieldName) {
14
+ this.value = value;
15
+ this.fieldName = fieldName;
16
+ }
17
+ validate() {
18
+ var _a, _b;
19
+ if (!/^[a-z]{2}$/i.test(((_a = this.value) !== null && _a !== void 0 ? _a : '').trim())) {
20
+ return new errors_1.InvalidFieldError(this.fieldName, `must be a 2-letter ISO 3166-1 alpha-2 country code (e.g. US, GB), got "${(_b = this.value) !== null && _b !== void 0 ? _b : ''}"`);
21
+ }
22
+ }
23
+ }
24
+ exports.CountryCode = CountryCode;
@@ -0,0 +1,14 @@
1
+ import { Validator } from '../protocols';
2
+ /**
3
+ * Rejects a name that does not resolve to a function on `window`.
4
+ *
5
+ * The name has to be global: a function declared inside a module, an IIFE or a
6
+ * `jQuery(document).ready(...)` block is not reachable this way, and this rule is
7
+ * what turns that into a message the buyer can act on.
8
+ */
9
+ export declare class GlobalFunction implements Validator {
10
+ private readonly name;
11
+ private readonly fieldName;
12
+ constructor(name: string | undefined, fieldName: string);
13
+ validate(): Error | undefined;
14
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GlobalFunction = void 0;
4
+ const errors_1 = require("../errors");
5
+ /**
6
+ * Rejects a name that does not resolve to a function on `window`.
7
+ *
8
+ * The name has to be global: a function declared inside a module, an IIFE or a
9
+ * `jQuery(document).ready(...)` block is not reachable this way, and this rule is
10
+ * what turns that into a message the buyer can act on.
11
+ */
12
+ class GlobalFunction {
13
+ constructor(name, fieldName) {
14
+ this.name = name;
15
+ this.fieldName = fieldName;
16
+ }
17
+ validate() {
18
+ var _a;
19
+ if (!((_a = this.name) === null || _a === void 0 ? void 0 : _a.trim()))
20
+ return new errors_1.InvalidFieldError(this.fieldName, 'is required');
21
+ if (typeof window === 'undefined')
22
+ return new errors_1.InvalidFieldError(this.fieldName, 'cannot be resolved outside a browser');
23
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
+ if (typeof window[this.name] !== 'function') {
25
+ return new errors_1.InvalidFieldError(this.fieldName, `"${this.name}" is not a global function`);
26
+ }
27
+ }
28
+ }
29
+ exports.GlobalFunction = GlobalFunction;
@@ -0,0 +1,9 @@
1
+ export * from './required-string';
2
+ export * from './positive-number';
3
+ export * from './interpolated-template';
4
+ export * from './json-object';
5
+ export * from './global-function';
6
+ export * from './schedule-record';
7
+ export * from './behavioural-signal';
8
+ export * from './country-code';
9
+ export * from './language-code';
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./required-string"), exports);
18
+ __exportStar(require("./positive-number"), exports);
19
+ __exportStar(require("./interpolated-template"), exports);
20
+ __exportStar(require("./json-object"), exports);
21
+ __exportStar(require("./global-function"), exports);
22
+ __exportStar(require("./schedule-record"), exports);
23
+ __exportStar(require("./behavioural-signal"), exports);
24
+ __exportStar(require("./country-code"), exports);
25
+ __exportStar(require("./language-code"), exports);
@@ -0,0 +1,14 @@
1
+ import { Validator } from '../protocols';
2
+ /**
3
+ * Rejects a value the survey platform never interpolated.
4
+ *
5
+ * Worth its own rule because the failure is silent and shared: a literal
6
+ * `${transaction_id}` is a perfectly usable string, so it flows through as an id
7
+ * that every respondent on the device would then have in common.
8
+ */
9
+ export declare class InterpolatedTemplate implements Validator {
10
+ private readonly value;
11
+ private readonly fieldName;
12
+ constructor(value: string | undefined, fieldName: string);
13
+ validate(): Error | undefined;
14
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InterpolatedTemplate = void 0;
4
+ const errors_1 = require("../errors");
5
+ /**
6
+ * Markers left behind when a survey platform fails to interpolate a placeholder.
7
+ */
8
+ const TEMPLATE_MARKERS = ['${', '{{', '{%', '<%'];
9
+ /**
10
+ * Rejects a value the survey platform never interpolated.
11
+ *
12
+ * Worth its own rule because the failure is silent and shared: a literal
13
+ * `${transaction_id}` is a perfectly usable string, so it flows through as an id
14
+ * that every respondent on the device would then have in common.
15
+ */
16
+ class InterpolatedTemplate {
17
+ constructor(value, fieldName) {
18
+ this.value = value;
19
+ this.fieldName = fieldName;
20
+ }
21
+ validate() {
22
+ const marker = TEMPLATE_MARKERS.find(m => { var _a; return (_a = this.value) === null || _a === void 0 ? void 0 : _a.includes(m); });
23
+ if (marker) {
24
+ return new errors_1.InvalidFieldError(this.fieldName, `looks like an uninterpolated template ("${this.value}")`);
25
+ }
26
+ }
27
+ }
28
+ exports.InterpolatedTemplate = InterpolatedTemplate;
@@ -0,0 +1,14 @@
1
+ import { Validator } from '../protocols';
2
+ /**
3
+ * Rejects a string that does not parse to a JSON object.
4
+ *
5
+ * An absent value passes — the attributes this guards are optional; it is only a
6
+ * value that is *present and unusable* that is an error. Arrays are rejected
7
+ * because the callers want a keyed object.
8
+ */
9
+ export declare class JsonObject implements Validator {
10
+ private readonly value;
11
+ private readonly fieldName;
12
+ constructor(value: string | undefined, fieldName: string);
13
+ validate(): Error | undefined;
14
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JsonObject = void 0;
4
+ const errors_1 = require("../errors");
5
+ /**
6
+ * Rejects a string that does not parse to a JSON object.
7
+ *
8
+ * An absent value passes — the attributes this guards are optional; it is only a
9
+ * value that is *present and unusable* that is an error. Arrays are rejected
10
+ * because the callers want a keyed object.
11
+ */
12
+ class JsonObject {
13
+ constructor(value, fieldName) {
14
+ this.value = value;
15
+ this.fieldName = fieldName;
16
+ }
17
+ validate() {
18
+ var _a;
19
+ if (!((_a = this.value) === null || _a === void 0 ? void 0 : _a.trim()))
20
+ return undefined;
21
+ let parsed;
22
+ try {
23
+ parsed = JSON.parse(this.value);
24
+ }
25
+ catch (_b) {
26
+ return new errors_1.InvalidFieldError(this.fieldName, 'is not valid JSON');
27
+ }
28
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
29
+ return new errors_1.InvalidFieldError(this.fieldName, 'is not a JSON object');
30
+ }
31
+ }
32
+ }
33
+ exports.JsonObject = JsonObject;
@@ -0,0 +1,13 @@
1
+ import { Validator } from '../protocols';
2
+ /**
3
+ * Rejects anything that is not shaped like an ISO 639-1 code (`en`, `fr`, `de`).
4
+ *
5
+ * A locale such as `en-US` is rejected on purpose: the country travels in its
6
+ * own field. As with `CountryCode`, only the shape is checked.
7
+ */
8
+ export declare class LanguageCode implements Validator {
9
+ private readonly value;
10
+ private readonly fieldName;
11
+ constructor(value: string | undefined, fieldName: string);
12
+ validate(): Error | undefined;
13
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LanguageCode = void 0;
4
+ const errors_1 = require("../errors");
5
+ /**
6
+ * Rejects anything that is not shaped like an ISO 639-1 code (`en`, `fr`, `de`).
7
+ *
8
+ * A locale such as `en-US` is rejected on purpose: the country travels in its
9
+ * own field. As with `CountryCode`, only the shape is checked.
10
+ */
11
+ class LanguageCode {
12
+ constructor(value, fieldName) {
13
+ this.value = value;
14
+ this.fieldName = fieldName;
15
+ }
16
+ validate() {
17
+ var _a, _b;
18
+ if (!/^[a-z]{2}$/i.test(((_a = this.value) !== null && _a !== void 0 ? _a : '').trim())) {
19
+ return new errors_1.InvalidFieldError(this.fieldName, `must be a 2-letter ISO 639-1 language code (e.g. en, fr), got "${(_b = this.value) !== null && _b !== void 0 ? _b : ''}"`);
20
+ }
21
+ }
22
+ }
23
+ exports.LanguageCode = LanguageCode;
@@ -0,0 +1,13 @@
1
+ import { Validator } from '../protocols';
2
+ /**
3
+ * Rejects anything that is not a finite number greater than zero.
4
+ *
5
+ * Takes the raw string because the values it guards arrive as HTML attributes,
6
+ * and the original text is what belongs in the error message.
7
+ */
8
+ export declare class PositiveNumber implements Validator {
9
+ private readonly value;
10
+ private readonly fieldName;
11
+ constructor(value: string | undefined, fieldName: string);
12
+ validate(): Error | undefined;
13
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PositiveNumber = void 0;
4
+ const errors_1 = require("../errors");
5
+ /**
6
+ * Rejects anything that is not a finite number greater than zero.
7
+ *
8
+ * Takes the raw string because the values it guards arrive as HTML attributes,
9
+ * and the original text is what belongs in the error message.
10
+ */
11
+ class PositiveNumber {
12
+ constructor(value, fieldName) {
13
+ this.value = value;
14
+ this.fieldName = fieldName;
15
+ }
16
+ validate() {
17
+ var _a, _b;
18
+ const parsed = Number(this.value);
19
+ if (!((_a = this.value) === null || _a === void 0 ? void 0 : _a.trim()) || !isFinite(parsed) || parsed <= 0) {
20
+ return new errors_1.InvalidFieldError(this.fieldName, `must be a positive number, got "${(_b = this.value) !== null && _b !== void 0 ? _b : ''}"`);
21
+ }
22
+ }
23
+ }
24
+ exports.PositiveNumber = PositiveNumber;
@@ -0,0 +1,10 @@
1
+ import { Validator } from '../protocols';
2
+ /**
3
+ * Rejects a missing, empty or whitespace-only string.
4
+ */
5
+ export declare class RequiredString implements Validator {
6
+ private readonly value;
7
+ private readonly fieldName;
8
+ constructor(value: string | undefined, fieldName: string);
9
+ validate(): Error | undefined;
10
+ }