@wener/common 2.0.3 → 2.0.6

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 (312) hide show
  1. package/lib/ai/qwen3vl/index.js +1 -1
  2. package/lib/ai/qwen3vl/utils.js +15 -15
  3. package/lib/ai/qwen3vl/utils.js.map +1 -1
  4. package/lib/ai/vision/DocLayoutElementTypeSchema.js +22 -22
  5. package/lib/ai/vision/ImageAnnotationSchema.js +63 -47
  6. package/lib/ai/vision/index.js +2 -2
  7. package/lib/ai/vision/resolveImageAnnotation.js +81 -95
  8. package/lib/cn/ChineseResidentIdNo.js +55 -41
  9. package/lib/cn/ChineseResidentIdNo.js.map +1 -1
  10. package/lib/cn/ChineseResidentIdNo.mod.js +6 -1
  11. package/lib/cn/ChineseResidentIdNo.test.js +22 -21
  12. package/lib/cn/DivisionCode.js +220 -235
  13. package/lib/cn/DivisionCode.mod.js +6 -1
  14. package/lib/cn/DivisionCode.test.js +92 -121
  15. package/lib/cn/Mod11.js +18 -37
  16. package/lib/cn/Mod11.js.map +1 -1
  17. package/lib/cn/Mod31.js +23 -41
  18. package/lib/cn/UnifiedSocialCreditCode.js +143 -137
  19. package/lib/cn/UnifiedSocialCreditCode.mod.js +6 -1
  20. package/lib/cn/UnifiedSocialCreditCode.test.js +21 -15
  21. package/lib/cn/formatChineseAmount.js +46 -71
  22. package/lib/cn/index.js +6 -6
  23. package/lib/cn/mod.js +5 -3
  24. package/lib/cn/parseChineseNumber.js +81 -85
  25. package/lib/cn/parseChineseNumber.test.js +183 -261
  26. package/lib/cn/pinyin/cartesianProduct.js +19 -19
  27. package/lib/cn/pinyin/cartesianProduct.test.js +78 -178
  28. package/lib/cn/pinyin/loader.js +13 -11
  29. package/lib/cn/pinyin/preload.js +2 -1
  30. package/lib/cn/pinyin/toPinyin.test.js +149 -161
  31. package/lib/cn/pinyin/toPinyinPure.js +28 -23
  32. package/lib/cn/pinyin/transform.js +11 -11
  33. package/lib/cn/types.d.js +2 -2
  34. package/lib/consola/createStandardConsolaReporter.js +14 -15
  35. package/lib/consola/formatLogObject.js +149 -133
  36. package/lib/consola/formatLogObject.js.map +1 -1
  37. package/lib/consola/formatLogObject.test.js +167 -178
  38. package/lib/consola/index.js +2 -2
  39. package/lib/data/formatSort.js +14 -12
  40. package/lib/data/formatSort.test.js +33 -33
  41. package/lib/data/index.js +3 -3
  42. package/lib/data/maybeNumber.js +23 -23
  43. package/lib/data/maybeNumber.js.map +1 -1
  44. package/lib/data/parseSort.js +75 -68
  45. package/lib/data/parseSort.test.js +196 -187
  46. package/lib/data/resolvePagination.js +38 -39
  47. package/lib/data/resolvePagination.test.js +228 -218
  48. package/lib/data/types.d.js +2 -2
  49. package/lib/data/types.d.js.map +1 -1
  50. package/lib/dayjs/dayjs.js +20 -20
  51. package/lib/dayjs/formatDuration.js +56 -56
  52. package/lib/dayjs/formatDuration.js.map +1 -1
  53. package/lib/dayjs/formatDuration.test.js +63 -77
  54. package/lib/dayjs/index.js +4 -4
  55. package/lib/dayjs/parseDuration.js +21 -26
  56. package/lib/dayjs/parseRelativeTime.js +65 -66
  57. package/lib/dayjs/parseRelativeTime.test.js +227 -243
  58. package/lib/dayjs/resolveRelativeTime.js +74 -144
  59. package/lib/dayjs/resolveRelativeTime.js.map +1 -1
  60. package/lib/dayjs/resolveRelativeTime.test.js +296 -307
  61. package/lib/decimal/index.js +1 -1
  62. package/lib/decimal/parseDecimal.js +12 -12
  63. package/lib/drain3/Drain.js +321 -0
  64. package/lib/drain3/Drain.js.map +1 -0
  65. package/lib/drain3/LogCluster.js +38 -0
  66. package/lib/drain3/LogCluster.js.map +1 -0
  67. package/lib/drain3/Node.js +39 -0
  68. package/lib/drain3/Node.js.map +1 -0
  69. package/lib/drain3/TemplateMiner.js +205 -0
  70. package/lib/drain3/TemplateMiner.js.map +1 -0
  71. package/lib/drain3/index.js +31 -0
  72. package/lib/drain3/index.js.map +1 -0
  73. package/lib/drain3/persistence/FilePersistence.js +24 -0
  74. package/lib/drain3/persistence/FilePersistence.js.map +1 -0
  75. package/lib/drain3/persistence/MemoryPersistence.js +18 -0
  76. package/lib/drain3/persistence/MemoryPersistence.js.map +1 -0
  77. package/lib/drain3/persistence/PersistenceHandler.js +5 -0
  78. package/lib/drain3/persistence/PersistenceHandler.js.map +1 -0
  79. package/lib/drain3/types.js +7 -0
  80. package/lib/drain3/types.js.map +1 -0
  81. package/lib/emittery/emitter.js +7 -7
  82. package/lib/emittery/index.js +1 -1
  83. package/lib/foundation/schema/SexType.js +15 -12
  84. package/lib/foundation/schema/index.js +1 -1
  85. package/lib/foundation/schema/parseSexType.js +15 -16
  86. package/lib/foundation/schema/types.js +8 -6
  87. package/lib/fs/FileSystemError.js +18 -18
  88. package/lib/fs/IFileSystem.d.js +2 -2
  89. package/lib/fs/IFileSystem.d.js.map +1 -1
  90. package/lib/fs/MemoryFileSystem.test.js +172 -181
  91. package/lib/fs/createBrowserFileSystem.js +222 -233
  92. package/lib/fs/createBrowserFileSystem.js.map +1 -1
  93. package/lib/fs/createMemoryFileSystem.js +473 -510
  94. package/lib/fs/createMemoryFileSystem.js.map +1 -1
  95. package/lib/fs/createSandboxFileSystem.js +102 -101
  96. package/lib/fs/createSandboxFileSystem.js.map +1 -1
  97. package/lib/fs/createWebDavFileSystem.js +162 -132
  98. package/lib/fs/createWebDavFileSystem.js.map +1 -1
  99. package/lib/fs/createWebFileSystem.js +202 -0
  100. package/lib/fs/createWebFileSystem.js.map +1 -0
  101. package/lib/fs/findMimeType.js +14 -14
  102. package/lib/fs/findMimeType.js.map +1 -1
  103. package/lib/fs/index.js +7 -7
  104. package/lib/fs/index.js.map +1 -1
  105. package/lib/fs/minio/createMinioFileSystem.js +977 -0
  106. package/lib/fs/minio/createMinioFileSystem.js.map +1 -0
  107. package/lib/fs/minio/index.js +2 -0
  108. package/lib/fs/minio/index.js.map +1 -0
  109. package/lib/fs/orpc/FileSystemContract.js +57 -57
  110. package/lib/fs/orpc/createContractClientFileSystem.js +88 -88
  111. package/lib/fs/orpc/createContractClientFileSystem.js.map +1 -1
  112. package/lib/fs/orpc/index.js +2 -2
  113. package/lib/fs/orpc/server/createFileSystemContractImpl.js +62 -60
  114. package/lib/fs/orpc/server/createFileSystemContractImpl.js.map +1 -1
  115. package/lib/fs/orpc/server/index.js +1 -1
  116. package/lib/fs/s3/createS3MiniFileSystem.js +756 -689
  117. package/lib/fs/s3/createS3MiniFileSystem.js.map +1 -1
  118. package/lib/fs/s3/index.js +1 -1
  119. package/lib/fs/s3/s3mini.test.js +524 -553
  120. package/lib/fs/scandir.js +56 -56
  121. package/lib/fs/server/createDatabaseFileSystem.js +834 -741
  122. package/lib/fs/server/createDatabaseFileSystem.js.map +1 -1
  123. package/lib/fs/server/createNodeFileSystem.js +407 -380
  124. package/lib/fs/server/createNodeFileSystem.js.map +1 -1
  125. package/lib/fs/server/dbfs.test.js +201 -214
  126. package/lib/fs/server/index.js +1 -1
  127. package/lib/fs/server/loadTestDatabase.js +40 -43
  128. package/lib/fs/tests/runFileSystemTest.js +352 -315
  129. package/lib/fs/tests/runFileSystemTest.js.map +1 -1
  130. package/lib/fs/types.js +17 -20
  131. package/lib/fs/utils/getFileUrl.js +24 -30
  132. package/lib/fs/utils.js +17 -17
  133. package/lib/fs/utils.js.map +1 -1
  134. package/lib/fs/webdav/index.js +2 -0
  135. package/lib/fs/webdav/index.js.map +1 -0
  136. package/lib/index.js +2 -2
  137. package/lib/jsonschema/JsonSchema.js +216 -155
  138. package/lib/jsonschema/JsonSchema.js.map +1 -1
  139. package/lib/jsonschema/JsonSchema.test.js +123 -124
  140. package/lib/jsonschema/forEachJsonSchema.js +41 -41
  141. package/lib/jsonschema/forEachJsonSchema.js.map +1 -1
  142. package/lib/jsonschema/index.js +2 -2
  143. package/lib/jsonschema/types.d.js +2 -2
  144. package/lib/jsonschema/types.d.js.map +1 -1
  145. package/lib/meta/defineFileType.js +32 -38
  146. package/lib/meta/defineInit.js +39 -35
  147. package/lib/meta/defineMetadata.js +37 -34
  148. package/lib/meta/defineMetadata.js.map +1 -1
  149. package/lib/meta/defineMetadata.test.js +13 -12
  150. package/lib/meta/index.js +3 -3
  151. package/lib/orpc/createOpenApiContractClient.js +26 -24
  152. package/lib/orpc/createOpenApiContractClient.js.map +1 -1
  153. package/lib/orpc/createRpcContractClient.js +37 -31
  154. package/lib/orpc/index.js +2 -2
  155. package/lib/orpc/resolveLinkPlugins.js +25 -25
  156. package/lib/password/PHC.js +187 -189
  157. package/lib/password/PHC.js.map +1 -1
  158. package/lib/password/PHC.test.js +517 -535
  159. package/lib/password/Password.js +85 -80
  160. package/lib/password/Password.test.js +330 -364
  161. package/lib/password/createArgon2PasswordAlgorithm.js +50 -51
  162. package/lib/password/createArgon2PasswordAlgorithm.js.map +1 -1
  163. package/lib/password/createBase64PasswordAlgorithm.js +11 -11
  164. package/lib/password/createBase64PasswordAlgorithm.js.map +1 -1
  165. package/lib/password/createBcryptPasswordAlgorithm.js +20 -18
  166. package/lib/password/createBcryptPasswordAlgorithm.js.map +1 -1
  167. package/lib/password/createPBKDF2PasswordAlgorithm.js +65 -52
  168. package/lib/password/createPBKDF2PasswordAlgorithm.js.map +1 -1
  169. package/lib/password/createScryptPasswordAlgorithm.js +74 -63
  170. package/lib/password/createScryptPasswordAlgorithm.js.map +1 -1
  171. package/lib/password/index.js +5 -5
  172. package/lib/password/server/index.js +1 -1
  173. package/lib/resource/Identifiable.js +2 -2
  174. package/lib/resource/ListQuery.js +42 -42
  175. package/lib/resource/ListQuery.js.map +1 -1
  176. package/lib/resource/getTitleOfResource.js +5 -5
  177. package/lib/resource/index.js +2 -2
  178. package/lib/resource/index.js.map +1 -1
  179. package/lib/resource/schema/AnyResourceSchema.js +91 -89
  180. package/lib/resource/schema/BaseResourceSchema.js +26 -26
  181. package/lib/resource/schema/ResourceActionType.js +117 -115
  182. package/lib/resource/schema/ResourceStatus.js +94 -92
  183. package/lib/resource/schema/ResourceType.js +25 -23
  184. package/lib/resource/schema/index.js +5 -5
  185. package/lib/resource/schema/types.js +86 -55
  186. package/lib/resource/schema/types.test.js +16 -13
  187. package/lib/s3/formatS3Url.js +60 -60
  188. package/lib/s3/formatS3Url.js.map +1 -1
  189. package/lib/s3/formatS3Url.test.js +238 -261
  190. package/lib/s3/index.js +2 -2
  191. package/lib/s3/parseS3Url.js +61 -60
  192. package/lib/s3/parseS3Url.js.map +1 -1
  193. package/lib/s3/parseS3Url.test.js +270 -269
  194. package/lib/schema/SchemaRegistry.js +41 -42
  195. package/lib/schema/SchemaRegistry.js.map +1 -1
  196. package/lib/schema/SchemaRegistry.mod.js +1 -1
  197. package/lib/schema/TypeSchema.d.js +2 -2
  198. package/lib/schema/TypeSchema.d.js.map +1 -1
  199. package/lib/schema/createSchemaData.js +113 -67
  200. package/lib/schema/createSchemaData.js.map +1 -1
  201. package/lib/schema/findJsonSchemaByPath.js +28 -23
  202. package/lib/schema/findJsonSchemaByPath.js.map +1 -1
  203. package/lib/schema/formatZodError.js +113 -134
  204. package/lib/schema/formatZodError.js.map +1 -1
  205. package/lib/schema/formatZodError.test.js +192 -195
  206. package/lib/schema/getSchemaCache.js +7 -7
  207. package/lib/schema/getSchemaOptions.js +17 -16
  208. package/lib/schema/index.js +6 -6
  209. package/lib/schema/toJsonSchema.js +196 -190
  210. package/lib/schema/toJsonSchema.js.map +1 -1
  211. package/lib/schema/toJsonSchema.test.js +34 -26
  212. package/lib/schema/validate.js +106 -97
  213. package/lib/schema/validate.js.map +1 -1
  214. package/lib/tools/generateSchema.js +40 -40
  215. package/lib/tools/renderJsonSchemaToMarkdownDoc.js +74 -74
  216. package/lib/utils/buildBaseUrl.js +8 -8
  217. package/lib/utils/buildRedactorFormSchema.js +55 -54
  218. package/lib/utils/buildRedactorFormSchema.js.map +1 -1
  219. package/lib/utils/getEstimateProcessTime.js +24 -19
  220. package/lib/utils/index.js +3 -3
  221. package/lib/utils/resolveFeatureOptions.js +9 -9
  222. package/package.json +37 -18
  223. package/src/ai/qwen3vl/utils.ts +1 -1
  224. package/src/ai/vision/index.ts +2 -2
  225. package/src/cn/ChineseResidentIdNo.ts +1 -1
  226. package/src/cn/Mod11.ts +1 -1
  227. package/src/cn/__snapshots__/ChineseResidentIdNo.test.ts.snap +1 -1
  228. package/src/cn/__snapshots__/UnifiedSocialCreditCode.test.ts.snap +0 -23
  229. package/src/cn/index.ts +1 -2
  230. package/src/cn/parseChineseNumber.test.ts +4 -4
  231. package/src/consola/formatLogObject.ts +6 -6
  232. package/src/consola/index.ts +1 -1
  233. package/src/data/index.ts +3 -4
  234. package/src/data/maybeNumber.ts +1 -1
  235. package/src/data/parseSort.test.ts +0 -1
  236. package/src/data/resolvePagination.ts +2 -2
  237. package/src/data/types.d.ts +2 -2
  238. package/src/dayjs/formatDuration.ts +10 -11
  239. package/src/dayjs/index.ts +1 -1
  240. package/src/dayjs/parseRelativeTime.ts +1 -1
  241. package/src/dayjs/resolveRelativeTime.ts +11 -14
  242. package/src/drain3/Drain.test.ts +378 -0
  243. package/src/drain3/Drain.ts +394 -0
  244. package/src/drain3/LogCluster.ts +46 -0
  245. package/src/drain3/Node.ts +53 -0
  246. package/src/drain3/TemplateMiner.ts +246 -0
  247. package/src/drain3/index.ts +34 -0
  248. package/src/drain3/persistence/FilePersistence.ts +24 -0
  249. package/src/drain3/persistence/MemoryPersistence.ts +23 -0
  250. package/src/drain3/persistence/PersistenceHandler.ts +19 -0
  251. package/src/drain3/types.ts +75 -0
  252. package/src/fs/IFileSystem.d.ts +1 -2
  253. package/src/fs/createBrowserFileSystem.ts +7 -5
  254. package/src/fs/createMemoryFileSystem.ts +9 -13
  255. package/src/fs/createSandboxFileSystem.ts +1 -1
  256. package/src/fs/createWebDavFileSystem.ts +30 -17
  257. package/src/fs/createWebFileSystem.ts +242 -0
  258. package/src/fs/findMimeType.ts +1 -4
  259. package/src/fs/index.ts +5 -5
  260. package/src/fs/minio/createMinioFileSystem.ts +1148 -0
  261. package/src/fs/minio/index.ts +1 -0
  262. package/src/fs/orpc/createContractClientFileSystem.ts +5 -5
  263. package/src/fs/orpc/server/createFileSystemContractImpl.ts +1 -1
  264. package/src/fs/s3/createS3MiniFileSystem.ts +120 -79
  265. package/src/fs/s3/s3fs.test.ts +441 -0
  266. package/src/fs/s3/s3mini.test.ts +2 -2
  267. package/src/fs/server/createDatabaseFileSystem.ts +78 -114
  268. package/src/fs/server/createNodeFileSystem.ts +32 -13
  269. package/src/fs/server/dbfs.test.ts +13 -8
  270. package/src/fs/server/index.ts +1 -0
  271. package/src/fs/server/loadTestDatabase.ts +8 -119
  272. package/src/fs/tests/runFileSystemTest.ts +29 -28
  273. package/src/fs/utils.ts +1 -1
  274. package/src/fs/webdav/index.ts +1 -0
  275. package/src/jsonschema/JsonSchema.ts +5 -5
  276. package/src/jsonschema/forEachJsonSchema.ts +1 -1
  277. package/src/jsonschema/index.ts +1 -1
  278. package/src/jsonschema/types.d.ts +1 -1
  279. package/src/meta/defineMetadata.ts +1 -1
  280. package/src/meta/index.ts +2 -3
  281. package/src/orm/createSqliteDialect.ts +17 -0
  282. package/src/orm/index.ts +1 -0
  283. package/src/orpc/createOpenApiContractClient.ts +3 -3
  284. package/src/orpc/index.ts +1 -1
  285. package/src/password/PHC.ts +3 -3
  286. package/src/password/createArgon2PasswordAlgorithm.ts +2 -2
  287. package/src/password/createBase64PasswordAlgorithm.ts +2 -2
  288. package/src/password/createBcryptPasswordAlgorithm.ts +4 -2
  289. package/src/password/createPBKDF2PasswordAlgorithm.ts +2 -2
  290. package/src/password/createScryptPasswordAlgorithm.ts +4 -4
  291. package/src/password/index.ts +2 -2
  292. package/src/resource/ListQuery.ts +4 -1
  293. package/src/resource/index.ts +3 -3
  294. package/src/resource/schema/index.ts +4 -4
  295. package/src/s3/formatS3Url.test.ts +1 -1
  296. package/src/s3/formatS3Url.ts +2 -2
  297. package/src/s3/index.ts +1 -1
  298. package/src/s3/parseS3Url.ts +1 -1
  299. package/src/schema/SchemaRegistry.ts +2 -2
  300. package/src/schema/TypeSchema.d.ts +6 -6
  301. package/src/schema/createSchemaData.ts +5 -5
  302. package/src/schema/findJsonSchemaByPath.ts +5 -5
  303. package/src/schema/formatZodError.test.ts +2 -1
  304. package/src/schema/formatZodError.ts +50 -62
  305. package/src/schema/index.ts +5 -5
  306. package/src/schema/toJsonSchema.ts +6 -6
  307. package/src/schema/validate.ts +2 -2
  308. package/src/utils/buildRedactorFormSchema.ts +4 -4
  309. package/src/utils/formatNumber.ts +18 -0
  310. package/src/utils/formatPercent.ts +17 -0
  311. package/src/utils/index.ts +3 -3
  312. package/src/utils/resolveFeatureOptions.ts +1 -1
@@ -1,375 +1,341 @@
1
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
- }
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ } catch (error) {
6
+ reject(error);
7
+ return;
8
+ }
9
+ if (info.done) {
10
+ resolve(value);
11
+ } else {
12
+ Promise.resolve(value).then(_next, _throw);
13
+ }
16
14
  }
17
15
  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
- };
16
+ return function () {
17
+ var args = arguments;
18
+ return new Promise((resolve, reject) => {
19
+ var gen = fn.apply(this, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'next', value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'throw', err);
25
+ }
26
+ _next(undefined);
27
+ });
28
+ };
31
29
  }
32
30
  function _object_without_properties(source, excluded) {
33
- if (source == null)
34
- return {};
35
- var target = {}, sourceKeys, key, i;
36
- if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
37
- sourceKeys = Reflect.ownKeys(source);
38
- for (i = 0; i < sourceKeys.length; i++) {
39
- key = sourceKeys[i];
40
- if (excluded.indexOf(key) >= 0)
41
- continue;
42
- if (!Object.prototype.propertyIsEnumerable.call(source, key))
43
- continue;
44
- target[key] = source[key];
45
- }
46
- return target;
47
- }
48
- target = _object_without_properties_loose(source, excluded);
49
- if (Object.getOwnPropertySymbols) {
50
- sourceKeys = Object.getOwnPropertySymbols(source);
51
- for (i = 0; i < sourceKeys.length; i++) {
52
- key = sourceKeys[i];
53
- if (excluded.indexOf(key) >= 0)
54
- continue;
55
- if (!Object.prototype.propertyIsEnumerable.call(source, key))
56
- continue;
57
- target[key] = source[key];
58
- }
59
- }
60
- return target;
31
+ if (source == null) return {};
32
+ var target = {},
33
+ sourceKeys,
34
+ key,
35
+ i;
36
+ if (typeof Reflect !== 'undefined' && Reflect.ownKeys) {
37
+ sourceKeys = Reflect.ownKeys(source);
38
+ for (i = 0; i < sourceKeys.length; i++) {
39
+ key = sourceKeys[i];
40
+ if (excluded.indexOf(key) >= 0) continue;
41
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
42
+ target[key] = source[key];
43
+ }
44
+ return target;
45
+ }
46
+ target = _object_without_properties_loose(source, excluded);
47
+ if (Object.getOwnPropertySymbols) {
48
+ sourceKeys = Object.getOwnPropertySymbols(source);
49
+ for (i = 0; i < sourceKeys.length; i++) {
50
+ key = sourceKeys[i];
51
+ if (excluded.indexOf(key) >= 0) continue;
52
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
53
+ target[key] = source[key];
54
+ }
55
+ }
56
+ return target;
61
57
  }
62
58
  function _object_without_properties_loose(source, excluded) {
63
- if (source == null)
64
- return {};
65
- var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
66
- for (i = 0; i < sourceKeys.length; i++) {
67
- key = sourceKeys[i];
68
- if (excluded.indexOf(key) >= 0)
69
- continue;
70
- if (!Object.prototype.propertyIsEnumerable.call(source, key))
71
- continue;
72
- target[key] = source[key];
73
- }
74
- return target;
59
+ if (source == null) return {};
60
+ var target = {},
61
+ sourceKeys = Object.getOwnPropertyNames(source),
62
+ key,
63
+ i;
64
+ for (i = 0; i < sourceKeys.length; i++) {
65
+ key = sourceKeys[i];
66
+ if (excluded.indexOf(key) >= 0) continue;
67
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
68
+ target[key] = source[key];
69
+ }
70
+ return target;
75
71
  }
76
72
  function _ts_generator(thisArg, body) {
77
- var f, y, t, _ = {
78
- label: 0,
79
- sent: function () {
80
- if (t[0] & 1)
81
- throw t[1];
82
- return t[1];
83
- },
84
- trys: [],
85
- ops: []
86
- }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
87
- return d(g, "next", {
88
- value: verb(0)
89
- }), d(g, "throw", {
90
- value: verb(1)
91
- }), d(g, "return", {
92
- value: verb(2)
93
- }), typeof Symbol === "function" && d(g, Symbol.iterator, {
94
- value: function () {
95
- return this;
96
- }
97
- }), g;
98
- function verb(n) {
99
- return function (v) {
100
- return step([
101
- n,
102
- v
103
- ]);
104
- };
105
- }
106
- function step(op) {
107
- if (f)
108
- throw new TypeError("Generator is already executing.");
109
- while (g && (g = 0, op[0] && (_ = 0)), _)
110
- try {
111
- 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)
112
- return t;
113
- if (y = 0, t)
114
- op = [
115
- op[0] & 2,
116
- t.value
117
- ];
118
- switch (op[0]) {
119
- case 0:
120
- case 1:
121
- t = op;
122
- break;
123
- case 4:
124
- _.label++;
125
- return {
126
- value: op[1],
127
- done: false
128
- };
129
- case 5:
130
- _.label++;
131
- y = op[1];
132
- op = [
133
- 0
134
- ];
135
- continue;
136
- case 7:
137
- op = _.ops.pop();
138
- _.trys.pop();
139
- continue;
140
- default:
141
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
142
- _ = 0;
143
- continue;
144
- }
145
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
146
- _.label = op[1];
147
- break;
148
- }
149
- if (op[0] === 6 && _.label < t[1]) {
150
- _.label = t[1];
151
- t = op;
152
- break;
153
- }
154
- if (t && _.label < t[2]) {
155
- _.label = t[2];
156
- _.ops.push(op);
157
- break;
158
- }
159
- if (t[2])
160
- _.ops.pop();
161
- _.trys.pop();
162
- continue;
163
- }
164
- op = body.call(thisArg, _);
165
- }
166
- catch (e) {
167
- op = [
168
- 6,
169
- e
170
- ];
171
- y = 0;
172
- }
173
- finally {
174
- f = t = 0;
175
- }
176
- if (op[0] & 5)
177
- throw op[1];
178
- return {
179
- value: op[0] ? op[1] : void 0,
180
- done: true
181
- };
182
- }
73
+ var f,
74
+ y,
75
+ t,
76
+ _ = {
77
+ label: 0,
78
+ sent: () => {
79
+ if (t[0] & 1) throw t[1];
80
+ return t[1];
81
+ },
82
+ trys: [],
83
+ ops: [],
84
+ },
85
+ g = Object.create((typeof Iterator === 'function' ? Iterator : Object).prototype),
86
+ d = Object.defineProperty;
87
+ return (
88
+ d(g, 'next', {
89
+ value: verb(0),
90
+ }),
91
+ d(g, 'throw', {
92
+ value: verb(1),
93
+ }),
94
+ d(g, 'return', {
95
+ value: verb(2),
96
+ }),
97
+ typeof Symbol === 'function' &&
98
+ d(g, Symbol.iterator, {
99
+ value: function () {
100
+ return this;
101
+ },
102
+ }),
103
+ g
104
+ );
105
+ function verb(n) {
106
+ return (v) => step([n, v]);
107
+ }
108
+ function step(op) {
109
+ if (f) throw new TypeError('Generator is already executing.');
110
+ while ((g && ((g = 0), op[0] && (_ = 0)), _))
111
+ try {
112
+ if (
113
+ ((f = 1),
114
+ y &&
115
+ (t = op[0] & 2 ? y['return'] : op[0] ? y['throw'] || ((t = y['return']) && t.call(y), 0) : y.next) &&
116
+ !(t = t.call(y, op[1])).done)
117
+ )
118
+ return t;
119
+ if (((y = 0), t)) op = [op[0] & 2, t.value];
120
+ switch (op[0]) {
121
+ case 0:
122
+ case 1:
123
+ t = op;
124
+ break;
125
+ case 4:
126
+ _.label++;
127
+ return {
128
+ value: op[1],
129
+ done: false,
130
+ };
131
+ case 5:
132
+ _.label++;
133
+ y = op[1];
134
+ op = [0];
135
+ continue;
136
+ case 7:
137
+ op = _.ops.pop();
138
+ _.trys.pop();
139
+ continue;
140
+ default:
141
+ if (!((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && (op[0] === 6 || op[0] === 2)) {
142
+ _ = 0;
143
+ continue;
144
+ }
145
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
146
+ _.label = op[1];
147
+ break;
148
+ }
149
+ if (op[0] === 6 && _.label < t[1]) {
150
+ _.label = t[1];
151
+ t = op;
152
+ break;
153
+ }
154
+ if (t && _.label < t[2]) {
155
+ _.label = t[2];
156
+ _.ops.push(op);
157
+ break;
158
+ }
159
+ if (t[2]) _.ops.pop();
160
+ _.trys.pop();
161
+ continue;
162
+ }
163
+ op = body.call(thisArg, _);
164
+ } catch (e) {
165
+ op = [6, e];
166
+ y = 0;
167
+ } finally {
168
+ f = t = 0;
169
+ }
170
+ if (op[0] & 5) throw op[1];
171
+ return {
172
+ value: op[0] ? op[1] : void 0,
173
+ done: true,
174
+ };
175
+ }
183
176
  }
184
- import { describe, expect, test } from "vitest";
185
- import { createArgon2PasswordAlgorithm } from "./createArgon2PasswordAlgorithm.js";
186
- import { createBase64PasswordAlgorithm } from "./createBase64PasswordAlgorithm.js";
187
- import { createBcryptPasswordAlgorithm } from "./createBcryptPasswordAlgorithm.js";
188
- import { Password } from "./Password.js";
189
- describe("Password", function () {
190
- var check = function (_0) {
191
- return _async_to_generator(function () {
192
- var _0_password, password, rest, out, result;
193
- return _ts_generator(this, function (_state) {
194
- switch (_state.label) {
195
- case 0:
196
- _0_password = _0.password, password = _0_password === void 0 ? "1" : _0_password, rest = _object_without_properties(_0, [
197
- "password"
198
- ]);
199
- return [
200
- 4,
201
- Password.hash(password, rest)
202
- ];
203
- case 1:
204
- out = _state.sent();
205
- console.log("".concat(rest.algorithm || "default", ": hash ").concat(out));
206
- return [
207
- 4,
208
- Password.verify(password, out)
209
- ];
210
- case 2:
211
- result = _state.sent();
212
- expect(result).toBe(true);
213
- return [
214
- 2
215
- ];
216
- }
217
- });
218
- })();
219
- };
220
- Password.addAlgorithm(createBcryptPasswordAlgorithm());
221
- Password.addAlgorithm(createBase64PasswordAlgorithm());
222
- Password.addAlgorithm(createArgon2PasswordAlgorithm({
223
- provide: import("argon2")
224
- }));
225
- // Password.addAlgorithm(createScryptPasswordAlgorithm());
226
- test("base", function () {
227
- return _async_to_generator(function () {
228
- return _ts_generator(this, function (_state) {
229
- switch (_state.label) {
230
- case 0:
231
- return [
232
- 4,
233
- check({})
234
- ];
235
- case 1:
236
- _state.sent();
237
- return [
238
- 4,
239
- check({
240
- algorithm: "bcrypt"
241
- })
242
- ];
243
- case 2:
244
- _state.sent();
245
- return [
246
- 4,
247
- check({
248
- algorithm: "base64"
249
- })
250
- ];
251
- case 3:
252
- _state.sent();
253
- // invalid base 64
254
- return [
255
- 4,
256
- check({
257
- algorithm: "base64",
258
- password: "\u4F60\u597D"
259
- })
260
- ];
261
- case 4:
262
- _state.sent();
263
- return [
264
- 4,
265
- check({
266
- algorithm: "5"
267
- })
268
- ];
269
- case 5:
270
- _state.sent();
271
- return [
272
- 4,
273
- check({
274
- algorithm: "6"
275
- })
276
- ];
277
- case 6:
278
- _state.sent();
279
- return [
280
- 2
281
- ];
282
- }
283
- });
284
- // await check({ algorithm: '7' });
285
- })();
286
- });
287
- test("should verify manual created hash", function () {
288
- return _async_to_generator(function () {
289
- var tests, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, _step_value_password, password, hash, err;
290
- return _ts_generator(this, function (_state) {
291
- switch (_state.label) {
292
- case 0:
293
- tests = [
294
- {
295
- hash: "$2y$10$MQ057tMbDG6/lVkGFWrNwOR9kh/5rzbkhBPrwNPTPuZ5wBpGNbWLa"
296
- },
297
- {
298
- hash: "$argon2i$v=19$m=16,t=2,p=1$SDZBU29LRUp0eTJyRDJqZg$76L95nAjG4SjjdoR0YZyFw"
299
- },
300
- {
301
- hash: "$argon2d$v=19$m=16,t=2,p=1$SDZBU29LRUp0eTJyRDJqZg$+cB2R45sauVlfxbGslAmOw"
302
- },
303
- {
304
- hash: "$argon2id$v=19$m=16,t=2,p=1$SDZBU29LRUp0eTJyRDJqZg$iP9HYuSDXgG2lW7KARBuQQ"
305
- }
306
- ];
307
- _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
308
- _state.label = 1;
309
- case 1:
310
- _state.trys.push([
311
- 1,
312
- 6,
313
- 7,
314
- 8
315
- ]);
316
- _iterator = tests[Symbol.iterator]();
317
- _state.label = 2;
318
- case 2:
319
- if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done))
320
- return [
321
- 3,
322
- 5
323
- ];
324
- _step_value = _step.value, _step_value_password = _step_value.password, password = _step_value_password === void 0 ? "1" : _step_value_password, hash = _step_value.hash;
325
- return [
326
- 4,
327
- Password.verify(password, hash)
328
- ];
329
- case 3:
330
- expect.apply(void 0, [
331
- _state.sent()
332
- ]).toBe(true);
333
- _state.label = 4;
334
- case 4:
335
- _iteratorNormalCompletion = true;
336
- return [
337
- 3,
338
- 2
339
- ];
340
- case 5:
341
- return [
342
- 3,
343
- 8
344
- ];
345
- case 6:
346
- err = _state.sent();
347
- _didIteratorError = true;
348
- _iteratorError = err;
349
- return [
350
- 3,
351
- 8
352
- ];
353
- case 7:
354
- try {
355
- if (!_iteratorNormalCompletion && _iterator.return != null) {
356
- _iterator.return();
357
- }
358
- }
359
- finally {
360
- if (_didIteratorError) {
361
- throw _iteratorError;
362
- }
363
- }
364
- return [
365
- 7
366
- ];
367
- case 8:
368
- return [
369
- 2
370
- ];
371
- }
372
- });
373
- })();
374
- });
177
+
178
+ import { describe, expect, test } from 'vitest';
179
+ import { createArgon2PasswordAlgorithm } from './createArgon2PasswordAlgorithm.js';
180
+ import { createBase64PasswordAlgorithm } from './createBase64PasswordAlgorithm.js';
181
+ import { createBcryptPasswordAlgorithm } from './createBcryptPasswordAlgorithm.js';
182
+ import { Password } from './Password.js';
183
+
184
+ describe('Password', () => {
185
+ var check = (_0) =>
186
+ _async_to_generator(function () {
187
+ var _0_password, password, rest, out, result;
188
+ return _ts_generator(this, (_state) => {
189
+ switch (_state.label) {
190
+ case 0:
191
+ (_0_password = _0.password),
192
+ (password = _0_password === void 0 ? '1' : _0_password),
193
+ (rest = _object_without_properties(_0, ['password']));
194
+ return [4, Password.hash(password, rest)];
195
+ case 1:
196
+ out = _state.sent();
197
+ console.log(''.concat(rest.algorithm || 'default', ': hash ').concat(out));
198
+ return [4, Password.verify(password, out)];
199
+ case 2:
200
+ result = _state.sent();
201
+ expect(result).toBe(true);
202
+ return [2];
203
+ }
204
+ });
205
+ })();
206
+ Password.addAlgorithm(createBcryptPasswordAlgorithm());
207
+ Password.addAlgorithm(createBase64PasswordAlgorithm());
208
+ Password.addAlgorithm(
209
+ createArgon2PasswordAlgorithm({
210
+ provide: import('argon2'),
211
+ }),
212
+ );
213
+ // Password.addAlgorithm(createScryptPasswordAlgorithm());
214
+ test('base', () =>
215
+ _async_to_generator(function () {
216
+ return _ts_generator(this, (_state) => {
217
+ switch (_state.label) {
218
+ case 0:
219
+ return [4, check({})];
220
+ case 1:
221
+ _state.sent();
222
+ return [
223
+ 4,
224
+ check({
225
+ algorithm: 'bcrypt',
226
+ }),
227
+ ];
228
+ case 2:
229
+ _state.sent();
230
+ return [
231
+ 4,
232
+ check({
233
+ algorithm: 'base64',
234
+ }),
235
+ ];
236
+ case 3:
237
+ _state.sent();
238
+ // invalid base 64
239
+ return [
240
+ 4,
241
+ check({
242
+ algorithm: 'base64',
243
+ password: '\u4F60\u597D',
244
+ }),
245
+ ];
246
+ case 4:
247
+ _state.sent();
248
+ return [
249
+ 4,
250
+ check({
251
+ algorithm: '5',
252
+ }),
253
+ ];
254
+ case 5:
255
+ _state.sent();
256
+ return [
257
+ 4,
258
+ check({
259
+ algorithm: '6',
260
+ }),
261
+ ];
262
+ case 6:
263
+ _state.sent();
264
+ return [2];
265
+ }
266
+ });
267
+ // await check({ algorithm: '7' });
268
+ })());
269
+ test('should verify manual created hash', () =>
270
+ _async_to_generator(function () {
271
+ var tests,
272
+ _iteratorNormalCompletion,
273
+ _didIteratorError,
274
+ _iteratorError,
275
+ _iterator,
276
+ _step,
277
+ _step_value,
278
+ _step_value_password,
279
+ password,
280
+ hash,
281
+ err;
282
+ return _ts_generator(this, (_state) => {
283
+ switch (_state.label) {
284
+ case 0:
285
+ tests = [
286
+ {
287
+ hash: '$2y$10$MQ057tMbDG6/lVkGFWrNwOR9kh/5rzbkhBPrwNPTPuZ5wBpGNbWLa',
288
+ },
289
+ {
290
+ hash: '$argon2i$v=19$m=16,t=2,p=1$SDZBU29LRUp0eTJyRDJqZg$76L95nAjG4SjjdoR0YZyFw',
291
+ },
292
+ {
293
+ hash: '$argon2d$v=19$m=16,t=2,p=1$SDZBU29LRUp0eTJyRDJqZg$+cB2R45sauVlfxbGslAmOw',
294
+ },
295
+ {
296
+ hash: '$argon2id$v=19$m=16,t=2,p=1$SDZBU29LRUp0eTJyRDJqZg$iP9HYuSDXgG2lW7KARBuQQ',
297
+ },
298
+ ];
299
+ (_iteratorNormalCompletion = true), (_didIteratorError = false), (_iteratorError = undefined);
300
+ _state.label = 1;
301
+ case 1:
302
+ _state.trys.push([1, 6, 7, 8]);
303
+ _iterator = tests[Symbol.iterator]();
304
+ _state.label = 2;
305
+ case 2:
306
+ if ((_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [3, 5];
307
+ (_step_value = _step.value),
308
+ (_step_value_password = _step_value.password),
309
+ (password = _step_value_password === void 0 ? '1' : _step_value_password),
310
+ (hash = _step_value.hash);
311
+ return [4, Password.verify(password, hash)];
312
+ case 3:
313
+ expect.apply(void 0, [_state.sent()]).toBe(true);
314
+ _state.label = 4;
315
+ case 4:
316
+ _iteratorNormalCompletion = true;
317
+ return [3, 2];
318
+ case 5:
319
+ return [3, 8];
320
+ case 6:
321
+ err = _state.sent();
322
+ _didIteratorError = true;
323
+ _iteratorError = err;
324
+ return [3, 8];
325
+ case 7:
326
+ try {
327
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
328
+ _iterator.return();
329
+ }
330
+ } finally {
331
+ if (_didIteratorError) {
332
+ throw _iteratorError;
333
+ }
334
+ }
335
+ return [7];
336
+ case 8:
337
+ return [2];
338
+ }
339
+ });
340
+ })());
375
341
  });