@loopcheck/qa-sdk 1.0.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 (124) hide show
  1. package/ARCHITECTURE.md +59 -0
  2. package/README.md +131 -0
  3. package/dist/config/normalize.d.ts +6 -0
  4. package/dist/config/normalize.d.ts.map +1 -0
  5. package/dist/config/normalize.js +88 -0
  6. package/dist/config/normalize.js.map +1 -0
  7. package/dist/core/QAClient.d.ts +53 -0
  8. package/dist/core/QAClient.d.ts.map +1 -0
  9. package/dist/core/QAClient.js +318 -0
  10. package/dist/core/QAClient.js.map +1 -0
  11. package/dist/core/QAEventBus.d.ts +10 -0
  12. package/dist/core/QAEventBus.d.ts.map +1 -0
  13. package/dist/core/QAEventBus.js +27 -0
  14. package/dist/core/QAEventBus.js.map +1 -0
  15. package/dist/debug/Debugger.d.ts +4 -0
  16. package/dist/debug/Debugger.d.ts.map +1 -0
  17. package/dist/debug/Debugger.js +57 -0
  18. package/dist/debug/Debugger.js.map +1 -0
  19. package/dist/identity/AccessibilityResolver.d.ts +3 -0
  20. package/dist/identity/AccessibilityResolver.d.ts.map +1 -0
  21. package/dist/identity/AccessibilityResolver.js +76 -0
  22. package/dist/identity/AccessibilityResolver.js.map +1 -0
  23. package/dist/identity/DuplicateDetector.d.ts +9 -0
  24. package/dist/identity/DuplicateDetector.d.ts.map +1 -0
  25. package/dist/identity/DuplicateDetector.js +41 -0
  26. package/dist/identity/DuplicateDetector.js.map +1 -0
  27. package/dist/identity/ElementResolver.d.ts +5 -0
  28. package/dist/identity/ElementResolver.d.ts.map +1 -0
  29. package/dist/identity/ElementResolver.js +123 -0
  30. package/dist/identity/ElementResolver.js.map +1 -0
  31. package/dist/identity/FingerprintGenerator.d.ts +19 -0
  32. package/dist/identity/FingerprintGenerator.d.ts.map +1 -0
  33. package/dist/identity/FingerprintGenerator.js +49 -0
  34. package/dist/identity/FingerprintGenerator.js.map +1 -0
  35. package/dist/identity/IdentityValidator.d.ts +6 -0
  36. package/dist/identity/IdentityValidator.d.ts.map +1 -0
  37. package/dist/identity/IdentityValidator.js +28 -0
  38. package/dist/identity/IdentityValidator.js.map +1 -0
  39. package/dist/index.d.ts +10 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +9 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/instrumentation/DOMObserver.d.ts +13 -0
  44. package/dist/instrumentation/DOMObserver.d.ts.map +1 -0
  45. package/dist/instrumentation/DOMObserver.js +45 -0
  46. package/dist/instrumentation/DOMObserver.js.map +1 -0
  47. package/dist/instrumentation/ElementRegistry.d.ts +15 -0
  48. package/dist/instrumentation/ElementRegistry.d.ts.map +1 -0
  49. package/dist/instrumentation/ElementRegistry.js +53 -0
  50. package/dist/instrumentation/ElementRegistry.js.map +1 -0
  51. package/dist/instrumentation/EventDelegator.d.ts +31 -0
  52. package/dist/instrumentation/EventDelegator.d.ts.map +1 -0
  53. package/dist/instrumentation/EventDelegator.js +238 -0
  54. package/dist/instrumentation/EventDelegator.js.map +1 -0
  55. package/dist/instrumentation/FormHarvest.d.ts +33 -0
  56. package/dist/instrumentation/FormHarvest.d.ts.map +1 -0
  57. package/dist/instrumentation/FormHarvest.js +179 -0
  58. package/dist/instrumentation/FormHarvest.js.map +1 -0
  59. package/dist/instrumentation/NavigationObserver.d.ts +11 -0
  60. package/dist/instrumentation/NavigationObserver.d.ts.map +1 -0
  61. package/dist/instrumentation/NavigationObserver.js +52 -0
  62. package/dist/instrumentation/NavigationObserver.js.map +1 -0
  63. package/dist/instrumentation/compiler-contract.d.ts +11 -0
  64. package/dist/instrumentation/compiler-contract.d.ts.map +1 -0
  65. package/dist/instrumentation/compiler-contract.js +11 -0
  66. package/dist/instrumentation/compiler-contract.js.map +1 -0
  67. package/dist/privacy/Redactor.d.ts +4 -0
  68. package/dist/privacy/Redactor.d.ts.map +1 -0
  69. package/dist/privacy/Redactor.js +50 -0
  70. package/dist/privacy/Redactor.js.map +1 -0
  71. package/dist/react/QAButton.d.ts +595 -0
  72. package/dist/react/QAButton.d.ts.map +1 -0
  73. package/dist/react/QAButton.js +22 -0
  74. package/dist/react/QAButton.js.map +1 -0
  75. package/dist/react/QAProvider.d.ts +23 -0
  76. package/dist/react/QAProvider.d.ts.map +1 -0
  77. package/dist/react/QAProvider.js +41 -0
  78. package/dist/react/QAProvider.js.map +1 -0
  79. package/dist/react/index.d.ts +4 -0
  80. package/dist/react/index.d.ts.map +1 -0
  81. package/dist/react/index.js +5 -0
  82. package/dist/react/index.js.map +1 -0
  83. package/dist/react/useQAElement.d.ts +3 -0
  84. package/dist/react/useQAElement.d.ts.map +1 -0
  85. package/dist/react/useQAElement.js +23 -0
  86. package/dist/react/useQAElement.js.map +1 -0
  87. package/dist/recorder/EventNormalizer.d.ts +32 -0
  88. package/dist/recorder/EventNormalizer.d.ts.map +1 -0
  89. package/dist/recorder/EventNormalizer.js +113 -0
  90. package/dist/recorder/EventNormalizer.js.map +1 -0
  91. package/dist/recorder.iife.js +14 -0
  92. package/dist/transport/BatchQueue.d.ts +26 -0
  93. package/dist/transport/BatchQueue.d.ts.map +1 -0
  94. package/dist/transport/BatchQueue.js +110 -0
  95. package/dist/transport/BatchQueue.js.map +1 -0
  96. package/dist/transport/HTTPTransport.d.ts +36 -0
  97. package/dist/transport/HTTPTransport.d.ts.map +1 -0
  98. package/dist/transport/HTTPTransport.js +121 -0
  99. package/dist/transport/HTTPTransport.js.map +1 -0
  100. package/dist/transport/RetryQueue.d.ts +10 -0
  101. package/dist/transport/RetryQueue.d.ts.map +1 -0
  102. package/dist/transport/RetryQueue.js +60 -0
  103. package/dist/transport/RetryQueue.js.map +1 -0
  104. package/dist/types/index.d.ts +147 -0
  105. package/dist/types/index.d.ts.map +1 -0
  106. package/dist/types/index.js +24 -0
  107. package/dist/types/index.js.map +1 -0
  108. package/dist/utils/dom.d.ts +24 -0
  109. package/dist/utils/dom.d.ts.map +1 -0
  110. package/dist/utils/dom.js +152 -0
  111. package/dist/utils/dom.js.map +1 -0
  112. package/dist/utils/env.d.ts +2 -0
  113. package/dist/utils/env.d.ts.map +1 -0
  114. package/dist/utils/env.js +6 -0
  115. package/dist/utils/env.js.map +1 -0
  116. package/dist/utils/id.d.ts +13 -0
  117. package/dist/utils/id.d.ts.map +1 -0
  118. package/dist/utils/id.js +74 -0
  119. package/dist/utils/id.js.map +1 -0
  120. package/dist/utils/safe.d.ts +5 -0
  121. package/dist/utils/safe.d.ts.map +1 -0
  122. package/dist/utils/safe.js +28 -0
  123. package/dist/utils/safe.js.map +1 -0
  124. package/package.json +79 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavigationObserver.d.ts","sourceRoot":"","sources":["../../src/instrumentation/NavigationObserver.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAkB;IAKjB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAJvC,OAAO,CAAC,YAAY,CAAC,CAAuB;IAC5C,OAAO,CAAC,eAAe,CAAC,CAA0B;IAClD,OAAO,CAAC,OAAO,CAAM;gBAEQ,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI;IAEhF,KAAK,IAAI,IAAI;IAmBb,IAAI,IAAI,IAAI;IAcZ,OAAO,CAAC,QAAQ,CAAC,KAAK,CAUpB;CACH"}
@@ -0,0 +1,52 @@
1
+ export class NavigationObserver {
2
+ onNavigate;
3
+ originalPush;
4
+ originalReplace;
5
+ lastUrl = '';
6
+ constructor(onNavigate) {
7
+ this.onNavigate = onNavigate;
8
+ }
9
+ start() {
10
+ if (typeof window === 'undefined' || typeof history === 'undefined') {
11
+ return;
12
+ }
13
+ this.lastUrl = window.location.href;
14
+ this.originalPush = history.pushState.bind(history);
15
+ this.originalReplace = history.replaceState.bind(history);
16
+ history.pushState = ((data, unused, url) => {
17
+ this.originalPush?.(data, unused, url);
18
+ this.check();
19
+ });
20
+ history.replaceState = ((data, unused, url) => {
21
+ this.originalReplace?.(data, unused, url);
22
+ this.check();
23
+ });
24
+ window.addEventListener('popstate', this.check);
25
+ window.addEventListener('hashchange', this.check);
26
+ }
27
+ stop() {
28
+ if (typeof window === 'undefined' || typeof history === 'undefined') {
29
+ return;
30
+ }
31
+ if (this.originalPush) {
32
+ history.pushState = this.originalPush;
33
+ }
34
+ if (this.originalReplace) {
35
+ history.replaceState = this.originalReplace;
36
+ }
37
+ window.removeEventListener('popstate', this.check);
38
+ window.removeEventListener('hashchange', this.check);
39
+ }
40
+ check = () => {
41
+ if (typeof window === 'undefined') {
42
+ return;
43
+ }
44
+ const href = window.location.href;
45
+ if (href === this.lastUrl) {
46
+ return;
47
+ }
48
+ this.lastUrl = href;
49
+ this.onNavigate(href, window.location.pathname || '/');
50
+ };
51
+ }
52
+ //# sourceMappingURL=NavigationObserver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavigationObserver.js","sourceRoot":"","sources":["../../src/instrumentation/NavigationObserver.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,kBAAkB;IAKA;IAJrB,YAAY,CAAwB;IACpC,eAAe,CAA2B;IAC1C,OAAO,GAAG,EAAE,CAAC;IAErB,YAA6B,UAAmD;QAAnD,eAAU,GAAV,UAAU,CAAyC;IAAG,CAAC;IAEpF,KAAK;QACH,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;YACpE,OAAO;QACT,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;QACpC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpD,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1D,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;YACzC,IAAI,CAAC,YAAY,EAAE,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I,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,IAAI,GAAG,CAAC,CAAC;IACzD,CAAC,CAAC;CACH"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Compiler plugin contract (not implemented in the runtime SDK).
3
+ *
4
+ * A future Babel/SWC/Vite plugin should inject:
5
+ * data-qa-source="src/checkout/Checkout.tsx:42"
6
+ *
7
+ * The runtime only *reads* that attribute via `parseSourceMeta`.
8
+ * Do not couple this package to a specific compiler.
9
+ */
10
+ export declare const QA_SOURCE_FORMAT = "file:line:column#component";
11
+ //# sourceMappingURL=compiler-contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler-contract.d.ts","sourceRoot":"","sources":["../../src/instrumentation/compiler-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,+BAA+B,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Compiler plugin contract (not implemented in the runtime SDK).
3
+ *
4
+ * A future Babel/SWC/Vite plugin should inject:
5
+ * data-qa-source="src/checkout/Checkout.tsx:42"
6
+ *
7
+ * The runtime only *reads* that attribute via `parseSourceMeta`.
8
+ * Do not couple this package to a specific compiler.
9
+ */
10
+ export const QA_SOURCE_FORMAT = 'file:line:column#component';
11
+ //# sourceMappingURL=compiler-contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler-contract.js","sourceRoot":"","sources":["../../src/instrumentation/compiler-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,4BAA4B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type ResolvedQAConfig } from '../types';
2
+ export declare function isSensitiveElement(element: Element, config: ResolvedQAConfig): boolean;
3
+ export declare function redactValue(element: Element, value: unknown, config: ResolvedQAConfig): string | undefined;
4
+ //# sourceMappingURL=Redactor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Redactor.d.ts","sourceRoot":"","sources":["../../src/privacy/Redactor.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,UAAU,CAAC;AAalB,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CA8BtF;AAED,wBAAgB,WAAW,CACzB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,gBAAgB,GACvB,MAAM,GAAG,SAAS,CAQpB"}
@@ -0,0 +1,50 @@
1
+ import { QA_SENSITIVE_ATTRIBUTE, REDACTED_VALUE, } from '../types';
2
+ import { isSafeSelector } from '../utils/dom';
3
+ const SENSITIVE_TYPE = new Set([
4
+ 'password',
5
+ 'hidden',
6
+ ]);
7
+ const SENSITIVE_AUTOCOMPLETE = /^(cc-|card |current-password|new-password|one-time-code|tel|email)/i;
8
+ const SENSITIVE_NAME = /password|passwd|secret|token|cvv|cvc|ssn|credit|card.?number|authorization|cookie|session/i;
9
+ export function isSensitiveElement(element, config) {
10
+ if (element.hasAttribute(QA_SENSITIVE_ATTRIBUTE)) {
11
+ return true;
12
+ }
13
+ if (element instanceof HTMLInputElement) {
14
+ if (SENSITIVE_TYPE.has(element.type.toLowerCase())) {
15
+ return true;
16
+ }
17
+ const autocomplete = element.getAttribute('autocomplete') ?? '';
18
+ if (autocomplete && SENSITIVE_AUTOCOMPLETE.test(autocomplete)) {
19
+ return true;
20
+ }
21
+ }
22
+ const name = element.getAttribute('name') ?? element.getAttribute('id') ?? '';
23
+ if (name && SENSITIVE_NAME.test(name)) {
24
+ return true;
25
+ }
26
+ for (const selector of config.redactSelectors) {
27
+ if (!isSafeSelector(selector)) {
28
+ continue;
29
+ }
30
+ try {
31
+ if (element.matches(selector) || element.closest(selector)) {
32
+ return true;
33
+ }
34
+ }
35
+ catch {
36
+ // ignore invalid
37
+ }
38
+ }
39
+ return false;
40
+ }
41
+ export function redactValue(element, value, config) {
42
+ if (isSensitiveElement(element, config) || !config.recordInputValues) {
43
+ return REDACTED_VALUE;
44
+ }
45
+ if (typeof value !== 'string') {
46
+ return value == null ? undefined : String(value);
47
+ }
48
+ return value.length > 200 ? `${value.slice(0, 200)}…` : value;
49
+ }
50
+ //# sourceMappingURL=Redactor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Redactor.js","sourceRoot":"","sources":["../../src/privacy/Redactor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,cAAc,GAEf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,UAAU;IACV,QAAQ;CACT,CAAC,CAAC;AAEH,MAAM,sBAAsB,GAAG,qEAAqE,CAAC;AAErG,MAAM,cAAc,GAClB,4FAA4F,CAAC;AAE/F,MAAM,UAAU,kBAAkB,CAAC,OAAgB,EAAE,MAAwB;IAC3E,IAAI,OAAO,CAAC,YAAY,CAAC,sBAAsB,CAAC,EAAE,CAAC;QACjD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,OAAO,YAAY,gBAAgB,EAAE,CAAC;QACxC,IAAI,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;YACnD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;QAChE,IAAI,YAAY,IAAI,sBAAsB,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;YAC9D,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,MAAM,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC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