mol_crypto_lib 0.0.153 → 0.0.157
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 +2 -1
- package/node.deps.json +1 -1
- package/node.esm.js +6 -7
- package/node.esm.js.map +1 -1
- package/node.js +6 -7
- package/node.js.map +1 -1
- package/node.test.js +27 -9
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +2 -1
- package/web.deps.json +1 -1
- package/web.esm.js +6 -7
- package/web.esm.js.map +1 -1
- package/web.js +6 -7
- package/web.js.map +1 -1
- package/web.test.js +21 -2
- package/web.test.js.map +1 -1
package/node.d.ts
CHANGED
|
@@ -83,6 +83,7 @@ declare namespace $ {
|
|
|
83
83
|
readonly native: CryptoKey & {
|
|
84
84
|
type: 'private';
|
|
85
85
|
};
|
|
86
|
+
static size: number;
|
|
86
87
|
constructor(native: CryptoKey & {
|
|
87
88
|
type: 'private';
|
|
88
89
|
});
|
|
@@ -90,7 +91,7 @@ declare namespace $ {
|
|
|
90
91
|
serial(): Promise<ArrayBuffer>;
|
|
91
92
|
sign(data: DataView | ArrayBuffer): Promise<ArrayBuffer>;
|
|
92
93
|
}
|
|
93
|
-
const $mol_crypto_auditor_sign_size =
|
|
94
|
+
const $mol_crypto_auditor_sign_size = 64;
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
declare namespace $ {
|
package/node.deps.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"files":["LICENSE","README.md","lang.lang.tree","mam.jam.js","mam.ts","package.json","sandbox.config.json","tsconfig.json","tsfmt.json","yarn.lock","mol/CNAME","mol/CODE_OF_CONDUCT.md","mol/CONTRIBUTING.md","mol/LICENSE","mol/index.html","mol/mol.meta.tree","mol/readme.md","mol/crypto/README.md","mol/crypto/secret/secret.ts","mol/crypto/cipher/cipher.ts","mol/crypto/auditor/auditor.ts","mol/crypto/salt/salt.ts","mol/crypto/lib/lib.meta.tree"],"mods":{},"deps_in":{"mol/crypto":{"mol/crypto/lib":-9007199254740991,"mol/crypto/secret":-9007199254740991,"mol/crypto/cipher":-9007199254740991,"mol/crypto/auditor":-9007199254740991,"mol/crypto/salt":-9007199254740991},"mol":{"mol/crypto":-9007199254740991},"":{"mol":-9007199254740991},"mol/crypto/secret":{"mol/crypto/lib":-9000},"mol/crypto/cipher":{"mol/crypto/lib":-9000},"mol/crypto/auditor":{"mol/crypto/lib":-9000},"mol/crypto/salt":{"mol/crypto/lib":-9000}},"deps_out":{"mol/crypto/lib":{"mol/crypto":-9007199254740991,"mol/crypto/secret":-9000,"mol/crypto/cipher":-9000,"mol/crypto/auditor":-9000,"mol/crypto/salt":-9000},"mol/crypto":{"mol":-9007199254740991},"mol":{"":-9007199254740991},"mol/crypto/secret":{"mol/crypto":-9007199254740991},"mol/crypto/cipher":{"mol/crypto":-9007199254740991},"mol/crypto/auditor":{"mol/crypto":-9007199254740991},"mol/crypto/salt":{"mol/crypto":-9007199254740991}},"sloc":{"LICENSE":113,"md":542,"tree":35,"js":10,"ts":
|
|
1
|
+
{"files":["LICENSE","README.md","lang.lang.tree","mam.jam.js","mam.ts","package.json","sandbox.config.json","tsconfig.json","tsfmt.json","yarn.lock","mol/CNAME","mol/CODE_OF_CONDUCT.md","mol/CONTRIBUTING.md","mol/LICENSE","mol/index.html","mol/mol.meta.tree","mol/readme.md","mol/crypto/README.md","mol/crypto/secret/secret.ts","mol/crypto/cipher/cipher.ts","mol/crypto/auditor/auditor.ts","mol/crypto/salt/salt.ts","mol/crypto/lib/lib.meta.tree"],"mods":{},"deps_in":{"mol/crypto":{"mol/crypto/lib":-9007199254740991,"mol/crypto/secret":-9007199254740991,"mol/crypto/cipher":-9007199254740991,"mol/crypto/auditor":-9007199254740991,"mol/crypto/salt":-9007199254740991},"mol":{"mol/crypto":-9007199254740991},"":{"mol":-9007199254740991},"mol/crypto/secret":{"mol/crypto/lib":-9000},"mol/crypto/cipher":{"mol/crypto/lib":-9000},"mol/crypto/auditor":{"mol/crypto/lib":-9000},"mol/crypto/salt":{"mol/crypto/lib":-9000}},"deps_out":{"mol/crypto/lib":{"mol/crypto":-9007199254740991,"mol/crypto/secret":-9000,"mol/crypto/cipher":-9000,"mol/crypto/auditor":-9000,"mol/crypto/salt":-9000},"mol/crypto":{"mol":-9007199254740991},"mol":{"":-9007199254740991},"mol/crypto/secret":{"mol/crypto":-9007199254740991},"mol/crypto/cipher":{"mol/crypto":-9007199254740991},"mol/crypto/auditor":{"mol/crypto":-9007199254740991},"mol/crypto/salt":{"mol/crypto":-9007199254740991}},"sloc":{"LICENSE":113,"md":542,"tree":35,"js":10,"ts":286,"json":86,"lock":933,"CNAME":1,"html":1},"deps":{"mol/crypto/lib":{"..":-9007199254740991,"/mol/crypto/secret":-9000,"/mol/crypto/cipher":-9000,"/mol/crypto/auditor":-9000,"/mol/crypto/salt":-9000},"mol/crypto":{"..":-9007199254740991},"mol":{"..":-9007199254740991},"":{},"mol/crypto/secret":{"..":-9007199254740991,"/mol/crypto/secret":-1},"mol/crypto/cipher":{"..":-9007199254740991,"/mol/crypto/cipher/pair":-1,"/mol/crypto/cipher/public":-1,"/mol/crypto/cipher/private":-1,"/mol/crypto/cipher/ecrypted/size":-1},"mol/crypto/auditor":{"..":-9007199254740991,"/mol/crypto/auditor/pair":-1,"/mol/crypto/auditor/public":-1,"/mol/crypto/auditor/private":-1,"/mol/crypto/auditor/sign/size":-1},"mol/crypto/salt":{"..":-9007199254740991,"/mol/crypto/salt":-1}}}
|
package/node.esm.js
CHANGED
|
@@ -131,11 +131,9 @@ var $;
|
|
|
131
131
|
var $;
|
|
132
132
|
(function ($) {
|
|
133
133
|
const algorithm = {
|
|
134
|
-
name:
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
hash: 'SHA-1',
|
|
138
|
-
saltLength: 8,
|
|
134
|
+
name: "ECDSA",
|
|
135
|
+
hash: { name: "SHA-256" },
|
|
136
|
+
namedCurve: 'P-256',
|
|
139
137
|
};
|
|
140
138
|
async function $mol_crypto_auditor_pair() {
|
|
141
139
|
const pair = await $.crypto.subtle.generateKey(algorithm, true, ['sign', 'verify']);
|
|
@@ -147,7 +145,7 @@ var $;
|
|
|
147
145
|
$.$mol_crypto_auditor_pair = $mol_crypto_auditor_pair;
|
|
148
146
|
class $mol_crypto_auditor_public extends Object {
|
|
149
147
|
native;
|
|
150
|
-
static size =
|
|
148
|
+
static size = 91;
|
|
151
149
|
constructor(native) {
|
|
152
150
|
super();
|
|
153
151
|
this.native = native;
|
|
@@ -165,6 +163,7 @@ var $;
|
|
|
165
163
|
$.$mol_crypto_auditor_public = $mol_crypto_auditor_public;
|
|
166
164
|
class $mol_crypto_auditor_private extends Object {
|
|
167
165
|
native;
|
|
166
|
+
static size = 138;
|
|
168
167
|
constructor(native) {
|
|
169
168
|
super();
|
|
170
169
|
this.native = native;
|
|
@@ -180,7 +179,7 @@ var $;
|
|
|
180
179
|
}
|
|
181
180
|
}
|
|
182
181
|
$.$mol_crypto_auditor_private = $mol_crypto_auditor_private;
|
|
183
|
-
$.$mol_crypto_auditor_sign_size =
|
|
182
|
+
$.$mol_crypto_auditor_sign_size = 64;
|
|
184
183
|
})($ || ($ = {}));
|
|
185
184
|
//auditor.js.map
|
|
186
185
|
;
|
package/node.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../mam.jam.js","-","../../../../mam.ts","../../secret/secret.ts","../../cipher/cipher.ts","../../auditor/auditor.ts","../../salt/salt.ts"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACbA;AACA;AACA;AACA;;ACHA,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;AAK3B,IAAU,CAAC,CAMV;AAND,WAAU,CAAC;AAMX,CAAC,EANS,CAAC,KAAD,CAAC,QAMV;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,CAAA;;;ADblB;AACA;AACA;;AEFA,IAAU,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AI,CAAE,MAA8B;YAChD,OAAO,IAAI,IAAI,CACd,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAC5B,OAAO,EACP,MAAM,EACN,SAAS,EACT,IAAI,EACJ,CAAE,MAAM,CAAE,CACyB,CACpC,CAAA;QACF,CAAC;QAGD,KAAK,CAAC,MAAM;YACX,OAAO,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CACnC,OAAO,EACP,IAAI,CAAC,MAAM,CACX,CAAA;QACF,CAAC;QAGD,KAAK,CAAC,IAAI,CAAE,IAA4B;YAEvC,OAAO,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAC9B,SAAS,EACT,IAAI,CAAC,MAAM,EACX,IAAI,CACJ,CAAA;QAEF,CAAC;KAED;IAvCY,6BAA2B,8BAuCvC,CAAA;IAGY,+BAA6B,GAAG,EAAE,CAAA;AAEhD,CAAC,EAzHS,CAAC,KAAD,CAAC,QAyHV;;;;ACzHD,IAAU,CAAC,CASV;AATD,WAAU,CAAC;IAGV,SAAgB,gBAAgB;QAC/B,OAAO,MAAM,CAAC,eAAe,CAC5B,IAAI,UAAU,CAAE,CAAC,CAAE,CACnB,CAAA;IACF,CAAC;IAJe,kBAAgB,mBAI/B,CAAA;AAEF,CAAC,EATS,CAAC,KAAD,CAAC,QASV;;;ALTD","file":"node.esm.js","sourcesContent":[null,null,"Error.stackTraceLimit = 50;\n\ndeclare let _$_: { new(): {} } & typeof globalThis\ndeclare class $ extends _$_ {}\n\nnamespace $ {\n\texport type $ = typeof $$\n\texport declare class $$ extends $ {}\n\tnamespace $$ {\n\t\texport type $$ = $\n\t}\n}\n\nmodule.exports = $\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'AES-GCM',\n\t\tlength: 128,\n\t\ttagLength: 32,\n\t}\n\t\n\t/** Symmetric cipher with shortest payload */\n\texport class $mol_crypto_secret extends Object {\n\t\t\n\t\t/** Key size in bytes. */\n\t\tstatic size = 16\n\t\t\n\t\t/** Extra size in bytes to encrypted data. */\n\t\tstatic extra = 4\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async generate() {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.generateKey(\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt', 'decrypt' ]\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'raw',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt', 'decrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 16 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'raw',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\n\t\t/** 4 bytes + data length */\n\t\tasync encrypt( open: DataView | ArrayBuffer, salt: Uint8Array ): Promise< ArrayBuffer > {\n\t\t\treturn await crypto.subtle.encrypt(\n\t\t\t\t{\n\t\t\t\t\t... algorithm,\n\t\t\t\t\tiv: salt,\n\t\t\t\t},\n\t\t\t\tthis.native,\n\t\t\t\topen\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync decrypt( closed: DataView | ArrayBuffer, salt : Uint8Array ): Promise< ArrayBuffer > {\n\t\t\treturn await crypto.subtle.decrypt(\n\t\t\t\t{\n\t\t\t\t\t... algorithm,\n\t\t\t\t\tiv: salt,\n\t\t\t\t},\n\t\t\t\tthis.native,\n\t\t\t\tclosed\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\n}\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'RSA-OAEP',\n\t\tmodulusLength: 1024,\n\t\tpublicExponent: new Uint8Array([ 1, 0, 1 ]),\n\t\thash: 'SHA-1',\n\t}\n\t\n\t/** Asymmetric cipher pair with shortest payload */\n\texport async function $mol_crypto_cipher_pair( this: $ ) {\n\t\t\n\t\tconst pair = await $.crypto.subtle.generateKey(\n\t\t\talgorithm,\n\t\t\ttrue,\n\t\t\t[ 'encrypt', 'decrypt' ]\n\t\t)\n\t\t\n\t\treturn {\n\t\t\t\n\t\t\tpublic: new $mol_crypto_cipher_public(\n\t\t\t\tpair.publicKey as CryptoKey & { type: 'public' }\n\t\t\t),\n\t\t\t\n\t\t\tprivate: new $mol_crypto_cipher_private(\n\t\t\t\tpair.privateKey as CryptoKey & { type: 'private' }\n\t\t\t),\n\t\t\t\n\t\t}\n\t\t\n\t}\n\n\t/** Asymmetric cipher public key wrapper with shortest payload */\n\texport class $mol_crypto_cipher_public extends Object {\n\t\t\n\t\t/** Public key size in bytes. */\n\t\tstatic size = 162\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'public' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'spki',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'public' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 162 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'spki',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** max 86 bytes input, 128 bytes output */\n\t\tasync encrypt( data: DataView | ArrayBuffer ): Promise< ArrayBuffer > {\n\t\t\treturn await crypto.subtle.encrypt(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\n\t/** Asymmetric cipher private key wrapper with shortest payload */\n\texport class $mol_crypto_cipher_private extends Object {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'pkcs8',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'decrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** ~640 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'pkcs8',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync decrypt( data: DataView | ArrayBuffer ): Promise< ArrayBuffer > {\n\t\t\treturn await crypto.subtle.decrypt(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\t\n\t/** Encrypted size in bytes. */\n\texport const $mol_crypto_cipher_ecrypted_size = 128\n\n}\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'RSA-PSS',\n\t\tmodulusLength: 256,\n\t\tpublicExponent: new Uint8Array([ 1, 0, 1 ]),\n\t\thash: 'SHA-1',\n\t\tsaltLength: 8,\n\t}\n\t\n\t/** Asymmetric signing pair with shortest payload */\n\texport async function $mol_crypto_auditor_pair( this: $ ) {\n\t\t\n\t\tconst pair = await $.crypto.subtle.generateKey(\n\t\t\talgorithm,\n\t\t\ttrue,\n\t\t\t[ 'sign', 'verify' ]\n\t\t)\n\t\t\n\t\treturn {\n\t\t\t\n\t\t\tpublic: new $mol_crypto_auditor_public(\n\t\t\t\tpair.publicKey as CryptoKey & { type: 'public' }\n\t\t\t),\n\t\t\t\n\t\t\tprivate: new $mol_crypto_auditor_private(\n\t\t\t\tpair.privateKey as CryptoKey & { type: 'private' }\n\t\t\t),\n\t\t\t\n\t\t}\n\t\t\n\t}\n\t\n\t/** Asymmetric signing public key wrapper with shortest payload */\n\texport class $mol_crypto_auditor_public extends Object {\n\t\t\n\t\t/** Public key size in bytes. */\n\t\tstatic size = 62\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'public' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'spki',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'verify' ],\n\t\t\t\t) as CryptoKey & { type: 'public' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 62 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'spki',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync verify( data: DataView | ArrayBuffer, sign: DataView | ArrayBuffer ) {\n\t\t\treturn await crypto.subtle.verify(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tsign,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\t\n\t/** Asymmetric signing private key wrapper with shortest payload */\n\texport class $mol_crypto_auditor_private extends Object {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'pkcs8',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'sign' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** ~195 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'pkcs8',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 32 bytes */\n\t\tasync sign( data: DataView | ArrayBuffer ) {\n\t\t\t\n\t\t\treturn await crypto.subtle.sign(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata\n\t\t\t)\n\t\t\t\n\t\t}\n\t\t\n\t}\n\t\n\t/** Sign size in bytes. */\n\texport const $mol_crypto_auditor_sign_size = 32\n\t\n}\n","namespace $ {\n\t\n\t/** 8 byte */\n\texport function $mol_crypto_salt() {\n\t\treturn crypto.getRandomValues(\n\t\t\tnew Uint8Array( 8 )\n\t\t)\n\t}\n\t\n}\n"]}
|
|
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;YA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AC,IAAI,CAAE,IAA4B;YAEvC,OAAO,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAC9B,SAAS,EACT,IAAI,CAAC,MAAM,EACX,IAAI,CACJ,CAAA;QAEF,CAAC;;IAxCW,6BAA2B,8BA0CvC,CAAA;IAGY,+BAA6B,GAAG,EAAE,CAAA;AAEhD,CAAC,EAnIS,CAAC,KAAD,CAAC,QAmIV;;;;ACnID,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\n\t// More compact (32B sign) but don't work in Safari\n\t// const 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\tconst algorithm = {\n\t\tname: \"ECDSA\",\n\t\thash: {name: \"SHA-256\"},\n\t\tnamedCurve: 'P-256',\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/** Key size in bytes. */\n\t\tstatic size = 91\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/** 91 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\t/** Key size in bytes. */\n\t\tstatic size = 138\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/** 138 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/** 64 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 = 64\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
CHANGED
|
@@ -131,11 +131,9 @@ var $;
|
|
|
131
131
|
var $;
|
|
132
132
|
(function ($) {
|
|
133
133
|
const algorithm = {
|
|
134
|
-
name:
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
hash: 'SHA-1',
|
|
138
|
-
saltLength: 8,
|
|
134
|
+
name: "ECDSA",
|
|
135
|
+
hash: { name: "SHA-256" },
|
|
136
|
+
namedCurve: 'P-256',
|
|
139
137
|
};
|
|
140
138
|
async function $mol_crypto_auditor_pair() {
|
|
141
139
|
const pair = await $.crypto.subtle.generateKey(algorithm, true, ['sign', 'verify']);
|
|
@@ -147,7 +145,7 @@ var $;
|
|
|
147
145
|
$.$mol_crypto_auditor_pair = $mol_crypto_auditor_pair;
|
|
148
146
|
class $mol_crypto_auditor_public extends Object {
|
|
149
147
|
native;
|
|
150
|
-
static size =
|
|
148
|
+
static size = 91;
|
|
151
149
|
constructor(native) {
|
|
152
150
|
super();
|
|
153
151
|
this.native = native;
|
|
@@ -165,6 +163,7 @@ var $;
|
|
|
165
163
|
$.$mol_crypto_auditor_public = $mol_crypto_auditor_public;
|
|
166
164
|
class $mol_crypto_auditor_private extends Object {
|
|
167
165
|
native;
|
|
166
|
+
static size = 138;
|
|
168
167
|
constructor(native) {
|
|
169
168
|
super();
|
|
170
169
|
this.native = native;
|
|
@@ -180,7 +179,7 @@ var $;
|
|
|
180
179
|
}
|
|
181
180
|
}
|
|
182
181
|
$.$mol_crypto_auditor_private = $mol_crypto_auditor_private;
|
|
183
|
-
$.$mol_crypto_auditor_sign_size =
|
|
182
|
+
$.$mol_crypto_auditor_sign_size = 64;
|
|
184
183
|
})($ || ($ = {}));
|
|
185
184
|
//auditor.js.map
|
|
186
185
|
;
|
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,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,CA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D,CAAC,QAyHV;;;;ACzHD,IAAU,CAAC,CASV;AATD,WAAU,CAAC;IAGV,SAAgB,gBAAgB;QAC/B,OAAO,MAAM,CAAC,eAAe,CAC5B,IAAI,UAAU,CAAE,CAAC,CAAE,CACnB,CAAA;IACF,CAAC;IAJe,kBAAgB,mBAI/B,CAAA;AAEF,CAAC,EATS,CAAC,KAAD,CAAC,QASV;;","file":"node.js","sourcesContent":[null,null,"Error.stackTraceLimit = 50;\n\ndeclare let _$_: { new(): {} } & typeof globalThis\ndeclare class $ extends _$_ {}\n\nnamespace $ {\n\texport type $ = typeof $$\n\texport declare class $$ extends $ {}\n\tnamespace $$ {\n\t\texport type $$ = $\n\t}\n}\n\nmodule.exports = $\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'AES-GCM',\n\t\tlength: 128,\n\t\ttagLength: 32,\n\t}\n\t\n\t/** Symmetric cipher with shortest payload */\n\texport class $mol_crypto_secret extends Object {\n\t\t\n\t\t/** Key size in bytes. */\n\t\tstatic size = 16\n\t\t\n\t\t/** Extra size in bytes to encrypted data. */\n\t\tstatic extra = 4\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async generate() {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.generateKey(\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt', 'decrypt' ]\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'raw',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt', 'decrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 16 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'raw',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\n\t\t/** 4 bytes + data length */\n\t\tasync encrypt( open: DataView | ArrayBuffer, salt: Uint8Array ): Promise< ArrayBuffer > {\n\t\t\treturn await crypto.subtle.encrypt(\n\t\t\t\t{\n\t\t\t\t\t... algorithm,\n\t\t\t\t\tiv: salt,\n\t\t\t\t},\n\t\t\t\tthis.native,\n\t\t\t\topen\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync decrypt( closed: DataView | ArrayBuffer, salt : Uint8Array ): Promise< ArrayBuffer > {\n\t\t\treturn await crypto.subtle.decrypt(\n\t\t\t\t{\n\t\t\t\t\t... algorithm,\n\t\t\t\t\tiv: salt,\n\t\t\t\t},\n\t\t\t\tthis.native,\n\t\t\t\tclosed\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\n}\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'RSA-OAEP',\n\t\tmodulusLength: 1024,\n\t\tpublicExponent: new Uint8Array([ 1, 0, 1 ]),\n\t\thash: 'SHA-1',\n\t}\n\t\n\t/** Asymmetric cipher pair with shortest payload */\n\texport async function $mol_crypto_cipher_pair( this: $ ) {\n\t\t\n\t\tconst pair = await $.crypto.subtle.generateKey(\n\t\t\talgorithm,\n\t\t\ttrue,\n\t\t\t[ 'encrypt', 'decrypt' ]\n\t\t)\n\t\t\n\t\treturn {\n\t\t\t\n\t\t\tpublic: new $mol_crypto_cipher_public(\n\t\t\t\tpair.publicKey as CryptoKey & { type: 'public' }\n\t\t\t),\n\t\t\t\n\t\t\tprivate: new $mol_crypto_cipher_private(\n\t\t\t\tpair.privateKey as CryptoKey & { type: 'private' }\n\t\t\t),\n\t\t\t\n\t\t}\n\t\t\n\t}\n\n\t/** Asymmetric cipher public key wrapper with shortest payload */\n\texport class $mol_crypto_cipher_public extends Object {\n\t\t\n\t\t/** Public key size in bytes. */\n\t\tstatic size = 162\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'public' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'spki',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'public' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 162 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'spki',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** max 86 bytes input, 128 bytes output */\n\t\tasync encrypt( data: DataView | ArrayBuffer ): Promise< ArrayBuffer > {\n\t\t\treturn await crypto.subtle.encrypt(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\n\t/** Asymmetric cipher private key wrapper with shortest payload */\n\texport class $mol_crypto_cipher_private extends Object {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'pkcs8',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'decrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** ~640 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'pkcs8',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync decrypt( data: DataView | ArrayBuffer ): Promise< ArrayBuffer > {\n\t\t\treturn await crypto.subtle.decrypt(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\t\n\t/** Encrypted size in bytes. */\n\texport const $mol_crypto_cipher_ecrypted_size = 128\n\n}\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'RSA-PSS',\n\t\tmodulusLength: 256,\n\t\tpublicExponent: new Uint8Array([ 1, 0, 1 ]),\n\t\thash: 'SHA-1',\n\t\tsaltLength: 8,\n\t}\n\t\n\t/** Asymmetric signing pair with shortest payload */\n\texport async function $mol_crypto_auditor_pair( this: $ ) {\n\t\t\n\t\tconst pair = await $.crypto.subtle.generateKey(\n\t\t\talgorithm,\n\t\t\ttrue,\n\t\t\t[ 'sign', 'verify' ]\n\t\t)\n\t\t\n\t\treturn {\n\t\t\t\n\t\t\tpublic: new $mol_crypto_auditor_public(\n\t\t\t\tpair.publicKey as CryptoKey & { type: 'public' }\n\t\t\t),\n\t\t\t\n\t\t\tprivate: new $mol_crypto_auditor_private(\n\t\t\t\tpair.privateKey as CryptoKey & { type: 'private' }\n\t\t\t),\n\t\t\t\n\t\t}\n\t\t\n\t}\n\t\n\t/** Asymmetric signing public key wrapper with shortest payload */\n\texport class $mol_crypto_auditor_public extends Object {\n\t\t\n\t\t/** Public key size in bytes. */\n\t\tstatic size = 62\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'public' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'spki',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'verify' ],\n\t\t\t\t) as CryptoKey & { type: 'public' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 62 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'spki',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync verify( data: DataView | ArrayBuffer, sign: DataView | ArrayBuffer ) {\n\t\t\treturn await crypto.subtle.verify(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tsign,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\t\n\t/** Asymmetric signing private key wrapper with shortest payload */\n\texport class $mol_crypto_auditor_private extends Object {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'pkcs8',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'sign' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** ~195 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'pkcs8',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 32 bytes */\n\t\tasync sign( data: DataView | ArrayBuffer ) {\n\t\t\t\n\t\t\treturn await crypto.subtle.sign(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata\n\t\t\t)\n\t\t\t\n\t\t}\n\t\t\n\t}\n\t\n\t/** Sign size in bytes. */\n\texport const $mol_crypto_auditor_sign_size = 32\n\t\n}\n","namespace $ {\n\t\n\t/** 8 byte */\n\texport function $mol_crypto_salt() {\n\t\treturn crypto.getRandomValues(\n\t\t\tnew Uint8Array( 8 )\n\t\t)\n\t}\n\t\n}\n"]}
|
|
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,CACnC,KAAK,EACL,IAAI,C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,MAAM,CAAC,MAAM,CAChC,SAAS,EACT,IAAI,CAAC,MAAM,EACX,IAAI,EACJ,IAAI,CACJ,CAAA;QACF,CAAC;;IAtCW,4BAA0B,6BAwCtC,CAAA;IAGD,MAAa,2BAA4B,SAAQ,MAAM;QAM5C;QAHV,MAAM,CAAC,IAAI,GAAG,GAAG,CAAA;QAEjB,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;;IAxCW,6BAA2B,8BA0CvC,CAAA;IAGY,+BAA6B,GAAG,EAAE,CAAA;AAEhD,CAAC,EAnIS,CAAC,KAAD,CAAC,QAmIV;;;;ACnID,IAAU,CAAC,CASV;AATD,WAAU,CAAC;IAGV,SAAgB,gBAAgB;QAC/B,OAAO,MAAM,CAAC,eAAe,CAC5B,IAAI,UAAU,CAAE,CAAC,CAAE,CACnB,CAAA;IACF,CAAC;IAJe,kBAAgB,mBAI/B,CAAA;AAEF,CAAC,EATS,CAAC,KAAD,CAAC,QASV;;","file":"node.js","sourcesContent":[null,null,"Error.stackTraceLimit = 50;\n\ndeclare let _$_: { new(): {} } & typeof globalThis\ndeclare class $ extends _$_ {}\n\nnamespace $ {\n\texport type $ = typeof $$\n\texport declare class $$ extends $ {}\n\tnamespace $$ {\n\t\texport type $$ = $\n\t}\n}\n\nmodule.exports = $\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'AES-GCM',\n\t\tlength: 128,\n\t\ttagLength: 32,\n\t}\n\t\n\t/** Symmetric cipher with shortest payload */\n\texport class $mol_crypto_secret extends Object {\n\t\t\n\t\t/** Key size in bytes. */\n\t\tstatic size = 16\n\t\t\n\t\t/** Extra size in bytes to encrypted data. */\n\t\tstatic extra = 4\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async generate() {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.generateKey(\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt', 'decrypt' ]\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'raw',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt', 'decrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 16 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'raw',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\n\t\t/** 4 bytes + data length */\n\t\tasync encrypt( open: DataView | ArrayBuffer, salt: Uint8Array ): Promise< ArrayBuffer > {\n\t\t\treturn await crypto.subtle.encrypt(\n\t\t\t\t{\n\t\t\t\t\t... algorithm,\n\t\t\t\t\tiv: salt,\n\t\t\t\t},\n\t\t\t\tthis.native,\n\t\t\t\topen\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync decrypt( closed: DataView | ArrayBuffer, salt : Uint8Array ): Promise< ArrayBuffer > {\n\t\t\treturn await crypto.subtle.decrypt(\n\t\t\t\t{\n\t\t\t\t\t... algorithm,\n\t\t\t\t\tiv: salt,\n\t\t\t\t},\n\t\t\t\tthis.native,\n\t\t\t\tclosed\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\n}\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'RSA-OAEP',\n\t\tmodulusLength: 1024,\n\t\tpublicExponent: new Uint8Array([ 1, 0, 1 ]),\n\t\thash: 'SHA-1',\n\t}\n\t\n\t/** Asymmetric cipher pair with shortest payload */\n\texport async function $mol_crypto_cipher_pair( this: $ ) {\n\t\t\n\t\tconst pair = await $.crypto.subtle.generateKey(\n\t\t\talgorithm,\n\t\t\ttrue,\n\t\t\t[ 'encrypt', 'decrypt' ]\n\t\t)\n\t\t\n\t\treturn {\n\t\t\t\n\t\t\tpublic: new $mol_crypto_cipher_public(\n\t\t\t\tpair.publicKey as CryptoKey & { type: 'public' }\n\t\t\t),\n\t\t\t\n\t\t\tprivate: new $mol_crypto_cipher_private(\n\t\t\t\tpair.privateKey as CryptoKey & { type: 'private' }\n\t\t\t),\n\t\t\t\n\t\t}\n\t\t\n\t}\n\n\t/** Asymmetric cipher public key wrapper with shortest payload */\n\texport class $mol_crypto_cipher_public extends Object {\n\t\t\n\t\t/** Public key size in bytes. */\n\t\tstatic size = 162\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'public' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'spki',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'public' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 162 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'spki',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** max 86 bytes input, 128 bytes output */\n\t\tasync encrypt( data: DataView | ArrayBuffer ): Promise< ArrayBuffer > {\n\t\t\treturn await crypto.subtle.encrypt(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\n\t/** Asymmetric cipher private key wrapper with shortest payload */\n\texport class $mol_crypto_cipher_private extends Object {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: DataView | ArrayBuffer ) {\n\t\t\treturn new this(\n\t\t\t\tawait crypto.subtle.importKey(\n\t\t\t\t\t'pkcs8',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'decrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** ~640 bytes */\n\t\tasync serial() {\n\t\t\treturn await crypto.subtle.exportKey(\n\t\t\t\t'pkcs8',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync decrypt( data: DataView | ArrayBuffer ): Promise< ArrayBuffer > {\n\t\t\treturn await crypto.subtle.decrypt(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\t\n\t/** Encrypted size in bytes. */\n\texport const $mol_crypto_cipher_ecrypted_size = 128\n\n}\n","namespace $ {\n\n\t// More compact (32B sign) but don't work in Safari\n\t// const 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\tconst algorithm = {\n\t\tname: \"ECDSA\",\n\t\thash: {name: \"SHA-256\"},\n\t\tnamedCurve: 'P-256',\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/** Key size in bytes. */\n\t\tstatic size = 91\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/** 91 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\t/** Key size in bytes. */\n\t\tstatic size = 138\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/** 138 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/** 64 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 = 64\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
|
@@ -123,11 +123,9 @@ var $;
|
|
|
123
123
|
var $;
|
|
124
124
|
(function ($) {
|
|
125
125
|
const algorithm = {
|
|
126
|
-
name:
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
hash: 'SHA-1',
|
|
130
|
-
saltLength: 8,
|
|
126
|
+
name: "ECDSA",
|
|
127
|
+
hash: { name: "SHA-256" },
|
|
128
|
+
namedCurve: 'P-256',
|
|
131
129
|
};
|
|
132
130
|
async function $mol_crypto_auditor_pair() {
|
|
133
131
|
const pair = await $.crypto.subtle.generateKey(algorithm, true, ['sign', 'verify']);
|
|
@@ -139,7 +137,7 @@ var $;
|
|
|
139
137
|
$.$mol_crypto_auditor_pair = $mol_crypto_auditor_pair;
|
|
140
138
|
class $mol_crypto_auditor_public extends Object {
|
|
141
139
|
native;
|
|
142
|
-
static size =
|
|
140
|
+
static size = 91;
|
|
143
141
|
constructor(native) {
|
|
144
142
|
super();
|
|
145
143
|
this.native = native;
|
|
@@ -157,6 +155,7 @@ var $;
|
|
|
157
155
|
$.$mol_crypto_auditor_public = $mol_crypto_auditor_public;
|
|
158
156
|
class $mol_crypto_auditor_private extends Object {
|
|
159
157
|
native;
|
|
158
|
+
static size = 138;
|
|
160
159
|
constructor(native) {
|
|
161
160
|
super();
|
|
162
161
|
this.native = native;
|
|
@@ -172,7 +171,7 @@ var $;
|
|
|
172
171
|
}
|
|
173
172
|
}
|
|
174
173
|
$.$mol_crypto_auditor_private = $mol_crypto_auditor_private;
|
|
175
|
-
$.$mol_crypto_auditor_sign_size =
|
|
174
|
+
$.$mol_crypto_auditor_sign_size = 64;
|
|
176
175
|
})($ || ($ = {}));
|
|
177
176
|
//auditor.js.map
|
|
178
177
|
;
|
|
@@ -644,6 +643,21 @@ var $;
|
|
|
644
643
|
$.$mol_assert_ok($.$mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
645
644
|
$.$mol_assert_not($.$mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
646
645
|
},
|
|
646
|
+
'Custom comparator'() {
|
|
647
|
+
class User {
|
|
648
|
+
name;
|
|
649
|
+
rand;
|
|
650
|
+
constructor(name, rand = Math.random()) {
|
|
651
|
+
this.name = name;
|
|
652
|
+
this.rand = rand;
|
|
653
|
+
}
|
|
654
|
+
[Symbol.toPrimitive](mode) {
|
|
655
|
+
return this.name;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
$.$mol_assert_ok($.$mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
659
|
+
$.$mol_assert_not($.$mol_compare_deep(new User('Jin'), new User('John')));
|
|
660
|
+
},
|
|
647
661
|
});
|
|
648
662
|
})($ || ($ = {}));
|
|
649
663
|
//deep.test.js.map
|
|
@@ -699,6 +713,8 @@ var $;
|
|
|
699
713
|
result = compare_map(left, right);
|
|
700
714
|
else if (ArrayBuffer.isView(left))
|
|
701
715
|
result = compare_buffer(left, right);
|
|
716
|
+
else if (Symbol.toPrimitive in left)
|
|
717
|
+
result = compare_primitive(left, right);
|
|
702
718
|
else
|
|
703
719
|
result = false;
|
|
704
720
|
}
|
|
@@ -763,6 +779,9 @@ var $;
|
|
|
763
779
|
}
|
|
764
780
|
return true;
|
|
765
781
|
}
|
|
782
|
+
function compare_primitive(left, right) {
|
|
783
|
+
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
784
|
+
}
|
|
766
785
|
})($ || ($ = {}));
|
|
767
786
|
//deep.js.map
|
|
768
787
|
;
|
|
@@ -964,8 +983,7 @@ var $;
|
|
|
964
983
|
async 'sizes'() {
|
|
965
984
|
const pair = await $.$$.$mol_crypto_auditor_pair();
|
|
966
985
|
const key_private = await pair.private.serial();
|
|
967
|
-
$.$
|
|
968
|
-
$.$mol_assert_ok(key_private.byteLength < 200);
|
|
986
|
+
$.$mol_assert_equal(key_private.byteLength, $.$mol_crypto_auditor_private.size);
|
|
969
987
|
const key_public = await pair.public.serial();
|
|
970
988
|
$.$mol_assert_equal(key_public.byteLength, $.$mol_crypto_auditor_public.size);
|
|
971
989
|
const data = new Uint8Array([1, 2, 3]);
|