@wener/common 1.0.5 → 2.0.2

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.
Files changed (222) hide show
  1. package/lib/cn/ChineseResidentIdNo.js +41 -0
  2. package/lib/cn/ChineseResidentIdNo.mod.js +1 -0
  3. package/lib/cn/ChineseResidentIdNo.test.js +22 -0
  4. package/lib/cn/DivisionCode.js +214 -280
  5. package/lib/cn/DivisionCode.mod.js +1 -0
  6. package/lib/cn/DivisionCode.test.js +134 -0
  7. package/lib/cn/Mod11.js +86 -0
  8. package/lib/cn/Mod31.js +98 -0
  9. package/lib/cn/UnifiedSocialCreditCode.js +130 -109
  10. package/lib/cn/UnifiedSocialCreditCode.mod.js +1 -0
  11. package/lib/cn/UnifiedSocialCreditCode.test.js +16 -0
  12. package/lib/cn/index.js +1 -4
  13. package/lib/cn/mod.js +6 -0
  14. package/lib/cn/types.d.js +0 -2
  15. package/lib/consola/createStandardConsolaReporter.js +6 -6
  16. package/lib/consola/formatLogObject.js +147 -34
  17. package/lib/consola/index.js +0 -1
  18. package/lib/data/formatSort.js +5 -6
  19. package/lib/data/formatSort.test.js +34 -0
  20. package/lib/data/index.js +0 -1
  21. package/lib/data/maybeNumber.js +11 -5
  22. package/lib/data/parseSort.js +28 -22
  23. package/lib/data/parseSort.test.js +188 -0
  24. package/lib/data/resolvePagination.js +27 -16
  25. package/lib/data/resolvePagination.test.js +232 -0
  26. package/lib/data/types.d.js +0 -2
  27. package/lib/dayjs/dayjs.js +38 -0
  28. package/lib/dayjs/formatDuration.js +58 -0
  29. package/lib/dayjs/formatDuration.test.js +90 -0
  30. package/lib/dayjs/index.js +3 -0
  31. package/lib/dayjs/parseDuration.js +32 -0
  32. package/lib/decimal/index.js +1 -0
  33. package/lib/decimal/parseDecimal.js +13 -0
  34. package/lib/foundation/schema/SexType.js +14 -0
  35. package/lib/foundation/schema/index.js +1 -0
  36. package/lib/foundation/schema/parseSexType.js +18 -0
  37. package/lib/foundation/schema/types.js +5 -0
  38. package/lib/index.js +0 -1
  39. package/lib/jsonschema/JsonSchema.js +78 -52
  40. package/lib/jsonschema/JsonSchema.test.js +137 -0
  41. package/lib/jsonschema/index.js +0 -1
  42. package/lib/jsonschema/types.d.js +5 -3
  43. package/lib/meta/defineFileType.js +103 -20
  44. package/lib/meta/defineInit.js +250 -31
  45. package/lib/meta/defineMetadata.js +140 -24
  46. package/lib/meta/defineMetadata.test.js +13 -0
  47. package/lib/meta/index.js +0 -1
  48. package/lib/password/PHC.js +87 -63
  49. package/lib/password/PHC.test.js +539 -0
  50. package/lib/password/Password.js +295 -30
  51. package/lib/password/Password.test.js +362 -0
  52. package/lib/password/createArgon2PasswordAlgorithm.js +191 -35
  53. package/lib/password/createBase64PasswordAlgorithm.js +141 -8
  54. package/lib/password/createBcryptPasswordAlgorithm.js +168 -13
  55. package/lib/password/createPBKDF2PasswordAlgorithm.js +228 -46
  56. package/lib/password/createScryptPasswordAlgorithm.js +211 -55
  57. package/lib/password/index.js +0 -1
  58. package/lib/password/server/index.js +0 -1
  59. package/lib/resource/Identifiable.js +1 -0
  60. package/lib/resource/ListQuery.js +119 -0
  61. package/lib/resource/getTitleOfResource.js +10 -0
  62. package/lib/resource/index.js +2 -0
  63. package/lib/resource/schema/AnyResourceSchema.js +89 -0
  64. package/lib/resource/schema/BaseResourceSchema.js +29 -0
  65. package/lib/resource/schema/ResourceActionType.js +118 -0
  66. package/lib/resource/schema/ResourceStatus.js +93 -0
  67. package/lib/resource/schema/ResourceType.js +24 -0
  68. package/lib/resource/schema/index.js +5 -0
  69. package/lib/resource/schema/types.js +89 -0
  70. package/lib/resource/schema/types.test.js +14 -0
  71. package/lib/schema/SchemaRegistry.js +45 -0
  72. package/lib/schema/SchemaRegistry.mod.js +2 -0
  73. package/lib/schema/TypeSchema.d.js +1 -0
  74. package/lib/schema/createSchemaData.js +173 -0
  75. package/lib/schema/findJsonSchemaByPath.js +49 -0
  76. package/lib/schema/getSchemaCache.js +11 -0
  77. package/lib/schema/getSchemaOptions.js +24 -0
  78. package/lib/schema/index.js +6 -0
  79. package/lib/schema/toJsonSchema.js +441 -0
  80. package/lib/schema/toJsonSchema.test.js +27 -0
  81. package/lib/schema/validate.js +124 -0
  82. package/lib/tools/generateSchema.js +197 -39
  83. package/lib/tools/renderJsonSchemaToMarkdownDoc.js +143 -55
  84. package/lib/utils/getEstimateProcessTime.js +20 -0
  85. package/lib/utils/index.js +1 -0
  86. package/package.json +38 -17
  87. package/src/cn/ChineseResidentIdNo.mod.ts +7 -0
  88. package/src/cn/ChineseResidentIdNo.test.ts +18 -0
  89. package/src/cn/ChineseResidentIdNo.ts +66 -0
  90. package/src/cn/DivisionCode.mod.ts +7 -0
  91. package/src/cn/DivisionCode.test.ts +3 -13
  92. package/src/cn/DivisionCode.ts +132 -195
  93. package/src/cn/{Mod11Checksum.ts → Mod11.ts} +3 -1
  94. package/src/cn/{Mod31Checksum.ts → Mod31.ts} +2 -0
  95. package/src/cn/UnifiedSocialCreditCode.mod.ts +7 -0
  96. package/src/cn/UnifiedSocialCreditCode.test.ts +2 -2
  97. package/src/cn/UnifiedSocialCreditCode.ts +105 -125
  98. package/src/cn/__snapshots__/ChineseResidentIdNo.test.ts.snap +14 -0
  99. package/src/cn/__snapshots__/UnifiedSocialCreditCode.test.ts.snap +18 -12
  100. package/src/cn/index.ts +1 -3
  101. package/src/cn/mod.ts +3 -0
  102. package/src/consola/formatLogObject.ts +12 -4
  103. package/src/data/maybeNumber.ts +5 -1
  104. package/src/data/resolvePagination.test.ts +1 -1
  105. package/src/data/resolvePagination.ts +18 -7
  106. package/src/data/types.d.ts +12 -0
  107. package/src/dayjs/dayjs.ts +40 -0
  108. package/src/dayjs/formatDuration.test.ts +14 -0
  109. package/src/dayjs/formatDuration.ts +86 -0
  110. package/src/dayjs/index.ts +3 -0
  111. package/src/dayjs/parseDuration.ts +40 -0
  112. package/src/decimal/index.ts +1 -0
  113. package/src/decimal/parseDecimal.ts +16 -0
  114. package/src/foundation/schema/SexType.ts +21 -0
  115. package/src/foundation/schema/index.ts +1 -0
  116. package/src/foundation/schema/parseSexType.ts +19 -0
  117. package/src/foundation/schema/types.ts +8 -0
  118. package/src/jsonschema/JsonSchema.test.ts +17 -0
  119. package/src/jsonschema/JsonSchema.ts +2 -2
  120. package/src/jsonschema/types.d.ts +63 -12
  121. package/src/password/Password.ts +2 -2
  122. package/src/resource/Identifiable.ts +3 -0
  123. package/src/resource/ListQuery.ts +53 -0
  124. package/src/resource/getTitleOfResource.tsx +6 -0
  125. package/src/resource/index.ts +4 -0
  126. package/src/resource/schema/AnyResourceSchema.ts +113 -0
  127. package/src/resource/schema/BaseResourceSchema.ts +32 -0
  128. package/src/resource/schema/ResourceActionType.ts +123 -0
  129. package/src/resource/schema/ResourceStatus.ts +94 -0
  130. package/src/resource/schema/ResourceType.ts +25 -0
  131. package/src/resource/schema/index.ts +5 -0
  132. package/src/resource/schema/types.test.ts +18 -0
  133. package/src/resource/schema/types.ts +105 -0
  134. package/src/schema/SchemaRegistry.mod.ts +1 -0
  135. package/src/schema/SchemaRegistry.ts +46 -0
  136. package/src/schema/TypeSchema.d.ts +32 -0
  137. package/src/schema/createSchemaData.ts +81 -0
  138. package/src/schema/findJsonSchemaByPath.ts +37 -0
  139. package/src/schema/getSchemaCache.ts +21 -0
  140. package/src/schema/getSchemaOptions.ts +24 -0
  141. package/src/schema/index.ts +7 -0
  142. package/src/schema/toJsonSchema.test.ts +37 -0
  143. package/src/schema/toJsonSchema.ts +200 -0
  144. package/src/schema/validate.ts +135 -0
  145. package/src/tools/generateSchema.ts +28 -28
  146. package/src/utils/getEstimateProcessTime.ts +36 -0
  147. package/src/utils/index.ts +1 -0
  148. package/lib/cn/DivisionCode.js.map +0 -1
  149. package/lib/cn/Mod11Checksum.js +0 -42
  150. package/lib/cn/Mod11Checksum.js.map +0 -1
  151. package/lib/cn/Mod31Checksum.js +0 -48
  152. package/lib/cn/Mod31Checksum.js.map +0 -1
  153. package/lib/cn/ResidentIdentityCardNumber.js +0 -50
  154. package/lib/cn/ResidentIdentityCardNumber.js.map +0 -1
  155. package/lib/cn/UnifiedSocialCreditCode.js.map +0 -1
  156. package/lib/cn/formatDate.js +0 -15
  157. package/lib/cn/formatDate.js.map +0 -1
  158. package/lib/cn/index.js.map +0 -1
  159. package/lib/cn/parseSex.js +0 -22
  160. package/lib/cn/parseSex.js.map +0 -1
  161. package/lib/cn/types.d.js.map +0 -1
  162. package/lib/consola/createStandardConsolaReporter.js.map +0 -1
  163. package/lib/consola/formatLogObject.js.map +0 -1
  164. package/lib/consola/index.js.map +0 -1
  165. package/lib/data/formatSort.js.map +0 -1
  166. package/lib/data/index.js.map +0 -1
  167. package/lib/data/maybeNumber.js.map +0 -1
  168. package/lib/data/parseSort.js.map +0 -1
  169. package/lib/data/resolvePagination.js.map +0 -1
  170. package/lib/data/types.d.js.map +0 -1
  171. package/lib/index.js.map +0 -1
  172. package/lib/jsonschema/JsonSchema.js.map +0 -1
  173. package/lib/jsonschema/index.js.map +0 -1
  174. package/lib/jsonschema/types.d.js.map +0 -1
  175. package/lib/meta/defineFileType.js.map +0 -1
  176. package/lib/meta/defineInit.js.map +0 -1
  177. package/lib/meta/defineMetadata.js.map +0 -1
  178. package/lib/meta/index.js.map +0 -1
  179. package/lib/password/PHC.js.map +0 -1
  180. package/lib/password/Password.js.map +0 -1
  181. package/lib/password/createArgon2PasswordAlgorithm.js.map +0 -1
  182. package/lib/password/createBase64PasswordAlgorithm.js.map +0 -1
  183. package/lib/password/createBcryptPasswordAlgorithm.js.map +0 -1
  184. package/lib/password/createPBKDF2PasswordAlgorithm.js.map +0 -1
  185. package/lib/password/createScryptPasswordAlgorithm.js.map +0 -1
  186. package/lib/password/index.js.map +0 -1
  187. package/lib/password/server/index.js.map +0 -1
  188. package/lib/search/AdvanceSearch.js +0 -10
  189. package/lib/search/AdvanceSearch.js.map +0 -1
  190. package/lib/search/formatAdvanceSearch.js +0 -64
  191. package/lib/search/formatAdvanceSearch.js.map +0 -1
  192. package/lib/search/index.js +0 -2
  193. package/lib/search/index.js.map +0 -1
  194. package/lib/search/optimizeAdvanceSearch.js +0 -89
  195. package/lib/search/optimizeAdvanceSearch.js.map +0 -1
  196. package/lib/search/parseAdvanceSearch.js +0 -20
  197. package/lib/search/parseAdvanceSearch.js.map +0 -1
  198. package/lib/search/parser.d.js +0 -3
  199. package/lib/search/parser.d.js.map +0 -1
  200. package/lib/search/parser.js +0 -3065
  201. package/lib/search/parser.js.map +0 -1
  202. package/lib/search/types.d.js +0 -3
  203. package/lib/search/types.d.js.map +0 -1
  204. package/lib/tools/generateSchema.js.map +0 -1
  205. package/lib/tools/renderJsonSchemaToMarkdownDoc.js.map +0 -1
  206. package/src/cn/ResidentIdentityCardNumber.test.ts +0 -17
  207. package/src/cn/ResidentIdentityCardNumber.ts +0 -96
  208. package/src/cn/__snapshots__/ResidentIdentityCardNumber.test.ts.snap +0 -15
  209. package/src/cn/formatDate.ts +0 -12
  210. package/src/cn/parseSex.ts +0 -13
  211. package/src/search/AdvanceSearch.test.ts +0 -149
  212. package/src/search/AdvanceSearch.ts +0 -14
  213. package/src/search/Makefile +0 -2
  214. package/src/search/__snapshots__/AdvanceSearch.test.ts.snap +0 -675
  215. package/src/search/formatAdvanceSearch.ts +0 -52
  216. package/src/search/index.ts +0 -1
  217. package/src/search/optimizeAdvanceSearch.ts +0 -77
  218. package/src/search/parseAdvanceSearch.ts +0 -23
  219. package/src/search/parser.d.ts +0 -8
  220. package/src/search/parser.js +0 -2794
  221. package/src/search/parser.peggy +0 -237
  222. package/src/search/types.d.ts +0 -45
@@ -1,8 +1,200 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ }
6
+ catch (error) {
7
+ reject(error);
8
+ return;
9
+ }
10
+ if (info.done) {
11
+ resolve(value);
12
+ }
13
+ else {
14
+ Promise.resolve(value).then(_next, _throw);
15
+ }
16
+ }
17
+ function _async_to_generator(fn) {
18
+ return function () {
19
+ var self = this, args = arguments;
20
+ return new Promise(function (resolve, reject) {
21
+ var gen = fn.apply(self, args);
22
+ function _next(value) {
23
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
24
+ }
25
+ function _throw(err) {
26
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
27
+ }
28
+ _next(undefined);
29
+ });
30
+ };
31
+ }
32
+ function _define_property(obj, key, value) {
33
+ if (key in obj) {
34
+ Object.defineProperty(obj, key, {
35
+ value: value,
36
+ enumerable: true,
37
+ configurable: true,
38
+ writable: true
39
+ });
40
+ }
41
+ else {
42
+ obj[key] = value;
43
+ }
44
+ return obj;
45
+ }
46
+ function _object_spread(target) {
47
+ for (var i = 1; i < arguments.length; i++) {
48
+ var source = arguments[i] != null ? arguments[i] : {};
49
+ var ownKeys = Object.keys(source);
50
+ if (typeof Object.getOwnPropertySymbols === "function") {
51
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
52
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
53
+ }));
54
+ }
55
+ ownKeys.forEach(function (key) {
56
+ _define_property(target, key, source[key]);
57
+ });
58
+ }
59
+ return target;
60
+ }
61
+ function _object_without_properties(source, excluded) {
62
+ if (source == null)
63
+ return {};
64
+ var target = _object_without_properties_loose(source, excluded);
65
+ var key, i;
66
+ if (Object.getOwnPropertySymbols) {
67
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
68
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
69
+ key = sourceSymbolKeys[i];
70
+ if (excluded.indexOf(key) >= 0)
71
+ continue;
72
+ if (!Object.prototype.propertyIsEnumerable.call(source, key))
73
+ continue;
74
+ target[key] = source[key];
75
+ }
76
+ }
77
+ return target;
78
+ }
79
+ function _object_without_properties_loose(source, excluded) {
80
+ if (source == null)
81
+ return {};
82
+ var target = {};
83
+ var sourceKeys = Object.keys(source);
84
+ var key, i;
85
+ for (i = 0; i < sourceKeys.length; i++) {
86
+ key = sourceKeys[i];
87
+ if (excluded.indexOf(key) >= 0)
88
+ continue;
89
+ target[key] = source[key];
90
+ }
91
+ return target;
92
+ }
93
+ function _ts_generator(thisArg, body) {
94
+ var f, y, t, _ = {
95
+ label: 0,
96
+ sent: function () {
97
+ if (t[0] & 1)
98
+ throw t[1];
99
+ return t[1];
100
+ },
101
+ trys: [],
102
+ ops: []
103
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
104
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function () {
105
+ return this;
106
+ }), g;
107
+ function verb(n) {
108
+ return function (v) {
109
+ return step([
110
+ n,
111
+ v
112
+ ]);
113
+ };
114
+ }
115
+ function step(op) {
116
+ if (f)
117
+ throw new TypeError("Generator is already executing.");
118
+ while (g && (g = 0, op[0] && (_ = 0)), _)
119
+ try {
120
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
121
+ return t;
122
+ if (y = 0, t)
123
+ op = [
124
+ op[0] & 2,
125
+ t.value
126
+ ];
127
+ switch (op[0]) {
128
+ case 0:
129
+ case 1:
130
+ t = op;
131
+ break;
132
+ case 4:
133
+ _.label++;
134
+ return {
135
+ value: op[1],
136
+ done: false
137
+ };
138
+ case 5:
139
+ _.label++;
140
+ y = op[1];
141
+ op = [
142
+ 0
143
+ ];
144
+ continue;
145
+ case 7:
146
+ op = _.ops.pop();
147
+ _.trys.pop();
148
+ continue;
149
+ default:
150
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
151
+ _ = 0;
152
+ continue;
153
+ }
154
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
155
+ _.label = op[1];
156
+ break;
157
+ }
158
+ if (op[0] === 6 && _.label < t[1]) {
159
+ _.label = t[1];
160
+ t = op;
161
+ break;
162
+ }
163
+ if (t && _.label < t[2]) {
164
+ _.label = t[2];
165
+ _.ops.push(op);
166
+ break;
167
+ }
168
+ if (t[2])
169
+ _.ops.pop();
170
+ _.trys.pop();
171
+ continue;
172
+ }
173
+ op = body.call(thisArg, _);
174
+ }
175
+ catch (e) {
176
+ op = [
177
+ 6,
178
+ e
179
+ ];
180
+ y = 0;
181
+ }
182
+ finally {
183
+ f = t = 0;
184
+ }
185
+ if (op[0] & 5)
186
+ throw op[1];
187
+ return {
188
+ value: op[0] ? op[1] : void 0,
189
+ done: true
190
+ };
191
+ }
192
+ }
1
193
  import { Errors } from "@wener/utils";
2
194
  import { createPBKDF2PasswordAlgorithm } from "./createPBKDF2PasswordAlgorithm.js";
3
195
  import { PHC } from "./PHC.js";
4
196
  (function (Password) {
5
- const Algorithms = {
197
+ var Algorithms = {
6
198
  1: "md5",
7
199
  "2a": "bcrypt",
8
200
  "2b": "bcrypt",
@@ -12,9 +204,9 @@ import { PHC } from "./PHC.js";
12
204
  6: "sha512",
13
205
  7: "scrypt"
14
206
  };
15
- let DefaultAlgorithm = "6";
207
+ var DefaultAlgorithm = "6";
16
208
  function setDefaultAlgorithm(algorithm) {
17
- Errors.BadRequest.check(Algorithms[algorithm], `Unknown algorithm ${algorithm}`);
209
+ Errors.BadRequest.check(Algorithms[algorithm], "Unknown algorithm ".concat(algorithm));
18
210
  DefaultAlgorithm = algorithm;
19
211
  }
20
212
  Password.setDefaultAlgorithm = setDefaultAlgorithm;
@@ -25,8 +217,28 @@ import { PHC } from "./PHC.js";
25
217
  function addAlgorithm(algorithm) {
26
218
  Algorithms[algorithm.name] = algorithm;
27
219
  if (algorithm.ids) {
28
- for (const id of algorithm.ids) {
29
- Algorithms[id] = algorithm;
220
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
221
+ try {
222
+ for (var _iterator = algorithm.ids[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
223
+ var id = _step.value;
224
+ Algorithms[id] = algorithm;
225
+ }
226
+ }
227
+ catch (err) {
228
+ _didIteratorError = true;
229
+ _iteratorError = err;
230
+ }
231
+ finally {
232
+ try {
233
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
234
+ _iterator.return();
235
+ }
236
+ }
237
+ finally {
238
+ if (_didIteratorError) {
239
+ throw _iteratorError;
240
+ }
241
+ }
30
242
  }
31
243
  }
32
244
  }
@@ -39,45 +251,98 @@ import { PHC } from "./PHC.js";
39
251
  id: "sha512",
40
252
  digest: "SHA-512"
41
253
  }));
42
- async function parse(hash) {
43
- return PHC.deserialize(hash);
254
+ function parse(hash) {
255
+ return _async_to_generator(function () {
256
+ return _ts_generator(this, function (_state) {
257
+ return [
258
+ 2,
259
+ PHC.deserialize(hash)
260
+ ];
261
+ });
262
+ })();
44
263
  }
45
264
  Password.parse = parse;
46
265
  function resolveAlgorithm(id) {
47
- let f = id;
266
+ var f = id;
48
267
  while (typeof f === "string") {
49
268
  f = Algorithms[f];
50
269
  }
51
270
  if (!f) {
52
- throw new Error(`Unknown algorithm ${id}`);
271
+ throw new Error("Unknown algorithm ".concat(id));
53
272
  }
54
273
  return f;
55
274
  }
56
- async function check(password, hash) {
57
- let res = await parse(hash);
58
- let f = resolveAlgorithm(res.id);
59
- return {
60
- result: f.verify(password, hash, res),
61
- parsed: res
62
- };
275
+ function validate(password, hash) {
276
+ return _async_to_generator(function () {
277
+ var res, f, _tmp;
278
+ return _ts_generator(this, function (_state) {
279
+ switch (_state.label) {
280
+ case 0:
281
+ return [
282
+ 4,
283
+ parse(hash)
284
+ ];
285
+ case 1:
286
+ res = _state.sent();
287
+ f = resolveAlgorithm(res.id);
288
+ _tmp = {};
289
+ return [
290
+ 4,
291
+ f.verify(password, hash, res)
292
+ ];
293
+ case 2:
294
+ return [
295
+ 2,
296
+ (_tmp.result = _state.sent(), _tmp.parsed = res, _tmp)
297
+ ];
298
+ }
299
+ });
300
+ })();
63
301
  }
64
- Password.check = check;
65
- async function verify(password, hash) {
66
- let res = await parse(hash);
67
- let f = resolveAlgorithm(res.id);
68
- return f.verify(password, hash, res);
302
+ Password.validate = validate;
303
+ function verify(password, hash) {
304
+ return _async_to_generator(function () {
305
+ var res, f;
306
+ return _ts_generator(this, function (_state) {
307
+ switch (_state.label) {
308
+ case 0:
309
+ return [
310
+ 4,
311
+ parse(hash)
312
+ ];
313
+ case 1:
314
+ res = _state.sent();
315
+ f = resolveAlgorithm(res.id);
316
+ return [
317
+ 2,
318
+ f.verify(password, hash, res)
319
+ ];
320
+ }
321
+ });
322
+ })();
69
323
  }
70
324
  Password.verify = verify;
71
- async function hash(password, { algorithm, ...opts } = {}) {
72
- let f = resolveAlgorithm(algorithm ?? DefaultAlgorithm);
73
- let id = algorithm ?? DefaultAlgorithm;
74
- typeof id !== "string" && (id = f.name);
75
- return f.hash(password, {
76
- id,
77
- ...opts
78
- });
325
+ function hash(_0) {
326
+ return _async_to_generator(function (password) {
327
+ var _param, algorithm, opts, f, id;
328
+ var _arguments = arguments;
329
+ return _ts_generator(this, function (_state) {
330
+ _param = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
331
+ algorithm = _param.algorithm, opts = _object_without_properties(_param, [
332
+ "algorithm"
333
+ ]);
334
+ f = resolveAlgorithm(algorithm !== null && algorithm !== void 0 ? algorithm : DefaultAlgorithm);
335
+ id = algorithm !== null && algorithm !== void 0 ? algorithm : DefaultAlgorithm;
336
+ typeof id !== "string" && (id = f.name);
337
+ return [
338
+ 2,
339
+ f.hash(password, _object_spread({
340
+ id: id
341
+ }, opts))
342
+ ];
343
+ });
344
+ }).apply(this, arguments);
79
345
  }
80
346
  Password.hash = hash;
81
347
  })(Password || (Password = {}));
82
348
  export var Password;
83
- //# sourceMappingURL=Password.js.map