@metamask-previews/notification-services-controller 0.1.0-preview-1f998a49 → 0.1.0-preview-30646c8e

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 (138) hide show
  1. package/dist/NotificationServicesController/NotificationServicesController.js +7 -7
  2. package/dist/NotificationServicesController/NotificationServicesController.mjs +6 -6
  3. package/dist/NotificationServicesController/constants/constants.js +1 -1
  4. package/dist/NotificationServicesController/constants/constants.mjs +1 -1
  5. package/dist/NotificationServicesController/constants/index.js +6 -4
  6. package/dist/NotificationServicesController/constants/index.mjs +5 -3
  7. package/dist/NotificationServicesController/constants/notification-schema.js +5 -3
  8. package/dist/NotificationServicesController/constants/notification-schema.mjs +4 -2
  9. package/dist/NotificationServicesController/index.js +12 -12
  10. package/dist/NotificationServicesController/index.mjs +11 -11
  11. package/dist/NotificationServicesController/processors/index.js +5 -5
  12. package/dist/NotificationServicesController/processors/index.mjs +4 -4
  13. package/dist/NotificationServicesController/processors/process-feature-announcement.js +1 -1
  14. package/dist/NotificationServicesController/processors/process-feature-announcement.mjs +1 -1
  15. package/dist/NotificationServicesController/processors/process-notifications.js +4 -4
  16. package/dist/NotificationServicesController/processors/process-notifications.mjs +3 -3
  17. package/dist/NotificationServicesController/processors/process-onchain-notifications.js +1 -1
  18. package/dist/NotificationServicesController/processors/process-onchain-notifications.mjs +1 -1
  19. package/dist/NotificationServicesController/services/feature-announcements.js +2 -2
  20. package/dist/NotificationServicesController/services/feature-announcements.mjs +2 -2
  21. package/dist/NotificationServicesController/services/onchain-notifications.js +5 -5
  22. package/dist/NotificationServicesController/services/onchain-notifications.mjs +4 -4
  23. package/dist/NotificationServicesController/types/index.js +2 -2
  24. package/dist/NotificationServicesController/types/index.mjs +2 -2
  25. package/dist/NotificationServicesController/ui/constants.js +40 -0
  26. package/dist/NotificationServicesController/ui/constants.js.map +1 -0
  27. package/dist/NotificationServicesController/ui/constants.mjs +40 -0
  28. package/dist/NotificationServicesController/ui/constants.mjs.map +1 -0
  29. package/dist/NotificationServicesController/utils/utils.js +4 -4
  30. package/dist/NotificationServicesController/utils/utils.mjs +3 -3
  31. package/dist/NotificationServicesPushController/NotificationServicesPushController.js +15 -15
  32. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +14 -14
  33. package/dist/NotificationServicesPushController/constants.js +1 -1
  34. package/dist/NotificationServicesPushController/constants.mjs +1 -1
  35. package/dist/NotificationServicesPushController/index.js +18 -18
  36. package/dist/NotificationServicesPushController/index.mjs +17 -17
  37. package/dist/NotificationServicesPushController/services/endpoints.js +1 -1
  38. package/dist/NotificationServicesPushController/services/endpoints.mjs +1 -1
  39. package/dist/NotificationServicesPushController/services/push/push-web.js +13 -13
  40. package/dist/NotificationServicesPushController/services/push/push-web.mjs +12 -12
  41. package/dist/NotificationServicesPushController/services/services.js +14 -14
  42. package/dist/NotificationServicesPushController/services/services.mjs +13 -13
  43. package/dist/NotificationServicesPushController/utils/get-notification-data.js +1 -1
  44. package/dist/NotificationServicesPushController/utils/get-notification-data.mjs +1 -1
  45. package/dist/NotificationServicesPushController/utils/get-notification-message.js +13 -13
  46. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs +12 -12
  47. package/dist/NotificationServicesPushController/utils/index.js +14 -14
  48. package/dist/NotificationServicesPushController/utils/index.mjs +13 -13
  49. package/dist/{chunk-NXXY4CAP.js → chunk-3RRAJSTZ.js} +9 -36
  50. package/dist/chunk-3RRAJSTZ.js.map +1 -0
  51. package/dist/{chunk-RYAHBEX2.mjs → chunk-54BC2GAN.mjs} +29 -9
  52. package/dist/chunk-54BC2GAN.mjs.map +1 -0
  53. package/dist/{chunk-GFAESVZA.js → chunk-5FUMSWDD.js} +3 -3
  54. package/dist/chunk-5SY7FJXH.mjs +925 -0
  55. package/dist/chunk-5SY7FJXH.mjs.map +1 -0
  56. package/dist/{chunk-ODZ6V4PH.mjs → chunk-5WMDB2VE.mjs} +4 -4
  57. package/dist/{chunk-SSWX2N73.mjs → chunk-6GUOLD7O.mjs} +2 -2
  58. package/dist/{chunk-NJBJIZLR.js → chunk-72H2V4J5.js} +6 -7
  59. package/dist/chunk-72H2V4J5.js.map +1 -0
  60. package/dist/{chunk-SMKJEA45.mjs → chunk-7S6524FI.mjs} +2 -2
  61. package/dist/{chunk-PIZCE3JD.js → chunk-7U22ZANC.js} +5 -5
  62. package/dist/{chunk-52NKJDI2.mjs → chunk-A5QFYBTR.mjs} +5 -6
  63. package/dist/chunk-A5QFYBTR.mjs.map +1 -0
  64. package/dist/{chunk-TT56I53C.mjs → chunk-ADYRLXWY.mjs} +2 -2
  65. package/dist/{chunk-LFD7J7KR.mjs → chunk-B3OMMG46.mjs} +6 -33
  66. package/dist/chunk-B3OMMG46.mjs.map +1 -0
  67. package/dist/{chunk-PGMXFZ6Y.js → chunk-BUT7X5F2.js} +3 -3
  68. package/dist/{chunk-JLHFZ2UG.mjs → chunk-DCADU5QI.mjs} +3 -3
  69. package/dist/{chunk-FFQNSBPU.js → chunk-ENRKCWJ6.js} +7 -7
  70. package/dist/{chunk-NMLYB3XT.js → chunk-GJHW5Z65.js} +4 -4
  71. package/dist/chunk-IGY2S5BC.js +36 -0
  72. package/dist/{chunk-VC6J62JI.mjs → chunk-J4D2NH6Y.mjs} +4 -2
  73. package/dist/chunk-J4D2NH6Y.mjs.map +1 -0
  74. package/dist/{chunk-RQWUD2FB.mjs → chunk-KCWTVLMK.mjs} +2 -2
  75. package/dist/{chunk-UPVIT75F.js → chunk-KWTSMLND.js} +6 -6
  76. package/dist/{chunk-UIRZIKC3.mjs → chunk-PI2RUC6X.mjs} +2 -2
  77. package/dist/chunk-QY4UST5V.js +37 -0
  78. package/dist/chunk-QY4UST5V.js.map +1 -0
  79. package/dist/{chunk-YRWUXGL3.js → chunk-TITJWXKP.js} +123 -103
  80. package/dist/chunk-TITJWXKP.js.map +1 -0
  81. package/dist/{chunk-VOZ7Y2OO.js → chunk-TPGIXSC2.js} +8 -8
  82. package/dist/chunk-U5UIDVOO.mjs +36 -0
  83. package/dist/{chunk-DKQBDI4C.js → chunk-UAVQ6J3W.js} +35 -35
  84. package/dist/{chunk-DY4ELDRQ.js → chunk-V6P5JEPT.js} +5 -3
  85. package/dist/chunk-V6P5JEPT.js.map +1 -0
  86. package/dist/{chunk-QTK2RMF7.mjs → chunk-X42WN3FE.mjs} +3 -3
  87. package/dist/chunk-YI2IXXU6.js +925 -0
  88. package/dist/chunk-YI2IXXU6.js.map +1 -0
  89. package/dist/{chunk-VE4DTN4R.mjs → chunk-ZHAD55AN.mjs} +5 -3
  90. package/dist/{chunk-VE4DTN4R.mjs.map → chunk-ZHAD55AN.mjs.map} +1 -1
  91. package/dist/index.js +18 -18
  92. package/dist/index.mjs +17 -17
  93. package/dist/tsconfig.build.tsbuildinfo +1 -1
  94. package/dist/types/NotificationServicesController/NotificationServicesController.d.ts +2 -0
  95. package/dist/types/NotificationServicesController/NotificationServicesController.d.ts.map +1 -1
  96. package/dist/types/NotificationServicesController/__fixtures__/index.d.ts +0 -1
  97. package/dist/types/NotificationServicesController/__fixtures__/index.d.ts.map +1 -1
  98. package/dist/types/NotificationServicesController/constants/notification-schema.d.ts +14 -8
  99. package/dist/types/NotificationServicesController/constants/notification-schema.d.ts.map +1 -1
  100. package/dist/types/NotificationServicesController/ui/constants.d.ts +29 -0
  101. package/dist/types/NotificationServicesController/ui/constants.d.ts.map +1 -0
  102. package/dist/types/NotificationServicesPushController/__fixtures__/index.d.ts +0 -1
  103. package/dist/types/NotificationServicesPushController/__fixtures__/index.d.ts.map +1 -1
  104. package/package.json +1 -1
  105. package/dist/chunk-26CCETCM.mjs +0 -70
  106. package/dist/chunk-4KZO4UUC.js +0 -4300
  107. package/dist/chunk-4KZO4UUC.js.map +0 -1
  108. package/dist/chunk-52NKJDI2.mjs.map +0 -1
  109. package/dist/chunk-CQ6CGSKZ.js +0 -35
  110. package/dist/chunk-CQ6CGSKZ.js.map +0 -1
  111. package/dist/chunk-DY4ELDRQ.js.map +0 -1
  112. package/dist/chunk-HCOBC2R5.mjs +0 -4300
  113. package/dist/chunk-HCOBC2R5.mjs.map +0 -1
  114. package/dist/chunk-LFD7J7KR.mjs.map +0 -1
  115. package/dist/chunk-NJBJIZLR.js.map +0 -1
  116. package/dist/chunk-NXXY4CAP.js.map +0 -1
  117. package/dist/chunk-RYAHBEX2.mjs.map +0 -1
  118. package/dist/chunk-V46WVGWN.js +0 -70
  119. package/dist/chunk-VC6J62JI.mjs.map +0 -1
  120. package/dist/chunk-YRWUXGL3.js.map +0 -1
  121. /package/dist/{chunk-GFAESVZA.js.map → chunk-5FUMSWDD.js.map} +0 -0
  122. /package/dist/{chunk-ODZ6V4PH.mjs.map → chunk-5WMDB2VE.mjs.map} +0 -0
  123. /package/dist/{chunk-SSWX2N73.mjs.map → chunk-6GUOLD7O.mjs.map} +0 -0
  124. /package/dist/{chunk-SMKJEA45.mjs.map → chunk-7S6524FI.mjs.map} +0 -0
  125. /package/dist/{chunk-PIZCE3JD.js.map → chunk-7U22ZANC.js.map} +0 -0
  126. /package/dist/{chunk-TT56I53C.mjs.map → chunk-ADYRLXWY.mjs.map} +0 -0
  127. /package/dist/{chunk-PGMXFZ6Y.js.map → chunk-BUT7X5F2.js.map} +0 -0
  128. /package/dist/{chunk-JLHFZ2UG.mjs.map → chunk-DCADU5QI.mjs.map} +0 -0
  129. /package/dist/{chunk-FFQNSBPU.js.map → chunk-ENRKCWJ6.js.map} +0 -0
  130. /package/dist/{chunk-NMLYB3XT.js.map → chunk-GJHW5Z65.js.map} +0 -0
  131. /package/dist/{chunk-V46WVGWN.js.map → chunk-IGY2S5BC.js.map} +0 -0
  132. /package/dist/{chunk-RQWUD2FB.mjs.map → chunk-KCWTVLMK.mjs.map} +0 -0
  133. /package/dist/{chunk-UPVIT75F.js.map → chunk-KWTSMLND.js.map} +0 -0
  134. /package/dist/{chunk-UIRZIKC3.mjs.map → chunk-PI2RUC6X.mjs.map} +0 -0
  135. /package/dist/{chunk-VOZ7Y2OO.js.map → chunk-TPGIXSC2.js.map} +0 -0
  136. /package/dist/{chunk-26CCETCM.mjs.map → chunk-U5UIDVOO.mjs.map} +0 -0
  137. /package/dist/{chunk-DKQBDI4C.js.map → chunk-UAVQ6J3W.js.map} +0 -0
  138. /package/dist/{chunk-QTK2RMF7.mjs.map → chunk-X42WN3FE.mjs.map} +0 -0
@@ -1,4300 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunkUPVIT75Fjs = require('./chunk-UPVIT75F.js');
4
-
5
-
6
- var _chunk232HZSEVjs = require('./chunk-232HZSEV.js');
7
-
8
-
9
-
10
- var _chunkYRWUXGL3js = require('./chunk-YRWUXGL3.js');
11
-
12
-
13
- var _chunkZMNXLHACjs = require('./chunk-ZMNXLHAC.js');
14
-
15
-
16
-
17
-
18
- var _chunkVOZ7Y2OOjs = require('./chunk-VOZ7Y2OO.js');
19
-
20
-
21
- var _chunkPIZCE3JDjs = require('./chunk-PIZCE3JD.js');
22
-
23
-
24
- var _chunkCQ6CGSKZjs = require('./chunk-CQ6CGSKZ.js');
25
-
26
-
27
- var _chunkTLX5QQK5js = require('./chunk-TLX5QQK5.js');
28
-
29
-
30
-
31
-
32
-
33
- var _chunkV46WVGWNjs = require('./chunk-V46WVGWN.js');
34
-
35
- // ../../node_modules/ms/index.js
36
- var require_ms = _chunkV46WVGWNjs.__commonJS.call(void 0, {
37
- "../../node_modules/ms/index.js"(exports, module) {
38
- "use strict";
39
- var s = 1e3;
40
- var m = s * 60;
41
- var h = m * 60;
42
- var d = h * 24;
43
- var w = d * 7;
44
- var y = d * 365.25;
45
- module.exports = function(val, options) {
46
- options = options || {};
47
- var type = typeof val;
48
- if (type === "string" && val.length > 0) {
49
- return parse(val);
50
- } else if (type === "number" && isFinite(val)) {
51
- return options.long ? fmtLong(val) : fmtShort(val);
52
- }
53
- throw new Error(
54
- "val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
55
- );
56
- };
57
- function parse(str) {
58
- str = String(str);
59
- if (str.length > 100) {
60
- return;
61
- }
62
- var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
63
- str
64
- );
65
- if (!match) {
66
- return;
67
- }
68
- var n = parseFloat(match[1]);
69
- var type = (match[2] || "ms").toLowerCase();
70
- switch (type) {
71
- case "years":
72
- case "year":
73
- case "yrs":
74
- case "yr":
75
- case "y":
76
- return n * y;
77
- case "weeks":
78
- case "week":
79
- case "w":
80
- return n * w;
81
- case "days":
82
- case "day":
83
- case "d":
84
- return n * d;
85
- case "hours":
86
- case "hour":
87
- case "hrs":
88
- case "hr":
89
- case "h":
90
- return n * h;
91
- case "minutes":
92
- case "minute":
93
- case "mins":
94
- case "min":
95
- case "m":
96
- return n * m;
97
- case "seconds":
98
- case "second":
99
- case "secs":
100
- case "sec":
101
- case "s":
102
- return n * s;
103
- case "milliseconds":
104
- case "millisecond":
105
- case "msecs":
106
- case "msec":
107
- case "ms":
108
- return n;
109
- default:
110
- return void 0;
111
- }
112
- }
113
- function fmtShort(ms) {
114
- var msAbs = Math.abs(ms);
115
- if (msAbs >= d) {
116
- return Math.round(ms / d) + "d";
117
- }
118
- if (msAbs >= h) {
119
- return Math.round(ms / h) + "h";
120
- }
121
- if (msAbs >= m) {
122
- return Math.round(ms / m) + "m";
123
- }
124
- if (msAbs >= s) {
125
- return Math.round(ms / s) + "s";
126
- }
127
- return ms + "ms";
128
- }
129
- function fmtLong(ms) {
130
- var msAbs = Math.abs(ms);
131
- if (msAbs >= d) {
132
- return plural(ms, msAbs, d, "day");
133
- }
134
- if (msAbs >= h) {
135
- return plural(ms, msAbs, h, "hour");
136
- }
137
- if (msAbs >= m) {
138
- return plural(ms, msAbs, m, "minute");
139
- }
140
- if (msAbs >= s) {
141
- return plural(ms, msAbs, s, "second");
142
- }
143
- return ms + " ms";
144
- }
145
- function plural(ms, msAbs, n, name) {
146
- var isPlural = msAbs >= n * 1.5;
147
- return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
148
- }
149
- }
150
- });
151
-
152
- // ../../node_modules/debug/src/common.js
153
- var require_common = _chunkV46WVGWNjs.__commonJS.call(void 0, {
154
- "../../node_modules/debug/src/common.js"(exports, module) {
155
- "use strict";
156
- function setup(env) {
157
- createDebug.debug = createDebug;
158
- createDebug.default = createDebug;
159
- createDebug.coerce = coerce;
160
- createDebug.disable = disable;
161
- createDebug.enable = enable;
162
- createDebug.enabled = enabled;
163
- createDebug.humanize = require_ms();
164
- createDebug.destroy = destroy;
165
- Object.keys(env).forEach((key) => {
166
- createDebug[key] = env[key];
167
- });
168
- createDebug.names = [];
169
- createDebug.skips = [];
170
- createDebug.formatters = {};
171
- function selectColor(namespace) {
172
- let hash = 0;
173
- for (let i = 0; i < namespace.length; i++) {
174
- hash = (hash << 5) - hash + namespace.charCodeAt(i);
175
- hash |= 0;
176
- }
177
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
178
- }
179
- createDebug.selectColor = selectColor;
180
- function createDebug(namespace) {
181
- let prevTime;
182
- let enableOverride = null;
183
- let namespacesCache;
184
- let enabledCache;
185
- function debug(...args) {
186
- if (!debug.enabled) {
187
- return;
188
- }
189
- const self = debug;
190
- const curr = Number(/* @__PURE__ */ new Date());
191
- const ms = curr - (prevTime || curr);
192
- self.diff = ms;
193
- self.prev = prevTime;
194
- self.curr = curr;
195
- prevTime = curr;
196
- args[0] = createDebug.coerce(args[0]);
197
- if (typeof args[0] !== "string") {
198
- args.unshift("%O");
199
- }
200
- let index = 0;
201
- args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
202
- if (match === "%%") {
203
- return "%";
204
- }
205
- index++;
206
- const formatter = createDebug.formatters[format];
207
- if (typeof formatter === "function") {
208
- const val = args[index];
209
- match = formatter.call(self, val);
210
- args.splice(index, 1);
211
- index--;
212
- }
213
- return match;
214
- });
215
- createDebug.formatArgs.call(self, args);
216
- const logFn = self.log || createDebug.log;
217
- logFn.apply(self, args);
218
- }
219
- debug.namespace = namespace;
220
- debug.useColors = createDebug.useColors();
221
- debug.color = createDebug.selectColor(namespace);
222
- debug.extend = extend;
223
- debug.destroy = createDebug.destroy;
224
- Object.defineProperty(debug, "enabled", {
225
- enumerable: true,
226
- configurable: false,
227
- get: () => {
228
- if (enableOverride !== null) {
229
- return enableOverride;
230
- }
231
- if (namespacesCache !== createDebug.namespaces) {
232
- namespacesCache = createDebug.namespaces;
233
- enabledCache = createDebug.enabled(namespace);
234
- }
235
- return enabledCache;
236
- },
237
- set: (v) => {
238
- enableOverride = v;
239
- }
240
- });
241
- if (typeof createDebug.init === "function") {
242
- createDebug.init(debug);
243
- }
244
- return debug;
245
- }
246
- function extend(namespace, delimiter) {
247
- const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
248
- newDebug.log = this.log;
249
- return newDebug;
250
- }
251
- function enable(namespaces) {
252
- createDebug.save(namespaces);
253
- createDebug.namespaces = namespaces;
254
- createDebug.names = [];
255
- createDebug.skips = [];
256
- let i;
257
- const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/);
258
- const len = split.length;
259
- for (i = 0; i < len; i++) {
260
- if (!split[i]) {
261
- continue;
262
- }
263
- namespaces = split[i].replace(/\*/g, ".*?");
264
- if (namespaces[0] === "-") {
265
- createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$"));
266
- } else {
267
- createDebug.names.push(new RegExp("^" + namespaces + "$"));
268
- }
269
- }
270
- }
271
- function disable() {
272
- const namespaces = [
273
- ...createDebug.names.map(toNamespace),
274
- ...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace)
275
- ].join(",");
276
- createDebug.enable("");
277
- return namespaces;
278
- }
279
- function enabled(name) {
280
- if (name[name.length - 1] === "*") {
281
- return true;
282
- }
283
- let i;
284
- let len;
285
- for (i = 0, len = createDebug.skips.length; i < len; i++) {
286
- if (createDebug.skips[i].test(name)) {
287
- return false;
288
- }
289
- }
290
- for (i = 0, len = createDebug.names.length; i < len; i++) {
291
- if (createDebug.names[i].test(name)) {
292
- return true;
293
- }
294
- }
295
- return false;
296
- }
297
- function toNamespace(regexp) {
298
- return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
299
- }
300
- function coerce(val) {
301
- if (val instanceof Error) {
302
- return val.stack || val.message;
303
- }
304
- return val;
305
- }
306
- function destroy() {
307
- console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
308
- }
309
- createDebug.enable(createDebug.load());
310
- return createDebug;
311
- }
312
- module.exports = setup;
313
- }
314
- });
315
-
316
- // ../../node_modules/debug/src/browser.js
317
- var require_browser = _chunkV46WVGWNjs.__commonJS.call(void 0, {
318
- "../../node_modules/debug/src/browser.js"(exports, module) {
319
- "use strict";
320
- exports.formatArgs = formatArgs;
321
- exports.save = save;
322
- exports.load = load;
323
- exports.useColors = useColors;
324
- exports.storage = localstorage();
325
- exports.destroy = /* @__PURE__ */ (() => {
326
- let warned = false;
327
- return () => {
328
- if (!warned) {
329
- warned = true;
330
- console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
331
- }
332
- };
333
- })();
334
- exports.colors = [
335
- "#0000CC",
336
- "#0000FF",
337
- "#0033CC",
338
- "#0033FF",
339
- "#0066CC",
340
- "#0066FF",
341
- "#0099CC",
342
- "#0099FF",
343
- "#00CC00",
344
- "#00CC33",
345
- "#00CC66",
346
- "#00CC99",
347
- "#00CCCC",
348
- "#00CCFF",
349
- "#3300CC",
350
- "#3300FF",
351
- "#3333CC",
352
- "#3333FF",
353
- "#3366CC",
354
- "#3366FF",
355
- "#3399CC",
356
- "#3399FF",
357
- "#33CC00",
358
- "#33CC33",
359
- "#33CC66",
360
- "#33CC99",
361
- "#33CCCC",
362
- "#33CCFF",
363
- "#6600CC",
364
- "#6600FF",
365
- "#6633CC",
366
- "#6633FF",
367
- "#66CC00",
368
- "#66CC33",
369
- "#9900CC",
370
- "#9900FF",
371
- "#9933CC",
372
- "#9933FF",
373
- "#99CC00",
374
- "#99CC33",
375
- "#CC0000",
376
- "#CC0033",
377
- "#CC0066",
378
- "#CC0099",
379
- "#CC00CC",
380
- "#CC00FF",
381
- "#CC3300",
382
- "#CC3333",
383
- "#CC3366",
384
- "#CC3399",
385
- "#CC33CC",
386
- "#CC33FF",
387
- "#CC6600",
388
- "#CC6633",
389
- "#CC9900",
390
- "#CC9933",
391
- "#CCCC00",
392
- "#CCCC33",
393
- "#FF0000",
394
- "#FF0033",
395
- "#FF0066",
396
- "#FF0099",
397
- "#FF00CC",
398
- "#FF00FF",
399
- "#FF3300",
400
- "#FF3333",
401
- "#FF3366",
402
- "#FF3399",
403
- "#FF33CC",
404
- "#FF33FF",
405
- "#FF6600",
406
- "#FF6633",
407
- "#FF9900",
408
- "#FF9933",
409
- "#FFCC00",
410
- "#FFCC33"
411
- ];
412
- function useColors() {
413
- if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
414
- return true;
415
- }
416
- if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
417
- return false;
418
- }
419
- return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
420
- typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
421
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
422
- typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
423
- typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
424
- }
425
- function formatArgs(args) {
426
- args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
427
- if (!this.useColors) {
428
- return;
429
- }
430
- const c = "color: " + this.color;
431
- args.splice(1, 0, c, "color: inherit");
432
- let index = 0;
433
- let lastC = 0;
434
- args[0].replace(/%[a-zA-Z%]/g, (match) => {
435
- if (match === "%%") {
436
- return;
437
- }
438
- index++;
439
- if (match === "%c") {
440
- lastC = index;
441
- }
442
- });
443
- args.splice(lastC, 0, c);
444
- }
445
- exports.log = console.debug || console.log || (() => {
446
- });
447
- function save(namespaces) {
448
- try {
449
- if (namespaces) {
450
- exports.storage.setItem("debug", namespaces);
451
- } else {
452
- exports.storage.removeItem("debug");
453
- }
454
- } catch (error) {
455
- }
456
- }
457
- function load() {
458
- let r;
459
- try {
460
- r = exports.storage.getItem("debug");
461
- } catch (error) {
462
- }
463
- if (!r && typeof process !== "undefined" && "env" in process) {
464
- r = process.env.DEBUG;
465
- }
466
- return r;
467
- }
468
- function localstorage() {
469
- try {
470
- return localStorage;
471
- } catch (error) {
472
- }
473
- }
474
- module.exports = require_common()(exports);
475
- var { formatters } = module.exports;
476
- formatters.j = function(v) {
477
- try {
478
- return JSON.stringify(v);
479
- } catch (error) {
480
- return "[UnexpectedJSONParseError]: " + error.message;
481
- }
482
- };
483
- }
484
- });
485
-
486
- // ../../node_modules/nock/lib/common.js
487
- var require_common2 = _chunkV46WVGWNjs.__commonJS.call(void 0, {
488
- "../../node_modules/nock/lib/common.js"(exports, module) {
489
- "use strict";
490
- var debug = require_browser()("nock.common");
491
- var timers = _chunkV46WVGWNjs.__require.call(void 0, "timers");
492
- var url = _chunkV46WVGWNjs.__require.call(void 0, "url");
493
- var util = _chunkV46WVGWNjs.__require.call(void 0, "util");
494
- function normalizeRequestOptions(options) {
495
- options.proto = options.proto || "http";
496
- options.port = options.port || (options.proto === "http" ? 80 : 443);
497
- if (options.host) {
498
- debug("options.host:", options.host);
499
- if (!options.hostname) {
500
- if (options.host.split(":").length === 2) {
501
- options.hostname = options.host.split(":")[0];
502
- } else {
503
- options.hostname = options.host;
504
- }
505
- }
506
- }
507
- debug("options.hostname in the end: %j", options.hostname);
508
- options.host = `${options.hostname || "localhost"}:${options.port}`;
509
- debug("options.host in the end: %j", options.host);
510
- ["hostname", "host"].forEach(function(attr) {
511
- if (options[attr]) {
512
- options[attr] = options[attr].toLowerCase();
513
- }
514
- });
515
- return options;
516
- }
517
- function isUtf8Representable(buffer) {
518
- const utfEncodedBuffer = buffer.toString("utf8");
519
- const reconstructedBuffer = Buffer.from(utfEncodedBuffer, "utf8");
520
- return reconstructedBuffer.equals(buffer);
521
- }
522
- var requestOverrides = {};
523
- function overrideRequests(newRequest) {
524
- debug("overriding requests");
525
- ["http", "https"].forEach(function(proto) {
526
- debug("- overriding request for", proto);
527
- const moduleName = proto;
528
- const module2 = _chunkV46WVGWNjs.__require.call(void 0, proto);
529
- const overriddenRequest = module2.request;
530
- const overriddenGet = module2.get;
531
- if (requestOverrides[moduleName]) {
532
- throw new Error(
533
- `Module's request already overridden for ${moduleName} protocol.`
534
- );
535
- }
536
- requestOverrides[moduleName] = {
537
- module: module2,
538
- request: overriddenRequest,
539
- get: overriddenGet
540
- };
541
- module2.request = function(input, options, callback) {
542
- return newRequest(proto, overriddenRequest.bind(module2), [
543
- input,
544
- options,
545
- callback
546
- ]);
547
- };
548
- module2.get = function(input, options, callback) {
549
- const req = newRequest(proto, overriddenGet.bind(module2), [
550
- input,
551
- options,
552
- callback
553
- ]);
554
- req.end();
555
- return req;
556
- };
557
- debug("- overridden request for", proto);
558
- });
559
- }
560
- function restoreOverriddenRequests() {
561
- debug("restoring requests");
562
- Object.entries(requestOverrides).forEach(
563
- ([proto, { module: module2, request, get }]) => {
564
- debug("- restoring request for", proto);
565
- module2.request = request;
566
- module2.get = get;
567
- debug("- restored request for", proto);
568
- }
569
- );
570
- requestOverrides = {};
571
- }
572
- function normalizeOrigin(proto, host, port) {
573
- const hostHasPort = host.includes(":");
574
- const portIsStandard = proto === "http" && (port === 80 || port === "80") || proto === "https" && (port === 443 || port === "443");
575
- const portStr = hostHasPort || portIsStandard ? "" : `:${port}`;
576
- return `${proto}://${host}${portStr}`;
577
- }
578
- function stringifyRequest(options, body) {
579
- const { method = "GET", path = "", port } = options;
580
- const origin = normalizeOrigin(options.proto, options.hostname, port);
581
- const log = {
582
- method,
583
- url: `${origin}${path}`,
584
- headers: options.headers
585
- };
586
- if (body) {
587
- log.body = body;
588
- }
589
- return JSON.stringify(log, null, 2);
590
- }
591
- function isContentEncoded(headers) {
592
- const contentEncoding2 = headers["content-encoding"];
593
- return typeof contentEncoding2 === "string" && contentEncoding2 !== "";
594
- }
595
- function contentEncoding(headers, encoder) {
596
- const contentEncoding2 = headers["content-encoding"];
597
- return contentEncoding2 !== void 0 && contentEncoding2.toString() === encoder;
598
- }
599
- function isJSONContent(headers) {
600
- const contentType = String(headers["content-type"] || "").toLowerCase();
601
- return contentType.startsWith("application/json");
602
- }
603
- function headersFieldNamesToLowerCase(headers, throwOnDuplicate) {
604
- if (!isPlainObject(headers)) {
605
- throw Error("Headers must be provided as an object");
606
- }
607
- const lowerCaseHeaders = {};
608
- Object.entries(headers).forEach(([fieldName, fieldValue]) => {
609
- const key = fieldName.toLowerCase();
610
- if (lowerCaseHeaders[key] !== void 0) {
611
- if (throwOnDuplicate) {
612
- throw Error(
613
- `Failed to convert header keys to lower case due to field name conflict: ${key}`
614
- );
615
- } else {
616
- debug(
617
- `Duplicate header provided in request: ${key}. Only the last value can be matched.`
618
- );
619
- }
620
- }
621
- lowerCaseHeaders[key] = fieldValue;
622
- });
623
- return lowerCaseHeaders;
624
- }
625
- var headersFieldsArrayToLowerCase = (headers) => [
626
- ...new Set(headers.map((fieldName) => fieldName.toLowerCase()))
627
- ];
628
- function headersInputToRawArray(headers) {
629
- if (headers === void 0) {
630
- return [];
631
- }
632
- if (Array.isArray(headers)) {
633
- if (headers.length % 2) {
634
- throw new Error(
635
- `Raw headers must be provided as an array with an even number of items. [fieldName, value, ...]`
636
- );
637
- }
638
- return [...headers];
639
- }
640
- if (util.types.isMap(headers)) {
641
- return [].concat(...Array.from(headers, ([k, v]) => [k.toString(), v]));
642
- }
643
- if (isPlainObject(headers)) {
644
- return [].concat(...Object.entries(headers));
645
- }
646
- throw new Error(
647
- `Headers must be provided as an array of raw values, a Map, or a plain Object. ${headers}`
648
- );
649
- }
650
- function headersArrayToObject(rawHeaders) {
651
- if (!Array.isArray(rawHeaders)) {
652
- throw Error("Expected a header array");
653
- }
654
- const accumulator = {};
655
- forEachHeader(rawHeaders, (value, fieldName) => {
656
- addHeaderLine(accumulator, fieldName, value);
657
- });
658
- return accumulator;
659
- }
660
- var noDuplicatesHeaders = /* @__PURE__ */ new Set([
661
- "age",
662
- "authorization",
663
- "content-length",
664
- "content-type",
665
- "etag",
666
- "expires",
667
- "from",
668
- "host",
669
- "if-modified-since",
670
- "if-unmodified-since",
671
- "last-modified",
672
- "location",
673
- "max-forwards",
674
- "proxy-authorization",
675
- "referer",
676
- "retry-after",
677
- "user-agent"
678
- ]);
679
- function addHeaderLine(headers, name, value) {
680
- let values;
681
- if (typeof value === "function") {
682
- values = [value.name];
683
- } else if (Array.isArray(value)) {
684
- values = value.map(String);
685
- } else {
686
- values = [String(value)];
687
- }
688
- const key = name.toLowerCase();
689
- if (key === "set-cookie") {
690
- if (headers["set-cookie"] === void 0) {
691
- headers["set-cookie"] = values;
692
- } else {
693
- headers["set-cookie"].push(...values);
694
- }
695
- } else if (noDuplicatesHeaders.has(key)) {
696
- if (headers[key] === void 0) {
697
- headers[key] = values[0];
698
- }
699
- } else {
700
- if (headers[key] !== void 0) {
701
- values = [headers[key], ...values];
702
- }
703
- const separator = key === "cookie" ? "; " : ", ";
704
- headers[key] = values.join(separator);
705
- }
706
- }
707
- function deleteHeadersField(headers, fieldNameToDelete) {
708
- if (!isPlainObject(headers)) {
709
- throw Error("headers must be an object");
710
- }
711
- if (typeof fieldNameToDelete !== "string") {
712
- throw Error("field name must be a string");
713
- }
714
- const lowerCaseFieldNameToDelete = fieldNameToDelete.toLowerCase();
715
- Object.keys(headers).filter((fieldName) => fieldName.toLowerCase() === lowerCaseFieldNameToDelete).forEach((fieldName) => delete headers[fieldName]);
716
- }
717
- function forEachHeader(rawHeaders, callback) {
718
- for (let i = 0; i < rawHeaders.length; i += 2) {
719
- callback(rawHeaders[i + 1], rawHeaders[i], i);
720
- }
721
- }
722
- function percentDecode(str) {
723
- try {
724
- return decodeURIComponent(str.replace(/\+/g, " "));
725
- } catch (e) {
726
- return str;
727
- }
728
- }
729
- function percentEncode(str) {
730
- return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
731
- return `%${c.charCodeAt(0).toString(16).toUpperCase()}`;
732
- });
733
- }
734
- function matchStringOrRegexp(target, pattern) {
735
- const targetStr = target === void 0 || target === null ? "" : String(target);
736
- if (pattern instanceof RegExp) {
737
- pattern.lastIndex = 0;
738
- return pattern.test(targetStr);
739
- }
740
- return targetStr === String(pattern);
741
- }
742
- function formatQueryValue(key, value, stringFormattingFn) {
743
- switch (true) {
744
- case typeof value === "number":
745
- case typeof value === "boolean":
746
- value = value.toString();
747
- break;
748
- case value === null:
749
- case value === void 0:
750
- value = "";
751
- break;
752
- case typeof value === "string":
753
- if (stringFormattingFn) {
754
- value = stringFormattingFn(value);
755
- }
756
- break;
757
- case value instanceof RegExp:
758
- break;
759
- case Array.isArray(value): {
760
- value = value.map(function(val, idx) {
761
- return formatQueryValue(idx, val, stringFormattingFn)[1];
762
- });
763
- break;
764
- }
765
- case typeof value === "object": {
766
- value = Object.entries(value).reduce(function(acc, [subKey, subVal]) {
767
- const subPair = formatQueryValue(subKey, subVal, stringFormattingFn);
768
- acc[subPair[0]] = subPair[1];
769
- return acc;
770
- }, {});
771
- break;
772
- }
773
- }
774
- if (stringFormattingFn)
775
- key = stringFormattingFn(key);
776
- return [key, value];
777
- }
778
- function isStream(obj) {
779
- return obj && typeof obj !== "string" && !Buffer.isBuffer(obj) && typeof obj.setEncoding === "function";
780
- }
781
- function normalizeClientRequestArgs(input, options, cb) {
782
- if (typeof input === "string") {
783
- input = urlToOptions(new url.URL(input));
784
- } else if (input instanceof url.URL) {
785
- input = urlToOptions(input);
786
- } else {
787
- cb = options;
788
- options = input;
789
- input = null;
790
- }
791
- if (typeof options === "function") {
792
- cb = options;
793
- options = input || {};
794
- } else {
795
- options = Object.assign(input || {}, options);
796
- }
797
- return { options, callback: cb };
798
- }
799
- function urlToOptions(url2) {
800
- const options = {
801
- protocol: url2.protocol,
802
- hostname: typeof url2.hostname === "string" && url2.hostname.startsWith("[") ? url2.hostname.slice(1, -1) : url2.hostname,
803
- hash: url2.hash,
804
- search: url2.search,
805
- pathname: url2.pathname,
806
- path: `${url2.pathname}${url2.search || ""}`,
807
- href: url2.href
808
- };
809
- if (url2.port !== "") {
810
- options.port = Number(url2.port);
811
- }
812
- if (url2.username || url2.password) {
813
- options.auth = `${url2.username}:${url2.password}`;
814
- }
815
- return options;
816
- }
817
- var dataEqual = (expected, actual) => {
818
- if (isPlainObject(expected)) {
819
- expected = expand(expected);
820
- }
821
- if (isPlainObject(actual)) {
822
- actual = expand(actual);
823
- }
824
- return deepEqual(expected, actual);
825
- };
826
- function deepEqual(expected, actual) {
827
- debug("deepEqual comparing", typeof expected, expected, typeof actual, actual);
828
- if (expected instanceof RegExp) {
829
- return expected.test(actual);
830
- }
831
- if (Array.isArray(expected) && Array.isArray(actual)) {
832
- if (expected.length !== actual.length) {
833
- return false;
834
- }
835
- return expected.every((expVal, idx) => deepEqual(expVal, actual[idx]));
836
- }
837
- if (isPlainObject(expected) && isPlainObject(actual)) {
838
- const allKeys = Array.from(
839
- new Set(Object.keys(expected).concat(Object.keys(actual)))
840
- );
841
- return allKeys.every((key) => deepEqual(expected[key], actual[key]));
842
- }
843
- return expected === actual;
844
- }
845
- var timeouts = [];
846
- var intervals = [];
847
- var immediates = [];
848
- var wrapTimer = (timer, ids) => (...args) => {
849
- const id = timer(...args);
850
- ids.push(id);
851
- return id;
852
- };
853
- var setTimeout = wrapTimer(timers.setTimeout, timeouts);
854
- var setInterval = wrapTimer(timers.setInterval, intervals);
855
- var setImmediate = wrapTimer(timers.setImmediate, immediates);
856
- function clearTimer(clear, ids) {
857
- while (ids.length) {
858
- clear(ids.shift());
859
- }
860
- }
861
- function removeAllTimers() {
862
- clearTimer(clearTimeout, timeouts);
863
- clearTimer(clearInterval, intervals);
864
- clearTimer(clearImmediate, immediates);
865
- }
866
- function isRequestDestroyed(req) {
867
- return !!(req.destroyed === true || req.aborted || req.socket && req.socket.destroyed);
868
- }
869
- function isPlainObject(value) {
870
- if (typeof value !== "object" || value === null)
871
- return false;
872
- if (Object.prototype.toString.call(value) !== "[object Object]")
873
- return false;
874
- const proto = Object.getPrototypeOf(value);
875
- if (proto === null)
876
- return true;
877
- const Ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
878
- return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value);
879
- }
880
- var prototypePollutionBlockList = ["__proto__", "prototype", "constructor"];
881
- var blocklistFilter = function(part) {
882
- return prototypePollutionBlockList.indexOf(part) === -1;
883
- };
884
- var expand = (input) => {
885
- if (input === void 0 || input === null) {
886
- return input;
887
- }
888
- const keys = Object.keys(input);
889
- const result = {};
890
- let resultPtr = result;
891
- for (let path of keys) {
892
- const originalPath = path;
893
- if (path.indexOf("[") >= 0) {
894
- path = path.replace(/\[/g, ".").replace(/]/g, "");
895
- }
896
- const parts = path.split(".");
897
- const check = parts.filter(blocklistFilter);
898
- if (check.length !== parts.length) {
899
- return void 0;
900
- }
901
- resultPtr = result;
902
- const lastIndex = parts.length - 1;
903
- for (let i = 0; i < parts.length; ++i) {
904
- const part = parts[i];
905
- if (i === lastIndex) {
906
- if (Array.isArray(resultPtr)) {
907
- resultPtr[+part] = input[originalPath];
908
- } else {
909
- resultPtr[part] = input[originalPath];
910
- }
911
- } else {
912
- if (resultPtr[part] === void 0 || resultPtr[part] === null) {
913
- const nextPart = parts[i + 1];
914
- if (/^\d+$/.test(nextPart)) {
915
- resultPtr[part] = [];
916
- } else {
917
- resultPtr[part] = {};
918
- }
919
- }
920
- resultPtr = resultPtr[part];
921
- }
922
- }
923
- }
924
- return result;
925
- };
926
- module.exports = {
927
- contentEncoding,
928
- dataEqual,
929
- deleteHeadersField,
930
- expand,
931
- forEachHeader,
932
- formatQueryValue,
933
- headersArrayToObject,
934
- headersFieldNamesToLowerCase,
935
- headersFieldsArrayToLowerCase,
936
- headersInputToRawArray,
937
- isContentEncoded,
938
- isJSONContent,
939
- isPlainObject,
940
- isRequestDestroyed,
941
- isStream,
942
- isUtf8Representable,
943
- matchStringOrRegexp,
944
- normalizeClientRequestArgs,
945
- normalizeOrigin,
946
- normalizeRequestOptions,
947
- overrideRequests,
948
- percentDecode,
949
- percentEncode,
950
- removeAllTimers,
951
- restoreOverriddenRequests,
952
- setImmediate,
953
- setInterval,
954
- setTimeout,
955
- stringifyRequest
956
- };
957
- }
958
- });
959
-
960
- // ../../node_modules/propagate/index.js
961
- var require_propagate = _chunkV46WVGWNjs.__commonJS.call(void 0, {
962
- "../../node_modules/propagate/index.js"(exports, module) {
963
- "use strict";
964
- function propagate(events, source, dest) {
965
- if (arguments.length < 3) {
966
- dest = source;
967
- source = events;
968
- events = void 0;
969
- }
970
- const eventsIsObject = typeof events === "object";
971
- if (events && !eventsIsObject)
972
- events = [events];
973
- if (eventsIsObject) {
974
- return explicitPropagate(events, source, dest);
975
- }
976
- const shouldPropagate = (eventName) => events === void 0 || events.includes(eventName);
977
- const oldEmit = source.emit;
978
- source.emit = (eventName, ...args) => {
979
- const oldEmitHadListeners = oldEmit.call(source, eventName, ...args);
980
- let destEmitHadListeners = false;
981
- if (shouldPropagate(eventName)) {
982
- destEmitHadListeners = dest.emit(eventName, ...args);
983
- }
984
- return oldEmitHadListeners || destEmitHadListeners;
985
- };
986
- function end() {
987
- source.emit = oldEmit;
988
- }
989
- return {
990
- end
991
- };
992
- }
993
- module.exports = propagate;
994
- function explicitPropagate(events, source, dest) {
995
- let eventsIn;
996
- let eventsOut;
997
- if (Array.isArray(events)) {
998
- eventsIn = events;
999
- eventsOut = events;
1000
- } else {
1001
- eventsIn = Object.keys(events);
1002
- eventsOut = eventsIn.map(function(key) {
1003
- return events[key];
1004
- });
1005
- }
1006
- const listeners = eventsOut.map(function(event) {
1007
- return function() {
1008
- const args = Array.prototype.slice.call(arguments);
1009
- args.unshift(event);
1010
- dest.emit.apply(dest, args);
1011
- };
1012
- });
1013
- listeners.forEach(register);
1014
- return {
1015
- end
1016
- };
1017
- function register(listener, i) {
1018
- source.on(eventsIn[i], listener);
1019
- }
1020
- function unregister(listener, i) {
1021
- source.removeListener(eventsIn[i], listener);
1022
- }
1023
- function end() {
1024
- listeners.forEach(unregister);
1025
- }
1026
- }
1027
- }
1028
- });
1029
-
1030
- // ../../node_modules/nock/lib/global_emitter.js
1031
- var require_global_emitter = _chunkV46WVGWNjs.__commonJS.call(void 0, {
1032
- "../../node_modules/nock/lib/global_emitter.js"(exports, module) {
1033
- "use strict";
1034
- var { EventEmitter } = _chunkV46WVGWNjs.__require.call(void 0, "events");
1035
- module.exports = new EventEmitter();
1036
- }
1037
- });
1038
-
1039
- // ../../node_modules/nock/lib/socket.js
1040
- var require_socket = _chunkV46WVGWNjs.__commonJS.call(void 0, {
1041
- "../../node_modules/nock/lib/socket.js"(exports, module) {
1042
- "use strict";
1043
- var { EventEmitter } = _chunkV46WVGWNjs.__require.call(void 0, "events");
1044
- var debug = require_browser()("nock.socket");
1045
- module.exports = class Socket extends EventEmitter {
1046
- constructor(options) {
1047
- super();
1048
- if (options.proto === "https") {
1049
- this.authorized = true;
1050
- this.encrypted = true;
1051
- }
1052
- this.bufferSize = 0;
1053
- this.writableLength = 0;
1054
- this.writable = true;
1055
- this.readable = true;
1056
- this.pending = false;
1057
- this.destroyed = false;
1058
- this.connecting = true;
1059
- this._hadError = false;
1060
- this.timeout = 0;
1061
- const ipv6 = options.family === 6;
1062
- this.remoteFamily = ipv6 ? "IPv6" : "IPv4";
1063
- this.localAddress = this.remoteAddress = ipv6 ? "::1" : "127.0.0.1";
1064
- this.localPort = this.remotePort = parseInt(options.port);
1065
- }
1066
- setNoDelay() {
1067
- }
1068
- setKeepAlive() {
1069
- }
1070
- resume() {
1071
- }
1072
- ref() {
1073
- }
1074
- unref() {
1075
- }
1076
- write() {
1077
- }
1078
- address() {
1079
- return {
1080
- port: this.remotePort,
1081
- family: this.remoteFamily,
1082
- address: this.remoteAddress
1083
- };
1084
- }
1085
- setTimeout(timeoutMs, fn) {
1086
- this.timeout = timeoutMs;
1087
- if (fn) {
1088
- this.once("timeout", fn);
1089
- }
1090
- return this;
1091
- }
1092
- /**
1093
- * Artificial delay that will trip socket timeouts when appropriate.
1094
- *
1095
- * Doesn't actually wait for time to pass.
1096
- * Timeout events don't necessarily end the request.
1097
- * While many clients choose to abort the request upon a timeout, Node itself does not.
1098
- */
1099
- applyDelay(delayMs) {
1100
- if (this.timeout && delayMs > this.timeout) {
1101
- debug("socket timeout");
1102
- this.emit("timeout");
1103
- }
1104
- }
1105
- getPeerCertificate() {
1106
- return Buffer.from(
1107
- (Math.random() * 1e4 + Date.now()).toString()
1108
- ).toString("base64");
1109
- }
1110
- /**
1111
- * Denotes that no more I/O activity should happen on this socket.
1112
- *
1113
- * The implementation in Node if far more complex as it juggles underlying async streams.
1114
- * For the purposes of Nock, we just need it to set some flags and on the first call
1115
- * emit a 'close' and optional 'error' event. Both events propagate through the request object.
1116
- */
1117
- destroy(err) {
1118
- if (this.destroyed) {
1119
- return this;
1120
- }
1121
- debug("socket destroy");
1122
- this.destroyed = true;
1123
- this.readable = this.writable = false;
1124
- this.readableEnded = this.writableFinished = true;
1125
- process.nextTick(() => {
1126
- if (err) {
1127
- this._hadError = true;
1128
- this.emit("error", err);
1129
- }
1130
- this.emit("close");
1131
- });
1132
- return this;
1133
- }
1134
- };
1135
- }
1136
- });
1137
-
1138
- // ../../node_modules/nock/lib/playback_interceptor.js
1139
- var require_playback_interceptor = _chunkV46WVGWNjs.__commonJS.call(void 0, {
1140
- "../../node_modules/nock/lib/playback_interceptor.js"(exports, module) {
1141
- "use strict";
1142
- var stream = _chunkV46WVGWNjs.__require.call(void 0, "stream");
1143
- var util = _chunkV46WVGWNjs.__require.call(void 0, "util");
1144
- var zlib = _chunkV46WVGWNjs.__require.call(void 0, "zlib");
1145
- var debug = require_browser()("nock.playback_interceptor");
1146
- var common = require_common2();
1147
- function parseJSONRequestBody(req, requestBody) {
1148
- if (!requestBody || !common.isJSONContent(req.headers)) {
1149
- return requestBody;
1150
- }
1151
- if (common.contentEncoding(req.headers, "gzip")) {
1152
- requestBody = String(zlib.gunzipSync(Buffer.from(requestBody, "hex")));
1153
- } else if (common.contentEncoding(req.headers, "deflate")) {
1154
- requestBody = String(zlib.inflateSync(Buffer.from(requestBody, "hex")));
1155
- }
1156
- return JSON.parse(requestBody);
1157
- }
1158
- function parseFullReplyResult(response, fullReplyResult) {
1159
- debug("full response from callback result: %j", fullReplyResult);
1160
- if (!Array.isArray(fullReplyResult)) {
1161
- throw Error("A single function provided to .reply MUST return an array");
1162
- }
1163
- if (fullReplyResult.length > 3) {
1164
- throw Error(
1165
- "The array returned from the .reply callback contains too many values"
1166
- );
1167
- }
1168
- const [status, body = "", headers] = fullReplyResult;
1169
- if (!Number.isInteger(status)) {
1170
- throw new Error(`Invalid ${typeof status} value for status code`);
1171
- }
1172
- response.statusCode = status;
1173
- response.rawHeaders.push(...common.headersInputToRawArray(headers));
1174
- debug("response.rawHeaders after reply: %j", response.rawHeaders);
1175
- return body;
1176
- }
1177
- function selectDefaultHeaders(existingHeaders, defaultHeaders) {
1178
- if (!defaultHeaders.length) {
1179
- return [];
1180
- }
1181
- const definedHeaders = /* @__PURE__ */ new Set();
1182
- const result = [];
1183
- common.forEachHeader(existingHeaders, (_, fieldName) => {
1184
- definedHeaders.add(fieldName.toLowerCase());
1185
- });
1186
- common.forEachHeader(defaultHeaders, (value, fieldName) => {
1187
- if (!definedHeaders.has(fieldName.toLowerCase())) {
1188
- result.push(fieldName, value);
1189
- }
1190
- });
1191
- return result;
1192
- }
1193
- var ReadableBuffers = class extends stream.Readable {
1194
- constructor(buffers, opts = {}) {
1195
- super(opts);
1196
- this.buffers = buffers;
1197
- }
1198
- _read(_size) {
1199
- while (this.buffers.length) {
1200
- if (!this.push(this.buffers.shift())) {
1201
- return;
1202
- }
1203
- }
1204
- this.push(null);
1205
- }
1206
- };
1207
- function convertBodyToStream(body) {
1208
- if (common.isStream(body)) {
1209
- return body;
1210
- }
1211
- if (body === void 0) {
1212
- return new ReadableBuffers([]);
1213
- }
1214
- if (Buffer.isBuffer(body)) {
1215
- return new ReadableBuffers([body]);
1216
- }
1217
- if (typeof body !== "string") {
1218
- body = JSON.stringify(body);
1219
- }
1220
- return new ReadableBuffers([Buffer.from(body)]);
1221
- }
1222
- function playbackInterceptor({
1223
- req,
1224
- socket,
1225
- options,
1226
- requestBodyString,
1227
- requestBodyIsUtf8Representable,
1228
- response,
1229
- interceptor
1230
- }) {
1231
- const { logger } = interceptor.scope;
1232
- function start() {
1233
- req.headers = req.getHeaders();
1234
- interceptor.scope.emit("request", req, interceptor, requestBodyString);
1235
- if (typeof interceptor.errorMessage !== "undefined") {
1236
- let error;
1237
- if (typeof interceptor.errorMessage === "object") {
1238
- error = interceptor.errorMessage;
1239
- } else {
1240
- error = new Error(interceptor.errorMessage);
1241
- }
1242
- const delay = interceptor.delayBodyInMs + interceptor.delayConnectionInMs;
1243
- common.setTimeout(() => req.destroy(error), delay);
1244
- return;
1245
- }
1246
- response.statusCode = interceptor.statusCode;
1247
- response.rawHeaders = [...interceptor.rawHeaders];
1248
- logger("response.rawHeaders:", response.rawHeaders);
1249
- interceptor.req = req;
1250
- if (interceptor.replyFunction) {
1251
- const parsedRequestBody = parseJSONRequestBody(req, requestBodyString);
1252
- let fn = interceptor.replyFunction;
1253
- if (fn.length === 3) {
1254
- fn = util.promisify(fn);
1255
- }
1256
- Promise.resolve(fn.call(interceptor, options.path, parsedRequestBody)).then(continueWithResponseBody).catch((err) => req.destroy(err));
1257
- return;
1258
- }
1259
- if (interceptor.fullReplyFunction) {
1260
- const parsedRequestBody = parseJSONRequestBody(req, requestBodyString);
1261
- let fn = interceptor.fullReplyFunction;
1262
- if (fn.length === 3) {
1263
- fn = util.promisify(fn);
1264
- }
1265
- Promise.resolve(fn.call(interceptor, options.path, parsedRequestBody)).then(continueWithFullResponse).catch((err) => req.destroy(err));
1266
- return;
1267
- }
1268
- if (common.isContentEncoded(interceptor.headers) && !common.isStream(interceptor.body)) {
1269
- const bufferData = Array.isArray(interceptor.body) ? interceptor.body : [interceptor.body];
1270
- const responseBuffers = bufferData.map((data) => Buffer.from(data, "hex"));
1271
- const responseBody2 = new ReadableBuffers(responseBuffers);
1272
- continueWithResponseBody(responseBody2);
1273
- return;
1274
- }
1275
- let responseBody = interceptor.body;
1276
- if (!requestBodyIsUtf8Representable && typeof responseBody === "string") {
1277
- responseBody = Buffer.from(responseBody, "hex");
1278
- if (!responseBody || interceptor.body.length > 0 && responseBody.length === 0) {
1279
- responseBody = Buffer.from(interceptor.body, "utf8");
1280
- }
1281
- }
1282
- return continueWithResponseBody(responseBody);
1283
- }
1284
- function continueWithFullResponse(fullReplyResult) {
1285
- let responseBody;
1286
- try {
1287
- responseBody = parseFullReplyResult(response, fullReplyResult);
1288
- } catch (err) {
1289
- req.destroy(err);
1290
- return;
1291
- }
1292
- continueWithResponseBody(responseBody);
1293
- }
1294
- function prepareResponseHeaders(body) {
1295
- const defaultHeaders = [...interceptor.scope._defaultReplyHeaders];
1296
- const isJSON = body !== void 0 && typeof body !== "string" && !Buffer.isBuffer(body) && !common.isStream(body);
1297
- if (isJSON) {
1298
- defaultHeaders.push("Content-Type", "application/json");
1299
- }
1300
- response.rawHeaders.push(
1301
- ...selectDefaultHeaders(response.rawHeaders, defaultHeaders)
1302
- );
1303
- common.forEachHeader(response.rawHeaders, (value, fieldName, i) => {
1304
- if (typeof value === "function") {
1305
- response.rawHeaders[i + 1] = value(req, response, body);
1306
- }
1307
- });
1308
- response.headers = common.headersArrayToObject(response.rawHeaders);
1309
- }
1310
- function continueWithResponseBody(rawBody) {
1311
- prepareResponseHeaders(rawBody);
1312
- const bodyAsStream = convertBodyToStream(rawBody);
1313
- bodyAsStream.pause();
1314
- bodyAsStream.on("data", function(chunk) {
1315
- response.push(chunk);
1316
- });
1317
- bodyAsStream.on("end", function() {
1318
- response.complete = true;
1319
- response.push(null);
1320
- interceptor.scope.emit("replied", req, interceptor);
1321
- });
1322
- bodyAsStream.on("error", function(err) {
1323
- response.emit("error", err);
1324
- });
1325
- const { delayBodyInMs, delayConnectionInMs } = interceptor;
1326
- function respond() {
1327
- if (common.isRequestDestroyed(req)) {
1328
- return;
1329
- }
1330
- req.res = response;
1331
- response.req = req;
1332
- logger("emitting response");
1333
- req.emit("response", response);
1334
- common.setTimeout(() => bodyAsStream.resume(), delayBodyInMs);
1335
- }
1336
- socket.applyDelay(delayConnectionInMs);
1337
- common.setTimeout(respond, delayConnectionInMs);
1338
- }
1339
- common.setImmediate(() => {
1340
- if (!common.isRequestDestroyed(req)) {
1341
- start();
1342
- }
1343
- });
1344
- }
1345
- module.exports = { playbackInterceptor };
1346
- }
1347
- });
1348
-
1349
- // ../../node_modules/nock/lib/intercepted_request_router.js
1350
- var require_intercepted_request_router = _chunkV46WVGWNjs.__commonJS.call(void 0, {
1351
- "../../node_modules/nock/lib/intercepted_request_router.js"(exports, module) {
1352
- "use strict";
1353
- var debug = require_browser()("nock.request_overrider");
1354
- var {
1355
- IncomingMessage,
1356
- ClientRequest,
1357
- request: originalHttpRequest
1358
- } = _chunkV46WVGWNjs.__require.call(void 0, "http");
1359
- var { request: originalHttpsRequest } = _chunkV46WVGWNjs.__require.call(void 0, "https");
1360
- var propagate = require_propagate();
1361
- var common = require_common2();
1362
- var globalEmitter = require_global_emitter();
1363
- var Socket = require_socket();
1364
- var { playbackInterceptor } = require_playback_interceptor();
1365
- function socketOnClose(req) {
1366
- debug("socket close");
1367
- if (!req.res && !req.socket._hadError) {
1368
- req.socket._hadError = true;
1369
- const err = new Error("socket hang up");
1370
- err.code = "ECONNRESET";
1371
- req.emit("error", err);
1372
- }
1373
- req.emit("close");
1374
- }
1375
- var InterceptedRequestRouter = class {
1376
- constructor({ req, options, interceptors }) {
1377
- this.req = req;
1378
- this.options = {
1379
- // We may be changing the options object and we don't want those changes
1380
- // affecting the user so we use a clone of the object.
1381
- ...options,
1382
- // We use lower-case header field names throughout Nock.
1383
- headers: common.headersFieldNamesToLowerCase(
1384
- options.headers || {},
1385
- false
1386
- )
1387
- };
1388
- this.interceptors = interceptors;
1389
- this.socket = new Socket(options);
1390
- const timeout = options.timeout || options.agent && options.agent.options && options.agent.options.timeout;
1391
- if (timeout) {
1392
- this.socket.setTimeout(timeout);
1393
- }
1394
- this.response = new IncomingMessage(this.socket);
1395
- this.requestBodyBuffers = [];
1396
- this.playbackStarted = false;
1397
- this.readyToStartPlaybackOnSocketEvent = false;
1398
- this.attachToReq();
1399
- process.nextTick(() => this.connectSocket());
1400
- }
1401
- attachToReq() {
1402
- const { req, options } = this;
1403
- for (const [name, val] of Object.entries(options.headers)) {
1404
- req.setHeader(name.toLowerCase(), val);
1405
- }
1406
- if (options.auth && !options.headers.authorization) {
1407
- req.setHeader(
1408
- // We use lower-case header field names throughout Nock.
1409
- "authorization",
1410
- `Basic ${Buffer.from(options.auth).toString("base64")}`
1411
- );
1412
- }
1413
- req.path = options.path;
1414
- req.method = options.method;
1415
- req.write = (...args) => this.handleWrite(...args);
1416
- req.end = (...args) => this.handleEnd(...args);
1417
- req.flushHeaders = (...args) => this.handleFlushHeaders(...args);
1418
- if (options.headers.expect === "100-continue") {
1419
- common.setImmediate(() => {
1420
- debug("continue");
1421
- req.emit("continue");
1422
- });
1423
- }
1424
- }
1425
- connectSocket() {
1426
- const { req, socket } = this;
1427
- if (common.isRequestDestroyed(req)) {
1428
- return;
1429
- }
1430
- req.socket = req.connection = socket;
1431
- propagate(["error", "timeout"], socket, req);
1432
- socket.on("close", () => socketOnClose(req));
1433
- socket.connecting = false;
1434
- req.emit("socket", socket);
1435
- socket.emit("connect");
1436
- if (socket.authorized) {
1437
- socket.emit("secureConnect");
1438
- }
1439
- if (this.readyToStartPlaybackOnSocketEvent) {
1440
- this.maybeStartPlayback();
1441
- }
1442
- }
1443
- // from docs: When write function is called with empty string or buffer, it does nothing and waits for more input.
1444
- // However, actually implementation checks the state of finished and aborted before checking if the first arg is empty.
1445
- handleWrite(...args) {
1446
- debug("request write");
1447
- let [buffer, encoding] = args;
1448
- const { req } = this;
1449
- if (req.finished) {
1450
- const err = new Error("write after end");
1451
- err.code = "ERR_STREAM_WRITE_AFTER_END";
1452
- process.nextTick(() => req.emit("error", err));
1453
- return true;
1454
- }
1455
- if (req.socket && req.socket.destroyed) {
1456
- return false;
1457
- }
1458
- if (!buffer) {
1459
- return true;
1460
- }
1461
- if (!Buffer.isBuffer(buffer)) {
1462
- buffer = Buffer.from(buffer, encoding);
1463
- }
1464
- this.requestBodyBuffers.push(buffer);
1465
- const callback = args.length > 1 ? args[args.length - 1] : void 0;
1466
- if (typeof callback === "function") {
1467
- callback();
1468
- }
1469
- common.setImmediate(function() {
1470
- req.emit("drain");
1471
- });
1472
- return false;
1473
- }
1474
- handleEnd(chunk, encoding, callback) {
1475
- debug("request end");
1476
- const { req } = this;
1477
- if (typeof chunk === "function") {
1478
- callback = chunk;
1479
- chunk = null;
1480
- } else if (typeof encoding === "function") {
1481
- callback = encoding;
1482
- encoding = null;
1483
- }
1484
- if (typeof callback === "function") {
1485
- req.once("finish", callback);
1486
- }
1487
- if (chunk) {
1488
- req.write(chunk, encoding);
1489
- }
1490
- req.finished = true;
1491
- this.maybeStartPlayback();
1492
- return req;
1493
- }
1494
- handleFlushHeaders() {
1495
- debug("request flushHeaders");
1496
- this.maybeStartPlayback();
1497
- }
1498
- /**
1499
- * Set request headers of the given request. This is needed both during the
1500
- * routing phase, in case header filters were specified, and during the
1501
- * interceptor-playback phase, to correctly pass mocked request headers.
1502
- * TODO There are some problems with this; see https://github.com/nock/nock/issues/1718
1503
- */
1504
- setHostHeaderUsingInterceptor(interceptor) {
1505
- const { req, options } = this;
1506
- const HOST_HEADER = "host";
1507
- if (interceptor.__nock_filteredScope && interceptor.__nock_scopeHost) {
1508
- options.headers[HOST_HEADER] = interceptor.__nock_scopeHost;
1509
- req.setHeader(HOST_HEADER, interceptor.__nock_scopeHost);
1510
- } else {
1511
- if (options.host && !req.getHeader(HOST_HEADER)) {
1512
- let hostHeader = options.host;
1513
- if (options.port === 80 || options.port === 443) {
1514
- hostHeader = hostHeader.split(":")[0];
1515
- }
1516
- req.setHeader(HOST_HEADER, hostHeader);
1517
- }
1518
- }
1519
- }
1520
- maybeStartPlayback() {
1521
- const { req, socket, playbackStarted } = this;
1522
- if (socket.connecting) {
1523
- this.readyToStartPlaybackOnSocketEvent = true;
1524
- return;
1525
- }
1526
- if (!common.isRequestDestroyed(req) && !playbackStarted) {
1527
- this.startPlayback();
1528
- }
1529
- }
1530
- startPlayback() {
1531
- debug("ending");
1532
- this.playbackStarted = true;
1533
- const { req, response, socket, options, interceptors } = this;
1534
- Object.assign(options, {
1535
- // Re-update `options` with the current value of `req.path` because badly
1536
- // behaving agents like superagent like to change `req.path` mid-flight.
1537
- path: req.path,
1538
- // Similarly, node-http-proxy will modify headers in flight, so we have
1539
- // to put the headers back into options.
1540
- // https://github.com/nock/nock/pull/1484
1541
- headers: req.getHeaders(),
1542
- // Fixes https://github.com/nock/nock/issues/976
1543
- protocol: `${options.proto}:`
1544
- });
1545
- interceptors.forEach((interceptor) => {
1546
- this.setHostHeaderUsingInterceptor(interceptor);
1547
- });
1548
- const requestBodyBuffer = Buffer.concat(this.requestBodyBuffers);
1549
- const requestBodyIsUtf8Representable = common.isUtf8Representable(requestBodyBuffer);
1550
- const requestBodyString = requestBodyBuffer.toString(
1551
- requestBodyIsUtf8Representable ? "utf8" : "hex"
1552
- );
1553
- const matchedInterceptor = interceptors.find(
1554
- (i) => i.match(req, options, requestBodyString)
1555
- );
1556
- if (matchedInterceptor) {
1557
- matchedInterceptor.scope.logger(
1558
- "interceptor identified, starting mocking"
1559
- );
1560
- matchedInterceptor.markConsumed();
1561
- req.emit("finish");
1562
- playbackInterceptor({
1563
- req,
1564
- socket,
1565
- options,
1566
- requestBodyString,
1567
- requestBodyIsUtf8Representable,
1568
- response,
1569
- interceptor: matchedInterceptor
1570
- });
1571
- } else {
1572
- globalEmitter.emit("no match", req, options, requestBodyString);
1573
- const allowUnmocked = interceptors.some(
1574
- (i) => i.matchHostName(options) && i.options.allowUnmocked
1575
- );
1576
- if (allowUnmocked && req instanceof ClientRequest) {
1577
- const newReq = options.proto === "https" ? originalHttpsRequest(options) : originalHttpRequest(options);
1578
- propagate(newReq, req);
1579
- newReq.end(requestBodyBuffer);
1580
- } else {
1581
- const reqStr = common.stringifyRequest(options, requestBodyString);
1582
- const err = new Error(`Nock: No match for request ${reqStr}`);
1583
- err.code = "ERR_NOCK_NO_MATCH";
1584
- err.statusCode = err.status = 404;
1585
- req.destroy(err);
1586
- }
1587
- }
1588
- }
1589
- };
1590
- module.exports = { InterceptedRequestRouter };
1591
- }
1592
- });
1593
-
1594
- // ../../node_modules/json-stringify-safe/stringify.js
1595
- var require_stringify = _chunkV46WVGWNjs.__commonJS.call(void 0, {
1596
- "../../node_modules/json-stringify-safe/stringify.js"(exports, module) {
1597
- "use strict";
1598
- exports = module.exports = stringify;
1599
- exports.getSerialize = serializer;
1600
- function stringify(obj, replacer, spaces, cycleReplacer) {
1601
- return JSON.stringify(obj, serializer(replacer, cycleReplacer), spaces);
1602
- }
1603
- function serializer(replacer, cycleReplacer) {
1604
- var stack = [], keys = [];
1605
- if (cycleReplacer == null)
1606
- cycleReplacer = function(key, value) {
1607
- if (stack[0] === value)
1608
- return "[Circular ~]";
1609
- return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
1610
- };
1611
- return function(key, value) {
1612
- if (stack.length > 0) {
1613
- var thisPos = stack.indexOf(this);
1614
- ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
1615
- ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
1616
- if (~stack.indexOf(value))
1617
- value = cycleReplacer.call(this, key, value);
1618
- } else
1619
- stack.push(value);
1620
- return replacer == null ? value : replacer.call(this, key, value);
1621
- };
1622
- }
1623
- }
1624
- });
1625
-
1626
- // ../../node_modules/nock/lib/match_body.js
1627
- var require_match_body = _chunkV46WVGWNjs.__commonJS.call(void 0, {
1628
- "../../node_modules/nock/lib/match_body.js"(exports, module) {
1629
- "use strict";
1630
- var querystring = _chunkV46WVGWNjs.__require.call(void 0, "querystring");
1631
- var common = require_common2();
1632
- module.exports = function matchBody(options, spec, body) {
1633
- if (spec instanceof RegExp) {
1634
- return spec.test(body);
1635
- }
1636
- if (Buffer.isBuffer(spec)) {
1637
- const encoding = common.isUtf8Representable(spec) ? "utf8" : "hex";
1638
- spec = spec.toString(encoding);
1639
- }
1640
- const contentType = (options.headers && (options.headers["Content-Type"] || options.headers["content-type"]) || "").toString();
1641
- const isMultipart = contentType.includes("multipart");
1642
- const isUrlencoded = contentType.includes("application/x-www-form-urlencoded");
1643
- let json;
1644
- if (typeof spec === "object" || typeof spec === "function") {
1645
- try {
1646
- json = JSON.parse(body);
1647
- } catch (err) {
1648
- }
1649
- if (json !== void 0) {
1650
- body = json;
1651
- } else if (isUrlencoded) {
1652
- body = querystring.parse(body);
1653
- }
1654
- }
1655
- if (typeof spec === "function") {
1656
- return spec.call(options, body);
1657
- }
1658
- if (!isMultipart && typeof body === "string") {
1659
- body = body.replace(/\r?\n|\r/g, "");
1660
- }
1661
- if (!isMultipart && typeof spec === "string") {
1662
- spec = spec.replace(/\r?\n|\r/g, "");
1663
- }
1664
- if (isUrlencoded) {
1665
- spec = mapValuesDeep(spec, (val) => val instanceof RegExp ? val : `${val}`);
1666
- }
1667
- return common.dataEqual(spec, body);
1668
- };
1669
- function mapValues(object, cb) {
1670
- const keys = Object.keys(object);
1671
- for (const key of keys) {
1672
- object[key] = cb(object[key], key, object);
1673
- }
1674
- return object;
1675
- }
1676
- function mapValuesDeep(obj, cb) {
1677
- if (Array.isArray(obj)) {
1678
- return obj.map((v) => mapValuesDeep(v, cb));
1679
- }
1680
- if (common.isPlainObject(obj)) {
1681
- return mapValues(obj, (v) => mapValuesDeep(v, cb));
1682
- }
1683
- return cb(obj);
1684
- }
1685
- }
1686
- });
1687
-
1688
- // ../../node_modules/nock/lib/interceptor.js
1689
- var require_interceptor = _chunkV46WVGWNjs.__commonJS.call(void 0, {
1690
- "../../node_modules/nock/lib/interceptor.js"(exports, module) {
1691
- "use strict";
1692
- var stringify = require_stringify();
1693
- var querystring = _chunkV46WVGWNjs.__require.call(void 0, "querystring");
1694
- var { URL, URLSearchParams } = _chunkV46WVGWNjs.__require.call(void 0, "url");
1695
- var common = require_common2();
1696
- var { remove } = require_intercept();
1697
- var matchBody = require_match_body();
1698
- var fs;
1699
- try {
1700
- fs = _chunkV46WVGWNjs.__require.call(void 0, "fs");
1701
- } catch (err) {
1702
- }
1703
- module.exports = class Interceptor {
1704
- /**
1705
- *
1706
- * Valid argument types for `uri`:
1707
- * - A string used for strict comparisons with pathname.
1708
- * The search portion of the URI may also be postfixed, in which case the search params
1709
- * are striped and added via the `query` method.
1710
- * - A RegExp instance that tests against only the pathname of requests.
1711
- * - A synchronous function bound to this Interceptor instance. It's provided the pathname
1712
- * of requests and must return a boolean denoting if the request is considered a match.
1713
- */
1714
- constructor(scope, uri, method, requestBody, interceptorOptions) {
1715
- const uriIsStr = typeof uri === "string";
1716
- if (uriIsStr && !scope.scopeOptions.filteringScope && !scope.basePathname && !uri.startsWith("/") && !uri.startsWith("*")) {
1717
- throw Error(
1718
- `Non-wildcard URL path strings must begin with a slash (otherwise they won't match anything) (got: ${uri})`
1719
- );
1720
- }
1721
- if (!method) {
1722
- throw new Error(
1723
- 'The "method" parameter is required for an intercept call.'
1724
- );
1725
- }
1726
- this.scope = scope;
1727
- this.interceptorMatchHeaders = [];
1728
- this.method = method.toUpperCase();
1729
- this.uri = uri;
1730
- this._key = `${this.method} ${scope.basePath}${scope.basePathname}${uriIsStr ? "" : "/"}${uri}`;
1731
- this.basePath = this.scope.basePath;
1732
- this.path = uriIsStr ? scope.basePathname + uri : uri;
1733
- this.queries = null;
1734
- this.options = interceptorOptions || {};
1735
- this.counter = 1;
1736
- this._requestBody = requestBody;
1737
- this.reqheaders = common.headersFieldNamesToLowerCase(
1738
- scope.scopeOptions.reqheaders || {},
1739
- true
1740
- );
1741
- this.badheaders = common.headersFieldsArrayToLowerCase(
1742
- scope.scopeOptions.badheaders || []
1743
- );
1744
- this.delayBodyInMs = 0;
1745
- this.delayConnectionInMs = 0;
1746
- this.optional = false;
1747
- if (uriIsStr && uri.includes("?")) {
1748
- const parsedURL = new URL(this.path, "http://localhost");
1749
- this.path = parsedURL.pathname;
1750
- this.query(parsedURL.searchParams);
1751
- this._key = `${this.method} ${scope.basePath}${this.path}`;
1752
- }
1753
- }
1754
- optionally(flag = true) {
1755
- if (typeof flag !== "boolean") {
1756
- throw new Error("Invalid arguments: argument should be a boolean");
1757
- }
1758
- this.optional = flag;
1759
- return this;
1760
- }
1761
- replyWithError(errorMessage) {
1762
- this.errorMessage = errorMessage;
1763
- this.options = {
1764
- ...this.scope.scopeOptions,
1765
- ...this.options
1766
- };
1767
- this.scope.add(this._key, this);
1768
- return this.scope;
1769
- }
1770
- reply(statusCode, body, rawHeaders) {
1771
- if (typeof statusCode === "function") {
1772
- if (arguments.length > 1) {
1773
- throw Error(
1774
- "Invalid arguments. When providing a function for the first argument, .reply does not accept other arguments."
1775
- );
1776
- }
1777
- this.statusCode = null;
1778
- this.fullReplyFunction = statusCode;
1779
- } else {
1780
- if (statusCode !== void 0 && !Number.isInteger(statusCode)) {
1781
- throw new Error(`Invalid ${typeof statusCode} value for status code`);
1782
- }
1783
- this.statusCode = statusCode || 200;
1784
- if (typeof body === "function") {
1785
- this.replyFunction = body;
1786
- body = null;
1787
- }
1788
- }
1789
- this.options = {
1790
- ...this.scope.scopeOptions,
1791
- ...this.options
1792
- };
1793
- this.rawHeaders = common.headersInputToRawArray(rawHeaders);
1794
- if (this.scope.date) {
1795
- this.rawHeaders.push("Date", this.scope.date.toUTCString());
1796
- }
1797
- this.headers = common.headersArrayToObject(
1798
- this.rawHeaders.concat(this.scope._defaultReplyHeaders)
1799
- );
1800
- if (body && typeof body !== "string" && !Buffer.isBuffer(body) && !common.isStream(body) && !common.isContentEncoded(this.headers)) {
1801
- try {
1802
- body = stringify(body);
1803
- } catch (err) {
1804
- throw new Error("Error encoding response body into JSON");
1805
- }
1806
- if (!this.headers["content-type"]) {
1807
- this.rawHeaders.push("Content-Type", "application/json");
1808
- }
1809
- }
1810
- if (this.scope.contentLen) {
1811
- if (typeof body === "string") {
1812
- this.rawHeaders.push("Content-Length", body.length);
1813
- } else if (Buffer.isBuffer(body)) {
1814
- this.rawHeaders.push("Content-Length", body.byteLength);
1815
- }
1816
- }
1817
- this.scope.logger("reply.headers:", this.headers);
1818
- this.scope.logger("reply.rawHeaders:", this.rawHeaders);
1819
- this.body = body;
1820
- this.scope.add(this._key, this);
1821
- return this.scope;
1822
- }
1823
- replyWithFile(statusCode, filePath, headers) {
1824
- if (!fs) {
1825
- throw new Error("No fs");
1826
- }
1827
- this.filePath = filePath;
1828
- return this.reply(
1829
- statusCode,
1830
- () => {
1831
- const readStream = fs.createReadStream(filePath);
1832
- readStream.pause();
1833
- return readStream;
1834
- },
1835
- headers
1836
- );
1837
- }
1838
- // Also match request headers
1839
- // https://github.com/nock/nock/issues/163
1840
- reqheaderMatches(options, key) {
1841
- const reqHeader = this.reqheaders[key];
1842
- let header = options.headers[key];
1843
- if (header && typeof header !== "string" && header.toString) {
1844
- header = header.toString();
1845
- }
1846
- if (key === "host" && (header === void 0 || reqHeader === void 0)) {
1847
- return true;
1848
- }
1849
- if (reqHeader !== void 0 && header !== void 0) {
1850
- if (typeof reqHeader === "function") {
1851
- return reqHeader(header);
1852
- } else if (common.matchStringOrRegexp(header, reqHeader)) {
1853
- return true;
1854
- }
1855
- }
1856
- this.scope.logger(
1857
- "request header field doesn't match:",
1858
- key,
1859
- header,
1860
- reqHeader
1861
- );
1862
- return false;
1863
- }
1864
- match(req, options, body) {
1865
- if (this.scope.logger.enabled) {
1866
- this.scope.logger(
1867
- "attempting match %s, body = %s",
1868
- stringify(options),
1869
- stringify(body)
1870
- );
1871
- }
1872
- const method = (options.method || "GET").toUpperCase();
1873
- let { path = "/" } = options;
1874
- let matches;
1875
- let matchKey;
1876
- const { proto } = options;
1877
- if (this.method !== method) {
1878
- this.scope.logger(
1879
- `Method did not match. Request ${method} Interceptor ${this.method}`
1880
- );
1881
- return false;
1882
- }
1883
- if (this.scope.transformPathFunction) {
1884
- path = this.scope.transformPathFunction(path);
1885
- }
1886
- const requestMatchesFilter = ({ name, value: predicate }) => {
1887
- const headerValue = req.getHeader(name);
1888
- if (typeof predicate === "function") {
1889
- return predicate(headerValue);
1890
- } else {
1891
- return common.matchStringOrRegexp(headerValue, predicate);
1892
- }
1893
- };
1894
- if (!this.scope.matchHeaders.every(requestMatchesFilter) || !this.interceptorMatchHeaders.every(requestMatchesFilter)) {
1895
- this.scope.logger("headers don't match");
1896
- return false;
1897
- }
1898
- const reqHeadersMatch = Object.keys(this.reqheaders).every(
1899
- (key) => this.reqheaderMatches(options, key)
1900
- );
1901
- if (!reqHeadersMatch) {
1902
- this.scope.logger("headers don't match");
1903
- return false;
1904
- }
1905
- if (this.scope.scopeOptions.conditionally && !this.scope.scopeOptions.conditionally()) {
1906
- this.scope.logger(
1907
- "matching failed because Scope.conditionally() did not validate"
1908
- );
1909
- return false;
1910
- }
1911
- const badHeaders = this.badheaders.filter(
1912
- (header) => header in options.headers
1913
- );
1914
- if (badHeaders.length) {
1915
- this.scope.logger("request contains bad headers", ...badHeaders);
1916
- return false;
1917
- }
1918
- if (this.queries === null) {
1919
- this.scope.logger("query matching skipped");
1920
- } else {
1921
- const [pathname, search] = path.split("?");
1922
- const matchQueries = this.matchQuery({ search });
1923
- this.scope.logger(
1924
- matchQueries ? "query matching succeeded" : "query matching failed"
1925
- );
1926
- if (!matchQueries) {
1927
- return false;
1928
- }
1929
- path = pathname;
1930
- }
1931
- if (this.__nock_filteredScope) {
1932
- matchKey = this.__nock_filteredScope;
1933
- } else {
1934
- matchKey = common.normalizeOrigin(proto, options.host, options.port);
1935
- }
1936
- if (typeof this.uri === "function") {
1937
- matches = common.matchStringOrRegexp(matchKey, this.basePath) && // This is a false positive, as `uri` is not bound to `this`.
1938
- // eslint-disable-next-line no-useless-call
1939
- this.uri.call(this, path);
1940
- } else {
1941
- matches = common.matchStringOrRegexp(matchKey, this.basePath) && common.matchStringOrRegexp(path, this.path);
1942
- }
1943
- this.scope.logger(`matching ${matchKey}${path} to ${this._key}: ${matches}`);
1944
- if (matches && this._requestBody !== void 0) {
1945
- if (this.scope.transformRequestBodyFunction) {
1946
- body = this.scope.transformRequestBodyFunction(body, this._requestBody);
1947
- }
1948
- matches = matchBody(options, this._requestBody, body);
1949
- if (!matches) {
1950
- this.scope.logger(
1951
- "bodies don't match: \n",
1952
- this._requestBody,
1953
- "\n",
1954
- body
1955
- );
1956
- }
1957
- }
1958
- return matches;
1959
- }
1960
- /**
1961
- * Return true when the interceptor's method, protocol, host, port, and path
1962
- * match the provided options.
1963
- */
1964
- matchOrigin(options) {
1965
- const isPathFn = typeof this.path === "function";
1966
- const isRegex = this.path instanceof RegExp;
1967
- const isRegexBasePath = this.scope.basePath instanceof RegExp;
1968
- const method = (options.method || "GET").toUpperCase();
1969
- let { path } = options;
1970
- const { proto } = options;
1971
- if (!isRegex) {
1972
- path = path ? path.split("?")[0] : "";
1973
- }
1974
- if (this.scope.transformPathFunction) {
1975
- path = this.scope.transformPathFunction(path);
1976
- }
1977
- const comparisonKey = isPathFn || isRegex ? this.__nock_scopeKey : this._key;
1978
- const matchKey = `${method} ${proto}://${options.host}${path}`;
1979
- if (isPathFn) {
1980
- return !!(matchKey.match(comparisonKey) && this.path(path));
1981
- }
1982
- if (isRegex && !isRegexBasePath) {
1983
- return !!matchKey.match(comparisonKey) && this.path.test(path);
1984
- }
1985
- if (isRegexBasePath) {
1986
- return this.scope.basePath.test(matchKey) && !!path.match(this.path);
1987
- }
1988
- return comparisonKey === matchKey;
1989
- }
1990
- matchHostName(options) {
1991
- const { basePath } = this.scope;
1992
- if (basePath instanceof RegExp) {
1993
- return basePath.test(options.hostname);
1994
- }
1995
- return options.hostname === this.scope.urlParts.hostname;
1996
- }
1997
- matchQuery(options) {
1998
- if (this.queries === true) {
1999
- return true;
2000
- }
2001
- const reqQueries = querystring.parse(options.search);
2002
- this.scope.logger("Interceptor queries: %j", this.queries);
2003
- this.scope.logger(" Request queries: %j", reqQueries);
2004
- if (typeof this.queries === "function") {
2005
- return this.queries(reqQueries);
2006
- }
2007
- return common.dataEqual(this.queries, reqQueries);
2008
- }
2009
- filteringPath(...args) {
2010
- this.scope.filteringPath(...args);
2011
- return this;
2012
- }
2013
- // TODO filtering by path is valid on the intercept level, but not filtering
2014
- // by request body?
2015
- markConsumed() {
2016
- this.interceptionCounter++;
2017
- remove(this);
2018
- if (!this.scope.shouldPersist() && this.counter < 1) {
2019
- this.scope.remove(this._key, this);
2020
- }
2021
- }
2022
- matchHeader(name, value) {
2023
- this.interceptorMatchHeaders.push({ name, value });
2024
- return this;
2025
- }
2026
- basicAuth({ user, pass = "" }) {
2027
- const encoded = Buffer.from(`${user}:${pass}`).toString("base64");
2028
- this.matchHeader("authorization", `Basic ${encoded}`);
2029
- return this;
2030
- }
2031
- /**
2032
- * Set query strings for the interceptor
2033
- * @name query
2034
- * @param queries Object of query string name,values (accepts regexp values)
2035
- * @public
2036
- * @example
2037
- * // Will match 'http://zombo.com/?q=t'
2038
- * nock('http://zombo.com').get('/').query({q: 't'});
2039
- */
2040
- query(queries) {
2041
- if (this.queries !== null) {
2042
- throw Error(`Query parameters have already been defined`);
2043
- }
2044
- if (queries === true) {
2045
- this.queries = queries;
2046
- return this;
2047
- }
2048
- if (typeof queries === "function") {
2049
- this.queries = queries;
2050
- return this;
2051
- }
2052
- let strFormattingFn;
2053
- if (this.scope.scopeOptions.encodedQueryParams) {
2054
- strFormattingFn = common.percentDecode;
2055
- }
2056
- if (queries instanceof URLSearchParams || typeof queries === "string") {
2057
- queries = querystring.parse(queries.toString());
2058
- } else if (!common.isPlainObject(queries)) {
2059
- throw Error(`Argument Error: ${queries}`);
2060
- }
2061
- this.queries = {};
2062
- for (const [key, value] of Object.entries(queries)) {
2063
- const formatted = common.formatQueryValue(key, value, strFormattingFn);
2064
- const [formattedKey, formattedValue] = formatted;
2065
- this.queries[formattedKey] = formattedValue;
2066
- }
2067
- return this;
2068
- }
2069
- /**
2070
- * Set number of times will repeat the interceptor
2071
- * @name times
2072
- * @param newCounter Number of times to repeat (should be > 0)
2073
- * @public
2074
- * @example
2075
- * // Will repeat mock 5 times for same king of request
2076
- * nock('http://zombo.com).get('/').times(5).reply(200, 'Ok');
2077
- */
2078
- times(newCounter) {
2079
- if (newCounter < 1) {
2080
- return this;
2081
- }
2082
- this.counter = newCounter;
2083
- return this;
2084
- }
2085
- /**
2086
- * An sugar syntax for times(1)
2087
- * @name once
2088
- * @see {@link times}
2089
- * @public
2090
- * @example
2091
- * nock('http://zombo.com).get('/').once().reply(200, 'Ok');
2092
- */
2093
- once() {
2094
- return this.times(1);
2095
- }
2096
- /**
2097
- * An sugar syntax for times(2)
2098
- * @name twice
2099
- * @see {@link times}
2100
- * @public
2101
- * @example
2102
- * nock('http://zombo.com).get('/').twice().reply(200, 'Ok');
2103
- */
2104
- twice() {
2105
- return this.times(2);
2106
- }
2107
- /**
2108
- * An sugar syntax for times(3).
2109
- * @name thrice
2110
- * @see {@link times}
2111
- * @public
2112
- * @example
2113
- * nock('http://zombo.com).get('/').thrice().reply(200, 'Ok');
2114
- */
2115
- thrice() {
2116
- return this.times(3);
2117
- }
2118
- /**
2119
- * Delay the response by a certain number of ms.
2120
- *
2121
- * @param {(integer|object)} opts - Number of milliseconds to wait, or an object
2122
- * @param {integer} [opts.head] - Number of milliseconds to wait before response is sent
2123
- * @param {integer} [opts.body] - Number of milliseconds to wait before response body is sent
2124
- * @return {Interceptor} - the current interceptor for chaining
2125
- */
2126
- delay(opts) {
2127
- let headDelay;
2128
- let bodyDelay;
2129
- if (typeof opts === "number") {
2130
- headDelay = opts;
2131
- bodyDelay = 0;
2132
- } else if (typeof opts === "object") {
2133
- headDelay = opts.head || 0;
2134
- bodyDelay = opts.body || 0;
2135
- } else {
2136
- throw new Error(`Unexpected input opts ${opts}`);
2137
- }
2138
- return this.delayConnection(headDelay).delayBody(bodyDelay);
2139
- }
2140
- /**
2141
- * Delay the response body by a certain number of ms.
2142
- *
2143
- * @param {integer} ms - Number of milliseconds to wait before response is sent
2144
- * @return {Interceptor} - the current interceptor for chaining
2145
- */
2146
- delayBody(ms) {
2147
- this.delayBodyInMs = ms;
2148
- return this;
2149
- }
2150
- /**
2151
- * Delay the connection by a certain number of ms.
2152
- *
2153
- * @param {integer} ms - Number of milliseconds to wait
2154
- * @return {Interceptor} - the current interceptor for chaining
2155
- */
2156
- delayConnection(ms) {
2157
- this.delayConnectionInMs = ms;
2158
- return this;
2159
- }
2160
- };
2161
- }
2162
- });
2163
-
2164
- // ../../node_modules/nock/lib/intercept.js
2165
- var require_intercept = _chunkV46WVGWNjs.__commonJS.call(void 0, {
2166
- "../../node_modules/nock/lib/intercept.js"(exports, module) {
2167
- "use strict";
2168
- var { InterceptedRequestRouter } = require_intercepted_request_router();
2169
- var common = require_common2();
2170
- var { inherits } = _chunkV46WVGWNjs.__require.call(void 0, "util");
2171
- var http = _chunkV46WVGWNjs.__require.call(void 0, "http");
2172
- var debug = require_browser()("nock.intercept");
2173
- var globalEmitter = require_global_emitter();
2174
- function NetConnectNotAllowedError(host, path) {
2175
- Error.call(this);
2176
- this.name = "NetConnectNotAllowedError";
2177
- this.code = "ENETUNREACH";
2178
- this.message = `Nock: Disallowed net connect for "${host}${path}"`;
2179
- Error.captureStackTrace(this, this.constructor);
2180
- }
2181
- inherits(NetConnectNotAllowedError, Error);
2182
- var allInterceptors = {};
2183
- var allowNetConnect;
2184
- function enableNetConnect(matcher) {
2185
- if (typeof matcher === "string") {
2186
- allowNetConnect = new RegExp(matcher);
2187
- } else if (matcher instanceof RegExp) {
2188
- allowNetConnect = matcher;
2189
- } else if (typeof matcher === "function") {
2190
- allowNetConnect = { test: matcher };
2191
- } else {
2192
- allowNetConnect = /.*/;
2193
- }
2194
- }
2195
- function isEnabledForNetConnect(options) {
2196
- common.normalizeRequestOptions(options);
2197
- const enabled = allowNetConnect && allowNetConnect.test(options.host);
2198
- debug("Net connect", enabled ? "" : "not", "enabled for", options.host);
2199
- return enabled;
2200
- }
2201
- function disableNetConnect() {
2202
- allowNetConnect = void 0;
2203
- }
2204
- function isOn() {
2205
- return !isOff();
2206
- }
2207
- function isOff() {
2208
- return process.env.NOCK_OFF === "true";
2209
- }
2210
- function addInterceptor(key, interceptor, scope, scopeOptions, host) {
2211
- if (!(key in allInterceptors)) {
2212
- allInterceptors[key] = { key, interceptors: [] };
2213
- }
2214
- interceptor.__nock_scope = scope;
2215
- interceptor.__nock_scopeKey = key;
2216
- interceptor.__nock_scopeOptions = scopeOptions;
2217
- interceptor.__nock_scopeHost = host;
2218
- interceptor.interceptionCounter = 0;
2219
- if (scopeOptions.allowUnmocked)
2220
- allInterceptors[key].allowUnmocked = true;
2221
- allInterceptors[key].interceptors.push(interceptor);
2222
- }
2223
- function remove(interceptor) {
2224
- if (interceptor.__nock_scope.shouldPersist() || --interceptor.counter > 0) {
2225
- return;
2226
- }
2227
- const { basePath } = interceptor;
2228
- const interceptors = allInterceptors[basePath] && allInterceptors[basePath].interceptors || [];
2229
- interceptors.some(function(thisInterceptor, i) {
2230
- return thisInterceptor === interceptor ? interceptors.splice(i, 1) : false;
2231
- });
2232
- }
2233
- function removeAll() {
2234
- Object.keys(allInterceptors).forEach(function(key) {
2235
- allInterceptors[key].interceptors.forEach(function(interceptor) {
2236
- interceptor.scope.keyedInterceptors = {};
2237
- });
2238
- });
2239
- allInterceptors = {};
2240
- }
2241
- function interceptorsFor(options) {
2242
- common.normalizeRequestOptions(options);
2243
- debug("interceptors for %j", options.host);
2244
- const basePath = `${options.proto}://${options.host}`;
2245
- debug("filtering interceptors for basepath", basePath);
2246
- for (const { key, interceptors, allowUnmocked } of Object.values(
2247
- allInterceptors
2248
- )) {
2249
- for (const interceptor of interceptors) {
2250
- const { filteringScope } = interceptor.__nock_scopeOptions;
2251
- if (filteringScope && filteringScope(basePath)) {
2252
- interceptor.scope.logger("found matching scope interceptor");
2253
- interceptors.forEach((ic) => {
2254
- ic.__nock_filteredScope = ic.__nock_scopeKey;
2255
- });
2256
- return interceptors;
2257
- }
2258
- }
2259
- if (common.matchStringOrRegexp(basePath, key)) {
2260
- if (allowUnmocked && interceptors.length === 0) {
2261
- debug("matched base path with allowUnmocked (no matching interceptors)");
2262
- return [
2263
- {
2264
- options: { allowUnmocked: true },
2265
- matchOrigin() {
2266
- return false;
2267
- }
2268
- }
2269
- ];
2270
- } else {
2271
- debug(
2272
- `matched base path (${interceptors.length} interceptor${interceptors.length > 1 ? "s" : ""})`
2273
- );
2274
- return interceptors;
2275
- }
2276
- }
2277
- }
2278
- return void 0;
2279
- }
2280
- function removeInterceptor(options) {
2281
- const Interceptor = require_interceptor();
2282
- let baseUrl, key, method, proto;
2283
- if (options instanceof Interceptor) {
2284
- baseUrl = options.basePath;
2285
- key = options._key;
2286
- } else {
2287
- proto = options.proto ? options.proto : "http";
2288
- common.normalizeRequestOptions(options);
2289
- baseUrl = `${proto}://${options.host}`;
2290
- method = options.method && options.method.toUpperCase() || "GET";
2291
- key = `${method} ${baseUrl}${options.path || "/"}`;
2292
- }
2293
- if (allInterceptors[baseUrl] && allInterceptors[baseUrl].interceptors.length > 0) {
2294
- for (let i = 0; i < allInterceptors[baseUrl].interceptors.length; i++) {
2295
- const interceptor = allInterceptors[baseUrl].interceptors[i];
2296
- if (options instanceof Interceptor ? interceptor === options : interceptor._key === key) {
2297
- allInterceptors[baseUrl].interceptors.splice(i, 1);
2298
- interceptor.scope.remove(key, interceptor);
2299
- break;
2300
- }
2301
- }
2302
- return true;
2303
- }
2304
- return false;
2305
- }
2306
- var originalClientRequest;
2307
- function ErroringClientRequest(error) {
2308
- http.OutgoingMessage.call(this);
2309
- process.nextTick(
2310
- function() {
2311
- this.emit("error", error);
2312
- }.bind(this)
2313
- );
2314
- }
2315
- inherits(ErroringClientRequest, http.ClientRequest);
2316
- function overrideClientRequest() {
2317
- debug("Overriding ClientRequest");
2318
- function OverriddenClientRequest(...args) {
2319
- const { options, callback } = common.normalizeClientRequestArgs(...args);
2320
- if (Object.keys(options).length === 0) {
2321
- throw Error(
2322
- "Creating a ClientRequest with empty `options` is not supported in Nock"
2323
- );
2324
- }
2325
- http.OutgoingMessage.call(this);
2326
- const interceptors = interceptorsFor(options);
2327
- if (isOn() && interceptors) {
2328
- debug("using", interceptors.length, "interceptors");
2329
- const overrider = new InterceptedRequestRouter({
2330
- req: this,
2331
- options,
2332
- interceptors
2333
- });
2334
- Object.assign(this, overrider);
2335
- if (callback) {
2336
- this.once("response", callback);
2337
- }
2338
- } else {
2339
- debug("falling back to original ClientRequest");
2340
- if (isOff() || isEnabledForNetConnect(options)) {
2341
- originalClientRequest.apply(this, arguments);
2342
- } else {
2343
- common.setImmediate(
2344
- function() {
2345
- const error = new NetConnectNotAllowedError(
2346
- options.host,
2347
- options.path
2348
- );
2349
- this.emit("error", error);
2350
- }.bind(this)
2351
- );
2352
- }
2353
- }
2354
- }
2355
- inherits(OverriddenClientRequest, http.ClientRequest);
2356
- originalClientRequest = http.ClientRequest;
2357
- http.ClientRequest = OverriddenClientRequest;
2358
- debug("ClientRequest overridden");
2359
- }
2360
- function restoreOverriddenClientRequest() {
2361
- debug("restoring overridden ClientRequest");
2362
- if (!originalClientRequest) {
2363
- debug("- ClientRequest was not overridden");
2364
- } else {
2365
- http.ClientRequest = originalClientRequest;
2366
- originalClientRequest = void 0;
2367
- debug("- ClientRequest restored");
2368
- }
2369
- }
2370
- function isActive() {
2371
- return originalClientRequest !== void 0;
2372
- }
2373
- function interceptorScopes() {
2374
- const nestedInterceptors = Object.values(allInterceptors).map(
2375
- (i) => i.interceptors
2376
- );
2377
- const scopes = new Set([].concat(...nestedInterceptors).map((i) => i.scope));
2378
- return [...scopes];
2379
- }
2380
- function isDone() {
2381
- return interceptorScopes().every((scope) => scope.isDone());
2382
- }
2383
- function pendingMocks() {
2384
- return [].concat(...interceptorScopes().map((scope) => scope.pendingMocks()));
2385
- }
2386
- function activeMocks() {
2387
- return [].concat(...interceptorScopes().map((scope) => scope.activeMocks()));
2388
- }
2389
- function activate() {
2390
- if (originalClientRequest) {
2391
- throw new Error("Nock already active");
2392
- }
2393
- common.overrideRequests(function(proto, overriddenRequest, args) {
2394
- const { options, callback } = common.normalizeClientRequestArgs(...args);
2395
- if (Object.keys(options).length === 0) {
2396
- throw Error(
2397
- "Making a request with empty `options` is not supported in Nock"
2398
- );
2399
- }
2400
- options.proto = proto;
2401
- const interceptors = interceptorsFor(options);
2402
- if (isOn() && interceptors) {
2403
- const matches = interceptors.some(
2404
- (interceptor) => interceptor.matchOrigin(options)
2405
- );
2406
- const allowUnmocked = interceptors.some(
2407
- (interceptor) => interceptor.options.allowUnmocked
2408
- );
2409
- if (!matches && allowUnmocked) {
2410
- let req;
2411
- if (proto === "https") {
2412
- const { ClientRequest } = http;
2413
- http.ClientRequest = originalClientRequest;
2414
- req = overriddenRequest(options, callback);
2415
- http.ClientRequest = ClientRequest;
2416
- } else {
2417
- req = overriddenRequest(options, callback);
2418
- }
2419
- globalEmitter.emit("no match", req);
2420
- return req;
2421
- }
2422
- return new http.ClientRequest(options, callback);
2423
- } else {
2424
- globalEmitter.emit("no match", options);
2425
- if (isOff() || isEnabledForNetConnect(options)) {
2426
- return overriddenRequest(options, callback);
2427
- } else {
2428
- const error = new NetConnectNotAllowedError(options.host, options.path);
2429
- return new ErroringClientRequest(error);
2430
- }
2431
- }
2432
- });
2433
- overrideClientRequest();
2434
- }
2435
- module.exports = {
2436
- addInterceptor,
2437
- remove,
2438
- removeAll,
2439
- removeInterceptor,
2440
- isOn,
2441
- activate,
2442
- isActive,
2443
- isDone,
2444
- pendingMocks,
2445
- activeMocks,
2446
- enableNetConnect,
2447
- disableNetConnect,
2448
- restoreOverriddenClientRequest,
2449
- abortPendingRequests: common.removeAllTimers
2450
- };
2451
- }
2452
- });
2453
-
2454
- // ../../node_modules/nock/lib/recorder.js
2455
- var require_recorder = _chunkV46WVGWNjs.__commonJS.call(void 0, {
2456
- "../../node_modules/nock/lib/recorder.js"(exports, module) {
2457
- "use strict";
2458
- var debug = require_browser()("nock.recorder");
2459
- var querystring = _chunkV46WVGWNjs.__require.call(void 0, "querystring");
2460
- var { inspect } = _chunkV46WVGWNjs.__require.call(void 0, "util");
2461
- var common = require_common2();
2462
- var { restoreOverriddenClientRequest } = require_intercept();
2463
- var SEPARATOR = "\n<<<<<<-- cut here -->>>>>>\n";
2464
- var recordingInProgress = false;
2465
- var outputs = [];
2466
- function getScope(options) {
2467
- const { proto, host, port } = common.normalizeRequestOptions(options);
2468
- return common.normalizeOrigin(proto, host, port);
2469
- }
2470
- function getMethod(options) {
2471
- return options.method || "GET";
2472
- }
2473
- function getBodyFromChunks(chunks, headers) {
2474
- if (headers && common.isContentEncoded(headers)) {
2475
- return {
2476
- body: chunks.map((chunk) => chunk.toString("hex"))
2477
- };
2478
- }
2479
- const mergedBuffer = Buffer.concat(chunks);
2480
- const isUtf8Representable = common.isUtf8Representable(mergedBuffer);
2481
- if (isUtf8Representable) {
2482
- const maybeStringifiedJson = mergedBuffer.toString("utf8");
2483
- try {
2484
- return {
2485
- isUtf8Representable,
2486
- body: JSON.parse(maybeStringifiedJson)
2487
- };
2488
- } catch (err) {
2489
- return {
2490
- isUtf8Representable,
2491
- body: maybeStringifiedJson
2492
- };
2493
- }
2494
- } else {
2495
- return {
2496
- isUtf8Representable,
2497
- body: mergedBuffer.toString("hex")
2498
- };
2499
- }
2500
- }
2501
- function generateRequestAndResponseObject({
2502
- req,
2503
- bodyChunks,
2504
- options,
2505
- res,
2506
- dataChunks,
2507
- reqheaders
2508
- }) {
2509
- const { body, isUtf8Representable } = getBodyFromChunks(
2510
- dataChunks,
2511
- res.headers
2512
- );
2513
- options.path = req.path;
2514
- return {
2515
- scope: getScope(options),
2516
- method: getMethod(options),
2517
- path: options.path,
2518
- // Is it deliberate that `getBodyFromChunks()` is called a second time?
2519
- body: getBodyFromChunks(bodyChunks).body,
2520
- status: res.statusCode,
2521
- response: body,
2522
- rawHeaders: res.rawHeaders,
2523
- reqheaders: reqheaders || void 0,
2524
- // When content-encoding is enabled, isUtf8Representable is `undefined`,
2525
- // so we explicitly check for `false`.
2526
- responseIsBinary: isUtf8Representable === false
2527
- };
2528
- }
2529
- function generateRequestAndResponse({
2530
- req,
2531
- bodyChunks,
2532
- options,
2533
- res,
2534
- dataChunks,
2535
- reqheaders
2536
- }) {
2537
- const requestBody = getBodyFromChunks(bodyChunks).body;
2538
- const responseBody = getBodyFromChunks(dataChunks, res.headers).body;
2539
- let { path } = options;
2540
- const queryIndex = req.path.indexOf("?");
2541
- let queryObj = {};
2542
- if (queryIndex !== -1) {
2543
- path = path.substring(0, queryIndex);
2544
- const queryStr = req.path.slice(queryIndex + 1);
2545
- queryObj = querystring.parse(queryStr);
2546
- }
2547
- path = path.replace(/'/g, `\\'`);
2548
- const encodedQueryObj = {};
2549
- for (const key in queryObj) {
2550
- const formattedPair = common.formatQueryValue(
2551
- key,
2552
- queryObj[key],
2553
- common.percentEncode
2554
- );
2555
- encodedQueryObj[formattedPair[0]] = formattedPair[1];
2556
- }
2557
- const lines = [];
2558
- lines.push("");
2559
- const scope = getScope(options);
2560
- lines.push(`nock('${scope}', {"encodedQueryParams":true})`);
2561
- const methodName = getMethod(options).toLowerCase();
2562
- if (requestBody) {
2563
- lines.push(` .${methodName}('${path}', ${JSON.stringify(requestBody)})`);
2564
- } else {
2565
- lines.push(` .${methodName}('${path}')`);
2566
- }
2567
- Object.entries(reqheaders || {}).forEach(([fieldName, fieldValue]) => {
2568
- const safeName = JSON.stringify(fieldName);
2569
- const safeValue = JSON.stringify(fieldValue);
2570
- lines.push(` .matchHeader(${safeName}, ${safeValue})`);
2571
- });
2572
- if (queryIndex !== -1) {
2573
- lines.push(` .query(${JSON.stringify(encodedQueryObj)})`);
2574
- }
2575
- const statusCode = res.statusCode.toString();
2576
- const stringifiedResponseBody = JSON.stringify(responseBody);
2577
- const headers = inspect(res.rawHeaders);
2578
- lines.push(` .reply(${statusCode}, ${stringifiedResponseBody}, ${headers});`);
2579
- return lines.join("\n");
2580
- }
2581
- var currentRecordingId = 0;
2582
- var defaultRecordOptions = {
2583
- dont_print: false,
2584
- enable_reqheaders_recording: false,
2585
- logging: console.log,
2586
- // eslint-disable-line no-console
2587
- output_objects: false,
2588
- use_separator: true
2589
- };
2590
- function record(recOptions) {
2591
- if (recordingInProgress) {
2592
- throw new Error("Nock recording already in progress");
2593
- }
2594
- recordingInProgress = true;
2595
- currentRecordingId = currentRecordingId + 1;
2596
- const thisRecordingId = currentRecordingId;
2597
- if (typeof recOptions === "boolean") {
2598
- recOptions = { dont_print: recOptions };
2599
- }
2600
- recOptions = { ...defaultRecordOptions, ...recOptions };
2601
- debug("start recording", thisRecordingId, recOptions);
2602
- const {
2603
- dont_print: dontPrint,
2604
- enable_reqheaders_recording: enableReqHeadersRecording,
2605
- logging,
2606
- output_objects: outputObjects,
2607
- use_separator: useSeparator
2608
- } = recOptions;
2609
- debug(thisRecordingId, "restoring overridden requests before new overrides");
2610
- common.restoreOverriddenRequests();
2611
- restoreOverriddenClientRequest();
2612
- common.overrideRequests(function(proto, overriddenRequest, rawArgs) {
2613
- const { options, callback } = common.normalizeClientRequestArgs(...rawArgs);
2614
- const bodyChunks = [];
2615
- if (options._recording) {
2616
- return overriddenRequest(options, callback);
2617
- }
2618
- options._recording = true;
2619
- const req = overriddenRequest(options, function(res) {
2620
- debug(thisRecordingId, "intercepting", proto, "request to record");
2621
- res.once("end", function() {
2622
- debug(thisRecordingId, proto, "intercepted request ended");
2623
- let reqheaders;
2624
- if (enableReqHeadersRecording) {
2625
- reqheaders = req.getHeaders();
2626
- common.deleteHeadersField(reqheaders, "user-agent");
2627
- }
2628
- const generateFn = outputObjects ? generateRequestAndResponseObject : generateRequestAndResponse;
2629
- let out = generateFn({
2630
- req,
2631
- bodyChunks,
2632
- options,
2633
- res,
2634
- dataChunks,
2635
- reqheaders
2636
- });
2637
- debug("out:", out);
2638
- if (thisRecordingId !== currentRecordingId) {
2639
- debug("skipping recording of an out-of-order request", out);
2640
- return;
2641
- }
2642
- outputs.push(out);
2643
- if (!dontPrint) {
2644
- if (useSeparator) {
2645
- if (typeof out !== "string") {
2646
- out = JSON.stringify(out, null, 2);
2647
- }
2648
- logging(SEPARATOR + out + SEPARATOR);
2649
- } else {
2650
- logging(out);
2651
- }
2652
- }
2653
- });
2654
- let encoding;
2655
- const { setEncoding } = res;
2656
- res.setEncoding = function(newEncoding) {
2657
- encoding = newEncoding;
2658
- return setEncoding.apply(this, arguments);
2659
- };
2660
- const dataChunks = [];
2661
- const origResPush = res.push;
2662
- res.push = function(data) {
2663
- if (data) {
2664
- if (encoding) {
2665
- data = Buffer.from(data, encoding);
2666
- }
2667
- dataChunks.push(data);
2668
- }
2669
- return origResPush.call(res, data);
2670
- };
2671
- if (callback) {
2672
- callback(res, options, callback);
2673
- }
2674
- debug("finished setting up intercepting");
2675
- if (proto === "https") {
2676
- options.proto = "https";
2677
- }
2678
- });
2679
- const recordChunk = (chunk, encoding) => {
2680
- debug(thisRecordingId, "new", proto, "body chunk");
2681
- if (!Buffer.isBuffer(chunk)) {
2682
- chunk = Buffer.from(chunk, encoding);
2683
- }
2684
- bodyChunks.push(chunk);
2685
- };
2686
- const oldWrite = req.write;
2687
- req.write = function(chunk, encoding) {
2688
- if (typeof chunk !== "undefined") {
2689
- recordChunk(chunk, encoding);
2690
- oldWrite.apply(req, arguments);
2691
- } else {
2692
- throw new Error("Data was undefined.");
2693
- }
2694
- };
2695
- const oldEnd = req.end;
2696
- req.end = function(chunk, encoding, callback2) {
2697
- debug("req.end");
2698
- if (typeof chunk === "function") {
2699
- callback2 = chunk;
2700
- chunk = null;
2701
- } else if (typeof encoding === "function") {
2702
- callback2 = encoding;
2703
- encoding = null;
2704
- }
2705
- if (chunk) {
2706
- recordChunk(chunk, encoding);
2707
- }
2708
- oldEnd.call(req, chunk, encoding, callback2);
2709
- };
2710
- return req;
2711
- });
2712
- }
2713
- function restore() {
2714
- debug(
2715
- currentRecordingId,
2716
- "restoring all the overridden http/https properties"
2717
- );
2718
- common.restoreOverriddenRequests();
2719
- restoreOverriddenClientRequest();
2720
- recordingInProgress = false;
2721
- }
2722
- function clear() {
2723
- outputs = [];
2724
- }
2725
- module.exports = {
2726
- record,
2727
- outputs: () => outputs,
2728
- restore,
2729
- clear
2730
- };
2731
- }
2732
- });
2733
-
2734
- // ../../node_modules/nock/lib/scope.js
2735
- var require_scope = _chunkV46WVGWNjs.__commonJS.call(void 0, {
2736
- "../../node_modules/nock/lib/scope.js"(exports, module) {
2737
- "use strict";
2738
- var { addInterceptor, isOn } = require_intercept();
2739
- var common = require_common2();
2740
- var assert = _chunkV46WVGWNjs.__require.call(void 0, "assert");
2741
- var url = _chunkV46WVGWNjs.__require.call(void 0, "url");
2742
- var debug = require_browser()("nock.scope");
2743
- var { EventEmitter } = _chunkV46WVGWNjs.__require.call(void 0, "events");
2744
- var Interceptor = require_interceptor();
2745
- var { URL, Url: LegacyUrl } = url;
2746
- var fs;
2747
- try {
2748
- fs = _chunkV46WVGWNjs.__require.call(void 0, "fs");
2749
- } catch (err) {
2750
- }
2751
- function normalizeUrl(u) {
2752
- if (!(u instanceof URL)) {
2753
- if (u instanceof LegacyUrl) {
2754
- return normalizeUrl(new URL(url.format(u)));
2755
- }
2756
- return normalizeUrl(new URL(u));
2757
- }
2758
- if (!/https?:/.test(u.protocol)) {
2759
- throw new TypeError(
2760
- `Protocol '${u.protocol}' not recognized. This commonly occurs when a hostname and port are included without a protocol, producing a URL that is valid but confusing, and probably not what you want.`
2761
- );
2762
- }
2763
- return {
2764
- href: u.href,
2765
- origin: u.origin,
2766
- protocol: u.protocol,
2767
- username: u.username,
2768
- password: u.password,
2769
- host: u.host,
2770
- hostname: (
2771
- // strip brackets from IPv6
2772
- typeof u.hostname === "string" && u.hostname.startsWith("[") ? u.hostname.slice(1, -1) : u.hostname
2773
- ),
2774
- port: u.port || (u.protocol === "http:" ? 80 : 443),
2775
- pathname: u.pathname,
2776
- search: u.search,
2777
- searchParams: u.searchParams,
2778
- hash: u.hash
2779
- };
2780
- }
2781
- var Scope = class _Scope extends EventEmitter {
2782
- constructor(basePath, options) {
2783
- super();
2784
- this.keyedInterceptors = {};
2785
- this.interceptors = [];
2786
- this.transformPathFunction = null;
2787
- this.transformRequestBodyFunction = null;
2788
- this.matchHeaders = [];
2789
- this.scopeOptions = options || {};
2790
- this.urlParts = {};
2791
- this._persist = false;
2792
- this.contentLen = false;
2793
- this.date = null;
2794
- this.basePath = basePath;
2795
- this.basePathname = "";
2796
- this.port = null;
2797
- this._defaultReplyHeaders = [];
2798
- let logNamespace = String(basePath);
2799
- if (!(basePath instanceof RegExp)) {
2800
- this.urlParts = normalizeUrl(basePath);
2801
- this.port = this.urlParts.port;
2802
- this.basePathname = this.urlParts.pathname.replace(/\/$/, "");
2803
- this.basePath = `${this.urlParts.protocol}//${this.urlParts.hostname}:${this.port}`;
2804
- logNamespace = this.urlParts.host;
2805
- }
2806
- this.logger = debug.extend(logNamespace);
2807
- }
2808
- add(key, interceptor) {
2809
- if (!(key in this.keyedInterceptors)) {
2810
- this.keyedInterceptors[key] = [];
2811
- }
2812
- this.keyedInterceptors[key].push(interceptor);
2813
- addInterceptor(
2814
- this.basePath,
2815
- interceptor,
2816
- this,
2817
- this.scopeOptions,
2818
- this.urlParts.hostname
2819
- );
2820
- }
2821
- remove(key, interceptor) {
2822
- if (this._persist) {
2823
- return;
2824
- }
2825
- const arr = this.keyedInterceptors[key];
2826
- if (arr) {
2827
- arr.splice(arr.indexOf(interceptor), 1);
2828
- if (arr.length === 0) {
2829
- delete this.keyedInterceptors[key];
2830
- }
2831
- }
2832
- }
2833
- intercept(uri, method, requestBody, interceptorOptions) {
2834
- const ic = new Interceptor(
2835
- this,
2836
- uri,
2837
- method,
2838
- requestBody,
2839
- interceptorOptions
2840
- );
2841
- this.interceptors.push(ic);
2842
- return ic;
2843
- }
2844
- get(uri, requestBody, options) {
2845
- return this.intercept(uri, "GET", requestBody, options);
2846
- }
2847
- post(uri, requestBody, options) {
2848
- return this.intercept(uri, "POST", requestBody, options);
2849
- }
2850
- put(uri, requestBody, options) {
2851
- return this.intercept(uri, "PUT", requestBody, options);
2852
- }
2853
- head(uri, requestBody, options) {
2854
- return this.intercept(uri, "HEAD", requestBody, options);
2855
- }
2856
- patch(uri, requestBody, options) {
2857
- return this.intercept(uri, "PATCH", requestBody, options);
2858
- }
2859
- merge(uri, requestBody, options) {
2860
- return this.intercept(uri, "MERGE", requestBody, options);
2861
- }
2862
- delete(uri, requestBody, options) {
2863
- return this.intercept(uri, "DELETE", requestBody, options);
2864
- }
2865
- options(uri, requestBody, options) {
2866
- return this.intercept(uri, "OPTIONS", requestBody, options);
2867
- }
2868
- // Returns the list of keys for non-optional Interceptors that haven't been completed yet.
2869
- // TODO: This assumes that completed mocks are removed from the keyedInterceptors list
2870
- // (when persistence is off). We should change that (and this) in future.
2871
- pendingMocks() {
2872
- return this.activeMocks().filter(
2873
- (key) => this.keyedInterceptors[key].some(({ interceptionCounter, optional }) => {
2874
- const persistedAndUsed = this._persist && interceptionCounter > 0;
2875
- return !persistedAndUsed && !optional;
2876
- })
2877
- );
2878
- }
2879
- // Returns all keyedInterceptors that are active.
2880
- // This includes incomplete interceptors, persisted but complete interceptors, and
2881
- // optional interceptors, but not non-persisted and completed interceptors.
2882
- activeMocks() {
2883
- return Object.keys(this.keyedInterceptors);
2884
- }
2885
- isDone() {
2886
- if (!isOn()) {
2887
- return true;
2888
- }
2889
- return this.pendingMocks().length === 0;
2890
- }
2891
- done() {
2892
- assert.ok(
2893
- this.isDone(),
2894
- `Mocks not yet satisfied:
2895
- ${this.pendingMocks().join("\n")}`
2896
- );
2897
- }
2898
- buildFilter() {
2899
- const filteringArguments = arguments;
2900
- if (arguments[0] instanceof RegExp) {
2901
- return function(candidate) {
2902
- if (typeof candidate !== "string") {
2903
- throw Error(
2904
- `Nock internal assertion failed: typeof candidate is ${typeof candidate}. If you encounter this error, please report it as a bug.`
2905
- );
2906
- }
2907
- return candidate.replace(filteringArguments[0], filteringArguments[1]);
2908
- };
2909
- } else if (typeof arguments[0] === "function") {
2910
- return arguments[0];
2911
- }
2912
- }
2913
- filteringPath() {
2914
- this.transformPathFunction = this.buildFilter.apply(this, arguments);
2915
- if (!this.transformPathFunction) {
2916
- throw new Error(
2917
- "Invalid arguments: filtering path should be a function or a regular expression"
2918
- );
2919
- }
2920
- return this;
2921
- }
2922
- filteringRequestBody() {
2923
- this.transformRequestBodyFunction = this.buildFilter.apply(this, arguments);
2924
- if (!this.transformRequestBodyFunction) {
2925
- throw new Error(
2926
- "Invalid arguments: filtering request body should be a function or a regular expression"
2927
- );
2928
- }
2929
- return this;
2930
- }
2931
- matchHeader(name, value) {
2932
- this.matchHeaders.push({ name: name.toLowerCase(), value });
2933
- return this;
2934
- }
2935
- defaultReplyHeaders(headers) {
2936
- this._defaultReplyHeaders = common.headersInputToRawArray(headers);
2937
- return this;
2938
- }
2939
- persist(flag = true) {
2940
- if (typeof flag !== "boolean") {
2941
- throw new Error("Invalid arguments: argument should be a boolean");
2942
- }
2943
- this._persist = flag;
2944
- return this;
2945
- }
2946
- /**
2947
- * @private
2948
- * @returns {boolean}
2949
- */
2950
- shouldPersist() {
2951
- return this._persist;
2952
- }
2953
- replyContentLength() {
2954
- this.contentLen = true;
2955
- return this;
2956
- }
2957
- replyDate(d) {
2958
- this.date = d || /* @__PURE__ */ new Date();
2959
- return this;
2960
- }
2961
- clone() {
2962
- return new _Scope(this.basePath, this.scopeOptions);
2963
- }
2964
- };
2965
- function loadDefs(path) {
2966
- if (!fs) {
2967
- throw new Error("No fs");
2968
- }
2969
- const contents = fs.readFileSync(path);
2970
- return JSON.parse(contents);
2971
- }
2972
- function load(path) {
2973
- return define(loadDefs(path));
2974
- }
2975
- function getStatusFromDefinition(nockDef) {
2976
- if (nockDef.reply !== void 0) {
2977
- const parsedReply = parseInt(nockDef.reply, 10);
2978
- if (isNaN(parsedReply)) {
2979
- throw Error("`reply`, when present, must be a numeric string");
2980
- }
2981
- return parsedReply;
2982
- }
2983
- const DEFAULT_STATUS_OK = 200;
2984
- return nockDef.status || DEFAULT_STATUS_OK;
2985
- }
2986
- function getScopeFromDefinition(nockDef) {
2987
- if (nockDef.port !== void 0) {
2988
- const options = url.parse(nockDef.scope);
2989
- if (options.port === null) {
2990
- return `${nockDef.scope}:${nockDef.port}`;
2991
- } else {
2992
- if (parseInt(options.port) !== parseInt(nockDef.port)) {
2993
- throw new Error(
2994
- "Mismatched port numbers in scope and port properties of nock definition."
2995
- );
2996
- }
2997
- }
2998
- }
2999
- return nockDef.scope;
3000
- }
3001
- function tryJsonParse(string) {
3002
- try {
3003
- return JSON.parse(string);
3004
- } catch (err) {
3005
- return string;
3006
- }
3007
- }
3008
- function define(nockDefs) {
3009
- const scopes = [];
3010
- nockDefs.forEach(function(nockDef) {
3011
- const nscope = getScopeFromDefinition(nockDef);
3012
- const npath = nockDef.path;
3013
- if (!nockDef.method) {
3014
- throw Error("Method is required");
3015
- }
3016
- const method = nockDef.method.toLowerCase();
3017
- const status = getStatusFromDefinition(nockDef);
3018
- const rawHeaders = nockDef.rawHeaders || [];
3019
- const reqheaders = nockDef.reqheaders || {};
3020
- const badheaders = nockDef.badheaders || [];
3021
- const options = { ...nockDef.options };
3022
- options.reqheaders = reqheaders;
3023
- options.badheaders = badheaders;
3024
- let response;
3025
- if (!nockDef.response) {
3026
- response = "";
3027
- } else if (nockDef.responseIsBinary) {
3028
- response = Buffer.from(nockDef.response, "hex");
3029
- } else {
3030
- response = typeof nockDef.response === "string" ? tryJsonParse(nockDef.response) : nockDef.response;
3031
- }
3032
- const scope = new Scope(nscope, options);
3033
- Object.entries(reqheaders).forEach(([fieldName, value]) => {
3034
- scope.matchHeader(fieldName, value);
3035
- });
3036
- const acceptableFilters = ["filteringRequestBody", "filteringPath"];
3037
- acceptableFilters.forEach((filter) => {
3038
- if (nockDef[filter]) {
3039
- scope[filter](nockDef[filter]);
3040
- }
3041
- });
3042
- scope.intercept(npath, method, nockDef.body).reply(status, response, rawHeaders);
3043
- scopes.push(scope);
3044
- });
3045
- return scopes;
3046
- }
3047
- module.exports = {
3048
- Scope,
3049
- load,
3050
- loadDefs,
3051
- define
3052
- };
3053
- }
3054
- });
3055
-
3056
- // ../../node_modules/nock/lib/back.js
3057
- var require_back = _chunkV46WVGWNjs.__commonJS.call(void 0, {
3058
- "../../node_modules/nock/lib/back.js"(exports, module) {
3059
- "use strict";
3060
- var assert = _chunkV46WVGWNjs.__require.call(void 0, "assert");
3061
- var recorder = require_recorder();
3062
- var {
3063
- activate,
3064
- disableNetConnect,
3065
- enableNetConnect,
3066
- removeAll: cleanAll
3067
- } = require_intercept();
3068
- var { loadDefs, define } = require_scope();
3069
- var { format } = _chunkV46WVGWNjs.__require.call(void 0, "util");
3070
- var path = _chunkV46WVGWNjs.__require.call(void 0, "path");
3071
- var debug = require_browser()("nock.back");
3072
- var _mode = null;
3073
- var fs;
3074
- try {
3075
- fs = _chunkV46WVGWNjs.__require.call(void 0, "fs");
3076
- } catch (err) {
3077
- }
3078
- function Back(fixtureName, options, nockedFn) {
3079
- if (!Back.fixtures) {
3080
- throw new Error(
3081
- "Back requires nock.back.fixtures to be set\nEx:\n require(nock).back.fixtures = '/path/to/fixtures/'"
3082
- );
3083
- }
3084
- if (typeof fixtureName !== "string") {
3085
- throw new Error("Parameter fixtureName must be a string");
3086
- }
3087
- if (arguments.length === 1) {
3088
- options = {};
3089
- } else if (arguments.length === 2) {
3090
- if (typeof options === "function") {
3091
- nockedFn = options;
3092
- options = {};
3093
- }
3094
- }
3095
- _mode.setup();
3096
- const fixture = path.join(Back.fixtures, fixtureName);
3097
- const context = _mode.start(fixture, options);
3098
- const nockDone = function() {
3099
- _mode.finish(fixture, options, context);
3100
- };
3101
- debug("context:", context);
3102
- if (typeof nockedFn === "function") {
3103
- nockedFn.call(context, nockDone);
3104
- } else {
3105
- return Promise.resolve({ nockDone, context });
3106
- }
3107
- }
3108
- var wild = {
3109
- setup: function() {
3110
- cleanAll();
3111
- recorder.restore();
3112
- activate();
3113
- enableNetConnect();
3114
- },
3115
- start: function() {
3116
- return load();
3117
- },
3118
- finish: function() {
3119
- }
3120
- };
3121
- var dryrun = {
3122
- setup: function() {
3123
- recorder.restore();
3124
- cleanAll();
3125
- activate();
3126
- enableNetConnect();
3127
- },
3128
- start: function(fixture, options) {
3129
- const contexts = load(fixture, options);
3130
- enableNetConnect();
3131
- return contexts;
3132
- },
3133
- finish: function() {
3134
- }
3135
- };
3136
- var record = {
3137
- setup: function() {
3138
- recorder.restore();
3139
- recorder.clear();
3140
- cleanAll();
3141
- activate();
3142
- disableNetConnect();
3143
- },
3144
- start: function(fixture, options) {
3145
- if (!fs) {
3146
- throw new Error("no fs");
3147
- }
3148
- const context = load(fixture, options);
3149
- if (!context.isLoaded) {
3150
- recorder.record({
3151
- dont_print: true,
3152
- output_objects: true,
3153
- ...options.recorder
3154
- });
3155
- context.isRecording = true;
3156
- }
3157
- return context;
3158
- },
3159
- finish: function(fixture, options, context) {
3160
- if (context.isRecording) {
3161
- let outputs = recorder.outputs();
3162
- if (typeof options.afterRecord === "function") {
3163
- outputs = options.afterRecord(outputs);
3164
- }
3165
- outputs = typeof outputs === "string" ? outputs : JSON.stringify(outputs, null, 4);
3166
- debug("recorder outputs:", outputs);
3167
- fs.mkdirSync(path.dirname(fixture), { recursive: true });
3168
- fs.writeFileSync(fixture, outputs);
3169
- }
3170
- }
3171
- };
3172
- var update = {
3173
- setup: function() {
3174
- recorder.restore();
3175
- recorder.clear();
3176
- cleanAll();
3177
- activate();
3178
- disableNetConnect();
3179
- },
3180
- start: function(fixture, options) {
3181
- if (!fs) {
3182
- throw new Error("no fs");
3183
- }
3184
- const context = removeFixture(fixture);
3185
- recorder.record({
3186
- dont_print: true,
3187
- output_objects: true,
3188
- ...options.recorder
3189
- });
3190
- context.isRecording = true;
3191
- return context;
3192
- },
3193
- finish: function(fixture, options, context) {
3194
- let outputs = recorder.outputs();
3195
- if (typeof options.afterRecord === "function") {
3196
- outputs = options.afterRecord(outputs);
3197
- }
3198
- outputs = typeof outputs === "string" ? outputs : JSON.stringify(outputs, null, 4);
3199
- debug("recorder outputs:", outputs);
3200
- fs.mkdirSync(path.dirname(fixture), { recursive: true });
3201
- fs.writeFileSync(fixture, outputs);
3202
- }
3203
- };
3204
- var lockdown = {
3205
- setup: function() {
3206
- recorder.restore();
3207
- recorder.clear();
3208
- cleanAll();
3209
- activate();
3210
- disableNetConnect();
3211
- },
3212
- start: function(fixture, options) {
3213
- return load(fixture, options);
3214
- },
3215
- finish: function() {
3216
- }
3217
- };
3218
- function load(fixture, options) {
3219
- const context = {
3220
- scopes: [],
3221
- assertScopesFinished: function() {
3222
- assertScopes(this.scopes, fixture);
3223
- },
3224
- query: function() {
3225
- const nested = this.scopes.map(
3226
- (scope) => scope.interceptors.map((interceptor) => ({
3227
- method: interceptor.method,
3228
- uri: interceptor.uri,
3229
- basePath: interceptor.basePath,
3230
- path: interceptor.path,
3231
- queries: interceptor.queries,
3232
- counter: interceptor.counter,
3233
- body: interceptor.body,
3234
- statusCode: interceptor.statusCode,
3235
- optional: interceptor.optional
3236
- }))
3237
- );
3238
- return [].concat.apply([], nested);
3239
- }
3240
- };
3241
- if (fixture && fixtureExists(fixture)) {
3242
- let scopes = loadDefs(fixture);
3243
- applyHook(scopes, options.before);
3244
- scopes = define(scopes);
3245
- applyHook(scopes, options.after);
3246
- context.scopes = scopes;
3247
- context.isLoaded = true;
3248
- }
3249
- return context;
3250
- }
3251
- function removeFixture(fixture, options) {
3252
- const context = {
3253
- scopes: [],
3254
- assertScopesFinished: function() {
3255
- }
3256
- };
3257
- if (fixture && fixtureExists(fixture)) {
3258
- fs.rmSync ? fs.rmSync(fixture) : fs.unlinkSync(fixture);
3259
- }
3260
- context.isLoaded = false;
3261
- return context;
3262
- }
3263
- function applyHook(scopes, fn) {
3264
- if (!fn) {
3265
- return;
3266
- }
3267
- if (typeof fn !== "function") {
3268
- throw new Error("processing hooks must be a function");
3269
- }
3270
- scopes.forEach(fn);
3271
- }
3272
- function fixtureExists(fixture) {
3273
- if (!fs) {
3274
- throw new Error("no fs");
3275
- }
3276
- return fs.existsSync(fixture);
3277
- }
3278
- function assertScopes(scopes, fixture) {
3279
- const pending = scopes.filter((scope) => !scope.isDone()).map((scope) => scope.pendingMocks());
3280
- if (pending.length) {
3281
- assert.fail(
3282
- format(
3283
- "%j was not used, consider removing %s to rerecord fixture",
3284
- [].concat(...pending),
3285
- fixture
3286
- )
3287
- );
3288
- }
3289
- }
3290
- var Modes = {
3291
- wild,
3292
- // all requests go out to the internet, dont replay anything, doesnt record anything
3293
- dryrun,
3294
- // use recorded nocks, allow http calls, doesnt record anything, useful for writing new tests (default)
3295
- record,
3296
- // use recorded nocks, record new nocks
3297
- update,
3298
- // allow http calls, record all nocks, don't use recorded nocks
3299
- lockdown
3300
- // use recorded nocks, disables all http calls even when not nocked, doesnt record
3301
- };
3302
- Back.setMode = function(mode) {
3303
- if (!(mode in Modes)) {
3304
- throw new Error(`Unknown mode: ${mode}`);
3305
- }
3306
- Back.currentMode = mode;
3307
- debug("New nock back mode:", Back.currentMode);
3308
- _mode = Modes[mode];
3309
- _mode.setup();
3310
- };
3311
- Back.fixtures = null;
3312
- Back.currentMode = null;
3313
- module.exports = Back;
3314
- }
3315
- });
3316
-
3317
- // ../../node_modules/nock/index.js
3318
- var require_nock = _chunkV46WVGWNjs.__commonJS.call(void 0, {
3319
- "../../node_modules/nock/index.js"(exports, module) {
3320
- "use strict";
3321
- var back = require_back();
3322
- var emitter = require_global_emitter();
3323
- var {
3324
- activate,
3325
- isActive,
3326
- isDone,
3327
- isOn,
3328
- pendingMocks,
3329
- activeMocks,
3330
- removeInterceptor,
3331
- disableNetConnect,
3332
- enableNetConnect,
3333
- removeAll,
3334
- abortPendingRequests
3335
- } = require_intercept();
3336
- var recorder = require_recorder();
3337
- var { Scope, load, loadDefs, define } = require_scope();
3338
- module.exports = (basePath, options) => new Scope(basePath, options);
3339
- Object.assign(module.exports, {
3340
- activate,
3341
- isActive,
3342
- isDone,
3343
- pendingMocks,
3344
- activeMocks,
3345
- removeInterceptor,
3346
- disableNetConnect,
3347
- enableNetConnect,
3348
- cleanAll: removeAll,
3349
- abortPendingRequests,
3350
- load,
3351
- loadDefs,
3352
- define,
3353
- emitter,
3354
- recorder: {
3355
- rec: recorder.record,
3356
- clear: recorder.clear,
3357
- play: recorder.outputs
3358
- },
3359
- restore: recorder.restore,
3360
- back
3361
- });
3362
- if (isOn()) {
3363
- back.setMode(process.env.NOCK_BACK_MODE || "dryrun");
3364
- }
3365
- }
3366
- });
3367
-
3368
- // src/NotificationServicesController/index.ts
3369
- var NotificationServicesController_exports = {};
3370
- _chunkV46WVGWNjs.__export.call(void 0, NotificationServicesController_exports, {
3371
- Constants: () => _chunkCQ6CGSKZjs.constants_exports,
3372
- Controller: () => _chunkYRWUXGL3js.NotificationServicesController,
3373
- Mocks: () => fixtures_exports,
3374
- Processors: () => _chunkUPVIT75Fjs.processors_exports,
3375
- Types: () => _chunk232HZSEVjs.types_exports,
3376
- defaultState: () => _chunkYRWUXGL3js.defaultState
3377
- });
3378
-
3379
- // src/NotificationServicesController/__fixtures__/index.ts
3380
- var fixtures_exports = {};
3381
- _chunkV46WVGWNjs.__export.call(void 0, fixtures_exports, {
3382
- CONTENTFUL_RESPONSE: () => CONTENTFUL_RESPONSE,
3383
- MOCK_RAW_ON_CHAIN_NOTIFICATIONS: () => MOCK_RAW_ON_CHAIN_NOTIFICATIONS,
3384
- MOCK_USER_STORAGE_ACCOUNT: () => MOCK_USER_STORAGE_ACCOUNT,
3385
- MOCK_USER_STORAGE_CHAIN: () => MOCK_USER_STORAGE_CHAIN,
3386
- createMockFeatureAnnouncementAPIResult: () => createMockFeatureAnnouncementAPIResult,
3387
- createMockFeatureAnnouncementRaw: () => createMockFeatureAnnouncementRaw,
3388
- createMockFullUserStorage: () => createMockFullUserStorage,
3389
- createMockNotificationERC1155Received: () => createMockNotificationERC1155Received,
3390
- createMockNotificationERC1155Sent: () => createMockNotificationERC1155Sent,
3391
- createMockNotificationERC20Received: () => createMockNotificationERC20Received,
3392
- createMockNotificationERC20Sent: () => createMockNotificationERC20Sent,
3393
- createMockNotificationERC721Received: () => createMockNotificationERC721Received,
3394
- createMockNotificationERC721Sent: () => createMockNotificationERC721Sent,
3395
- createMockNotificationEthReceived: () => createMockNotificationEthReceived,
3396
- createMockNotificationEthSent: () => createMockNotificationEthSent,
3397
- createMockNotificationLidoReadyToBeWithdrawn: () => createMockNotificationLidoReadyToBeWithdrawn,
3398
- createMockNotificationLidoStakeCompleted: () => createMockNotificationLidoStakeCompleted,
3399
- createMockNotificationLidoWithdrawalCompleted: () => createMockNotificationLidoWithdrawalCompleted,
3400
- createMockNotificationLidoWithdrawalRequested: () => createMockNotificationLidoWithdrawalRequested,
3401
- createMockNotificationMetaMaskSwapsCompleted: () => createMockNotificationMetaMaskSwapsCompleted,
3402
- createMockNotificationRocketPoolStakeCompleted: () => createMockNotificationRocketPoolStakeCompleted,
3403
- createMockNotificationRocketPoolUnStakeCompleted: () => createMockNotificationRocketPoolUnStakeCompleted,
3404
- createMockNotificationTrigger: () => createMockNotificationTrigger,
3405
- createMockRawOnChainNotifications: () => createMockRawOnChainNotifications,
3406
- createMockUserStorage: () => createMockUserStorage,
3407
- createMockUserStorageWithTriggers: () => createMockUserStorageWithTriggers,
3408
- getMockBatchCreateTriggersResponse: () => getMockBatchCreateTriggersResponse,
3409
- getMockBatchDeleteTriggersResponse: () => getMockBatchDeleteTriggersResponse,
3410
- getMockFeatureAnnouncementResponse: () => getMockFeatureAnnouncementResponse,
3411
- getMockListNotificationsResponse: () => getMockListNotificationsResponse,
3412
- getMockMarkNotificationsAsReadResponse: () => getMockMarkNotificationsAsReadResponse,
3413
- mockBatchCreateTriggers: () => mockBatchCreateTriggers,
3414
- mockBatchDeleteTriggers: () => mockBatchDeleteTriggers,
3415
- mockFetchFeatureAnnouncementNotifications: () => mockFetchFeatureAnnouncementNotifications,
3416
- mockListNotifications: () => mockListNotifications,
3417
- mockMarkNotificationsAsRead: () => mockMarkNotificationsAsRead
3418
- });
3419
-
3420
- // src/NotificationServicesController/__fixtures__/mock-feature-announcements.ts
3421
- function createMockFeatureAnnouncementAPIResult() {
3422
- return {
3423
- sys: {
3424
- type: "Array"
3425
- },
3426
- total: 17,
3427
- skip: 0,
3428
- limit: 1,
3429
- items: [
3430
- {
3431
- metadata: {
3432
- tags: []
3433
- },
3434
- sys: {
3435
- space: {
3436
- sys: {
3437
- type: "Link",
3438
- linkType: "Space",
3439
- id: "jdkgyfmyd9sw"
3440
- }
3441
- },
3442
- id: "1ABRmHaNCgmxROKXXLXsMu",
3443
- type: "Entry",
3444
- createdAt: "2024-04-09T13:24:01.872Z",
3445
- updatedAt: "2024-04-09T13:24:01.872Z",
3446
- environment: {
3447
- sys: {
3448
- id: "master",
3449
- type: "Link",
3450
- linkType: "Environment"
3451
- }
3452
- },
3453
- revision: 1,
3454
- contentType: {
3455
- sys: {
3456
- type: "Link",
3457
- linkType: "ContentType",
3458
- id: "productAnnouncement"
3459
- }
3460
- },
3461
- locale: "en-US"
3462
- },
3463
- fields: {
3464
- title: "Don\u2019t miss out on airdrops and new NFT mints!",
3465
- id: "dont-miss-out-on-airdrops-and-new-nft-mints",
3466
- category: "ANNOUNCEMENT",
3467
- shortDescription: "Check your airdrop eligibility and see trending NFT drops. Head over to the Explore tab to get started. ",
3468
- image: {
3469
- sys: {
3470
- type: "Link",
3471
- linkType: "Asset",
3472
- id: "5jqq8sFeLc6XEoeWlpI3aB"
3473
- }
3474
- },
3475
- longDescription: {
3476
- data: {},
3477
- content: [
3478
- {
3479
- data: {},
3480
- content: [
3481
- {
3482
- data: {},
3483
- marks: [],
3484
- value: "You can now verify if any of your connected addresses are eligible for airdrops and other ERC-20 claims in a secure and convenient way. We\u2019ve also added trending NFT mints based on creators you\u2019ve minted from before or other tokens you hold. Head over to the Explore tab to get started. \n",
3485
- nodeType: "text"
3486
- }
3487
- ],
3488
- nodeType: "paragraph"
3489
- }
3490
- ],
3491
- nodeType: "document"
3492
- },
3493
- link: {
3494
- sys: {
3495
- type: "Link",
3496
- linkType: "Entry",
3497
- id: "62xKYM2ydo4F1mS5q97K5q"
3498
- }
3499
- }
3500
- }
3501
- }
3502
- ],
3503
- includes: {
3504
- Entry: [
3505
- {
3506
- metadata: {
3507
- tags: []
3508
- },
3509
- sys: {
3510
- space: {
3511
- sys: {
3512
- type: "Link",
3513
- linkType: "Space",
3514
- id: "jdkgyfmyd9sw"
3515
- }
3516
- },
3517
- id: "62xKYM2ydo4F1mS5q97K5q",
3518
- type: "Entry",
3519
- createdAt: "2024-04-09T13:23:03.636Z",
3520
- updatedAt: "2024-04-09T13:23:03.636Z",
3521
- environment: {
3522
- sys: {
3523
- id: "master",
3524
- type: "Link",
3525
- linkType: "Environment"
3526
- }
3527
- },
3528
- revision: 1,
3529
- contentType: {
3530
- sys: {
3531
- type: "Link",
3532
- linkType: "ContentType",
3533
- id: "link"
3534
- }
3535
- },
3536
- locale: "en-US"
3537
- },
3538
- fields: {
3539
- extensionLinkText: "Try now",
3540
- extensionLinkRoute: "home.html"
3541
- }
3542
- }
3543
- ],
3544
- Asset: [
3545
- {
3546
- metadata: {
3547
- tags: []
3548
- },
3549
- sys: {
3550
- space: {
3551
- sys: {
3552
- type: "Link",
3553
- linkType: "Space",
3554
- id: "jdkgyfmyd9sw"
3555
- }
3556
- },
3557
- id: "5jqq8sFeLc6XEoeWlpI3aB",
3558
- type: "Asset",
3559
- createdAt: "2024-04-09T13:23:13.327Z",
3560
- updatedAt: "2024-04-09T13:23:13.327Z",
3561
- environment: {
3562
- sys: {
3563
- id: "master",
3564
- type: "Link",
3565
- linkType: "Environment"
3566
- }
3567
- },
3568
- revision: 1,
3569
- locale: "en-US"
3570
- },
3571
- fields: {
3572
- title: "PDAPP notification image Airdrops & NFT mints",
3573
- description: "",
3574
- file: {
3575
- url: "//images.ctfassets.net/jdkgyfmyd9sw/5jqq8sFeLc6XEoeWlpI3aB/73ee0f1afa9916c3a7538b0bbee09c26/PDAPP_notification_image_Airdrops___NFT_mints.png",
3576
- details: {
3577
- size: 797731,
3578
- image: {
3579
- width: 2880,
3580
- height: 1921
3581
- }
3582
- },
3583
- fileName: "PDAPP notification image_Airdrops & NFT mints.png",
3584
- contentType: "image/png"
3585
- }
3586
- }
3587
- }
3588
- ]
3589
- }
3590
- };
3591
- }
3592
- function createMockFeatureAnnouncementRaw() {
3593
- return {
3594
- type: "features_announcement" /* FEATURES_ANNOUNCEMENT */,
3595
- createdAt: "2999-04-09T13:24:01.872Z",
3596
- data: {
3597
- id: "dont-miss-out-on-airdrops-and-new-nft-mints",
3598
- category: "ANNOUNCEMENT",
3599
- title: "Don\u2019t miss out on airdrops and new NFT mints!",
3600
- longDescription: `<p>You can now verify if any of your connected addresses are eligible for airdrops and other ERC-20 claims in a secure and convenient way. We\u2019ve also added trending NFT mints based on creators you\u2019ve minted from before or other tokens you hold. Head over to the Explore tab to get started.</p>`,
3601
- shortDescription: "Check your airdrop eligibility and see trending NFT drops. Head over to the Explore tab to get started.",
3602
- image: {
3603
- title: "PDAPP notification image Airdrops & NFT mints",
3604
- description: "",
3605
- url: "//images.ctfassets.net/jdkgyfmyd9sw/5jqq8sFeLc6XEoeWlpI3aB/73ee0f1afa9916c3a7538b0bbee09c26/PDAPP_notification_image_Airdrops___NFT_mints.png"
3606
- },
3607
- extensionLink: {
3608
- extensionLinkText: "Try now",
3609
- extensionLinkRoute: "home.html"
3610
- }
3611
- }
3612
- };
3613
- }
3614
-
3615
- // src/NotificationServicesController/__fixtures__/mock-notification-trigger.ts
3616
- var _uuid = require('uuid');
3617
- function createMockNotificationTrigger(override) {
3618
- return {
3619
- id: _uuid.v4.call(void 0, ),
3620
- address: "0xFAKE_ADDRESS",
3621
- chainId: "1",
3622
- kind: "eth_sent",
3623
- enabled: true,
3624
- ...override
3625
- };
3626
- }
3627
-
3628
- // src/NotificationServicesController/__fixtures__/mock-notification-user-storage.ts
3629
- var MOCK_USER_STORAGE_ACCOUNT = "0x0000000000000000000000000000000000000000";
3630
- var MOCK_USER_STORAGE_CHAIN = "1";
3631
- function createMockUserStorage(override) {
3632
- return {
3633
- [_chunkTLX5QQK5js.USER_STORAGE_VERSION_KEY]: "1",
3634
- [MOCK_USER_STORAGE_ACCOUNT]: {
3635
- [MOCK_USER_STORAGE_CHAIN]: {
3636
- "111-111-111-111": {
3637
- k: "erc20_received" /* ERC20_RECEIVED */,
3638
- e: true
3639
- },
3640
- "222-222-222-222": {
3641
- k: "erc20_sent" /* ERC20_SENT */,
3642
- e: true
3643
- }
3644
- }
3645
- },
3646
- ...override
3647
- };
3648
- }
3649
- function createMockUserStorageWithTriggers(triggers) {
3650
- const userStorage = {
3651
- [_chunkTLX5QQK5js.USER_STORAGE_VERSION_KEY]: "1",
3652
- [MOCK_USER_STORAGE_ACCOUNT]: {
3653
- [MOCK_USER_STORAGE_CHAIN]: {}
3654
- }
3655
- };
3656
- triggers.forEach((t) => {
3657
- let tId;
3658
- let e;
3659
- let k;
3660
- if (typeof t === "string") {
3661
- tId = t;
3662
- e = true;
3663
- k = "erc20_received" /* ERC20_RECEIVED */;
3664
- } else {
3665
- tId = t.id;
3666
- e = t.e;
3667
- k = t.k ?? "erc20_received" /* ERC20_RECEIVED */;
3668
- }
3669
- userStorage[MOCK_USER_STORAGE_ACCOUNT][MOCK_USER_STORAGE_CHAIN][tId] = {
3670
- k,
3671
- e
3672
- };
3673
- });
3674
- return userStorage;
3675
- }
3676
- function createMockFullUserStorage(props = {}) {
3677
- return _chunkPIZCE3JDjs.initializeUserStorage.call(void 0,
3678
- [{ address: props.address ?? MOCK_USER_STORAGE_ACCOUNT }],
3679
- props.triggersEnabled ?? true
3680
- );
3681
- }
3682
-
3683
- // src/NotificationServicesController/__fixtures__/mock-raw-notifications.ts
3684
- function createMockNotificationEthSent() {
3685
- const mockNotification = {
3686
- type: "eth_sent" /* ETH_SENT */,
3687
- id: "3fa85f64-5717-4562-b3fc-2c963f66afa6",
3688
- trigger_id: "3fa85f64-5717-4562-b3fc-2c963f66afa6",
3689
- chain_id: 1,
3690
- block_number: 17485840,
3691
- block_timestamp: "2022-03-01T00:00:00Z",
3692
- tx_hash: "0x881D40237659C251811CEC9c364ef91dC08D300C",
3693
- unread: true,
3694
- created_at: "2022-03-01T00:00:00Z",
3695
- address: "0x881D40237659C251811CEC9c364ef91dC08D300C",
3696
- data: {
3697
- kind: "eth_sent",
3698
- network_fee: {
3699
- gas_price: "207806259583",
3700
- native_token_price_in_usd: "0.83"
3701
- },
3702
- from: "0x881D40237659C251811CEC9c364ef91dC08D300C",
3703
- to: "0x881D40237659C251811CEC9c364ef91dC08D300D",
3704
- amount: {
3705
- usd: "670.64",
3706
- eth: "0.005"
3707
- }
3708
- }
3709
- };
3710
- return mockNotification;
3711
- }
3712
- function createMockNotificationEthReceived() {
3713
- const mockNotification = {
3714
- type: "eth_received" /* ETH_RECEIVED */,
3715
- id: "3fa85f64-5717-4562-b3fc-2c963f66afa6",
3716
- trigger_id: "3fa85f64-5717-4562-b3fc-2c963f66afa6",
3717
- chain_id: 1,
3718
- block_number: 17485840,
3719
- block_timestamp: "2022-03-01T00:00:00Z",
3720
- tx_hash: "0x881D40237659C251811CEC9c364ef91dC08D300C",
3721
- unread: true,
3722
- created_at: "2022-03-01T00:00:00Z",
3723
- address: "0x881D40237659C251811CEC9c364ef91dC08D300C",
3724
- data: {
3725
- kind: "eth_received",
3726
- network_fee: {
3727
- gas_price: "207806259583",
3728
- native_token_price_in_usd: "0.83"
3729
- },
3730
- from: "0x881D40237659C251811CEC9c364ef91dC08D300C",
3731
- to: "0x881D40237659C251811CEC9c364ef91dC08D300D",
3732
- amount: {
3733
- usd: "670.64",
3734
- eth: "808.000000000000000000"
3735
- }
3736
- }
3737
- };
3738
- return mockNotification;
3739
- }
3740
- function createMockNotificationERC20Sent() {
3741
- const mockNotification = {
3742
- type: "erc20_sent" /* ERC20_SENT */,
3743
- id: "3fa85f64-5717-4562-b3fc-2c963f66afa6",
3744
- trigger_id: "3fa85f64-5717-4562-b3fc-2c963f66afa6",
3745
- chain_id: 1,
3746
- block_number: 17485840,
3747
- block_timestamp: "2022-03-01T00:00:00Z",
3748
- tx_hash: "0x881D40237659C251811CEC9c364ef91dC08D300C",
3749
- unread: true,
3750
- created_at: "2022-03-01T00:00:00Z",
3751
- address: "0x881D40237659C251811CEC9c364ef91dC08D300C",
3752
- data: {
3753
- kind: "erc20_sent",
3754
- network_fee: {
3755
- gas_price: "207806259583",
3756
- native_token_price_in_usd: "0.83"
3757
- },
3758
- to: "0xecc19e177d24551aa7ed6bc6fe566eca726cc8a9",
3759
- from: "0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae",
3760
- token: {
3761
- usd: "1.00",
3762
- name: "USDC",
3763
- image: "https://raw.githubusercontent.com/MetaMask/contract-metadata/master/images/usdc.svg",
3764
- amount: "4956250000",
3765
- symbol: "USDC",
3766
- address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
3767
- decimals: "6"
3768
- }
3769
- }
3770
- };
3771
- return mockNotification;
3772
- }
3773
- function createMockNotificationERC20Received() {
3774
- const mockNotification = {
3775
- type: "erc20_received" /* ERC20_RECEIVED */,
3776
- id: "3fa85f64-5717-4562-b3fc-2c963f66afa6",
3777
- trigger_id: "3fa85f64-5717-4562-b3fc-2c963f66afa6",
3778
- chain_id: 1,
3779
- block_number: 17485840,
3780
- block_timestamp: "2022-03-01T00:00:00Z",
3781
- tx_hash: "0x881D40237659C251811CEC9c364ef91dC08D300C",
3782
- unread: true,
3783
- created_at: "2022-03-01T00:00:00Z",
3784
- address: "0x881D40237659C251811CEC9c364ef91dC08D300C",
3785
- data: {
3786
- kind: "erc20_received",
3787
- network_fee: {
3788
- gas_price: "207806259583",
3789
- native_token_price_in_usd: "0.83"
3790
- },
3791
- to: "0xeae7380dd4cef6fbd1144f49e4d1e6964258a4f4",
3792
- from: "0x51c72848c68a965f66fa7a88855f9f7784502a7f",
3793
- token: {
3794
- usd: "0.00",
3795
- name: "SHIBA INU",
3796
- image: "https://raw.githubusercontent.com/MetaMask/contract-metadata/master/images/shib.svg",
3797
- amount: "8382798736999999457296646144",
3798
- symbol: "SHIB",
3799
- address: "0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce",
3800
- decimals: "18"
3801
- }
3802
- }
3803
- };
3804
- return mockNotification;
3805
- }
3806
- function createMockNotificationERC721Sent() {
3807
- const mockNotification = {
3808
- type: "erc721_sent" /* ERC721_SENT */,
3809
- block_number: 18576643,
3810
- block_timestamp: "1700043467",
3811
- chain_id: 1,
3812
- created_at: "2023-11-15T11:08:17.895407Z",
3813
- address: "0x881D40237659C251811CEC9c364ef91dC08D300C",
3814
- data: {
3815
- to: "0xf47f628fe3bd2595e9ab384bfffc3859b448e451",
3816
- nft: {
3817
- name: "Captainz #8680",
3818
- image: "https://i.seadn.io/s/raw/files/ae0fc06714ff7fb40217340d8a242c0e.gif?w=500&auto=format",
3819
- token_id: "8680",
3820
- collection: {
3821
- name: "The Captainz",
3822
- image: "https://i.seadn.io/gcs/files/6df4d75778066bce740050615bc84e21.png?w=500&auto=format",
3823
- symbol: "Captainz",
3824
- address: "0x769272677fab02575e84945f03eca517acc544cc"
3825
- }
3826
- },
3827
- from: "0x24a0bb54b7e7a8e406e9b28058a9fd6c49e6df4f",
3828
- kind: "erc721_sent",
3829
- network_fee: {
3830
- gas_price: "24550653274",
3831
- native_token_price_in_usd: "1986.61"
3832
- }
3833
- },
3834
- id: "a4193058-9814-537e-9df4-79dcac727fb6",
3835
- trigger_id: "028485be-b994-422b-a93b-03fcc01ab715",
3836
- tx_hash: "0x0833c69fb41cf972a0f031fceca242939bc3fcf82b964b74606649abcad371bd",
3837
- unread: true
3838
- };
3839
- return mockNotification;
3840
- }
3841
- function createMockNotificationERC721Received() {
3842
- const mockNotification = {
3843
- type: "erc721_received" /* ERC721_RECEIVED */,
3844
- block_number: 18571446,
3845
- block_timestamp: "1699980623",
3846
- chain_id: 1,
3847
- created_at: "2023-11-14T17:40:52.319281Z",
3848
- address: "0x881D40237659C251811CEC9c364ef91dC08D300C",
3849
- data: {
3850
- to: "0xba7f3daa8adfdad686574406ab9bd5d2f0a49d2e",
3851
- nft: {
3852
- name: "The Plague #2722",
3853
- image: "https://i.seadn.io/s/raw/files/a96f90ec8ebf55a2300c66a0c46d6a16.png?w=500&auto=format",
3854
- token_id: "2722",
3855
- collection: {
3856
- name: "The Plague NFT",
3857
- image: "https://i.seadn.io/gcs/files/4577987a5ca45ca5118b2e31559ee4d1.jpg?w=500&auto=format",
3858
- symbol: "FROG",
3859
- address: "0xc379e535caff250a01caa6c3724ed1359fe5c29b"
3860
- }
3861
- },
3862
- from: "0x24a0bb54b7e7a8e406e9b28058a9fd6c49e6df4f",
3863
- kind: "erc721_received",
3864
- network_fee: {
3865
- gas_price: "53701898538",
3866
- native_token_price_in_usd: "2047.01"
3867
- }
3868
- },
3869
- id: "00a79d24-befa-57ed-a55a-9eb8696e1654",
3870
- trigger_id: "d24ac26a-8579-49ec-9947-d04d63592ebd",
3871
- tx_hash: "0xe554c9e29e6eeca8ba94da4d047334ba08b8eb9ca3b801dd69cec08dfdd4ae43",
3872
- unread: true
3873
- };
3874
- return mockNotification;
3875
- }
3876
- function createMockNotificationERC1155Sent() {
3877
- const mockNotification = {
3878
- type: "erc1155_sent" /* ERC1155_SENT */,
3879
- block_number: 18615206,
3880
- block_timestamp: "1700510003",
3881
- chain_id: 1,
3882
- created_at: "2023-11-20T20:44:10.110706Z",
3883
- address: "0x881D40237659C251811CEC9c364ef91dC08D300C",
3884
- data: {
3885
- to: "0x15bd77ccacf2da39b84f0c31fee2e451225bb190",
3886
- nft: {
3887
- name: "IlluminatiNFT DAO",
3888
- image: "https://i.seadn.io/gcs/files/79a77cb37c7b2f1069f752645d29fea7.jpg?w=500&auto=format",
3889
- token_id: "1",
3890
- collection: {
3891
- name: "IlluminatiNFT DAO",
3892
- image: "https://i.seadn.io/gae/LTKz3om2eCQfn3M6PkqEmY7KhLtdMCOm0QVch2318KJq7-KyToCH7NBTMo4UuJ0AZI-oaBh1HcgrAEIEWYbXY3uMcYpuGXunaXEh?w=500&auto=format",
3893
- symbol: "TRUTH",
3894
- address: "0xe25f0fe686477f9df3c2876c4902d3b85f75f33a"
3895
- }
3896
- },
3897
- from: "0x0000000000000000000000000000000000000000",
3898
- kind: "erc1155_sent",
3899
- network_fee: {
3900
- gas_price: "33571446596",
3901
- native_token_price_in_usd: "2038.88"
3902
- }
3903
- },
3904
- id: "a09ff9d1-623a-52ab-a3d4-c7c8c9a58362",
3905
- trigger_id: "e2130f7d-78b8-4c34-999a-3f3d3bb5b03c",
3906
- tx_hash: "0x03381aba290facbaf71c123e263c8dc3dd550aac00ef589cce395182eaeff76f",
3907
- unread: true
3908
- };
3909
- return mockNotification;
3910
- }
3911
- function createMockNotificationERC1155Received() {
3912
- const mockNotification = {
3913
- type: "erc1155_received" /* ERC1155_RECEIVED */,
3914
- block_number: 18615206,
3915
- block_timestamp: "1700510003",
3916
- chain_id: 1,
3917
- created_at: "2023-11-20T20:44:10.110706Z",
3918
- address: "0x881D40237659C251811CEC9c364ef91dC08D300C",
3919
- data: {
3920
- to: "0x15bd77ccacf2da39b84f0c31fee2e451225bb190",
3921
- nft: {
3922
- name: "IlluminatiNFT DAO",
3923
- image: "https://i.seadn.io/gcs/files/79a77cb37c7b2f1069f752645d29fea7.jpg?w=500&auto=format",
3924
- token_id: "1",
3925
- collection: {
3926
- name: "IlluminatiNFT DAO",
3927
- image: "https://i.seadn.io/gae/LTKz3om2eCQfn3M6PkqEmY7KhLtdMCOm0QVch2318KJq7-KyToCH7NBTMo4UuJ0AZI-oaBh1HcgrAEIEWYbXY3uMcYpuGXunaXEh?w=500&auto=format",
3928
- symbol: "TRUTH",
3929
- address: "0xe25f0fe686477f9df3c2876c4902d3b85f75f33a"
3930
- }
3931
- },
3932
- from: "0x0000000000000000000000000000000000000000",
3933
- kind: "erc1155_received",
3934
- network_fee: {
3935
- gas_price: "33571446596",
3936
- native_token_price_in_usd: "2038.88"
3937
- }
3938
- },
3939
- id: "b6b93c84-e8dc-54ed-9396-7ea50474843a",
3940
- trigger_id: "710c8abb-43a9-42a5-9d86-9dd258726c82",
3941
- tx_hash: "0x03381aba290facbaf71c123e263c8dc3dd550aac00ef589cce395182eaeff76f",
3942
- unread: true
3943
- };
3944
- return mockNotification;
3945
- }
3946
- function createMockNotificationMetaMaskSwapsCompleted() {
3947
- const mockNotification = {
3948
- type: "metamask_swap_completed" /* METAMASK_SWAP_COMPLETED */,
3949
- block_number: 18377666,
3950
- block_timestamp: "1697637275",
3951
- chain_id: 1,
3952
- created_at: "2023-10-18T13:58:49.854596Z",
3953
- address: "0x881D40237659C251811CEC9c364ef91dC08D300C",
3954
- data: {
3955
- kind: "metamask_swap_completed",
3956
- rate: "1558.27",
3957
- token_in: {
3958
- usd: "1576.73",
3959
- image: "https://token.api.cx.metamask.io/assets/nativeCurrencyLogos/ethereum.svg",
3960
- amount: "9000000000000000",
3961
- symbol: "ETH",
3962
- address: "0x0000000000000000000000000000000000000000",
3963
- decimals: "18",
3964
- name: "Ethereum"
3965
- },
3966
- token_out: {
3967
- usd: "1.00",
3968
- image: "https://raw.githubusercontent.com/MetaMask/contract-metadata/master/images/usdt.svg",
3969
- amount: "14024419",
3970
- symbol: "USDT",
3971
- address: "0xdac17f958d2ee523a2206206994597c13d831ec7",
3972
- decimals: "6",
3973
- name: "USDT"
3974
- },
3975
- network_fee: {
3976
- gas_price: "15406129273",
3977
- native_token_price_in_usd: "1576.73"
3978
- }
3979
- },
3980
- id: "7ddfe6a1-ac52-5ffe-aa40-f04242db4b8b",
3981
- trigger_id: "d2eaa2eb-2e6e-4fd5-8763-b70ea571b46c",
3982
- tx_hash: "0xf69074290f3aa11bce567aabc9ca0df7a12559dfae1b80ba1a124e9dfe19ecc5",
3983
- unread: true
3984
- };
3985
- return mockNotification;
3986
- }
3987
- function createMockNotificationRocketPoolStakeCompleted() {
3988
- const mockNotification = {
3989
- type: "rocketpool_stake_completed" /* ROCKETPOOL_STAKE_COMPLETED */,
3990
- block_number: 18585057,
3991
- block_timestamp: "1700145059",
3992
- chain_id: 1,
3993
- created_at: "2023-11-20T12:02:48.796824Z",
3994
- address: "0x881D40237659C251811CEC9c364ef91dC08D300C",
3995
- data: {
3996
- kind: "rocketpool_stake_completed",
3997
- stake_in: {
3998
- usd: "2031.86",
3999
- name: "Ethereum",
4000
- image: "https://token.api.cx.metamask.io/assets/nativeCurrencyLogos/ethereum.svg",
4001
- amount: "190690478063438272",
4002
- symbol: "ETH",
4003
- address: "0x0000000000000000000000000000000000000000",
4004
- decimals: "18"
4005
- },
4006
- stake_out: {
4007
- usd: "2226.49",
4008
- name: "Rocket Pool ETH",
4009
- image: "https://raw.githubusercontent.com/MetaMask/contract-metadata/master/images/rETH.svg",
4010
- amount: "175024360778165879",
4011
- symbol: "RETH",
4012
- address: "0xae78736Cd615f374D3085123A210448E74Fc6393",
4013
- decimals: "18"
4014
- },
4015
- network_fee: {
4016
- gas_price: "36000000000",
4017
- native_token_price_in_usd: "2031.86"
4018
- }
4019
- },
4020
- id: "c2a2f225-b2fb-5d6c-ba56-e27a5c71ffb9",
4021
- trigger_id: "5110ff97-acff-40c0-83b4-11d487b8c7b0",
4022
- tx_hash: "0xcfc0693bf47995907b0f46ef0644cf16dd9a0de797099b2e00fd481e1b2117d3",
4023
- unread: true
4024
- };
4025
- return mockNotification;
4026
- }
4027
- function createMockNotificationRocketPoolUnStakeCompleted() {
4028
- const mockNotification = {
4029
- type: "rocketpool_unstake_completed" /* ROCKETPOOL_UNSTAKE_COMPLETED */,
4030
- block_number: 18384336,
4031
- block_timestamp: "1697718011",
4032
- chain_id: 1,
4033
- created_at: "2023-10-19T13:11:10.623042Z",
4034
- address: "0x881D40237659C251811CEC9c364ef91dC08D300C",
4035
- data: {
4036
- kind: "rocketpool_unstake_completed",
4037
- stake_in: {
4038
- usd: "1686.34",
4039
- image: "https://raw.githubusercontent.com/MetaMask/contract-metadata/master/images/rETH.svg",
4040
- amount: "66608041413696770",
4041
- symbol: "RETH",
4042
- address: "0xae78736Cd615f374D3085123A210448E74Fc6393",
4043
- decimals: "18",
4044
- name: "Rocketpool Eth"
4045
- },
4046
- stake_out: {
4047
- usd: "1553.75",
4048
- image: "https://token.api.cx.metamask.io/assets/nativeCurrencyLogos/ethereum.svg",
4049
- amount: "72387843427700824",
4050
- symbol: "ETH",
4051
- address: "0x0000000000000000000000000000000000000000",
4052
- decimals: "18",
4053
- name: "Ethereum"
4054
- },
4055
- network_fee: {
4056
- gas_price: "5656322987",
4057
- native_token_price_in_usd: "1553.75"
4058
- }
4059
- },
4060
- id: "d8c246e7-a0a4-5f1d-b079-2b1707665fbc",
4061
- trigger_id: "291ec897-f569-4837-b6c0-21001b198dff",
4062
- tx_hash: "0xc7972a7e409abfc62590ec90e633acd70b9b74e76ad02305be8bf133a0e22d5f",
4063
- unread: true
4064
- };
4065
- return mockNotification;
4066
- }
4067
- function createMockNotificationLidoStakeCompleted() {
4068
- const mockNotification = {
4069
- type: "lido_stake_completed" /* LIDO_STAKE_COMPLETED */,
4070
- block_number: 18487118,
4071
- block_timestamp: "1698961091",
4072
- chain_id: 1,
4073
- created_at: "2023-11-02T22:28:49.970865Z",
4074
- address: "0x881D40237659C251811CEC9c364ef91dC08D300C",
4075
- data: {
4076
- kind: "lido_stake_completed",
4077
- stake_in: {
4078
- usd: "1806.33",
4079
- name: "Ethereum",
4080
- image: "https://token.api.cx.metamask.io/assets/nativeCurrencyLogos/ethereum.svg",
4081
- amount: "330303634023928032",
4082
- symbol: "ETH",
4083
- address: "0x0000000000000000000000000000000000000000",
4084
- decimals: "18"
4085
- },
4086
- stake_out: {
4087
- usd: "1801.30",
4088
- name: "Liquid staked Ether 2.0",
4089
- image: "https://raw.githubusercontent.com/MetaMask/contract-metadata/master/images/stETH.svg",
4090
- amount: "330303634023928032",
4091
- symbol: "STETH",
4092
- address: "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84",
4093
- decimals: "18"
4094
- },
4095
- network_fee: {
4096
- gas_price: "26536359866",
4097
- native_token_price_in_usd: "1806.33"
4098
- }
4099
- },
4100
- id: "9d9b1467-b3ee-5492-8ca2-22382657b690",
4101
- trigger_id: "ec10d66a-f78f-461f-83c9-609aada8cc50",
4102
- tx_hash: "0x8cc0fa805f7c3b1743b14f3b91c6b824113b094f26d4ccaf6a71ad8547ce6a0f",
4103
- unread: true
4104
- };
4105
- return mockNotification;
4106
- }
4107
- function createMockNotificationLidoWithdrawalRequested() {
4108
- const mockNotification = {
4109
- type: "lido_withdrawal_requested" /* LIDO_WITHDRAWAL_REQUESTED */,
4110
- block_number: 18377760,
4111
- block_timestamp: "1697638415",
4112
- chain_id: 1,
4113
- created_at: "2023-10-18T15:04:02.482526Z",
4114
- address: "0x881D40237659C251811CEC9c364ef91dC08D300C",
4115
- data: {
4116
- kind: "lido_withdrawal_requested",
4117
- stake_in: {
4118
- usd: "1568.54",
4119
- image: "https://raw.githubusercontent.com/MetaMask/contract-metadata/master/images/stETH.svg",
4120
- amount: "97180668792218669859",
4121
- symbol: "STETH",
4122
- address: "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84",
4123
- decimals: "18",
4124
- name: "Staked Eth"
4125
- },
4126
- stake_out: {
4127
- usd: "1576.73",
4128
- image: "https://token.api.cx.metamask.io/assets/nativeCurrencyLogos/ethereum.svg",
4129
- amount: "97180668792218669859",
4130
- symbol: "ETH",
4131
- address: "0x0000000000000000000000000000000000000000",
4132
- decimals: "18",
4133
- name: "Ethereum"
4134
- },
4135
- network_fee: {
4136
- gas_price: "11658906980",
4137
- native_token_price_in_usd: "1576.73"
4138
- }
4139
- },
4140
- id: "29ddc718-78c6-5f91-936f-2bef13a605f0",
4141
- trigger_id: "ef003925-3379-4ba7-9e2d-8218690cadc8",
4142
- tx_hash: "0x58b5f82e084cb750ea174e02b20fbdfd2ba8d78053deac787f34fc38e5d427aa",
4143
- unread: true
4144
- };
4145
- return mockNotification;
4146
- }
4147
- function createMockNotificationLidoWithdrawalCompleted() {
4148
- const mockNotification = {
4149
- type: "lido_withdrawal_completed" /* LIDO_WITHDRAWAL_COMPLETED */,
4150
- block_number: 18378208,
4151
- block_timestamp: "1697643851",
4152
- chain_id: 1,
4153
- created_at: "2023-10-18T16:35:03.147606Z",
4154
- address: "0x881D40237659C251811CEC9c364ef91dC08D300C",
4155
- data: {
4156
- kind: "lido_withdrawal_completed",
4157
- stake_in: {
4158
- usd: "1570.23",
4159
- image: "https://raw.githubusercontent.com/MetaMask/contract-metadata/master/images/stETH.svg",
4160
- amount: "35081997661451346",
4161
- symbol: "STETH",
4162
- address: "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84",
4163
- decimals: "18",
4164
- name: "Staked Eth"
4165
- },
4166
- stake_out: {
4167
- usd: "1571.74",
4168
- image: "https://token.api.cx.metamask.io/assets/nativeCurrencyLogos/ethereum.svg",
4169
- amount: "35081997661451346",
4170
- symbol: "ETH",
4171
- address: "0x0000000000000000000000000000000000000000",
4172
- decimals: "18",
4173
- name: "Ethereum"
4174
- },
4175
- network_fee: {
4176
- gas_price: "12699495150",
4177
- native_token_price_in_usd: "1571.74"
4178
- }
4179
- },
4180
- id: "f4ef0b7f-5612-537f-9144-0b5c63ae5391",
4181
- trigger_id: "d73df14d-ce73-4f38-bad3-ab028154042c",
4182
- tx_hash: "0xe6d210d2e601ef3dd1075c48e71452cf35f2daae3886911e964e3babad8ac657",
4183
- unread: true
4184
- };
4185
- return mockNotification;
4186
- }
4187
- function createMockNotificationLidoReadyToBeWithdrawn() {
4188
- const mockNotification = {
4189
- type: "lido_stake_ready_to_be_withdrawn" /* LIDO_STAKE_READY_TO_BE_WITHDRAWN */,
4190
- block_number: 18378208,
4191
- block_timestamp: "1697643851",
4192
- chain_id: 1,
4193
- created_at: "2023-10-18T16:35:03.147606Z",
4194
- address: "0x881D40237659C251811CEC9c364ef91dC08D300C",
4195
- data: {
4196
- kind: "lido_stake_ready_to_be_withdrawn",
4197
- request_id: "123456789",
4198
- staked_eth: {
4199
- address: "0x881D40237659C251811CEC9c364ef91dC08D300F",
4200
- symbol: "ETH",
4201
- name: "Ethereum",
4202
- amount: "2.5",
4203
- decimals: "18",
4204
- image: "https://token.api.cx.metamask.io/assets/nativeCurrencyLogos/ethereum.svg",
4205
- usd: "10000.00"
4206
- }
4207
- },
4208
- id: "f4ef0b7f-5612-537f-9144-0b5c63ae5391",
4209
- trigger_id: "d73df14d-ce73-4f38-bad3-ab028154042c",
4210
- tx_hash: "0xe6d210d2e601ef3dd1075c48e71452cf35f2daae3886911e964e3babad8ac657",
4211
- unread: true
4212
- };
4213
- return mockNotification;
4214
- }
4215
- function createMockRawOnChainNotifications() {
4216
- return [1, 2, 3].map((id) => {
4217
- const notification = createMockNotificationEthSent();
4218
- notification.id += `-${id}`;
4219
- return notification;
4220
- });
4221
- }
4222
-
4223
- // src/NotificationServicesController/__fixtures__/mockResponses.ts
4224
- var CONTENTFUL_RESPONSE = createMockFeatureAnnouncementAPIResult();
4225
- var getMockFeatureAnnouncementResponse = () => {
4226
- return {
4227
- url: _chunkZMNXLHACjs.FEATURE_ANNOUNCEMENT_API,
4228
- requestMethod: "GET",
4229
- response: CONTENTFUL_RESPONSE
4230
- };
4231
- };
4232
- var getMockBatchCreateTriggersResponse = () => {
4233
- return {
4234
- url: _chunkVOZ7Y2OOjs.TRIGGER_API_BATCH_ENDPOINT,
4235
- requestMethod: "POST",
4236
- response: null
4237
- };
4238
- };
4239
- var getMockBatchDeleteTriggersResponse = () => {
4240
- return {
4241
- url: _chunkVOZ7Y2OOjs.TRIGGER_API_BATCH_ENDPOINT,
4242
- requestMethod: "DELETE",
4243
- response: null
4244
- };
4245
- };
4246
- var MOCK_RAW_ON_CHAIN_NOTIFICATIONS = createMockRawOnChainNotifications();
4247
- var getMockListNotificationsResponse = () => {
4248
- return {
4249
- url: _chunkVOZ7Y2OOjs.NOTIFICATION_API_LIST_ENDPOINT,
4250
- requestMethod: "POST",
4251
- response: MOCK_RAW_ON_CHAIN_NOTIFICATIONS
4252
- };
4253
- };
4254
- var getMockMarkNotificationsAsReadResponse = () => {
4255
- return {
4256
- url: _chunkVOZ7Y2OOjs.NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT,
4257
- requestMethod: "POST",
4258
- response: null
4259
- };
4260
- };
4261
-
4262
- // src/NotificationServicesController/__fixtures__/mockServices.ts
4263
- var import_nock = _chunkV46WVGWNjs.__toESM.call(void 0, require_nock());
4264
- var mockFetchFeatureAnnouncementNotifications = (mockReply) => {
4265
- const mockResponse = getMockFeatureAnnouncementResponse();
4266
- const reply = mockReply ?? { status: 200, body: mockResponse.response };
4267
- const mockEndpoint = (0, import_nock.default)(mockResponse.url).get("").query(true).reply(reply.status, reply.body);
4268
- return mockEndpoint;
4269
- };
4270
- var mockBatchCreateTriggers = (mockReply) => {
4271
- const mockResponse = getMockBatchCreateTriggersResponse();
4272
- const reply = mockReply ?? { status: 204 };
4273
- const mockEndpoint = (0, import_nock.default)(mockResponse.url).post("").reply(reply.status, reply.body);
4274
- return mockEndpoint;
4275
- };
4276
- var mockBatchDeleteTriggers = (mockReply) => {
4277
- const mockResponse = getMockBatchDeleteTriggersResponse();
4278
- const reply = mockReply ?? { status: 204 };
4279
- const mockEndpoint = (0, import_nock.default)(mockResponse.url).delete("").reply(reply.status, reply.body);
4280
- return mockEndpoint;
4281
- };
4282
- var mockListNotifications = (mockReply) => {
4283
- const mockResponse = getMockListNotificationsResponse();
4284
- const reply = mockReply ?? { status: 200, body: mockResponse.response };
4285
- const mockEndpoint = (0, import_nock.default)(mockResponse.url).post("").query(true).reply(reply.status, reply.body);
4286
- return mockEndpoint;
4287
- };
4288
- var mockMarkNotificationsAsRead = (mockReply) => {
4289
- const mockResponse = getMockMarkNotificationsAsReadResponse();
4290
- const reply = mockReply ?? { status: 200 };
4291
- const mockEndpoint = (0, import_nock.default)(mockResponse.url).post("").reply(reply.status, reply.body);
4292
- return mockEndpoint;
4293
- };
4294
-
4295
-
4296
-
4297
-
4298
-
4299
- exports.require_nock = require_nock; exports.fixtures_exports = fixtures_exports; exports.NotificationServicesController_exports = NotificationServicesController_exports;
4300
- //# sourceMappingURL=chunk-4KZO4UUC.js.map