hyoo_sync_client 0.0.241 → 0.0.243

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
  }
@@ -1182,7 +1276,6 @@ var $;
1182
1276
  $.$mol_dev_format_element = $mol_dev_format_element;
1183
1277
  function $mol_dev_format_span(style, ...content) {
1184
1278
  return $mol_dev_format_element('span', {
1185
- 'vertical-align': '8%',
1186
1279
  ...style,
1187
1280
  }, ...content);
1188
1281
  }
@@ -2116,6 +2209,8 @@ var $;
2116
2209
  return true;
2117
2210
  }
2118
2211
  function compare_buffer(left, right) {
2212
+ if (left instanceof DataView)
2213
+ return compare_buffer(new Uint8Array(left.buffer, left.byteOffset, left.byteLength), new Uint8Array(right.buffer, left.byteOffset, left.byteLength));
2119
2214
  const len = left.byteLength;
2120
2215
  if (len !== right.byteLength)
2121
2216
  return false;
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
  }
@@ -1174,7 +1268,6 @@ var $;
1174
1268
  $.$mol_dev_format_element = $mol_dev_format_element;
1175
1269
  function $mol_dev_format_span(style, ...content) {
1176
1270
  return $mol_dev_format_element('span', {
1177
- 'vertical-align': '8%',
1178
1271
  ...style,
1179
1272
  }, ...content);
1180
1273
  }
@@ -2108,6 +2201,8 @@ var $;
2108
2201
  return true;
2109
2202
  }
2110
2203
  function compare_buffer(left, right) {
2204
+ if (left instanceof DataView)
2205
+ return compare_buffer(new Uint8Array(left.buffer, left.byteOffset, left.byteLength), new Uint8Array(right.buffer, left.byteOffset, left.byteLength));
2111
2206
  const len = left.byteLength;
2112
2207
  if (len !== right.byteLength)
2113
2208
  return false;
@@ -5244,6 +5339,11 @@ var $;
5244
5339
  $mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
5245
5340
  $mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
5246
5341
  },
5342
+ 'DataView'() {
5343
+ $mol_assert_ok($mol_compare_deep(new DataView(new Uint8Array().buffer), new DataView(new Uint8Array().buffer)));
5344
+ $mol_assert_ok($mol_compare_deep(new DataView(new Uint8Array([0]).buffer), new DataView(new Uint8Array([0]).buffer)));
5345
+ $mol_assert_not($mol_compare_deep(new DataView(new Uint8Array([0]).buffer), new DataView(new Uint8Array([1]).buffer)));
5346
+ },
5247
5347
  'Serializale'() {
5248
5348
  class User {
5249
5349
  name;
@@ -5354,7 +5454,7 @@ var $;
5354
5454
  if ('outerHTML' in val)
5355
5455
  return val.outerHTML;
5356
5456
  try {
5357
- return JSON.stringify(val, null, '\t');
5457
+ return JSON.stringify(val, (k, v) => typeof v === 'bigint' ? String(v) : v, '\t');
5358
5458
  }
5359
5459
  catch (error) {
5360
5460
  console.error(error);
@@ -5624,6 +5724,36 @@ var $;
5624
5724
  ;
5625
5725
  "use strict";
5626
5726
  var $;
5727
+ (function ($) {
5728
+ const png = new Uint8Array([0x1a, 0x0a, 0x00, 0x49, 0x48, 0x78, 0xda]);
5729
+ $mol_test({
5730
+ 'base64 encode string'() {
5731
+ $mol_assert_equal($mol_base64_encode('Hello, ΧΨΩЫ'), 'SGVsbG8sIM6nzqjOqdCr');
5732
+ },
5733
+ 'base64 encode binary'() {
5734
+ $mol_assert_equal($mol_base64_encode(png), 'GgoASUh42g==');
5735
+ },
5736
+ });
5737
+ })($ || ($ = {}));
5738
+ //mol/base64/encode/encode.test.ts
5739
+ ;
5740
+ "use strict";
5741
+ var $;
5742
+ (function ($) {
5743
+ const png = new Uint8Array([0x1a, 0x0a, 0x00, 0x49, 0x48, 0x78, 0xda]);
5744
+ $mol_test({
5745
+ 'base64 decode string'() {
5746
+ $mol_assert_like($mol_base64_decode('SGVsbG8sIM6nzqjOqdCr'), new TextEncoder().encode('Hello, ΧΨΩЫ'));
5747
+ },
5748
+ 'base64 decode binary'() {
5749
+ $mol_assert_like($mol_base64_decode('GgoASUh42g=='), png);
5750
+ },
5751
+ });
5752
+ })($ || ($ = {}));
5753
+ //mol/base64/decode/decode.test.ts
5754
+ ;
5755
+ "use strict";
5756
+ var $;
5627
5757
  (function ($) {
5628
5758
  $mol_test({
5629
5759
  'decode utf8 string'() {