@secrecy/lib 1.86.2-fix-metrics.1 → 1.86.2-fix-crypto.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,4 @@
1
1
  import SparkMD5 from 'spark-md5';
2
- import { workerMd5Script } from './workerCodes.js';
3
2
  function* chunks(arr, n) {
4
3
  for (let i = 0; i < arr.length; i += n) {
5
4
  yield arr.slice(i, i + n);
@@ -8,8 +7,9 @@ function* chunks(arr, n) {
8
7
  const CHUNK_SIZE = 8192;
9
8
  export const md5 = process.env.NODE_ENV !== 'test'
10
9
  ? async (data) => {
10
+ const { workerMd5Script } = await import('./generated/md5.js');
11
+ const worker = new Worker(URL.createObjectURL(new Blob([workerMd5Script], { type: 'text/javascript' })));
11
12
  return await new Promise((resolve, reject) => {
12
- const worker = new Worker(URL.createObjectURL(new Blob([workerMd5Script], { type: 'text/javascript' })));
13
13
  worker.addEventListener('error', reject);
14
14
  worker.addEventListener('messageerror', reject);
15
15
  worker.addEventListener('message', ({ data }) => {
@@ -1,26 +1,18 @@
1
1
  import { decryptSecretStream, encryptSecretStream, } from '../crypto/data.js';
2
- import { workerSodiumScript } from './workerCodes.js';
3
- // const ensureNonDetachedUniqueBuffers = (
4
- // values: Transferable[]
5
- // ): Set<Transferable> =>
6
- // new Set(
7
- // values.filter(v => {
8
- // if (v instanceof ArrayBuffer) {
9
- // return v.byteLength === 0;
10
- // } else {
11
- // return true;
12
- // }
13
- // })
14
- // );
2
+ // Loaded lazily so the bundled libsodium only ships when a worker is needed.
3
+ const createSodiumWorker = async () => {
4
+ const { workerSodiumScript } = await import('./generated/sodium.js');
5
+ return new Worker(URL.createObjectURL(new Blob([workerSodiumScript], { type: 'text/javascript' })));
6
+ };
15
7
  export const encrypt = process.env.NODE_ENV !== 'test'
16
8
  ? async (key, dataToEncrypt, progress, signal) => {
9
+ const worker = await createSodiumWorker();
17
10
  return await new Promise((resolve, reject) => {
18
11
  void progress?.({
19
12
  current: 0,
20
13
  percent: 0,
21
14
  total: dataToEncrypt.byteLength,
22
15
  });
23
- const worker = new Worker(URL.createObjectURL(new Blob([workerSodiumScript], { type: 'text/javascript' })));
24
16
  worker.addEventListener('error', reject);
25
17
  worker.addEventListener('messageerror', reject);
26
18
  worker.addEventListener('message', ({ data }) => {
@@ -46,6 +38,11 @@ export const encrypt = process.env.NODE_ENV !== 'test'
46
38
  void progress?.(data.data);
47
39
  break;
48
40
  }
41
+ case 'error': {
42
+ worker.terminate();
43
+ reject(new Error(data.data));
44
+ break;
45
+ }
49
46
  case 'encrypt-result': {
50
47
  worker.terminate();
51
48
  resolve(data.data);
@@ -58,14 +55,14 @@ export const encrypt = process.env.NODE_ENV !== 'test'
58
55
  return encryptSecretStream(key, dataToEncrypt, progress, signal);
59
56
  };
60
57
  export const decrypt = process.env.NODE_ENV !== 'test'
61
- ? async (key, dataToDecrypt, progress, signal) => {
58
+ ? async (key, dataToDecrypt, progress, signal, options) => {
59
+ const worker = await createSodiumWorker();
62
60
  return await new Promise((resolve, reject) => {
63
61
  void progress?.({
64
62
  current: 0,
65
63
  percent: 0,
66
64
  total: dataToDecrypt.byteLength,
67
65
  });
68
- const worker = new Worker(URL.createObjectURL(new Blob([workerSodiumScript], { type: 'text/javascript' })));
69
66
  worker.addEventListener('error', reject);
70
67
  worker.addEventListener('messageerror', reject);
71
68
  worker.addEventListener('message', ({ data }) => {
@@ -75,6 +72,7 @@ export const decrypt = process.env.NODE_ENV !== 'test'
75
72
  event: 'decrypt',
76
73
  key,
77
74
  data: dataToDecrypt,
75
+ options,
78
76
  };
79
77
  worker.postMessage(postData, {
80
78
  transfer: [postData.data.buffer],
@@ -91,6 +89,11 @@ export const decrypt = process.env.NODE_ENV !== 'test'
91
89
  void progress?.(data.data);
92
90
  break;
93
91
  }
92
+ case 'error': {
93
+ worker.terminate();
94
+ reject(new Error(data.data));
95
+ break;
96
+ }
94
97
  case 'decrypt-result': {
95
98
  worker.terminate();
96
99
  resolve(data.data);
@@ -99,6 +102,6 @@ export const decrypt = process.env.NODE_ENV !== 'test'
99
102
  });
100
103
  });
101
104
  }
102
- : async (key, dataToDecrypt, progress, signal) => {
103
- return decryptSecretStream(key, dataToDecrypt, progress, signal);
105
+ : async (key, dataToDecrypt, progress, signal, options) => {
106
+ return decryptSecretStream(key, dataToDecrypt, progress, signal, options);
104
107
  };
@@ -3918,7 +3918,7 @@ export declare const createTRPCClient: (opts: CreateTrpcClientOptions) => import
3918
3918
  output: {
3919
3919
  id: string;
3920
3920
  name: string;
3921
- currentState: "init" | "resetting" | "ready" | "archived" | (string & Record<never, never>);
3921
+ currentState: "init" | "ready";
3922
3922
  isPrimary: boolean;
3923
3923
  parentId?: string | undefined;
3924
3924
  };
@@ -3942,7 +3942,7 @@ export declare const createTRPCClient: (opts: CreateTrpcClientOptions) => import
3942
3942
  output: {
3943
3943
  id: string;
3944
3944
  name: string;
3945
- currentState: "init" | "resetting" | "ready" | "archived" | (string & Record<never, never>);
3945
+ currentState: "init" | "ready";
3946
3946
  isPrimary: boolean;
3947
3947
  parentId?: string | undefined;
3948
3948
  };
@@ -3960,7 +3960,7 @@ export declare const createTRPCClient: (opts: CreateTrpcClientOptions) => import
3960
3960
  output: {
3961
3961
  id: string;
3962
3962
  name: string;
3963
- currentState: "init" | "resetting" | "ready" | "archived" | (string & Record<never, never>);
3963
+ currentState: "init" | "ready";
3964
3964
  isPrimary: boolean;
3965
3965
  parentId?: string | undefined;
3966
3966
  }[];
@@ -3976,7 +3976,7 @@ export declare const createTRPCClient: (opts: CreateTrpcClientOptions) => import
3976
3976
  output: {
3977
3977
  id: string;
3978
3978
  name: string;
3979
- currentState: "init" | "resetting" | "ready" | "archived" | (string & Record<never, never>);
3979
+ currentState: "init" | "ready";
3980
3980
  isPrimary: boolean;
3981
3981
  parentId?: string | undefined;
3982
3982
  };
@@ -4002,7 +4002,7 @@ export declare const createTRPCClient: (opts: CreateTrpcClientOptions) => import
4002
4002
  output: {
4003
4003
  id: string;
4004
4004
  name: string;
4005
- currentState: "init" | "resetting" | "ready" | "archived" | (string & Record<never, never>);
4005
+ currentState: "init" | "ready";
4006
4006
  isPrimary: boolean;
4007
4007
  parentId?: string | undefined;
4008
4008
  };
@@ -4017,7 +4017,7 @@ export declare const createTRPCClient: (opts: CreateTrpcClientOptions) => import
4017
4017
  output: {
4018
4018
  id: string;
4019
4019
  name: string;
4020
- currentState: "init" | "resetting" | "ready" | "archived" | (string & Record<never, never>);
4020
+ currentState: "init" | "ready";
4021
4021
  isPrimary: boolean;
4022
4022
  parentId?: string | undefined;
4023
4023
  };
@@ -10626,7 +10626,7 @@ export declare const getTrpcGuestClient: ({ url }?: {
10626
10626
  output: {
10627
10627
  id: string;
10628
10628
  name: string;
10629
- currentState: "init" | "resetting" | "ready" | "archived" | (string & Record<never, never>);
10629
+ currentState: "init" | "ready";
10630
10630
  isPrimary: boolean;
10631
10631
  parentId?: string | undefined;
10632
10632
  };
@@ -10650,7 +10650,7 @@ export declare const getTrpcGuestClient: ({ url }?: {
10650
10650
  output: {
10651
10651
  id: string;
10652
10652
  name: string;
10653
- currentState: "init" | "resetting" | "ready" | "archived" | (string & Record<never, never>);
10653
+ currentState: "init" | "ready";
10654
10654
  isPrimary: boolean;
10655
10655
  parentId?: string | undefined;
10656
10656
  };
@@ -10668,7 +10668,7 @@ export declare const getTrpcGuestClient: ({ url }?: {
10668
10668
  output: {
10669
10669
  id: string;
10670
10670
  name: string;
10671
- currentState: "init" | "resetting" | "ready" | "archived" | (string & Record<never, never>);
10671
+ currentState: "init" | "ready";
10672
10672
  isPrimary: boolean;
10673
10673
  parentId?: string | undefined;
10674
10674
  }[];
@@ -10684,7 +10684,7 @@ export declare const getTrpcGuestClient: ({ url }?: {
10684
10684
  output: {
10685
10685
  id: string;
10686
10686
  name: string;
10687
- currentState: "init" | "resetting" | "ready" | "archived" | (string & Record<never, never>);
10687
+ currentState: "init" | "ready";
10688
10688
  isPrimary: boolean;
10689
10689
  parentId?: string | undefined;
10690
10690
  };
@@ -10710,7 +10710,7 @@ export declare const getTrpcGuestClient: ({ url }?: {
10710
10710
  output: {
10711
10711
  id: string;
10712
10712
  name: string;
10713
- currentState: "init" | "resetting" | "ready" | "archived" | (string & Record<never, never>);
10713
+ currentState: "init" | "ready";
10714
10714
  isPrimary: boolean;
10715
10715
  parentId?: string | undefined;
10716
10716
  };
@@ -10725,7 +10725,7 @@ export declare const getTrpcGuestClient: ({ url }?: {
10725
10725
  output: {
10726
10726
  id: string;
10727
10727
  name: string;
10728
- currentState: "init" | "resetting" | "ready" | "archived" | (string & Record<never, never>);
10728
+ currentState: "init" | "ready";
10729
10729
  isPrimary: boolean;
10730
10730
  parentId?: string | undefined;
10731
10731
  };
@@ -3,6 +3,16 @@ export interface EncryptedFile {
3
3
  md5: string;
4
4
  md5Encrypted: string;
5
5
  }
6
+ export interface DecryptSecretStreamOptions {
7
+ /**
8
+ * Accept a stream whose last chunk is not tagged `TAG_FINAL`.
9
+ * Streams produced before the final tag was always set (size multiple of
10
+ * CHUNK_SIZE) lack it, so a truncation at a chunk boundary is undetectable
11
+ * for them: only enable this when the caller verifies the decrypted content
12
+ * independently (e.g. against a known digest).
13
+ */
14
+ allowMissingFinalTag?: boolean;
15
+ }
6
16
  export declare function secretStreamKeygen(): Uint8Array;
7
17
  export declare const CHUNK_SIZE = 8192;
8
18
  export interface SecretStreamProgress {
@@ -10,5 +20,15 @@ export interface SecretStreamProgress {
10
20
  total: number;
11
21
  current: number;
12
22
  }
23
+ /**
24
+ * Encrypt `data` as a secretstream: the header followed by one authenticated
25
+ * chunk per CHUNK_SIZE bytes of plaintext. The last chunk (an empty one for
26
+ * empty data) is always tagged `TAG_FINAL` so that truncation is detected.
27
+ */
13
28
  export declare function encryptSecretStream(key: Uint8Array, data: Uint8Array<ArrayBuffer>, progress?: (progress: SecretStreamProgress) => Promise<void>, signal?: AbortSignal): Promise<EncryptedFile>;
14
- export declare function decryptSecretStream(key: Uint8Array, data: Uint8Array<ArrayBuffer>, progress?: (progress: SecretStreamProgress) => Promise<void>, signal?: AbortSignal): Promise<Uint8Array<ArrayBuffer>>;
29
+ /**
30
+ * Decrypt a secretstream produced by `encryptSecretStream`. Throws if any
31
+ * chunk fails authentication, if data follows the `TAG_FINAL` chunk, or if the
32
+ * stream ends without it (truncation) unless `allowMissingFinalTag` is set.
33
+ */
34
+ export declare function decryptSecretStream(key: Uint8Array, data: Uint8Array<ArrayBuffer>, progress?: (progress: SecretStreamProgress) => Promise<void>, signal?: AbortSignal, options?: DecryptSecretStreamOptions): Promise<Uint8Array<ArrayBuffer>>;
@@ -1,5 +1,16 @@
1
1
  export declare function generatePassword(): string;
2
2
  export declare function derivePassword(password: string, salt: Uint8Array<ArrayBufferLike>): string;
3
+ /**
4
+ * Wrap a data key under a password, with a random salt:
5
+ * `version (1 byte) || salt || nonce || secretbox(key)`.
6
+ */
7
+ export declare function encryptKeyWithPassword(key: Uint8Array, password: string): Uint8Array;
8
+ /**
9
+ * Unwrap a data key produced by `encryptKeyWithPassword`. Also reads the
10
+ * legacy format (`nonce || secretbox(key)`) whose salt was derived from the
11
+ * password and the plaintext md5, hence `legacyMd5`.
12
+ */
13
+ export declare function decryptKeyWithPassword(wrapped: Uint8Array, password: string, legacyMd5: string): Uint8Array;
3
14
  export declare function encryptName(name: string, nameKey: string): Promise<string>;
4
15
  export declare function generateAndEncryptNameAndKey(args: {
5
16
  name: string;
@@ -46,7 +46,8 @@ export declare function popupWithPost(url: string, postData: Record<string, stri
46
46
  * Return html that when executed, will trigger the popup to callback with a response
47
47
  *
48
48
  * @param {Object}
49
+ * @param {String} targetOrigin origin of the opener allowed to receive `data`
49
50
  * @return {String}
50
51
  */
51
- export declare function popupResponse<T>(id: string, data: T): string;
52
+ export declare function popupResponse<T>(id: string, data: T, targetOrigin: string): string;
52
53
  export {};
@@ -0,0 +1 @@
1
+ export declare const workerMd5Script = "(()=>{var D=Object.create;var{getPrototypeOf:E,defineProperty:F,getOwnPropertyNames:G}=Object;var v=Object.prototype.hasOwnProperty;function H(o){return this[o]}var K,N,R=(o,u,s)=>{var _=o!=null&&typeof o===\"object\";if(_){var y=u?K??=new WeakMap:N??=new WeakMap,b=y.get(o);if(b)return b}s=o!=null?D(E(o)):{};let l=u||!o||!o.__esModule||!v.call(o,\"default\")?F(s,\"default\",{value:o,enumerable:!0}):s;if(o&&typeof o===\"object\"||typeof o===\"function\"){for(let g of G(o))if(!v.call(l,g))F(l,g,{get:H.bind(o,g),enumerable:!0})}if(_)y.set(o,l);return l};var Z=(o,u)=>()=>(u||o((u={exports:{}}).exports,u),u.exports);var S=Z(function(w,U){(function(o){if(typeof w===\"object\")U.exports=o();else if(typeof define===\"function\"&&define.amd)define(o);else{var u;try{u=window}catch(s){u=self}u.SparkMD5=o()}})(function(o){var u=function(i,f){return i+f&4294967295},s=[\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"a\",\"b\",\"c\",\"d\",\"e\",\"f\"];function _(i,f,r,t,n,e){return f=u(u(f,i),u(t,e)),u(f<<n|f>>>32-n,r)}function y(i,f){var r=i[0],t=i[1],n=i[2],e=i[3];r+=(t&n|~t&e)+f[0]-680876936|0,r=(r<<7|r>>>25)+t|0,e+=(r&t|~r&n)+f[1]-389564586|0,e=(e<<12|e>>>20)+r|0,n+=(e&r|~e&t)+f[2]+606105819|0,n=(n<<17|n>>>15)+e|0,t+=(n&e|~n&r)+f[3]-1044525330|0,t=(t<<22|t>>>10)+n|0,r+=(t&n|~t&e)+f[4]-176418897|0,r=(r<<7|r>>>25)+t|0,e+=(r&t|~r&n)+f[5]+1200080426|0,e=(e<<12|e>>>20)+r|0,n+=(e&r|~e&t)+f[6]-1473231341|0,n=(n<<17|n>>>15)+e|0,t+=(n&e|~n&r)+f[7]-45705983|0,t=(t<<22|t>>>10)+n|0,r+=(t&n|~t&e)+f[8]+1770035416|0,r=(r<<7|r>>>25)+t|0,e+=(r&t|~r&n)+f[9]-1958414417|0,e=(e<<12|e>>>20)+r|0,n+=(e&r|~e&t)+f[10]-42063|0,n=(n<<17|n>>>15)+e|0,t+=(n&e|~n&r)+f[11]-1990404162|0,t=(t<<22|t>>>10)+n|0,r+=(t&n|~t&e)+f[12]+1804603682|0,r=(r<<7|r>>>25)+t|0,e+=(r&t|~r&n)+f[13]-40341101|0,e=(e<<12|e>>>20)+r|0,n+=(e&r|~e&t)+f[14]-1502002290|0,n=(n<<17|n>>>15)+e|0,t+=(n&e|~n&r)+f[15]+1236535329|0,t=(t<<22|t>>>10)+n|0,r+=(t&e|n&~e)+f[1]-165796510|0,r=(r<<5|r>>>27)+t|0,e+=(r&n|t&~n)+f[6]-1069501632|0,e=(e<<9|e>>>23)+r|0,n+=(e&t|r&~t)+f[11]+643717713|0,n=(n<<14|n>>>18)+e|0,t+=(n&r|e&~r)+f[0]-373897302|0,t=(t<<20|t>>>12)+n|0,r+=(t&e|n&~e)+f[5]-701558691|0,r=(r<<5|r>>>27)+t|0,e+=(r&n|t&~n)+f[10]+38016083|0,e=(e<<9|e>>>23)+r|0,n+=(e&t|r&~t)+f[15]-660478335|0,n=(n<<14|n>>>18)+e|0,t+=(n&r|e&~r)+f[4]-405537848|0,t=(t<<20|t>>>12)+n|0,r+=(t&e|n&~e)+f[9]+568446438|0,r=(r<<5|r>>>27)+t|0,e+=(r&n|t&~n)+f[14]-1019803690|0,e=(e<<9|e>>>23)+r|0,n+=(e&t|r&~t)+f[3]-187363961|0,n=(n<<14|n>>>18)+e|0,t+=(n&r|e&~r)+f[8]+1163531501|0,t=(t<<20|t>>>12)+n|0,r+=(t&e|n&~e)+f[13]-1444681467|0,r=(r<<5|r>>>27)+t|0,e+=(r&n|t&~n)+f[2]-51403784|0,e=(e<<9|e>>>23)+r|0,n+=(e&t|r&~t)+f[7]+1735328473|0,n=(n<<14|n>>>18)+e|0,t+=(n&r|e&~r)+f[12]-1926607734|0,t=(t<<20|t>>>12)+n|0,r+=(t^n^e)+f[5]-378558|0,r=(r<<4|r>>>28)+t|0,e+=(r^t^n)+f[8]-2022574463|0,e=(e<<11|e>>>21)+r|0,n+=(e^r^t)+f[11]+1839030562|0,n=(n<<16|n>>>16)+e|0,t+=(n^e^r)+f[14]-35309556|0,t=(t<<23|t>>>9)+n|0,r+=(t^n^e)+f[1]-1530992060|0,r=(r<<4|r>>>28)+t|0,e+=(r^t^n)+f[4]+1272893353|0,e=(e<<11|e>>>21)+r|0,n+=(e^r^t)+f[7]-155497632|0,n=(n<<16|n>>>16)+e|0,t+=(n^e^r)+f[10]-1094730640|0,t=(t<<23|t>>>9)+n|0,r+=(t^n^e)+f[13]+681279174|0,r=(r<<4|r>>>28)+t|0,e+=(r^t^n)+f[0]-358537222|0,e=(e<<11|e>>>21)+r|0,n+=(e^r^t)+f[3]-722521979|0,n=(n<<16|n>>>16)+e|0,t+=(n^e^r)+f[6]+76029189|0,t=(t<<23|t>>>9)+n|0,r+=(t^n^e)+f[9]-640364487|0,r=(r<<4|r>>>28)+t|0,e+=(r^t^n)+f[12]-421815835|0,e=(e<<11|e>>>21)+r|0,n+=(e^r^t)+f[15]+530742520|0,n=(n<<16|n>>>16)+e|0,t+=(n^e^r)+f[2]-995338651|0,t=(t<<23|t>>>9)+n|0,r+=(n^(t|~e))+f[0]-198630844|0,r=(r<<6|r>>>26)+t|0,e+=(t^(r|~n))+f[7]+1126891415|0,e=(e<<10|e>>>22)+r|0,n+=(r^(e|~t))+f[14]-1416354905|0,n=(n<<15|n>>>17)+e|0,t+=(e^(n|~r))+f[5]-57434055|0,t=(t<<21|t>>>11)+n|0,r+=(n^(t|~e))+f[12]+1700485571|0,r=(r<<6|r>>>26)+t|0,e+=(t^(r|~n))+f[3]-1894986606|0,e=(e<<10|e>>>22)+r|0,n+=(r^(e|~t))+f[10]-1051523|0,n=(n<<15|n>>>17)+e|0,t+=(e^(n|~r))+f[1]-2054922799|0,t=(t<<21|t>>>11)+n|0,r+=(n^(t|~e))+f[8]+1873313359|0,r=(r<<6|r>>>26)+t|0,e+=(t^(r|~n))+f[15]-30611744|0,e=(e<<10|e>>>22)+r|0,n+=(r^(e|~t))+f[6]-1560198380|0,n=(n<<15|n>>>17)+e|0,t+=(e^(n|~r))+f[13]+1309151649|0,t=(t<<21|t>>>11)+n|0,r+=(n^(t|~e))+f[4]-145523070|0,r=(r<<6|r>>>26)+t|0,e+=(t^(r|~n))+f[11]-1120210379|0,e=(e<<10|e>>>22)+r|0,n+=(r^(e|~t))+f[2]+718787259|0,n=(n<<15|n>>>17)+e|0,t+=(e^(n|~r))+f[9]-343485551|0,t=(t<<21|t>>>11)+n|0,i[0]=r+i[0]|0,i[1]=t+i[1]|0,i[2]=n+i[2]|0,i[3]=e+i[3]|0}function b(i){var f=[],r;for(r=0;r<64;r+=4)f[r>>2]=i.charCodeAt(r)+(i.charCodeAt(r+1)<<8)+(i.charCodeAt(r+2)<<16)+(i.charCodeAt(r+3)<<24);return f}function l(i){var f=[],r;for(r=0;r<64;r+=4)f[r>>2]=i[r]+(i[r+1]<<8)+(i[r+2]<<16)+(i[r+3]<<24);return f}function g(i){var f=i.length,r=[1732584193,-271733879,-1732584194,271733878],t,n,e,a,c,p;for(t=64;t<=f;t+=64)y(r,b(i.substring(t-64,t)));i=i.substring(t-64),n=i.length,e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<n;t+=1)e[t>>2]|=i.charCodeAt(t)<<(t%4<<3);if(e[t>>2]|=128<<(t%4<<3),t>55){y(r,e);for(t=0;t<16;t+=1)e[t]=0}return a=f*8,a=a.toString(16).match(/(.*?)(.{0,8})$/),c=parseInt(a[2],16),p=parseInt(a[1],16)||0,e[14]=c,e[15]=p,y(r,e),r}function T(i){var f=i.length,r=[1732584193,-271733879,-1732584194,271733878],t,n,e,a,c,p;for(t=64;t<=f;t+=64)y(r,l(i.subarray(t-64,t)));i=t-64<f?i.subarray(t-64):new Uint8Array(0),n=i.length,e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<n;t+=1)e[t>>2]|=i[t]<<(t%4<<3);if(e[t>>2]|=128<<(t%4<<3),t>55){y(r,e);for(t=0;t<16;t+=1)e[t]=0}return a=f*8,a=a.toString(16).match(/(.*?)(.{0,8})$/),c=parseInt(a[2],16),p=parseInt(a[1],16)||0,e[14]=c,e[15]=p,y(r,e),r}function L(i){var f=\"\",r;for(r=0;r<4;r+=1)f+=s[i>>r*8+4&15]+s[i>>r*8&15];return f}function d(i){var f;for(f=0;f<i.length;f+=1)i[f]=L(i[f]);return i.join(\"\")}if(d(g(\"hello\"))!==\"5d41402abc4b2a76b9719d911017c592\")u=function(i,f){var r=(i&65535)+(f&65535),t=(i>>16)+(f>>16)+(r>>16);return t<<16|r&65535};if(typeof ArrayBuffer<\"u\"&&!ArrayBuffer.prototype.slice)(function(){function i(f,r){if(f=f|0||0,f<0)return Math.max(f+r,0);return Math.min(f,r)}ArrayBuffer.prototype.slice=function(f,r){var t=this.byteLength,n=i(f,t),e=t,a,c,p,B;if(r!==o)e=i(r,t);if(n>e)return new ArrayBuffer(0);return a=e-n,c=new ArrayBuffer(a),p=new Uint8Array(c),B=new Uint8Array(this,n,a),p.set(B),c}})();function m(i){if(/[\\u0080-\\uFFFF]/.test(i))i=unescape(encodeURIComponent(i));return i}function M(i,f){var r=i.length,t=new ArrayBuffer(r),n=new Uint8Array(t),e;for(e=0;e<r;e+=1)n[e]=i.charCodeAt(e);return f?n:t}function x(i){return String.fromCharCode.apply(null,new Uint8Array(i))}function j(i,f,r){var t=new Uint8Array(i.byteLength+f.byteLength);return t.set(new Uint8Array(i)),t.set(new Uint8Array(f),i.byteLength),r?t:t.buffer}function A(i){var f=[],r=i.length,t;for(t=0;t<r-1;t+=2)f.push(parseInt(i.substr(t,2),16));return String.fromCharCode.apply(String,f)}function h(){this.reset()}return h.prototype.append=function(i){return this.appendBinary(m(i)),this},h.prototype.appendBinary=function(i){this._buff+=i,this._length+=i.length;var f=this._buff.length,r;for(r=64;r<=f;r+=64)y(this._hash,b(this._buff.substring(r-64,r)));return this._buff=this._buff.substring(r-64),this},h.prototype.end=function(i){var f=this._buff,r=f.length,t,n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e;for(t=0;t<r;t+=1)n[t>>2]|=f.charCodeAt(t)<<(t%4<<3);if(this._finish(n,r),e=d(this._hash),i)e=A(e);return this.reset(),e},h.prototype.reset=function(){return this._buff=\"\",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},h.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},h.prototype.setState=function(i){return this._buff=i.buff,this._length=i.length,this._hash=i.hash,this},h.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},h.prototype._finish=function(i,f){var r=f,t,n,e;if(i[r>>2]|=128<<(r%4<<3),r>55){y(this._hash,i);for(r=0;r<16;r+=1)i[r]=0}t=this._length*8,t=t.toString(16).match(/(.*?)(.{0,8})$/),n=parseInt(t[2],16),e=parseInt(t[1],16)||0,i[14]=n,i[15]=e,y(this._hash,i)},h.hash=function(i,f){return h.hashBinary(m(i),f)},h.hashBinary=function(i,f){var r=g(i),t=d(r);return f?A(t):t},h.ArrayBuffer=function(){this.reset()},h.ArrayBuffer.prototype.append=function(i){var f=j(this._buff.buffer,i,!0),r=f.length,t;this._length+=i.byteLength;for(t=64;t<=r;t+=64)y(this._hash,l(f.subarray(t-64,t)));return this._buff=t-64<r?new Uint8Array(f.buffer.slice(t-64)):new Uint8Array(0),this},h.ArrayBuffer.prototype.end=function(i){var f=this._buff,r=f.length,t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n,e;for(n=0;n<r;n+=1)t[n>>2]|=f[n]<<(n%4<<3);if(this._finish(t,r),e=d(this._hash),i)e=A(e);return this.reset(),e},h.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},h.ArrayBuffer.prototype.getState=function(){var i=h.prototype.getState.call(this);return i.buff=x(i.buff),i},h.ArrayBuffer.prototype.setState=function(i){return i.buff=M(i.buff,!0),h.prototype.setState.call(this,i)},h.ArrayBuffer.prototype.destroy=h.prototype.destroy,h.ArrayBuffer.prototype._finish=h.prototype._finish,h.ArrayBuffer.hash=function(i,f){var r=T(new Uint8Array(i)),t=d(r);return f?A(t):t},h})});var I=R(S(),1);function*C(o,u){for(let s=0;s<o.length;s+=u)yield o.slice(s,s+u)}var q=8192;self.onmessage=({data:o})=>{if(o.event===\"md5\"){let u=new I.default.ArrayBuffer;for(let s of C(o.data,q))u.append(s.buffer);postMessage({event:\"md5-result\",data:u.end()})}};})();\n";