avo-inspector 3.2.3-alpha.1 → 3.2.3

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 (71) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
  3. package/dist/AvoBatcher.js +0 -87
  4. package/dist/AvoDeduplicator.js +0 -142
  5. package/dist/AvoEncryption.js +0 -176
  6. package/dist/AvoInspector.js +0 -435
  7. package/dist/AvoNetworkCallsHandler.js +0 -229
  8. package/dist/AvoSchemaParser.js +0 -95
  9. package/dist/AvoStreamId.js +0 -82
  10. package/dist/__mocks__/xhr.js +0 -14
  11. package/dist/__mocks__/xhrError.js +0 -14
  12. package/dist/__tests__/AvoEncryption.d.ts +0 -1
  13. package/dist/__tests__/AvoEncryption.js +0 -272
  14. package/dist/__tests__/AvoEncryptionIntegration.d.ts +0 -1
  15. package/dist/__tests__/AvoEncryptionIntegration.js +0 -191
  16. package/dist/__tests__/AvoEventSpecFetcher.d.ts +0 -1
  17. package/dist/__tests__/AvoEventSpecFetcher.js +0 -377
  18. package/dist/__tests__/AvoInspector.d.ts +0 -1
  19. package/dist/__tests__/AvoInspector.js +0 -335
  20. package/dist/__tests__/Batcher.d.ts +0 -1
  21. package/dist/__tests__/Batcher.js +0 -214
  22. package/dist/__tests__/BatcherPublic.d.ts +0 -1
  23. package/dist/__tests__/BatcherPublic.js +0 -139
  24. package/dist/__tests__/Deduplicator.d.ts +0 -1
  25. package/dist/__tests__/Deduplicator.js +0 -190
  26. package/dist/__tests__/EnableLoggingLite_test.d.ts +0 -1
  27. package/dist/__tests__/EnableLogging_test.d.ts +0 -1
  28. package/dist/__tests__/EventSpecCache.d.ts +0 -1
  29. package/dist/__tests__/EventSpecCache.js +0 -143
  30. package/dist/__tests__/EventValidator.d.ts +0 -1
  31. package/dist/__tests__/EventValidator.js +0 -543
  32. package/dist/__tests__/InstallationId.d.ts +0 -1
  33. package/dist/__tests__/InstallationId.js +0 -60
  34. package/dist/__tests__/NetworkCallsHandler.d.ts +0 -1
  35. package/dist/__tests__/NetworkCallsHandler.js +0 -222
  36. package/dist/__tests__/NetworkCallsHandlerModelA.d.ts +0 -1
  37. package/dist/__tests__/NetworkCallsHandlerModelA.js +0 -206
  38. package/dist/__tests__/Parsing.d.ts +0 -1
  39. package/dist/__tests__/Parsing.js +0 -115
  40. package/dist/__tests__/Sessions.d.ts +0 -1
  41. package/dist/__tests__/Sessions.js +0 -10
  42. package/dist/__tests__/Storage.d.ts +0 -1
  43. package/dist/__tests__/Storage.js +0 -173
  44. package/dist/__tests__/StreamId.d.ts +0 -1
  45. package/dist/__tests__/StreamId.js +0 -153
  46. package/dist/__tests__/constants.js +0 -48
  47. package/dist/browser.js +0 -2
  48. package/dist/esm/AvoBatcher.js +0 -75
  49. package/dist/esm/AvoDeduplicator.js +0 -137
  50. package/dist/esm/AvoEncryption.js +0 -277
  51. package/dist/esm/AvoGuid.js +0 -9
  52. package/dist/esm/AvoInspector.js +0 -470
  53. package/dist/esm/AvoInspectorEnv.js +0 -5
  54. package/dist/esm/AvoNetworkCallsHandler.js +0 -181
  55. package/dist/esm/AvoSchemaParser.js +0 -128
  56. package/dist/esm/AvoStorage.js +0 -176
  57. package/dist/esm/AvoStreamId.js +0 -140
  58. package/dist/esm/eventSpec/AvoEventSpecCache.js +0 -165
  59. package/dist/esm/eventSpec/AvoEventSpecFetchTypes.js +0 -6
  60. package/dist/esm/eventSpec/AvoEventSpecFetcher.js +0 -203
  61. package/dist/esm/eventSpec/EventValidator.js +0 -687
  62. package/dist/esm/eventSpec/index.js +0 -4
  63. package/dist/esm/index.js +0 -3
  64. package/dist/esm/utils.js +0 -38
  65. package/dist/esm/version.js +0 -2
  66. package/dist/eventSpec/AvoEventSpecCache.js +0 -181
  67. package/dist/eventSpec/AvoEventSpecFetcher.js +0 -290
  68. package/dist/eventSpec/EventValidator.js +0 -846
  69. package/dist/eventSpec/index.js +0 -20
  70. package/dist/version.d.ts +0 -1
  71. package/dist/version.js +0 -5
@@ -1,95 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AvoSchemaParser = void 0;
4
- var isArray = function (obj) {
5
- return Object.prototype.toString.call(obj) === "[object Array]";
6
- };
7
- var AvoSchemaParser = /** @class */ (function () {
8
- function AvoSchemaParser() {
9
- }
10
- AvoSchemaParser.extractSchema = function (eventProperties) {
11
- var _this = this;
12
- if (eventProperties === null || eventProperties === undefined) {
13
- return [];
14
- }
15
- var mapping = function (object) {
16
- if (isArray(object)) {
17
- var list = object.map(function (x) {
18
- return mapping(x);
19
- });
20
- return _this.removeDuplicates(list);
21
- }
22
- else if (typeof object === "object") {
23
- var mappedResult = [];
24
- for (var key in object) {
25
- if (object.hasOwnProperty(key)) {
26
- var val = object[key];
27
- var mappedEntry = {
28
- propertyName: key,
29
- propertyType: _this.getPropValueType(val),
30
- };
31
- if (typeof val === "object" && val != null) {
32
- mappedEntry["children"] = mapping(val);
33
- }
34
- mappedResult.push(mappedEntry);
35
- }
36
- }
37
- return mappedResult;
38
- }
39
- else {
40
- return _this.getPropValueType(object);
41
- }
42
- };
43
- var mappedEventProps = mapping(eventProperties);
44
- return mappedEventProps;
45
- };
46
- AvoSchemaParser.removeDuplicates = function (array) {
47
- // XXX TODO fix any types
48
- var primitives = { boolean: {}, number: {}, string: {} };
49
- var objects = [];
50
- return array.filter(function (item) {
51
- var type = typeof item;
52
- if (type in primitives) {
53
- return primitives[type].hasOwnProperty(item)
54
- ? false
55
- : (primitives[type][item] = true);
56
- }
57
- else {
58
- return objects.indexOf(item) >= 0 ? false : objects.push(item);
59
- }
60
- });
61
- };
62
- AvoSchemaParser.getPropValueType = function (propValue) {
63
- var propType = typeof propValue;
64
- if (propValue == null) {
65
- return "null";
66
- }
67
- else if (propType === "string") {
68
- return "string";
69
- }
70
- else if (propType === "number" || propType === "bigint") {
71
- if ((propValue + "").indexOf(".") >= 0) {
72
- return "float";
73
- }
74
- else {
75
- return "int";
76
- }
77
- }
78
- else if (propType === "boolean") {
79
- return "boolean";
80
- }
81
- else if (propType === "object") {
82
- if (isArray(propValue)) {
83
- return "list";
84
- }
85
- else {
86
- return "object";
87
- }
88
- }
89
- else {
90
- return "unknown";
91
- }
92
- };
93
- return AvoSchemaParser;
94
- }());
95
- exports.AvoSchemaParser = AvoSchemaParser;
@@ -1,82 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AvoStreamId = void 0;
4
- var AvoGuid_1 = require("./AvoGuid");
5
- var AvoInspector_1 = require("./AvoInspector");
6
- var AvoStreamId = /** @class */ (function () {
7
- function AvoStreamId() {
8
- }
9
- /**
10
- * Returns the persistent anonymous ID (Model A).
11
- * Generates a UUID once and persists it via AsyncStorage.
12
- * Never resets based on time.
13
- * Concurrent calls before cache is populated all return the same UUID.
14
- */
15
- AvoStreamId.initialize = function () {
16
- // Return cached value immediately if available
17
- if (AvoStreamId._anonymousId !== null) {
18
- return Promise.resolve(AvoStreamId._anonymousId);
19
- }
20
- // Return the in-flight promise if initialization is already underway
21
- if (AvoStreamId._initializationPromise !== null) {
22
- return AvoStreamId._initializationPromise;
23
- }
24
- // Guard: if storage isn't initialized yet, fall back to a fresh GUID
25
- if (!AvoInspector_1.AvoInspector.avoStorage) {
26
- var fallbackId = AvoGuid_1.default.newGuid();
27
- AvoStreamId._anonymousId = fallbackId;
28
- return Promise.resolve(fallbackId);
29
- }
30
- // Start initialization and cache the promise to handle concurrent calls
31
- var storagePromise = AvoInspector_1.AvoInspector.avoStorage.getItemAsync(AvoStreamId.cacheKey);
32
- var resolvedPromise = storagePromise && typeof storagePromise.then === "function"
33
- ? storagePromise
34
- : Promise.resolve(null);
35
- AvoStreamId._initializationPromise = resolvedPromise.then(function (maybeId) {
36
- if (maybeId !== null && maybeId !== undefined) {
37
- AvoStreamId._anonymousId = maybeId;
38
- }
39
- else {
40
- AvoStreamId._anonymousId = AvoGuid_1.default.newGuid();
41
- AvoInspector_1.AvoInspector.avoStorage.setItem(AvoStreamId.cacheKey, AvoStreamId._anonymousId);
42
- }
43
- return AvoStreamId._anonymousId;
44
- }).catch(function (error) {
45
- // Reset so callers can retry on next call
46
- AvoStreamId._initializationPromise = null;
47
- // Fall back to a fresh GUID
48
- var fallbackId = AvoGuid_1.default.newGuid();
49
- AvoStreamId._anonymousId = fallbackId;
50
- return fallbackId;
51
- });
52
- return AvoStreamId._initializationPromise;
53
- };
54
- /**
55
- * Sets a custom anonymous ID. Persists to storage.
56
- */
57
- AvoStreamId.setAnonymousId = function (id) {
58
- AvoStreamId._anonymousId = id;
59
- AvoStreamId._initializationPromise = null;
60
- if (AvoInspector_1.AvoInspector.avoStorage) {
61
- AvoInspector_1.AvoInspector.avoStorage.setItem(AvoStreamId.cacheKey, id);
62
- }
63
- };
64
- /**
65
- * Clears the cached anonymous ID. The next access will reload from storage.
66
- */
67
- AvoStreamId.clearCache = function () {
68
- AvoStreamId._anonymousId = null;
69
- AvoStreamId._initializationPromise = null;
70
- };
71
- Object.defineProperty(AvoStreamId, "cacheKey", {
72
- get: function () {
73
- return "AvoInspectorAnonymousId";
74
- },
75
- enumerable: false,
76
- configurable: true
77
- });
78
- AvoStreamId._anonymousId = null;
79
- AvoStreamId._initializationPromise = null;
80
- return AvoStreamId;
81
- }());
82
- exports.AvoStreamId = AvoStreamId;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var xhrMock = {
4
- open: jest.fn(),
5
- send: jest.fn(),
6
- setRequestHeader: jest.fn(),
7
- onload: jest.fn(),
8
- onerror: jest.fn(),
9
- ontimeout: jest.fn(),
10
- status: 200,
11
- response: "{}",
12
- };
13
- window.XMLHttpRequest = jest.fn(function () { return xhrMock; });
14
- exports.default = xhrMock;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var xhrErrorMock = {
4
- open: jest.fn(),
5
- send: jest.fn(),
6
- setRequestHeader: jest.fn(),
7
- onload: jest.fn(),
8
- onerror: jest.fn(),
9
- ontimeout: jest.fn(),
10
- status: 400,
11
- statusText: "Bad Request",
12
- };
13
- window.XMLHttpRequest = jest.fn(function () { return xhrErrorMock; });
14
- exports.default = xhrErrorMock;
@@ -1 +0,0 @@
1
- export {};
@@ -1,272 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * Tests for AvoEncryption (React Native - @noble/ciphers based, fully synchronous).
5
- *
6
- * Covers:
7
- * - shouldEncrypt() truth table
8
- * - Wire format structural tests
9
- * - Cross-SDK interop (TypeScript mirror of Java EncryptionInteropTestUtil)
10
- * - Encryption failure handling
11
- * - List-type property omission
12
- * - publicEncryptionKey in base body
13
- * - Prod negative test
14
- */
15
- var p256_1 = require("@noble/curves/p256");
16
- var aes_1 = require("@noble/ciphers/aes");
17
- var sha256_1 = require("@noble/hashes/sha256");
18
- var AvoEncryption_1 = require("../AvoEncryption");
19
- // =========================================================================
20
- // Helper: TypeScript mirror of Java EncryptionInteropTestUtil.decrypt
21
- // =========================================================================
22
- function hexToBytes(hex) {
23
- var bytes = new Uint8Array(hex.length / 2);
24
- for (var i = 0; i < hex.length; i += 2) {
25
- bytes[i / 2] = parseInt(hex.substring(i, i + 2), 16);
26
- }
27
- return bytes;
28
- }
29
- function bytesToHex(bytes) {
30
- return Array.from(bytes)
31
- .map(function (b) { return b.toString(16).padStart(2, "0"); })
32
- .join("");
33
- }
34
- /**
35
- * Reference decryptor mirroring Java EncryptionInteropTestUtil.decrypt.
36
- * Uses @noble/curves + @noble/ciphers (same libs, but acts as independent verification).
37
- */
38
- function referenceDecrypt(base64Encrypted, privateKeyHex) {
39
- var data = Buffer.from(base64Encrypted, "base64");
40
- // Minimum length: 1 (version) + 65 (ephemeral pub key) + 16 (IV) + 16 (auth tag) + 1 (min ciphertext)
41
- if (data.length < 99) {
42
- throw new Error("Encrypted data too short: expected at least 99 bytes, got ".concat(data.length));
43
- }
44
- // Step 2: Assert version byte
45
- if (data[0] !== 0x00) {
46
- throw new Error("Unsupported version byte: expected 0x00, got 0x".concat(data[0].toString(16).padStart(2, "0")));
47
- }
48
- // Step 3: Extract ephemeral public key bytes [1..65] (65 bytes, uncompressed EC point)
49
- var ephemeralPubKeyBytes = new Uint8Array(data.slice(1, 66));
50
- // Step 4: Extract IV [66..81] (16 bytes)
51
- var iv = new Uint8Array(data.slice(66, 82));
52
- // Step 5: Extract auth tag [82..97] (16 bytes)
53
- var authTag = new Uint8Array(data.slice(82, 98));
54
- // Step 6: Extract ciphertext [98..N]
55
- var ciphertext = new Uint8Array(data.slice(98));
56
- // Step 7-8: ECDH with recipient private key -> sharedSecret
57
- var privateKeyBytes = hexToBytes(privateKeyHex);
58
- var sharedSecretPoint = p256_1.p256.getSharedSecret(privateKeyBytes, ephemeralPubKeyBytes);
59
- var sharedSecret = sharedSecretPoint.slice(-32); // X-coordinate
60
- // Step 9: KDF: SHA-256(sharedSecret) -> aesKey
61
- var aesKey = (0, sha256_1.sha256)(sharedSecret);
62
- // Step 10: AES/GCM decrypt
63
- // @noble/ciphers gcm expects ciphertext + authTag concatenated
64
- var ciphertextWithTag = new Uint8Array(ciphertext.length + authTag.length);
65
- ciphertextWithTag.set(ciphertext, 0);
66
- ciphertextWithTag.set(authTag, ciphertext.length);
67
- var aes = (0, aes_1.gcm)(aesKey, iv);
68
- var plainBytes = aes.decrypt(ciphertextWithTag);
69
- // Step 11: Return as UTF-8 string
70
- return new TextDecoder().decode(plainBytes);
71
- }
72
- // =========================================================================
73
- // Generate a test key pair
74
- // =========================================================================
75
- function generateTestKeyPair() {
76
- var privateKeyBytes = p256_1.p256.utils.randomPrivateKey();
77
- var publicKeyBytes = p256_1.p256.getPublicKey(privateKeyBytes, false);
78
- return {
79
- privateKey: bytesToHex(privateKeyBytes).padStart(64, "0"),
80
- publicKey: bytesToHex(publicKeyBytes),
81
- };
82
- }
83
- // =========================================================================
84
- // Tests
85
- // =========================================================================
86
- describe("AvoEncryption (React Native - @noble/ciphers)", function () {
87
- // -----------------------------------------------------------------------
88
- // shouldEncrypt() truth table
89
- // -----------------------------------------------------------------------
90
- describe("shouldEncrypt()", function () {
91
- test("dev + valid key = true", function () {
92
- expect((0, AvoEncryption_1.shouldEncrypt)("dev", "04abcdef1234")).toBe(true);
93
- });
94
- test("staging + valid key = true", function () {
95
- expect((0, AvoEncryption_1.shouldEncrypt)("staging", "04abcdef1234")).toBe(true);
96
- });
97
- test("prod + valid key = false", function () {
98
- expect((0, AvoEncryption_1.shouldEncrypt)("prod", "04abcdef1234")).toBe(false);
99
- });
100
- test("dev + null key = false", function () {
101
- expect((0, AvoEncryption_1.shouldEncrypt)("dev", null)).toBe(false);
102
- });
103
- test("dev + undefined key = false", function () {
104
- expect((0, AvoEncryption_1.shouldEncrypt)("dev", undefined)).toBe(false);
105
- });
106
- test("dev + empty string key = false", function () {
107
- expect((0, AvoEncryption_1.shouldEncrypt)("dev", "")).toBe(false);
108
- });
109
- test("dev + whitespace-only key = false", function () {
110
- expect((0, AvoEncryption_1.shouldEncrypt)("dev", " ")).toBe(false);
111
- });
112
- });
113
- // -----------------------------------------------------------------------
114
- // Wire format structural test
115
- // -----------------------------------------------------------------------
116
- describe("Wire format", function () {
117
- var keyPair = generateTestKeyPair();
118
- test("base64Decode(output).length >= 99", function () {
119
- var encrypted = (0, AvoEncryption_1.encryptValue)("hello world", keyPair.publicKey);
120
- var decoded = Buffer.from(encrypted, "base64");
121
- expect(decoded.length).toBeGreaterThanOrEqual(99);
122
- });
123
- test("output[0] == 0x00 (version byte)", function () {
124
- var encrypted = (0, AvoEncryption_1.encryptValue)("hello world", keyPair.publicKey);
125
- var decoded = Buffer.from(encrypted, "base64");
126
- expect(decoded[0]).toBe(0x00);
127
- });
128
- test("output[1] == 0x04 (uncompressed point marker)", function () {
129
- var encrypted = (0, AvoEncryption_1.encryptValue)("hello world", keyPair.publicKey);
130
- var decoded = Buffer.from(encrypted, "base64");
131
- expect(decoded[1]).toBe(0x04);
132
- });
133
- test("encryptValue is synchronous (returns string, not Promise)", function () {
134
- var result = (0, AvoEncryption_1.encryptValue)("test", keyPair.publicKey);
135
- // If it were async, result would be a Promise, not a string
136
- expect(typeof result).toBe("string");
137
- // Ensure it's NOT a Promise
138
- expect(result).not.toBeInstanceOf(Promise);
139
- });
140
- test("different encryptions produce different output", function () {
141
- var enc1 = (0, AvoEncryption_1.encryptValue)("same", keyPair.publicKey);
142
- var enc2 = (0, AvoEncryption_1.encryptValue)("same", keyPair.publicKey);
143
- expect(enc1).not.toBe(enc2);
144
- });
145
- });
146
- // -----------------------------------------------------------------------
147
- // Cross-SDK interop: RN-encrypted ciphertext decryptable by reference decryptor
148
- // -----------------------------------------------------------------------
149
- describe("Cross-SDK interop", function () {
150
- var keyPair = generateTestKeyPair();
151
- var standardPlaintexts = [
152
- '"hello world"',
153
- "42",
154
- "3.14",
155
- "true",
156
- '"test string value"',
157
- ];
158
- standardPlaintexts.forEach(function (plaintext) {
159
- test("RN encrypt -> reference decrypt: ".concat(plaintext), function () {
160
- var encrypted = (0, AvoEncryption_1.encryptValue)(plaintext, keyPair.publicKey);
161
- var decrypted = referenceDecrypt(encrypted, keyPair.privateKey);
162
- expect(decrypted).toBe(plaintext);
163
- });
164
- });
165
- test("round-trip with JSON-stringified object", function () {
166
- var obj = { key: "value", number: 123 };
167
- var jsonStr = JSON.stringify(obj);
168
- var encrypted = (0, AvoEncryption_1.encryptValue)(jsonStr, keyPair.publicKey);
169
- var decrypted = referenceDecrypt(encrypted, keyPair.privateKey);
170
- expect(decrypted).toBe(jsonStr);
171
- });
172
- });
173
- // -----------------------------------------------------------------------
174
- // encryptEventProperties
175
- // -----------------------------------------------------------------------
176
- describe("encryptEventProperties()", function () {
177
- var keyPair = generateTestKeyPair();
178
- test("encrypts string property values", function () {
179
- var properties = [
180
- { propertyName: "name", propertyType: "string" },
181
- ];
182
- var eventProps = { name: "Alice" };
183
- var result = (0, AvoEncryption_1.encryptEventProperties)(properties, eventProps, keyPair.publicKey);
184
- expect(result).toHaveLength(1);
185
- expect(result[0].propertyName).toBe("name");
186
- expect(result[0].propertyType).toBe("string");
187
- expect(result[0].encryptedPropertyValue).toBeDefined();
188
- // Verify it decrypts correctly
189
- var decrypted = referenceDecrypt(result[0].encryptedPropertyValue, keyPair.privateKey);
190
- expect(JSON.parse(decrypted)).toBe("Alice");
191
- });
192
- test("encrypts int property values", function () {
193
- var properties = [
194
- { propertyName: "age", propertyType: "int" },
195
- ];
196
- var eventProps = { age: 42 };
197
- var result = (0, AvoEncryption_1.encryptEventProperties)(properties, eventProps, keyPair.publicKey);
198
- expect(result[0].encryptedPropertyValue).toBeDefined();
199
- var decrypted = referenceDecrypt(result[0].encryptedPropertyValue, keyPair.privateKey);
200
- expect(JSON.parse(decrypted)).toBe(42);
201
- });
202
- test("encrypts boolean property values", function () {
203
- var properties = [
204
- { propertyName: "active", propertyType: "boolean" },
205
- ];
206
- var eventProps = { active: true };
207
- var result = (0, AvoEncryption_1.encryptEventProperties)(properties, eventProps, keyPair.publicKey);
208
- expect(result[0].encryptedPropertyValue).toBeDefined();
209
- var decrypted = referenceDecrypt(result[0].encryptedPropertyValue, keyPair.privateKey);
210
- expect(JSON.parse(decrypted)).toBe(true);
211
- });
212
- test("omits list-type properties entirely", function () {
213
- var properties = [
214
- { propertyName: "tags", propertyType: "list", children: ["string"] },
215
- { propertyName: "name", propertyType: "string" },
216
- ];
217
- var eventProps = { tags: ["a", "b"], name: "Alice" };
218
- var result = (0, AvoEncryption_1.encryptEventProperties)(properties, eventProps, keyPair.publicKey);
219
- // list property should be omitted entirely
220
- expect(result).toHaveLength(1);
221
- expect(result[0].propertyName).toBe("name");
222
- });
223
- test("encryption failure: console.warn, omit property, continue", function () {
224
- var warnSpy = jest.spyOn(console, "warn").mockImplementation();
225
- var properties = [
226
- { propertyName: "secret", propertyType: "string" },
227
- { propertyName: "name", propertyType: "string" },
228
- ];
229
- var eventProps = { secret: "value1", name: "value2" };
230
- // Use an invalid public key to trigger encryption failure for the first property
231
- // We can't easily make only one fail, so let's test with a completely invalid key
232
- var result = (0, AvoEncryption_1.encryptEventProperties)(properties, eventProps, "invalid-key");
233
- // Both should fail with invalid key, so both should be omitted
234
- expect(result).toHaveLength(0);
235
- expect(warnSpy).toHaveBeenCalledTimes(1);
236
- // Check that warning message matches expected format
237
- var calls = warnSpy.mock.calls;
238
- expect(calls.some(function (call) {
239
- return String(call[0]).includes("[Avo Inspector] Encryption failed:");
240
- })).toBe(true);
241
- warnSpy.mockRestore();
242
- });
243
- test("null property values are encrypted as null", function () {
244
- var properties = [
245
- { propertyName: "nullProp", propertyType: "null" },
246
- ];
247
- var eventProps = { nullProp: null };
248
- var result = (0, AvoEncryption_1.encryptEventProperties)(properties, eventProps, keyPair.publicKey);
249
- expect(result).toHaveLength(1);
250
- expect(result[0].encryptedPropertyValue).toBeDefined();
251
- var decrypted = referenceDecrypt(result[0].encryptedPropertyValue, keyPair.privateKey);
252
- expect(JSON.parse(decrypted)).toBeNull();
253
- });
254
- test("object property values are encrypted", function () {
255
- var properties = [
256
- {
257
- propertyName: "address",
258
- propertyType: "object",
259
- children: [
260
- { propertyName: "street", propertyType: "string" },
261
- ],
262
- },
263
- ];
264
- var eventProps = { address: { street: "123 Main St" } };
265
- var result = (0, AvoEncryption_1.encryptEventProperties)(properties, eventProps, keyPair.publicKey);
266
- expect(result).toHaveLength(1);
267
- expect(result[0].encryptedPropertyValue).toBeDefined();
268
- var decrypted = referenceDecrypt(result[0].encryptedPropertyValue, keyPair.privateKey);
269
- expect(JSON.parse(decrypted)).toEqual({ street: "123 Main St" });
270
- });
271
- });
272
- });
@@ -1 +0,0 @@
1
- export {};