@oneuptime/react-native-replay 14.2.0 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -60,7 +60,7 @@ var SESSION_REPLAY_MAX_OFFLINE_DELAY_MS = 3 * 24 * 60 * 60 * 1e3;
60
60
  var MOBILE_CAPTURE_INTERVAL_MS = 500;
61
61
  var MOBILE_RECORDER_KIND = "rn-view-tree";
62
62
  var SYNTHETIC_RRWEB_VERSION = "synthetic-1";
63
- var RECORDER_VERSION = true ? "14.2.0" : "0.0.0-dev";
63
+ var RECORDER_VERSION = true ? "15.0.0" : "0.0.0-dev";
64
64
  var SESSION_REPLAY_MOBILE_RECORDER_CAPABILITIES = [
65
65
  "mobile-view-tree",
66
66
  "mobile-touch-events",
@@ -143,7 +143,8 @@ var UUID_SEGMENT = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12
143
143
  var OBJECT_ID_SEGMENT = /^[0-9a-f]{24}$/iu;
144
144
  var EMAIL_SEGMENT = /^[^@\s/]{1,64}@[^@\s/]{1,253}\.[^@\s/]{1,63}$/u;
145
145
  var LONG_DIGIT_SEGMENT = /^\d{9,}$/u;
146
- var OPAQUE_TOKEN_SEGMENT = /^[A-Za-z0-9_-]{32,}$/u;
146
+ var OPAQUE_TOKEN_SEGMENT = /^[A-Za-z0-9_+/-]{32,}={0,2}$/u;
147
+ var JWT_SEGMENT = /^eyJ[A-Za-z0-9_-]{8,}(?:\.[A-Za-z0-9_-]*){1,4}$/u;
147
148
  var ABSOLUTE_URL_PATTERN = /^[A-Za-z][A-Za-z0-9+.-]*:\/\//;
148
149
  var CONTROL_CHARACTER_PATTERN = /[\u0000-\u001F\u007F]/gu;
149
150
  function truncate(value, length) {
@@ -238,12 +239,16 @@ function sanitizeRoute(route) {
238
239
  }
239
240
  path = path.split("/").map((segment) => {
240
241
  let decoded = segment;
241
- try {
242
- decoded = decodeURIComponent(segment);
243
- } catch {
244
- decoded = segment;
242
+ for (let pass = 0; pass < 2; pass++) {
243
+ try {
244
+ decoded = decodeURIComponent(decoded);
245
+ } catch {
246
+ }
247
+ if (UUID_SEGMENT.test(decoded) || OBJECT_ID_SEGMENT.test(decoded) || EMAIL_SEGMENT.test(decoded) || LONG_DIGIT_SEGMENT.test(decoded) || OPAQUE_TOKEN_SEGMENT.test(decoded) || JWT_SEGMENT.test(decoded)) {
248
+ return "[redacted]";
249
+ }
245
250
  }
246
- return UUID_SEGMENT.test(decoded) || OBJECT_ID_SEGMENT.test(decoded) || EMAIL_SEGMENT.test(decoded) || LONG_DIGIT_SEGMENT.test(decoded) || OPAQUE_TOKEN_SEGMENT.test(decoded) ? "[redacted]" : segment;
251
+ return segment;
247
252
  }).join("/");
248
253
  return truncate(path.replace(CONTROL_CHARACTER_PATTERN, ""), 2048);
249
254
  }
@@ -535,12 +540,50 @@ function readCustomSignals(frustrationSignals) {
535
540
  }
536
541
  return signals;
537
542
  }
543
+ var ESCAPED_BYTE = /^%[0-9A-Fa-f]{2}$/;
544
+ var BEYOND_ASCII = /^[\u0080-\uffff]+$/;
545
+ var SPELLED_CHARACTER = /[%\u0080-\uffff]/;
546
+ function composed(text) {
547
+ return typeof text.normalize === "function" ? text.normalize("NFC") : text;
548
+ }
549
+ function readPathAsWritten(path) {
550
+ if (!SPELLED_CHARACTER.test(path)) {
551
+ return path;
552
+ }
553
+ let spelled = "";
554
+ let words = "";
555
+ let index = 0;
556
+ while (index < path.length) {
557
+ const escape = path.slice(index, index + 3);
558
+ if (!ESCAPED_BYTE.test(escape)) {
559
+ words += path.charAt(index);
560
+ index += 1;
561
+ continue;
562
+ }
563
+ const lead = parseInt(escape.slice(1), 16);
564
+ const length = lead < 194 ? 0 : lead < 224 ? 6 : lead < 240 ? 9 : 12;
565
+ let character = "";
566
+ try {
567
+ character = length ? decodeURIComponent(path.slice(index, index + length)) : "";
568
+ } catch {
569
+ }
570
+ if (BEYOND_ASCII.test(composed(character))) {
571
+ words += character;
572
+ index += length;
573
+ continue;
574
+ }
575
+ spelled += composed(words) + escape.toUpperCase();
576
+ words = "";
577
+ index += 3;
578
+ }
579
+ return spelled + composed(words);
580
+ }
538
581
  function canonicalPath(path) {
539
582
  let end = path.length;
540
583
  while (end > 1 && path.charAt(end - 1) === "/") {
541
584
  end--;
542
585
  }
543
- return path.slice(0, end).toLowerCase();
586
+ return readPathAsWritten(path.slice(0, end)).toLowerCase();
544
587
  }
545
588
  function matchesPagePattern(pattern, path) {
546
589
  const target = canonicalPath(path);
@@ -2793,6 +2836,200 @@ var ReplaySessionStore = class {
2793
2836
  }
2794
2837
  };
2795
2838
 
2839
+ // src/RetryAfter.ts
2840
+ var RETRY_AFTER_HEADER = "retry-after";
2841
+ var DEFAULT_RETRY_AFTER_MIN_MS = 1e3;
2842
+ var DEFAULT_RETRY_AFTER_MAX_MS = 60 * 60 * 1e3;
2843
+ var DELAY_SECONDS = /^\d+$/;
2844
+ var MONTHS = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ");
2845
+ var DAY_NAME = "(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)";
2846
+ var DAY_NAME_LONG = "(?:Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)day";
2847
+ var MONTH = `(${MONTHS.join("|")})`;
2848
+ var TIME_OF_DAY = "(\\d\\d):(\\d\\d):(\\d\\d)";
2849
+ var IMF_FIXDATE = new RegExp(
2850
+ `^${DAY_NAME}, (\\d\\d) ${MONTH} (\\d{4}) ${TIME_OF_DAY} GMT$`
2851
+ );
2852
+ var RFC_850_DATE = new RegExp(
2853
+ `^${DAY_NAME_LONG}, (\\d\\d)-${MONTH}-(\\d\\d) ${TIME_OF_DAY} GMT$`
2854
+ );
2855
+ var ASCTIME_DATE = new RegExp(
2856
+ `^${DAY_NAME} ${MONTH} (\\d\\d| \\d) ${TIME_OF_DAY} (\\d{4})$`
2857
+ );
2858
+ var TWO_DIGIT_YEAR_LOOKAHEAD_YEARS = 50;
2859
+ function toUtcMs(year, month, day, hour, minute, second) {
2860
+ const monthIndex = MONTHS.indexOf(month || "");
2861
+ const dayOfMonth = Number(day);
2862
+ const date = /* @__PURE__ */ new Date(0);
2863
+ date.setUTCFullYear(year, monthIndex, dayOfMonth);
2864
+ if (monthIndex < 0 || date.getUTCMonth() !== monthIndex || date.getUTCDate() !== dayOfMonth || !(Number(hour) <= 23 && Number(minute) <= 59 && Number(second) <= 60)) {
2865
+ return void 0;
2866
+ }
2867
+ date.setUTCHours(Number(hour), Number(minute), Number(second), 0);
2868
+ return date.getTime();
2869
+ }
2870
+ function readRfc850Date(match, nowMs) {
2871
+ const thisYear = new Date(nowMs).getUTCFullYear();
2872
+ const lookaheadEnd = new Date(nowMs);
2873
+ lookaheadEnd.setUTCFullYear(thisYear + TWO_DIGIT_YEAR_LOOKAHEAD_YEARS);
2874
+ let year = thisYear - thisYear % 100 + Number(match[3]);
2875
+ let atMs = toUtcMs(
2876
+ year,
2877
+ match[2],
2878
+ match[1],
2879
+ match[4],
2880
+ match[5],
2881
+ match[6]
2882
+ );
2883
+ if (atMs !== void 0 && atMs > lookaheadEnd.getTime()) {
2884
+ year -= 100;
2885
+ atMs = toUtcMs(year, match[2], match[1], match[4], match[5], match[6]);
2886
+ }
2887
+ return atMs;
2888
+ }
2889
+ function isSpace(code) {
2890
+ return code === 32 || code === 9;
2891
+ }
2892
+ function toText(value) {
2893
+ if (Array.isArray(value)) {
2894
+ const copies = value.map(
2895
+ (copy) => {
2896
+ return Array.isArray(copy) ? void 0 : toText(copy);
2897
+ }
2898
+ );
2899
+ return copies.every((copy) => {
2900
+ return copy === copies[0];
2901
+ }) ? copies[0] : void 0;
2902
+ }
2903
+ if (typeof value !== "string" && typeof value !== "number") {
2904
+ return void 0;
2905
+ }
2906
+ const text = String(value);
2907
+ let start = 0;
2908
+ let end = text.length;
2909
+ while (start < end && isSpace(text.charCodeAt(start))) {
2910
+ start++;
2911
+ }
2912
+ while (end > start && isSpace(text.charCodeAt(end - 1))) {
2913
+ end--;
2914
+ }
2915
+ return start < end ? text.slice(start, end) : void 0;
2916
+ }
2917
+ function readNow(nowMs) {
2918
+ return typeof nowMs === "number" && Number.isFinite(nowMs) ? nowMs : Date.now();
2919
+ }
2920
+ function readBound(bound, fallback) {
2921
+ return typeof bound === "number" && Number.isFinite(bound) && bound >= 0 ? bound : fallback;
2922
+ }
2923
+ var RetryAfter = class _RetryAfter {
2924
+ /*
2925
+ * The wait a Retry-After value asks for, in milliseconds, held between
2926
+ * minMs and maxMs; undefined when the value is not a Retry-After (absent,
2927
+ * empty, or neither delay-seconds nor an HTTP-date), so the caller waits
2928
+ * its own backoff. The value is a header's: a string, a number, or the
2929
+ * copies of a header sent more than once - which count only when they
2930
+ * all say the same.
2931
+ */
2932
+ static parseMs(value, options) {
2933
+ const text = toText(value);
2934
+ const asked = options || {};
2935
+ let waitMs;
2936
+ if (text === void 0) {
2937
+ return void 0;
2938
+ }
2939
+ if (DELAY_SECONDS.test(text)) {
2940
+ waitMs = Number(text) * 1e3;
2941
+ } else if (asked.acceptHttpDate !== false) {
2942
+ const nowMs = readNow(asked.nowMs);
2943
+ const retryAtMs = _RetryAfter.parseHttpDate(
2944
+ text,
2945
+ nowMs
2946
+ );
2947
+ waitMs = retryAtMs === void 0 ? void 0 : retryAtMs - nowMs;
2948
+ }
2949
+ return waitMs === void 0 ? void 0 : Math.min(
2950
+ Math.max(waitMs, readBound(asked.minMs, DEFAULT_RETRY_AFTER_MIN_MS)),
2951
+ readBound(asked.maxMs, DEFAULT_RETRY_AFTER_MAX_MS)
2952
+ );
2953
+ }
2954
+ /*
2955
+ * The same wait in whole seconds, rounded up - never sooner than asked -
2956
+ * for a caller that counts in seconds.
2957
+ */
2958
+ static parseSeconds(value, options) {
2959
+ const waitMs = _RetryAfter.parseMs(value, options);
2960
+ return waitMs === void 0 ? void 0 : Math.ceil(waitMs / 1e3);
2961
+ }
2962
+ /*
2963
+ * The Retry-After header of a response's headers, whatever its case: an
2964
+ * object with a get() (fetch's Headers, axios's AxiosHeaders), or a plain
2965
+ * object of names to values (Node's, a test's). Undefined when there is
2966
+ * none; a get() that throws reads as none.
2967
+ */
2968
+ static readHeader(headers) {
2969
+ if (!headers || typeof headers !== "object") {
2970
+ return void 0;
2971
+ }
2972
+ const get = headers.get;
2973
+ if (typeof get === "function") {
2974
+ try {
2975
+ const value = get.call(
2976
+ headers,
2977
+ RETRY_AFTER_HEADER
2978
+ );
2979
+ if (value !== void 0 && value !== null) {
2980
+ return value;
2981
+ }
2982
+ } catch {
2983
+ }
2984
+ }
2985
+ for (const name of Object.keys(headers)) {
2986
+ if (name.toLowerCase() === RETRY_AFTER_HEADER) {
2987
+ return headers[name];
2988
+ }
2989
+ }
2990
+ return void 0;
2991
+ }
2992
+ // parseMs of a response's Retry-After header.
2993
+ static msFromHeaders(headers, options) {
2994
+ return _RetryAfter.parseMs(_RetryAfter.readHeader(headers), options);
2995
+ }
2996
+ // parseSeconds of a response's Retry-After header.
2997
+ static secondsFromHeaders(headers, options) {
2998
+ return _RetryAfter.parseSeconds(_RetryAfter.readHeader(headers), options);
2999
+ }
3000
+ /*
3001
+ * An HTTP-date in any of its three shapes, exactly as written, as
3002
+ * milliseconds since the epoch; undefined for anything else. nowMs is what
3003
+ * an RFC 850 date's two-digit year is read against.
3004
+ */
3005
+ static parseHttpDate(value, nowMs) {
3006
+ let match = IMF_FIXDATE.exec(value);
3007
+ if (match) {
3008
+ return toUtcMs(
3009
+ Number(match[3]),
3010
+ match[2],
3011
+ match[1],
3012
+ match[4],
3013
+ match[5],
3014
+ match[6]
3015
+ );
3016
+ }
3017
+ match = RFC_850_DATE.exec(value);
3018
+ if (match) {
3019
+ return readRfc850Date(match, readNow(nowMs));
3020
+ }
3021
+ match = ASCTIME_DATE.exec(value);
3022
+ return match ? toUtcMs(
3023
+ Number(match[6]),
3024
+ match[1],
3025
+ match[2],
3026
+ match[3],
3027
+ match[4],
3028
+ match[5]
3029
+ ) : void 0;
3030
+ }
3031
+ };
3032
+
2796
3033
  // src/Transport.ts
2797
3034
  var MAX_ATTEMPTS_PER_FRAME = 3;
2798
3035
  var DEFAULT_RETRY_MS = 15e3;
@@ -2855,11 +3092,7 @@ async function readDirective(response) {
2855
3092
  }
2856
3093
  }
2857
3094
  function parseRetryAfter(value) {
2858
- if (!value) {
2859
- return null;
2860
- }
2861
- const seconds = Number(value);
2862
- return Number.isFinite(seconds) && seconds >= 0 ? Math.min(300, seconds) : null;
3095
+ return RetryAfter.parseSeconds(value, { maxMs: 300 * 1e3 }) ?? null;
2863
3096
  }
2864
3097
  var ReplayTransport = class {
2865
3098
  constructor(options) {