@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.cjs CHANGED
@@ -99,7 +99,7 @@ var SESSION_REPLAY_MAX_OFFLINE_DELAY_MS = 3 * 24 * 60 * 60 * 1e3;
99
99
  var MOBILE_CAPTURE_INTERVAL_MS = 500;
100
100
  var MOBILE_RECORDER_KIND = "rn-view-tree";
101
101
  var SYNTHETIC_RRWEB_VERSION = "synthetic-1";
102
- var RECORDER_VERSION = true ? "14.2.0" : "0.0.0-dev";
102
+ var RECORDER_VERSION = true ? "15.0.0" : "0.0.0-dev";
103
103
  var SESSION_REPLAY_MOBILE_RECORDER_CAPABILITIES = [
104
104
  "mobile-view-tree",
105
105
  "mobile-touch-events",
@@ -182,7 +182,8 @@ var UUID_SEGMENT = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12
182
182
  var OBJECT_ID_SEGMENT = /^[0-9a-f]{24}$/iu;
183
183
  var EMAIL_SEGMENT = /^[^@\s/]{1,64}@[^@\s/]{1,253}\.[^@\s/]{1,63}$/u;
184
184
  var LONG_DIGIT_SEGMENT = /^\d{9,}$/u;
185
- var OPAQUE_TOKEN_SEGMENT = /^[A-Za-z0-9_-]{32,}$/u;
185
+ var OPAQUE_TOKEN_SEGMENT = /^[A-Za-z0-9_+/-]{32,}={0,2}$/u;
186
+ var JWT_SEGMENT = /^eyJ[A-Za-z0-9_-]{8,}(?:\.[A-Za-z0-9_-]*){1,4}$/u;
186
187
  var ABSOLUTE_URL_PATTERN = /^[A-Za-z][A-Za-z0-9+.-]*:\/\//;
187
188
  var CONTROL_CHARACTER_PATTERN = /[\u0000-\u001F\u007F]/gu;
188
189
  function truncate(value, length) {
@@ -277,12 +278,16 @@ function sanitizeRoute(route) {
277
278
  }
278
279
  path = path.split("/").map((segment) => {
279
280
  let decoded = segment;
280
- try {
281
- decoded = decodeURIComponent(segment);
282
- } catch {
283
- decoded = segment;
281
+ for (let pass = 0; pass < 2; pass++) {
282
+ try {
283
+ decoded = decodeURIComponent(decoded);
284
+ } catch {
285
+ }
286
+ 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)) {
287
+ return "[redacted]";
288
+ }
284
289
  }
285
- 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;
290
+ return segment;
286
291
  }).join("/");
287
292
  return truncate(path.replace(CONTROL_CHARACTER_PATTERN, ""), 2048);
288
293
  }
@@ -574,12 +579,50 @@ function readCustomSignals(frustrationSignals) {
574
579
  }
575
580
  return signals;
576
581
  }
582
+ var ESCAPED_BYTE = /^%[0-9A-Fa-f]{2}$/;
583
+ var BEYOND_ASCII = /^[\u0080-\uffff]+$/;
584
+ var SPELLED_CHARACTER = /[%\u0080-\uffff]/;
585
+ function composed(text) {
586
+ return typeof text.normalize === "function" ? text.normalize("NFC") : text;
587
+ }
588
+ function readPathAsWritten(path) {
589
+ if (!SPELLED_CHARACTER.test(path)) {
590
+ return path;
591
+ }
592
+ let spelled = "";
593
+ let words = "";
594
+ let index = 0;
595
+ while (index < path.length) {
596
+ const escape = path.slice(index, index + 3);
597
+ if (!ESCAPED_BYTE.test(escape)) {
598
+ words += path.charAt(index);
599
+ index += 1;
600
+ continue;
601
+ }
602
+ const lead = parseInt(escape.slice(1), 16);
603
+ const length = lead < 194 ? 0 : lead < 224 ? 6 : lead < 240 ? 9 : 12;
604
+ let character = "";
605
+ try {
606
+ character = length ? decodeURIComponent(path.slice(index, index + length)) : "";
607
+ } catch {
608
+ }
609
+ if (BEYOND_ASCII.test(composed(character))) {
610
+ words += character;
611
+ index += length;
612
+ continue;
613
+ }
614
+ spelled += composed(words) + escape.toUpperCase();
615
+ words = "";
616
+ index += 3;
617
+ }
618
+ return spelled + composed(words);
619
+ }
577
620
  function canonicalPath(path) {
578
621
  let end = path.length;
579
622
  while (end > 1 && path.charAt(end - 1) === "/") {
580
623
  end--;
581
624
  }
582
- return path.slice(0, end).toLowerCase();
625
+ return readPathAsWritten(path.slice(0, end)).toLowerCase();
583
626
  }
584
627
  function matchesPagePattern(pattern, path) {
585
628
  const target = canonicalPath(path);
@@ -2832,6 +2875,200 @@ var ReplaySessionStore = class {
2832
2875
  }
2833
2876
  };
2834
2877
 
2878
+ // src/RetryAfter.ts
2879
+ var RETRY_AFTER_HEADER = "retry-after";
2880
+ var DEFAULT_RETRY_AFTER_MIN_MS = 1e3;
2881
+ var DEFAULT_RETRY_AFTER_MAX_MS = 60 * 60 * 1e3;
2882
+ var DELAY_SECONDS = /^\d+$/;
2883
+ var MONTHS = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ");
2884
+ var DAY_NAME = "(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)";
2885
+ var DAY_NAME_LONG = "(?:Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)day";
2886
+ var MONTH = `(${MONTHS.join("|")})`;
2887
+ var TIME_OF_DAY = "(\\d\\d):(\\d\\d):(\\d\\d)";
2888
+ var IMF_FIXDATE = new RegExp(
2889
+ `^${DAY_NAME}, (\\d\\d) ${MONTH} (\\d{4}) ${TIME_OF_DAY} GMT$`
2890
+ );
2891
+ var RFC_850_DATE = new RegExp(
2892
+ `^${DAY_NAME_LONG}, (\\d\\d)-${MONTH}-(\\d\\d) ${TIME_OF_DAY} GMT$`
2893
+ );
2894
+ var ASCTIME_DATE = new RegExp(
2895
+ `^${DAY_NAME} ${MONTH} (\\d\\d| \\d) ${TIME_OF_DAY} (\\d{4})$`
2896
+ );
2897
+ var TWO_DIGIT_YEAR_LOOKAHEAD_YEARS = 50;
2898
+ function toUtcMs(year, month, day, hour, minute, second) {
2899
+ const monthIndex = MONTHS.indexOf(month || "");
2900
+ const dayOfMonth = Number(day);
2901
+ const date = /* @__PURE__ */ new Date(0);
2902
+ date.setUTCFullYear(year, monthIndex, dayOfMonth);
2903
+ if (monthIndex < 0 || date.getUTCMonth() !== monthIndex || date.getUTCDate() !== dayOfMonth || !(Number(hour) <= 23 && Number(minute) <= 59 && Number(second) <= 60)) {
2904
+ return void 0;
2905
+ }
2906
+ date.setUTCHours(Number(hour), Number(minute), Number(second), 0);
2907
+ return date.getTime();
2908
+ }
2909
+ function readRfc850Date(match, nowMs) {
2910
+ const thisYear = new Date(nowMs).getUTCFullYear();
2911
+ const lookaheadEnd = new Date(nowMs);
2912
+ lookaheadEnd.setUTCFullYear(thisYear + TWO_DIGIT_YEAR_LOOKAHEAD_YEARS);
2913
+ let year = thisYear - thisYear % 100 + Number(match[3]);
2914
+ let atMs = toUtcMs(
2915
+ year,
2916
+ match[2],
2917
+ match[1],
2918
+ match[4],
2919
+ match[5],
2920
+ match[6]
2921
+ );
2922
+ if (atMs !== void 0 && atMs > lookaheadEnd.getTime()) {
2923
+ year -= 100;
2924
+ atMs = toUtcMs(year, match[2], match[1], match[4], match[5], match[6]);
2925
+ }
2926
+ return atMs;
2927
+ }
2928
+ function isSpace(code) {
2929
+ return code === 32 || code === 9;
2930
+ }
2931
+ function toText(value) {
2932
+ if (Array.isArray(value)) {
2933
+ const copies = value.map(
2934
+ (copy) => {
2935
+ return Array.isArray(copy) ? void 0 : toText(copy);
2936
+ }
2937
+ );
2938
+ return copies.every((copy) => {
2939
+ return copy === copies[0];
2940
+ }) ? copies[0] : void 0;
2941
+ }
2942
+ if (typeof value !== "string" && typeof value !== "number") {
2943
+ return void 0;
2944
+ }
2945
+ const text = String(value);
2946
+ let start = 0;
2947
+ let end = text.length;
2948
+ while (start < end && isSpace(text.charCodeAt(start))) {
2949
+ start++;
2950
+ }
2951
+ while (end > start && isSpace(text.charCodeAt(end - 1))) {
2952
+ end--;
2953
+ }
2954
+ return start < end ? text.slice(start, end) : void 0;
2955
+ }
2956
+ function readNow(nowMs) {
2957
+ return typeof nowMs === "number" && Number.isFinite(nowMs) ? nowMs : Date.now();
2958
+ }
2959
+ function readBound(bound, fallback) {
2960
+ return typeof bound === "number" && Number.isFinite(bound) && bound >= 0 ? bound : fallback;
2961
+ }
2962
+ var RetryAfter = class _RetryAfter {
2963
+ /*
2964
+ * The wait a Retry-After value asks for, in milliseconds, held between
2965
+ * minMs and maxMs; undefined when the value is not a Retry-After (absent,
2966
+ * empty, or neither delay-seconds nor an HTTP-date), so the caller waits
2967
+ * its own backoff. The value is a header's: a string, a number, or the
2968
+ * copies of a header sent more than once - which count only when they
2969
+ * all say the same.
2970
+ */
2971
+ static parseMs(value, options) {
2972
+ const text = toText(value);
2973
+ const asked = options || {};
2974
+ let waitMs;
2975
+ if (text === void 0) {
2976
+ return void 0;
2977
+ }
2978
+ if (DELAY_SECONDS.test(text)) {
2979
+ waitMs = Number(text) * 1e3;
2980
+ } else if (asked.acceptHttpDate !== false) {
2981
+ const nowMs = readNow(asked.nowMs);
2982
+ const retryAtMs = _RetryAfter.parseHttpDate(
2983
+ text,
2984
+ nowMs
2985
+ );
2986
+ waitMs = retryAtMs === void 0 ? void 0 : retryAtMs - nowMs;
2987
+ }
2988
+ return waitMs === void 0 ? void 0 : Math.min(
2989
+ Math.max(waitMs, readBound(asked.minMs, DEFAULT_RETRY_AFTER_MIN_MS)),
2990
+ readBound(asked.maxMs, DEFAULT_RETRY_AFTER_MAX_MS)
2991
+ );
2992
+ }
2993
+ /*
2994
+ * The same wait in whole seconds, rounded up - never sooner than asked -
2995
+ * for a caller that counts in seconds.
2996
+ */
2997
+ static parseSeconds(value, options) {
2998
+ const waitMs = _RetryAfter.parseMs(value, options);
2999
+ return waitMs === void 0 ? void 0 : Math.ceil(waitMs / 1e3);
3000
+ }
3001
+ /*
3002
+ * The Retry-After header of a response's headers, whatever its case: an
3003
+ * object with a get() (fetch's Headers, axios's AxiosHeaders), or a plain
3004
+ * object of names to values (Node's, a test's). Undefined when there is
3005
+ * none; a get() that throws reads as none.
3006
+ */
3007
+ static readHeader(headers) {
3008
+ if (!headers || typeof headers !== "object") {
3009
+ return void 0;
3010
+ }
3011
+ const get = headers.get;
3012
+ if (typeof get === "function") {
3013
+ try {
3014
+ const value = get.call(
3015
+ headers,
3016
+ RETRY_AFTER_HEADER
3017
+ );
3018
+ if (value !== void 0 && value !== null) {
3019
+ return value;
3020
+ }
3021
+ } catch {
3022
+ }
3023
+ }
3024
+ for (const name of Object.keys(headers)) {
3025
+ if (name.toLowerCase() === RETRY_AFTER_HEADER) {
3026
+ return headers[name];
3027
+ }
3028
+ }
3029
+ return void 0;
3030
+ }
3031
+ // parseMs of a response's Retry-After header.
3032
+ static msFromHeaders(headers, options) {
3033
+ return _RetryAfter.parseMs(_RetryAfter.readHeader(headers), options);
3034
+ }
3035
+ // parseSeconds of a response's Retry-After header.
3036
+ static secondsFromHeaders(headers, options) {
3037
+ return _RetryAfter.parseSeconds(_RetryAfter.readHeader(headers), options);
3038
+ }
3039
+ /*
3040
+ * An HTTP-date in any of its three shapes, exactly as written, as
3041
+ * milliseconds since the epoch; undefined for anything else. nowMs is what
3042
+ * an RFC 850 date's two-digit year is read against.
3043
+ */
3044
+ static parseHttpDate(value, nowMs) {
3045
+ let match = IMF_FIXDATE.exec(value);
3046
+ if (match) {
3047
+ return toUtcMs(
3048
+ Number(match[3]),
3049
+ match[2],
3050
+ match[1],
3051
+ match[4],
3052
+ match[5],
3053
+ match[6]
3054
+ );
3055
+ }
3056
+ match = RFC_850_DATE.exec(value);
3057
+ if (match) {
3058
+ return readRfc850Date(match, readNow(nowMs));
3059
+ }
3060
+ match = ASCTIME_DATE.exec(value);
3061
+ return match ? toUtcMs(
3062
+ Number(match[6]),
3063
+ match[1],
3064
+ match[2],
3065
+ match[3],
3066
+ match[4],
3067
+ match[5]
3068
+ ) : void 0;
3069
+ }
3070
+ };
3071
+
2835
3072
  // src/Transport.ts
2836
3073
  var MAX_ATTEMPTS_PER_FRAME = 3;
2837
3074
  var DEFAULT_RETRY_MS = 15e3;
@@ -2894,11 +3131,7 @@ async function readDirective(response) {
2894
3131
  }
2895
3132
  }
2896
3133
  function parseRetryAfter(value) {
2897
- if (!value) {
2898
- return null;
2899
- }
2900
- const seconds = Number(value);
2901
- return Number.isFinite(seconds) && seconds >= 0 ? Math.min(300, seconds) : null;
3134
+ return RetryAfter.parseSeconds(value, { maxMs: 300 * 1e3 }) ?? null;
2902
3135
  }
2903
3136
  var ReplayTransport = class {
2904
3137
  constructor(options) {