treadwheel 1.0.0 → 1.0.2

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.
Files changed (58) hide show
  1. package/README.md +13 -25
  2. package/dist/browser/codec.d.ts +0 -1
  3. package/dist/browser/codec.js +0 -1
  4. package/dist/browser/index.d.ts +0 -1
  5. package/dist/browser/index.js +2 -1
  6. package/dist/browser/widget.d.ts +0 -1
  7. package/dist/browser/widget.js +0 -1
  8. package/dist/browser/worker.d.ts +0 -1
  9. package/dist/browser/worker.js +0 -1
  10. package/dist/core/cipher.d.ts +0 -1
  11. package/dist/core/cipher.js +0 -1
  12. package/dist/core/defaults.d.ts +0 -1
  13. package/dist/core/defaults.js +0 -1
  14. package/dist/core/index.d.ts +0 -1
  15. package/dist/core/index.js +0 -1
  16. package/dist/core/io.d.ts +0 -1
  17. package/dist/core/io.js +0 -1
  18. package/dist/core/puzzle.d.ts +0 -1
  19. package/dist/core/puzzle.js +0 -1
  20. package/dist/core/types.d.ts +0 -1
  21. package/dist/core/types.js +0 -1
  22. package/dist/node/cli.d.ts +0 -1
  23. package/dist/node/cli.js +0 -1
  24. package/dist/node/index.d.ts +0 -1
  25. package/dist/node/index.js +0 -1
  26. package/dist/node/worker.d.ts +0 -1
  27. package/dist/node/worker.js +0 -1
  28. package/dist/treadwheel-widget.min.js +1 -1
  29. package/dist/treadwheel-widget.min.js.map +1 -1
  30. package/dist/treadwheel.min.js +1 -1
  31. package/dist/treadwheel.min.js.map +1 -1
  32. package/package.json +8 -4
  33. package/dist/browser/codec.d.ts.map +0 -1
  34. package/dist/browser/codec.js.map +0 -1
  35. package/dist/browser/index.d.ts.map +0 -1
  36. package/dist/browser/index.js.map +0 -1
  37. package/dist/browser/widget.d.ts.map +0 -1
  38. package/dist/browser/widget.js.map +0 -1
  39. package/dist/browser/worker.d.ts.map +0 -1
  40. package/dist/browser/worker.js.map +0 -1
  41. package/dist/core/cipher.d.ts.map +0 -1
  42. package/dist/core/cipher.js.map +0 -1
  43. package/dist/core/defaults.d.ts.map +0 -1
  44. package/dist/core/defaults.js.map +0 -1
  45. package/dist/core/index.d.ts.map +0 -1
  46. package/dist/core/index.js.map +0 -1
  47. package/dist/core/io.d.ts.map +0 -1
  48. package/dist/core/io.js.map +0 -1
  49. package/dist/core/puzzle.d.ts.map +0 -1
  50. package/dist/core/puzzle.js.map +0 -1
  51. package/dist/core/types.d.ts.map +0 -1
  52. package/dist/core/types.js.map +0 -1
  53. package/dist/node/cli.d.ts.map +0 -1
  54. package/dist/node/cli.js.map +0 -1
  55. package/dist/node/index.d.ts.map +0 -1
  56. package/dist/node/index.js.map +0 -1
  57. package/dist/node/worker.d.ts.map +0 -1
  58. package/dist/node/worker.js.map +0 -1
package/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Treadwheel
2
2
 
3
+ [![NPM Version](https://img.shields.io/npm/v/treadwheel)](https://www.npmjs.com/package/treadwheel)
4
+ [![CI](https://github.com/jo-phil/treadwheel/actions/workflows/ci.yml/badge.svg)](https://github.com/jo-phil/treadwheel/actions/workflows/ci.yml)
5
+ [![Docs](https://github.com/jo-phil/treadwheel/actions/workflows/docs.yml/badge.svg)](https://jo-phil.github.io/treadwheel/)
6
+
3
7
  Treadwheel uses time-lock puzzles based on
4
8
  [Rivest, Shamir, and Wagner (1996)](https://people.csail.mit.edu/rivest/pubs/RSW96.pdf)
5
9
  to protect information from bots while keeping access simple for humans.
@@ -30,8 +34,8 @@ npm i treadwheel
30
34
  ## Usage
31
35
 
32
36
  This section explains how to seal plaintext using the CLI and integrate a widget
33
- to unseal it in a web application. For programmatic usage, see the
34
- [API Reference](docs/api.md).
37
+ to unseal it in a web application. For advanced configuration and full API
38
+ details, see the [Documentation](https://jo-phil.github.io/treadwheel/).
35
39
 
36
40
  ### 1. Sealing plaintext
37
41
 
@@ -42,23 +46,22 @@ npx treadwheel seal "Hello, World!"
42
46
  ```
43
47
 
44
48
  This outputs a Base64URL-encoded envelope containing the time-lock puzzle and
45
- encrypted payload.
49
+ encrypted payload, which can be used for the `envelope` attribute of the widget.
46
50
 
47
- The puzzle's difficulty can be adjusted using the `--time` and
48
- `--modulus-length` options. The `--time` option specifies the number of
49
- sequential squarings required to solve the puzzle, while `--modulus-length`
50
- specifies the desired bit length of its modulus.
51
+ > [!TIP]
52
+ > The puzzle's difficulty can be adjusted with the `--time` option. See the
53
+ > [CLI Reference](https://jo-phil.github.io/treadwheel/cli) for details.
51
54
 
52
55
  ### 2. Importing the widget
53
56
 
54
- To use the widget in a client-side application, import the `treadwheel/widget`
55
- module:
57
+ To allow visitors to unseal the envelope on your website, register the
58
+ `<treadwheel-widget>` element by importing the `treadwheel/widget` module:
56
59
 
57
60
  ```javascript
58
61
  import 'treadwheel/widget';
59
62
  ```
60
63
 
61
- Alternatively, load it from a CDN with a script tag, e.g.:
64
+ Alternatively, use a script tag to load it from a CDN:
62
65
 
63
66
  ```html
64
67
  <script type="module" src="https://cdn.jsdelivr.net/npm/treadwheel@latest/dist/treadwheel-widget.min.js"></script>
@@ -72,21 +75,6 @@ Add a `<treadwheel-widget>` element with the envelope to your HTML document:
72
75
  <treadwheel-widget envelope="tw__..."></treadwheel-widget>
73
76
  ```
74
77
 
75
- If the plaintext contains HTML, set `output="html"` (only for envelopes from a
76
- trusted source):
77
-
78
- ```html
79
- <treadwheel-widget output="html" envelope="tw__..."></treadwheel-widget>
80
- ```
81
-
82
- To display the widget in a floating layout, include a button inside the element:
83
-
84
- ```html
85
- <treadwheel-widget envelope="tw__...">
86
- <button type="button">Click to reveal</button>
87
- </treadwheel-widget>
88
- ```
89
-
90
78
  ## License
91
79
 
92
80
  This project is licensed under the [Apache License 2.0](LICENSE).
@@ -1,3 +1,2 @@
1
1
  export declare function bytesToBase64Url(bytes: Uint8Array): string;
2
2
  export declare function base64UrlToBytes(base64Url: string): Uint8Array<ArrayBuffer>;
3
- //# sourceMappingURL=codec.d.ts.map
@@ -20,4 +20,3 @@ export function base64UrlToBytes(base64Url) {
20
20
  base64 += '=='.slice((base64.length + 2) % 4);
21
21
  return Uint8Array.from(atob(base64), (char) => char.charCodeAt(0));
22
22
  }
23
- //# sourceMappingURL=codec.js.map
@@ -23,4 +23,3 @@ export declare function unseal(envelope: string): Promise<string>;
23
23
  * @returns The decrypted plaintext.
24
24
  */
25
25
  export declare function unsealInWorker(envelope: string, options?: UnsealInWorkerOptions): Promise<string>;
26
- //# sourceMappingURL=index.d.ts.map
@@ -31,6 +31,8 @@ export async function seal(plaintext, options) {
31
31
  * @returns The decrypted plaintext.
32
32
  */
33
33
  export async function unseal(envelope) {
34
+ if (!globalThis.crypto?.subtle)
35
+ throw new Error('Web Crypto API is not available');
34
36
  return await unsealFromBytes(base64UrlToBytes(envelope));
35
37
  }
36
38
  /**
@@ -71,4 +73,3 @@ export function unsealInWorker(envelope, options) {
71
73
  worker.postMessage(envelope);
72
74
  });
73
75
  }
74
- //# sourceMappingURL=index.js.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=widget.d.ts.map
@@ -222,4 +222,3 @@ class TreadwheelWidget extends HTMLElement {
222
222
  }
223
223
  }
224
224
  customElements.define('treadwheel-widget', TreadwheelWidget);
225
- //# sourceMappingURL=widget.js.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=worker.d.ts.map
@@ -11,4 +11,3 @@ self.onmessage = async (e) => {
11
11
  });
12
12
  }
13
13
  };
14
- //# sourceMappingURL=worker.js.map
@@ -1,4 +1,3 @@
1
1
  import type { Cipher } from './types.js';
2
2
  export declare function encrypt(payload: Uint8Array<ArrayBuffer>, keyData: BufferSource): Promise<Cipher>;
3
3
  export declare function decrypt(cipher: Cipher, keyData: BufferSource): Promise<Uint8Array<ArrayBuffer>>;
4
- //# sourceMappingURL=cipher.d.ts.map
@@ -14,4 +14,3 @@ export async function decrypt(cipher, keyData) {
14
14
  const derivedKey = await deriveKey(keyData, cipher.salt);
15
15
  return new Uint8Array(await globalThis.crypto.subtle.decrypt({ name: 'AES-GCM', iv: cipher.iv }, derivedKey, cipher.ciphertext));
16
16
  }
17
- //# sourceMappingURL=cipher.js.map
@@ -1,3 +1,2 @@
1
1
  import type { SealOptions } from './types.js';
2
2
  export declare const SEAL_DEFAULTS: Required<SealOptions>;
3
- //# sourceMappingURL=defaults.d.ts.map
@@ -2,4 +2,3 @@ export const SEAL_DEFAULTS = {
2
2
  time: 250000,
3
3
  modulusLength: 2048,
4
4
  };
5
- //# sourceMappingURL=defaults.js.map
@@ -1,4 +1,3 @@
1
1
  import type { PuzzleParams } from './types.js';
2
2
  export declare function sealFromPrimes(plaintext: string, p: bigint, q: bigint, puzzleParams: PuzzleParams): Promise<Uint8Array<ArrayBuffer>>;
3
3
  export declare function unsealFromBytes(bytes: Uint8Array<ArrayBuffer>): Promise<string>;
4
- //# sourceMappingURL=index.d.ts.map
@@ -29,4 +29,3 @@ export async function unsealFromBytes(bytes) {
29
29
  }
30
30
  return decoder.decode(payload);
31
31
  }
32
- //# sourceMappingURL=index.js.map
package/dist/core/io.d.ts CHANGED
@@ -3,4 +3,3 @@ export declare function bytesToBigInt(bytes: Uint8Array): bigint;
3
3
  export declare function bigIntToBytes(bigint: bigint, byteLength: number): Uint8Array<ArrayBuffer>;
4
4
  export declare function envelopeToBytes({ v, modulusByteLength, time, modulus, base, salt, iv, ciphertext, }: Envelope): Uint8Array<ArrayBuffer>;
5
5
  export declare function bytesToEnvelope(bytes: Uint8Array<ArrayBuffer>): Envelope;
6
- //# sourceMappingURL=io.d.ts.map
package/dist/core/io.js CHANGED
@@ -110,4 +110,3 @@ export function bytesToEnvelope(bytes) {
110
110
  const ciphertext = reader.readBytes(ciphertextLength);
111
111
  return { v, modulusByteLength, time, modulus, base, salt, iv, ciphertext };
112
112
  }
113
- //# sourceMappingURL=io.js.map
@@ -4,4 +4,3 @@ export declare function mint(p: bigint, q: bigint, { time, modulusLength }: Puzz
4
4
  solution: bigint;
5
5
  };
6
6
  export declare function solve({ modulus, base, time }: Puzzle): bigint;
7
- //# sourceMappingURL=puzzle.d.ts.map
@@ -39,4 +39,3 @@ export function solve({ modulus, base, time }) {
39
39
  }
40
40
  return base;
41
41
  }
42
- //# sourceMappingURL=puzzle.js.map
@@ -38,4 +38,3 @@ export interface UnsealInWorkerOptions {
38
38
  */
39
39
  signal?: AbortSignal | undefined;
40
40
  }
41
- //# sourceMappingURL=types.d.ts.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=types.js.map
@@ -1,3 +1,2 @@
1
1
  #!/usr/bin/env node
2
2
  export {};
3
- //# sourceMappingURL=cli.d.ts.map
package/dist/node/cli.js CHANGED
@@ -134,4 +134,3 @@ catch (err) {
134
134
  process.stderr.write(`Error: ${err instanceof Error ? err.message : String(err)}\n`);
135
135
  process.exitCode = 1;
136
136
  }
137
- //# sourceMappingURL=cli.js.map
@@ -23,4 +23,3 @@ export declare function unseal(envelope: string): Promise<string>;
23
23
  * @returns The decrypted plaintext.
24
24
  */
25
25
  export declare function unsealInWorker(envelope: string, options?: UnsealInWorkerOptions): Promise<string>;
26
- //# sourceMappingURL=index.d.ts.map
@@ -69,4 +69,3 @@ export function unsealInWorker(envelope, options) {
69
69
  }
70
70
  });
71
71
  }
72
- //# sourceMappingURL=index.js.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=worker.d.ts.map
@@ -4,4 +4,3 @@ if (!parentPort)
4
4
  throw new Error('Failed to initialize worker port');
5
5
  const plaintext = await unseal(workerData);
6
6
  parentPort.postMessage(plaintext);
7
- //# sourceMappingURL=worker.js.map
@@ -1,2 +1,2 @@
1
- function e(e,t){return new Promise((n,r)=>{if(t?.signal?.aborted)return r(t.signal.reason);t?.signal?.addEventListener(`abort`,s);let i=URL.createObjectURL(new Blob(["(function(){let e=new TextEncoder().encode(`treadwheel-v1`);async function t(t,n){let r=await globalThis.crypto.subtle.importKey(`raw`,t,`HKDF`,!1,[`deriveKey`]);return await globalThis.crypto.subtle.deriveKey({name:`HKDF`,hash:`SHA-256`,salt:n,info:e},r,{name:`AES-GCM`,length:256},!1,[`encrypt`,`decrypt`])}async function n(e,n){let r=await t(n,e.salt);return new Uint8Array(await globalThis.crypto.subtle.decrypt({name:`AES-GCM`,iv:e.iv},r,e.ciphertext))}let r=new Uint8Array([183,15,255]);var i=class{constructor(e){this.offset=0,this.bytes=e,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}},a=class extends i{readUint8(){return this.view.getUint8(this.offset++)}readUint16(){let e=this.view.getUint16(this.offset);return this.offset+=2,e}readUint32(){let e=this.view.getUint32(this.offset);return this.offset+=4,e}readBigUInt64(){let e=this.view.getBigUint64(this.offset);return this.offset+=8,e}readBytes(e){let t=this.offset+e;if(t>this.bytes.byteLength)throw Error(`Malformed envelope: unexpected end of data`);let n=this.bytes.subarray(this.offset,t);return this.offset=t,n}};function o(e){let t=0n;for(let n=0;n<e.length;n++)t=t<<8n|BigInt(e[n]);return t}function s(e,t){let n=new Uint8Array(t);for(let r=0;r<t;r++){let i=BigInt((t-1-r)*8);n[r]=Number(e>>i&255n)}return n}function c(e){let t=new a(e);if(!t.readBytes(r.byteLength).every((e,t)=>e===r[t]))throw Error(`Invalid envelope: magic bytes mismatch`);let n=t.readUint8();if(n!==1)throw Error(`Unsupported envelope version ${n}`);let i=t.readUint16(),s=t.readUint32();return{v:n,modulusByteLength:i,time:t.readBigUInt64(),modulus:o(t.readBytes(i)),base:o(t.readBytes(i)),salt:t.readBytes(32),iv:t.readBytes(12),ciphertext:t.readBytes(s)}}function l({modulus:e,base:t,time:n}){for(let r=0n;r<n;r++)t=t*t%e;return t}new TextEncoder;let u=new TextDecoder;async function d(e){let t=c(e),r=s(l(t),t.modulusByteLength),i;try{i=await n(t,r)}finally{r.fill(0)}return u.decode(i)}function f(e){if(`fromBase64`in Uint8Array&&typeof Uint8Array.fromBase64==`function`)return Uint8Array.fromBase64(e,{alphabet:`base64url`});let t=e.replace(/-/g,`+`).replace(/_/g,`/`);return t+=`==`.slice((t.length+2)%4),Uint8Array.from(atob(t),e=>e.charCodeAt(0))}async function p(e){return await d(f(e))}self.onmessage=async e=>{try{let t=await p(e.data);self.postMessage({success:!0,plaintext:t})}catch(e){self.postMessage({success:!1,error:e instanceof Error?e:Error(String(e))})}}})();"],{type:`application/javascript`})),a=new Worker(i);URL.revokeObjectURL(i);let o=()=>{a.terminate(),t?.signal?.removeEventListener(`abort`,s)};a.onmessage=e=>{e.data.success?n(e.data.plaintext):r(e.data.error),o()},a.onerror=e=>{e.preventDefault(),r(e.error??Error(e.message)),o()};function s(e){r(e.target.reason),o()}a.postMessage(e)})}const t=String.raw,n=document.createElement(`template`);n.innerHTML=t`<style>article{all:initial;display:block;box-sizing:border-box;width:min(300px,100dvw);border:1px solid rgba(0,0,0,.12);border-radius:10px;color:#111;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.06);font-family:Inter,Roboto,"Helvetica Neue","Arial Nova","Nimbus Sans",Arial,sans-serif;font-size:16px;line-height:1.25;user-select:none}:host([layout=floating]){display:inline-block;position:relative}:host([layout=floating]) article{display:none;position:absolute;z-index:1000000;opacity:0;transition:opacity .2s ease-in .8s}:host([layout=floating][status]) article{display:block}:host([layout=floating][status=error]) article,:host([layout=floating][status=processing]) article{opacity:1;transition:opacity .1s ease-out}@supports (position-area:block-end span-inline-end){:host([layout=floating]){position:static;anchor-name:--host}:host([layout=floating]) article{position:fixed;position-anchor:--host;position-area:block-end span-inline-end;position-try-fallbacks:flip-inline}}button{all:unset;width:100%;cursor:pointer}button:focus-visible{outline:revert}:host([status]) #status,button{position:relative;box-sizing:border-box;min-height:46px;padding:16px 16px 10px 52px;border-radius:6px}:host([status]) button{display:none}:host([status=processing]) #status{cursor:wait}:host([status]) #status::before,button::before{content:'';position:absolute;left:14px;top:50%;width:24px;height:24px;margin-top:-10px;border:1px solid #bbb;border-radius:6px}:host([status=processing]) #status::before{border-radius:50%;border-color:transparent transparent #111 #111;animation:spin 1s linear infinite}:host([status=success]) #status::before{border-color:#16a34a;background-color:#16a34a;background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjZmZmIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+PHBhdGggZD0ibTE4IDgtOCA5LTQtNCIvPjwvc3ZnPg==")}:host([status=error]) #status::before{border-color:#dc2626;background-color:#dc2626;background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgc3Ryb2tlPSIjZmZmIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCI+PHBhdGggZD0iTTE3IDcgNyAxN003IDdsMTAgMTAiLz48L3N2Zz4=")}footer{text-align:right;font-size:12px;color:#666;padding:2px 9px 7px 9px}footer a{color:inherit;text-decoration:none}footer a:hover{text-decoration:underline}@keyframes spin{to{transform:rotate(360deg)}}</style><slot></slot><article><button type="button">I'm not a robot</button><div id="status" role="status"></div><footer>Protected by <a href="https://github.com/jo-phil/treadwheel" target="_blank" rel="noopener noreferrer">Treadwheel</a></footer></article>`;var r=class extends HTMLElement{constructor(){super(),this._shadow=this.attachShadow({mode:`open`}),this._handleClick=async t=>{if(!t.target?.closest(`button`))return;let n=this.getAttribute(`envelope`);if(!n)return;this.setAttribute(`status`,`processing`);let r=this._shadow.getElementById(`status`);r&&(r.textContent=`Verifying…`),this.querySelectorAll(`button`).forEach(e=>{e.disabled=!0});try{let t=await e(n,{signal:this._abortController?.signal});this.setAttribute(`status`,`success`),r&&(r.textContent=`Verified`);let i=document.createElement(`template`);this.getAttribute(`output`)===`html`?i.innerHTML=t:i.content.textContent=t,this.getAttribute(`layout`)===`floating`?(this.replaceChildren(i.content),this._shadow.addEventListener(`transitionend`,()=>this.replaceWith(...this.childNodes),{once:!0})):this.replaceWith(i.content)}catch(e){e instanceof DOMException&&e.name===`AbortError`?(this.removeAttribute(`status`),r&&(r.textContent=``),this.querySelectorAll(`button`).forEach(e=>{e.disabled=!1})):(this.setAttribute(`status`,`error`),r&&(r.textContent=`Verification failed`))}},this._shadow.appendChild(n.content.cloneNode(!0)),this._shadow.addEventListener(`click`,this._handleClick),this._shadow.querySelector(`slot`)?.addEventListener(`slotchange`,()=>{this.hasAttribute(`layout`)||this.querySelector(`button`)&&this.setAttribute(`layout`,`floating`)},{once:!0})}connectedCallback(){this._abortController=new AbortController}disconnectedCallback(){this._abortController?.abort()}};customElements.define(`treadwheel-widget`,r);
1
+ function e(e,t){return new Promise((n,r)=>{if(t?.signal?.aborted)return r(t.signal.reason);t?.signal?.addEventListener(`abort`,s);let i=URL.createObjectURL(new Blob(["(function(){let e=new TextEncoder().encode(`treadwheel-v1`);async function t(t,n){let r=await globalThis.crypto.subtle.importKey(`raw`,t,`HKDF`,!1,[`deriveKey`]);return await globalThis.crypto.subtle.deriveKey({name:`HKDF`,hash:`SHA-256`,salt:n,info:e},r,{name:`AES-GCM`,length:256},!1,[`encrypt`,`decrypt`])}async function n(e,n){let r=await t(n,e.salt);return new Uint8Array(await globalThis.crypto.subtle.decrypt({name:`AES-GCM`,iv:e.iv},r,e.ciphertext))}let r=new Uint8Array([183,15,255]);var i=class{constructor(e){this.offset=0,this.bytes=e,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}},a=class extends i{readUint8(){return this.view.getUint8(this.offset++)}readUint16(){let e=this.view.getUint16(this.offset);return this.offset+=2,e}readUint32(){let e=this.view.getUint32(this.offset);return this.offset+=4,e}readBigUInt64(){let e=this.view.getBigUint64(this.offset);return this.offset+=8,e}readBytes(e){let t=this.offset+e;if(t>this.bytes.byteLength)throw Error(`Malformed envelope: unexpected end of data`);let n=this.bytes.subarray(this.offset,t);return this.offset=t,n}};function o(e){let t=0n;for(let n=0;n<e.length;n++)t=t<<8n|BigInt(e[n]);return t}function s(e,t){let n=new Uint8Array(t);for(let r=0;r<t;r++){let i=BigInt((t-1-r)*8);n[r]=Number(e>>i&255n)}return n}function c(e){let t=new a(e);if(!t.readBytes(r.byteLength).every((e,t)=>e===r[t]))throw Error(`Invalid envelope: magic bytes mismatch`);let n=t.readUint8();if(n!==1)throw Error(`Unsupported envelope version ${n}`);let i=t.readUint16(),s=t.readUint32();return{v:n,modulusByteLength:i,time:t.readBigUInt64(),modulus:o(t.readBytes(i)),base:o(t.readBytes(i)),salt:t.readBytes(32),iv:t.readBytes(12),ciphertext:t.readBytes(s)}}function l({modulus:e,base:t,time:n}){for(let r=0n;r<n;r++)t=t*t%e;return t}new TextEncoder;let u=new TextDecoder;async function d(e){let t=c(e),r=s(l(t),t.modulusByteLength),i;try{i=await n(t,r)}finally{r.fill(0)}return u.decode(i)}function f(e){if(`fromBase64`in Uint8Array&&typeof Uint8Array.fromBase64==`function`)return Uint8Array.fromBase64(e,{alphabet:`base64url`});let t=e.replace(/-/g,`+`).replace(/_/g,`/`);return t+=`==`.slice((t.length+2)%4),Uint8Array.from(atob(t),e=>e.charCodeAt(0))}async function p(e){if(!globalThis.crypto?.subtle)throw Error(`Web Crypto API is not available`);return await d(f(e))}self.onmessage=async e=>{try{let t=await p(e.data);self.postMessage({success:!0,plaintext:t})}catch(e){self.postMessage({success:!1,error:e instanceof Error?e:Error(String(e))})}}})();"],{type:`application/javascript`})),a=new Worker(i);URL.revokeObjectURL(i);let o=()=>{a.terminate(),t?.signal?.removeEventListener(`abort`,s)};a.onmessage=e=>{e.data.success?n(e.data.plaintext):r(e.data.error),o()},a.onerror=e=>{e.preventDefault(),r(e.error??Error(e.message)),o()};function s(e){r(e.target.reason),o()}a.postMessage(e)})}const t=String.raw,n=document.createElement(`template`);n.innerHTML=t`<style>article{all:initial;display:block;box-sizing:border-box;width:min(300px,100dvw);border:1px solid rgba(0,0,0,.12);border-radius:10px;color:#111;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.06);font-family:Inter,Roboto,"Helvetica Neue","Arial Nova","Nimbus Sans",Arial,sans-serif;font-size:16px;line-height:1.25;user-select:none}:host([layout=floating]){display:inline-block;position:relative}:host([layout=floating]) article{display:none;position:absolute;z-index:1000000;opacity:0;transition:opacity .2s ease-in .8s}:host([layout=floating][status]) article{display:block}:host([layout=floating][status=error]) article,:host([layout=floating][status=processing]) article{opacity:1;transition:opacity .1s ease-out}@supports (position-area:block-end span-inline-end){:host([layout=floating]){position:static;anchor-name:--host}:host([layout=floating]) article{position:fixed;position-anchor:--host;position-area:block-end span-inline-end;position-try-fallbacks:flip-inline}}button{all:unset;width:100%;cursor:pointer}button:focus-visible{outline:revert}:host([status]) #status,button{position:relative;box-sizing:border-box;min-height:46px;padding:16px 16px 10px 52px;border-radius:6px}:host([status]) button{display:none}:host([status=processing]) #status{cursor:wait}:host([status]) #status::before,button::before{content:'';position:absolute;left:14px;top:50%;width:24px;height:24px;margin-top:-10px;border:1px solid #bbb;border-radius:6px}:host([status=processing]) #status::before{border-radius:50%;border-color:transparent transparent #111 #111;animation:spin 1s linear infinite}:host([status=success]) #status::before{border-color:#16a34a;background-color:#16a34a;background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjZmZmIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+PHBhdGggZD0ibTE4IDgtOCA5LTQtNCIvPjwvc3ZnPg==")}:host([status=error]) #status::before{border-color:#dc2626;background-color:#dc2626;background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgc3Ryb2tlPSIjZmZmIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCI+PHBhdGggZD0iTTE3IDcgNyAxN003IDdsMTAgMTAiLz48L3N2Zz4=")}footer{text-align:right;font-size:12px;color:#666;padding:2px 9px 7px 9px}footer a{color:inherit;text-decoration:none}footer a:hover{text-decoration:underline}@keyframes spin{to{transform:rotate(360deg)}}</style><slot></slot><article><button type="button">I'm not a robot</button><div id="status" role="status"></div><footer>Protected by <a href="https://github.com/jo-phil/treadwheel" target="_blank" rel="noopener noreferrer">Treadwheel</a></footer></article>`;var r=class extends HTMLElement{constructor(){super(),this._shadow=this.attachShadow({mode:`open`}),this._handleClick=async t=>{if(!t.target?.closest(`button`))return;let n=this.getAttribute(`envelope`);if(!n)return;this.setAttribute(`status`,`processing`);let r=this._shadow.getElementById(`status`);r&&(r.textContent=`Verifying…`),this.querySelectorAll(`button`).forEach(e=>{e.disabled=!0});try{let t=await e(n,{signal:this._abortController?.signal});this.setAttribute(`status`,`success`),r&&(r.textContent=`Verified`);let i=document.createElement(`template`);this.getAttribute(`output`)===`html`?i.innerHTML=t:i.content.textContent=t,this.getAttribute(`layout`)===`floating`?(this.replaceChildren(i.content),this._shadow.addEventListener(`transitionend`,()=>this.replaceWith(...this.childNodes),{once:!0})):this.replaceWith(i.content)}catch(e){e instanceof DOMException&&e.name===`AbortError`?(this.removeAttribute(`status`),r&&(r.textContent=``),this.querySelectorAll(`button`).forEach(e=>{e.disabled=!1})):(this.setAttribute(`status`,`error`),r&&(r.textContent=`Verification failed`))}},this._shadow.appendChild(n.content.cloneNode(!0)),this._shadow.addEventListener(`click`,this._handleClick),this._shadow.querySelector(`slot`)?.addEventListener(`slotchange`,()=>{this.hasAttribute(`layout`)||this.querySelector(`button`)&&this.setAttribute(`layout`,`floating`)},{once:!0})}connectedCallback(){this._abortController=new AbortController}disconnectedCallback(){this._abortController?.abort()}};customElements.define(`treadwheel-widget`,r);
2
2
  //# sourceMappingURL=treadwheel-widget.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"treadwheel-widget.min.js","names":["unsealInWorker","options","reject","handleAbort","url","worker","cleanup","event","resolve","errorEvent","envelope","html","template","TreadwheelWidget","e","status","plaintext","output","error"],"sources":["../src/browser/index.ts","../src/browser/widget.ts"],"sourcesContent":["import { SEAL_DEFAULTS } from '../core/defaults.js';\nimport { sealFromPrimes, unsealFromBytes } from '../core/index.js';\nimport { bytesToBigInt } from '../core/io.js';\nimport type { SealOptions, UnsealInWorkerOptions } from '../core/types.js';\nimport { base64UrlToBytes, bytesToBase64Url } from './codec.js';\n\nexport type { SealOptions, UnsealInWorkerOptions };\n\n/**\n * Seal plaintext using a time-lock puzzle.\n *\n * @param plaintext - The plaintext to seal.\n * @param options - Optional configuration options.\n * @returns A Base64URL-encoded envelope.\n */\nexport async function seal(\n plaintext: string,\n options?: SealOptions,\n): Promise<string> {\n const config = { ...SEAL_DEFAULTS, ...options };\n\n const keyPair = await globalThis.crypto.subtle.generateKey(\n {\n name: 'RSA-OAEP',\n modulusLength: config.modulusLength,\n publicExponent: new Uint8Array([0x01, 0x00, 0x01]),\n hash: 'SHA-256',\n },\n true,\n ['decrypt'],\n );\n const jwk = await globalThis.crypto.subtle.exportKey(\n 'jwk',\n keyPair.privateKey,\n );\n\n if (!jwk.p || !jwk.q) throw new Error('RSA JWK is missing primes p or q');\n const p = bytesToBigInt(base64UrlToBytes(jwk.p));\n const q = bytesToBigInt(base64UrlToBytes(jwk.q));\n\n return bytesToBase64Url(await sealFromPrimes(plaintext, p, q, config));\n}\n\n/**\n * Unseal an envelope by solving its time-lock puzzle.\n *\n * @param envelope - A Base64URL-encoded envelope.\n * @returns The decrypted plaintext.\n */\nexport async function unseal(envelope: string): Promise<string> {\n return await unsealFromBytes(base64UrlToBytes(envelope));\n}\n\n/**\n * Unseal an envelope in a web worker.\n *\n * @param envelope - A Base64URL-encoded envelope.\n * @param options - Optional configuration options.\n * @returns The decrypted plaintext.\n */\nexport function unsealInWorker(\n envelope: string,\n options?: UnsealInWorkerOptions,\n): Promise<string> {\n return new Promise((resolve, reject) => {\n if (options?.signal?.aborted) return reject(options.signal.reason);\n options?.signal?.addEventListener('abort', handleAbort);\n\n const worker = new Worker(new URL('./worker.js', import.meta.url), {\n type: 'module',\n });\n\n const cleanup = () => {\n worker.terminate();\n options?.signal?.removeEventListener('abort', handleAbort);\n };\n\n worker.onmessage = (event) => {\n if (event.data.success) resolve(event.data.plaintext);\n else reject(event.data.error);\n cleanup();\n };\n\n worker.onerror = (errorEvent) => {\n errorEvent.preventDefault();\n reject(errorEvent.error ?? new Error(errorEvent.message));\n cleanup();\n };\n\n function handleAbort(event: Event) {\n reject((event.target as AbortSignal).reason);\n cleanup();\n }\n\n worker.postMessage(envelope);\n });\n}\n","import { unsealInWorker } from './index.js';\n\nconst html = String.raw;\n\nconst template = document.createElement('template');\ntemplate.innerHTML = html`\n <style>\n article {\n all: initial;\n display: block;\n box-sizing: border-box;\n width: min(300px, 100dvw);\n border: 1px solid rgba(0, 0, 0, 0.12);\n border-radius: 10px;\n color: #111;\n background: #fff;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);\n font-family:\n Inter, Roboto, \"Helvetica Neue\", \"Arial Nova\", \"Nimbus Sans\", Arial,\n sans-serif;\n font-size: 16px;\n line-height: 1.25;\n user-select: none;\n }\n\n :host([layout=\"floating\"]) {\n display: inline-block;\n position: relative;\n }\n\n :host([layout=\"floating\"]) article {\n display: none;\n position: absolute;\n z-index: 1000000;\n opacity: 0;\n transition: opacity .2s ease-in .8s;\n }\n\n :host([layout=\"floating\"][status]) article {\n display: block;\n }\n\n :host([layout=\"floating\"][status=\"processing\"]) article,\n :host([layout=\"floating\"][status=\"error\"]) article {\n opacity: 1;\n transition: opacity .1s ease-out;\n }\n\n @supports (position-area: block-end span-inline-end) {\n :host([layout=\"floating\"]) {\n position: static;\n anchor-name: --host;\n }\n\n :host([layout=\"floating\"]) article {\n position: fixed;\n position-anchor: --host;\n position-area: block-end span-inline-end;\n position-try-fallbacks: flip-inline;\n }\n }\n\n button {\n all: unset;\n width: 100%;\n cursor: pointer;\n }\n\n button:focus-visible {\n outline: revert;\n }\n\n button, :host([status]) #status {\n position: relative;\n box-sizing: border-box;\n min-height: 46px;\n padding: 16px 16px 10px 52px;\n border-radius: 6px;\n }\n\n :host([status]) button {\n display: none;\n }\n\n :host([status=\"processing\"]) #status {\n cursor: wait;\n }\n\n button::before, :host([status]) #status::before {\n content: '';\n position: absolute;\n left: 14px;\n top: 50%;\n width: 24px;\n height: 24px;\n margin-top: -10px;\n border: 1px solid #bbb;\n border-radius: 6px;\n }\n\n :host([status=\"processing\"]) #status::before {\n border-radius: 50%;\n border-color: transparent transparent #111 #111;\n animation: spin 1s linear infinite;\n }\n\n :host([status=\"success\"]) #status::before {\n border-color: #16a34a;\n background-color: #16a34a;\n background-image: url(\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjZmZmIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+PHBhdGggZD0ibTE4IDgtOCA5LTQtNCIvPjwvc3ZnPg==\");\n }\n\n :host([status=\"error\"]) #status::before {\n border-color: #dc2626;\n background-color: #dc2626;\n background-image: url(\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgc3Ryb2tlPSIjZmZmIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCI+PHBhdGggZD0iTTE3IDcgNyAxN003IDdsMTAgMTAiLz48L3N2Zz4=\");\n }\n\n footer {\n text-align: right;\n font-size: 12px;\n color: #666;\n padding: 2px 9px 7px 9px;\n }\n\n footer a {\n color: inherit;\n text-decoration: none;\n }\n\n footer a:hover {\n text-decoration: underline;\n }\n\n @keyframes spin { to { transform: rotate(360deg); } }\n </style>\n <slot></slot>\n <article>\n <button type=\"button\">I'm not a robot</button>\n <div id=\"status\" role=\"status\"></div>\n <footer>\n Protected by\n <a\n href=\"https://github.com/jo-phil/treadwheel\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n Treadwheel\n </a>\n </footer>\n </article>\n`;\n\nclass TreadwheelWidget extends HTMLElement {\n private _shadow = this.attachShadow({ mode: 'open' });\n private _abortController?: AbortController;\n\n constructor() {\n super();\n\n this._shadow.appendChild(template.content.cloneNode(true));\n this._shadow.addEventListener('click', this._handleClick);\n this._shadow.querySelector('slot')?.addEventListener(\n 'slotchange',\n () => {\n if (this.hasAttribute('layout')) return;\n if (this.querySelector('button')) {\n this.setAttribute('layout', 'floating');\n }\n },\n { once: true },\n );\n }\n\n connectedCallback() {\n this._abortController = new AbortController();\n }\n\n disconnectedCallback() {\n this._abortController?.abort();\n }\n\n private _handleClick = async (e: Event) => {\n const target = e.target as HTMLElement | null;\n if (!target?.closest('button')) return;\n\n const envelope = this.getAttribute('envelope');\n if (!envelope) return;\n\n this.setAttribute('status', 'processing');\n const status = this._shadow.getElementById('status');\n if (status) status.textContent = 'Verifying…';\n this.querySelectorAll('button').forEach((button) => {\n button.disabled = true;\n });\n\n try {\n const plaintext = await unsealInWorker(envelope, {\n signal: this._abortController?.signal,\n });\n this.setAttribute('status', 'success');\n if (status) status.textContent = 'Verified';\n\n const output = document.createElement('template');\n if (this.getAttribute('output') === 'html') {\n output.innerHTML = plaintext;\n } else {\n output.content.textContent = plaintext;\n }\n\n if (this.getAttribute('layout') === 'floating') {\n this.replaceChildren(output.content);\n this._shadow.addEventListener(\n 'transitionend',\n () => this.replaceWith(...this.childNodes),\n { once: true },\n );\n } else {\n this.replaceWith(output.content);\n }\n } catch (error) {\n if (error instanceof DOMException && error.name === 'AbortError') {\n this.removeAttribute('status');\n if (status) status.textContent = '';\n this.querySelectorAll('button').forEach((button) => {\n button.disabled = false;\n });\n } else {\n this.setAttribute('status', 'error');\n if (status) status.textContent = 'Verification failed';\n }\n }\n };\n}\n\ncustomElements.define('treadwheel-widget', TreadwheelWidget);\n"],"mappings":"AA4DA,SAAgBA,EACd,EACA,EACiB,CACjB,OAAO,IAAI,SAAS,EAAS,IAAW,CACtC,GAAIC,GAAS,QAAQ,QAAS,OAAOC,EAAOD,EAAQ,OAAO,MAAM,EACjEA,GAAS,QAAQ,iBAAiB,QAASE,CAAW,EAEtD,IAAAC,EAAA,IAAA,gBAAA,IAAA,KAAA,CAAA,y4EAAA,EAAA,CAAA,KAAA,wBAAA,CAAA,CAAA,EAAAC,EAAA,IAAA,OAAAD,CAAA,EAAA,IAAA,gBAAAA,CAAA,EAIA,IAAME,MAAgB,CACpBD,EAAO,UAAU,EACjBJ,GAAS,QAAQ,oBAAoB,QAASE,CAAW,CAC3D,EAEA,EAAO,UAAa,GAAU,CACxBI,EAAM,KAAK,QAASC,EAAQD,EAAM,KAAK,SAAS,EAC/CL,EAAOK,EAAM,KAAK,KAAK,EAC5BD,EAAQ,CACV,EAEA,EAAO,QAAW,GAAe,CAC/BG,EAAW,eAAe,EAC1BP,EAAOO,EAAW,OAAa,MAAMA,EAAW,OAAO,CAAC,EACxDH,EAAQ,CACV,EAEA,SAASH,EAAY,EAAc,CACjCD,EAAQK,EAAM,OAAuB,MAAM,EAC3CD,EAAQ,CACV,CAEAD,EAAO,YAAYK,CAAQ,CAC7B,CAAC,CACH,CC9FA,MAAMC,EAAO,OAAO,IAEdC,EAAW,SAAS,cAAc,UAAU,EAClD,EAAS,UAAY,CAAI,ytFAoJzB,IAAMC,EAAN,cAA+B,WAAY,CAIzC,aAAc,CACZ,MAAM,EAJR,KAAQ,QAAU,KAAK,aAAa,CAAE,KAAM,MAAO,CAAC,EA4BpD,KAAQ,aAAe,KAAO,IAAa,CAEzC,GAAI,CADWC,EAAE,QACJ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EACA,CAAE,KAAM,EAAK,CACf,CACF,CAEA,mBAAoB,CAClB,KAAK,iBAAmB,IAAI,eAC9B,CAEA,sBAAuB,CACrB,KAAK,kBAAkB,MAAM,CAC/B,CAqDF,EAEA,eAAe,OAAO,oBAAqBC,CAAgB"}
1
+ {"version":3,"file":"treadwheel-widget.min.js","names":["unsealInWorker","options","reject","handleAbort","url","worker","cleanup","event","resolve","errorEvent","envelope","html","template","TreadwheelWidget","e","status","plaintext","output","error"],"sources":["../src/browser/index.ts","../src/browser/widget.ts"],"sourcesContent":["import { SEAL_DEFAULTS } from '../core/defaults.js';\nimport { sealFromPrimes, unsealFromBytes } from '../core/index.js';\nimport { bytesToBigInt } from '../core/io.js';\nimport type { SealOptions, UnsealInWorkerOptions } from '../core/types.js';\nimport { base64UrlToBytes, bytesToBase64Url } from './codec.js';\n\nexport type { SealOptions, UnsealInWorkerOptions };\n\n/**\n * Seal plaintext using a time-lock puzzle.\n *\n * @param plaintext - The plaintext to seal.\n * @param options - Optional configuration options.\n * @returns A Base64URL-encoded envelope.\n */\nexport async function seal(\n plaintext: string,\n options?: SealOptions,\n): Promise<string> {\n const config = { ...SEAL_DEFAULTS, ...options };\n\n const keyPair = await globalThis.crypto.subtle.generateKey(\n {\n name: 'RSA-OAEP',\n modulusLength: config.modulusLength,\n publicExponent: new Uint8Array([0x01, 0x00, 0x01]),\n hash: 'SHA-256',\n },\n true,\n ['decrypt'],\n );\n const jwk = await globalThis.crypto.subtle.exportKey(\n 'jwk',\n keyPair.privateKey,\n );\n\n if (!jwk.p || !jwk.q) throw new Error('RSA JWK is missing primes p or q');\n const p = bytesToBigInt(base64UrlToBytes(jwk.p));\n const q = bytesToBigInt(base64UrlToBytes(jwk.q));\n\n return bytesToBase64Url(await sealFromPrimes(plaintext, p, q, config));\n}\n\n/**\n * Unseal an envelope by solving its time-lock puzzle.\n *\n * @param envelope - A Base64URL-encoded envelope.\n * @returns The decrypted plaintext.\n */\nexport async function unseal(envelope: string): Promise<string> {\n if (!globalThis.crypto?.subtle)\n throw new Error('Web Crypto API is not available');\n\n return await unsealFromBytes(base64UrlToBytes(envelope));\n}\n\n/**\n * Unseal an envelope in a web worker.\n *\n * @param envelope - A Base64URL-encoded envelope.\n * @param options - Optional configuration options.\n * @returns The decrypted plaintext.\n */\nexport function unsealInWorker(\n envelope: string,\n options?: UnsealInWorkerOptions,\n): Promise<string> {\n return new Promise((resolve, reject) => {\n if (options?.signal?.aborted) return reject(options.signal.reason);\n options?.signal?.addEventListener('abort', handleAbort);\n\n const worker = new Worker(new URL('./worker.js', import.meta.url), {\n type: 'module',\n });\n\n const cleanup = () => {\n worker.terminate();\n options?.signal?.removeEventListener('abort', handleAbort);\n };\n\n worker.onmessage = (event) => {\n if (event.data.success) resolve(event.data.plaintext);\n else reject(event.data.error);\n cleanup();\n };\n\n worker.onerror = (errorEvent) => {\n errorEvent.preventDefault();\n reject(errorEvent.error ?? new Error(errorEvent.message));\n cleanup();\n };\n\n function handleAbort(event: Event) {\n reject((event.target as AbortSignal).reason);\n cleanup();\n }\n\n worker.postMessage(envelope);\n });\n}\n","import { unsealInWorker } from './index.js';\n\nconst html = String.raw;\n\nconst template = document.createElement('template');\ntemplate.innerHTML = html`\n <style>\n article {\n all: initial;\n display: block;\n box-sizing: border-box;\n width: min(300px, 100dvw);\n border: 1px solid rgba(0, 0, 0, 0.12);\n border-radius: 10px;\n color: #111;\n background: #fff;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);\n font-family:\n Inter, Roboto, \"Helvetica Neue\", \"Arial Nova\", \"Nimbus Sans\", Arial,\n sans-serif;\n font-size: 16px;\n line-height: 1.25;\n user-select: none;\n }\n\n :host([layout=\"floating\"]) {\n display: inline-block;\n position: relative;\n }\n\n :host([layout=\"floating\"]) article {\n display: none;\n position: absolute;\n z-index: 1000000;\n opacity: 0;\n transition: opacity .2s ease-in .8s;\n }\n\n :host([layout=\"floating\"][status]) article {\n display: block;\n }\n\n :host([layout=\"floating\"][status=\"processing\"]) article,\n :host([layout=\"floating\"][status=\"error\"]) article {\n opacity: 1;\n transition: opacity .1s ease-out;\n }\n\n @supports (position-area: block-end span-inline-end) {\n :host([layout=\"floating\"]) {\n position: static;\n anchor-name: --host;\n }\n\n :host([layout=\"floating\"]) article {\n position: fixed;\n position-anchor: --host;\n position-area: block-end span-inline-end;\n position-try-fallbacks: flip-inline;\n }\n }\n\n button {\n all: unset;\n width: 100%;\n cursor: pointer;\n }\n\n button:focus-visible {\n outline: revert;\n }\n\n button, :host([status]) #status {\n position: relative;\n box-sizing: border-box;\n min-height: 46px;\n padding: 16px 16px 10px 52px;\n border-radius: 6px;\n }\n\n :host([status]) button {\n display: none;\n }\n\n :host([status=\"processing\"]) #status {\n cursor: wait;\n }\n\n button::before, :host([status]) #status::before {\n content: '';\n position: absolute;\n left: 14px;\n top: 50%;\n width: 24px;\n height: 24px;\n margin-top: -10px;\n border: 1px solid #bbb;\n border-radius: 6px;\n }\n\n :host([status=\"processing\"]) #status::before {\n border-radius: 50%;\n border-color: transparent transparent #111 #111;\n animation: spin 1s linear infinite;\n }\n\n :host([status=\"success\"]) #status::before {\n border-color: #16a34a;\n background-color: #16a34a;\n background-image: url(\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjZmZmIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+PHBhdGggZD0ibTE4IDgtOCA5LTQtNCIvPjwvc3ZnPg==\");\n }\n\n :host([status=\"error\"]) #status::before {\n border-color: #dc2626;\n background-color: #dc2626;\n background-image: url(\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgc3Ryb2tlPSIjZmZmIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCI+PHBhdGggZD0iTTE3IDcgNyAxN003IDdsMTAgMTAiLz48L3N2Zz4=\");\n }\n\n footer {\n text-align: right;\n font-size: 12px;\n color: #666;\n padding: 2px 9px 7px 9px;\n }\n\n footer a {\n color: inherit;\n text-decoration: none;\n }\n\n footer a:hover {\n text-decoration: underline;\n }\n\n @keyframes spin { to { transform: rotate(360deg); } }\n </style>\n <slot></slot>\n <article>\n <button type=\"button\">I'm not a robot</button>\n <div id=\"status\" role=\"status\"></div>\n <footer>\n Protected by\n <a\n href=\"https://github.com/jo-phil/treadwheel\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n Treadwheel\n </a>\n </footer>\n </article>\n`;\n\nclass TreadwheelWidget extends HTMLElement {\n private _shadow = this.attachShadow({ mode: 'open' });\n private _abortController?: AbortController;\n\n constructor() {\n super();\n\n this._shadow.appendChild(template.content.cloneNode(true));\n this._shadow.addEventListener('click', this._handleClick);\n this._shadow.querySelector('slot')?.addEventListener(\n 'slotchange',\n () => {\n if (this.hasAttribute('layout')) return;\n if (this.querySelector('button')) {\n this.setAttribute('layout', 'floating');\n }\n },\n { once: true },\n );\n }\n\n connectedCallback() {\n this._abortController = new AbortController();\n }\n\n disconnectedCallback() {\n this._abortController?.abort();\n }\n\n private _handleClick = async (e: Event) => {\n const target = e.target as HTMLElement | null;\n if (!target?.closest('button')) return;\n\n const envelope = this.getAttribute('envelope');\n if (!envelope) return;\n\n this.setAttribute('status', 'processing');\n const status = this._shadow.getElementById('status');\n if (status) status.textContent = 'Verifying…';\n this.querySelectorAll('button').forEach((button) => {\n button.disabled = true;\n });\n\n try {\n const plaintext = await unsealInWorker(envelope, {\n signal: this._abortController?.signal,\n });\n this.setAttribute('status', 'success');\n if (status) status.textContent = 'Verified';\n\n const output = document.createElement('template');\n if (this.getAttribute('output') === 'html') {\n output.innerHTML = plaintext;\n } else {\n output.content.textContent = plaintext;\n }\n\n if (this.getAttribute('layout') === 'floating') {\n this.replaceChildren(output.content);\n this._shadow.addEventListener(\n 'transitionend',\n () => this.replaceWith(...this.childNodes),\n { once: true },\n );\n } else {\n this.replaceWith(output.content);\n }\n } catch (error) {\n if (error instanceof DOMException && error.name === 'AbortError') {\n this.removeAttribute('status');\n if (status) status.textContent = '';\n this.querySelectorAll('button').forEach((button) => {\n button.disabled = false;\n });\n } else {\n this.setAttribute('status', 'error');\n if (status) status.textContent = 'Verification failed';\n }\n }\n };\n}\n\ncustomElements.define('treadwheel-widget', TreadwheelWidget);\n"],"mappings":"AA+DA,SAAgBA,EACd,EACA,EACiB,CACjB,OAAO,IAAI,SAAS,EAAS,IAAW,CACtC,GAAIC,GAAS,QAAQ,QAAS,OAAOC,EAAOD,EAAQ,OAAO,MAAM,EACjEA,GAAS,QAAQ,iBAAiB,QAASE,CAAW,EAEtD,IAAAC,EAAA,IAAA,gBAAA,IAAA,KAAA,CAAA,s9EAAA,EAAA,CAAA,KAAA,wBAAA,CAAA,CAAA,EAAAC,EAAA,IAAA,OAAAD,CAAA,EAAA,IAAA,gBAAAA,CAAA,EAIA,IAAME,MAAgB,CACpBD,EAAO,UAAU,EACjBJ,GAAS,QAAQ,oBAAoB,QAASE,CAAW,CAC3D,EAEA,EAAO,UAAa,GAAU,CACxBI,EAAM,KAAK,QAASC,EAAQD,EAAM,KAAK,SAAS,EAC/CL,EAAOK,EAAM,KAAK,KAAK,EAC5BD,EAAQ,CACV,EAEA,EAAO,QAAW,GAAe,CAC/BG,EAAW,eAAe,EAC1BP,EAAOO,EAAW,OAAa,MAAMA,EAAW,OAAO,CAAC,EACxDH,EAAQ,CACV,EAEA,SAASH,EAAY,EAAc,CACjCD,EAAQK,EAAM,OAAuB,MAAM,EAC3CD,EAAQ,CACV,CAEAD,EAAO,YAAYK,CAAQ,CAC7B,CAAC,CACH,CCjGA,MAAMC,EAAO,OAAO,IAEdC,EAAW,SAAS,cAAc,UAAU,EAClD,EA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AAC,EACzD,KAAK,QAAQ,iBAAiB,QAAS,KAAK,YAAY,EACxD,KAAK,QAAQ,cAAc,MAAM,CAAC,EAAE,iBAClC,iBACM,CACA,KAAK,aAAa,QAAQ,GAC1B,KAAK,cAAc,QAAQ,GAC7B,KAAK,aAAa,SAAU,UAAU,CAE1C,EACA,CAAE,KAAM,EAAK,CACf,CACF,CAEA,mBAAoB,CAClB,KAAK,iBAAmB,IAAI,eAC9B,CAEA,sBAAuB,CACrB,KAAK,kBAAkB,MAAM,CAC/B,CAqDF,EAEA,eAAe,OAAO,oBAAqBC,CAAgB"}
@@ -1,2 +1,2 @@
1
- const e={time:25e4,modulusLength:2048},t=new TextEncoder().encode(`treadwheel-v1`);async function n(e,n){let r=await globalThis.crypto.subtle.importKey(`raw`,e,`HKDF`,!1,[`deriveKey`]);return await globalThis.crypto.subtle.deriveKey({name:`HKDF`,hash:`SHA-256`,salt:n,info:t},r,{name:`AES-GCM`,length:256},!1,[`encrypt`,`decrypt`])}async function r(e,t){let r=globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32)),i=globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(12)),a=await n(t,r);return{salt:r,iv:i,ciphertext:new Uint8Array(await globalThis.crypto.subtle.encrypt({name:`AES-GCM`,iv:i},a,e))}}async function i(e,t){let r=await n(t,e.salt);return new Uint8Array(await globalThis.crypto.subtle.decrypt({name:`AES-GCM`,iv:e.iv},r,e.ciphertext))}const a=new Uint8Array([183,15,255]);var o=class{constructor(e){this.offset=0,this.bytes=e,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}},s=class extends o{readUint8(){return this.view.getUint8(this.offset++)}readUint16(){let e=this.view.getUint16(this.offset);return this.offset+=2,e}readUint32(){let e=this.view.getUint32(this.offset);return this.offset+=4,e}readBigUInt64(){let e=this.view.getBigUint64(this.offset);return this.offset+=8,e}readBytes(e){let t=this.offset+e;if(t>this.bytes.byteLength)throw Error(`Malformed envelope: unexpected end of data`);let n=this.bytes.subarray(this.offset,t);return this.offset=t,n}},c=class extends o{writeUint8(e){this.view.setUint8(this.offset++,e)}writeUint16(e){this.view.setUint16(this.offset,e),this.offset+=2}writeUint32(e){this.view.setUint32(this.offset,e),this.offset+=4}writeBigUInt64(e){this.view.setBigUint64(this.offset,BigInt(e)),this.offset+=8}writeBytes(e){this.bytes.set(e,this.offset),this.offset+=e.byteLength}};function l(e){let t=0n;for(let n=0;n<e.length;n++)t=t<<8n|BigInt(e[n]);return t}function u(e,t){let n=new Uint8Array(t);for(let r=0;r<t;r++){let i=BigInt((t-1-r)*8);n[r]=Number(e>>i&255n)}return n}function d({v:e,modulusByteLength:t,time:n,modulus:r,base:i,salt:o,iv:s,ciphertext:l}){let d=a.byteLength+15+2*t+o.byteLength+s.byteLength+l.byteLength,f=new Uint8Array(d),p=new c(f);return p.writeBytes(a),p.writeUint8(e),p.writeUint16(t),p.writeUint32(l.byteLength),p.writeBigUInt64(n),p.writeBytes(u(r,t)),p.writeBytes(u(i,t)),p.writeBytes(o),p.writeBytes(s),p.writeBytes(l),f}function f(e){let t=new s(e);if(!t.readBytes(a.byteLength).every((e,t)=>e===a[t]))throw Error(`Invalid envelope: magic bytes mismatch`);let n=t.readUint8();if(n!==1)throw Error(`Unsupported envelope version ${n}`);let r=t.readUint16(),i=t.readUint32();return{v:n,modulusByteLength:r,time:t.readBigUInt64(),modulus:l(t.readBytes(r)),base:l(t.readBytes(r)),salt:t.readBytes(32),iv:t.readBytes(12),ciphertext:t.readBytes(i)}}function p(e,t,n){if(n===1n)return 0n;let r=1n;for(e%=n;t>0n;)(t&1n)==1n&&(r=r*e%n),t>>=1n,e=e*e%n;return r}function m(e,t){let n=new Uint8Array(t+16);globalThis.crypto.getRandomValues(n);let r=l(n)%e;return r<=1n&&(r=2n),r}function h(e,t,{time:n,modulusLength:r}){if(!Number.isSafeInteger(n)||n<0)throw RangeError(`Option 'time' must be a non-negative safe integer`);let i=BigInt(n),a=Math.ceil(r/8),o=e*t,s=(e-1n)*(t-1n),c=m(o,a),l=p(c,p(2n,i,s),o);return{puzzle:{modulusByteLength:a,modulus:o,base:c,time:i},solution:l}}function g({modulus:e,base:t,time:n}){for(let r=0n;r<n;r++)t=t*t%e;return t}const _=new TextEncoder,v=new TextDecoder;async function y(e,t,n,i){let a=_.encode(e),{puzzle:o,solution:s}=h(t,n,i),c=u(s,o.modulusByteLength),l;try{l=await r(a,c)}finally{c.fill(0)}return d({v:1,...o,...l})}async function b(e){let t=f(e),n=u(g(t),t.modulusByteLength),r;try{r=await i(t,n)}finally{n.fill(0)}return v.decode(r)}function x(e){if(`toBase64`in e&&typeof e.toBase64==`function`)return e.toBase64({alphabet:`base64url`,omitPadding:!0});let t=16384,n=``;for(let r=0;r<e.length;r+=t){let i=e.subarray(r,r+t);n+=String.fromCharCode(...i)}return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function S(e){if(`fromBase64`in Uint8Array&&typeof Uint8Array.fromBase64==`function`)return Uint8Array.fromBase64(e,{alphabet:`base64url`});let t=e.replace(/-/g,`+`).replace(/_/g,`/`);return t+=`==`.slice((t.length+2)%4),Uint8Array.from(atob(t),e=>e.charCodeAt(0))}async function C(t,n){let r={...e,...n},i=await globalThis.crypto.subtle.generateKey({name:`RSA-OAEP`,modulusLength:r.modulusLength,publicExponent:new Uint8Array([1,0,1]),hash:`SHA-256`},!0,[`decrypt`]),a=await globalThis.crypto.subtle.exportKey(`jwk`,i.privateKey);if(!a.p||!a.q)throw Error(`RSA JWK is missing primes p or q`);return x(await y(t,l(S(a.p)),l(S(a.q)),r))}async function w(e){return await b(S(e))}function T(e,t){return new Promise((n,r)=>{if(t?.signal?.aborted)return r(t.signal.reason);t?.signal?.addEventListener(`abort`,s);let i=URL.createObjectURL(new Blob(["(function(){let e=new TextEncoder().encode(`treadwheel-v1`);async function t(t,n){let r=await globalThis.crypto.subtle.importKey(`raw`,t,`HKDF`,!1,[`deriveKey`]);return await globalThis.crypto.subtle.deriveKey({name:`HKDF`,hash:`SHA-256`,salt:n,info:e},r,{name:`AES-GCM`,length:256},!1,[`encrypt`,`decrypt`])}async function n(e,n){let r=await t(n,e.salt);return new Uint8Array(await globalThis.crypto.subtle.decrypt({name:`AES-GCM`,iv:e.iv},r,e.ciphertext))}let r=new Uint8Array([183,15,255]);var i=class{constructor(e){this.offset=0,this.bytes=e,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}},a=class extends i{readUint8(){return this.view.getUint8(this.offset++)}readUint16(){let e=this.view.getUint16(this.offset);return this.offset+=2,e}readUint32(){let e=this.view.getUint32(this.offset);return this.offset+=4,e}readBigUInt64(){let e=this.view.getBigUint64(this.offset);return this.offset+=8,e}readBytes(e){let t=this.offset+e;if(t>this.bytes.byteLength)throw Error(`Malformed envelope: unexpected end of data`);let n=this.bytes.subarray(this.offset,t);return this.offset=t,n}};function o(e){let t=0n;for(let n=0;n<e.length;n++)t=t<<8n|BigInt(e[n]);return t}function s(e,t){let n=new Uint8Array(t);for(let r=0;r<t;r++){let i=BigInt((t-1-r)*8);n[r]=Number(e>>i&255n)}return n}function c(e){let t=new a(e);if(!t.readBytes(r.byteLength).every((e,t)=>e===r[t]))throw Error(`Invalid envelope: magic bytes mismatch`);let n=t.readUint8();if(n!==1)throw Error(`Unsupported envelope version ${n}`);let i=t.readUint16(),s=t.readUint32();return{v:n,modulusByteLength:i,time:t.readBigUInt64(),modulus:o(t.readBytes(i)),base:o(t.readBytes(i)),salt:t.readBytes(32),iv:t.readBytes(12),ciphertext:t.readBytes(s)}}function l({modulus:e,base:t,time:n}){for(let r=0n;r<n;r++)t=t*t%e;return t}new TextEncoder;let u=new TextDecoder;async function d(e){let t=c(e),r=s(l(t),t.modulusByteLength),i;try{i=await n(t,r)}finally{r.fill(0)}return u.decode(i)}function f(e){if(`fromBase64`in Uint8Array&&typeof Uint8Array.fromBase64==`function`)return Uint8Array.fromBase64(e,{alphabet:`base64url`});let t=e.replace(/-/g,`+`).replace(/_/g,`/`);return t+=`==`.slice((t.length+2)%4),Uint8Array.from(atob(t),e=>e.charCodeAt(0))}async function p(e){return await d(f(e))}self.onmessage=async e=>{try{let t=await p(e.data);self.postMessage({success:!0,plaintext:t})}catch(e){self.postMessage({success:!1,error:e instanceof Error?e:Error(String(e))})}}})();"],{type:`application/javascript`})),a=new Worker(i);URL.revokeObjectURL(i);let o=()=>{a.terminate(),t?.signal?.removeEventListener(`abort`,s)};a.onmessage=e=>{e.data.success?n(e.data.plaintext):r(e.data.error),o()},a.onerror=e=>{e.preventDefault(),r(e.error??Error(e.message)),o()};function s(e){r(e.target.reason),o()}a.postMessage(e)})}export{C as seal,w as unseal,T as unsealInWorker};
1
+ const e={time:25e4,modulusLength:2048},t=new TextEncoder().encode(`treadwheel-v1`);async function n(e,n){let r=await globalThis.crypto.subtle.importKey(`raw`,e,`HKDF`,!1,[`deriveKey`]);return await globalThis.crypto.subtle.deriveKey({name:`HKDF`,hash:`SHA-256`,salt:n,info:t},r,{name:`AES-GCM`,length:256},!1,[`encrypt`,`decrypt`])}async function r(e,t){let r=globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32)),i=globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(12)),a=await n(t,r);return{salt:r,iv:i,ciphertext:new Uint8Array(await globalThis.crypto.subtle.encrypt({name:`AES-GCM`,iv:i},a,e))}}async function i(e,t){let r=await n(t,e.salt);return new Uint8Array(await globalThis.crypto.subtle.decrypt({name:`AES-GCM`,iv:e.iv},r,e.ciphertext))}const a=new Uint8Array([183,15,255]);var o=class{constructor(e){this.offset=0,this.bytes=e,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}},s=class extends o{readUint8(){return this.view.getUint8(this.offset++)}readUint16(){let e=this.view.getUint16(this.offset);return this.offset+=2,e}readUint32(){let e=this.view.getUint32(this.offset);return this.offset+=4,e}readBigUInt64(){let e=this.view.getBigUint64(this.offset);return this.offset+=8,e}readBytes(e){let t=this.offset+e;if(t>this.bytes.byteLength)throw Error(`Malformed envelope: unexpected end of data`);let n=this.bytes.subarray(this.offset,t);return this.offset=t,n}},c=class extends o{writeUint8(e){this.view.setUint8(this.offset++,e)}writeUint16(e){this.view.setUint16(this.offset,e),this.offset+=2}writeUint32(e){this.view.setUint32(this.offset,e),this.offset+=4}writeBigUInt64(e){this.view.setBigUint64(this.offset,BigInt(e)),this.offset+=8}writeBytes(e){this.bytes.set(e,this.offset),this.offset+=e.byteLength}};function l(e){let t=0n;for(let n=0;n<e.length;n++)t=t<<8n|BigInt(e[n]);return t}function u(e,t){let n=new Uint8Array(t);for(let r=0;r<t;r++){let i=BigInt((t-1-r)*8);n[r]=Number(e>>i&255n)}return n}function d({v:e,modulusByteLength:t,time:n,modulus:r,base:i,salt:o,iv:s,ciphertext:l}){let d=a.byteLength+15+2*t+o.byteLength+s.byteLength+l.byteLength,f=new Uint8Array(d),p=new c(f);return p.writeBytes(a),p.writeUint8(e),p.writeUint16(t),p.writeUint32(l.byteLength),p.writeBigUInt64(n),p.writeBytes(u(r,t)),p.writeBytes(u(i,t)),p.writeBytes(o),p.writeBytes(s),p.writeBytes(l),f}function f(e){let t=new s(e);if(!t.readBytes(a.byteLength).every((e,t)=>e===a[t]))throw Error(`Invalid envelope: magic bytes mismatch`);let n=t.readUint8();if(n!==1)throw Error(`Unsupported envelope version ${n}`);let r=t.readUint16(),i=t.readUint32();return{v:n,modulusByteLength:r,time:t.readBigUInt64(),modulus:l(t.readBytes(r)),base:l(t.readBytes(r)),salt:t.readBytes(32),iv:t.readBytes(12),ciphertext:t.readBytes(i)}}function p(e,t,n){if(n===1n)return 0n;let r=1n;for(e%=n;t>0n;)(t&1n)==1n&&(r=r*e%n),t>>=1n,e=e*e%n;return r}function m(e,t){let n=new Uint8Array(t+16);globalThis.crypto.getRandomValues(n);let r=l(n)%e;return r<=1n&&(r=2n),r}function h(e,t,{time:n,modulusLength:r}){if(!Number.isSafeInteger(n)||n<0)throw RangeError(`Option 'time' must be a non-negative safe integer`);let i=BigInt(n),a=Math.ceil(r/8),o=e*t,s=(e-1n)*(t-1n),c=m(o,a),l=p(c,p(2n,i,s),o);return{puzzle:{modulusByteLength:a,modulus:o,base:c,time:i},solution:l}}function g({modulus:e,base:t,time:n}){for(let r=0n;r<n;r++)t=t*t%e;return t}const _=new TextEncoder,v=new TextDecoder;async function y(e,t,n,i){let a=_.encode(e),{puzzle:o,solution:s}=h(t,n,i),c=u(s,o.modulusByteLength),l;try{l=await r(a,c)}finally{c.fill(0)}return d({v:1,...o,...l})}async function b(e){let t=f(e),n=u(g(t),t.modulusByteLength),r;try{r=await i(t,n)}finally{n.fill(0)}return v.decode(r)}function x(e){if(`toBase64`in e&&typeof e.toBase64==`function`)return e.toBase64({alphabet:`base64url`,omitPadding:!0});let t=16384,n=``;for(let r=0;r<e.length;r+=t){let i=e.subarray(r,r+t);n+=String.fromCharCode(...i)}return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function S(e){if(`fromBase64`in Uint8Array&&typeof Uint8Array.fromBase64==`function`)return Uint8Array.fromBase64(e,{alphabet:`base64url`});let t=e.replace(/-/g,`+`).replace(/_/g,`/`);return t+=`==`.slice((t.length+2)%4),Uint8Array.from(atob(t),e=>e.charCodeAt(0))}async function C(t,n){let r={...e,...n},i=await globalThis.crypto.subtle.generateKey({name:`RSA-OAEP`,modulusLength:r.modulusLength,publicExponent:new Uint8Array([1,0,1]),hash:`SHA-256`},!0,[`decrypt`]),a=await globalThis.crypto.subtle.exportKey(`jwk`,i.privateKey);if(!a.p||!a.q)throw Error(`RSA JWK is missing primes p or q`);return x(await y(t,l(S(a.p)),l(S(a.q)),r))}async function w(e){if(!globalThis.crypto?.subtle)throw Error(`Web Crypto API is not available`);return await b(S(e))}function T(e,t){return new Promise((n,r)=>{if(t?.signal?.aborted)return r(t.signal.reason);t?.signal?.addEventListener(`abort`,s);let i=URL.createObjectURL(new Blob(["(function(){let e=new TextEncoder().encode(`treadwheel-v1`);async function t(t,n){let r=await globalThis.crypto.subtle.importKey(`raw`,t,`HKDF`,!1,[`deriveKey`]);return await globalThis.crypto.subtle.deriveKey({name:`HKDF`,hash:`SHA-256`,salt:n,info:e},r,{name:`AES-GCM`,length:256},!1,[`encrypt`,`decrypt`])}async function n(e,n){let r=await t(n,e.salt);return new Uint8Array(await globalThis.crypto.subtle.decrypt({name:`AES-GCM`,iv:e.iv},r,e.ciphertext))}let r=new Uint8Array([183,15,255]);var i=class{constructor(e){this.offset=0,this.bytes=e,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}},a=class extends i{readUint8(){return this.view.getUint8(this.offset++)}readUint16(){let e=this.view.getUint16(this.offset);return this.offset+=2,e}readUint32(){let e=this.view.getUint32(this.offset);return this.offset+=4,e}readBigUInt64(){let e=this.view.getBigUint64(this.offset);return this.offset+=8,e}readBytes(e){let t=this.offset+e;if(t>this.bytes.byteLength)throw Error(`Malformed envelope: unexpected end of data`);let n=this.bytes.subarray(this.offset,t);return this.offset=t,n}};function o(e){let t=0n;for(let n=0;n<e.length;n++)t=t<<8n|BigInt(e[n]);return t}function s(e,t){let n=new Uint8Array(t);for(let r=0;r<t;r++){let i=BigInt((t-1-r)*8);n[r]=Number(e>>i&255n)}return n}function c(e){let t=new a(e);if(!t.readBytes(r.byteLength).every((e,t)=>e===r[t]))throw Error(`Invalid envelope: magic bytes mismatch`);let n=t.readUint8();if(n!==1)throw Error(`Unsupported envelope version ${n}`);let i=t.readUint16(),s=t.readUint32();return{v:n,modulusByteLength:i,time:t.readBigUInt64(),modulus:o(t.readBytes(i)),base:o(t.readBytes(i)),salt:t.readBytes(32),iv:t.readBytes(12),ciphertext:t.readBytes(s)}}function l({modulus:e,base:t,time:n}){for(let r=0n;r<n;r++)t=t*t%e;return t}new TextEncoder;let u=new TextDecoder;async function d(e){let t=c(e),r=s(l(t),t.modulusByteLength),i;try{i=await n(t,r)}finally{r.fill(0)}return u.decode(i)}function f(e){if(`fromBase64`in Uint8Array&&typeof Uint8Array.fromBase64==`function`)return Uint8Array.fromBase64(e,{alphabet:`base64url`});let t=e.replace(/-/g,`+`).replace(/_/g,`/`);return t+=`==`.slice((t.length+2)%4),Uint8Array.from(atob(t),e=>e.charCodeAt(0))}async function p(e){if(!globalThis.crypto?.subtle)throw Error(`Web Crypto API is not available`);return await d(f(e))}self.onmessage=async e=>{try{let t=await p(e.data);self.postMessage({success:!0,plaintext:t})}catch(e){self.postMessage({success:!1,error:e instanceof Error?e:Error(String(e))})}}})();"],{type:`application/javascript`})),a=new Worker(i);URL.revokeObjectURL(i);let o=()=>{a.terminate(),t?.signal?.removeEventListener(`abort`,s)};a.onmessage=e=>{e.data.success?n(e.data.plaintext):r(e.data.error),o()},a.onerror=e=>{e.preventDefault(),r(e.error??Error(e.message)),o()};function s(e){r(e.target.reason),o()}a.postMessage(e)})}export{C as seal,w as unseal,T as unsealInWorker};
2
2
  //# sourceMappingURL=treadwheel.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"treadwheel.min.js","names":["SEAL_DEFAULTS","INFO_BYTES","deriveKey","baseKey","keyData","encrypt","salt","iv","derivedKey","payload","decrypt","cipher","MAGIC_BYTES","BinaryCursor","bytes","BinaryReader","value","until","length","BinaryWriter","buffer","bytesToBigInt","result","i","bigIntToBytes","byteLength","shift","bigint","envelopeToBytes","totalSize","modulusByteLength","ciphertext","writer","v","time","modulus","base","bytesToEnvelope","reader","b","ciphertextLength","modExp","exponent","randomBigInt","randomBytes","x","strictUpperBound","mint","t","modulusLength","p","q","phi","solution","solve","encoder","decoder","sealFromPrimes","plaintext","puzzleParams","puzzle","unsealFromBytes","envelope","bytesToBase64Url","CHUNK_SIZE","binaryString","chunk","base64UrlToBytes","base64Url","base64","char","seal","config","options","keyPair","jwk","unseal","unsealInWorker","reject","handleAbort","url","worker","cleanup","event","resolve","errorEvent"],"sources":["../src/core/defaults.ts","../src/core/cipher.ts","../src/core/io.ts","../src/core/puzzle.ts","../src/core/index.ts","../src/browser/codec.ts","../src/browser/index.ts"],"sourcesContent":["import type { SealOptions } from './types.js';\n\nexport const SEAL_DEFAULTS: Required<SealOptions> = {\n time: 250_000,\n modulusLength: 2048,\n};\n","import type { Cipher } from './types.js';\n\nconst INFO_BYTES = new TextEncoder().encode('treadwheel-v1');\n\nasync function deriveKey(\n keyData: BufferSource,\n salt: BufferSource,\n): Promise<CryptoKey> {\n const baseKey = await globalThis.crypto.subtle.importKey(\n 'raw',\n keyData,\n 'HKDF',\n false,\n ['deriveKey'],\n );\n\n return await globalThis.crypto.subtle.deriveKey(\n { name: 'HKDF', hash: 'SHA-256', salt: salt, info: INFO_BYTES },\n baseKey,\n { name: 'AES-GCM', length: 256 },\n false,\n ['encrypt', 'decrypt'],\n );\n}\n\nexport async function encrypt(\n payload: Uint8Array<ArrayBuffer>,\n keyData: BufferSource,\n): Promise<Cipher> {\n const salt = globalThis.crypto.getRandomValues(new Uint8Array(32));\n const iv = globalThis.crypto.getRandomValues(new Uint8Array(12));\n\n const derivedKey = await deriveKey(keyData, salt);\n const ciphertext = new Uint8Array(\n await globalThis.crypto.subtle.encrypt(\n { name: 'AES-GCM', iv },\n derivedKey,\n payload,\n ),\n );\n\n return { salt, iv, ciphertext };\n}\n\nexport async function decrypt(\n cipher: Cipher,\n keyData: BufferSource,\n): Promise<Uint8Array<ArrayBuffer>> {\n const derivedKey = await deriveKey(keyData, cipher.salt);\n return new Uint8Array(\n await globalThis.crypto.subtle.decrypt(\n { name: 'AES-GCM', iv: cipher.iv },\n derivedKey,\n cipher.ciphertext,\n ),\n );\n}\n","import type { Envelope } from './types.js';\n\nconst MAGIC_BYTES = new Uint8Array([0xb7, 0x0f, 0xff]);\n\nclass BinaryCursor {\n protected view: DataView;\n protected bytes: Uint8Array<ArrayBuffer>;\n protected offset: number = 0;\n\n constructor(bytes: Uint8Array<ArrayBuffer>) {\n this.bytes = bytes;\n this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n }\n}\n\nclass BinaryReader extends BinaryCursor {\n public readUint8(): number {\n return this.view.getUint8(this.offset++);\n }\n\n public readUint16(): number {\n const value = this.view.getUint16(this.offset);\n this.offset += 2;\n return value;\n }\n\n public readUint32(): number {\n const value = this.view.getUint32(this.offset);\n this.offset += 4;\n return value;\n }\n\n public readBigUInt64(): bigint {\n const value = this.view.getBigUint64(this.offset);\n this.offset += 8;\n return value;\n }\n\n public readBytes(length: number): Uint8Array<ArrayBuffer> {\n const until = this.offset + length;\n if (until > this.bytes.byteLength)\n throw new Error('Malformed envelope: unexpected end of data');\n\n const bytes = this.bytes.subarray(this.offset, until);\n this.offset = until;\n return bytes;\n }\n}\n\nclass BinaryWriter extends BinaryCursor {\n public writeUint8(value: number): void {\n this.view.setUint8(this.offset++, value);\n }\n\n public writeUint16(value: number): void {\n this.view.setUint16(this.offset, value);\n this.offset += 2;\n }\n\n public writeUint32(value: number): void {\n this.view.setUint32(this.offset, value);\n this.offset += 4;\n }\n\n public writeBigUInt64(value: bigint): void {\n this.view.setBigUint64(this.offset, BigInt(value));\n this.offset += 8;\n }\n\n public writeBytes(buffer: Uint8Array): void {\n this.bytes.set(buffer, this.offset);\n this.offset += buffer.byteLength;\n }\n}\n\nexport function bytesToBigInt(bytes: Uint8Array): bigint {\n let result = 0n;\n for (let i = 0; i < bytes.length; i++) {\n result = (result << 8n) | BigInt(bytes[i] as number);\n }\n return result;\n}\n\nexport function bigIntToBytes(\n bigint: bigint,\n byteLength: number,\n): Uint8Array<ArrayBuffer> {\n const buffer = new Uint8Array(byteLength);\n for (let i = 0; i < byteLength; i++) {\n const shift = BigInt((byteLength - 1 - i) * 8);\n buffer[i] = Number((bigint >> shift) & 0xffn);\n }\n return buffer;\n}\n\nexport function envelopeToBytes({\n v,\n modulusByteLength,\n time,\n modulus,\n base,\n salt,\n iv,\n ciphertext,\n}: Envelope): Uint8Array<ArrayBuffer> {\n // header: some magic bytes, 1 version, 8 for t, 2 mod length, 4 ct length\n const headerSize = MAGIC_BYTES.byteLength + 15;\n const totalSize =\n headerSize +\n 2 * modulusByteLength +\n salt.byteLength +\n iv.byteLength +\n ciphertext.byteLength;\n\n const bytes = new Uint8Array(totalSize);\n const writer = new BinaryWriter(bytes);\n\n writer.writeBytes(MAGIC_BYTES);\n writer.writeUint8(v);\n\n writer.writeUint16(modulusByteLength);\n writer.writeUint32(ciphertext.byteLength);\n\n writer.writeBigUInt64(time);\n writer.writeBytes(bigIntToBytes(modulus, modulusByteLength));\n writer.writeBytes(bigIntToBytes(base, modulusByteLength));\n\n writer.writeBytes(salt);\n writer.writeBytes(iv);\n writer.writeBytes(ciphertext);\n\n return bytes;\n}\n\nexport function bytesToEnvelope(bytes: Uint8Array<ArrayBuffer>): Envelope {\n const reader = new BinaryReader(bytes);\n\n const magicBytes = reader.readBytes(MAGIC_BYTES.byteLength);\n if (!magicBytes.every((b, i) => b === MAGIC_BYTES[i]))\n throw new Error('Invalid envelope: magic bytes mismatch');\n\n const v = reader.readUint8();\n if (v !== 1) throw new Error(`Unsupported envelope version ${v}`);\n\n const modulusByteLength = reader.readUint16();\n const ciphertextLength = reader.readUint32();\n\n const time = reader.readBigUInt64();\n const modulus = bytesToBigInt(reader.readBytes(modulusByteLength));\n const base = bytesToBigInt(reader.readBytes(modulusByteLength));\n\n const salt = reader.readBytes(32);\n const iv = reader.readBytes(12);\n const ciphertext = reader.readBytes(ciphertextLength);\n\n return { v, modulusByteLength, time, modulus, base, salt, iv, ciphertext };\n}\n","import { bytesToBigInt } from './io.js';\nimport type { Puzzle, PuzzleParams } from './types.js';\n\nfunction modExp(base: bigint, exponent: bigint, modulus: bigint): bigint {\n if (modulus === 1n) return 0n;\n let result = 1n;\n base = base % modulus;\n while (exponent > 0n) {\n if ((exponent & 1n) === 1n) result = (result * base) % modulus;\n exponent >>= 1n;\n base = (base * base) % modulus;\n }\n return result;\n}\n\nfunction randomBigInt(strictUpperBound: bigint, byteLength: number): bigint {\n // Oversample by 16 bytes to reduce modulo bias\n const randomBytes = new Uint8Array(byteLength + 16);\n globalThis.crypto.getRandomValues(randomBytes);\n\n let x = bytesToBigInt(randomBytes) % strictUpperBound;\n if (x <= 1n) x = 2n;\n return x;\n}\n\nexport function mint(\n p: bigint,\n q: bigint,\n { time, modulusLength }: PuzzleParams,\n): { puzzle: Puzzle; solution: bigint } {\n if (!Number.isSafeInteger(time) || time < 0)\n throw new RangeError(\"Option 'time' must be a non-negative safe integer\");\n\n const t = BigInt(time);\n const modulusByteLength = Math.ceil(modulusLength / 8);\n\n const modulus = p * q;\n const phi = (p - 1n) * (q - 1n);\n const base = randomBigInt(modulus, modulusByteLength);\n const exponent = modExp(2n, t, phi);\n const solution = modExp(base, exponent, modulus);\n\n return { puzzle: { modulusByteLength, modulus, base, time: t }, solution };\n}\n\nexport function solve({ modulus, base, time }: Puzzle): bigint {\n for (let i = 0n; i < time; i++) {\n base = (base * base) % modulus;\n }\n return base;\n}\n","import { decrypt, encrypt } from './cipher.js';\nimport { bigIntToBytes, bytesToEnvelope, envelopeToBytes } from './io.js';\nimport { mint, solve } from './puzzle.js';\nimport type { Cipher, PuzzleParams } from './types.js';\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\nexport async function sealFromPrimes(\n plaintext: string,\n p: bigint,\n q: bigint,\n puzzleParams: PuzzleParams,\n): Promise<Uint8Array<ArrayBuffer>> {\n const payload = encoder.encode(plaintext);\n const { puzzle, solution } = mint(p, q, puzzleParams);\n const keyData = bigIntToBytes(solution, puzzle.modulusByteLength);\n\n let cipher: Cipher;\n try {\n cipher = await encrypt(payload, keyData);\n } finally {\n keyData.fill(0);\n }\n\n return envelopeToBytes({ v: 1, ...puzzle, ...cipher });\n}\n\nexport async function unsealFromBytes(\n bytes: Uint8Array<ArrayBuffer>,\n): Promise<string> {\n const envelope = bytesToEnvelope(bytes);\n const solution = solve(envelope);\n const keyData = bigIntToBytes(solution, envelope.modulusByteLength);\n\n let payload: Uint8Array<ArrayBuffer>;\n try {\n payload = await decrypt(envelope, keyData);\n } finally {\n keyData.fill(0);\n }\n\n return decoder.decode(payload);\n}\n","export function bytesToBase64Url(bytes: Uint8Array): string {\n if ('toBase64' in bytes && typeof bytes.toBase64 === 'function') {\n return bytes.toBase64({ alphabet: 'base64url', omitPadding: true });\n }\n\n const CHUNK_SIZE = 0x4000;\n let binaryString = '';\n for (let i = 0; i < bytes.length; i += CHUNK_SIZE) {\n const chunk = bytes.subarray(i, i + CHUNK_SIZE);\n binaryString += String.fromCharCode(...chunk);\n }\n\n const base64 = btoa(binaryString);\n return base64.replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '');\n}\n\nexport function base64UrlToBytes(base64Url: string): Uint8Array<ArrayBuffer> {\n if (\n 'fromBase64' in Uint8Array &&\n typeof Uint8Array.fromBase64 === 'function'\n ) {\n return Uint8Array.fromBase64(base64Url, { alphabet: 'base64url' });\n }\n\n let base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');\n base64 += '=='.slice((base64.length + 2) % 4);\n return Uint8Array.from(atob(base64), (char) => char.charCodeAt(0));\n}\n","import { SEAL_DEFAULTS } from '../core/defaults.js';\nimport { sealFromPrimes, unsealFromBytes } from '../core/index.js';\nimport { bytesToBigInt } from '../core/io.js';\nimport type { SealOptions, UnsealInWorkerOptions } from '../core/types.js';\nimport { base64UrlToBytes, bytesToBase64Url } from './codec.js';\n\nexport type { SealOptions, UnsealInWorkerOptions };\n\n/**\n * Seal plaintext using a time-lock puzzle.\n *\n * @param plaintext - The plaintext to seal.\n * @param options - Optional configuration options.\n * @returns A Base64URL-encoded envelope.\n */\nexport async function seal(\n plaintext: string,\n options?: SealOptions,\n): Promise<string> {\n const config = { ...SEAL_DEFAULTS, ...options };\n\n const keyPair = await globalThis.crypto.subtle.generateKey(\n {\n name: 'RSA-OAEP',\n modulusLength: config.modulusLength,\n publicExponent: new Uint8Array([0x01, 0x00, 0x01]),\n hash: 'SHA-256',\n },\n true,\n ['decrypt'],\n );\n const jwk = await globalThis.crypto.subtle.exportKey(\n 'jwk',\n keyPair.privateKey,\n );\n\n if (!jwk.p || !jwk.q) throw new Error('RSA JWK is missing primes p or q');\n const p = bytesToBigInt(base64UrlToBytes(jwk.p));\n const q = bytesToBigInt(base64UrlToBytes(jwk.q));\n\n return bytesToBase64Url(await sealFromPrimes(plaintext, p, q, config));\n}\n\n/**\n * Unseal an envelope by solving its time-lock puzzle.\n *\n * @param envelope - A Base64URL-encoded envelope.\n * @returns The decrypted plaintext.\n */\nexport async function unseal(envelope: string): Promise<string> {\n return await unsealFromBytes(base64UrlToBytes(envelope));\n}\n\n/**\n * Unseal an envelope in a web worker.\n *\n * @param envelope - A Base64URL-encoded envelope.\n * @param options - Optional configuration options.\n * @returns The decrypted plaintext.\n */\nexport function unsealInWorker(\n envelope: string,\n options?: UnsealInWorkerOptions,\n): Promise<string> {\n return new Promise((resolve, reject) => {\n if (options?.signal?.aborted) return reject(options.signal.reason);\n options?.signal?.addEventListener('abort', handleAbort);\n\n const worker = new Worker(new URL('./worker.js', import.meta.url), {\n type: 'module',\n });\n\n const cleanup = () => {\n worker.terminate();\n options?.signal?.removeEventListener('abort', handleAbort);\n };\n\n worker.onmessage = (event) => {\n if (event.data.success) resolve(event.data.plaintext);\n else reject(event.data.error);\n cleanup();\n };\n\n worker.onerror = (errorEvent) => {\n errorEvent.preventDefault();\n reject(errorEvent.error ?? new Error(errorEvent.message));\n cleanup();\n };\n\n function handleAbort(event: Event) {\n reject((event.target as AbortSignal).reason);\n cleanup();\n }\n\n worker.postMessage(envelope);\n });\n}\n"],"mappings":"AAEA,MAAaA,EAAuC,CAClD,KAAM,KACN,cAAe,IACjB,ECHMC,EAAa,IAAI,YAAY,CAAC,CAAC,OAAO,eAAe,EAE3D,eAAeC,EACb,EACA,EACoB,CACpB,IAAMC,EAAU,MAAM,WAAW,OAAO,OAAO,UAC7C,MACAC,EACA,OACA,GACA,CAAC,WAAW,CACd,EAEA,OAAO,MAAM,WAAW,OAAO,OAAO,UACpC,CAAE,KAAM,OAAQ,KAAM,UAAiB,OAAM,KAAMH,CAAW,EAC9DE,EACA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ACV,CAEAD,EAAO,YAAYnB,CAAQ,CAC7B,CAAC,CACH,C"}
1
+ {"version":3,"file":"treadwheel.min.js","names":["SEAL_DEFAULTS","INFO_BYTES","deriveKey","baseKey","keyData","encrypt","salt","iv","derivedKey","payload","decrypt","cipher","MAGIC_BYTES","BinaryCursor","bytes","BinaryReader","value","until","length","BinaryWriter","buffer","bytesToBigInt","result","i","bigIntToBytes","byteLength","shift","bigint","envelopeToBytes","totalSize","modulusByteLength","ciphertext","writer","v","time","modulus","base","bytesToEnvelope","reader","b","ciphertextLength","modExp","exponent","randomBigInt","randomBytes","x","strictUpperBound","mint","t","modulusLength","p","q","phi","solution","solve","encoder","decoder","sealFromPrimes","plaintext","puzzleParams","puzzle","unsealFromBytes","envelope","bytesToBase64Url","CHUNK_SIZE","binaryString","chunk","base64UrlToBytes","base64Url","base64","char","seal","config","options","keyPair","jwk","unseal","unsealInWorker","reject","handleAbort","url","worker","cleanup","event","resolve","errorEvent"],"sources":["../src/core/defaults.ts","../src/core/cipher.ts","../src/core/io.ts","../src/core/puzzle.ts","../src/core/index.ts","../src/browser/codec.ts","../src/browser/index.ts"],"sourcesContent":["import type { SealOptions } from './types.js';\n\nexport const SEAL_DEFAULTS: Required<SealOptions> = {\n time: 250_000,\n modulusLength: 2048,\n};\n","import type { Cipher } from './types.js';\n\nconst INFO_BYTES = new TextEncoder().encode('treadwheel-v1');\n\nasync function deriveKey(\n keyData: BufferSource,\n salt: BufferSource,\n): Promise<CryptoKey> {\n const baseKey = await globalThis.crypto.subtle.importKey(\n 'raw',\n keyData,\n 'HKDF',\n false,\n ['deriveKey'],\n );\n\n return await globalThis.crypto.subtle.deriveKey(\n { name: 'HKDF', hash: 'SHA-256', salt: salt, info: INFO_BYTES },\n baseKey,\n { name: 'AES-GCM', length: 256 },\n false,\n ['encrypt', 'decrypt'],\n );\n}\n\nexport async function encrypt(\n payload: Uint8Array<ArrayBuffer>,\n keyData: BufferSource,\n): Promise<Cipher> {\n const salt = globalThis.crypto.getRandomValues(new Uint8Array(32));\n const iv = globalThis.crypto.getRandomValues(new Uint8Array(12));\n\n const derivedKey = await deriveKey(keyData, salt);\n const ciphertext = new Uint8Array(\n await globalThis.crypto.subtle.encrypt(\n { name: 'AES-GCM', iv },\n derivedKey,\n payload,\n ),\n );\n\n return { salt, iv, ciphertext };\n}\n\nexport async function decrypt(\n cipher: Cipher,\n keyData: BufferSource,\n): Promise<Uint8Array<ArrayBuffer>> {\n const derivedKey = await deriveKey(keyData, cipher.salt);\n return new Uint8Array(\n await globalThis.crypto.subtle.decrypt(\n { name: 'AES-GCM', iv: cipher.iv },\n derivedKey,\n cipher.ciphertext,\n ),\n );\n}\n","import type { Envelope } from './types.js';\n\nconst MAGIC_BYTES = new Uint8Array([0xb7, 0x0f, 0xff]);\n\nclass BinaryCursor {\n protected view: DataView;\n protected bytes: Uint8Array<ArrayBuffer>;\n protected offset: number = 0;\n\n constructor(bytes: Uint8Array<ArrayBuffer>) {\n this.bytes = bytes;\n this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n }\n}\n\nclass BinaryReader extends BinaryCursor {\n public readUint8(): number {\n return this.view.getUint8(this.offset++);\n }\n\n public readUint16(): number {\n const value = this.view.getUint16(this.offset);\n this.offset += 2;\n return value;\n }\n\n public readUint32(): number {\n const value = this.view.getUint32(this.offset);\n this.offset += 4;\n return value;\n }\n\n public readBigUInt64(): bigint {\n const value = this.view.getBigUint64(this.offset);\n this.offset += 8;\n return value;\n }\n\n public readBytes(length: number): Uint8Array<ArrayBuffer> {\n const until = this.offset + length;\n if (until > this.bytes.byteLength)\n throw new Error('Malformed envelope: unexpected end of data');\n\n const bytes = this.bytes.subarray(this.offset, until);\n this.offset = until;\n return bytes;\n }\n}\n\nclass BinaryWriter extends BinaryCursor {\n public writeUint8(value: number): void {\n this.view.setUint8(this.offset++, value);\n }\n\n public writeUint16(value: number): void {\n this.view.setUint16(this.offset, value);\n this.offset += 2;\n }\n\n public writeUint32(value: number): void {\n this.view.setUint32(this.offset, value);\n this.offset += 4;\n }\n\n public writeBigUInt64(value: bigint): void {\n this.view.setBigUint64(this.offset, BigInt(value));\n this.offset += 8;\n }\n\n public writeBytes(buffer: Uint8Array): void {\n this.bytes.set(buffer, this.offset);\n this.offset += buffer.byteLength;\n }\n}\n\nexport function bytesToBigInt(bytes: Uint8Array): bigint {\n let result = 0n;\n for (let i = 0; i < bytes.length; i++) {\n result = (result << 8n) | BigInt(bytes[i] as number);\n }\n return result;\n}\n\nexport function bigIntToBytes(\n bigint: bigint,\n byteLength: number,\n): Uint8Array<ArrayBuffer> {\n const buffer = new Uint8Array(byteLength);\n for (let i = 0; i < byteLength; i++) {\n const shift = BigInt((byteLength - 1 - i) * 8);\n buffer[i] = Number((bigint >> shift) & 0xffn);\n }\n return buffer;\n}\n\nexport function envelopeToBytes({\n v,\n modulusByteLength,\n time,\n modulus,\n base,\n salt,\n iv,\n ciphertext,\n}: Envelope): Uint8Array<ArrayBuffer> {\n // header: some magic bytes, 1 version, 8 for t, 2 mod length, 4 ct length\n const headerSize = MAGIC_BYTES.byteLength + 15;\n const totalSize =\n headerSize +\n 2 * modulusByteLength +\n salt.byteLength +\n iv.byteLength +\n ciphertext.byteLength;\n\n const bytes = new Uint8Array(totalSize);\n const writer = new BinaryWriter(bytes);\n\n writer.writeBytes(MAGIC_BYTES);\n writer.writeUint8(v);\n\n writer.writeUint16(modulusByteLength);\n writer.writeUint32(ciphertext.byteLength);\n\n writer.writeBigUInt64(time);\n writer.writeBytes(bigIntToBytes(modulus, modulusByteLength));\n writer.writeBytes(bigIntToBytes(base, modulusByteLength));\n\n writer.writeBytes(salt);\n writer.writeBytes(iv);\n writer.writeBytes(ciphertext);\n\n return bytes;\n}\n\nexport function bytesToEnvelope(bytes: Uint8Array<ArrayBuffer>): Envelope {\n const reader = new BinaryReader(bytes);\n\n const magicBytes = reader.readBytes(MAGIC_BYTES.byteLength);\n if (!magicBytes.every((b, i) => b === MAGIC_BYTES[i]))\n throw new Error('Invalid envelope: magic bytes mismatch');\n\n const v = reader.readUint8();\n if (v !== 1) throw new Error(`Unsupported envelope version ${v}`);\n\n const modulusByteLength = reader.readUint16();\n const ciphertextLength = reader.readUint32();\n\n const time = reader.readBigUInt64();\n const modulus = bytesToBigInt(reader.readBytes(modulusByteLength));\n const base = bytesToBigInt(reader.readBytes(modulusByteLength));\n\n const salt = reader.readBytes(32);\n const iv = reader.readBytes(12);\n const ciphertext = reader.readBytes(ciphertextLength);\n\n return { v, modulusByteLength, time, modulus, base, salt, iv, ciphertext };\n}\n","import { bytesToBigInt } from './io.js';\nimport type { Puzzle, PuzzleParams } from './types.js';\n\nfunction modExp(base: bigint, exponent: bigint, modulus: bigint): bigint {\n if (modulus === 1n) return 0n;\n let result = 1n;\n base = base % modulus;\n while (exponent > 0n) {\n if ((exponent & 1n) === 1n) result = (result * base) % modulus;\n exponent >>= 1n;\n base = (base * base) % modulus;\n }\n return result;\n}\n\nfunction randomBigInt(strictUpperBound: bigint, byteLength: number): bigint {\n // Oversample by 16 bytes to reduce modulo bias\n const randomBytes = new Uint8Array(byteLength + 16);\n globalThis.crypto.getRandomValues(randomBytes);\n\n let x = bytesToBigInt(randomBytes) % strictUpperBound;\n if (x <= 1n) x = 2n;\n return x;\n}\n\nexport function mint(\n p: bigint,\n q: bigint,\n { time, modulusLength }: PuzzleParams,\n): { puzzle: Puzzle; solution: bigint } {\n if (!Number.isSafeInteger(time) || time < 0)\n throw new RangeError(\"Option 'time' must be a non-negative safe integer\");\n\n const t = BigInt(time);\n const modulusByteLength = Math.ceil(modulusLength / 8);\n\n const modulus = p * q;\n const phi = (p - 1n) * (q - 1n);\n const base = randomBigInt(modulus, modulusByteLength);\n const exponent = modExp(2n, t, phi);\n const solution = modExp(base, exponent, modulus);\n\n return { puzzle: { modulusByteLength, modulus, base, time: t }, solution };\n}\n\nexport function solve({ modulus, base, time }: Puzzle): bigint {\n for (let i = 0n; i < time; i++) {\n base = (base * base) % modulus;\n }\n return base;\n}\n","import { decrypt, encrypt } from './cipher.js';\nimport { bigIntToBytes, bytesToEnvelope, envelopeToBytes } from './io.js';\nimport { mint, solve } from './puzzle.js';\nimport type { Cipher, PuzzleParams } from './types.js';\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\nexport async function sealFromPrimes(\n plaintext: string,\n p: bigint,\n q: bigint,\n puzzleParams: PuzzleParams,\n): Promise<Uint8Array<ArrayBuffer>> {\n const payload = encoder.encode(plaintext);\n const { puzzle, solution } = mint(p, q, puzzleParams);\n const keyData = bigIntToBytes(solution, puzzle.modulusByteLength);\n\n let cipher: Cipher;\n try {\n cipher = await encrypt(payload, keyData);\n } finally {\n keyData.fill(0);\n }\n\n return envelopeToBytes({ v: 1, ...puzzle, ...cipher });\n}\n\nexport async function unsealFromBytes(\n bytes: Uint8Array<ArrayBuffer>,\n): Promise<string> {\n const envelope = bytesToEnvelope(bytes);\n const solution = solve(envelope);\n const keyData = bigIntToBytes(solution, envelope.modulusByteLength);\n\n let payload: Uint8Array<ArrayBuffer>;\n try {\n payload = await decrypt(envelope, keyData);\n } finally {\n keyData.fill(0);\n }\n\n return decoder.decode(payload);\n}\n","export function bytesToBase64Url(bytes: Uint8Array): string {\n if ('toBase64' in bytes && typeof bytes.toBase64 === 'function') {\n return bytes.toBase64({ alphabet: 'base64url', omitPadding: true });\n }\n\n const CHUNK_SIZE = 0x4000;\n let binaryString = '';\n for (let i = 0; i < bytes.length; i += CHUNK_SIZE) {\n const chunk = bytes.subarray(i, i + CHUNK_SIZE);\n binaryString += String.fromCharCode(...chunk);\n }\n\n const base64 = btoa(binaryString);\n return base64.replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '');\n}\n\nexport function base64UrlToBytes(base64Url: string): Uint8Array<ArrayBuffer> {\n if (\n 'fromBase64' in Uint8Array &&\n typeof Uint8Array.fromBase64 === 'function'\n ) {\n return Uint8Array.fromBase64(base64Url, { alphabet: 'base64url' });\n }\n\n let base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');\n base64 += '=='.slice((base64.length + 2) % 4);\n return Uint8Array.from(atob(base64), (char) => char.charCodeAt(0));\n}\n","import { SEAL_DEFAULTS } from '../core/defaults.js';\nimport { sealFromPrimes, unsealFromBytes } from '../core/index.js';\nimport { bytesToBigInt } from '../core/io.js';\nimport type { SealOptions, UnsealInWorkerOptions } from '../core/types.js';\nimport { base64UrlToBytes, bytesToBase64Url } from './codec.js';\n\nexport type { SealOptions, UnsealInWorkerOptions };\n\n/**\n * Seal plaintext using a time-lock puzzle.\n *\n * @param plaintext - The plaintext to seal.\n * @param options - Optional configuration options.\n * @returns A Base64URL-encoded envelope.\n */\nexport async function seal(\n plaintext: string,\n options?: SealOptions,\n): Promise<string> {\n const config = { ...SEAL_DEFAULTS, ...options };\n\n const keyPair = await globalThis.crypto.subtle.generateKey(\n {\n name: 'RSA-OAEP',\n modulusLength: config.modulusLength,\n publicExponent: new Uint8Array([0x01, 0x00, 0x01]),\n hash: 'SHA-256',\n },\n true,\n ['decrypt'],\n );\n const jwk = await globalThis.crypto.subtle.exportKey(\n 'jwk',\n keyPair.privateKey,\n );\n\n if (!jwk.p || !jwk.q) throw new Error('RSA JWK is missing primes p or q');\n const p = bytesToBigInt(base64UrlToBytes(jwk.p));\n const q = bytesToBigInt(base64UrlToBytes(jwk.q));\n\n return bytesToBase64Url(await sealFromPrimes(plaintext, p, q, config));\n}\n\n/**\n * Unseal an envelope by solving its time-lock puzzle.\n *\n * @param envelope - A Base64URL-encoded envelope.\n * @returns The decrypted plaintext.\n */\nexport async function unseal(envelope: string): Promise<string> {\n if (!globalThis.crypto?.subtle)\n throw new Error('Web Crypto API is not available');\n\n return await unsealFromBytes(base64UrlToBytes(envelope));\n}\n\n/**\n * Unseal an envelope in a web worker.\n *\n * @param envelope - A Base64URL-encoded envelope.\n * @param options - Optional configuration options.\n * @returns The decrypted plaintext.\n */\nexport function unsealInWorker(\n envelope: string,\n options?: UnsealInWorkerOptions,\n): Promise<string> {\n return new Promise((resolve, reject) => {\n if (options?.signal?.aborted) return reject(options.signal.reason);\n options?.signal?.addEventListener('abort', handleAbort);\n\n const worker = new Worker(new URL('./worker.js', import.meta.url), {\n type: 'module',\n });\n\n const cleanup = () => {\n worker.terminate();\n options?.signal?.removeEventListener('abort', handleAbort);\n };\n\n worker.onmessage = (event) => {\n if (event.data.success) resolve(event.data.plaintext);\n else reject(event.data.error);\n cleanup();\n };\n\n worker.onerror = (errorEvent) => {\n errorEvent.preventDefault();\n reject(errorEvent.error ?? new Error(errorEvent.message));\n cleanup();\n };\n\n function handleAbort(event: Event) {\n reject((event.target as AbortSignal).reason);\n cleanup();\n }\n\n worker.postMessage(envelope);\n });\n}\n"],"mappings":"AAEA,MAAaA,EAAuC,CAClD,KAAM,KACN,cAAe,IACjB,ECHMC,EAAa,IAAI,YAAY,CAAC,CAAC,OAAO,eAAe,EAE3D,eAAeC,EACb,EACA,EACoB,CACpB,IAAMC,EAAU,MAAM,WAAW,OAAO,OAAO,UAC7C,MACAC,EACA,OACA,GACA,CAAC,WAAW,CACd,EAEA,OAAO,MAAM,WAAW,OAAO,OAAO,UACpC,CAAE,KAAM,OAAQ,KAAM,UAAiB,OAAM,KAAMH,CAAW,EAC9DE,EACA,CAAE,KAAM,UAAW,OAAQ,GAAI,EAC/B,GACA,CAAC,UAAW,SAAS,CACvB,CACF,CAEA,eAAsBE,EACpB,EACA,EACiB,CACjB,IAAMC,EAAO,WAAW,OAAO,gCAAgB,IAAI,WAAW,EAAE,CAAC,EAC3DC,EAAK,WAAW,OAAO,gCAAgB,IAAI,WAAW,EAAE,CAAC,EAEzDC,EAAa,MAAMN,EAAUE,EAASE,CAAI,EAShD,MAAO,CAAE,OAAM,KAAI,WAAA,IARI,WACrB,MAAM,WAAW,OAAO,OAAO,QAC7B,CAAE,KAAM,UAAW,IAAG,EACtBE,EACAC,CACF,CAG0B,CAAE,CAChC,CAEA,eAAsBC,EACpB,EACA,EACkC,CAClC,IAAMF,EAAa,MAAMN,EAAUE,EA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B,MAAU,MAAM,iCAAiC,EAEnD,OAAO,MAAMf,EAAgBM,EAAiBL,CAAQ,CAAC,CACzD,CASA,SAAgBe,EACd,EACA,EACiB,CACjB,OAAO,IAAI,SAAS,EAAS,IAAW,CACtC,GAAIJ,GAAS,QAAQ,QAAS,OAAOK,EAAOL,EAAQ,OAAO,MAAM,EACjEA,GAAS,QAAQ,iBAAiB,QAASM,CAAW,EAEtD,IAAAC,EAAA,IAAA,gBAAA,IAAA,KAAA,CAAA,s9EAAA,EAAA,CAAA,KAAA,wBAAA,CAAA,CAAA,EAAAC,EAAA,IAAA,OAAAD,CAAA,EAAA,IAAA,gBAAAA,CAAA,EAIA,IAAME,MAAgB,CACpBD,EAAO,UAAU,EACjBR,GAAS,QAAQ,oBAAoB,QAASM,CAAW,CAC3D,EAEA,EAAO,UAAa,GAAU,CACxBI,EAAM,KAAK,QAASC,EAAQD,EAAM,KAAK,SAAS,EAC/CL,EAAOK,EAAM,KAAK,KAAK,EAC5BD,EAAQ,CACV,EAEA,EAAO,QAAW,GAAe,CAC/BG,EAAW,eAAe,EAC1BP,EAAOO,EAAW,OAAa,MAAMA,EAAW,OAAO,CAAC,EACxDH,EAAQ,CACV,EAEA,SAASH,EAAY,EAAc,CACjCD,EAAQK,EAAM,OAAuB,MAAM,EAC3CD,EAAQ,CACV,CAEAD,EAAO,YAAYnB,CAAQ,CAC7B,CAAC,CACH,C"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "treadwheel",
3
- "version": "1.0.0",
4
- "description": "Time-release encryption for automated extraction deterrence",
3
+ "version": "1.0.2",
4
+ "description": "Time-release encryption to protect sensitive information from bots",
5
5
  "keywords": [
6
6
  "anti-scraping",
7
7
  "bot-protection",
@@ -11,7 +11,7 @@
11
11
  "time-lock-puzzle",
12
12
  "time-release-cryptography"
13
13
  ],
14
- "homepage": "https://github.com/jo-phil/treadwheel",
14
+ "homepage": "https://jo-phil.github.io/treadwheel/",
15
15
  "bugs": {
16
16
  "url": "https://github.com/jo-phil/treadwheel/issues"
17
17
  },
@@ -59,7 +59,10 @@
59
59
  "test": "vitest run",
60
60
  "test:cov": "vitest run --coverage",
61
61
  "test:dev": "vitest unit",
62
- "validate": "pnpm check && pnpm lint && pnpm test"
62
+ "validate": "pnpm check && pnpm lint && pnpm test",
63
+ "docs:dev": "typedoc --watch & vitepress dev docs",
64
+ "docs:build": "typedoc && vitepress build docs",
65
+ "docs:preview": "vitepress preview docs"
63
66
  },
64
67
  "devDependencies": {
65
68
  "@biomejs/biome": "2.5.6",
@@ -77,6 +80,7 @@
77
80
  "typedoc": "^0.28.20",
78
81
  "typedoc-plugin-markdown": "^4.14.1",
79
82
  "typescript": "^5.9.3",
83
+ "vitepress": "^1.6.4",
80
84
  "vitest": "^5.0.5"
81
85
  },
82
86
  "packageManager": "pnpm@12.16.1",
@@ -1 +0,0 @@
1
- {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/browser/codec.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAc1D;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAW3E"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/browser/codec.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,gBAAgB,CAAC,KAAiB;IAChD,IAAI,UAAU,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,QAAQ,KAAK,UAAU,EAAE,CAAC;QAChE,OAAO,KAAK,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;IACtE,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC;IAC1B,IAAI,YAAY,GAAG,EAAE,CAAC;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,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EF,MAAM,CAAC,SAAS,GAAG,CAAC,KAAK,EAAE,EAAE;YAC3B,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO;gBAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;;gBACjD,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC9B,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC;QAEF,MAAM,CAAC,OAAO,GAAG,CAAC,UAAU,EAAE,EAAE;YAC9B,UAAU,CAAC,cAAc,EAAE,CAAC;YAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;YAC1D,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC;QAEF,SAAS,WAAW,CAAC,KAAY;YAC/B,MAAM,CAAE,KAAK,CAAC,MAAsB,CAAC,MAAM,CAAC,CAAC;YAC7C,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../../src/browser/widget.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"widget.js","sourceRoot":"","sources":["../../src/browser/widget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC;AAExB,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;AACpD,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3D,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC1D,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAClD,YAAY,EACZ,GAAG,EAAE;YACH,IAAI,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC;gBAAE,OAAO;YACxC,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACjC,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC,EACD,EAAE,IAAI,EAAE,IAAI,EAAE,CACf,CAAC;IACJ,CAAC;IAED,iBAAiB;QACf,IAAI,CAAC,gBAAgB,GAAG,IAAI,eAAe,EAAE,CAAC;IAChD,CAAC;IAED,oBAAoB;QAClB,IAAI,CAAC,gBAAgB,EAAE,KAAK,EAAE,CAAC;IACjC,CAAC;CAqDF;AAED,cAAc,CAAC,MAAM,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/browser/worker.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/browser/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,IAAI,CAAC,SAAS,GAAG,KAAK,EAAE,CAAe,EAAE,EAAE;IACzC,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IACjD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,WAAW,CAAC;YACf,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACjE,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"cipher.d.ts","sourceRoot":"","sources":["../../src/core/cipher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAyBzC,wBAAsB,OAAO,CAC3B,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC,EAChC,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,MAAM,CAAC,CAcjB;AAED,wBAAsB,OAAO,CAC3B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CASlC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"cipher.js","sourceRoot":"","sources":["../../src/core/cipher.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;AAE7D,KAAK,UAAU,SAAS,CACtB,OAAqB,EACrB,IAAkB;IAElB,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CACtD,KAAK,EACL,OAAO,EACP,MAAM,EACN,KAAK,EACL,CAAC,WAAW,CAAC,CACd,CAAC;IAEF,OAAO,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAC7C,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,EAC/D,OAAO,EACP,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,EAChC,KAAK,EACL,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1
- {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/core/defaults.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAA0B;IAClD,IAAI,EAAE,MAAO;IACb,aAAa,EAAE,IAAI;CACpB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAU,YAAY,EAAE,MAAM,YAAY,CAAC;AAKvD,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,EACjB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAalC;AAED,wBAAsB,eAAe,CACnC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,GAC7B,OAAO,CAAC,MAAM,CAAC,CAajB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAG1C,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAClC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,SAAiB,EACjB,CAAS,EACT,CAAS,EACT,YAA0B;IAE1B,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC1C,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC;IACtD,MAAM,OAAO,GAAG,aA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C,UAAU,EAAE,CAAC;IAC9C,MAAM,gBAAgB,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;IAE7C,MAAM,IAAI,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;IACpC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACnE,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAEhE,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAClC,MAAM,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAChC,MAAM,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAEtD,OAAO,EAAE,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC;AAC7E,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"puzzle.d.ts","sourceRoot":"","sources":["../../src/core/puzzle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAwBvD,wBAAgB,IAAI,CAClB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,YAAY,GACpC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CActC;AAED,wBAAgB,KAAK,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,MAAM,GAAG,MAAM,CAK7D"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"puzzle.js","sourceRoot":"","sources":["../../src/core/puzzle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,C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C,CAAC,EAAE,CAAC,CAAC;CACN;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,YAAa,SAAQ,QAAQ,CAAC,WAAW,CAAC;CAAG;AAE9D;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CAClC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/node/cli.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/node/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,GAAG,MAAM,oBAAoB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,KAAK,GAAG;;;;;;;;sDAQwC,aAAa,CAAC,IAAI;6EACK,aAAa,CAAC,aAAa;;;;;CAKvG,CAAC;AAEF,MAAM,iBAAiB,GAAG;IACxB,gBAAgB,EAAE,IAAI;IACtB,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,GAAG;YACV,OAAO,EAAE,GAAG,aAAa,CAAC,IAAI,EAAE;SACjC;QACD,gBAAgB,EAAE;YAChB,IAAI,EAAE,QAAQ;YACd,KAAK,EA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AAU,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAC/D,CAAC;IACF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAE3E,YAAY,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;AAanD;;;;;;GAMG;AACH,wBAAsB,IAAI,CACxB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,MAAM,CAAC,CAYjB;AAED;;;;;GAKG;AACH,wBAAsB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE9D;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAuBjB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKnE,SAAS,kBAAkB,CAAC,IAAY;IACtC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,QAAQ,GAAG,CAAC,GAAiB,EAAE,KAAa,EAAE,EAAE;YACpD,IAAI,GAAG;gBAAE,MAAM,CAAC,GAA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CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACnE,OAAO,EAAE,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAExD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YACjE,UAAU,EAAE,QAAQ;SACrB,CAAC,CAAC;QAEH,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC9B,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC3B,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YACzB,OAAO,EAAE,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAC3D,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBACf,MAAM,CAAC,IAAI,KAAK,CAAC,iCAAiC,IAAI,EAAE,CAAC,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,SAAS,WAAW,CAAC,KAAY;YAC/B,MAAM,CAAE,KAAK,CAAC,MAAsB,CAAC,MAAM,CAAC,CAAC;YAC7C,MAAM,CAAC,SAAS,EAAE,CAAC;QACrB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/node/worker.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/node/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,IAAI,CAAC,UAAU;IAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;AAErE,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;AAC3C,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC"}