hyoo_sync_client 0.0.240 → 0.0.242

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.mjs CHANGED
@@ -996,6 +996,74 @@ var $;
996
996
  ;
997
997
  "use strict";
998
998
  var $;
999
+ (function ($) {
1000
+ function $mol_base64_encode(src) {
1001
+ throw new Error('Not implemented');
1002
+ }
1003
+ $.$mol_base64_encode = $mol_base64_encode;
1004
+ })($ || ($ = {}));
1005
+ //mol/base64/encode/encode.ts
1006
+ ;
1007
+ "use strict";
1008
+ var $;
1009
+ (function ($) {
1010
+ function $mol_base64_encode_node(str) {
1011
+ if (!str)
1012
+ return '';
1013
+ if (Buffer.isBuffer(str))
1014
+ return str.toString('base64');
1015
+ return Buffer.from(str).toString('base64');
1016
+ }
1017
+ $.$mol_base64_encode_node = $mol_base64_encode_node;
1018
+ $.$mol_base64_encode = $mol_base64_encode_node;
1019
+ })($ || ($ = {}));
1020
+ //mol/base64/encode/encode.node.ts
1021
+ ;
1022
+ "use strict";
1023
+ var $;
1024
+ (function ($) {
1025
+ function $mol_base64_encode_safe(buffer) {
1026
+ return $mol_base64_encode(buffer).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/, '');
1027
+ }
1028
+ $.$mol_base64_encode_safe = $mol_base64_encode_safe;
1029
+ })($ || ($ = {}));
1030
+ //mol/base64/encode/safe/safe.ts
1031
+ ;
1032
+ "use strict";
1033
+ var $;
1034
+ (function ($) {
1035
+ function $mol_base64_decode(base64) {
1036
+ throw new Error('Not implemented');
1037
+ }
1038
+ $.$mol_base64_decode = $mol_base64_decode;
1039
+ })($ || ($ = {}));
1040
+ //mol/base64/decode/decode.ts
1041
+ ;
1042
+ "use strict";
1043
+ var $;
1044
+ (function ($) {
1045
+ function $mol_base64_decode_node(base64Str) {
1046
+ base64Str = base64Str.replace(/-/g, '+').replace(/_/g, '/');
1047
+ const buffer = Buffer.from(base64Str, 'base64');
1048
+ return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
1049
+ }
1050
+ $.$mol_base64_decode_node = $mol_base64_decode_node;
1051
+ $.$mol_base64_decode = $mol_base64_decode_node;
1052
+ })($ || ($ = {}));
1053
+ //mol/base64/decode/decode.node.ts
1054
+ ;
1055
+ "use strict";
1056
+ var $;
1057
+ (function ($) {
1058
+ function $mol_base64_decode_safe(str) {
1059
+ return $mol_base64_decode(str.replace(/-/g, '+').replace(/_/g, '/'));
1060
+ }
1061
+ $.$mol_base64_decode_safe = $mol_base64_decode_safe;
1062
+ })($ || ($ = {}));
1063
+ //mol/base64/decode/safe/safe.ts
1064
+ ;
1065
+ "use strict";
1066
+ var $;
999
1067
  (function ($) {
1000
1068
  const algorithm = {
1001
1069
  name: 'ECDSA',
@@ -1012,12 +1080,17 @@ var $;
1012
1080
  $.$mol_crypto_auditor_pair = $mol_crypto_auditor_pair;
1013
1081
  class $mol_crypto_auditor_public extends Object {
1014
1082
  native;
1015
- static size = 86;
1083
+ static size_str = 86;
1084
+ static size_bin = 64;
1016
1085
  constructor(native) {
1017
1086
  super();
1018
1087
  this.native = native;
1019
1088
  }
1020
1089
  static async from(serial) {
1090
+ if (typeof serial !== 'string') {
1091
+ serial = $mol_base64_encode_safe(serial.subarray(0, 32))
1092
+ + $mol_base64_encode_safe(serial.subarray(32, 64));
1093
+ }
1021
1094
  return new this(await $mol_crypto_native.subtle.importKey('jwk', {
1022
1095
  crv: "P-256",
1023
1096
  ext: true,
@@ -1031,6 +1104,13 @@ var $;
1031
1104
  const { x, y } = await $mol_crypto_native.subtle.exportKey('jwk', this.native);
1032
1105
  return x + y;
1033
1106
  }
1107
+ async toArray() {
1108
+ const { x, y, d } = await $mol_crypto_native.subtle.exportKey('jwk', this.native);
1109
+ return new Uint8Array([
1110
+ ...$mol_base64_decode_safe(x),
1111
+ ...$mol_base64_decode_safe(y),
1112
+ ]);
1113
+ }
1034
1114
  async verify(data, sign) {
1035
1115
  return await $mol_crypto_native.subtle.verify(algorithm, this.native, sign, data);
1036
1116
  }
@@ -1038,12 +1118,18 @@ var $;
1038
1118
  $.$mol_crypto_auditor_public = $mol_crypto_auditor_public;
1039
1119
  class $mol_crypto_auditor_private extends Object {
1040
1120
  native;
1041
- static size = 129;
1121
+ static size_str = 129;
1122
+ static size_bin = 96;
1042
1123
  constructor(native) {
1043
1124
  super();
1044
1125
  this.native = native;
1045
1126
  }
1046
1127
  static async from(serial) {
1128
+ if (typeof serial !== 'string') {
1129
+ serial = $mol_base64_encode_safe(serial.subarray(0, 32))
1130
+ + $mol_base64_encode_safe(serial.subarray(32, 64))
1131
+ + $mol_base64_encode_safe(serial.subarray(64));
1132
+ }
1047
1133
  return new this(await $mol_crypto_native.subtle.importKey('jwk', {
1048
1134
  crv: "P-256",
1049
1135
  ext: true,
@@ -1058,6 +1144,14 @@ var $;
1058
1144
  const { x, y, d } = await $mol_crypto_native.subtle.exportKey('jwk', this.native);
1059
1145
  return x + y + d;
1060
1146
  }
1147
+ async toArray() {
1148
+ const { x, y, d } = await $mol_crypto_native.subtle.exportKey('jwk', this.native);
1149
+ return new Uint8Array([
1150
+ ...$mol_base64_decode_safe(x),
1151
+ ...$mol_base64_decode_safe(y),
1152
+ ...$mol_base64_decode_safe(d),
1153
+ ]);
1154
+ }
1061
1155
  async sign(data) {
1062
1156
  return await $mol_crypto_native.subtle.sign(algorithm, this.native, data);
1063
1157
  }
@@ -2001,11 +2095,15 @@ var $;
2001
2095
  (function ($) {
2002
2096
  $.$mol_key_store = new WeakMap();
2003
2097
  function $mol_key(value) {
2098
+ if (typeof value === 'bigint')
2099
+ return value.toString() + 'n';
2004
2100
  if (!value)
2005
2101
  return JSON.stringify(value);
2006
2102
  if (typeof value !== 'object' && typeof value !== 'function')
2007
2103
  return JSON.stringify(value);
2008
2104
  return JSON.stringify(value, (field, value) => {
2105
+ if (typeof value === 'bigint')
2106
+ return value.toString() + 'n';
2009
2107
  if (!value)
2010
2108
  return value;
2011
2109
  if (typeof value !== 'object' && typeof value !== 'function')
package/node.test.js CHANGED
@@ -988,6 +988,74 @@ var $;
988
988
  ;
989
989
  "use strict";
990
990
  var $;
991
+ (function ($) {
992
+ function $mol_base64_encode(src) {
993
+ throw new Error('Not implemented');
994
+ }
995
+ $.$mol_base64_encode = $mol_base64_encode;
996
+ })($ || ($ = {}));
997
+ //mol/base64/encode/encode.ts
998
+ ;
999
+ "use strict";
1000
+ var $;
1001
+ (function ($) {
1002
+ function $mol_base64_encode_node(str) {
1003
+ if (!str)
1004
+ return '';
1005
+ if (Buffer.isBuffer(str))
1006
+ return str.toString('base64');
1007
+ return Buffer.from(str).toString('base64');
1008
+ }
1009
+ $.$mol_base64_encode_node = $mol_base64_encode_node;
1010
+ $.$mol_base64_encode = $mol_base64_encode_node;
1011
+ })($ || ($ = {}));
1012
+ //mol/base64/encode/encode.node.ts
1013
+ ;
1014
+ "use strict";
1015
+ var $;
1016
+ (function ($) {
1017
+ function $mol_base64_encode_safe(buffer) {
1018
+ return $mol_base64_encode(buffer).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/, '');
1019
+ }
1020
+ $.$mol_base64_encode_safe = $mol_base64_encode_safe;
1021
+ })($ || ($ = {}));
1022
+ //mol/base64/encode/safe/safe.ts
1023
+ ;
1024
+ "use strict";
1025
+ var $;
1026
+ (function ($) {
1027
+ function $mol_base64_decode(base64) {
1028
+ throw new Error('Not implemented');
1029
+ }
1030
+ $.$mol_base64_decode = $mol_base64_decode;
1031
+ })($ || ($ = {}));
1032
+ //mol/base64/decode/decode.ts
1033
+ ;
1034
+ "use strict";
1035
+ var $;
1036
+ (function ($) {
1037
+ function $mol_base64_decode_node(base64Str) {
1038
+ base64Str = base64Str.replace(/-/g, '+').replace(/_/g, '/');
1039
+ const buffer = Buffer.from(base64Str, 'base64');
1040
+ return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
1041
+ }
1042
+ $.$mol_base64_decode_node = $mol_base64_decode_node;
1043
+ $.$mol_base64_decode = $mol_base64_decode_node;
1044
+ })($ || ($ = {}));
1045
+ //mol/base64/decode/decode.node.ts
1046
+ ;
1047
+ "use strict";
1048
+ var $;
1049
+ (function ($) {
1050
+ function $mol_base64_decode_safe(str) {
1051
+ return $mol_base64_decode(str.replace(/-/g, '+').replace(/_/g, '/'));
1052
+ }
1053
+ $.$mol_base64_decode_safe = $mol_base64_decode_safe;
1054
+ })($ || ($ = {}));
1055
+ //mol/base64/decode/safe/safe.ts
1056
+ ;
1057
+ "use strict";
1058
+ var $;
991
1059
  (function ($) {
992
1060
  const algorithm = {
993
1061
  name: 'ECDSA',
@@ -1004,12 +1072,17 @@ var $;
1004
1072
  $.$mol_crypto_auditor_pair = $mol_crypto_auditor_pair;
1005
1073
  class $mol_crypto_auditor_public extends Object {
1006
1074
  native;
1007
- static size = 86;
1075
+ static size_str = 86;
1076
+ static size_bin = 64;
1008
1077
  constructor(native) {
1009
1078
  super();
1010
1079
  this.native = native;
1011
1080
  }
1012
1081
  static async from(serial) {
1082
+ if (typeof serial !== 'string') {
1083
+ serial = $mol_base64_encode_safe(serial.subarray(0, 32))
1084
+ + $mol_base64_encode_safe(serial.subarray(32, 64));
1085
+ }
1013
1086
  return new this(await $mol_crypto_native.subtle.importKey('jwk', {
1014
1087
  crv: "P-256",
1015
1088
  ext: true,
@@ -1023,6 +1096,13 @@ var $;
1023
1096
  const { x, y } = await $mol_crypto_native.subtle.exportKey('jwk', this.native);
1024
1097
  return x + y;
1025
1098
  }
1099
+ async toArray() {
1100
+ const { x, y, d } = await $mol_crypto_native.subtle.exportKey('jwk', this.native);
1101
+ return new Uint8Array([
1102
+ ...$mol_base64_decode_safe(x),
1103
+ ...$mol_base64_decode_safe(y),
1104
+ ]);
1105
+ }
1026
1106
  async verify(data, sign) {
1027
1107
  return await $mol_crypto_native.subtle.verify(algorithm, this.native, sign, data);
1028
1108
  }
@@ -1030,12 +1110,18 @@ var $;
1030
1110
  $.$mol_crypto_auditor_public = $mol_crypto_auditor_public;
1031
1111
  class $mol_crypto_auditor_private extends Object {
1032
1112
  native;
1033
- static size = 129;
1113
+ static size_str = 129;
1114
+ static size_bin = 96;
1034
1115
  constructor(native) {
1035
1116
  super();
1036
1117
  this.native = native;
1037
1118
  }
1038
1119
  static async from(serial) {
1120
+ if (typeof serial !== 'string') {
1121
+ serial = $mol_base64_encode_safe(serial.subarray(0, 32))
1122
+ + $mol_base64_encode_safe(serial.subarray(32, 64))
1123
+ + $mol_base64_encode_safe(serial.subarray(64));
1124
+ }
1039
1125
  return new this(await $mol_crypto_native.subtle.importKey('jwk', {
1040
1126
  crv: "P-256",
1041
1127
  ext: true,
@@ -1050,6 +1136,14 @@ var $;
1050
1136
  const { x, y, d } = await $mol_crypto_native.subtle.exportKey('jwk', this.native);
1051
1137
  return x + y + d;
1052
1138
  }
1139
+ async toArray() {
1140
+ const { x, y, d } = await $mol_crypto_native.subtle.exportKey('jwk', this.native);
1141
+ return new Uint8Array([
1142
+ ...$mol_base64_decode_safe(x),
1143
+ ...$mol_base64_decode_safe(y),
1144
+ ...$mol_base64_decode_safe(d),
1145
+ ]);
1146
+ }
1053
1147
  async sign(data) {
1054
1148
  return await $mol_crypto_native.subtle.sign(algorithm, this.native, data);
1055
1149
  }
@@ -1993,11 +2087,15 @@ var $;
1993
2087
  (function ($) {
1994
2088
  $.$mol_key_store = new WeakMap();
1995
2089
  function $mol_key(value) {
2090
+ if (typeof value === 'bigint')
2091
+ return value.toString() + 'n';
1996
2092
  if (!value)
1997
2093
  return JSON.stringify(value);
1998
2094
  if (typeof value !== 'object' && typeof value !== 'function')
1999
2095
  return JSON.stringify(value);
2000
2096
  return JSON.stringify(value, (field, value) => {
2097
+ if (typeof value === 'bigint')
2098
+ return value.toString() + 'n';
2001
2099
  if (!value)
2002
2100
  return value;
2003
2101
  if (typeof value !== 'object' && typeof value !== 'function')
@@ -5620,6 +5718,36 @@ var $;
5620
5718
  ;
5621
5719
  "use strict";
5622
5720
  var $;
5721
+ (function ($) {
5722
+ const png = new Uint8Array([0x1a, 0x0a, 0x00, 0x49, 0x48, 0x78, 0xda]);
5723
+ $mol_test({
5724
+ 'base64 encode string'() {
5725
+ $mol_assert_equal($mol_base64_encode('Hello, ΧΨΩЫ'), 'SGVsbG8sIM6nzqjOqdCr');
5726
+ },
5727
+ 'base64 encode binary'() {
5728
+ $mol_assert_equal($mol_base64_encode(png), 'GgoASUh42g==');
5729
+ },
5730
+ });
5731
+ })($ || ($ = {}));
5732
+ //mol/base64/encode/encode.test.ts
5733
+ ;
5734
+ "use strict";
5735
+ var $;
5736
+ (function ($) {
5737
+ const png = new Uint8Array([0x1a, 0x0a, 0x00, 0x49, 0x48, 0x78, 0xda]);
5738
+ $mol_test({
5739
+ 'base64 decode string'() {
5740
+ $mol_assert_like($mol_base64_decode('SGVsbG8sIM6nzqjOqdCr'), new TextEncoder().encode('Hello, ΧΨΩЫ'));
5741
+ },
5742
+ 'base64 decode binary'() {
5743
+ $mol_assert_like($mol_base64_decode('GgoASUh42g=='), png);
5744
+ },
5745
+ });
5746
+ })($ || ($ = {}));
5747
+ //mol/base64/decode/decode.test.ts
5748
+ ;
5749
+ "use strict";
5750
+ var $;
5623
5751
  (function ($) {
5624
5752
  $mol_test({
5625
5753
  'decode utf8 string'() {
@@ -8378,6 +8506,7 @@ var $;
8378
8506
  $mol_assert_equal($mol_key(false), 'false');
8379
8507
  $mol_assert_equal($mol_key(true), 'true');
8380
8508
  $mol_assert_equal($mol_key(0), '0');
8509
+ $mol_assert_equal($mol_key(1n << 64n), '18446744073709551616n');
8381
8510
  $mol_assert_equal($mol_key(''), '""');
8382
8511
  },
8383
8512
  'Array & POJO'() {