mol_crypto_lib 0.0.151 → 0.0.152
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/node.d.ts +4 -4
- package/node.esm.js.map +1 -1
- package/node.js.map +1 -1
- package/node.test.js +49 -117
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +4 -4
- package/web.esm.js.map +1 -1
- package/web.js.map +1 -1
- package/web.test.js +48 -116
- package/web.test.js.map +1 -1
package/node.d.ts
CHANGED
|
@@ -26,8 +26,8 @@ declare namespace $ {
|
|
|
26
26
|
static generate(): Promise<$mol_crypto_secret>;
|
|
27
27
|
static from(serial: DataView | ArrayBuffer): Promise<$mol_crypto_secret>;
|
|
28
28
|
serial(): Promise<ArrayBuffer>;
|
|
29
|
-
encrypt(open: DataView | ArrayBuffer, salt: Uint8Array): Promise<
|
|
30
|
-
decrypt(closed: DataView | ArrayBuffer, salt: Uint8Array): Promise<
|
|
29
|
+
encrypt(open: DataView | ArrayBuffer, salt: Uint8Array): Promise<ArrayBuffer>;
|
|
30
|
+
decrypt(closed: DataView | ArrayBuffer, salt: Uint8Array): Promise<ArrayBuffer>;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -46,7 +46,7 @@ declare namespace $ {
|
|
|
46
46
|
});
|
|
47
47
|
static from(serial: DataView | ArrayBuffer): Promise<$mol_crypto_cipher_public>;
|
|
48
48
|
serial(): Promise<ArrayBuffer>;
|
|
49
|
-
encrypt(data: DataView | ArrayBuffer): Promise<
|
|
49
|
+
encrypt(data: DataView | ArrayBuffer): Promise<ArrayBuffer>;
|
|
50
50
|
}
|
|
51
51
|
class $mol_crypto_cipher_private extends Object {
|
|
52
52
|
readonly native: CryptoKey & {
|
|
@@ -57,7 +57,7 @@ declare namespace $ {
|
|
|
57
57
|
});
|
|
58
58
|
static from(serial: DataView | ArrayBuffer): Promise<$mol_crypto_cipher_private>;
|
|
59
59
|
serial(): Promise<ArrayBuffer>;
|
|
60
|
-
decrypt(data: DataView | ArrayBuffer): Promise<
|
|
60
|
+
decrypt(data: DataView | ArrayBuffer): Promise<ArrayBuffer>;
|
|
61
61
|
}
|
|
62
62
|
const $mol_crypto_cipher_ecrypted_size = 128;
|
|
63
63
|
}
|
package/node.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../mam.jam.js","-","../../../../mam.ts","../../secret/secret.ts","../../cipher/cipher.ts","../../auditor/auditor.ts","../../salt/salt.ts"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACbA;AACA;AACA;AACA;;ACHA,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;AAK3B,IAAU,CAAC,CAMV;AAND,WAAU,CAAC;AAMX,CAAC,EANS,CAAC,KAAD,CAAC,QAMV;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,CAAA;;;ADblB;AACA;AACA;;AEFA,IAAU,CAAC,CA8EV;AA9ED,WAAU,CAAC;IAEV,MAAM,SAAS,GAAG;QACjB,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,GAAG;QACX,SAAS,EAAE,EAAE;KACb,CAAA;IAGD,MAAa,kBAAmB,SAAQ,MAAM;QASnC;QANV,MAAM,CAAC,IAAI,GAAG,EAAE,CAAA;QAGhB,MAAM,CAAC,KAAK,GAAG,CAAC,CAAA;QAEhB,YACU,MAAuC;YAEhD,KAAK,EAAE,CAAA;YAFE,WAAM,GAAN,MAAM,CAAiC;QAGjD,CAAC;QAED,MAAM,CAAC,KAAK,CAAC,QAAQ;YACpB,OAAO,IAAI,IAAI,CACd,MAAM,MAAM,CAAC,MAAM,CAAC,WAAW,CAC9B,SAAS,EACT,IAAI,EACJ,CAAE,SAAS,EAAE,SAAS,CAAE,CACW,CACpC,CAAA;QACF,CAAC;QAED,MAAM,CAAC,KAAK,CAAC,IAAI,CAAE,MAA8B;YAChD,OAAO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AAC,CASV;AATD,WAAU,CAAC;IAGV,SAAgB,gBAAgB;QAC/B,OAAO,MAAM,CAAC,eAAe,CAC5B,IAAI,UAAU,CAAE,CAAC,CAAE,CACnB,CAAA;IACF,CAAC;IAJe,kBAAgB,mBAI/B,CAAA;AAEF,CAAC,EATS,CAAC,KAAD,CAAC,QASV;;;ALTD","file":"node.esm.js","sourcesContent":[null,null,"Error.stackTraceLimit = 50;\n\ndeclare let _$_: { new(): {} } & typeof globalThis\ndeclare class $ extends _$_ {}\n\nnamespace $ {\n\texport type $ = typeof $$\n\texport declare class $$ extends $ {}\n\tnamespace $$ {\n\t\texport type $$ = $\n\t}\n}\n\nmodule.exports = $\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'AES-GCM',\n\t\tlength: 128,\n\t\ttagLength: 32,\n\t}\n\t\n\t/** Symmetric cipher with shortest payload */\n\texport class $mol_crypto_secret extends Object {\n\t\t\n\t\t/** Key size in bytes. */\n\t\tstatic size = 16\n\t\t\n\t\t/** Extra size in bytes to encrypted data. */\n\t\tstatic extra = 4\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async generate() {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.generateKey(\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt', 'decrypt' ]\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'raw',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt', 'decrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 16 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'raw',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\n\t\t/** 4 bytes + data length */\n\t\tasync encrypt( open: DataView | ArrayBuffer, salt: Uint8Array ) {\n\t\t\treturn await crypto.subtle.encrypt(\n\t\t\t\t{\n\t\t\t\t\t... algorithm,\n\t\t\t\t\tiv: salt,\n\t\t\t\t},\n\t\t\t\tthis.native,\n\t\t\t\topen\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync decrypt( closed: DataView | ArrayBuffer, salt : Uint8Array ) {\n\t\t\treturn await crypto.subtle.decrypt(\n\t\t\t\t{\n\t\t\t\t\t... algorithm,\n\t\t\t\t\tiv: salt,\n\t\t\t\t},\n\t\t\t\tthis.native,\n\t\t\t\tclosed\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\n}\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'RSA-OAEP',\n\t\tmodulusLength: 1024,\n\t\tpublicExponent: new Uint8Array([ 1, 0, 1 ]),\n\t\thash: 'SHA-1',\n\t}\n\t\n\t/** Asymmetric cipher pair with shortest payload */\n\texport async function $mol_crypto_cipher_pair( this: $ ) {\n\t\t\n\t\tconst pair = await $.crypto.subtle.generateKey(\n\t\t\talgorithm,\n\t\t\ttrue,\n\t\t\t[ 'encrypt', 'decrypt' ]\n\t\t)\n\t\t\n\t\treturn {\n\t\t\t\n\t\t\tpublic: new $mol_crypto_cipher_public(\n\t\t\t\tpair.publicKey as CryptoKey & { type: 'public' }\n\t\t\t),\n\t\t\t\n\t\t\tprivate: new $mol_crypto_cipher_private(\n\t\t\t\tpair.privateKey as CryptoKey & { type: 'private' }\n\t\t\t),\n\t\t\t\n\t\t}\n\t\t\n\t}\n\n\t/** Asymmetric cipher public key wrapper with shortest payload */\n\texport class $mol_crypto_cipher_public extends Object {\n\t\t\n\t\t/** Public key size in bytes. */\n\t\tstatic size = 162\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'public' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'spki',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'public' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 162 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'spki',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** max 86 bytes input, 128 bytes output */\n\t\tasync encrypt( data: DataView | ArrayBuffer ) {\n\t\t\treturn await crypto.subtle.encrypt(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\n\t/** Asymmetric cipher private key wrapper with shortest payload */\n\texport class $mol_crypto_cipher_private extends Object {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'pkcs8',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'decrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** ~640 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'pkcs8',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync decrypt( data: DataView | ArrayBuffer ) {\n\t\t\treturn await crypto.subtle.decrypt(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\t\n\t/** Encrypted size in bytes. */\n\texport const $mol_crypto_cipher_ecrypted_size = 128\n\n}\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'RSA-PSS',\n\t\tmodulusLength: 256,\n\t\tpublicExponent: new Uint8Array([ 1, 0, 1 ]),\n\t\thash: 'SHA-1',\n\t\tsaltLength: 8,\n\t}\n\t\n\t/** Asymmetric signing pair with shortest payload */\n\texport async function $mol_crypto_auditor_pair( this: $ ) {\n\t\t\n\t\tconst pair = await $.crypto.subtle.generateKey(\n\t\t\talgorithm,\n\t\t\ttrue,\n\t\t\t[ 'sign', 'verify' ]\n\t\t)\n\t\t\n\t\treturn {\n\t\t\t\n\t\t\tpublic: new $mol_crypto_auditor_public(\n\t\t\t\tpair.publicKey as CryptoKey & { type: 'public' }\n\t\t\t),\n\t\t\t\n\t\t\tprivate: new $mol_crypto_auditor_private(\n\t\t\t\tpair.privateKey as CryptoKey & { type: 'private' }\n\t\t\t),\n\t\t\t\n\t\t}\n\t\t\n\t}\n\t\n\t/** Asymmetric signing public key wrapper with shortest payload */\n\texport class $mol_crypto_auditor_public extends Object {\n\t\t\n\t\t/** Public key size in bytes. */\n\t\tstatic size = 62\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'public' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'spki',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'verify' ],\n\t\t\t\t) as CryptoKey & { type: 'public' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 62 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'spki',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync verify( data: DataView | ArrayBuffer, sign: DataView | ArrayBuffer ) {\n\t\t\treturn await crypto.subtle.verify(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tsign,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\t\n\t/** Asymmetric signing private key wrapper with shortest payload */\n\texport class $mol_crypto_auditor_private extends Object {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'pkcs8',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'sign' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** ~195 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'pkcs8',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 32 bytes */\n\t\tasync sign( data: DataView | ArrayBuffer ) {\n\t\t\t\n\t\t\treturn await crypto.subtle.sign(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata\n\t\t\t)\n\t\t\t\n\t\t}\n\t\t\n\t}\n\t\n\t/** Sign size in bytes. */\n\texport const $mol_crypto_auditor_sign_size = 32\n\t\n}\n","namespace $ {\n\t\n\t/** 8 byte */\n\texport function $mol_crypto_salt() {\n\t\treturn crypto.getRandomValues(\n\t\t\tnew Uint8Array( 8 )\n\t\t)\n\t}\n\t\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../../mam.jam.js","-","../../../../mam.ts","../../secret/secret.ts","../../cipher/cipher.ts","../../auditor/auditor.ts","../../salt/salt.ts"],"names":[],"mappings":";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AAM,CAAC,MAAM,CAChC,SAAS,EACT,IAAI,CAAC,MAAM,EACX,IAAI,EACJ,IAAI,CACJ,CAAA;QACF,CAAC;;IAtCW,4BAA0B,6BAwCtC,CAAA;IAGD,MAAa,2BAA4B,SAAQ,MAAM;QAG5C;QADV,YACU,MAAuC;YAEhD,KAAK,EAAE,CAAA;YAFE,WAAM,GAAN,MAAM,CAAiC;QAGjD,CAAC;QAED,MAAM,CAAC,KAAK,CAAC,IAAI,CAAE,MAA8B;YAChD,OAAO,IAAI,IAAI,CACd,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAC5B,OAAO,EACP,MAAM,EACN,SAAS,EACT,IAAI,EACJ,CAAE,MAAM,CAAE,CACyB,CACpC,CAAA;QACF,CAAC;QAGD,KAAK,CAAC,MAAM;YACX,OAAO,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CACnC,OAAO,EACP,IAAI,CAAC,MAAM,CACX,CAAA;QACF,CAAC;QAGD,KAAK,CAAC,IAAI,CAAE,IAA4B;YAEvC,OAAO,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAC9B,SAAS,EACT,IAAI,CAAC,MAAM,EACX,IAAI,CACJ,CAAA;QAEF,CAAC;KAED;IAvCY,6BAA2B,8BAuCvC,CAAA;IAGY,+BAA6B,GAAG,EAAE,CAAA;AAEhD,CAAC,EAzHS,CAAC,KAAD,CAAC,QAyHV;;;;ACzHD,IAAU,CAAC,CASV;AATD,WAAU,CAAC;IAGV,SAAgB,gBAAgB;QAC/B,OAAO,MAAM,CAAC,eAAe,CAC5B,IAAI,UAAU,CAAE,CAAC,CAAE,CACnB,CAAA;IACF,CAAC;IAJe,kBAAgB,mBAI/B,CAAA;AAEF,CAAC,EATS,CAAC,KAAD,CAAC,QASV;;;ALTD","file":"node.esm.js","sourcesContent":[null,null,"Error.stackTraceLimit = 50;\n\ndeclare let _$_: { new(): {} } & typeof globalThis\ndeclare class $ extends _$_ {}\n\nnamespace $ {\n\texport type $ = typeof $$\n\texport declare class $$ extends $ {}\n\tnamespace $$ {\n\t\texport type $$ = $\n\t}\n}\n\nmodule.exports = $\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'AES-GCM',\n\t\tlength: 128,\n\t\ttagLength: 32,\n\t}\n\t\n\t/** Symmetric cipher with shortest payload */\n\texport class $mol_crypto_secret extends Object {\n\t\t\n\t\t/** Key size in bytes. */\n\t\tstatic size = 16\n\t\t\n\t\t/** Extra size in bytes to encrypted data. */\n\t\tstatic extra = 4\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async generate() {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.generateKey(\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt', 'decrypt' ]\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'raw',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt', 'decrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 16 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'raw',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\n\t\t/** 4 bytes + data length */\n\t\tasync encrypt( open: DataView | ArrayBuffer, salt: Uint8Array ): Promise< ArrayBuffer > {\n\t\t\treturn await crypto.subtle.encrypt(\n\t\t\t\t{\n\t\t\t\t\t... algorithm,\n\t\t\t\t\tiv: salt,\n\t\t\t\t},\n\t\t\t\tthis.native,\n\t\t\t\topen\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync decrypt( closed: DataView | ArrayBuffer, salt : Uint8Array ): Promise< ArrayBuffer > {\n\t\t\treturn await crypto.subtle.decrypt(\n\t\t\t\t{\n\t\t\t\t\t... algorithm,\n\t\t\t\t\tiv: salt,\n\t\t\t\t},\n\t\t\t\tthis.native,\n\t\t\t\tclosed\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\n}\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'RSA-OAEP',\n\t\tmodulusLength: 1024,\n\t\tpublicExponent: new Uint8Array([ 1, 0, 1 ]),\n\t\thash: 'SHA-1',\n\t}\n\t\n\t/** Asymmetric cipher pair with shortest payload */\n\texport async function $mol_crypto_cipher_pair( this: $ ) {\n\t\t\n\t\tconst pair = await $.crypto.subtle.generateKey(\n\t\t\talgorithm,\n\t\t\ttrue,\n\t\t\t[ 'encrypt', 'decrypt' ]\n\t\t)\n\t\t\n\t\treturn {\n\t\t\t\n\t\t\tpublic: new $mol_crypto_cipher_public(\n\t\t\t\tpair.publicKey as CryptoKey & { type: 'public' }\n\t\t\t),\n\t\t\t\n\t\t\tprivate: new $mol_crypto_cipher_private(\n\t\t\t\tpair.privateKey as CryptoKey & { type: 'private' }\n\t\t\t),\n\t\t\t\n\t\t}\n\t\t\n\t}\n\n\t/** Asymmetric cipher public key wrapper with shortest payload */\n\texport class $mol_crypto_cipher_public extends Object {\n\t\t\n\t\t/** Public key size in bytes. */\n\t\tstatic size = 162\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'public' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'spki',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'public' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 162 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'spki',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** max 86 bytes input, 128 bytes output */\n\t\tasync encrypt( data: DataView | ArrayBuffer ): Promise< ArrayBuffer > {\n\t\t\treturn await crypto.subtle.encrypt(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\n\t/** Asymmetric cipher private key wrapper with shortest payload */\n\texport class $mol_crypto_cipher_private extends Object {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'pkcs8',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'decrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** ~640 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'pkcs8',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync decrypt( data: DataView | ArrayBuffer ): Promise< ArrayBuffer > {\n\t\t\treturn await crypto.subtle.decrypt(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\t\n\t/** Encrypted size in bytes. */\n\texport const $mol_crypto_cipher_ecrypted_size = 128\n\n}\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'RSA-PSS',\n\t\tmodulusLength: 256,\n\t\tpublicExponent: new Uint8Array([ 1, 0, 1 ]),\n\t\thash: 'SHA-1',\n\t\tsaltLength: 8,\n\t}\n\t\n\t/** Asymmetric signing pair with shortest payload */\n\texport async function $mol_crypto_auditor_pair( this: $ ) {\n\t\t\n\t\tconst pair = await $.crypto.subtle.generateKey(\n\t\t\talgorithm,\n\t\t\ttrue,\n\t\t\t[ 'sign', 'verify' ]\n\t\t)\n\t\t\n\t\treturn {\n\t\t\t\n\t\t\tpublic: new $mol_crypto_auditor_public(\n\t\t\t\tpair.publicKey as CryptoKey & { type: 'public' }\n\t\t\t),\n\t\t\t\n\t\t\tprivate: new $mol_crypto_auditor_private(\n\t\t\t\tpair.privateKey as CryptoKey & { type: 'private' }\n\t\t\t),\n\t\t\t\n\t\t}\n\t\t\n\t}\n\t\n\t/** Asymmetric signing public key wrapper with shortest payload */\n\texport class $mol_crypto_auditor_public extends Object {\n\t\t\n\t\t/** Public key size in bytes. */\n\t\tstatic size = 62\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'public' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'spki',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'verify' ],\n\t\t\t\t) as CryptoKey & { type: 'public' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 62 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'spki',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync verify( data: DataView | ArrayBuffer, sign: DataView | ArrayBuffer ) {\n\t\t\treturn await crypto.subtle.verify(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tsign,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\t\n\t/** Asymmetric signing private key wrapper with shortest payload */\n\texport class $mol_crypto_auditor_private extends Object {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'pkcs8',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'sign' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** ~195 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'pkcs8',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 32 bytes */\n\t\tasync sign( data: DataView | ArrayBuffer ) {\n\t\t\t\n\t\t\treturn await crypto.subtle.sign(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata\n\t\t\t)\n\t\t\t\n\t\t}\n\t\t\n\t}\n\t\n\t/** Sign size in bytes. */\n\texport const $mol_crypto_auditor_sign_size = 32\n\t\n}\n","namespace $ {\n\t\n\t/** 8 byte */\n\texport function $mol_crypto_salt() {\n\t\treturn crypto.getRandomValues(\n\t\t\tnew Uint8Array( 8 )\n\t\t)\n\t}\n\t\n}\n"]}
|
package/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../mam.jam.js","-","../../../../mam.ts","../../secret/secret.ts","../../cipher/cipher.ts","../../auditor/auditor.ts","../../salt/salt.ts"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACbA;AACA;AACA;AACA;;ACHA,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;AAK3B,IAAU,CAAC,CAMV;AAND,WAAU,CAAC;AAMX,CAAC,EANS,CAAC,KAAD,CAAC,QAMV;AAED,MAAM,CAAC,OAAO,GAAG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QAGjD,CAAC;QAED,MAAM,CAAC,KAAK,CAAC,IAAI,CAAE,MAA8B;YAChD,OAAO,IAAI,IAAI,CACd,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAC5B,OAAO,EACP,MAAM,EACN,SAAS,EACT,IAAI,EACJ,CAAE,MAAM,CAAE,CACyB,CACpC,CAAA;QACF,CAAC;QAGD,KAAK,CAAC,MAAM;YACX,OAAO,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CACnC,OAAO,EACP,IAAI,CAAC,MAAM,CACX,CAAA;QACF,CAAC;QAGD,KAAK,CAAC,IAAI,CAAE,IAA4B;YAEvC,OAAO,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAC9B,SAAS,EACT,IAAI,CAAC,MAAM,EACX,IAAI,CACJ,CAAA;QAEF,CAAC;KAED;IAvCY,6BAA2B,8BAuCvC,CAAA;IAGY,+BAA6B,GAAG,EAAE,CAAA;AAEhD,CAAC,EAzHS,CAAC,KAAD,CAAC,QAyHV;;;;ACzHD,IAAU,CAAC,CASV;AATD,WAAU,CAAC;IAGV,SAAgB,gBAAgB;QAC/B,OAAO,MAAM,CAAC,eAAe,CAC5B,IAAI,UAAU,CAAE,CAAC,CAAE,CACnB,CAAA;IACF,CAAC;IAJe,kBAAgB,mBAI/B,CAAA;AAEF,CAAC,EATS,CAAC,KAAD,CAAC,QASV;;","file":"node.js","sourcesContent":[null,null,"Error.stackTraceLimit = 50;\n\ndeclare let _$_: { new(): {} } & typeof globalThis\ndeclare class $ extends _$_ {}\n\nnamespace $ {\n\texport type $ = typeof $$\n\texport declare class $$ extends $ {}\n\tnamespace $$ {\n\t\texport type $$ = $\n\t}\n}\n\nmodule.exports = $\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'AES-GCM',\n\t\tlength: 128,\n\t\ttagLength: 32,\n\t}\n\t\n\t/** Symmetric cipher with shortest payload */\n\texport class $mol_crypto_secret extends Object {\n\t\t\n\t\t/** Key size in bytes. */\n\t\tstatic size = 16\n\t\t\n\t\t/** Extra size in bytes to encrypted data. */\n\t\tstatic extra = 4\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async generate() {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.generateKey(\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt', 'decrypt' ]\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'raw',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt', 'decrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 16 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'raw',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\n\t\t/** 4 bytes + data length */\n\t\tasync encrypt( open: DataView | ArrayBuffer, salt: Uint8Array ) {\n\t\t\treturn await crypto.subtle.encrypt(\n\t\t\t\t{\n\t\t\t\t\t... algorithm,\n\t\t\t\t\tiv: salt,\n\t\t\t\t},\n\t\t\t\tthis.native,\n\t\t\t\topen\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync decrypt( closed: DataView | ArrayBuffer, salt : Uint8Array ) {\n\t\t\treturn await crypto.subtle.decrypt(\n\t\t\t\t{\n\t\t\t\t\t... algorithm,\n\t\t\t\t\tiv: salt,\n\t\t\t\t},\n\t\t\t\tthis.native,\n\t\t\t\tclosed\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\n}\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'RSA-OAEP',\n\t\tmodulusLength: 1024,\n\t\tpublicExponent: new Uint8Array([ 1, 0, 1 ]),\n\t\thash: 'SHA-1',\n\t}\n\t\n\t/** Asymmetric cipher pair with shortest payload */\n\texport async function $mol_crypto_cipher_pair( this: $ ) {\n\t\t\n\t\tconst pair = await $.crypto.subtle.generateKey(\n\t\t\talgorithm,\n\t\t\ttrue,\n\t\t\t[ 'encrypt', 'decrypt' ]\n\t\t)\n\t\t\n\t\treturn {\n\t\t\t\n\t\t\tpublic: new $mol_crypto_cipher_public(\n\t\t\t\tpair.publicKey as CryptoKey & { type: 'public' }\n\t\t\t),\n\t\t\t\n\t\t\tprivate: new $mol_crypto_cipher_private(\n\t\t\t\tpair.privateKey as CryptoKey & { type: 'private' }\n\t\t\t),\n\t\t\t\n\t\t}\n\t\t\n\t}\n\n\t/** Asymmetric cipher public key wrapper with shortest payload */\n\texport class $mol_crypto_cipher_public extends Object {\n\t\t\n\t\t/** Public key size in bytes. */\n\t\tstatic size = 162\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'public' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'spki',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'public' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 162 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'spki',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** max 86 bytes input, 128 bytes output */\n\t\tasync encrypt( data: DataView | ArrayBuffer ) {\n\t\t\treturn await crypto.subtle.encrypt(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\n\t/** Asymmetric cipher private key wrapper with shortest payload */\n\texport class $mol_crypto_cipher_private extends Object {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'pkcs8',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'decrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** ~640 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'pkcs8',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync decrypt( data: DataView | ArrayBuffer ) {\n\t\t\treturn await crypto.subtle.decrypt(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\t\n\t/** Encrypted size in bytes. */\n\texport const $mol_crypto_cipher_ecrypted_size = 128\n\n}\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'RSA-PSS',\n\t\tmodulusLength: 256,\n\t\tpublicExponent: new Uint8Array([ 1, 0, 1 ]),\n\t\thash: 'SHA-1',\n\t\tsaltLength: 8,\n\t}\n\t\n\t/** Asymmetric signing pair with shortest payload */\n\texport async function $mol_crypto_auditor_pair( this: $ ) {\n\t\t\n\t\tconst pair = await $.crypto.subtle.generateKey(\n\t\t\talgorithm,\n\t\t\ttrue,\n\t\t\t[ 'sign', 'verify' ]\n\t\t)\n\t\t\n\t\treturn {\n\t\t\t\n\t\t\tpublic: new $mol_crypto_auditor_public(\n\t\t\t\tpair.publicKey as CryptoKey & { type: 'public' }\n\t\t\t),\n\t\t\t\n\t\t\tprivate: new $mol_crypto_auditor_private(\n\t\t\t\tpair.privateKey as CryptoKey & { type: 'private' }\n\t\t\t),\n\t\t\t\n\t\t}\n\t\t\n\t}\n\t\n\t/** Asymmetric signing public key wrapper with shortest payload */\n\texport class $mol_crypto_auditor_public extends Object {\n\t\t\n\t\t/** Public key size in bytes. */\n\t\tstatic size = 62\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'public' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'spki',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'verify' ],\n\t\t\t\t) as CryptoKey & { type: 'public' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 62 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'spki',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync verify( data: DataView | ArrayBuffer, sign: DataView | ArrayBuffer ) {\n\t\t\treturn await crypto.subtle.verify(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tsign,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\t\n\t/** Asymmetric signing private key wrapper with shortest payload */\n\texport class $mol_crypto_auditor_private extends Object {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'pkcs8',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'sign' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** ~195 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'pkcs8',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 32 bytes */\n\t\tasync sign( data: DataView | ArrayBuffer ) {\n\t\t\t\n\t\t\treturn await crypto.subtle.sign(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata\n\t\t\t)\n\t\t\t\n\t\t}\n\t\t\n\t}\n\t\n\t/** Sign size in bytes. */\n\texport const $mol_crypto_auditor_sign_size = 32\n\t\n}\n","namespace $ {\n\t\n\t/** 8 byte */\n\texport function $mol_crypto_salt() {\n\t\treturn crypto.getRandomValues(\n\t\t\tnew Uint8Array( 8 )\n\t\t)\n\t}\n\t\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../../mam.jam.js","-","../../../../mam.ts","../../secret/secret.ts","../../cipher/cipher.ts","../../auditor/auditor.ts","../../salt/salt.ts"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACbA;AACA;AACA;AACA;;ACHA,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;AAK3B,IAAU,CAAC,CAMV;AAND,WAAU,CAAC;AAMX,CAAC,EANS,CAAC,KAAD,CAAC,QAMV;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,CAAA;;;ADblB;AACA;AACA;;AEFA,IAAU,CAAC,CA8EV;AA9ED,WAAU,CAAC;IAEV,MAAM,SAAS,GAAG;QACjB,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,GAAG;QACX,SAAS,EAAE,EAAE;KACb,CAAA;IAGD,MAAa,kBAAmB,SAAQ,MAAM;QASnC;QANV,MAAM,CAAC,IAAI,GAAG,EAAE,CAAA;QAGhB,MAAM,CAAC,KAAK,GAAG,CAAC,CAAA;QAEhB,YACU,MAAuC;YAEhD,KAAK,EAAE,CAAA;YAFE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GD,KAAK,CAAC,IAAI,CAAE,IAA4B;YAEvC,OAAO,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAC9B,SAAS,EACT,IAAI,CAAC,MAAM,EACX,IAAI,CACJ,CAAA;QAEF,CAAC;KAED;IAvCY,6BAA2B,8BAuCvC,CAAA;IAGY,+BAA6B,GAAG,EAAE,CAAA;AAEhD,CAAC,EAzHS,CAAC,KAAD,CAAC,QAyHV;;;;ACzHD,IAAU,CAAC,CASV;AATD,WAAU,CAAC;IAGV,SAAgB,gBAAgB;QAC/B,OAAO,MAAM,CAAC,eAAe,CAC5B,IAAI,UAAU,CAAE,CAAC,CAAE,CACnB,CAAA;IACF,CAAC;IAJe,kBAAgB,mBAI/B,CAAA;AAEF,CAAC,EATS,CAAC,KAAD,CAAC,QASV;;","file":"node.js","sourcesContent":[null,null,"Error.stackTraceLimit = 50;\n\ndeclare let _$_: { new(): {} } & typeof globalThis\ndeclare class $ extends _$_ {}\n\nnamespace $ {\n\texport type $ = typeof $$\n\texport declare class $$ extends $ {}\n\tnamespace $$ {\n\t\texport type $$ = $\n\t}\n}\n\nmodule.exports = $\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'AES-GCM',\n\t\tlength: 128,\n\t\ttagLength: 32,\n\t}\n\t\n\t/** Symmetric cipher with shortest payload */\n\texport class $mol_crypto_secret extends Object {\n\t\t\n\t\t/** Key size in bytes. */\n\t\tstatic size = 16\n\t\t\n\t\t/** Extra size in bytes to encrypted data. */\n\t\tstatic extra = 4\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async generate() {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.generateKey(\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt', 'decrypt' ]\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'raw',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt', 'decrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 16 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'raw',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\n\t\t/** 4 bytes + data length */\n\t\tasync encrypt( open: DataView | ArrayBuffer, salt: Uint8Array ): Promise< ArrayBuffer > {\n\t\t\treturn await crypto.subtle.encrypt(\n\t\t\t\t{\n\t\t\t\t\t... algorithm,\n\t\t\t\t\tiv: salt,\n\t\t\t\t},\n\t\t\t\tthis.native,\n\t\t\t\topen\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync decrypt( closed: DataView | ArrayBuffer, salt : Uint8Array ): Promise< ArrayBuffer > {\n\t\t\treturn await crypto.subtle.decrypt(\n\t\t\t\t{\n\t\t\t\t\t... algorithm,\n\t\t\t\t\tiv: salt,\n\t\t\t\t},\n\t\t\t\tthis.native,\n\t\t\t\tclosed\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\n}\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'RSA-OAEP',\n\t\tmodulusLength: 1024,\n\t\tpublicExponent: new Uint8Array([ 1, 0, 1 ]),\n\t\thash: 'SHA-1',\n\t}\n\t\n\t/** Asymmetric cipher pair with shortest payload */\n\texport async function $mol_crypto_cipher_pair( this: $ ) {\n\t\t\n\t\tconst pair = await $.crypto.subtle.generateKey(\n\t\t\talgorithm,\n\t\t\ttrue,\n\t\t\t[ 'encrypt', 'decrypt' ]\n\t\t)\n\t\t\n\t\treturn {\n\t\t\t\n\t\t\tpublic: new $mol_crypto_cipher_public(\n\t\t\t\tpair.publicKey as CryptoKey & { type: 'public' }\n\t\t\t),\n\t\t\t\n\t\t\tprivate: new $mol_crypto_cipher_private(\n\t\t\t\tpair.privateKey as CryptoKey & { type: 'private' }\n\t\t\t),\n\t\t\t\n\t\t}\n\t\t\n\t}\n\n\t/** Asymmetric cipher public key wrapper with shortest payload */\n\texport class $mol_crypto_cipher_public extends Object {\n\t\t\n\t\t/** Public key size in bytes. */\n\t\tstatic size = 162\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'public' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'spki',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'public' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 162 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'spki',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** max 86 bytes input, 128 bytes output */\n\t\tasync encrypt( data: DataView | ArrayBuffer ): Promise< ArrayBuffer > {\n\t\t\treturn await crypto.subtle.encrypt(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\n\t/** Asymmetric cipher private key wrapper with shortest payload */\n\texport class $mol_crypto_cipher_private extends Object {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'pkcs8',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'decrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** ~640 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'pkcs8',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync decrypt( data: DataView | ArrayBuffer ): Promise< ArrayBuffer > {\n\t\t\treturn await crypto.subtle.decrypt(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\t\n\t/** Encrypted size in bytes. */\n\texport const $mol_crypto_cipher_ecrypted_size = 128\n\n}\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'RSA-PSS',\n\t\tmodulusLength: 256,\n\t\tpublicExponent: new Uint8Array([ 1, 0, 1 ]),\n\t\thash: 'SHA-1',\n\t\tsaltLength: 8,\n\t}\n\t\n\t/** Asymmetric signing pair with shortest payload */\n\texport async function $mol_crypto_auditor_pair( this: $ ) {\n\t\t\n\t\tconst pair = await $.crypto.subtle.generateKey(\n\t\t\talgorithm,\n\t\t\ttrue,\n\t\t\t[ 'sign', 'verify' ]\n\t\t)\n\t\t\n\t\treturn {\n\t\t\t\n\t\t\tpublic: new $mol_crypto_auditor_public(\n\t\t\t\tpair.publicKey as CryptoKey & { type: 'public' }\n\t\t\t),\n\t\t\t\n\t\t\tprivate: new $mol_crypto_auditor_private(\n\t\t\t\tpair.privateKey as CryptoKey & { type: 'private' }\n\t\t\t),\n\t\t\t\n\t\t}\n\t\t\n\t}\n\t\n\t/** Asymmetric signing public key wrapper with shortest payload */\n\texport class $mol_crypto_auditor_public extends Object {\n\t\t\n\t\t/** Public key size in bytes. */\n\t\tstatic size = 62\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'public' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'spki',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'verify' ],\n\t\t\t\t) as CryptoKey & { type: 'public' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 62 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'spki',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync verify( data: DataView | ArrayBuffer, sign: DataView | ArrayBuffer ) {\n\t\t\treturn await crypto.subtle.verify(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tsign,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\t\n\t/** Asymmetric signing private key wrapper with shortest payload */\n\texport class $mol_crypto_auditor_private extends Object {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'pkcs8',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'sign' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** ~195 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'pkcs8',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 32 bytes */\n\t\tasync sign( data: DataView | ArrayBuffer ) {\n\t\t\t\n\t\t\treturn await crypto.subtle.sign(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata\n\t\t\t)\n\t\t\t\n\t\t}\n\t\t\n\t}\n\t\n\t/** Sign size in bytes. */\n\texport const $mol_crypto_auditor_sign_size = 32\n\t\n}\n","namespace $ {\n\t\n\t/** 8 byte */\n\texport function $mol_crypto_salt() {\n\t\treturn crypto.getRandomValues(\n\t\t\tnew Uint8Array( 8 )\n\t\t)\n\t}\n\t\n}\n"]}
|
package/node.test.js
CHANGED
|
@@ -588,23 +588,15 @@ var $;
|
|
|
588
588
|
$.$mol_assert_ok($.$mol_compare_deep(1, 1));
|
|
589
589
|
$.$mol_assert_ok($.$mol_compare_deep(Number.NaN, Number.NaN));
|
|
590
590
|
$.$mol_assert_not($.$mol_compare_deep(1, 2));
|
|
591
|
+
$.$mol_assert_not($.$mol_compare_deep(Object(1), Object(1)));
|
|
591
592
|
},
|
|
592
|
-
'
|
|
593
|
-
$.$mol_assert_ok($.$mol_compare_deep(Object(1), Object(1)));
|
|
594
|
-
$.$mol_assert_ok($.$mol_compare_deep(Object(Number.NaN), Object(Number.NaN)));
|
|
595
|
-
$.$mol_assert_not($.$mol_compare_deep(Object(1), Object(2)));
|
|
596
|
-
},
|
|
597
|
-
'empty POJOs'() {
|
|
593
|
+
'POJO'() {
|
|
598
594
|
$.$mol_assert_ok($.$mol_compare_deep({}, {}));
|
|
599
|
-
},
|
|
600
|
-
'different POJOs'() {
|
|
601
595
|
$.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
602
|
-
},
|
|
603
|
-
'different POJOs with same keys but different values'() {
|
|
604
596
|
$.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
605
|
-
},
|
|
606
|
-
'different POJOs with different keys but same values'() {
|
|
607
597
|
$.$mol_assert_not($.$mol_compare_deep({}, { a: undefined }));
|
|
598
|
+
$.$mol_assert_ok($.$mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
599
|
+
$.$mol_assert_ok($.$mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
608
600
|
},
|
|
609
601
|
'Array'() {
|
|
610
602
|
$.$mol_assert_ok($.$mol_compare_deep([], []));
|
|
@@ -612,17 +604,12 @@ var $;
|
|
|
612
604
|
$.$mol_assert_not($.$mol_compare_deep([1, 2], [1, 3]));
|
|
613
605
|
$.$mol_assert_not($.$mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
614
606
|
},
|
|
615
|
-
'
|
|
616
|
-
|
|
617
|
-
},
|
|
618
|
-
'different classes with same values'() {
|
|
619
|
-
class Obj {
|
|
620
|
-
foo = 1;
|
|
607
|
+
'Non POJO are different'() {
|
|
608
|
+
class Thing extends Object {
|
|
621
609
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
$.$mol_assert_not($.$mol_compare_deep(a, b));
|
|
610
|
+
$.$mol_assert_not($.$mol_compare_deep(new Thing, new Thing));
|
|
611
|
+
$.$mol_assert_not($.$mol_compare_deep(() => 1, () => 1));
|
|
612
|
+
$.$mol_assert_not($.$mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
626
613
|
},
|
|
627
614
|
'same POJOs with cyclic reference'() {
|
|
628
615
|
const a = { foo: {} };
|
|
@@ -631,41 +618,6 @@ var $;
|
|
|
631
618
|
b['self'] = b;
|
|
632
619
|
$.$mol_assert_ok($.$mol_compare_deep(a, b));
|
|
633
620
|
},
|
|
634
|
-
'empty Element'() {
|
|
635
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("div", null)));
|
|
636
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("span", null)));
|
|
637
|
-
},
|
|
638
|
-
'Element with attributes'() {
|
|
639
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "rtl" })));
|
|
640
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", null)));
|
|
641
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "ltr" })));
|
|
642
|
-
},
|
|
643
|
-
'Element with styles'() {
|
|
644
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'red' } })));
|
|
645
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: {} })));
|
|
646
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'blue' } })));
|
|
647
|
-
},
|
|
648
|
-
'Element with content'() {
|
|
649
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
650
|
-
"foo",
|
|
651
|
-
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
652
|
-
"foo",
|
|
653
|
-
$.$mol_jsx("br", null))));
|
|
654
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
655
|
-
"foo",
|
|
656
|
-
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
657
|
-
"bar",
|
|
658
|
-
$.$mol_jsx("br", null))));
|
|
659
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
660
|
-
"foo",
|
|
661
|
-
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
662
|
-
"foo",
|
|
663
|
-
$.$mol_jsx("hr", null))));
|
|
664
|
-
},
|
|
665
|
-
'Element with handlers'() {
|
|
666
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 1 })));
|
|
667
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 2 })));
|
|
668
|
-
},
|
|
669
621
|
'Date'() {
|
|
670
622
|
$.$mol_assert_ok($.$mol_compare_deep(new Date(12345), new Date(12345)));
|
|
671
623
|
$.$mol_assert_not($.$mol_compare_deep(new Date(12345), new Date(12346)));
|
|
@@ -697,94 +649,74 @@ var $;
|
|
|
697
649
|
"use strict";
|
|
698
650
|
var $;
|
|
699
651
|
(function ($) {
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
function $mol_compare_deep(a, b) {
|
|
704
|
-
if (Object.is(a, b))
|
|
652
|
+
let cache = new WeakMap();
|
|
653
|
+
function $mol_compare_deep(left, right) {
|
|
654
|
+
if (Object.is(left, right))
|
|
705
655
|
return true;
|
|
706
|
-
|
|
707
|
-
const b_type = typeof b;
|
|
708
|
-
if (a_type !== b_type)
|
|
656
|
+
if (left === null)
|
|
709
657
|
return false;
|
|
710
|
-
if (
|
|
711
|
-
return a['toString']() === b['toString']();
|
|
712
|
-
if (a_type !== 'object')
|
|
658
|
+
if (right === null)
|
|
713
659
|
return false;
|
|
714
|
-
if (
|
|
660
|
+
if (typeof left !== 'object')
|
|
715
661
|
return false;
|
|
716
|
-
if (
|
|
662
|
+
if (typeof right !== 'object')
|
|
717
663
|
return false;
|
|
718
|
-
if (
|
|
664
|
+
if (left['constructor'] !== right['constructor'])
|
|
719
665
|
return false;
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
}
|
|
726
|
-
if (!cache)
|
|
727
|
-
cache = new WeakMap;
|
|
728
|
-
let a_cache = cache.get(a);
|
|
729
|
-
if (a_cache) {
|
|
730
|
-
const b_cache = a_cache.get(b);
|
|
731
|
-
if (typeof b_cache === 'boolean')
|
|
732
|
-
return b_cache;
|
|
666
|
+
let left_cache = cache.get(left);
|
|
667
|
+
if (left_cache) {
|
|
668
|
+
const right_cache = left_cache.get(right);
|
|
669
|
+
if (typeof right_cache === 'boolean')
|
|
670
|
+
return right_cache;
|
|
733
671
|
}
|
|
734
672
|
else {
|
|
735
|
-
|
|
736
|
-
cache.set(
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
673
|
+
left_cache = new WeakMap();
|
|
674
|
+
cache.set(left, left_cache);
|
|
675
|
+
left_cache.set(right, true);
|
|
676
|
+
}
|
|
677
|
+
if (left instanceof RegExp)
|
|
678
|
+
return left.toString() === right['toString']();
|
|
679
|
+
if (left instanceof Date)
|
|
680
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
740
681
|
let result;
|
|
741
682
|
try {
|
|
742
|
-
if (Symbol.iterator in
|
|
743
|
-
const
|
|
744
|
-
const
|
|
683
|
+
if (Symbol.iterator in left) {
|
|
684
|
+
const left_iter = left[Symbol.iterator]();
|
|
685
|
+
const right_iter = right[Symbol.iterator]();
|
|
745
686
|
while (true) {
|
|
746
|
-
const
|
|
747
|
-
const
|
|
748
|
-
if (
|
|
687
|
+
const left_next = left_iter.next();
|
|
688
|
+
const right_next = right_iter.next();
|
|
689
|
+
if (left_next.done !== right_next.done)
|
|
749
690
|
return result = false;
|
|
750
|
-
if (
|
|
691
|
+
if (left_next.done)
|
|
751
692
|
break;
|
|
752
|
-
if (!$mol_compare_deep(
|
|
693
|
+
if (!$mol_compare_deep(left_next.value, right_next.value))
|
|
753
694
|
return result = false;
|
|
754
695
|
}
|
|
755
696
|
return result = true;
|
|
756
697
|
}
|
|
698
|
+
if (left['constructor'] !== ({}).constructor)
|
|
699
|
+
return result = false;
|
|
757
700
|
let count = 0;
|
|
758
|
-
for (let key in
|
|
701
|
+
for (let key in left) {
|
|
759
702
|
try {
|
|
760
|
-
if (!$mol_compare_deep(
|
|
703
|
+
if (!$mol_compare_deep(left[key], right[key]))
|
|
761
704
|
return result = false;
|
|
762
705
|
}
|
|
763
706
|
catch (error) {
|
|
764
|
-
$.$mol_fail_hidden(new $.$mol_error_mix(`Failed ${JSON.stringify(key)} fields comparison of ${
|
|
707
|
+
$.$mol_fail_hidden(new $.$mol_error_mix(`Failed ${JSON.stringify(key)} fields comparison of ${left} and ${right}`, error));
|
|
765
708
|
}
|
|
766
709
|
++count;
|
|
767
710
|
}
|
|
768
|
-
for (let key in
|
|
711
|
+
for (let key in right) {
|
|
769
712
|
--count;
|
|
770
713
|
if (count < 0)
|
|
771
714
|
return result = false;
|
|
772
715
|
}
|
|
773
|
-
if (a instanceof Number || a instanceof String || a instanceof Symbol || a instanceof Boolean || a instanceof Date) {
|
|
774
|
-
if (!Object.is(a['valueOf'](), b['valueOf']()))
|
|
775
|
-
return result = false;
|
|
776
|
-
}
|
|
777
716
|
return result = true;
|
|
778
717
|
}
|
|
779
718
|
finally {
|
|
780
|
-
|
|
781
|
-
b_stack.pop();
|
|
782
|
-
if (a_stack.length === 0) {
|
|
783
|
-
cache = null;
|
|
784
|
-
}
|
|
785
|
-
else {
|
|
786
|
-
a_cache.set(b, result);
|
|
787
|
-
}
|
|
719
|
+
left_cache.set(right, result);
|
|
788
720
|
}
|
|
789
721
|
}
|
|
790
722
|
$.$mol_compare_deep = $mol_compare_deep;
|
|
@@ -932,7 +864,7 @@ var $;
|
|
|
932
864
|
const salt = $.$mol_crypto_salt();
|
|
933
865
|
const closed = await cipher.encrypt(data, salt);
|
|
934
866
|
const opened = await cipher.decrypt(closed, salt);
|
|
935
|
-
$.$mol_assert_like(data
|
|
867
|
+
$.$mol_assert_like(data, new Uint8Array(opened));
|
|
936
868
|
},
|
|
937
869
|
async 'decrypt encrypted with exported auto generated key'() {
|
|
938
870
|
const data = new Uint8Array([1, 2, 3]);
|
|
@@ -941,7 +873,7 @@ var $;
|
|
|
941
873
|
const closed = await Alice.encrypt(data, salt);
|
|
942
874
|
const Bob = await $.$mol_crypto_secret.from(await Alice.serial());
|
|
943
875
|
const opened = await Bob.decrypt(closed, salt);
|
|
944
|
-
$.$mol_assert_like(data
|
|
876
|
+
$.$mol_assert_like(data, new Uint8Array(opened));
|
|
945
877
|
},
|
|
946
878
|
});
|
|
947
879
|
})($ || ($ = {}));
|
|
@@ -967,7 +899,7 @@ var $;
|
|
|
967
899
|
const data = new Uint8Array([1, 2, 3]);
|
|
968
900
|
const closed = await pair.public.encrypt(data);
|
|
969
901
|
const opened = await pair.private.decrypt(closed);
|
|
970
|
-
$.$mol_assert_like(data
|
|
902
|
+
$.$mol_assert_like(data, new Uint8Array(opened));
|
|
971
903
|
},
|
|
972
904
|
async 'decrypt encrypted with exported auto generated key'() {
|
|
973
905
|
const pair = await $.$$.$mol_crypto_cipher_pair();
|
|
@@ -976,7 +908,7 @@ var $;
|
|
|
976
908
|
const closed = await Alice.encrypt(data);
|
|
977
909
|
const Bob = await $.$mol_crypto_cipher_private.from(await pair.private.serial());
|
|
978
910
|
const opened = await Bob.decrypt(closed);
|
|
979
|
-
$.$mol_assert_like(data
|
|
911
|
+
$.$mol_assert_like(data, new Uint8Array(opened));
|
|
980
912
|
},
|
|
981
913
|
});
|
|
982
914
|
})($ || ($ = {}));
|