@pdf-viewer/react 0.8.0-beta.1 → 0.9.0-beta.1
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,5 +1,5 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export declare const DarkModeContext: React.Context<
|
|
4
|
-
export declare const useDarkModeContext: () =>
|
|
2
|
+
import { DarkModeProps, DarkModeProviderProps } from '../utils/types';
|
|
3
|
+
export declare const DarkModeContext: React.Context<DarkModeProps>;
|
|
4
|
+
export declare const useDarkModeContext: () => DarkModeProps;
|
|
5
5
|
export declare const DarkModeProvider: FC<DarkModeProviderProps>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const useDarkMode: (initialDarkMode?: boolean) =>
|
|
1
|
+
import { DarkModeProps } from '../types';
|
|
2
|
+
export declare const useDarkMode: (initialDarkMode?: boolean) => DarkModeProps;
|
|
@@ -197,14 +197,12 @@ export interface RPThemeContextType extends PropsWithChildren {
|
|
|
197
197
|
customVariables?: Partial<Record<ThemeVariables, string>>;
|
|
198
198
|
customDarkVariables?: Partial<Record<ThemeVariables, string>>;
|
|
199
199
|
}
|
|
200
|
-
export interface
|
|
200
|
+
export interface DarkModeProps {
|
|
201
201
|
darkMode: boolean;
|
|
202
202
|
setDarkMode: Dispatch<React.SetStateAction<boolean>>;
|
|
203
203
|
}
|
|
204
|
-
export interface DarkModeProps {
|
|
204
|
+
export interface DarkMode extends DarkModeProps {
|
|
205
205
|
onDarkModeChange: (value: boolean) => void;
|
|
206
|
-
setDarkMode: React.Dispatch<React.SetStateAction<boolean>>;
|
|
207
|
-
darkMode: boolean;
|
|
208
206
|
}
|
|
209
207
|
export interface License {
|
|
210
208
|
isValid: boolean;
|
|
@@ -411,7 +409,7 @@ export declare enum ThemeVariables {
|
|
|
411
409
|
DIALOG_TITLE_FONT_WEIGHT = "--rp-dialog-title-font-weight",
|
|
412
410
|
MENU_ITEM_ICON_SIZE = "--rp-menu-item-icon-size"
|
|
413
411
|
}
|
|
414
|
-
export interface DarkModeProviderProps extends PropsWithChildren, Partial<Omit<
|
|
412
|
+
export interface DarkModeProviderProps extends PropsWithChildren, Partial<Omit<DarkMode, 'setDarkMode'>> {
|
|
415
413
|
}
|
|
416
414
|
export interface RotateProviderProps extends PropsWithChildren {
|
|
417
415
|
initialRotate?: number;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { useDarkMode as
|
|
2
|
-
const
|
|
3
|
-
const { darkMode:
|
|
1
|
+
import { useDarkMode as e } from "./useDarkMode.js";
|
|
2
|
+
const t = () => {
|
|
3
|
+
const { darkMode: o, setDarkMode: r } = e();
|
|
4
4
|
return {
|
|
5
|
-
darkMode:
|
|
6
|
-
|
|
7
|
-
setDarkMode: o
|
|
5
|
+
darkMode: o,
|
|
6
|
+
setDarkMode: r
|
|
8
7
|
};
|
|
9
8
|
};
|
|
10
9
|
export {
|
|
11
|
-
|
|
10
|
+
t as useDarkModeProps
|
|
12
11
|
};
|
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
import { useState as g, useCallback as
|
|
1
|
+
import { useState as g, useCallback as E, useEffect as h } from "react";
|
|
2
2
|
import { appConsole as l } from "../appConsole.js";
|
|
3
|
-
const
|
|
3
|
+
const A = /* @__PURE__ */ new Date("2025-02-26T04:15:46.379Z"), d = "Please visit https://www.react-pdf.dev/license-management/ to generate a new license key.", o = {
|
|
4
4
|
invalidLicense: `You are currently using without a valid license. ${d}`,
|
|
5
5
|
mismatchedDomain: `Your license key is not valid for the current domain / IP. ${d}`,
|
|
6
6
|
expired: `Your license key has expired. ${d}`,
|
|
7
7
|
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.",
|
|
8
8
|
invalidSignature: "Invalid license key: Signature mismatch"
|
|
9
9
|
};
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
for (let e = 0; e <
|
|
13
|
-
|
|
14
|
-
return
|
|
10
|
+
function b(r) {
|
|
11
|
+
const t = r.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s+/g, ""), i = atob(t), n = new Uint8Array(i.length);
|
|
12
|
+
for (let e = 0; e < i.length; e++)
|
|
13
|
+
n[e] = i.charCodeAt(e);
|
|
14
|
+
return n.buffer;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
for (let
|
|
19
|
-
|
|
20
|
-
return
|
|
16
|
+
function S(r) {
|
|
17
|
+
const t = atob(r), i = new Uint8Array(t.length);
|
|
18
|
+
for (let n = 0; n < t.length; n++)
|
|
19
|
+
i[n] = t.charCodeAt(n);
|
|
20
|
+
return i.buffer;
|
|
21
21
|
}
|
|
22
|
-
async function I(r,
|
|
22
|
+
async function I(r, t = "SHA-256") {
|
|
23
23
|
try {
|
|
24
|
-
const { data:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
const { data: i, signature: n } = JSON.parse(atob(r)), e = b(`-----BEGIN PUBLIC KEY-----
|
|
25
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvIokvErJ0Fctu0jduSAx
|
|
26
|
+
gr+5Har/VSuZLlOunS28hnlqqA+OF1apHL7RYkjBosS15yvviYdLrVWYHpHnoY4b
|
|
27
|
+
HLQ9I6YX6FMB9T/VbB4xLdVdKvfi8r49aTScl5EKuSpgpPgz2VSJTfvVGcRuth/Y
|
|
28
|
+
Bm7PPGYdL2l2gvKDxchmmsHFPukGki9L4JOUeIVX0GXAxabENckaEH/iC1NZhX+W
|
|
29
|
+
vXnpHeHuIIKlZ16LSivXNgo6BH2Z3GFdg4G3cAaXr6qNP8fsacYNqv2SpTW1viFD
|
|
30
|
+
vzcGRabN25gpJAp9/syeScefWH3OiJY1lmw88oTiJbjIoiq6AkPhfn3G9mF54nvR
|
|
31
|
+
kwIDAQAB
|
|
32
32
|
-----END PUBLIC KEY-----`), a = await window.crypto.subtle.importKey(
|
|
33
33
|
"spki",
|
|
34
34
|
// str2ab(publicKeyContent), // Convert PEM string to ArrayBuffer
|
|
35
35
|
e,
|
|
36
|
-
{ name: "RSA-PSS", hash:
|
|
36
|
+
{ name: "RSA-PSS", hash: t },
|
|
37
37
|
!0,
|
|
38
38
|
["verify"]
|
|
39
39
|
);
|
|
40
40
|
if (!await window.crypto.subtle.verify(
|
|
41
41
|
{ name: "RSA-PSS", saltLength: 32 },
|
|
42
42
|
a,
|
|
43
|
-
|
|
43
|
+
S(n),
|
|
44
44
|
// Convert signature to ArrayBuffer
|
|
45
|
-
new TextEncoder().encode(atob(
|
|
45
|
+
new TextEncoder().encode(atob(i))
|
|
46
46
|
))
|
|
47
47
|
throw new Error(o.invalidSignature);
|
|
48
|
-
return JSON.parse(atob(
|
|
48
|
+
return JSON.parse(atob(i));
|
|
49
49
|
} catch {
|
|
50
50
|
throw new Error(o.invalidLicense);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
const L = (r,
|
|
53
|
+
const L = (r, t) => r === "specific" ? t === window.location.host : window.location.host.includes(t), c = {
|
|
54
54
|
isValid: !1,
|
|
55
55
|
invalidatedMessage: o.invalidLicense,
|
|
56
56
|
type: void 0
|
|
57
|
-
},
|
|
58
|
-
const [
|
|
57
|
+
}, N = (r) => {
|
|
58
|
+
const [t, i] = g(c), n = E(async () => {
|
|
59
59
|
if (!r)
|
|
60
|
-
return
|
|
60
|
+
return i(c), c;
|
|
61
61
|
try {
|
|
62
62
|
const e = await I(r);
|
|
63
63
|
l.debug(">>> validatedLicense", e);
|
|
64
|
-
const { avu: a, exp: s, dmt: m, dm:
|
|
64
|
+
const { avu: a, exp: s, dmt: m, dm: p, t: v } = e;
|
|
65
65
|
if (!s)
|
|
66
66
|
throw new Error("License is missing expiration timestamp");
|
|
67
67
|
if (s > Number.MAX_SAFE_INTEGER / 1e3)
|
|
68
68
|
throw new Error("Invalid expiration timestamp: value too large");
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
69
|
+
const f = new Date(s * 1e3), w = (/* @__PURE__ */ new Date()).getTime();
|
|
70
|
+
if (f.getTime() < w)
|
|
71
71
|
throw new Error(o.expired);
|
|
72
72
|
if (!a)
|
|
73
73
|
throw new Error("License is missing available until version timestamp");
|
|
74
74
|
if (a > Number.MAX_SAFE_INTEGER / 1e3)
|
|
75
75
|
throw new Error("Invalid available until version timestamp: value too large");
|
|
76
76
|
const u = new Date(a * 1e3);
|
|
77
|
-
if (l.debug("availableUntilTimestamp", u), u.getTime() <
|
|
77
|
+
if (l.debug("availableUntilTimestamp", u), u.getTime() < A.getTime())
|
|
78
78
|
throw new Error(o.exceededVersion);
|
|
79
|
-
if (!L(m,
|
|
79
|
+
if (!L(m, p))
|
|
80
80
|
throw new Error(o.mismatchedDomain);
|
|
81
81
|
return {
|
|
82
82
|
isValid: !0,
|
|
83
|
-
type:
|
|
83
|
+
type: v,
|
|
84
84
|
invalidatedMessage: void 0
|
|
85
85
|
};
|
|
86
86
|
} catch (e) {
|
|
87
87
|
return l.warn(e.message), { ...c, invalidatedMessage: e.message };
|
|
88
88
|
}
|
|
89
89
|
}, [r]);
|
|
90
|
-
return
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
return h(() => {
|
|
91
|
+
n().then(({ isValid: e, type: a, invalidatedMessage: s }) => {
|
|
92
|
+
i({
|
|
93
93
|
isValid: e,
|
|
94
94
|
type: a,
|
|
95
95
|
invalidatedMessage: s
|
|
96
96
|
});
|
|
97
97
|
});
|
|
98
|
-
}, [
|
|
98
|
+
}, [n]), t;
|
|
99
99
|
};
|
|
100
100
|
export {
|
|
101
|
-
|
|
101
|
+
N as useLicense
|
|
102
102
|
};
|