mol_crypto_lib 0.0.151 → 0.0.155

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mol_crypto_lib",
3
- "version": "0.0.151",
3
+ "version": "0.0.155",
4
4
  "main": "node.js",
5
5
  "module": "node.esm.js",
6
6
  "browser": "web.js",
package/web.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/web.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,IAAI,IAAI,CACd,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAC5B,KAAK,EACL,MAAM,EACN,SAAS,EACT,IAAI,EACJ,CAAE,SAAS,EAAE,SAAS,CAAE,CACW,CACpC,CAAA;QACF,CAAC;QAGD,KAAK,CAAC,MAAM;YACX,OAAO,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,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ent":[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,GA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C;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":"web.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/web.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,CA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,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":"web.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,CA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HV;;;;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":"web.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/web.test.js CHANGED
@@ -359,23 +359,16 @@ var $;
359
359
  $.$mol_assert_ok($.$mol_compare_deep(1, 1));
360
360
  $.$mol_assert_ok($.$mol_compare_deep(Number.NaN, Number.NaN));
361
361
  $.$mol_assert_not($.$mol_compare_deep(1, 2));
362
- },
363
- 'Number'() {
364
362
  $.$mol_assert_ok($.$mol_compare_deep(Object(1), Object(1)));
365
- $.$mol_assert_ok($.$mol_compare_deep(Object(Number.NaN), Object(Number.NaN)));
366
363
  $.$mol_assert_not($.$mol_compare_deep(Object(1), Object(2)));
367
364
  },
368
- 'empty POJOs'() {
365
+ 'POJO'() {
369
366
  $.$mol_assert_ok($.$mol_compare_deep({}, {}));
370
- },
371
- 'different POJOs'() {
372
367
  $.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { b: 2 }));
373
- },
374
- 'different POJOs with same keys but different values'() {
375
368
  $.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { a: 2 }));
376
- },
377
- 'different POJOs with different keys but same values'() {
378
369
  $.$mol_assert_not($.$mol_compare_deep({}, { a: undefined }));
370
+ $.$mol_assert_ok($.$mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
371
+ $.$mol_assert_ok($.$mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
379
372
  },
380
373
  'Array'() {
381
374
  $.$mol_assert_ok($.$mol_compare_deep([], []));
@@ -383,17 +376,12 @@ var $;
383
376
  $.$mol_assert_not($.$mol_compare_deep([1, 2], [1, 3]));
384
377
  $.$mol_assert_not($.$mol_compare_deep([1, 2,], [1, 3, undefined]));
385
378
  },
386
- 'same POJO trees'() {
387
- $.$mol_assert_ok($.$mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
388
- },
389
- 'different classes with same values'() {
390
- class Obj {
391
- foo = 1;
379
+ 'Non POJO are different'() {
380
+ class Thing extends Object {
392
381
  }
393
- const a = new Obj;
394
- const b = new class extends Obj {
395
- };
396
- $.$mol_assert_not($.$mol_compare_deep(a, b));
382
+ $.$mol_assert_not($.$mol_compare_deep(new Thing, new Thing));
383
+ $.$mol_assert_not($.$mol_compare_deep(() => 1, () => 1));
384
+ $.$mol_assert_not($.$mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
397
385
  },
398
386
  'same POJOs with cyclic reference'() {
399
387
  const a = { foo: {} };
@@ -402,41 +390,6 @@ var $;
402
390
  b['self'] = b;
403
391
  $.$mol_assert_ok($.$mol_compare_deep(a, b));
404
392
  },
405
- 'empty Element'() {
406
- $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("div", null)));
407
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("span", null)));
408
- },
409
- 'Element with attributes'() {
410
- $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "rtl" })));
411
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", null)));
412
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "ltr" })));
413
- },
414
- 'Element with styles'() {
415
- $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'red' } })));
416
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: {} })));
417
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'blue' } })));
418
- },
419
- 'Element with content'() {
420
- $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null,
421
- "foo",
422
- $.$mol_jsx("br", null)), $.$mol_jsx("div", null,
423
- "foo",
424
- $.$mol_jsx("br", null))));
425
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
426
- "foo",
427
- $.$mol_jsx("br", null)), $.$mol_jsx("div", null,
428
- "bar",
429
- $.$mol_jsx("br", null))));
430
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
431
- "foo",
432
- $.$mol_jsx("br", null)), $.$mol_jsx("div", null,
433
- "foo",
434
- $.$mol_jsx("hr", null))));
435
- },
436
- 'Element with handlers'() {
437
- $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 1 })));
438
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 2 })));
439
- },
440
393
  'Date'() {
441
394
  $.$mol_assert_ok($.$mol_compare_deep(new Date(12345), new Date(12345)));
442
395
  $.$mol_assert_not($.$mol_compare_deep(new Date(12345), new Date(12346)));
@@ -448,8 +401,9 @@ var $;
448
401
  },
449
402
  'Map'() {
450
403
  $.$mol_assert_ok($.$mol_compare_deep(new Map, new Map));
451
- $.$mol_assert_ok($.$mol_compare_deep(new Map([[[1], [2]]]), new Map([[[1], [2]]])));
404
+ $.$mol_assert_ok($.$mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
452
405
  $.$mol_assert_not($.$mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
406
+ $.$mol_assert_not($.$mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
453
407
  },
454
408
  'Set'() {
455
409
  $.$mol_assert_ok($.$mol_compare_deep(new Set, new Set));
@@ -461,6 +415,21 @@ var $;
461
415
  $.$mol_assert_ok($.$mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
462
416
  $.$mol_assert_not($.$mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
463
417
  },
418
+ 'Custom comparator'() {
419
+ class User {
420
+ name;
421
+ rand;
422
+ constructor(name, rand = Math.random()) {
423
+ this.name = name;
424
+ this.rand = rand;
425
+ }
426
+ [Symbol.toPrimitive](mode) {
427
+ return this.name;
428
+ }
429
+ }
430
+ $.$mol_assert_ok($.$mol_compare_deep(new User('Jin'), new User('Jin')));
431
+ $.$mol_assert_not($.$mol_compare_deep(new User('Jin'), new User('John')));
432
+ },
464
433
  });
465
434
  })($ || ($ = {}));
466
435
  //deep.test.js.map
@@ -468,97 +437,123 @@ var $;
468
437
  "use strict";
469
438
  var $;
470
439
  (function ($) {
471
- const a_stack = [];
472
- const b_stack = [];
473
- let cache = null;
474
- function $mol_compare_deep(a, b) {
475
- if (Object.is(a, b))
440
+ let cache = new WeakMap();
441
+ function $mol_compare_deep(left, right) {
442
+ if (Object.is(left, right))
476
443
  return true;
477
- const a_type = typeof a;
478
- const b_type = typeof b;
479
- if (a_type !== b_type)
444
+ if (left === null)
480
445
  return false;
481
- if (a_type === 'function')
482
- return a['toString']() === b['toString']();
483
- if (a_type !== 'object')
446
+ if (right === null)
484
447
  return false;
485
- if (!a || !b)
448
+ if (typeof left !== 'object')
486
449
  return false;
487
- if (a instanceof Error)
450
+ if (typeof right !== 'object')
488
451
  return false;
489
- if (a['constructor'] !== b['constructor'])
452
+ const left_proto = Reflect.getPrototypeOf(left);
453
+ const right_proto = Reflect.getPrototypeOf(right);
454
+ if (left_proto !== right_proto)
490
455
  return false;
491
- if (a instanceof RegExp)
492
- return a.toString() === b['toString']();
493
- const ref = a_stack.indexOf(a);
494
- if (ref >= 0) {
495
- return Object.is(b_stack[ref], b);
496
- }
497
- if (!cache)
498
- cache = new WeakMap;
499
- let a_cache = cache.get(a);
500
- if (a_cache) {
501
- const b_cache = a_cache.get(b);
502
- if (typeof b_cache === 'boolean')
503
- return b_cache;
456
+ if (left instanceof Boolean)
457
+ return Object.is(left.valueOf(), right['valueOf']());
458
+ if (left instanceof Number)
459
+ return Object.is(left.valueOf(), right['valueOf']());
460
+ if (left instanceof String)
461
+ return Object.is(left.valueOf(), right['valueOf']());
462
+ if (left instanceof Date)
463
+ return Object.is(left.valueOf(), right['valueOf']());
464
+ if (left instanceof RegExp)
465
+ return left.source === right['source'] && left.flags === right['flags'];
466
+ let left_cache = cache.get(left);
467
+ if (left_cache) {
468
+ const right_cache = left_cache.get(right);
469
+ if (typeof right_cache === 'boolean')
470
+ return right_cache;
504
471
  }
505
472
  else {
506
- a_cache = new WeakMap();
507
- cache.set(a, a_cache);
473
+ left_cache = new WeakMap([[right, true]]);
474
+ cache.set(left, left_cache);
508
475
  }
509
- a_stack.push(a);
510
- b_stack.push(b);
511
476
  let result;
512
477
  try {
513
- if (Symbol.iterator in a) {
514
- const a_iter = a[Symbol.iterator]();
515
- const b_iter = b[Symbol.iterator]();
516
- while (true) {
517
- const a_next = a_iter.next();
518
- const b_next = b_iter.next();
519
- if (a_next.done !== b_next.done)
520
- return result = false;
521
- if (a_next.done)
522
- break;
523
- if (!$mol_compare_deep(a_next.value, b_next.value))
524
- return result = false;
525
- }
526
- return result = true;
527
- }
528
- let count = 0;
529
- for (let key in a) {
530
- try {
531
- if (!$mol_compare_deep(a[key], b[key]))
532
- return result = false;
533
- }
534
- catch (error) {
535
- $.$mol_fail_hidden(new $.$mol_error_mix(`Failed ${JSON.stringify(key)} fields comparison of ${a} and ${b}`, error));
536
- }
537
- ++count;
538
- }
539
- for (let key in b) {
540
- --count;
541
- if (count < 0)
542
- return result = false;
543
- }
544
- if (a instanceof Number || a instanceof String || a instanceof Symbol || a instanceof Boolean || a instanceof Date) {
545
- if (!Object.is(a['valueOf'](), b['valueOf']()))
546
- return result = false;
547
- }
548
- return result = true;
478
+ if (left_proto && !Reflect.getPrototypeOf(left_proto))
479
+ result = compare_pojo(left, right);
480
+ else if (Array.isArray(left))
481
+ result = compare_array(left, right);
482
+ else if (left instanceof Set)
483
+ result = compare_set(left, right);
484
+ else if (left instanceof Map)
485
+ result = compare_map(left, right);
486
+ else if (ArrayBuffer.isView(left))
487
+ result = compare_buffer(left, right);
488
+ else if (Symbol.toPrimitive in left)
489
+ result = compare_primitive(left, right);
490
+ else
491
+ result = false;
549
492
  }
550
493
  finally {
551
- a_stack.pop();
552
- b_stack.pop();
553
- if (a_stack.length === 0) {
554
- cache = null;
555
- }
556
- else {
557
- a_cache.set(b, result);
558
- }
494
+ left_cache.set(right, result);
559
495
  }
496
+ return result;
560
497
  }
561
498
  $.$mol_compare_deep = $mol_compare_deep;
499
+ function compare_array(left, right) {
500
+ const len = left.length;
501
+ if (len !== right.length)
502
+ return false;
503
+ for (let i = 0; i < len; ++i) {
504
+ if (!$mol_compare_deep(left[i], right[i]))
505
+ return false;
506
+ }
507
+ return true;
508
+ }
509
+ function compare_buffer(left, right) {
510
+ const len = left.byteLength;
511
+ if (len !== right.byteLength)
512
+ return false;
513
+ for (let i = 0; i < len; ++i) {
514
+ if (left[i] !== right[i])
515
+ return false;
516
+ }
517
+ return true;
518
+ }
519
+ function compare_iterator(left, right, compare) {
520
+ while (true) {
521
+ const left_next = left.next();
522
+ const right_next = right.next();
523
+ if (left_next.done !== right_next.done)
524
+ return false;
525
+ if (left_next.done)
526
+ break;
527
+ if (!compare(left_next.value, right_next.value))
528
+ return false;
529
+ }
530
+ return true;
531
+ }
532
+ function compare_set(left, right) {
533
+ if (left.size !== right.size)
534
+ return false;
535
+ return compare_iterator(left.values(), right.values(), $mol_compare_deep);
536
+ }
537
+ function compare_map(left, right) {
538
+ if (left.size !== right.size)
539
+ return false;
540
+ return compare_iterator(left.keys(), right.keys(), Object.is)
541
+ && compare_iterator(left.values(), right.values(), $mol_compare_deep);
542
+ }
543
+ function compare_pojo(left, right) {
544
+ const left_keys = Object.getOwnPropertyNames(left);
545
+ const right_keys = Object.getOwnPropertyNames(right);
546
+ if (left_keys.length !== right_keys.length)
547
+ return false;
548
+ for (let key of left_keys) {
549
+ if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
550
+ return false;
551
+ }
552
+ return true;
553
+ }
554
+ function compare_primitive(left, right) {
555
+ return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
556
+ }
562
557
  })($ || ($ = {}));
563
558
  //deep.js.map
564
559
  ;
@@ -703,7 +698,7 @@ var $;
703
698
  const salt = $.$mol_crypto_salt();
704
699
  const closed = await cipher.encrypt(data, salt);
705
700
  const opened = await cipher.decrypt(closed, salt);
706
- $.$mol_assert_like(data.buffer, opened);
701
+ $.$mol_assert_like(data, new Uint8Array(opened));
707
702
  },
708
703
  async 'decrypt encrypted with exported auto generated key'() {
709
704
  const data = new Uint8Array([1, 2, 3]);
@@ -712,7 +707,7 @@ var $;
712
707
  const closed = await Alice.encrypt(data, salt);
713
708
  const Bob = await $.$mol_crypto_secret.from(await Alice.serial());
714
709
  const opened = await Bob.decrypt(closed, salt);
715
- $.$mol_assert_like(data.buffer, opened);
710
+ $.$mol_assert_like(data, new Uint8Array(opened));
716
711
  },
717
712
  });
718
713
  })($ || ($ = {}));
@@ -738,7 +733,7 @@ var $;
738
733
  const data = new Uint8Array([1, 2, 3]);
739
734
  const closed = await pair.public.encrypt(data);
740
735
  const opened = await pair.private.decrypt(closed);
741
- $.$mol_assert_like(data.buffer, opened);
736
+ $.$mol_assert_like(data, new Uint8Array(opened));
742
737
  },
743
738
  async 'decrypt encrypted with exported auto generated key'() {
744
739
  const pair = await $.$$.$mol_crypto_cipher_pair();
@@ -747,7 +742,7 @@ var $;
747
742
  const closed = await Alice.encrypt(data);
748
743
  const Bob = await $.$mol_crypto_cipher_private.from(await pair.private.serial());
749
744
  const opened = await Bob.decrypt(closed);
750
- $.$mol_assert_like(data.buffer, opened);
745
+ $.$mol_assert_like(data, new Uint8Array(opened));
751
746
  },
752
747
  });
753
748
  })($ || ($ = {}));
@@ -864,91 +859,5 @@ var $;
864
859
  ;
865
860
  "use strict";
866
861
  //equals.js.map
867
- ;
868
- "use strict";
869
- var $;
870
- (function ($) {
871
- $.$mol_test({
872
- 'equal paths'() {
873
- const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]);
874
- $.$mol_assert_like(diff, {
875
- prefix: [1, 2, 3, 4],
876
- suffix: [[], [], []],
877
- });
878
- },
879
- 'different suffix'() {
880
- const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 5, 4]);
881
- $.$mol_assert_like(diff, {
882
- prefix: [1, 2],
883
- suffix: [[3, 4], [3, 5], [5, 4]],
884
- });
885
- },
886
- 'one contains other'() {
887
- const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2], [1, 2, 3]);
888
- $.$mol_assert_like(diff, {
889
- prefix: [1, 2],
890
- suffix: [[3, 4], [], [3]],
891
- });
892
- },
893
- 'fully different'() {
894
- const diff = $.$mol_diff_path([1, 2], [3, 4], [5, 6]);
895
- $.$mol_assert_like(diff, {
896
- prefix: [],
897
- suffix: [[1, 2], [3, 4], [5, 6]],
898
- });
899
- },
900
- });
901
- })($ || ($ = {}));
902
- //path.test.js.map
903
- ;
904
- "use strict";
905
- var $;
906
- (function ($) {
907
- function $mol_diff_path(...paths) {
908
- const limit = Math.min(...paths.map(path => path.length));
909
- lookup: for (var i = 0; i < limit; ++i) {
910
- const first = paths[0][i];
911
- for (let j = 1; j < paths.length; ++j) {
912
- if (paths[j][i] !== first)
913
- break lookup;
914
- }
915
- }
916
- return {
917
- prefix: paths[0].slice(0, i),
918
- suffix: paths.map(path => path.slice(i)),
919
- };
920
- }
921
- $.$mol_diff_path = $mol_diff_path;
922
- })($ || ($ = {}));
923
- //path.js.map
924
- ;
925
- "use strict";
926
- var $;
927
- (function ($) {
928
- class $mol_error_mix extends Error {
929
- errors;
930
- constructor(message, ...errors) {
931
- super(message);
932
- this.errors = errors;
933
- if (errors.length) {
934
- const stacks = [...errors.map(error => error.stack), this.stack];
935
- const diff = $.$mol_diff_path(...stacks.map(stack => {
936
- if (!stack)
937
- return [];
938
- return stack.split('\n').reverse();
939
- }));
940
- const head = diff.prefix.reverse().join('\n');
941
- const tails = diff.suffix.map(path => path.reverse().map(line => line.replace(/^(?!\s+at)/, '\tat (.) ')).join('\n')).join('\n\tat (.) -----\n');
942
- this.stack = `Error: ${this.constructor.name}\n\tat (.) /"""\\\n${tails}\n\tat (.) \\___/\n${head}`;
943
- this.message += errors.map(error => '\n' + error.message).join('');
944
- }
945
- }
946
- toJSON() {
947
- return this.message;
948
- }
949
- }
950
- $.$mol_error_mix = $mol_error_mix;
951
- })($ || ($ = {}));
952
- //mix.js.map
953
862
 
954
863
  //# sourceMappingURL=web.test.js.map