@lowerdeck/encryption 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.
@@ -0,0 +1,9 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(npm run build:*)"
5
+ ],
6
+ "deny": [],
7
+ "ask": []
8
+ }
9
+ }
@@ -0,0 +1,13 @@
1
+
2
+ $ microbundle
3
+ No name was provided for external module '@lowerdeck/id' in output.globals – guessing 'id'
4
+ No name was provided for external module '@lowerdeck/base62' in output.globals – guessing 'base62'
5
+ Build "@lowerdeck/encryption" to dist:
6
+ 878 B: index.cjs.gz
7
+ 788 B: index.cjs.br
8
+ 730 B: index.module.js.gz
9
+ 672 B: index.module.js.br
10
+ 849 B: index.module.js.gz
11
+ 767 B: index.module.js.br
12
+ 964 B: index.umd.js.gz
13
+ 862 B: index.umd.js.br
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @lowerdeck/encryption
2
+
3
+ ## 1.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix salts
@@ -0,0 +1,5 @@
1
+ export declare let base86: {
2
+ encode: (input: string | Uint8Array) => string;
3
+ decode: (input: string) => Uint8Array<ArrayBufferLike>;
4
+ };
5
+ //# sourceMappingURL=base86.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base86.d.ts","sourceRoot":"","sources":["../src/base86.ts"],"names":[],"mappings":"AAMA,eAAO,IAAI,MAAM;oBACC,MAAM,GAAG,UAAU;oBAEnB,MAAM;CACvB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare let secretsCrypto: {
2
+ encrypt: (secretData: string, password: string) => Promise<string>;
3
+ decrypt: (encryptedData: string, password: string) => Promise<string>;
4
+ sha512: (data: string) => Promise<string>;
5
+ };
6
+ //# sourceMappingURL=crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"AAsEA,eAAO,IAAI,aAAa;0BA/Ca,MAAM,YAAY,MAAM;6BAuBrB,MAAM,YAAY,MAAM;mBAmBtC,MAAM;CAS/B,CAAC"}
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ var e=require("@lowerdeck/id"),r=require("@lowerdeck/base62");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=/*#__PURE__*/t(require("base-x")).default("!#$%()*+-.0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~§"),o=new TextEncoder,c=new TextDecoder,i=function(e){return crypto.subtle.importKey("raw",o.encode(e),"PBKDF2",!1,["deriveKey"])},s=function(e,r,t){return crypto.subtle.deriveKey({name:"PBKDF2",salt:r,iterations:25e4,hash:"SHA-256"},e,{name:"AES-GCM",length:256},!1,t)},u={encrypt:function(e,r){try{var t=crypto.getRandomValues(new Uint8Array(16)),c=crypto.getRandomValues(new Uint8Array(12));return Promise.resolve(i(r)).then(function(r){return Promise.resolve(s(r,t,["encrypt"])).then(function(r){return Promise.resolve(crypto.subtle.encrypt({name:"AES-GCM",iv:c},r,o.encode(e))).then(function(e){var r,o=new Uint8Array(e),i=new Uint8Array(t.byteLength+c.byteLength+o.byteLength);return i.set(t,0),i.set(c,t.byteLength),i.set(o,t.byteLength+c.byteLength),n.encode("string"==typeof(r=i)?(new TextEncoder).encode(r):r)})})})}catch(e){return Promise.reject(e)}},decrypt:function(e,r){try{var t=n.decode(e),o=t.slice(0,16),u=t.slice(16,28),a=t.slice(28);return Promise.resolve(i(r)).then(function(e){return Promise.resolve(s(e,o,["decrypt"])).then(function(e){return Promise.resolve(crypto.subtle.decrypt({name:"AES-GCM",iv:u},e,a)).then(function(e){return c.decode(e)})})})}catch(e){return Promise.reject(e)}},sha512:function(e){try{return Promise.resolve(crypto.subtle.digest("SHA-512",o.encode(e))).then(function(e){return r.base62.encode(new Uint8Array(e))})}catch(e){return Promise.reject(e)}}};exports.Encryption=/*#__PURE__*/function(){function r(e){this.password=void 0,this.password=e}var t=r.prototype;return t.getPassword=function(e){try{return Promise.resolve(u.sha512(""+e+this.password)).then(function(e){return e.slice(0,50)})}catch(e){return Promise.reject(e)}},t.encrypt=function(r){try{var t=u.encrypt,n=JSON.stringify({id:e.generatePlainId(10),key:r.secret});return Promise.resolve(this.getPassword(r.entityId)).then(function(e){return Promise.resolve(t.call(u,n,e))})}catch(e){return Promise.reject(e)}},t.decrypt=function(e){try{var r=u.decrypt,t=e.encrypted;return Promise.resolve(this.getPassword(e.entityId)).then(function(e){return Promise.resolve(r.call(u,t,e)).then(function(e){return JSON.parse(e).key})})}catch(e){return Promise.reject(e)}},r}();
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/base86.ts","../src/crypto.ts","../src/index.ts"],"sourcesContent":["import baseX from 'base-x';\n\nlet internal = baseX(\n '!#$%()*+-.0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~§'\n);\n\nexport let base86 = {\n encode: (input: string | Uint8Array) =>\n internal.encode(typeof input == 'string' ? new TextEncoder().encode(input) : input),\n decode: (input: string) => internal.decode(input)\n};\n","import { base62 } from '@lowerdeck/base62';\nimport { base86 } from './base86';\n\nlet enc = new TextEncoder();\nlet dec = new TextDecoder();\n\nlet getPasswordKey = (password: string) =>\n crypto.subtle.importKey('raw', enc.encode(password), 'PBKDF2', false, ['deriveKey']);\n\nlet deriveKey = (passwordKey: CryptoKey, salt: BufferSource, keyUsage: ('encrypt' | 'decrypt')[]) =>\n crypto.subtle.deriveKey(\n {\n name: 'PBKDF2',\n salt: salt,\n iterations: 250000,\n hash: 'SHA-256'\n },\n passwordKey,\n { name: 'AES-GCM', length: 256 },\n false,\n keyUsage\n );\n\nlet encryptData = async (secretData: string, password: string) => {\n let salt = crypto.getRandomValues(new Uint8Array(16));\n let iv = crypto.getRandomValues(new Uint8Array(12));\n let passwordKey = await getPasswordKey(password);\n let aesKey = await deriveKey(passwordKey, salt, ['encrypt']);\n let encryptedContent = await crypto.subtle.encrypt(\n {\n name: 'AES-GCM',\n iv\n },\n aesKey,\n enc.encode(secretData)\n );\n\n let encryptedContentArr = new Uint8Array(encryptedContent);\n let buff = new Uint8Array(salt.byteLength + iv.byteLength + encryptedContentArr.byteLength);\n buff.set(salt, 0);\n buff.set(iv, salt.byteLength);\n buff.set(encryptedContentArr, salt.byteLength + iv.byteLength);\n\n return base86.encode(buff);\n};\n\nlet decryptData = async (encryptedData: string, password: string) => {\n let encryptedDataBuff = base86.decode(encryptedData);\n let salt = encryptedDataBuff.slice(0, 16);\n let iv = encryptedDataBuff.slice(16, 28);\n let data = encryptedDataBuff.slice(28);\n let passwordKey = await getPasswordKey(password);\n let aesKey = await deriveKey(passwordKey, salt, ['decrypt']);\n let decryptedContent = await crypto.subtle.decrypt(\n {\n name: 'AES-GCM',\n iv\n },\n aesKey,\n data\n );\n\n return dec.decode(decryptedContent);\n};\n\nlet sha512 = async (data: string) => {\n let hashBuffer = await crypto.subtle.digest('SHA-512', enc.encode(data));\n return base62.encode(new Uint8Array(hashBuffer));\n};\n\nexport let secretsCrypto = {\n encrypt: encryptData,\n decrypt: decryptData,\n sha512\n};\n","import { generatePlainId } from '@lowerdeck/id';\nimport { secretsCrypto } from './crypto';\n\nexport class Encryption {\n constructor(private readonly password: string) {}\n\n private async getPassword(entityId: string) {\n return (await secretsCrypto.sha512(`${entityId}${this.password!}`)).slice(0, 50);\n }\n\n async encrypt(input: { secret: string; entityId: string }) {\n return await secretsCrypto.encrypt(\n JSON.stringify({\n id: generatePlainId(10),\n key: input.secret\n }),\n await this.getPassword(input.entityId)\n );\n }\n\n async decrypt(info: { encrypted: string; entityId: string }) {\n let content = JSON.parse(\n await secretsCrypto.decrypt(info.encrypted, await this.getPassword(info.entityId))\n );\n\n return content.key;\n }\n}\n"],"names":["internal","baseX","enc","TextEncoder","dec","TextDecoder","getPasswordKey","password","crypto","subtle","importKey","encode","deriveKey","passwordKey","salt","keyUsage","name","iterations","hash","length","secretsCrypto","encrypt","secretData","getRandomValues","Uint8Array","iv","Promise","resolve","then","aesKey","encryptedContent","input","encryptedContentArr","buff","byteLength","set","e","reject","decrypt","encryptedData","encryptedDataBuff","decode","slice","data","decryptedContent","sha512","digest","hashBuffer","base62","Encryption","this","_proto","prototype","getPassword","entityId","_secretsCrypto$sha","_this2","_encrypt","_JSON$stringify","JSON","stringify","id","generatePlainId","key","secret","_this2$getPassword","call","info","_this3","_decrypt","_info$encrypted","encrypted","_this3$getPassword","_secretsCrypto$decryp","parse"],"mappings":"0IAEIA,oCAAWC,QACb,0FCAEC,EAAM,IAAIC,YACVC,EAAM,IAAIC,YAEVC,EAAiB,SAACC,GAAgB,OACpCC,OAAOC,OAAOC,UAAU,MAAOR,EAAIS,OAAOJ,GAAW,UAAU,EAAO,CAAC,aAAa,EAElFK,EAAY,SAACC,EAAwBC,EAAoBC,GAAmC,OAC9FP,OAAOC,OAAOG,UACZ,CACEI,KAAM,SACNF,KAAMA,EACNG,WAAY,KACZC,KAAM,WAERL,EACA,CAAEG,KAAM,UAAWG,OAAQ,MAC3B,EACAJ,EACD,EAiDQK,EAAgB,CACzBC,QAhDa,SAAUC,EAAoBf,GAAoB,IAC/D,IAAIO,EAAON,OAAOe,gBAAgB,IAAIC,WAAW,KAC7CC,EAAKjB,OAAOe,gBAAgB,IAAIC,WAAW,KAAK,OAAAE,QAAAC,QAC5BrB,EAAeC,IAASqB,KAAA,SAA5Cf,GAAW,OAAAa,QAAAC,QACIf,EAAUC,EAAaC,EAAM,CAAC,aAAWc,KAAxDC,SAAAA,GAAMH,OAAAA,QAAAC,QACmBnB,OAAOC,OAAOY,QACzC,CACEL,KAAM,UACNS,GAAAA,GAEFI,EACA3B,EAAIS,OAAOW,KACZM,KAAA,SAPGE,GASJ,ID9BSC,EC8BLC,EAAsB,IAAIR,WAAWM,GACrCG,E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iBAAAD,EAEnCE,YAAA,SAAYC,GAAgB,IACa5B,OAAAA,QAAAC,QAAvCP,EAAcyB,OAAUS,GAAAA,EAAWJ,KAAK3C,WAAYqB,KAAA2B,SAAAA,GAAlE,OAAOA,EAA6Db,MAAM,EAAG,GAAI,EACnF,CAAC,MAAAN,GAAA,OAAAV,QAAAW,OAAAD,EAAA,CAAA,EAAAe,EAEK9B,QAAO,SAACU,GAA2C,IAAAyB,IAM3CC,EALCrC,EAAcC,QAAOqC,EAChCC,KAAKC,UAAU,CACbC,GAAIC,EAAeA,gBAAC,IACpBC,IAAKhC,EAAMiC,SACX,OAAAtC,QAAAC,QACIuB,KAAKG,YAAYtB,EAAMuB,WAAS1B,KAAAqC,SAAAA,GAAAvC,OAAAA,QAAAC,QAAA8B,EAAAS,KAL3B9C,EAAasC,EAAAO,GAO5B,EAAA,CAAC,MAAA7B,GAAAV,OAAAA,QAAAW,OAAAD,EAAAe,CAAAA,EAAAA,EAEKb,QAAA,SAAQ6B,GAA6C,IAAAC,IAEDC,EAAhDjD,EAAckB,QAAOgC,EAACH,EAAKI,UAAS,OAAA7C,QAAAC,QAAQuB,KAAKG,YAAYc,EAAKb,WAAS1B,KAAA4C,SAAAA,GAAA9C,OAAAA,QAAAC,QAAA0C,EAAAH,KAA3E9C,EAAakD,EAAAE,IAAA5C,KAAA,SAAA6C,GAGrB,OAJcd,KAAKe,MAAKD,GAITV,GAAI,EACrB,EAAA,CAAC,MAAA3B,GAAAV,OAAAA,QAAAW,OAAAD,KAAAa,CAAA,CAtBD"}
@@ -0,0 +1,14 @@
1
+ export declare class Encryption {
2
+ private readonly password;
3
+ constructor(password: string);
4
+ private getPassword;
5
+ encrypt(input: {
6
+ secret: string;
7
+ entityId: string;
8
+ }): Promise<string>;
9
+ decrypt(info: {
10
+ encrypted: string;
11
+ entityId: string;
12
+ }): Promise<any>;
13
+ }
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,qBAAa,UAAU;IACT,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,MAAM;YAE/B,WAAW;IAInB,OAAO,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;IAUnD,OAAO,CAAC,IAAI,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;CAO5D"}
@@ -0,0 +1,2 @@
1
+ import{generatePlainId as e}from"@lowerdeck/id";import{base62 as r}from"@lowerdeck/base62";import t from"base-x";var n=t("!#$%()*+-.0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~§"),o=new TextEncoder,c=new TextDecoder,s=function(e){return crypto.subtle.importKey("raw",o.encode(e),"PBKDF2",!1,["deriveKey"])},i=function(e,r,t){return crypto.subtle.deriveKey({name:"PBKDF2",salt:r,iterations:25e4,hash:"SHA-256"},e,{name:"AES-GCM",length:256},!1,t)},u={encrypt:function(e,r){try{var t=crypto.getRandomValues(new Uint8Array(16)),c=crypto.getRandomValues(new Uint8Array(12));return Promise.resolve(s(r)).then(function(r){return Promise.resolve(i(r,t,["encrypt"])).then(function(r){return Promise.resolve(crypto.subtle.encrypt({name:"AES-GCM",iv:c},r,o.encode(e))).then(function(e){var r,o=new Uint8Array(e),s=new Uint8Array(t.byteLength+c.byteLength+o.byteLength);return s.set(t,0),s.set(c,t.byteLength),s.set(o,t.byteLength+c.byteLength),n.encode("string"==typeof(r=s)?(new TextEncoder).encode(r):r)})})})}catch(e){return Promise.reject(e)}},decrypt:function(e,r){try{var t=n.decode(e),o=t.slice(0,16),u=t.slice(16,28),y=t.slice(28);return Promise.resolve(s(r)).then(function(e){return Promise.resolve(i(e,o,["decrypt"])).then(function(e){return Promise.resolve(crypto.subtle.decrypt({name:"AES-GCM",iv:u},e,y)).then(function(e){return c.decode(e)})})})}catch(e){return Promise.reject(e)}},sha512:function(e){try{return Promise.resolve(crypto.subtle.digest("SHA-512",o.encode(e))).then(function(e){return r.encode(new Uint8Array(e))})}catch(e){return Promise.reject(e)}}},y=/*#__PURE__*/function(){function r(e){this.password=void 0,this.password=e}var t=r.prototype;return t.getPassword=function(e){try{return Promise.resolve(u.sha512(""+e+this.password)).then(function(e){return e.slice(0,50)})}catch(e){return Promise.reject(e)}},t.encrypt=function(r){try{var t=u.encrypt,n=JSON.stringify({id:e(10),key:r.secret});return Promise.resolve(this.getPassword(r.entityId)).then(function(e){return Promise.resolve(t.call(u,n,e))})}catch(e){return Promise.reject(e)}},t.decrypt=function(e){try{var r=u.decrypt,t=e.encrypted;return Promise.resolve(this.getPassword(e.entityId)).then(function(e){return Promise.resolve(r.call(u,t,e)).then(function(e){return JSON.parse(e).key})})}catch(e){return Promise.reject(e)}},r}();export{y as Encryption};
2
+ //# sourceMappingURL=index.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.module.js","sources":["../src/base86.ts","../src/crypto.ts","../src/index.ts"],"sourcesContent":["import baseX from 'base-x';\n\nlet internal = baseX(\n '!#$%()*+-.0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~§'\n);\n\nexport let base86 = {\n encode: (input: string | Uint8Array) =>\n internal.encode(typeof input == 'string' ? new TextEncoder().encode(input) : input),\n decode: (input: string) => internal.decode(input)\n};\n","import { base62 } from '@lowerdeck/base62';\nimport { base86 } from './base86';\n\nlet enc = new TextEncoder();\nlet dec = new TextDecoder();\n\nlet getPasswordKey = (password: string) =>\n crypto.subtle.importKey('raw', enc.encode(password), 'PBKDF2', false, ['deriveKey']);\n\nlet deriveKey = (passwordKey: CryptoKey, salt: BufferSource, keyUsage: ('encrypt' | 'decrypt')[]) =>\n crypto.subtle.deriveKey(\n {\n name: 'PBKDF2',\n salt: salt,\n iterations: 250000,\n hash: 'SHA-256'\n },\n passwordKey,\n { name: 'AES-GCM', length: 256 },\n false,\n keyUsage\n );\n\nlet encryptData = async (secretData: string, password: string) => {\n let salt = crypto.getRandomValues(new Uint8Array(16));\n let iv = crypto.getRandomValues(new Uint8Array(12));\n let passwordKey = await getPasswordKey(password);\n let aesKey = await deriveKey(passwordKey, salt, ['encrypt']);\n let encryptedContent = await crypto.subtle.encrypt(\n {\n name: 'AES-GCM',\n iv\n },\n aesKey,\n enc.encode(secretData)\n );\n\n let encryptedContentArr = new Uint8Array(encryptedContent);\n let buff = new Uint8Array(salt.byteLength + iv.byteLength + encryptedContentArr.byteLength);\n buff.set(salt, 0);\n buff.set(iv, salt.byteLength);\n buff.set(encryptedContentArr, salt.byteLength + iv.byteLength);\n\n return base86.encode(buff);\n};\n\nlet decryptData = async (encryptedData: string, password: string) => {\n let encryptedDataBuff = base86.decode(encryptedData);\n let salt = encryptedDataBuff.slice(0, 16);\n let iv = encryptedDataBuff.slice(16, 28);\n let data = encryptedDataBuff.slice(28);\n let passwordKey = await getPasswordKey(password);\n let aesKey = await deriveKey(passwordKey, salt, ['decrypt']);\n let decryptedContent = await crypto.subtle.decrypt(\n {\n name: 'AES-GCM',\n iv\n },\n aesKey,\n data\n );\n\n return dec.decode(decryptedContent);\n};\n\nlet sha512 = async (data: string) => {\n let hashBuffer = await crypto.subtle.digest('SHA-512', enc.encode(data));\n return base62.encode(new Uint8Array(hashBuffer));\n};\n\nexport let secretsCrypto = {\n encrypt: encryptData,\n decrypt: decryptData,\n sha512\n};\n","import { generatePlainId } from '@lowerdeck/id';\nimport { secretsCrypto } from './crypto';\n\nexport class Encryption {\n constructor(private readonly password: string) {}\n\n private async getPassword(entityId: string) {\n return (await secretsCrypto.sha512(`${entityId}${this.password!}`)).slice(0, 50);\n }\n\n async encrypt(input: { secret: string; entityId: string }) {\n return await secretsCrypto.encrypt(\n JSON.stringify({\n id: generatePlainId(10),\n key: input.secret\n }),\n await this.getPassword(input.entityId)\n );\n }\n\n async decrypt(info: { encrypted: string; entityId: string }) {\n let content = JSON.parse(\n await secretsCrypto.decrypt(info.encrypted, await this.getPassword(info.entityId))\n );\n\n return content.key;\n }\n}\n"],"names":["internal","baseX","enc","TextEncoder","dec","TextDecoder","getPasswordKey","password","crypto","subtle","importKey","encode","deriveKey","passwordKey","salt","keyUsage","name","iterations","hash","length","secretsCrypto","encrypt","secretData","getRandomValues","Uint8Array","iv","Promise","resolve","then","aesKey","encryptedContent","input","encryptedContentArr","buff","byteLength","set","e","reject","decrypt","encryptedData","encryptedDataBuff","decode","slice","data","decryptedContent","sha512","digest","hashBuffer","base62","Encryption","this","_proto","prototype","getPassword","entityId","_secretsCrypto$sha","_this2","_encrypt","_JSON$stringify","JSON","stringify","id","generatePlainId","key","secret","_this2$getPassword","call","info","_this3","_decrypt","_info$encrypted","encrypted","_this3$getPassword","_secretsCrypto$decryp","parse"],"mappings":"iHAEA,IAAIA,EAAWC,EACb,0FCAEC,EAAM,IAAIC,YACVC,EAAM,IAAIC,YAEVC,EAAiB,SAACC,GAAgB,OACpCC,OAAOC,OAAOC,UAAU,MAAOR,EAAIS,OAAOJ,GAAW,UAAU,EAAO,CAAC,aAAa,EAElFK,EAAY,SAACC,EAAwBC,EAAoBC,GAAmC,OAC9FP,OAAOC,OAAOG,UACZ,CACEI,KAAM,SACNF,KAAMA,EACNG,WAAY,KACZC,KAAM,WAERL,EACA,CAAEG,KAAM,UAAWG,OAAQ,MAC3B,EACAJ,EACD,EAiDQK,EAAgB,CACzBC,QAhDa,SAAUC,EAAoBf,GAAoB,IAC/D,IAAIO,EAAON,OAAOe,gBAAgB,IAAIC,WAAW,KAC7CC,EAAKjB,OAAOe,gBAAgB,IAAIC,WAAW,KAAK,OAAAE,QAAAC,QAC5BrB,EAAeC,IAASqB,KAAA,SAA5Cf,GAAW,OAAAa,QAAAC,QACIf,EAAUC,EAAaC,EAAM,CAAC,aAAWc,KAAxDC,SAAAA,GAAMH,OAAAA,QAAAC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AAAX,GAAAV,OAAAA,QAAAW,OAAAD,MCjEYa,eACX,WAAA,SAAAA,EAA6B1C,GAAgB2C,KAAhB3C,cAAA,EAAA2C,KAAQ3C,SAARA,CAAmB,CAAC,IAAA4C,EAAAF,EAAAG,iBAAAD,EAEnCE,YAAA,SAAYC,GAAgB,IACa5B,OAAAA,QAAAC,QAAvCP,EAAcyB,OAAUS,GAAAA,EAAWJ,KAAK3C,WAAYqB,KAAA2B,SAAAA,GAAlE,OAAOA,EAA6Db,MAAM,EAAG,GAAI,EACnF,CAAC,MAAAN,GAAA,OAAAV,QAAAW,OAAAD,EAAA,CAAA,EAAAe,EAEK9B,QAAO,SAACU,GAA2C,IAAAyB,IAM3CC,EALCrC,EAAcC,QAAOqC,EAChCC,KAAKC,UAAU,CACbC,GAAIC,EAAgB,IACpBC,IAAKhC,EAAMiC,SACX,OAAAtC,QAAAC,QACIuB,KAAKG,YAAYtB,EAAMuB,WAAS1B,KAAAqC,SAAAA,GAAAvC,OAAAA,QAAAC,QAAA8B,EAAAS,KAL3B9C,EAAasC,EAAAO,GAO5B,EAAA,CAAC,MAAA7B,GAAAV,OAAAA,QAAAW,OAAAD,EAAAe,CAAAA,EAAAA,EAEKb,QAAA,SAAQ6B,GAA6C,IAAAC,IAEDC,EAAhDjD,EAAckB,QAAOgC,EAACH,EAAKI,UAAS,OAAA7C,QAAAC,QAAQuB,KAAKG,YAAYc,EAAKb,WAAS1B,KAAA4C,SAAAA,GAAA9C,OAAAA,QAAAC,QAAA0C,EAAAH,KAA3E9C,EAAakD,EAAAE,IAAA5C,KAAA,SAAA6C,GAGrB,OAJcd,KAAKe,MAAKD,GAITV,GAAI,EACrB,EAAA,CAAC,MAAA3B,GAAAV,OAAAA,QAAAW,OAAAD,KAAAa,CAAA,CAtBD"}
@@ -0,0 +1,2 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@lowerdeck/id"),require("@lowerdeck/base62"),require("base-x")):"function"==typeof define&&define.amd?define(["exports","@lowerdeck/id","@lowerdeck/base62","base-x"],t):t((e||self).encryption={},e.id,e.base62,e.baseX)}(this,function(e,t,r,n){function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=/*#__PURE__*/o(n).default("!#$%()*+-.0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~§"),c=new TextEncoder,s=new TextDecoder,u=function(e){return crypto.subtle.importKey("raw",c.encode(e),"PBKDF2",!1,["deriveKey"])},a=function(e,t,r){return crypto.subtle.deriveKey({name:"PBKDF2",salt:t,iterations:25e4,hash:"SHA-256"},e,{name:"AES-GCM",length:256},!1,r)},d={encrypt:function(e,t){try{var r=crypto.getRandomValues(new Uint8Array(16)),n=crypto.getRandomValues(new Uint8Array(12));return Promise.resolve(u(t)).then(function(t){return Promise.resolve(a(t,r,["encrypt"])).then(function(t){return Promise.resolve(crypto.subtle.encrypt({name:"AES-GCM",iv:n},t,c.encode(e))).then(function(e){var t,o=new Uint8Array(e),c=new Uint8Array(r.byteLength+n.byteLength+o.byteLength);return c.set(r,0),c.set(n,r.byteLength),c.set(o,r.byteLength+n.byteLength),i.encode("string"==typeof(t=c)?(new TextEncoder).encode(t):t)})})})}catch(e){return Promise.reject(e)}},decrypt:function(e,t){try{var r=i.decode(e),n=r.slice(0,16),o=r.slice(16,28),c=r.slice(28);return Promise.resolve(u(t)).then(function(e){return Promise.resolve(a(e,n,["decrypt"])).then(function(e){return Promise.resolve(crypto.subtle.decrypt({name:"AES-GCM",iv:o},e,c)).then(function(e){return s.decode(e)})})})}catch(e){return Promise.reject(e)}},sha512:function(e){try{return Promise.resolve(crypto.subtle.digest("SHA-512",c.encode(e))).then(function(e){return r.base62.encode(new Uint8Array(e))})}catch(e){return Promise.reject(e)}}};e.Encryption=/*#__PURE__*/function(){function e(e){this.password=void 0,this.password=e}var r=e.prototype;return r.getPassword=function(e){try{return Promise.resolve(d.sha512(""+e+this.password)).then(function(e){return e.slice(0,50)})}catch(e){return Promise.reject(e)}},r.encrypt=function(e){try{var r=d.encrypt,n=JSON.stringify({id:t.generatePlainId(10),key:e.secret});return Promise.resolve(this.getPassword(e.entityId)).then(function(e){return Promise.resolve(r.call(d,n,e))})}catch(e){return Promise.reject(e)}},r.decrypt=function(e){try{var t=d.decrypt,r=e.encrypted;return Promise.resolve(this.getPassword(e.entityId)).then(function(e){return Promise.resolve(t.call(d,r,e)).then(function(e){return JSON.parse(e).key})})}catch(e){return Promise.reject(e)}},e}()});
2
+ //# sourceMappingURL=index.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.umd.js","sources":["../src/base86.ts","../src/crypto.ts","../src/index.ts"],"sourcesContent":["import baseX from 'base-x';\n\nlet internal = baseX(\n '!#$%()*+-.0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~§'\n);\n\nexport let base86 = {\n encode: (input: string | Uint8Array) =>\n internal.encode(typeof input == 'string' ? new TextEncoder().encode(input) : input),\n decode: (input: string) => internal.decode(input)\n};\n","import { base62 } from '@lowerdeck/base62';\nimport { base86 } from './base86';\n\nlet enc = new TextEncoder();\nlet dec = new TextDecoder();\n\nlet getPasswordKey = (password: string) =>\n crypto.subtle.importKey('raw', enc.encode(password), 'PBKDF2', false, ['deriveKey']);\n\nlet deriveKey = (passwordKey: CryptoKey, salt: BufferSource, keyUsage: ('encrypt' | 'decrypt')[]) =>\n crypto.subtle.deriveKey(\n {\n name: 'PBKDF2',\n salt: salt,\n iterations: 250000,\n hash: 'SHA-256'\n },\n passwordKey,\n { name: 'AES-GCM', length: 256 },\n false,\n keyUsage\n );\n\nlet encryptData = async (secretData: string, password: string) => {\n let salt = crypto.getRandomValues(new Uint8Array(16));\n let iv = crypto.getRandomValues(new Uint8Array(12));\n let passwordKey = await getPasswordKey(password);\n let aesKey = await deriveKey(passwordKey, salt, ['encrypt']);\n let encryptedContent = await crypto.subtle.encrypt(\n {\n name: 'AES-GCM',\n iv\n },\n aesKey,\n enc.encode(secretData)\n );\n\n let encryptedContentArr = new Uint8Array(encryptedContent);\n let buff = new Uint8Array(salt.byteLength + iv.byteLength + encryptedContentArr.byteLength);\n buff.set(salt, 0);\n buff.set(iv, salt.byteLength);\n buff.set(encryptedContentArr, salt.byteLength + iv.byteLength);\n\n return base86.encode(buff);\n};\n\nlet decryptData = async (encryptedData: string, password: string) => {\n let encryptedDataBuff = base86.decode(encryptedData);\n let salt = encryptedDataBuff.slice(0, 16);\n let iv = encryptedDataBuff.slice(16, 28);\n let data = encryptedDataBuff.slice(28);\n let passwordKey = await getPasswordKey(password);\n let aesKey = await deriveKey(passwordKey, salt, ['decrypt']);\n let decryptedContent = await crypto.subtle.decrypt(\n {\n name: 'AES-GCM',\n iv\n },\n aesKey,\n data\n );\n\n return dec.decode(decryptedContent);\n};\n\nlet sha512 = async (data: string) => {\n let hashBuffer = await crypto.subtle.digest('SHA-512', enc.encode(data));\n return base62.encode(new Uint8Array(hashBuffer));\n};\n\nexport let secretsCrypto = {\n encrypt: encryptData,\n decrypt: decryptData,\n sha512\n};\n","import { generatePlainId } from '@lowerdeck/id';\nimport { secretsCrypto } from './crypto';\n\nexport class Encryption {\n constructor(private readonly password: string) {}\n\n private async getPassword(entityId: string) {\n return (await secretsCrypto.sha512(`${entityId}${this.password!}`)).slice(0, 50);\n }\n\n async encrypt(input: { secret: string; entityId: string }) {\n return await secretsCrypto.encrypt(\n JSON.stringify({\n id: generatePlainId(10),\n key: input.secret\n }),\n await this.getPassword(input.entityId)\n );\n }\n\n async decrypt(info: { encrypted: string; entityId: string }) {\n let content = JSON.parse(\n await secretsCrypto.decrypt(info.encrypted, await this.getPassword(info.entityId))\n );\n\n return content.key;\n }\n}\n"],"names":["internal","baseX","enc","TextEncoder","dec","TextDecoder","getPasswordKey","password","crypto","subtle","importKey","encode","deriveKey","passwordKey","salt","keyUsage","name","iterations","hash","length","secretsCrypto","encrypt","secretData","getRandomValues","Uint8Array","iv","Promise","resolve","then","aesKey","encryptedContent","input","encryptedContentArr","buff","byteLength","set","e","reject","decrypt","encryptedData","encryptedDataBuff","decode","slice","data","decryptedContent","sha512","digest","hashBuffer","base62","Encryption","this","_proto","prototype","getPassword","entityId","_secretsCrypto$sha","_this2","_encrypt","_JSON$stringify","JSON","stringify","id","generatePlainId","key","secret","_this2$getPassword","call","info","_this3","_decrypt","_info$encrypted","encrypted","_this3$getPassword","_secretsCrypto$decryp","parse"],"mappings":"icAEIA,oBAAWC,QACb,0FCAEC,EAAM,IAAIC,YACVC,EAAM,IAAIC,YAEVC,EAAiB,SAACC,GAAgB,OACpCC,OAAOC,OAAOC,UAAU,MAAOR,EAAIS,OAAOJ,GAAW,UAAU,EAAO,CAAC,aAAa,EAElFK,EAAY,SAACC,EAAwBC,EAAoBC,GAAmC,OAC9FP,OAAOC,OAAOG,UACZ,CACEI,KAAM,SACNF,KAAMA,EACNG,WAAY,KACZC,KAAM,WAERL,EACA,CAAEG,KAAM,UAAWG,OAAQ,MAC3B,EACAJ,EACD,EAiDQK,EAAgB,CACzBC,QAhDa,SAAUC,EAAoBf,GAAoB,IAC/D,IAAIO,EAAON,OAAOe,gBAAgB,IAAIC,WAAW,KAC7CC,EAAKjB,OAAOe,gBAAgB,IAAIC,WAAW,KAAK,OAAAE,QAAAC,QAC5BrB,EAAeC,IAASqB,KAAA,SAA5Cf,GAAW,OAAAa,QAAAC,QACIf,EAAUC,EAAaC,EAAM,CAAC,aAAWc,KAAxDC,SAAAA,GAAMH,OAAAA,QAAAC,QACmBnB,OAAOC,OAAOY,QACzC,CACEL,KAAM,UACNS,GAAAA,GAEFI,EACA3B,EAAIS,OAAOW,KACZM,KAAA,SAPGE,GASJ,ID9BSC,EC8BLC,EAAsB,IAAIR,WAAWM,GACrCG,EAAO,IAAIT,WAAWV,EAAKoB,WAAaT,EAAGS,WAAaF,EAAoBE,YAKhF,OAJAD,EAAKE,IAAIrB,EAAM,GACfmB,EAAKE,IAAIV,EAAIX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B,SAAAA,GAAlE,OAAOA,EAA6Db,MAAM,EAAG,GAAI,EACnF,CAAC,MAAAN,GAAA,OAAAV,QAAAW,OAAAD,EAAA,CAAA,EAAAe,EAEK9B,QAAO,SAACU,GAA2C,IAAAyB,IAM3CC,EALCrC,EAAcC,QAAOqC,EAChCC,KAAKC,UAAU,CACbC,GAAIC,EAAeA,gBAAC,IACpBC,IAAKhC,EAAMiC,SACX,OAAAtC,QAAAC,QACIuB,KAAKG,YAAYtB,EAAMuB,WAAS1B,KAAAqC,SAAAA,GAAAvC,OAAAA,QAAAC,QAAA8B,EAAAS,KAL3B9C,EAAasC,EAAAO,GAO5B,EAAA,CAAC,MAAA7B,GAAAV,OAAAA,QAAAW,OAAAD,EAAAe,CAAAA,EAAAA,EAEKb,QAAA,SAAQ6B,GAA6C,IAAAC,IAEDC,EAAhDjD,EAAckB,QAAOgC,EAACH,EAAKI,UAAS,OAAA7C,QAAAC,QAAQuB,KAAKG,YAAYc,EAAKb,WAAS1B,KAAA4C,SAAAA,GAAA9C,OAAAA,QAAAC,QAAA0C,EAAAH,KAA3E9C,EAAakD,EAAAE,IAAA5C,KAAA,SAAA6C,GAGrB,OAJcd,KAAKe,MAAKD,GAITV,GAAI,EACrB,EAAA,CAAC,MAAA3B,GAAAV,OAAAA,QAAAW,OAAAD,KAAAa,CAAA,CAtBD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowerdeck/encryption",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/crypto.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { base62 } from '@metorial/base62';
1
+ import { base62 } from '@lowerdeck/base62';
2
2
  import { base86 } from './base86';
3
3
 
4
4
  let enc = new TextEncoder();
@@ -7,10 +7,11 @@ let dec = new TextDecoder();
7
7
  let getPasswordKey = (password: string) =>
8
8
  crypto.subtle.importKey('raw', enc.encode(password), 'PBKDF2', false, ['deriveKey']);
9
9
 
10
- let deriveKey = (passwordKey: CryptoKey, keyUsage: ('encrypt' | 'decrypt')[]) =>
10
+ let deriveKey = (passwordKey: CryptoKey, salt: BufferSource, keyUsage: ('encrypt' | 'decrypt')[]) =>
11
11
  crypto.subtle.deriveKey(
12
12
  {
13
13
  name: 'PBKDF2',
14
+ salt: salt,
14
15
  iterations: 250000,
15
16
  hash: 'SHA-256'
16
17
  },
@@ -21,9 +22,10 @@ let deriveKey = (passwordKey: CryptoKey, keyUsage: ('encrypt' | 'decrypt')[]) =>
21
22
  );
22
23
 
23
24
  let encryptData = async (secretData: string, password: string) => {
25
+ let salt = crypto.getRandomValues(new Uint8Array(16));
24
26
  let iv = crypto.getRandomValues(new Uint8Array(12));
25
27
  let passwordKey = await getPasswordKey(password);
26
- let aesKey = await deriveKey(passwordKey, ['encrypt']);
28
+ let aesKey = await deriveKey(passwordKey, salt, ['encrypt']);
27
29
  let encryptedContent = await crypto.subtle.encrypt(
28
30
  {
29
31
  name: 'AES-GCM',
@@ -34,19 +36,21 @@ let encryptData = async (secretData: string, password: string) => {
34
36
  );
35
37
 
36
38
  let encryptedContentArr = new Uint8Array(encryptedContent);
37
- let buff = new Uint8Array(iv.byteLength + encryptedContentArr.byteLength);
38
- buff.set(iv, 0);
39
- buff.set(encryptedContentArr, iv.byteLength);
39
+ let buff = new Uint8Array(salt.byteLength + iv.byteLength + encryptedContentArr.byteLength);
40
+ buff.set(salt, 0);
41
+ buff.set(iv, salt.byteLength);
42
+ buff.set(encryptedContentArr, salt.byteLength + iv.byteLength);
40
43
 
41
44
  return base86.encode(buff);
42
45
  };
43
46
 
44
47
  let decryptData = async (encryptedData: string, password: string) => {
45
48
  let encryptedDataBuff = base86.decode(encryptedData);
46
- let iv = encryptedDataBuff.slice(0, 16);
47
- let data = encryptedDataBuff.slice(16);
49
+ let salt = encryptedDataBuff.slice(0, 16);
50
+ let iv = encryptedDataBuff.slice(16, 28);
51
+ let data = encryptedDataBuff.slice(28);
48
52
  let passwordKey = await getPasswordKey(password);
49
- let aesKey = await deriveKey(passwordKey, ['decrypt']);
53
+ let aesKey = await deriveKey(passwordKey, salt, ['decrypt']);
50
54
  let decryptedContent = await crypto.subtle.decrypt(
51
55
  {
52
56
  name: 'AES-GCM',
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { generatePlainId } from '@metorial/id';
1
+ import { generatePlainId } from '@lowerdeck/id';
2
2
  import { secretsCrypto } from './crypto';
3
3
 
4
4
  export class Encryption {
package/tsconfig.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/tsconfig",
3
- "extends": "@metorial/tsconfig/base.json",
3
+ "extends": "@lowerdeck/tsconfig/base.json",
4
4
  "exclude": ["dist"],
5
5
  "compilerOptions": {
6
6
  "outDir": "dist"