@react-pdf-kit/viewer 2.2.0-beta.5 → 2.2.0-beta.6

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,21 +1,21 @@
1
1
  import { useState as h, useCallback as E, useEffect as A } from "react";
2
2
  import { LicenseType as b } from "../types.js";
3
- import { appConsole as l } from "../appConsole.js";
3
+ import { appConsole as c } from "../appConsole.js";
4
4
  import "../../de_DE-a553b162.js";
5
- const L = /* @__PURE__ */ new Date("2026-03-19T08:45:31.636Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
5
+ const y = /* @__PURE__ */ new Date("2026-03-23T03:06:51.138Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", o = {
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(n) {
12
+ function L(n) {
13
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
15
  r[i] = e.charCodeAt(i);
16
16
  return r.buffer;
17
17
  }
18
- function y(n) {
18
+ function S(n) {
19
19
  const t = atob(n), e = new Uint8Array(t.length);
20
20
  for (let r = 0; r < t.length; r++)
21
21
  e[r] = t.charCodeAt(r);
@@ -23,7 +23,7 @@ function y(n) {
23
23
  }
24
24
  async function I(n, t = "SHA-256") {
25
25
  try {
26
- const { data: e, signature: r } = JSON.parse(atob(n)), i = S(`-----BEGIN PUBLIC KEY-----
26
+ const { data: e, signature: r } = JSON.parse(atob(n)), i = L(`-----BEGIN PUBLIC KEY-----
27
27
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvIokvErJ0Fctu0jduSAx
28
28
  gr+5Har/VSuZLlOunS28hnlqqA+OF1apHL7RYkjBosS15yvviYdLrVWYHpHnoY4b
29
29
  HLQ9I6YX6FMB9T/VbB4xLdVdKvfi8r49aTScl5EKuSpgpPgz2VSJTfvVGcRuth/Y
@@ -31,25 +31,25 @@ Bm7PPGYdL2l2gvKDxchmmsHFPukGki9L4JOUeIVX0GXAxabENckaEH/iC1NZhX+W
31
31
  vXnpHeHuIIKlZ16LSivXNgo6BH2Z3GFdg4G3cAaXr6qNP8fsacYNqv2SpTW1viFD
32
32
  vzcGRabN25gpJAp9/syeScefWH3OiJY1lmw88oTiJbjIoiq6AkPhfn3G9mF54nvR
33
33
  kwIDAQAB
34
- -----END PUBLIC KEY-----`), a = await window.crypto.subtle.importKey(
34
+ -----END PUBLIC KEY-----`), s = await window.crypto.subtle.importKey(
35
35
  "spki",
36
36
  // str2ab(publicKeyContent), // Convert PEM string to ArrayBuffer
37
37
  i,
38
38
  { name: "RSA-PSS", hash: t },
39
39
  !0,
40
40
  ["verify"]
41
- );
42
- if (!await window.crypto.subtle.verify(
41
+ ), a = await window.crypto.subtle.verify(
43
42
  { name: "RSA-PSS", saltLength: 32 },
44
- a,
45
- y(r),
43
+ s,
44
+ S(r),
46
45
  // Convert signature to ArrayBuffer
47
46
  new TextEncoder().encode(atob(e))
48
- ))
49
- throw new Error(s.invalidSignature);
47
+ );
48
+ if (c.debug(">>> Verified license key validity", a), !a)
49
+ throw new Error(o.invalidSignature);
50
50
  return JSON.parse(atob(e));
51
51
  } catch {
52
- throw new Error(s.invalidLicense);
52
+ throw new Error(o.invalidLicense);
53
53
  }
54
54
  }
55
55
  const T = (n, t) => {
@@ -61,48 +61,48 @@ const T = (n, t) => {
61
61
  }
62
62
  }, u = {
63
63
  isValid: !0,
64
- invalidatedMessage: s.invalidLicense,
64
+ invalidatedMessage: o.invalidLicense,
65
65
  type: void 0
66
- }, Y = (n) => {
66
+ }, V = (n) => {
67
67
  const [t, e] = h(u), r = E(async () => {
68
- if (e((c) => ({ ...c, validating: !0 })), !n)
69
- throw e({ ...u, validating: !1 }), new Error(s.invalidLicense);
68
+ if (e((l) => ({ ...l, validating: !0 })), !n)
69
+ throw e({ ...u, validating: !1 }), new Error(o.invalidLicense);
70
70
  let i;
71
71
  try {
72
72
  i = await I(n);
73
- } catch (c) {
74
- throw l.warn(c.message), new Error(c.message);
73
+ } catch (l) {
74
+ throw c.warn(l.message), new Error(l.message);
75
75
  }
76
- l.debug(">>> validatedLicense", i);
77
- const { avu: a, exp: o, dmt: w, dm: p, t: m } = i;
78
- if (!o)
76
+ c.debug(">>> validatedLicense", i);
77
+ const { avu: s, exp: a, dmt: v, dm: w, t: f } = i;
78
+ if (!a)
79
79
  throw new Error("License is missing expiration timestamp");
80
- if (o > Number.MAX_SAFE_INTEGER / 1e3)
80
+ if (a > Number.MAX_SAFE_INTEGER / 1e3)
81
81
  throw new Error("Invalid expiration timestamp: value too large");
82
- const v = new Date(o * 1e3), g = (/* @__PURE__ */ new Date()).getTime();
83
- if (v.getTime() < g)
84
- throw new Error(s.expired);
85
- if (!a)
82
+ const p = new Date(a * 1e3), g = (/* @__PURE__ */ new Date()).getTime();
83
+ if (p.getTime() < g)
84
+ throw new Error(o.expired);
85
+ if (!s)
86
86
  throw new Error("License is missing available until version timestamp");
87
- if (a > Number.MAX_SAFE_INTEGER / 1e3)
87
+ if (s > Number.MAX_SAFE_INTEGER / 1e3)
88
88
  throw new Error("Invalid available until version timestamp: value too large");
89
- const f = new Date(a * 1e3);
90
- if (l.debug("availableUntilTimestamp", f), f.getTime() < L.getTime())
91
- throw new Error(s.exceededVersion);
92
- if (m !== b.Custom && !T(w, p))
93
- throw new Error(s.mismatchedDomain);
89
+ const m = new Date(s * 1e3);
90
+ if (c.debug("availableUntilTimestamp", m), m.getTime() < y.getTime())
91
+ throw new Error(o.exceededVersion);
92
+ if (f !== b.Custom && !T(v, w))
93
+ throw new Error(o.mismatchedDomain);
94
94
  return {
95
95
  isValid: !0,
96
- type: m,
96
+ type: f,
97
97
  invalidatedMessage: void 0
98
98
  };
99
99
  }, [n]);
100
100
  return A(() => {
101
- r().then(({ isValid: i, type: a, invalidatedMessage: o }) => {
101
+ r().then(({ isValid: i, type: s, invalidatedMessage: a }) => {
102
102
  e({
103
103
  isValid: i,
104
- type: a,
105
- invalidatedMessage: o,
104
+ type: s,
105
+ invalidatedMessage: a,
106
106
  validating: !1
107
107
  });
108
108
  }).catch((i) => {
@@ -110,10 +110,10 @@ const T = (n, t) => {
110
110
  ...u,
111
111
  isValid: !1,
112
112
  validating: !1
113
- }), l.warn(i.message);
113
+ }), c.warn(i.message);
114
114
  });
115
115
  }, [r]), t;
116
116
  };
117
117
  export {
118
- Y as useLicense
118
+ V as useLicense
119
119
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pdf-kit/viewer",
3
- "version": "2.2.0-beta.5",
3
+ "version": "2.2.0-beta.6",
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": [