next-flipbook 0.9.0 → 0.10.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/LICENSE +97 -21
- package/README.md +23 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/license/check.d.ts +19 -0
- package/dist/license/check.d.ts.map +1 -0
- package/dist/license/check.js +42 -0
- package/dist/license/check.js.map +1 -0
- package/dist/license/format.d.ts +47 -0
- package/dist/license/format.d.ts.map +1 -0
- package/dist/license/format.js +114 -0
- package/dist/license/format.js.map +1 -0
- package/dist/license/index.d.ts +10 -0
- package/dist/license/index.d.ts.map +1 -0
- package/dist/license/index.js +7 -0
- package/dist/license/index.js.map +1 -0
- package/dist/license/publicKey.d.ts +10 -0
- package/dist/license/publicKey.d.ts.map +1 -0
- package/dist/license/publicKey.js +14 -0
- package/dist/license/publicKey.js.map +1 -0
- package/dist/license/revoked.d.ts +8 -0
- package/dist/license/revoked.d.ts.map +1 -0
- package/dist/license/revoked.js +8 -0
- package/dist/license/revoked.js.map +1 -0
- package/dist/license/types.d.ts +76 -0
- package/dist/license/types.d.ts.map +1 -0
- package/dist/license/types.js +2 -0
- package/dist/license/types.js.map +1 -0
- package/dist/license/verify.d.ts +25 -0
- package/dist/license/verify.d.ts.map +1 -0
- package/dist/license/verify.js +48 -0
- package/dist/license/verify.js.map +1 -0
- package/dist/license/warn.d.ts +14 -0
- package/dist/license/warn.d.ts.map +1 -0
- package/dist/license/warn.js +47 -0
- package/dist/license/warn.js.map +1 -0
- package/dist/react/components/FlipBookLicenseMark.d.ts +11 -0
- package/dist/react/components/FlipBookLicenseMark.d.ts.map +1 -0
- package/dist/react/components/FlipBookLicenseMark.js +46 -0
- package/dist/react/components/FlipBookLicenseMark.js.map +1 -0
- package/dist/react/components/FlipBookLicenseProvider.d.ts +18 -0
- package/dist/react/components/FlipBookLicenseProvider.d.ts.map +1 -0
- package/dist/react/components/FlipBookLicenseProvider.js +17 -0
- package/dist/react/components/FlipBookLicenseProvider.js.map +1 -0
- package/dist/react/components/FlipBookProvider.d.ts.map +1 -1
- package/dist/react/components/FlipBookProvider.js +5 -1
- package/dist/react/components/FlipBookProvider.js.map +1 -1
- package/dist/react/components/FlipBookStage.d.ts.map +1 -1
- package/dist/react/components/FlipBookStage.js +4 -3
- package/dist/react/components/FlipBookStage.js.map +1 -1
- package/dist/react/context.d.ts +3 -0
- package/dist/react/context.d.ts.map +1 -1
- package/dist/react/context.js.map +1 -1
- package/dist/react/hooks/useLicense.d.ts +9 -0
- package/dist/react/hooks/useLicense.d.ts.map +1 -0
- package/dist/react/hooks/useLicense.js +32 -0
- package/dist/react/hooks/useLicense.js.map +1 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +2 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/licenseContext.d.ts +3 -0
- package/dist/react/licenseContext.d.ts.map +1 -0
- package/dist/react/licenseContext.js +5 -0
- package/dist/react/licenseContext.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,21 +1,97 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
DRAFT FOR REVIEW. DELETE THIS BANNER ONLY AFTER A LAWYER HAS REVIEWED THIS TEXT.
|
|
2
|
+
|
|
3
|
+
This is a starting template written by an AI assistant, not legal advice and not the work of a
|
|
4
|
+
lawyer. It says what the author asked for: the package is not free, and one license key covers one
|
|
5
|
+
website. Whether it says that in a way that holds up in your country, and what else it needs
|
|
6
|
+
(governing law, a limit on liability that the law of your customers' countries allows, how
|
|
7
|
+
contributions to the repository are licensed), is for a lawyer to decide. Fill in the [bracketed]
|
|
8
|
+
parts. `npm run verify:release` refuses to publish a package while this banner is here.
|
|
9
|
+
|
|
10
|
+
----------------------------------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
next-flipbook Commercial License
|
|
13
|
+
|
|
14
|
+
Copyright (c) 2026 Samith Mendis ("the Licensor"). All rights reserved.
|
|
15
|
+
|
|
16
|
+
This license applies to next-flipbook version [0.10.0] and later ("the Software"). Earlier versions
|
|
17
|
+
that were published under the MIT License stay under the MIT License, for the people who received
|
|
18
|
+
them under it.
|
|
19
|
+
|
|
20
|
+
1. Definitions
|
|
21
|
+
|
|
22
|
+
"License Key" is the text the Licensor issues, which names one website.
|
|
23
|
+
"Licensed Website" is the website name a License Key names, and the subdomains of that name.
|
|
24
|
+
"Project" is the one website or web application that is served from the Licensed Website.
|
|
25
|
+
"Development Address" is a local or private-network address: localhost, an address in a private
|
|
26
|
+
range (10.x.x.x, 172.16-31.x.x, 192.168.x.x, 127.x.x.x), or a name ending in .local, .localhost,
|
|
27
|
+
.test or .internal.
|
|
28
|
+
|
|
29
|
+
2. What you may do
|
|
30
|
+
|
|
31
|
+
a. Evaluate the Software, in development or in a trial, on any Development Address, with no License
|
|
32
|
+
Key and at no charge.
|
|
33
|
+
b. With a valid License Key for a Licensed Website, use the Software in the Project, in
|
|
34
|
+
production and in testing, and include it in the Project's build and in what the Project
|
|
35
|
+
sends to its visitors.
|
|
36
|
+
c. Read the source code, for the purpose of understanding the Software and fixing your own use of it.
|
|
37
|
+
|
|
38
|
+
This is a non-exclusive, non-transferable, non-sublicensable license, worldwide, for the term of
|
|
39
|
+
the License Key.
|
|
40
|
+
|
|
41
|
+
3. One key, one project
|
|
42
|
+
|
|
43
|
+
A License Key is for the Project on its Licensed Website, and for nothing else. You may not use a
|
|
44
|
+
License Key on any other website or in any other project, and may not give, sell, publish or
|
|
45
|
+
share it so that another party can use it. A second website, or a project for a different
|
|
46
|
+
customer, needs its own License Key. [An agency that builds sites for clients needs a License Key
|
|
47
|
+
for each client's site.]
|
|
48
|
+
|
|
49
|
+
4. What you may not do
|
|
50
|
+
|
|
51
|
+
a. Remove, hide, disable or work around the license check, the watermark or the console warning,
|
|
52
|
+
or change the Software so that a website without a valid License Key looks as if it had one.
|
|
53
|
+
b. Sell, rent, sublicense, publish, or otherwise make the Software available to others, whole or in
|
|
54
|
+
part, in source form, compiled form, or inside a package, template or library of your own,
|
|
55
|
+
except as part of the Project's own output to its visitors.
|
|
56
|
+
c. Use the Software to make a product that competes with it.
|
|
57
|
+
d. Use the Software in production on a website that has no valid License Key.
|
|
58
|
+
|
|
59
|
+
5. Term, and ending the license
|
|
60
|
+
|
|
61
|
+
A License Key is valid until the end date it carries, or without end if it carries none. The
|
|
62
|
+
Licensor may withdraw a License Key if you break this license, or if the fee for it is not paid
|
|
63
|
+
[when due]. When a License Key ends or is withdrawn, the Software shows its watermark on the
|
|
64
|
+
Licensed Website, and you must stop using the Software there in production, or obtain a new
|
|
65
|
+
License Key. A withdrawal takes effect for a website when it installs a version of the Software
|
|
66
|
+
that lists the withdrawal.
|
|
67
|
+
|
|
68
|
+
6. Ownership
|
|
69
|
+
|
|
70
|
+
The Software is licensed, not sold. The Licensor keeps all rights in it that this license does not
|
|
71
|
+
give you. Nothing here gives you any right to the name "next-flipbook".
|
|
72
|
+
|
|
73
|
+
7. Other people's software
|
|
74
|
+
|
|
75
|
+
The Software uses other software, such as PDF.js and React, which stays under its own license. This
|
|
76
|
+
license does not change those.
|
|
77
|
+
|
|
78
|
+
8. No warranty
|
|
79
|
+
|
|
80
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING THE
|
|
81
|
+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
|
82
|
+
|
|
83
|
+
9. Limit of liability
|
|
84
|
+
|
|
85
|
+
TO THE EXTENT THE LAW ALLOWS, THE LICENSOR IS NOT LIABLE FOR ANY INDIRECT OR CONSEQUENTIAL LOSS, OR FOR
|
|
86
|
+
ANY LOSS OF PROFIT, DATA OR BUSINESS, ARISING FROM THE SOFTWARE, AND THE LICENSOR'S TOTAL LIABILITY IS
|
|
87
|
+
LIMITED TO THE FEE YOU PAID FOR THE LICENSE KEY IN THE [12] MONTHS BEFORE THE CLAIM.
|
|
88
|
+
[A lawyer should check this against the law of the places your customers are in.]
|
|
89
|
+
|
|
90
|
+
10. Law
|
|
91
|
+
|
|
92
|
+
This license is governed by the law of [COUNTRY], and the courts of [PLACE] decide any dispute
|
|
93
|
+
about it, unless the law of your country does not allow that.
|
|
94
|
+
|
|
95
|
+
11. Contact
|
|
96
|
+
|
|
97
|
+
Samith Mendis, samithmendis.01@gmail.com, https://github.com/dsamithmendis
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ A realistic, responsive flipbook engine for React and Next.js.
|
|
|
4
4
|
|
|
5
5
|
Give it a PDF, images or React components and it gives you a book: a physical page-turn animation you can grab and drag, pinch and double-tap zoom, thumbnails, bookmarks, text search and a table of contents, single or two-page layout that follows the container size, keyboard navigation, accessible controls and right-to-left support. The engine has no React or Next.js dependency, and the React layer is a thin, SSR-safe shell around it.
|
|
6
6
|
|
|
7
|
-
> **Status: Phase 7 (0.
|
|
7
|
+
> **Status: Phase 7 (0.10.0).** PDFs (PDF.js), images and custom React pages; drag, swipe and zoom; a toolbar with thumbnails (their size can be set), bookmarks, a changeable background, fullscreen, download, print and share; text search, the PDF's table of contents, clickable PDF links, hotspots, overlays, deep links and a saved reading place; bounded memory on very long PDFs, with benchmarks; linted, with end-to-end, accessibility and visual tests and CI. A license key per website. Not built yet: autoplay, hard pages, page curl, sound, plugins. The API only exposes what is implemented.
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
@@ -14,6 +14,24 @@ npm install next-flipbook
|
|
|
14
14
|
|
|
15
15
|
Requires React 18 or newer. The package is ESM-only. `pdfjs-dist` is installed with it and is loaded only when a PDF is shown, in its own chunk, so image-only books never download it.
|
|
16
16
|
|
|
17
|
+
### License key
|
|
18
|
+
|
|
19
|
+
next-flipbook is not free: a website that uses it in production needs a **license key**, and one key works on one website. Anyone can install it and try it. Without a valid key the viewer shows an "Unlicensed copy" watermark and writes one warning to the console, and it keeps working. `localhost` and private-network addresses never need a key.
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
<FlipBook source="/magazine.pdf" licenseKey="FB1.eyJ2Ijox…" />
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Or once for the whole app, in the root layout:
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { FlipBookLicenseProvider } from "next-flipbook";
|
|
29
|
+
|
|
30
|
+
<FlipBookLicenseProvider licenseKey={process.env.NEXT_PUBLIC_FLIPBOOK_LICENSE_KEY}>{children}</FlipBookLicenseProvider>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
How keys work, what a visitor and a developer see, and how to make keys: [docs/licensing.md](docs/licensing.md).
|
|
34
|
+
|
|
17
35
|
## Quick start: a PDF
|
|
18
36
|
|
|
19
37
|
```tsx
|
|
@@ -134,6 +152,7 @@ ref.current?.getCacheStats(); // what the viewer holds: cached pages, thumbnails
|
|
|
134
152
|
|
|
135
153
|
| Prop | Default | Notes |
|
|
136
154
|
| --- | --- | --- |
|
|
155
|
+
| `licenseKey` | none | The key you were given for this website. Without a valid one the viewer shows a watermark and one console warning, and keeps working. `localhost` and private addresses need none. `<FlipBookLicenseProvider>` sets it for every viewer below it. See [docs/licensing.md](docs/licensing.md). |
|
|
137
156
|
| `source` | none | A PDF: URL, `File`, `Blob`, `ArrayBuffer` or `Uint8Array`. Pass `source` or `pages`, not both. Keep it referentially stable: a new value loads a new document. |
|
|
138
157
|
| `pages` | none | Strings (image URLs), `{ type: "image", src, alt?, width?, height? }`, `{ type: "custom", component? \| render? }` or `{ type: "pdf", source, page }`. |
|
|
139
158
|
| `pdf` | none | `workerSrc`, `renderScale`, `maxCanvasPixels`, `maxCacheBytes`, `maxTextCacheBytes`, `cleanupAfterPages`, `password`, `withCredentials`, `httpHeaders`, `maxConcurrentRenders`, `documentParams`, `loadPdfjs`. See [docs/pdf.md](docs/pdf.md). |
|
|
@@ -276,6 +295,8 @@ node benchmarks/browser.mjs # a real Chromium on the demo's /l
|
|
|
276
295
|
|
|
277
296
|
What was measured, on what, and what it does not show: [docs/performance.md](docs/performance.md).
|
|
278
297
|
|
|
298
|
+
License keys are made with `npm run license -- …` (see [docs/licensing.md](docs/licensing.md)), and `npm run verify:release` checks that a package is ready to be published.
|
|
299
|
+
|
|
279
300
|
Layout: `packages/flipbook` is the library, `demo/next-app` is the App Router demo, `benchmarks` holds the benchmarks, `docs` holds design notes. See [docs/architecture.md](docs/architecture.md).
|
|
280
301
|
|
|
281
302
|
## Author
|
|
@@ -284,4 +305,4 @@ Samith Mendis ([@dsamithmendis](https://github.com/dsamithmendis)) · samithmend
|
|
|
284
305
|
|
|
285
306
|
## License
|
|
286
307
|
|
|
287
|
-
|
|
308
|
+
Commercial: one license key per website. See [LICENSE](LICENSE) and [docs/licensing.md](docs/licensing.md).
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from "./react/index.js";
|
|
2
2
|
export type { AppearanceSnapshot, AspectRatioProp, BackgroundChoice, BookmarkOptions, BookmarkStorage, CustomPage, DownloadOptions, EngineState, FlipBookAppearanceControls, FlipBookBookProps, FlipBookController, FlipBookDirection, FlipBookError, FlipBookErrorCode, FlipBookFeatures, FlipBookHotspot, FlipBookLink, FlipBookLocale, FlipBookMode, FlipBookPage, FlipBookPageInput, FlipBookProps, FlipBookStageProps, FlipBookTheme, FlipBookTurnEvent, FlipBookView, ImagePage, ImageTextBox, PasswordReason, PersistStateOptions, PdfOptions, PdfPage, PdfSource, PrintOptions, SearchOptions, ShareOptions, ThumbnailSize, ThumbnailSizeName, PanelId, UiSnapshot, UrlStateOptions, WhileTurning, ZoomSnapshot, } from "./types/index.js";
|
|
3
3
|
export type { FlipBookCacheControls, FlipBookCacheStats, FlipBookOutlineControls, FlipBookOutlineItem, FlipBookSearchControls, SearchResult, SearchSnapshot, StorageLike, } from "./core/index.js";
|
|
4
|
+
export { LICENSE_INFO_URL, hostMatchesDomain, isDevelopmentHost, parseLicenseKey, verifyLicense } from "./license/index.js";
|
|
5
|
+
export type { LicenseProblem, LicensePayload, LicensePublicKey, LicenseStatus, VerifyLicenseOptions } from "./license/index.js";
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AAEjC,YAAY,EACV,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,UAAU,EACV,eAAe,EACf,WAAW,EACX,0BAA0B,EAC1B,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,UAAU,EACV,OAAO,EACP,SAAS,EACT,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,OAAO,EACP,UAAU,EACV,eAAe,EACf,YAAY,EACZ,YAAY,GACb,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACtB,YAAY,EACZ,cAAc,EACd,WAAW,GACZ,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AAEjC,YAAY,EACV,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,UAAU,EACV,eAAe,EACf,WAAW,EACX,0BAA0B,EAC1B,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,UAAU,EACV,OAAO,EACP,SAAS,EACT,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,OAAO,EACP,UAAU,EACV,eAAe,EACf,YAAY,EACZ,YAAY,GACb,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACtB,YAAY,EACZ,cAAc,EACd,WAAW,GACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC5H,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AAyDjC,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { LicensePublicKey, LicenseStatus } from "./types.js";
|
|
2
|
+
/** The website the page is on, or null where there is no page (server rendering). */
|
|
3
|
+
export declare function currentHostname(): string | null;
|
|
4
|
+
/**
|
|
5
|
+
* The license status of `key` for the website this page is on. Every viewer on a page asks the
|
|
6
|
+
* same question, so the check runs once per key and the answer is shared. On the server it answers
|
|
7
|
+
* `pending`: the check belongs to the browser, and the server's HTML has to match the browser's
|
|
8
|
+
* first render.
|
|
9
|
+
*/
|
|
10
|
+
export declare function checkLicense(key: string | undefined): Promise<LicenseStatus>;
|
|
11
|
+
/** Forgets the answers. For tests: a page never needs it. */
|
|
12
|
+
export declare function resetLicenseChecks(): void;
|
|
13
|
+
/**
|
|
14
|
+
* Checks keys against another public key, or against the package's own again with `undefined`. For
|
|
15
|
+
* tests, which sign keys with a key of their own. It is not exported from the package (nothing in
|
|
16
|
+
* `exports` reaches this file), so an app cannot swap the key.
|
|
17
|
+
*/
|
|
18
|
+
export declare function overrideLicensePublicKey(key: LicensePublicKey | null | undefined): void;
|
|
19
|
+
//# sourceMappingURL=check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/license/check.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAOlE,qFAAqF;AACrF,wBAAgB,eAAe,IAAI,MAAM,GAAG,IAAI,CAE/C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,CAU5E;AAED,6DAA6D;AAC7D,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,gBAAgB,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAGvF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { LICENSE_PUBLIC_KEY } from "./publicKey.js";
|
|
2
|
+
import { REVOKED_LICENSE_IDS } from "./revoked.js";
|
|
3
|
+
import { verifyLicense } from "./verify.js";
|
|
4
|
+
const PENDING = { state: "pending" };
|
|
5
|
+
const answers = new Map();
|
|
6
|
+
let publicKey = LICENSE_PUBLIC_KEY;
|
|
7
|
+
/** The website the page is on, or null where there is no page (server rendering). */
|
|
8
|
+
export function currentHostname() {
|
|
9
|
+
return typeof location === "undefined" ? null : location.hostname;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The license status of `key` for the website this page is on. Every viewer on a page asks the
|
|
13
|
+
* same question, so the check runs once per key and the answer is shared. On the server it answers
|
|
14
|
+
* `pending`: the check belongs to the browser, and the server's HTML has to match the browser's
|
|
15
|
+
* first render.
|
|
16
|
+
*/
|
|
17
|
+
export function checkLicense(key) {
|
|
18
|
+
const hostname = currentHostname();
|
|
19
|
+
if (hostname === null)
|
|
20
|
+
return Promise.resolve(PENDING);
|
|
21
|
+
const id = `${hostname}\n${key ?? ""}`;
|
|
22
|
+
let answer = answers.get(id);
|
|
23
|
+
if (!answer) {
|
|
24
|
+
answer = verifyLicense({ key, hostname, publicKey, revoked: REVOKED_LICENSE_IDS });
|
|
25
|
+
answers.set(id, answer);
|
|
26
|
+
}
|
|
27
|
+
return answer;
|
|
28
|
+
}
|
|
29
|
+
/** Forgets the answers. For tests: a page never needs it. */
|
|
30
|
+
export function resetLicenseChecks() {
|
|
31
|
+
answers.clear();
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Checks keys against another public key, or against the package's own again with `undefined`. For
|
|
35
|
+
* tests, which sign keys with a key of their own. It is not exported from the package (nothing in
|
|
36
|
+
* `exports` reaches this file), so an app cannot swap the key.
|
|
37
|
+
*/
|
|
38
|
+
export function overrideLicensePublicKey(key) {
|
|
39
|
+
publicKey = key === undefined ? LICENSE_PUBLIC_KEY : key;
|
|
40
|
+
answers.clear();
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/license/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,GAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AACpD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkC,CAAC;AAC1D,IAAI,SAAS,GAA4B,kBAAkB,CAAC;AAE5D,qFAAqF;AACrF,MAAM,UAAU,eAAe;IAC7B,OAAO,OAAO,QAAQ,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;AACpE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,GAAuB;IAClD,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;IACnC,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvD,MAAM,EAAE,GAAG,GAAG,QAAQ,KAAK,GAAG,IAAI,EAAE,EAAE,CAAC;IACvC,IAAI,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC7B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,aAAa,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,mBAAmB,EAAE,CAAC,CAAC;QACnF,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,kBAAkB;IAChC,OAAO,CAAC,KAAK,EAAE,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAwC;IAC/E,SAAS,GAAG,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,GAAG,CAAC;IACzD,OAAO,CAAC,KAAK,EAAE,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { LicensePayload } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* A license key is three parts joined by dots:
|
|
4
|
+
*
|
|
5
|
+
* FB1.<payload>.<signature>
|
|
6
|
+
*
|
|
7
|
+
* The payload is JSON (see `LicensePayload`) and the signature covers the text `FB1.<payload>`
|
|
8
|
+
* exactly as written, so there is nothing to canonicalize. Both parts are base64url. The
|
|
9
|
+
* signature is ECDSA with P-256 and SHA-256, in the 64-byte `r || s` form that `crypto.subtle`
|
|
10
|
+
* uses. That algorithm is the one every browser's `crypto.subtle` has had for years; Ed25519 is
|
|
11
|
+
* not available in the older ones.
|
|
12
|
+
*
|
|
13
|
+
* This file is plain functions with no browser or Node APIs beyond `atob` and `TextDecoder`, so
|
|
14
|
+
* the same code runs in the browser, on the server and in tests.
|
|
15
|
+
*/
|
|
16
|
+
export declare const LICENSE_KEY_PREFIX = "FB1";
|
|
17
|
+
export interface ParsedLicenseKey {
|
|
18
|
+
payload: LicensePayload;
|
|
19
|
+
/** The text the signature covers. */
|
|
20
|
+
signedText: string;
|
|
21
|
+
/** The 64 signature bytes. */
|
|
22
|
+
signature: Uint8Array<ArrayBuffer>;
|
|
23
|
+
}
|
|
24
|
+
/** Bytes from base64url text, or null if it is not that. */
|
|
25
|
+
export declare function fromBase64Url(text: string): Uint8Array<ArrayBuffer> | null;
|
|
26
|
+
/**
|
|
27
|
+
* Splits a key into its payload and signature. Spaces and line breaks are ignored, because keys
|
|
28
|
+
* get pasted from emails and wrapped. Returns null for anything that is not shaped like a key.
|
|
29
|
+
* Nothing in the result can be trusted until the signature has been checked.
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseLicenseKey(input: string): ParsedLicenseKey | null;
|
|
32
|
+
/** A host name or domain in the form that is compared: lower case, with no brackets or trailing dot. */
|
|
33
|
+
export declare function normalizeHost(value: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Whether `host` is `domain` or one of its subdomains. A key for `example.com` covers
|
|
36
|
+
* `www.example.com` and `app.example.com`, and not `notexample.com`. A domain with a single label
|
|
37
|
+
* (`com`, `intranet`) matches only itself, so a key can never cover a whole top-level domain.
|
|
38
|
+
*/
|
|
39
|
+
export declare function hostMatchesDomain(host: string, domain: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the viewer runs on a developer's own machine or network: there is no website to check a
|
|
42
|
+
* key against, and a warning on every `npm run dev` would only train people to ignore it. This
|
|
43
|
+
* covers `localhost`, loopback and private-network addresses, `*.local`, `*.test`, `*.internal`,
|
|
44
|
+
* and pages that are not on a host at all (`file:`).
|
|
45
|
+
*/
|
|
46
|
+
export declare function isDevelopmentHost(host: string): boolean;
|
|
47
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/license/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAExC,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,cAAc,CAAC;IACxB,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,8BAA8B;IAC9B,SAAS,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;CACpC;AAED,4DAA4D;AAC5D,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAY1E;AAmBD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAkBtE;AAED,wGAAwG;AACxG,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAMvE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAevD"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A license key is three parts joined by dots:
|
|
3
|
+
*
|
|
4
|
+
* FB1.<payload>.<signature>
|
|
5
|
+
*
|
|
6
|
+
* The payload is JSON (see `LicensePayload`) and the signature covers the text `FB1.<payload>`
|
|
7
|
+
* exactly as written, so there is nothing to canonicalize. Both parts are base64url. The
|
|
8
|
+
* signature is ECDSA with P-256 and SHA-256, in the 64-byte `r || s` form that `crypto.subtle`
|
|
9
|
+
* uses. That algorithm is the one every browser's `crypto.subtle` has had for years; Ed25519 is
|
|
10
|
+
* not available in the older ones.
|
|
11
|
+
*
|
|
12
|
+
* This file is plain functions with no browser or Node APIs beyond `atob` and `TextDecoder`, so
|
|
13
|
+
* the same code runs in the browser, on the server and in tests.
|
|
14
|
+
*/
|
|
15
|
+
export const LICENSE_KEY_PREFIX = "FB1";
|
|
16
|
+
/** Bytes from base64url text, or null if it is not that. */
|
|
17
|
+
export function fromBase64Url(text) {
|
|
18
|
+
if (!/^[A-Za-z0-9_-]*$/.test(text))
|
|
19
|
+
return null;
|
|
20
|
+
const padded = text.replace(/-/g, "+").replace(/_/g, "/") + "=".repeat((4 - (text.length % 4)) % 4);
|
|
21
|
+
let binary;
|
|
22
|
+
try {
|
|
23
|
+
binary = atob(padded);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const bytes = new Uint8Array(new ArrayBuffer(binary.length));
|
|
29
|
+
for (let index = 0; index < binary.length; index += 1)
|
|
30
|
+
bytes[index] = binary.charCodeAt(index);
|
|
31
|
+
return bytes;
|
|
32
|
+
}
|
|
33
|
+
function isPayload(value) {
|
|
34
|
+
if (typeof value !== "object" || value === null)
|
|
35
|
+
return false;
|
|
36
|
+
const payload = value;
|
|
37
|
+
const whole = (n) => typeof n === "number" && Number.isSafeInteger(n) && n >= 0;
|
|
38
|
+
return (payload.v === 1 &&
|
|
39
|
+
typeof payload.id === "string" &&
|
|
40
|
+
payload.id.length > 0 &&
|
|
41
|
+
payload.id.length <= 32 &&
|
|
42
|
+
typeof payload.d === "string" &&
|
|
43
|
+
payload.d.length > 0 &&
|
|
44
|
+
payload.d.length <= 253 &&
|
|
45
|
+
whole(payload.iat) &&
|
|
46
|
+
(payload.exp === undefined || whole(payload.exp)));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Splits a key into its payload and signature. Spaces and line breaks are ignored, because keys
|
|
50
|
+
* get pasted from emails and wrapped. Returns null for anything that is not shaped like a key.
|
|
51
|
+
* Nothing in the result can be trusted until the signature has been checked.
|
|
52
|
+
*/
|
|
53
|
+
export function parseLicenseKey(input) {
|
|
54
|
+
const text = input.replace(/\s+/g, "");
|
|
55
|
+
const parts = text.split(".");
|
|
56
|
+
if (parts.length !== 3 || parts[0] !== LICENSE_KEY_PREFIX)
|
|
57
|
+
return null;
|
|
58
|
+
const [prefix, encodedPayload, encodedSignature] = parts;
|
|
59
|
+
const payloadBytes = fromBase64Url(encodedPayload);
|
|
60
|
+
const signature = fromBase64Url(encodedSignature);
|
|
61
|
+
if (!payloadBytes || !signature || signature.length !== 64)
|
|
62
|
+
return null;
|
|
63
|
+
let payload;
|
|
64
|
+
try {
|
|
65
|
+
payload = JSON.parse(new TextDecoder().decode(payloadBytes));
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
if (!isPayload(payload))
|
|
71
|
+
return null;
|
|
72
|
+
return { payload, signedText: `${prefix}.${encodedPayload}`, signature };
|
|
73
|
+
}
|
|
74
|
+
/** A host name or domain in the form that is compared: lower case, with no brackets or trailing dot. */
|
|
75
|
+
export function normalizeHost(value) {
|
|
76
|
+
return value.trim().toLowerCase().replace(/^\[|\]$/g, "").replace(/\.+$/, "");
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Whether `host` is `domain` or one of its subdomains. A key for `example.com` covers
|
|
80
|
+
* `www.example.com` and `app.example.com`, and not `notexample.com`. A domain with a single label
|
|
81
|
+
* (`com`, `intranet`) matches only itself, so a key can never cover a whole top-level domain.
|
|
82
|
+
*/
|
|
83
|
+
export function hostMatchesDomain(host, domain) {
|
|
84
|
+
const h = normalizeHost(host);
|
|
85
|
+
const d = normalizeHost(domain);
|
|
86
|
+
if (h === "" || d === "")
|
|
87
|
+
return false;
|
|
88
|
+
if (h === d)
|
|
89
|
+
return true;
|
|
90
|
+
return d.includes(".") && h.endsWith(`.${d}`);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Whether the viewer runs on a developer's own machine or network: there is no website to check a
|
|
94
|
+
* key against, and a warning on every `npm run dev` would only train people to ignore it. This
|
|
95
|
+
* covers `localhost`, loopback and private-network addresses, `*.local`, `*.test`, `*.internal`,
|
|
96
|
+
* and pages that are not on a host at all (`file:`).
|
|
97
|
+
*/
|
|
98
|
+
export function isDevelopmentHost(host) {
|
|
99
|
+
const h = normalizeHost(host);
|
|
100
|
+
if (h === "")
|
|
101
|
+
return true;
|
|
102
|
+
if (h === "localhost" || /\.(localhost|local|test|internal)$/.test(h))
|
|
103
|
+
return true;
|
|
104
|
+
const v4 = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(h);
|
|
105
|
+
if (v4) {
|
|
106
|
+
const a = Number(v4[1]);
|
|
107
|
+
const b = Number(v4[2]);
|
|
108
|
+
return (a === 0 || a === 10 || a === 127 || (a === 169 && b === 254) || (a === 172 && b >= 16 && b <= 31) || (a === 192 && b === 168));
|
|
109
|
+
}
|
|
110
|
+
if (h.includes(":"))
|
|
111
|
+
return h === "::" || h === "::1" || /^f[cd][0-9a-f]{2}:/.test(h) || /^fe[89ab][0-9a-f]:/.test(h);
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/license/format.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAUxC,4DAA4D;AAC5D,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAChD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACpG,IAAI,MAAc,CAAC;IACnB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC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AO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { checkLicense, currentHostname, resetLicenseChecks } from "./check.js";
|
|
2
|
+
export { LICENSE_KEY_PREFIX, hostMatchesDomain, isDevelopmentHost, normalizeHost, parseLicenseKey, } from "./format.js";
|
|
3
|
+
export type { ParsedLicenseKey } from "./format.js";
|
|
4
|
+
export { LICENSE_PUBLIC_KEY } from "./publicKey.js";
|
|
5
|
+
export { REVOKED_LICENSE_IDS } from "./revoked.js";
|
|
6
|
+
export type { LicensePayload, LicenseProblem, LicensePublicKey, LicenseStatus } from "./types.js";
|
|
7
|
+
export { verifyLicense } from "./verify.js";
|
|
8
|
+
export type { VerifyLicenseOptions } from "./verify.js";
|
|
9
|
+
export { LICENSE_INFO_URL, describeLicense, resetLicenseWarnings, warnAboutLicense } from "./warn.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/license/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAClG,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { checkLicense, currentHostname, resetLicenseChecks } from "./check.js";
|
|
2
|
+
export { LICENSE_KEY_PREFIX, hostMatchesDomain, isDevelopmentHost, normalizeHost, parseLicenseKey, } from "./format.js";
|
|
3
|
+
export { LICENSE_PUBLIC_KEY } from "./publicKey.js";
|
|
4
|
+
export { REVOKED_LICENSE_IDS } from "./revoked.js";
|
|
5
|
+
export { verifyLicense } from "./verify.js";
|
|
6
|
+
export { LICENSE_INFO_URL, describeLicense, resetLicenseWarnings, warnAboutLicense } from "./warn.js";
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/license/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LicensePublicKey } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The half of the signing key that checks license keys. It is not a secret: it goes out in every
|
|
4
|
+
* copy of the package, and it can only check keys, never make them.
|
|
5
|
+
*
|
|
6
|
+
* Written by `npm run license -- init`. A build with no key here (`null`) accepts no license key at
|
|
7
|
+
* all, and `npm run verify:release` refuses to publish it.
|
|
8
|
+
*/
|
|
9
|
+
export declare const LICENSE_PUBLIC_KEY: LicensePublicKey | null;
|
|
10
|
+
//# sourceMappingURL=publicKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publicKey.d.ts","sourceRoot":"","sources":["../../src/license/publicKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,GAAG,IAKnD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The half of the signing key that checks license keys. It is not a secret: it goes out in every
|
|
3
|
+
* copy of the package, and it can only check keys, never make them.
|
|
4
|
+
*
|
|
5
|
+
* Written by `npm run license -- init`. A build with no key here (`null`) accepts no license key at
|
|
6
|
+
* all, and `npm run verify:release` refuses to publish it.
|
|
7
|
+
*/
|
|
8
|
+
export const LICENSE_PUBLIC_KEY = {
|
|
9
|
+
kty: "EC",
|
|
10
|
+
crv: "P-256",
|
|
11
|
+
x: "Jq6blXQje0K12yUu6S6fOWFJSDvju2JIjAYmbzTIB2E",
|
|
12
|
+
y: "M5acONLudl9xHsvDa2J5XYVTfgWYTlZnRwgD6dRb7Wk",
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=publicKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publicKey.js","sourceRoot":"","sources":["../../src/license/publicKey.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA4B;IACzD,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,OAAO;IACZ,CAAC,EAAE,6CAA6C;IAChD,CAAC,EAAE,6CAA6C;CACjD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serial numbers of license keys that have been withdrawn. A key cannot be recalled once it is
|
|
3
|
+
* sent, so a withdrawal reaches a website with the next release of the package that it installs.
|
|
4
|
+
*
|
|
5
|
+
* This file is written by `npm run license -- revoke <id>`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const REVOKED_LICENSE_IDS: readonly string[];
|
|
8
|
+
//# sourceMappingURL=revoked.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revoked.d.ts","sourceRoot":"","sources":["../../src/license/revoked.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAAO,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serial numbers of license keys that have been withdrawn. A key cannot be recalled once it is
|
|
3
|
+
* sent, so a withdrawal reaches a website with the next release of the package that it installs.
|
|
4
|
+
*
|
|
5
|
+
* This file is written by `npm run license -- revoke <id>`.
|
|
6
|
+
*/
|
|
7
|
+
export const REVOKED_LICENSE_IDS = [];
|
|
8
|
+
//# sourceMappingURL=revoked.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revoked.js","sourceRoot":"","sources":["../../src/license/revoked.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** Why a license key does not unlock the viewer. */
|
|
2
|
+
export type LicenseProblem =
|
|
3
|
+
/** No key was given. */
|
|
4
|
+
"missing"
|
|
5
|
+
/** The text is not a license key: cut off, mistyped, or not ours. */
|
|
6
|
+
| "malformed"
|
|
7
|
+
/** The key was not signed by the author of next-flipbook. */
|
|
8
|
+
| "signature"
|
|
9
|
+
/** The key is genuine, but for another website. */
|
|
10
|
+
| "domain"
|
|
11
|
+
/** The key is genuine and for this website, but its end date has passed. */
|
|
12
|
+
| "expired"
|
|
13
|
+
/** The key was withdrawn by the author. */
|
|
14
|
+
| "revoked"
|
|
15
|
+
/** This build of the package has no public key to check keys against. */
|
|
16
|
+
| "no-public-key";
|
|
17
|
+
/**
|
|
18
|
+
* What the license check found, for the website the viewer is running on.
|
|
19
|
+
*
|
|
20
|
+
* Only `unlicensed` changes what the reader sees: the viewer shows a watermark. It never stops
|
|
21
|
+
* working, whatever the state.
|
|
22
|
+
*/
|
|
23
|
+
export type LicenseStatus =
|
|
24
|
+
/** Not checked yet: on the server, and in the first moment in the browser. */
|
|
25
|
+
{
|
|
26
|
+
state: "pending";
|
|
27
|
+
}
|
|
28
|
+
/** A local or private-network address (`localhost`, `192.168.x.x`, `*.local`, ...). Nothing to check. */
|
|
29
|
+
| {
|
|
30
|
+
state: "development";
|
|
31
|
+
host: string;
|
|
32
|
+
}
|
|
33
|
+
/** A genuine key for this website. */
|
|
34
|
+
| {
|
|
35
|
+
state: "licensed";
|
|
36
|
+
id: string;
|
|
37
|
+
domain: string;
|
|
38
|
+
expiresAt: number | null;
|
|
39
|
+
}
|
|
40
|
+
/** The key could not be checked here, because the browser has no `crypto.subtle` (plain HTTP). */
|
|
41
|
+
| {
|
|
42
|
+
state: "unverified";
|
|
43
|
+
host: string;
|
|
44
|
+
reason: "no-webcrypto";
|
|
45
|
+
}
|
|
46
|
+
/** No key, or one that does not unlock this website. */
|
|
47
|
+
| {
|
|
48
|
+
state: "unlicensed";
|
|
49
|
+
host: string;
|
|
50
|
+
reason: LicenseProblem;
|
|
51
|
+
/** For `domain`: the website the key was issued for. */
|
|
52
|
+
licensedFor?: string;
|
|
53
|
+
/** For `expired`: when it ended, in milliseconds since 1970. */
|
|
54
|
+
expiredAt?: number;
|
|
55
|
+
};
|
|
56
|
+
/** The signing key's public half, as the JSON Web Key that `crypto.subtle` imports. */
|
|
57
|
+
export interface LicensePublicKey {
|
|
58
|
+
kty: "EC";
|
|
59
|
+
crv: "P-256";
|
|
60
|
+
x: string;
|
|
61
|
+
y: string;
|
|
62
|
+
}
|
|
63
|
+
/** What a key says, once its signature has been checked. */
|
|
64
|
+
export interface LicensePayload {
|
|
65
|
+
/** The format version. */
|
|
66
|
+
v: 1;
|
|
67
|
+
/** The serial number, such as `fb-0003`. Revoking a key names it. */
|
|
68
|
+
id: string;
|
|
69
|
+
/** The website the key is for, such as `example.com`. It covers the subdomains too. */
|
|
70
|
+
d: string;
|
|
71
|
+
/** When the key was issued, in seconds since 1970. */
|
|
72
|
+
iat: number;
|
|
73
|
+
/** When the key ends, in seconds since 1970. A key without it never ends. */
|
|
74
|
+
exp?: number;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/license/types.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,MAAM,cAAc;AACxB,wBAAwB;AACtB,SAAS;AACX,qEAAqE;GACnE,WAAW;AACb,6DAA6D;GAC3D,WAAW;AACb,mDAAmD;GACjD,QAAQ;AACV,4EAA4E;GAC1E,SAAS;AACX,2CAA2C;GACzC,SAAS;AACX,yEAAyE;GACvE,eAAe,CAAC;AAEpB;;;;;GAKG;AACH,MAAM,MAAM,aAAa;AACvB,8EAA8E;AAC5E;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE;AACtB,yGAAyG;GACvG;IAAE,KAAK,EAAE,aAAa,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AACxC,sCAAsC;GACpC;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE;AAC7E,kGAAkG;GAChG;IAAE,KAAK,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,cAAc,CAAA;CAAE;AAC/D,wDAAwD;GACtD;IACE,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,EAAE,MA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