@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.
- package/lib/cn/ChineseResidentIdNo.js +41 -0
- package/lib/cn/ChineseResidentIdNo.mod.js +1 -0
- package/lib/cn/ChineseResidentIdNo.test.js +22 -0
- package/lib/cn/DivisionCode.js +214 -280
- package/lib/cn/DivisionCode.mod.js +1 -0
- package/lib/cn/DivisionCode.test.js +134 -0
- package/lib/cn/Mod11.js +86 -0
- package/lib/cn/Mod31.js +98 -0
- package/lib/cn/UnifiedSocialCreditCode.js +130 -109
- package/lib/cn/UnifiedSocialCreditCode.mod.js +1 -0
- package/lib/cn/UnifiedSocialCreditCode.test.js +16 -0
- package/lib/cn/index.js +1 -4
- package/lib/cn/mod.js +6 -0
- package/lib/cn/types.d.js +0 -2
- package/lib/consola/createStandardConsolaReporter.js +6 -6
- package/lib/consola/formatLogObject.js +147 -34
- package/lib/consola/index.js +0 -1
- package/lib/data/formatSort.js +5 -6
- package/lib/data/formatSort.test.js +34 -0
- package/lib/data/index.js +0 -1
- package/lib/data/maybeNumber.js +11 -5
- package/lib/data/parseSort.js +28 -22
- package/lib/data/parseSort.test.js +188 -0
- package/lib/data/resolvePagination.js +27 -16
- package/lib/data/resolvePagination.test.js +232 -0
- package/lib/data/types.d.js +0 -2
- package/lib/dayjs/dayjs.js +38 -0
- package/lib/dayjs/formatDuration.js +58 -0
- package/lib/dayjs/formatDuration.test.js +90 -0
- package/lib/dayjs/index.js +3 -0
- package/lib/dayjs/parseDuration.js +32 -0
- package/lib/decimal/index.js +1 -0
- package/lib/decimal/parseDecimal.js +13 -0
- package/lib/foundation/schema/SexType.js +14 -0
- package/lib/foundation/schema/index.js +1 -0
- package/lib/foundation/schema/parseSexType.js +18 -0
- package/lib/foundation/schema/types.js +5 -0
- package/lib/index.js +0 -1
- package/lib/jsonschema/JsonSchema.js +78 -52
- package/lib/jsonschema/JsonSchema.test.js +137 -0
- package/lib/jsonschema/index.js +0 -1
- package/lib/jsonschema/types.d.js +5 -3
- package/lib/meta/defineFileType.js +103 -20
- package/lib/meta/defineInit.js +250 -31
- package/lib/meta/defineMetadata.js +140 -24
- package/lib/meta/defineMetadata.test.js +13 -0
- package/lib/meta/index.js +0 -1
- package/lib/password/PHC.js +87 -63
- package/lib/password/PHC.test.js +539 -0
- package/lib/password/Password.js +295 -30
- package/lib/password/Password.test.js +362 -0
- package/lib/password/createArgon2PasswordAlgorithm.js +191 -35
- package/lib/password/createBase64PasswordAlgorithm.js +141 -8
- package/lib/password/createBcryptPasswordAlgorithm.js +168 -13
- package/lib/password/createPBKDF2PasswordAlgorithm.js +228 -46
- package/lib/password/createScryptPasswordAlgorithm.js +211 -55
- package/lib/password/index.js +0 -1
- package/lib/password/server/index.js +0 -1
- package/lib/resource/Identifiable.js +1 -0
- package/lib/resource/ListQuery.js +119 -0
- package/lib/resource/getTitleOfResource.js +10 -0
- package/lib/resource/index.js +2 -0
- package/lib/resource/schema/AnyResourceSchema.js +89 -0
- package/lib/resource/schema/BaseResourceSchema.js +29 -0
- package/lib/resource/schema/ResourceActionType.js +118 -0
- package/lib/resource/schema/ResourceStatus.js +93 -0
- package/lib/resource/schema/ResourceType.js +24 -0
- package/lib/resource/schema/index.js +5 -0
- package/lib/resource/schema/types.js +89 -0
- package/lib/resource/schema/types.test.js +14 -0
- package/lib/schema/SchemaRegistry.js +45 -0
- package/lib/schema/SchemaRegistry.mod.js +2 -0
- package/lib/schema/TypeSchema.d.js +1 -0
- package/lib/schema/createSchemaData.js +173 -0
- package/lib/schema/findJsonSchemaByPath.js +49 -0
- package/lib/schema/getSchemaCache.js +11 -0
- package/lib/schema/getSchemaOptions.js +24 -0
- package/lib/schema/index.js +6 -0
- package/lib/schema/toJsonSchema.js +441 -0
- package/lib/schema/toJsonSchema.test.js +27 -0
- package/lib/schema/validate.js +124 -0
- package/lib/tools/generateSchema.js +197 -39
- package/lib/tools/renderJsonSchemaToMarkdownDoc.js +143 -55
- package/lib/utils/getEstimateProcessTime.js +20 -0
- package/lib/utils/index.js +1 -0
- package/package.json +38 -17
- package/src/cn/ChineseResidentIdNo.mod.ts +7 -0
- package/src/cn/ChineseResidentIdNo.test.ts +18 -0
- package/src/cn/ChineseResidentIdNo.ts +66 -0
- package/src/cn/DivisionCode.mod.ts +7 -0
- package/src/cn/DivisionCode.test.ts +3 -13
- package/src/cn/DivisionCode.ts +132 -195
- package/src/cn/{Mod11Checksum.ts → Mod11.ts} +3 -1
- package/src/cn/{Mod31Checksum.ts → Mod31.ts} +2 -0
- package/src/cn/UnifiedSocialCreditCode.mod.ts +7 -0
- package/src/cn/UnifiedSocialCreditCode.test.ts +2 -2
- package/src/cn/UnifiedSocialCreditCode.ts +105 -125
- package/src/cn/__snapshots__/ChineseResidentIdNo.test.ts.snap +14 -0
- package/src/cn/__snapshots__/UnifiedSocialCreditCode.test.ts.snap +18 -12
- package/src/cn/index.ts +1 -3
- package/src/cn/mod.ts +3 -0
- package/src/consola/formatLogObject.ts +12 -4
- package/src/data/maybeNumber.ts +5 -1
- package/src/data/resolvePagination.test.ts +1 -1
- package/src/data/resolvePagination.ts +18 -7
- package/src/data/types.d.ts +12 -0
- package/src/dayjs/dayjs.ts +40 -0
- package/src/dayjs/formatDuration.test.ts +14 -0
- package/src/dayjs/formatDuration.ts +86 -0
- package/src/dayjs/index.ts +3 -0
- package/src/dayjs/parseDuration.ts +40 -0
- package/src/decimal/index.ts +1 -0
- package/src/decimal/parseDecimal.ts +16 -0
- package/src/foundation/schema/SexType.ts +21 -0
- package/src/foundation/schema/index.ts +1 -0
- package/src/foundation/schema/parseSexType.ts +19 -0
- package/src/foundation/schema/types.ts +8 -0
- package/src/jsonschema/JsonSchema.test.ts +17 -0
- package/src/jsonschema/JsonSchema.ts +2 -2
- package/src/jsonschema/types.d.ts +63 -12
- package/src/password/Password.ts +2 -2
- package/src/resource/Identifiable.ts +3 -0
- package/src/resource/ListQuery.ts +53 -0
- package/src/resource/getTitleOfResource.tsx +6 -0
- package/src/resource/index.ts +4 -0
- package/src/resource/schema/AnyResourceSchema.ts +113 -0
- package/src/resource/schema/BaseResourceSchema.ts +32 -0
- package/src/resource/schema/ResourceActionType.ts +123 -0
- package/src/resource/schema/ResourceStatus.ts +94 -0
- package/src/resource/schema/ResourceType.ts +25 -0
- package/src/resource/schema/index.ts +5 -0
- package/src/resource/schema/types.test.ts +18 -0
- package/src/resource/schema/types.ts +105 -0
- package/src/schema/SchemaRegistry.mod.ts +1 -0
- package/src/schema/SchemaRegistry.ts +46 -0
- package/src/schema/TypeSchema.d.ts +32 -0
- package/src/schema/createSchemaData.ts +81 -0
- package/src/schema/findJsonSchemaByPath.ts +37 -0
- package/src/schema/getSchemaCache.ts +21 -0
- package/src/schema/getSchemaOptions.ts +24 -0
- package/src/schema/index.ts +7 -0
- package/src/schema/toJsonSchema.test.ts +37 -0
- package/src/schema/toJsonSchema.ts +200 -0
- package/src/schema/validate.ts +135 -0
- package/src/tools/generateSchema.ts +28 -28
- package/src/utils/getEstimateProcessTime.ts +36 -0
- package/src/utils/index.ts +1 -0
- package/lib/cn/DivisionCode.js.map +0 -1
- package/lib/cn/Mod11Checksum.js +0 -42
- package/lib/cn/Mod11Checksum.js.map +0 -1
- package/lib/cn/Mod31Checksum.js +0 -48
- package/lib/cn/Mod31Checksum.js.map +0 -1
- package/lib/cn/ResidentIdentityCardNumber.js +0 -50
- package/lib/cn/ResidentIdentityCardNumber.js.map +0 -1
- package/lib/cn/UnifiedSocialCreditCode.js.map +0 -1
- package/lib/cn/formatDate.js +0 -15
- package/lib/cn/formatDate.js.map +0 -1
- package/lib/cn/index.js.map +0 -1
- package/lib/cn/parseSex.js +0 -22
- package/lib/cn/parseSex.js.map +0 -1
- package/lib/cn/types.d.js.map +0 -1
- package/lib/consola/createStandardConsolaReporter.js.map +0 -1
- package/lib/consola/formatLogObject.js.map +0 -1
- package/lib/consola/index.js.map +0 -1
- package/lib/data/formatSort.js.map +0 -1
- package/lib/data/index.js.map +0 -1
- package/lib/data/maybeNumber.js.map +0 -1
- package/lib/data/parseSort.js.map +0 -1
- package/lib/data/resolvePagination.js.map +0 -1
- package/lib/data/types.d.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/jsonschema/JsonSchema.js.map +0 -1
- package/lib/jsonschema/index.js.map +0 -1
- package/lib/jsonschema/types.d.js.map +0 -1
- package/lib/meta/defineFileType.js.map +0 -1
- package/lib/meta/defineInit.js.map +0 -1
- package/lib/meta/defineMetadata.js.map +0 -1
- package/lib/meta/index.js.map +0 -1
- package/lib/password/PHC.js.map +0 -1
- package/lib/password/Password.js.map +0 -1
- package/lib/password/createArgon2PasswordAlgorithm.js.map +0 -1
- package/lib/password/createBase64PasswordAlgorithm.js.map +0 -1
- package/lib/password/createBcryptPasswordAlgorithm.js.map +0 -1
- package/lib/password/createPBKDF2PasswordAlgorithm.js.map +0 -1
- package/lib/password/createScryptPasswordAlgorithm.js.map +0 -1
- package/lib/password/index.js.map +0 -1
- package/lib/password/server/index.js.map +0 -1
- package/lib/search/AdvanceSearch.js +0 -10
- package/lib/search/AdvanceSearch.js.map +0 -1
- package/lib/search/formatAdvanceSearch.js +0 -64
- package/lib/search/formatAdvanceSearch.js.map +0 -1
- package/lib/search/index.js +0 -2
- package/lib/search/index.js.map +0 -1
- package/lib/search/optimizeAdvanceSearch.js +0 -89
- package/lib/search/optimizeAdvanceSearch.js.map +0 -1
- package/lib/search/parseAdvanceSearch.js +0 -20
- package/lib/search/parseAdvanceSearch.js.map +0 -1
- package/lib/search/parser.d.js +0 -3
- package/lib/search/parser.d.js.map +0 -1
- package/lib/search/parser.js +0 -3065
- package/lib/search/parser.js.map +0 -1
- package/lib/search/types.d.js +0 -3
- package/lib/search/types.d.js.map +0 -1
- package/lib/tools/generateSchema.js.map +0 -1
- package/lib/tools/renderJsonSchemaToMarkdownDoc.js.map +0 -1
- package/src/cn/ResidentIdentityCardNumber.test.ts +0 -17
- package/src/cn/ResidentIdentityCardNumber.ts +0 -96
- package/src/cn/__snapshots__/ResidentIdentityCardNumber.test.ts.snap +0 -15
- package/src/cn/formatDate.ts +0 -12
- package/src/cn/parseSex.ts +0 -13
- package/src/search/AdvanceSearch.test.ts +0 -149
- package/src/search/AdvanceSearch.ts +0 -14
- package/src/search/Makefile +0 -2
- package/src/search/__snapshots__/AdvanceSearch.test.ts.snap +0 -675
- package/src/search/formatAdvanceSearch.ts +0 -52
- package/src/search/index.ts +0 -1
- package/src/search/optimizeAdvanceSearch.ts +0 -77
- package/src/search/parseAdvanceSearch.ts +0 -23
- package/src/search/parser.d.ts +0 -8
- package/src/search/parser.js +0 -2794
- package/src/search/parser.peggy +0 -237
- package/src/search/types.d.ts +0 -45
package/lib/password/Password.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
207
|
+
var DefaultAlgorithm = "6";
|
|
16
208
|
function setDefaultAlgorithm(algorithm) {
|
|
17
|
-
Errors.BadRequest.check(Algorithms[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
|
-
|
|
29
|
-
|
|
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
|
-
|
|
43
|
-
return
|
|
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
|
-
|
|
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(
|
|
271
|
+
throw new Error("Unknown algorithm ".concat(id));
|
|
53
272
|
}
|
|
54
273
|
return f;
|
|
55
274
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|