node-avo-inspector 1.2.0-alpha.1 → 2.0.0-beta.1

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 (105) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +268 -4
  3. package/package.json +17 -1
  4. package/.claude/scheduled_tasks.lock +0 -1
  5. package/.claude/settings.local.json +0 -11
  6. package/.claude/worktrees/release-1.1.1/LICENSE +0 -21
  7. package/.claude/worktrees/release-1.1.1/README.md +0 -69
  8. package/.claude/worktrees/release-1.1.1/examples/node-inspector-js/index.js +0 -30
  9. package/.claude/worktrees/release-1.1.1/examples/node-inspector-js/package.json +0 -15
  10. package/.claude/worktrees/release-1.1.1/examples/node-inspector-js/yarn.lock +0 -6
  11. package/.claude/worktrees/release-1.1.1/examples/node-inspector-ts/dist/index.js +0 -34
  12. package/.claude/worktrees/release-1.1.1/examples/node-inspector-ts/index.ts +0 -30
  13. package/.claude/worktrees/release-1.1.1/examples/node-inspector-ts/package.json +0 -18
  14. package/.claude/worktrees/release-1.1.1/examples/node-inspector-ts/tsconfig.json +0 -15
  15. package/.claude/worktrees/release-1.1.1/examples/node-inspector-ts/yarn.lock +0 -11
  16. package/.claude/worktrees/release-1.1.1/package-lock.json +0 -4039
  17. package/.claude/worktrees/release-1.1.1/package.json +0 -48
  18. package/.claude/worktrees/release-1.1.1/reason/AvoInspector.rei +0 -11
  19. package/.claude/worktrees/release-1.1.1/reason/NodeAvoInspector.re +0 -27
  20. package/.claude/worktrees/release-1.1.1/src/AvoDeduplicator.ts +0 -146
  21. package/.claude/worktrees/release-1.1.1/src/AvoEncryption.ts +0 -90
  22. package/.claude/worktrees/release-1.1.1/src/AvoGuid.ts +0 -9
  23. package/.claude/worktrees/release-1.1.1/src/AvoInspector.ts +0 -383
  24. package/.claude/worktrees/release-1.1.1/src/AvoInspectorEnv.ts +0 -8
  25. package/.claude/worktrees/release-1.1.1/src/AvoNetworkCallsHandler.ts +0 -267
  26. package/.claude/worktrees/release-1.1.1/src/AvoSchemaParser.ts +0 -115
  27. package/.claude/worktrees/release-1.1.1/src/AvoStreamId.ts +0 -16
  28. package/.claude/worktrees/release-1.1.1/src/__tests__/TestAvoEncryption.ts +0 -515
  29. package/.claude/worktrees/release-1.1.1/src/__tests__/TestAvoEventSpecCache.ts +0 -242
  30. package/.claude/worktrees/release-1.1.1/src/__tests__/TestAvoEventSpecFetcher.ts +0 -241
  31. package/.claude/worktrees/release-1.1.1/src/__tests__/TestAvoInspector.ts +0 -360
  32. package/.claude/worktrees/release-1.1.1/src/__tests__/TestAvoStreamId.ts +0 -72
  33. package/.claude/worktrees/release-1.1.1/src/__tests__/TestDeduplicator.ts +0 -191
  34. package/.claude/worktrees/release-1.1.1/src/__tests__/TestEventValidator.ts +0 -231
  35. package/.claude/worktrees/release-1.1.1/src/__tests__/TestNetworkCallsHandler.ts +0 -179
  36. package/.claude/worktrees/release-1.1.1/src/__tests__/TestNetworkCallsHandlerPublic.ts +0 -208
  37. package/.claude/worktrees/release-1.1.1/src/__tests__/TestParsing.ts +0 -153
  38. package/.claude/worktrees/release-1.1.1/src/__tests__/constants.ts +0 -63
  39. package/.claude/worktrees/release-1.1.1/src/eventSpec/AvoEventSpecCache.ts +0 -109
  40. package/.claude/worktrees/release-1.1.1/src/eventSpec/AvoEventSpecFetchTypes.ts +0 -47
  41. package/.claude/worktrees/release-1.1.1/src/eventSpec/AvoEventSpecFetcher.ts +0 -106
  42. package/.claude/worktrees/release-1.1.1/src/eventSpec/EventValidator.ts +0 -74
  43. package/.claude/worktrees/release-1.1.1/src/index.ts +0 -2
  44. package/.claude/worktrees/release-1.1.1/src/utils.ts +0 -49
  45. package/.claude/worktrees/release-1.1.1/tsconfig.json +0 -13
  46. package/.claude/worktrees/release-1.1.1/yarn.lock +0 -2310
  47. package/.github/workflows/claude.yml +0 -55
  48. package/dist/__tests__/TestAvoEncryption.d.ts +0 -1
  49. package/dist/__tests__/TestAvoEncryption.js +0 -288
  50. package/dist/__tests__/TestAvoEventSpecCache.d.ts +0 -1
  51. package/dist/__tests__/TestAvoEventSpecCache.js +0 -194
  52. package/dist/__tests__/TestAvoEventSpecFetcher.d.ts +0 -1
  53. package/dist/__tests__/TestAvoEventSpecFetcher.js +0 -219
  54. package/dist/__tests__/TestAvoInspector.d.ts +0 -1
  55. package/dist/__tests__/TestAvoInspector.js +0 -291
  56. package/dist/__tests__/TestAvoStreamId.d.ts +0 -1
  57. package/dist/__tests__/TestAvoStreamId.js +0 -55
  58. package/dist/__tests__/TestDeduplicator.d.ts +0 -1
  59. package/dist/__tests__/TestDeduplicator.js +0 -102
  60. package/dist/__tests__/TestEventValidator.d.ts +0 -1
  61. package/dist/__tests__/TestEventValidator.js +0 -196
  62. package/dist/__tests__/TestNetworkCallsHandler.d.ts +0 -1
  63. package/dist/__tests__/TestNetworkCallsHandler.js +0 -86
  64. package/dist/__tests__/TestNetworkCallsHandlerPublic.d.ts +0 -1
  65. package/dist/__tests__/TestNetworkCallsHandlerPublic.js +0 -160
  66. package/dist/__tests__/TestParsing.d.ts +0 -1
  67. package/dist/__tests__/TestParsing.js +0 -128
  68. package/dist/__tests__/constants.d.ts +0 -42
  69. package/dist/__tests__/constants.js +0 -53
  70. package/examples/node-inspector-js/index.js +0 -30
  71. package/examples/node-inspector-js/package.json +0 -15
  72. package/examples/node-inspector-js/yarn.lock +0 -6
  73. package/examples/node-inspector-ts/dist/index.js +0 -34
  74. package/examples/node-inspector-ts/index.ts +0 -30
  75. package/examples/node-inspector-ts/package.json +0 -18
  76. package/examples/node-inspector-ts/tsconfig.json +0 -15
  77. package/examples/node-inspector-ts/yarn.lock +0 -11
  78. package/reason/AvoInspector.rei +0 -11
  79. package/reason/NodeAvoInspector.re +0 -27
  80. package/src/AvoDeduplicator.ts +0 -150
  81. package/src/AvoEncryption.ts +0 -90
  82. package/src/AvoGuid.ts +0 -9
  83. package/src/AvoInspector.ts +0 -498
  84. package/src/AvoInspectorEnv.ts +0 -8
  85. package/src/AvoNetworkCallsHandler.ts +0 -340
  86. package/src/AvoSchemaParser.ts +0 -115
  87. package/src/AvoStreamId.ts +0 -16
  88. package/src/__tests__/TestAvoEncryption.ts +0 -515
  89. package/src/__tests__/TestAvoEventSpecCache.ts +0 -242
  90. package/src/__tests__/TestAvoEventSpecFetcher.ts +0 -279
  91. package/src/__tests__/TestAvoInspector.ts +0 -376
  92. package/src/__tests__/TestAvoStreamId.ts +0 -72
  93. package/src/__tests__/TestDeduplicator.ts +0 -191
  94. package/src/__tests__/TestEventValidator.ts +0 -231
  95. package/src/__tests__/TestNetworkCallsHandler.ts +0 -181
  96. package/src/__tests__/TestNetworkCallsHandlerPublic.ts +0 -208
  97. package/src/__tests__/TestParsing.ts +0 -153
  98. package/src/__tests__/constants.ts +0 -63
  99. package/src/eventSpec/AvoEventSpecCache.ts +0 -119
  100. package/src/eventSpec/AvoEventSpecFetchTypes.ts +0 -47
  101. package/src/eventSpec/AvoEventSpecFetcher.ts +0 -186
  102. package/src/eventSpec/EventValidator.ts +0 -74
  103. package/src/index.ts +0 -2
  104. package/src/utils.ts +0 -49
  105. package/tsconfig.json +0 -13
@@ -1,48 +0,0 @@
1
- {
2
- "name": "node-avo-inspector",
3
- "version": "1.1.1",
4
- "description": "Avo Inspector for Node.js",
5
- "main": "dist/index.js",
6
- "repository": "https://github.com/avohq/node-avo-inspector",
7
- "author": "Avo (https://www.avo.app)",
8
- "license": "MIT",
9
- "private": false,
10
- "bugs": {
11
- "url": "https://github.com/avohq/node-avo-inspector/issues"
12
- },
13
- "homepage": "https://github.com/avohq/node-avo-inspector#readme",
14
- "scripts": {
15
- "build": "tsc --outDir dist",
16
- "test": "jest",
17
- "typecheck": "tsc --noEmit"
18
- },
19
- "jest": {
20
- "transform": {
21
- "^.+\\.[j]sx?$": "babel-jest",
22
- "^.+\\.[t]sx?$": "ts-jest"
23
- },
24
- "testPathIgnorePatterns": [
25
- "constants",
26
- "examples",
27
- "node_modules",
28
- "dist",
29
- "dist-native"
30
- ],
31
- "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
32
- "moduleFileExtensions": [
33
- "ts",
34
- "tsx",
35
- "js"
36
- ]
37
- },
38
- "devDependencies": {
39
- "@types/jest": "^29.5.12",
40
- "@types/node": "^22.3.0",
41
- "jest": "^29.7.0",
42
- "ts-jest": "^29.2.4",
43
- "typescript": "*"
44
- },
45
- "dependencies": {
46
- "safe-regex2": "^5.0.0"
47
- }
48
- }
@@ -1,11 +0,0 @@
1
- type t;
2
-
3
- type env = [
4
- | `Dev
5
- | `Staging
6
- | `Prod
7
- ];
8
-
9
- let make: (~apiKey: string, ~env: env, ~version: string, , ~appName: string, unit) => t;
10
-
11
- let trackSchemaFromEvent: t => string => Js.Json.t => Js.Promise.t(unit);
@@ -1,27 +0,0 @@
1
- type t;
2
-
3
- [@bs.deriving jsConverter]
4
- type env = [
5
- | [@bs.as "dev"] `Dev
6
- | [@bs.as "staging"] `Staging
7
- | [@bs.as "prod"] `Prod
8
- ];
9
-
10
- [@bs.deriving abstract]
11
- type options = {
12
- apiKey: string,
13
- env: string,
14
- version: string,
15
- appName: string,
16
- };
17
-
18
- [@bs.new] [@bs.module "node-avo-inspector"]
19
- external make: options => t = "AvoInspector";
20
-
21
- let make = (~apiKey, ~env, ~version, ~appName, ()) => {
22
- make(options(~apiKey, ~env=envToJs(env), ~version, ~appName));
23
- };
24
-
25
- [@bs.send]
26
- external trackSchemaFromEvent: (t, string, Js.Json.t) => Js.Promise.t(unit) =
27
- "trackSchemaFromEvent";
@@ -1,146 +0,0 @@
1
- import { deepEquals } from "./utils";
2
-
3
- export class AvoDeduplicator {
4
- avoFunctionsEvents: { [time: number]: string } = {};
5
- manualEvents: { [time: number]: string } = {};
6
- private msToConsiderOld = 500;
7
-
8
- avoFunctionsEventsParams: {
9
- [eventName: string]: { [propName: string]: any };
10
- } = {};
11
- manualEventsParams: { [eventName: string]: { [propName: string]: any } } = {};
12
-
13
- shouldRegisterEvent(
14
- eventName: string,
15
- params: { [propName: string]: any },
16
- fromAvoFunction: boolean
17
- ): boolean {
18
- this.clearOldEvents();
19
-
20
- if (fromAvoFunction) {
21
- this.avoFunctionsEvents[Date.now()] = eventName;
22
- this.avoFunctionsEventsParams[eventName] = params;
23
- } else {
24
- this.manualEvents[Date.now()] = eventName;
25
- this.manualEventsParams[eventName] = params;
26
- }
27
-
28
- let checkInAvoFunctions = !fromAvoFunction;
29
-
30
- return !this.hasSameEventAs(eventName, params, checkInAvoFunctions);
31
- }
32
-
33
- private hasSameEventAs(
34
- eventName: string,
35
- params: { [propName: string]: any },
36
- checkInAvoFunctions: boolean
37
- ): boolean {
38
- let result = false;
39
-
40
- if (checkInAvoFunctions) {
41
- if (
42
- this.lookForEventIn(eventName, params, this.avoFunctionsEventsParams)
43
- ) {
44
- result = true;
45
- }
46
- } else {
47
- if (this.lookForEventIn(eventName, params, this.manualEventsParams)) {
48
- result = true;
49
- }
50
- }
51
-
52
- if (result) {
53
- delete this.avoFunctionsEventsParams[eventName];
54
- delete this.manualEventsParams[eventName];
55
- }
56
-
57
- return result;
58
- }
59
-
60
- private lookForEventIn(
61
- eventName: string,
62
- params: { [propName: string]: any },
63
- eventsStorage: { [eventName: string]: { [propName: string]: any } }
64
- ): boolean {
65
- for (const otherEventName in eventsStorage) {
66
- if (eventsStorage.hasOwnProperty(otherEventName)) {
67
- if (otherEventName === eventName) {
68
- const otherParams = eventsStorage[eventName];
69
- if (otherParams && deepEquals(params, otherParams)) {
70
- return true;
71
- }
72
- }
73
- }
74
- }
75
- return false;
76
- }
77
-
78
- hasSeenEventParams(
79
- params: { [propName: string]: any },
80
- checkInAvoFunctions: boolean
81
- ) {
82
- let result = false;
83
-
84
- if (checkInAvoFunctions) {
85
- if (this.lookForEventParamsIn(params, this.avoFunctionsEventsParams)) {
86
- result = true;
87
- }
88
- } else {
89
- if (this.lookForEventParamsIn(params, this.manualEventsParams)) {
90
- result = true;
91
- }
92
- }
93
-
94
- return result;
95
- }
96
-
97
- private lookForEventParamsIn(
98
- params: { [propName: string]: any },
99
- eventsStorage: { [eventName: string]: { [propName: string]: any } }
100
- ): boolean {
101
- for (const otherEventName in eventsStorage) {
102
- if (eventsStorage.hasOwnProperty(otherEventName)) {
103
- const otherParams = eventsStorage[otherEventName];
104
- if (otherParams && deepEquals(params, otherParams)) {
105
- return true;
106
- }
107
- }
108
- }
109
- return false;
110
- }
111
-
112
- private clearOldEvents() {
113
- const now = Date.now();
114
-
115
- for (const time in this.avoFunctionsEvents) {
116
- if (this.avoFunctionsEvents.hasOwnProperty(time)) {
117
- const timestamp = Number(time) || 0;
118
- if (now - timestamp > this.msToConsiderOld) {
119
- const eventName = this.avoFunctionsEvents[time];
120
- delete this.avoFunctionsEvents[time];
121
- delete this.avoFunctionsEventsParams[eventName];
122
- }
123
- }
124
- }
125
-
126
- for (const time in this.manualEvents) {
127
- if (this.manualEvents.hasOwnProperty(time)) {
128
- const timestamp = Number(time) || 0;
129
- if (now - timestamp > this.msToConsiderOld) {
130
- const eventName = this.manualEvents[time];
131
- delete this.manualEvents[time];
132
- delete this.manualEventsParams[eventName];
133
- }
134
- }
135
- }
136
- }
137
-
138
- // used in tests
139
- private _clearEvents() {
140
- this.avoFunctionsEvents = {};
141
- this.manualEvents = {};
142
-
143
- this.avoFunctionsEventsParams = {};
144
- this.manualEventsParams = {};
145
- }
146
- }
@@ -1,90 +0,0 @@
1
- import * as crypto from "crypto";
2
-
3
- export class AvoEncryption {
4
- /**
5
- * Determines whether encryption should be applied.
6
- *
7
- * Truth table:
8
- * dev + key => true
9
- * staging + key => true
10
- * prod + key => false
11
- * dev + null => false
12
- * dev + "" => false
13
- */
14
- static shouldEncrypt(
15
- env: string,
16
- publicEncryptionKey: string | undefined | null
17
- ): boolean {
18
- if (!publicEncryptionKey || publicEncryptionKey.length === 0) {
19
- return false;
20
- }
21
- if (env === "prod") {
22
- return false;
23
- }
24
- return true;
25
- }
26
-
27
- /**
28
- * Returns true if the propertyType represents a list type (e.g. "list(string)").
29
- */
30
- static isListType(propertyType: string): boolean {
31
- return propertyType.startsWith("list(");
32
- }
33
-
34
- /**
35
- * Encrypts a string value using ECIES with prime256v1.
36
- *
37
- * Wire format: [0x00][65-byte ephemeral pubkey][16-byte IV][16-byte auth tag][ciphertext]
38
- * Output is base64-encoded.
39
- *
40
- * Returns null on failure, logging a warning.
41
- */
42
- static encryptValue(
43
- value: string,
44
- recipientPubKeyHex: string
45
- ): string | null {
46
- try {
47
- const recipientPubKey = Buffer.from(recipientPubKeyHex, "hex");
48
-
49
- // Generate ephemeral key pair
50
- const ecdh = crypto.createECDH("prime256v1");
51
- ecdh.generateKeys();
52
- const ephemeralPubKey = ecdh.getPublicKey(); // 65 bytes, uncompressed
53
-
54
- // Compute shared secret (raw 32-byte X-coordinate)
55
- const sharedSecret = ecdh.computeSecret(recipientPubKey);
56
-
57
- // Derive AES key via SHA-256
58
- const aesKey = crypto.createHash("sha256").update(sharedSecret).digest();
59
-
60
- // Generate random 16-byte IV
61
- const iv = crypto.randomBytes(16);
62
-
63
- // Encrypt with AES-256-GCM
64
- const cipher = crypto.createCipheriv("aes-256-gcm", aesKey, iv, {
65
- authTagLength: 16,
66
- });
67
- const encrypted = Buffer.concat([
68
- cipher.update(value, "utf8"),
69
- cipher.final(),
70
- ]);
71
- const authTag = cipher.getAuthTag(); // 16 bytes
72
-
73
- // Assemble wire format: [version][ephemeralPubKey][IV][authTag][ciphertext]
74
- const wire = Buffer.concat([
75
- Buffer.from([0x00]), // version byte
76
- ephemeralPubKey, // 65 bytes
77
- iv, // 16 bytes
78
- authTag, // 16 bytes
79
- encrypted, // variable length
80
- ]);
81
-
82
- return wire.toString("base64");
83
- } catch (e) {
84
- console.warn(
85
- `[Avo Inspector] Warning: encryption failed for value, omitting property. ${e}`
86
- );
87
- return null;
88
- }
89
- }
90
- }
@@ -1,9 +0,0 @@
1
- export class AvoGuid {
2
- static newGuid(): string {
3
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
4
- var r = (Math.random() * 16) | 0,
5
- v = c == "x" ? r : (r & 0x3) | 0x8;
6
- return v.toString(16);
7
- });
8
- }
9
- }