mol_crypto_lib 0.0.149 → 0.0.153

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 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<any>;
30
- decrypt(closed: DataView | ArrayBuffer, salt: Uint8Array): Promise<any>;
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<any>;
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<any>;
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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,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 ) {\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,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N,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,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,KA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,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,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,IAAI,IAAI,CACd,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAC5B,KAAK,EACL,MAAM,EACN,SAAS,EACT,IAAI,EACJ,CAAE,SAAS,EAAE,SAAS,CAA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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,16 @@ 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
- },
592
- 'Number'() {
593
591
  $.$mol_assert_ok($.$mol_compare_deep(Object(1), Object(1)));
594
- $.$mol_assert_ok($.$mol_compare_deep(Object(Number.NaN), Object(Number.NaN)));
595
592
  $.$mol_assert_not($.$mol_compare_deep(Object(1), Object(2)));
596
593
  },
597
- 'empty POJOs'() {
594
+ 'POJO'() {
598
595
  $.$mol_assert_ok($.$mol_compare_deep({}, {}));
599
- },
600
- 'different POJOs'() {
601
596
  $.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { b: 2 }));
602
- },
603
- 'different POJOs with same keys but different values'() {
604
597
  $.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { a: 2 }));
605
- },
606
- 'different POJOs with different keys but same values'() {
607
598
  $.$mol_assert_not($.$mol_compare_deep({}, { a: undefined }));
599
+ $.$mol_assert_ok($.$mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
600
+ $.$mol_assert_ok($.$mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
608
601
  },
609
602
  'Array'() {
610
603
  $.$mol_assert_ok($.$mol_compare_deep([], []));
@@ -612,17 +605,12 @@ var $;
612
605
  $.$mol_assert_not($.$mol_compare_deep([1, 2], [1, 3]));
613
606
  $.$mol_assert_not($.$mol_compare_deep([1, 2,], [1, 3, undefined]));
614
607
  },
615
- 'same POJO trees'() {
616
- $.$mol_assert_ok($.$mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
617
- },
618
- 'different classes with same values'() {
619
- class Obj {
620
- foo = 1;
608
+ 'Non POJO are different'() {
609
+ class Thing extends Object {
621
610
  }
622
- const a = new Obj;
623
- const b = new class extends Obj {
624
- };
625
- $.$mol_assert_not($.$mol_compare_deep(a, b));
611
+ $.$mol_assert_not($.$mol_compare_deep(new Thing, new Thing));
612
+ $.$mol_assert_not($.$mol_compare_deep(() => 1, () => 1));
613
+ $.$mol_assert_not($.$mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
626
614
  },
627
615
  'same POJOs with cyclic reference'() {
628
616
  const a = { foo: {} };
@@ -631,41 +619,6 @@ var $;
631
619
  b['self'] = b;
632
620
  $.$mol_assert_ok($.$mol_compare_deep(a, b));
633
621
  },
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
622
  'Date'() {
670
623
  $.$mol_assert_ok($.$mol_compare_deep(new Date(12345), new Date(12345)));
671
624
  $.$mol_assert_not($.$mol_compare_deep(new Date(12345), new Date(12346)));
@@ -677,8 +630,9 @@ var $;
677
630
  },
678
631
  'Map'() {
679
632
  $.$mol_assert_ok($.$mol_compare_deep(new Map, new Map));
680
- $.$mol_assert_ok($.$mol_compare_deep(new Map([[[1], [2]]]), new Map([[[1], [2]]])));
633
+ $.$mol_assert_ok($.$mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
681
634
  $.$mol_assert_not($.$mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
635
+ $.$mol_assert_not($.$mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
682
636
  },
683
637
  'Set'() {
684
638
  $.$mol_assert_ok($.$mol_compare_deep(new Set, new Set));
@@ -697,97 +651,118 @@ var $;
697
651
  "use strict";
698
652
  var $;
699
653
  (function ($) {
700
- const a_stack = [];
701
- const b_stack = [];
702
- let cache = null;
703
- function $mol_compare_deep(a, b) {
704
- if (Object.is(a, b))
654
+ let cache = new WeakMap();
655
+ function $mol_compare_deep(left, right) {
656
+ if (Object.is(left, right))
705
657
  return true;
706
- const a_type = typeof a;
707
- const b_type = typeof b;
708
- if (a_type !== b_type)
658
+ if (left === null)
709
659
  return false;
710
- if (a_type === 'function')
711
- return a['toString']() === b['toString']();
712
- if (a_type !== 'object')
660
+ if (right === null)
713
661
  return false;
714
- if (!a || !b)
662
+ if (typeof left !== 'object')
715
663
  return false;
716
- if (a instanceof Error)
664
+ if (typeof right !== 'object')
717
665
  return false;
718
- if (a['constructor'] !== b['constructor'])
666
+ const left_proto = Reflect.getPrototypeOf(left);
667
+ const right_proto = Reflect.getPrototypeOf(right);
668
+ if (left_proto !== right_proto)
719
669
  return false;
720
- if (a instanceof RegExp)
721
- return a.toString() === b['toString']();
722
- const ref = a_stack.indexOf(a);
723
- if (ref >= 0) {
724
- return Object.is(b_stack[ref], b);
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;
670
+ if (left instanceof Boolean)
671
+ return Object.is(left.valueOf(), right['valueOf']());
672
+ if (left instanceof Number)
673
+ return Object.is(left.valueOf(), right['valueOf']());
674
+ if (left instanceof String)
675
+ return Object.is(left.valueOf(), right['valueOf']());
676
+ if (left instanceof Date)
677
+ return Object.is(left.valueOf(), right['valueOf']());
678
+ if (left instanceof RegExp)
679
+ return left.source === right['source'] && left.flags === right['flags'];
680
+ let left_cache = cache.get(left);
681
+ if (left_cache) {
682
+ const right_cache = left_cache.get(right);
683
+ if (typeof right_cache === 'boolean')
684
+ return right_cache;
733
685
  }
734
686
  else {
735
- a_cache = new WeakMap();
736
- cache.set(a, a_cache);
687
+ left_cache = new WeakMap([[right, true]]);
688
+ cache.set(left, left_cache);
737
689
  }
738
- a_stack.push(a);
739
- b_stack.push(b);
740
690
  let result;
741
691
  try {
742
- if (Symbol.iterator in a) {
743
- const a_iter = a[Symbol.iterator]();
744
- const b_iter = b[Symbol.iterator]();
745
- while (true) {
746
- const a_next = a_iter.next();
747
- const b_next = b_iter.next();
748
- if (a_next.done !== b_next.done)
749
- return result = false;
750
- if (a_next.done)
751
- break;
752
- if (!$mol_compare_deep(a_next.value, b_next.value))
753
- return result = false;
754
- }
755
- return result = true;
756
- }
757
- let count = 0;
758
- for (let key in a) {
759
- try {
760
- if (!$mol_compare_deep(a[key], b[key]))
761
- return result = false;
762
- }
763
- catch (error) {
764
- $.$mol_fail_hidden(new $.$mol_error_mix(`Failed ${JSON.stringify(key)} fields comparison of ${a} and ${b}`, error));
765
- }
766
- ++count;
767
- }
768
- for (let key in b) {
769
- --count;
770
- if (count < 0)
771
- return result = false;
772
- }
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
- return result = true;
692
+ if (left_proto && !Reflect.getPrototypeOf(left_proto))
693
+ result = compare_pojo(left, right);
694
+ else if (Array.isArray(left))
695
+ result = compare_array(left, right);
696
+ else if (left instanceof Set)
697
+ result = compare_set(left, right);
698
+ else if (left instanceof Map)
699
+ result = compare_map(left, right);
700
+ else if (ArrayBuffer.isView(left))
701
+ result = compare_buffer(left, right);
702
+ else
703
+ result = false;
778
704
  }
779
705
  finally {
780
- a_stack.pop();
781
- b_stack.pop();
782
- if (a_stack.length === 0) {
783
- cache = null;
784
- }
785
- else {
786
- a_cache.set(b, result);
787
- }
706
+ left_cache.set(right, result);
788
707
  }
708
+ return result;
789
709
  }
790
710
  $.$mol_compare_deep = $mol_compare_deep;
711
+ function compare_array(left, right) {
712
+ const len = left.length;
713
+ if (len !== right.length)
714
+ return false;
715
+ for (let i = 0; i < len; ++i) {
716
+ if (!$mol_compare_deep(left[i], right[i]))
717
+ return false;
718
+ }
719
+ return true;
720
+ }
721
+ function compare_buffer(left, right) {
722
+ const len = left.byteLength;
723
+ if (len !== right.byteLength)
724
+ return false;
725
+ for (let i = 0; i < len; ++i) {
726
+ if (left[i] !== right[i])
727
+ return false;
728
+ }
729
+ return true;
730
+ }
731
+ function compare_iterator(left, right, compare) {
732
+ while (true) {
733
+ const left_next = left.next();
734
+ const right_next = right.next();
735
+ if (left_next.done !== right_next.done)
736
+ return false;
737
+ if (left_next.done)
738
+ break;
739
+ if (!compare(left_next.value, right_next.value))
740
+ return false;
741
+ }
742
+ return true;
743
+ }
744
+ function compare_set(left, right) {
745
+ if (left.size !== right.size)
746
+ return false;
747
+ return compare_iterator(left.values(), right.values(), $mol_compare_deep);
748
+ }
749
+ function compare_map(left, right) {
750
+ if (left.size !== right.size)
751
+ return false;
752
+ return compare_iterator(left.keys(), right.keys(), Object.is)
753
+ && compare_iterator(left.values(), right.values(), $mol_compare_deep);
754
+ }
755
+ function compare_pojo(left, right) {
756
+ const left_keys = Object.getOwnPropertyNames(left);
757
+ const right_keys = Object.getOwnPropertyNames(right);
758
+ if (left_keys.length !== right_keys.length)
759
+ return false;
760
+ for (let key of left_keys) {
761
+ if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
762
+ return false;
763
+ }
764
+ return true;
765
+ }
791
766
  })($ || ($ = {}));
792
767
  //deep.js.map
793
768
  ;
@@ -932,7 +907,7 @@ var $;
932
907
  const salt = $.$mol_crypto_salt();
933
908
  const closed = await cipher.encrypt(data, salt);
934
909
  const opened = await cipher.decrypt(closed, salt);
935
- $.$mol_assert_like(data.buffer, opened);
910
+ $.$mol_assert_like(data, new Uint8Array(opened));
936
911
  },
937
912
  async 'decrypt encrypted with exported auto generated key'() {
938
913
  const data = new Uint8Array([1, 2, 3]);
@@ -941,7 +916,7 @@ var $;
941
916
  const closed = await Alice.encrypt(data, salt);
942
917
  const Bob = await $.$mol_crypto_secret.from(await Alice.serial());
943
918
  const opened = await Bob.decrypt(closed, salt);
944
- $.$mol_assert_like(data.buffer, opened);
919
+ $.$mol_assert_like(data, new Uint8Array(opened));
945
920
  },
946
921
  });
947
922
  })($ || ($ = {}));
@@ -967,7 +942,7 @@ var $;
967
942
  const data = new Uint8Array([1, 2, 3]);
968
943
  const closed = await pair.public.encrypt(data);
969
944
  const opened = await pair.private.decrypt(closed);
970
- $.$mol_assert_like(data.buffer, opened);
945
+ $.$mol_assert_like(data, new Uint8Array(opened));
971
946
  },
972
947
  async 'decrypt encrypted with exported auto generated key'() {
973
948
  const pair = await $.$$.$mol_crypto_cipher_pair();
@@ -976,7 +951,7 @@ var $;
976
951
  const closed = await Alice.encrypt(data);
977
952
  const Bob = await $.$mol_crypto_cipher_private.from(await pair.private.serial());
978
953
  const opened = await Bob.decrypt(closed);
979
- $.$mol_assert_like(data.buffer, opened);
954
+ $.$mol_assert_like(data, new Uint8Array(opened));
980
955
  },
981
956
  });
982
957
  })($ || ($ = {}));
@@ -1768,91 +1743,5 @@ var $;
1768
1743
  ;
1769
1744
  "use strict";
1770
1745
  //equals.js.map
1771
- ;
1772
- "use strict";
1773
- var $;
1774
- (function ($) {
1775
- $.$mol_test({
1776
- 'equal paths'() {
1777
- const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]);
1778
- $.$mol_assert_like(diff, {
1779
- prefix: [1, 2, 3, 4],
1780
- suffix: [[], [], []],
1781
- });
1782
- },
1783
- 'different suffix'() {
1784
- const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 5, 4]);
1785
- $.$mol_assert_like(diff, {
1786
- prefix: [1, 2],
1787
- suffix: [[3, 4], [3, 5], [5, 4]],
1788
- });
1789
- },
1790
- 'one contains other'() {
1791
- const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2], [1, 2, 3]);
1792
- $.$mol_assert_like(diff, {
1793
- prefix: [1, 2],
1794
- suffix: [[3, 4], [], [3]],
1795
- });
1796
- },
1797
- 'fully different'() {
1798
- const diff = $.$mol_diff_path([1, 2], [3, 4], [5, 6]);
1799
- $.$mol_assert_like(diff, {
1800
- prefix: [],
1801
- suffix: [[1, 2], [3, 4], [5, 6]],
1802
- });
1803
- },
1804
- });
1805
- })($ || ($ = {}));
1806
- //path.test.js.map
1807
- ;
1808
- "use strict";
1809
- var $;
1810
- (function ($) {
1811
- function $mol_diff_path(...paths) {
1812
- const limit = Math.min(...paths.map(path => path.length));
1813
- lookup: for (var i = 0; i < limit; ++i) {
1814
- const first = paths[0][i];
1815
- for (let j = 1; j < paths.length; ++j) {
1816
- if (paths[j][i] !== first)
1817
- break lookup;
1818
- }
1819
- }
1820
- return {
1821
- prefix: paths[0].slice(0, i),
1822
- suffix: paths.map(path => path.slice(i)),
1823
- };
1824
- }
1825
- $.$mol_diff_path = $mol_diff_path;
1826
- })($ || ($ = {}));
1827
- //path.js.map
1828
- ;
1829
- "use strict";
1830
- var $;
1831
- (function ($) {
1832
- class $mol_error_mix extends Error {
1833
- errors;
1834
- constructor(message, ...errors) {
1835
- super(message);
1836
- this.errors = errors;
1837
- if (errors.length) {
1838
- const stacks = [...errors.map(error => error.stack), this.stack];
1839
- const diff = $.$mol_diff_path(...stacks.map(stack => {
1840
- if (!stack)
1841
- return [];
1842
- return stack.split('\n').reverse();
1843
- }));
1844
- const head = diff.prefix.reverse().join('\n');
1845
- const tails = diff.suffix.map(path => path.reverse().map(line => line.replace(/^(?!\s+at)/, '\tat (.) ')).join('\n')).join('\n\tat (.) -----\n');
1846
- this.stack = `Error: ${this.constructor.name}\n\tat (.) /"""\\\n${tails}\n\tat (.) \\___/\n${head}`;
1847
- this.message += errors.map(error => '\n' + error.message).join('');
1848
- }
1849
- }
1850
- toJSON() {
1851
- return this.message;
1852
- }
1853
- }
1854
- $.$mol_error_mix = $mol_error_mix;
1855
- })($ || ($ = {}));
1856
- //mix.js.map
1857
1746
 
1858
1747
  //# sourceMappingURL=node.test.js.map