@react-pdf-kit/viewer 2.2.0-beta.4 → 2.2.0-rc.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.
@@ -1,29 +1,29 @@
1
- import { useState as E, useCallback as h, useEffect as A } from "react";
1
+ import { useState as h, useCallback as E, useEffect as A } from "react";
2
2
  import { LicenseType as b } from "../types.js";
3
3
  import { appConsole as l } from "../appConsole.js";
4
4
  import "../../de_DE-a553b162.js";
5
- const L = /* @__PURE__ */ new Date("2026-03-19T04:03:12.760Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
5
+ const L = /* @__PURE__ */ new Date("2026-03-19T12:29:21.665Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
6
6
  invalidLicense: `You are currently using without a valid license. ${d}`,
7
7
  mismatchedDomain: `Your license key is not valid for the current domain / IP. ${d}`,
8
8
  expired: `Your license key has expired. ${d}`,
9
9
  exceededVersion: "Your license does not support the current version of React PDF. The library version you are using exceeds the supported range of your license.",
10
10
  invalidSignature: "Invalid license key: Signature mismatch"
11
11
  };
12
- function S(r) {
13
- const t = r.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s+/g, ""), e = atob(t), n = new Uint8Array(e.length);
12
+ function S(n) {
13
+ const t = n.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s+/g, ""), e = atob(t), r = new Uint8Array(e.length);
14
14
  for (let i = 0; i < e.length; i++)
15
- n[i] = e.charCodeAt(i);
16
- return n.buffer;
15
+ r[i] = e.charCodeAt(i);
16
+ return r.buffer;
17
17
  }
18
- function y(r) {
19
- const t = atob(r), e = new Uint8Array(t.length);
20
- for (let n = 0; n < t.length; n++)
21
- e[n] = t.charCodeAt(n);
18
+ function y(n) {
19
+ const t = atob(n), e = new Uint8Array(t.length);
20
+ for (let r = 0; r < t.length; r++)
21
+ e[r] = t.charCodeAt(r);
22
22
  return e.buffer;
23
23
  }
24
- async function I(r, t = "SHA-256") {
24
+ async function I(n, t = "SHA-256") {
25
25
  try {
26
- const { data: e, signature: n } = JSON.parse(atob(r)), i = S(`-----BEGIN PUBLIC KEY-----
26
+ const { data: e, signature: r } = JSON.parse(atob(n)), i = S(`-----BEGIN PUBLIC KEY-----
27
27
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvIokvErJ0Fctu0jduSAx
28
28
  gr+5Har/VSuZLlOunS28hnlqqA+OF1apHL7RYkjBosS15yvviYdLrVWYHpHnoY4b
29
29
  HLQ9I6YX6FMB9T/VbB4xLdVdKvfi8r49aTScl5EKuSpgpPgz2VSJTfvVGcRuth/Y
@@ -42,7 +42,7 @@ kwIDAQAB
42
42
  if (!await window.crypto.subtle.verify(
43
43
  { name: "RSA-PSS", saltLength: 32 },
44
44
  a,
45
- y(n),
45
+ y(r),
46
46
  // Convert signature to ArrayBuffer
47
47
  new TextEncoder().encode(atob(e))
48
48
  ))
@@ -52,28 +52,35 @@ kwIDAQAB
52
52
  throw new Error(s.invalidLicense);
53
53
  }
54
54
  }
55
- const T = (r, t) => r === "specific" ? t === window.location.host : window.location.host.includes(t), u = {
55
+ const T = (n, t) => {
56
+ switch (n) {
57
+ case "specific":
58
+ return t === window.location.host;
59
+ case "wildcard":
60
+ return t ? window.location.host.includes(t) : !1;
61
+ }
62
+ }, u = {
56
63
  isValid: !0,
57
64
  invalidatedMessage: s.invalidLicense,
58
65
  type: void 0
59
- }, Y = (r) => {
60
- const [t, e] = E(u), n = h(async () => {
61
- if (e((c) => ({ ...c, validating: !0 })), !r)
66
+ }, Y = (n) => {
67
+ const [t, e] = h(u), r = E(async () => {
68
+ if (e((c) => ({ ...c, validating: !0 })), !n)
62
69
  throw e({ ...u, validating: !1 }), new Error(s.invalidLicense);
63
70
  let i;
64
71
  try {
65
- i = await I(r);
72
+ i = await I(n);
66
73
  } catch (c) {
67
74
  throw l.warn(c.message), new Error(c.message);
68
75
  }
69
76
  l.debug(">>> validatedLicense", i);
70
- const { avu: a, exp: o, dmt: p, dm: v, t: m } = i;
77
+ const { avu: a, exp: o, dmt: w, dm: p, t: m } = i;
71
78
  if (!o)
72
79
  throw new Error("License is missing expiration timestamp");
73
80
  if (o > Number.MAX_SAFE_INTEGER / 1e3)
74
81
  throw new Error("Invalid expiration timestamp: value too large");
75
- const w = new Date(o * 1e3), g = (/* @__PURE__ */ new Date()).getTime();
76
- if (w.getTime() < g)
82
+ const v = new Date(o * 1e3), g = (/* @__PURE__ */ new Date()).getTime();
83
+ if (v.getTime() < g)
77
84
  throw new Error(s.expired);
78
85
  if (!a)
79
86
  throw new Error("License is missing available until version timestamp");
@@ -82,16 +89,16 @@ const T = (r, t) => r === "specific" ? t === window.location.host : window.locat
82
89
  const f = new Date(a * 1e3);
83
90
  if (l.debug("availableUntilTimestamp", f), f.getTime() < L.getTime())
84
91
  throw new Error(s.exceededVersion);
85
- if (m !== b.Custom && !T(p, v))
92
+ if (m !== b.Custom && !T(w, p))
86
93
  throw new Error(s.mismatchedDomain);
87
94
  return {
88
95
  isValid: !0,
89
96
  type: m,
90
97
  invalidatedMessage: void 0
91
98
  };
92
- }, [r]);
99
+ }, [n]);
93
100
  return A(() => {
94
- n().then(({ isValid: i, type: a, invalidatedMessage: o }) => {
101
+ r().then(({ isValid: i, type: a, invalidatedMessage: o }) => {
95
102
  e({
96
103
  isValid: i,
97
104
  type: a,
@@ -105,7 +112,7 @@ const T = (r, t) => r === "specific" ? t === window.location.host : window.locat
105
112
  validating: !1
106
113
  }), l.warn(i.message);
107
114
  });
108
- }, [n]), t;
115
+ }, [r]), t;
109
116
  };
110
117
  export {
111
118
  Y as useLicense
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pdf-kit/viewer",
3
- "version": "2.2.0-beta.4",
3
+ "version": "2.2.0-rc.0",
4
4
  "private": false,
5
5
  "description": "A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.",
6
6
  "keywords": [