@secrecy/lib 1.86.2-fix-md5.1 → 1.86.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/base-client.js +6 -5
- package/dist/lib/cache.js +14 -5
- package/dist/lib/client/SecrecyCloudClient.js +2 -4
- package/dist/lib/client/SecrecyMailClient.js +12 -5
- package/dist/lib/client/data-link.js +12 -6
- package/dist/lib/client/helpers.js +34 -4
- package/dist/lib/client/index.js +6 -8
- package/dist/lib/client/upload.js +14 -12
- package/dist/lib/client.js +6 -10
- package/dist/lib/crypto/data.js +90 -145
- package/dist/lib/crypto/domain.js +3 -1
- package/dist/lib/crypto/helpers.js +1 -23
- package/dist/lib/crypto/index.js +9 -2
- package/dist/lib/error/client.js +7 -1
- package/dist/lib/react/index.js +69 -0
- package/dist/lib/transformer.js +3 -2
- package/dist/lib/utils/popup-tools.js +20 -24
- package/dist/lib/versioning.js +1 -1
- package/dist/lib/worker/md5.js +2 -2
- package/dist/lib/worker/sodium.js +15 -17
- package/dist/lib/worker/workerCodes.js +254 -0
- package/dist/types/base-client.d.ts +2 -0
- package/dist/types/cache.d.ts +7 -6
- package/dist/types/client/SecrecyMailClient.d.ts +23 -1
- package/dist/types/client/data-link.d.ts +4 -4
- package/dist/types/client/helpers.d.ts +13 -0
- package/dist/types/client/index.d.ts +4 -2
- package/dist/types/client/types/data.d.ts +1 -2
- package/dist/types/client.d.ts +75 -66
- package/dist/types/crypto/data.d.ts +1 -11
- package/dist/types/crypto/domain.d.ts +1 -0
- package/dist/types/crypto/helpers.d.ts +0 -7
- package/dist/types/error/client.d.ts +8 -0
- package/dist/types/error/index.d.ts +4 -0
- package/dist/types/react/index.d.ts +20 -0
- package/dist/types/utils/popup-tools.d.ts +2 -5
- package/dist/types/versioning.d.ts +1 -1
- package/dist/types/worker/workerCodes.d.ts +2 -0
- package/package.json +38 -16
- package/dist/lib/client/SecrecyDbClient.js +0 -3
- package/dist/lib/worker/generated/md5.js +0 -2
- package/dist/lib/worker/generated/sodium.js +0 -2
- package/dist/types/client/SecrecyDbClient.d.ts +0 -4
- package/dist/types/worker/generated/md5.d.ts +0 -1
- package/dist/types/worker/generated/sodium.d.ts +0 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { SecrecyClient } from '../client/index.js';
|
|
3
|
+
import type { SecrecyUrls } from '../base-client.js';
|
|
4
|
+
export type SecrecyStatus = 'idle' | 'loading' | 'authenticated' | 'error';
|
|
5
|
+
export interface SecrecyContextValue {
|
|
6
|
+
client: SecrecyClient | null;
|
|
7
|
+
status: SecrecyStatus;
|
|
8
|
+
error: unknown;
|
|
9
|
+
login: () => Promise<void>;
|
|
10
|
+
logout: () => Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export interface SecrecyProviderProps {
|
|
13
|
+
appId: string;
|
|
14
|
+
session?: boolean | undefined;
|
|
15
|
+
redirect?: boolean | undefined;
|
|
16
|
+
secrecyUrls?: Partial<SecrecyUrls> | undefined;
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export declare function SecrecyProvider(props: SecrecyProviderProps): ReactNode;
|
|
20
|
+
export declare function useSecrecy(): SecrecyContextValue;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TS Rewrite of https://github.com/enhancv/popup-tools
|
|
3
3
|
*/
|
|
4
|
+
import { type ClientError } from '../error/client.js';
|
|
4
5
|
type YesNo = 'yes' | 'no';
|
|
5
6
|
interface Options {
|
|
6
7
|
width?: number;
|
|
@@ -13,7 +14,7 @@ interface Options {
|
|
|
13
14
|
left?: number;
|
|
14
15
|
top?: number;
|
|
15
16
|
}
|
|
16
|
-
type Callback = (err?:
|
|
17
|
+
type Callback = (err?: ClientError, data?: unknown) => void;
|
|
17
18
|
/**
|
|
18
19
|
* Open a popup using the first argument.
|
|
19
20
|
* Wait for it to close and call the callback.
|
|
@@ -44,10 +45,6 @@ export declare function popup(url: string, name: string, options: Partial<Option
|
|
|
44
45
|
export declare function popupWithPost(url: string, postData: Record<string, string>, name: string, options: Partial<Options>, callback: Callback): Window | null;
|
|
45
46
|
/**
|
|
46
47
|
* Return html that when executed, will trigger the popup to callback with a response
|
|
47
|
-
*
|
|
48
|
-
* @param {Object}
|
|
49
|
-
* @param {String} targetOrigin origin of the opener allowed to receive `data`
|
|
50
|
-
* @return {String}
|
|
51
48
|
*/
|
|
52
49
|
export declare function popupResponse<T>(id: string, data: T, targetOrigin: string): string;
|
|
53
50
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SECRECY_LIB_VERSION = "1.
|
|
1
|
+
export declare const SECRECY_LIB_VERSION = "1.86.3";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const workerSodiumScript = "let sodium;\n\nself.sodium = {\n onload: (sod) => {\n sodium = sod\n postMessage({ event: \"ready\" })\n }\n};\n\nimportScripts('https://cdn.jsdelivr.net/gh/jedisct1/libsodium.js@0.7.15/dist/browsers/sodium.js');\nimportScripts('https://cdnjs.cloudflare.com/ajax/libs/spark-md5/3.0.0/spark-md5.min.js');\n\nfunction* chunks(arr, n) {\n for (let i = 0; i < arr.length; i += n) {\n yield arr.slice(i, i + n);\n }\n}\n\nfunction assert(c, message) {\n if (!c) {\n throw new Error(message);\n }\n}\n\nfunction encrypt(key) {\n let destroyed = false;\n const {\n state,\n header\n } = sodium.crypto_secretstream_xchacha20poly1305_init_push(key);\n\n const encrypt = (tag, plaintext) => {\n assert(destroyed === false, \"state already destroyed\");\n\n return sodium.crypto_secretstream_xchacha20poly1305_push(\n state,\n plaintext,\n null,\n tag\n );\n };\n\n function destroy() {\n assert(destroyed === false, \"state already destroyed\");\n destroyed = true;\n }\n\n return {\n encrypt,\n destroy,\n header\n };\n}\n\nfunction decrypt(header, key) {\n assert(\n header.byteLength >=\n sodium.crypto_secretstream_xchacha20poly1305_HEADERBYTES,\n \"header must be at least HEADERBYTES (\" + sodium.crypto_secretstream_xchacha20poly1305_HEADERBYTES + \") long\"\n );\n assert(\n key.byteLength >= sodium.crypto_secretstream_xchacha20poly1305_KEYBYTES,\n \"key must be at least KEYBYTES (\" + sodium.crypto_secretstream_xchacha20poly1305_KEYBYTES + \") long\"\n );\n\n let destroyed = false;\n const state = sodium.crypto_secretstream_xchacha20poly1305_init_pull(\n header,\n key\n );\n\n const decrypt = ciphertext => {\n assert(destroyed === false, \"state already destroyed\");\n\n return sodium.crypto_secretstream_xchacha20poly1305_pull(state, ciphertext);\n };\n\n function destroy() {\n assert(destroyed === false, \"state already destroyed\");\n destroyed = true;\n }\n\n return {\n decrypt,\n destroy\n };\n}\n\nconst CHUNK_SIZE = 8192;\n\nasync function encryptSecretstream(key, data, progress) {\n const { encrypt: crypt, destroy, header } = encrypt(key);\n const cryptedChunk =\n CHUNK_SIZE + sodium.crypto_secretstream_xchacha20poly1305_ABYTES;\n const max =\n Math.ceil(data.byteLength / CHUNK_SIZE) * cryptedChunk + header.byteLength;\n\n progress?.({\n percent: 0,\n total: max,\n current: 0\n });\n const final = new Uint8Array(max);\n const sparkEncrypted = new SparkMD5.ArrayBuffer();\n const spark = new SparkMD5.ArrayBuffer();\n\n final.set(header);\n sparkEncrypted.append(header);\n let total = header.byteLength;\n progress?.({\n percent: total / max,\n total: max,\n current: total\n });\n let lastPercent = total / max;\n\n for (const chunk of chunks(data, CHUNK_SIZE)) {\n spark.append(chunk);\n const tag =\n chunk.length < CHUNK_SIZE\n ? sodium.crypto_secretstream_xchacha20poly1305_TAG_FINAL\n : sodium.crypto_secretstream_xchacha20poly1305_TAG_MESSAGE;\n const crypted = crypt(tag, chunk);\n sparkEncrypted.append(crypted);\n final.set(crypted, total);\n total += crypted.byteLength;\n const percent = total / max;\n if (percent > lastPercent + 0.01) {\n progress?.({\n percent,\n total: max,\n current: total\n });\n lastPercent = percent;\n }\n }\n\n destroy();\n progress?.({\n percent: 1,\n total,\n current: total\n });\n return {\n data: final.slice(0, total),\n md5Encrypted: sparkEncrypted.end(),\n md5: spark.end()\n };\n}\n\nasync function decryptSecretstream(key, data, progress) {\n const header = data.slice(\n 0,\n sodium.crypto_secretstream_xchacha20poly1305_HEADERBYTES\n );\n data = data.slice(sodium.crypto_secretstream_xchacha20poly1305_HEADERBYTES);\n\n const { decrypt: decryptt, destroy } = decrypt(header, key);\n const chunkSize =\n CHUNK_SIZE + sodium.crypto_secretstream_xchacha20poly1305_ABYTES;\n const max = Math.ceil(data.byteLength / chunkSize) * CHUNK_SIZE;\n\n progress?.({\n percent: 0,\n total: max,\n current: 0\n });\n const final = new Uint8Array(max);\n let total = 0;\n let lastPercent = total / max;\n\n for (const chunk of chunks(data, chunkSize)) {\n const tmp = decryptt(chunk);\n final.set(tmp.message, total);\n total += tmp.message.byteLength;\n\n const percent = total / max;\n if (percent > lastPercent + 0.01) {\n progress?.({\n percent,\n total: max,\n current: total\n });\n lastPercent = percent;\n }\n }\n\n destroy();\n progress?.({\n percent: 1,\n total,\n current: total\n });\n return final.slice(0, total);\n}\n\nself.onmessage = async ({ data }) => {\n switch (data.event) {\n case \"encrypt\": {\n postMessage({ event: \"working\" })\n postMessage({\n event: \"encrypt-result\",\n data: await encryptSecretstream(data.key, data.data, progress => postMessage({\n event: \"encrypt-progress\",\n data: progress\n }))\n });\n postMessage({ event: \"ready\" })\n break;\n }\n case \"decrypt\": {\n postMessage({ event: \"working\" })\n postMessage({\n event: \"decrypt-result\",\n data: await decryptSecretstream(data.key, data.data, progress => postMessage({\n event: \"decrypt-progress\",\n data: progress\n }))\n });\n postMessage({ event: \"ready\" })\n break;\n }\n }\n}";
|
|
2
|
+
export declare const workerMd5Script = "importScripts('https://cdnjs.cloudflare.com/ajax/libs/spark-md5/3.0.0/spark-md5.min.js');\n\nfunction* chunks(arr, n) {\n for (let i = 0; i < arr.length; i += n) {\n yield arr.slice(i, i + n);\n }\n}\n\nconst CHUNK_SIZE = 8192;\n\nfunction md5(data) {\n const spark = new SparkMD5.ArrayBuffer();\n for (const chunk of chunks(data, CHUNK_SIZE)) {\n spark.append(chunk);\n }\n return spark.end();\n}\n\n\nself.onmessage = ({ data }) => {\n switch (data.event) {\n case \"md5\": {\n postMessage({\n event: \"md5-result\",\n data: md5(data.data)\n });\n break;\n }\n }\n}";
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secrecy/lib",
|
|
3
|
-
"author": "
|
|
4
|
-
"description": "
|
|
5
|
-
"version": "1.86.
|
|
3
|
+
"author": "Secrecy Team <contact@secrecy.tech>",
|
|
4
|
+
"description": "Client-side end-to-end encryption SDK for Secrecy",
|
|
5
|
+
"version": "1.86.3",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=22.21.1"
|
|
8
|
+
},
|
|
6
9
|
"repository": {
|
|
7
10
|
"type": "git",
|
|
8
11
|
"url": "https://github.com/anonymize-org/lib.git"
|
|
@@ -13,13 +16,17 @@
|
|
|
13
16
|
},
|
|
14
17
|
"homepage": "https://github.com/anonymize-org/lib#readme",
|
|
15
18
|
"keywords": [
|
|
16
|
-
"anonymize",
|
|
17
|
-
"lib",
|
|
18
19
|
"secrecy",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
20
|
+
"e2ee",
|
|
21
|
+
"encryption",
|
|
22
|
+
"libsodium",
|
|
23
|
+
"zero-knowledge",
|
|
24
|
+
"browser"
|
|
21
25
|
],
|
|
22
26
|
"type": "module",
|
|
27
|
+
"sideEffects": [
|
|
28
|
+
"./dist/lib/transformer.js"
|
|
29
|
+
],
|
|
23
30
|
"exports": {
|
|
24
31
|
".": {
|
|
25
32
|
"types": "./dist/types/index.d.ts",
|
|
@@ -42,20 +49,23 @@
|
|
|
42
49
|
"format": "prettier \"**/*.{ts,tsx,md,mdx,json}\" --check --cache --cache-strategy content --cache-location='node_modules/.cache/.prettiercache'",
|
|
43
50
|
"format:fix": "prettier \"**/*.{ts,tsx,md,mdx,json}\" --check --write --cache --cache-strategy content --cache-location='node_modules/.cache/.prettiercache'",
|
|
44
51
|
"docs": "typedoc",
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
52
|
+
"test": "bun test",
|
|
53
|
+
"test:watch": "bun test --watch",
|
|
54
|
+
"prepublishOnly": "bun run build",
|
|
55
|
+
"check-types": "tsc --noEmit",
|
|
56
|
+
"build": "node scripts/inject-version.mjs && tsc -p tsconfig.build.json",
|
|
49
57
|
"prepare": "husky",
|
|
50
|
-
"semantic-release": "semantic-release"
|
|
51
|
-
"build:workers": "bun scripts/build-workers.ts"
|
|
58
|
+
"semantic-release": "semantic-release"
|
|
52
59
|
},
|
|
53
60
|
"devDependencies": {
|
|
54
61
|
"@commitlint/cli": "^20.3.0",
|
|
55
62
|
"@commitlint/config-conventional": "^20.3.0",
|
|
63
|
+
"@happy-dom/global-registrator": "^20.11.2",
|
|
56
64
|
"@prisma/client": "6.17.1",
|
|
65
|
+
"@trpc/server": "^11.6.0",
|
|
57
66
|
"@types/bun": "^1.3.5",
|
|
58
67
|
"@types/jsonwebtoken": "^9.0.10",
|
|
68
|
+
"@types/react": "^19.2.18",
|
|
59
69
|
"@types/spark-md5": "^3.0.5",
|
|
60
70
|
"@types/streamsaver": "^2.0.5",
|
|
61
71
|
"@typescript-eslint/eslint-plugin": "^8.52.0",
|
|
@@ -69,6 +79,8 @@
|
|
|
69
79
|
"husky": "^9.1.7",
|
|
70
80
|
"npm-run-all": "^4.1.5",
|
|
71
81
|
"prettier": "^3.7.4",
|
|
82
|
+
"ethers": "^6.16.0",
|
|
83
|
+
"react": "^19.2.8",
|
|
72
84
|
"rimraf": "^6.1.2",
|
|
73
85
|
"semantic-release": "^25.0.2",
|
|
74
86
|
"typedoc": "^0.28.15",
|
|
@@ -78,13 +90,11 @@
|
|
|
78
90
|
},
|
|
79
91
|
"dependencies": {
|
|
80
92
|
"@js-temporal/polyfill": "^0.5.1",
|
|
81
|
-
"@secrecy/trpc-api-types": "1.43.0-
|
|
93
|
+
"@secrecy/trpc-api-types": "1.43.0-dev.1",
|
|
82
94
|
"@trpc/client": "11.6.0",
|
|
83
|
-
"@trpc/server": "^11.6.0",
|
|
84
95
|
"@types/libsodium-wrappers-sumo": "^0.7.8",
|
|
85
96
|
"axios": "^1.13.2",
|
|
86
97
|
"bson": "^7.0.0",
|
|
87
|
-
"ethers": "^6.16.0",
|
|
88
98
|
"file-type": "^21.3.0",
|
|
89
99
|
"jsonwebtoken": "^9.0.3",
|
|
90
100
|
"ky": "^1.14.2",
|
|
@@ -94,5 +104,17 @@
|
|
|
94
104
|
"streamsaver": "^2.0.6",
|
|
95
105
|
"superjson": "2.2.6",
|
|
96
106
|
"zod": "4.3.5"
|
|
107
|
+
},
|
|
108
|
+
"peerDependencies": {
|
|
109
|
+
"ethers": "^6.0.0",
|
|
110
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
111
|
+
},
|
|
112
|
+
"peerDependenciesMeta": {
|
|
113
|
+
"ethers": {
|
|
114
|
+
"optional": true
|
|
115
|
+
},
|
|
116
|
+
"react": {
|
|
117
|
+
"optional": true
|
|
118
|
+
}
|
|
97
119
|
}
|
|
98
120
|
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// Generated by scripts/build-workers.ts, do not edit.
|
|
2
|
-
export 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";
|