@zvonimirsun/iszy-common 1.1.3 → 1.1.4
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/dist/index.cjs +1 -1
- package/dist/index.js +38 -27
- package/dist/utils/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var i=(n=>(n.SUPERADMIN="superadmin",n.ADMIN="admin",n))(i||{}),d=(n=>(n[n.DEACTIVATED=0]="DEACTIVATED",n[n.ENABLED=1]="ENABLED",n[n.DISABLED=2]="DISABLED",n))(d||{});const s="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function x(n){let t="";do t=s.charAt(Number(n%62n))+t,n=n/62n;while(n>0n);return t}const l=/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\v\f\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|\\[\x01-\x09\v\f\x0E-\x7F])\*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d{1,2}|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\v\f\x0E-\x1F\x21-\x5A\x53-\x7F]|\\[\x01-\x09\v\f\x0E-\x7F])+)\])$/,g=/^1[3-9]\d{9}$/;function D(n){const{passwd:t,passwdSalt:r,...o}=n;return o}function I(n){const{userId:t,userName:r,nickName:o}=n;return{userId:t,userName:r,nickName:o}}const e=[];for(let n=0;n<256;++n)e.push((n+256).toString(16).slice(1));function U(n,t=0){return(e[n[t+0]]+e[n[t+1]]+e[n[t+2]]+e[n[t+3]]+"-"+e[n[t+4]]+e[n[t+5]]+"-"+e[n[t+6]]+e[n[t+7]]+"-"+e[n[t+8]]+e[n[t+9]]+"-"+e[n[t+10]]+e[n[t+11]]+e[n[t+12]]+e[n[t+13]]+e[n[t+14]]+e[n[t+15]]).toLowerCase()}let c;const m=new Uint8Array(16);function b(){if(!c){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");c=crypto.getRandomValues.bind(crypto)}return c(m)}const p=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),u={randomUUID:p};function y(n,t,r){n=n||{};const o=n.random??n.rng?.()??b();if(o.length<16)throw new Error("Random bytes length must be >= 16");return o[6]=o[6]&15|64,o[8]=o[8]&63|128,U(o)}function A(n,t,r){return u.randomUUID&&!n?u.randomUUID():y(n)}function E(){return A()}function h(n){n=n||E();const t=n.replace(/-/g,""),r=BigInt(`0x${t.substring(0,16)}`),o=BigInt(`0x${t.substring(16,32)}`),a=r^o;return x(a).substring(0,6)}exports.REGEX_EMAIL=l;exports.REGEX_MOBILE_PHONE=g;exports.RoleEnum=i;exports.UserStatus=d;exports.base62Encode=x;exports.encodeUUID=h;exports.getUUID=E;exports.toMinimalUser=I;exports.toPublicUser=D;
|
package/dist/index.js
CHANGED
|
@@ -1,53 +1,64 @@
|
|
|
1
|
-
var
|
|
2
|
-
const
|
|
3
|
-
function
|
|
1
|
+
var x = /* @__PURE__ */ ((n) => (n.SUPERADMIN = "superadmin", n.ADMIN = "admin", n))(x || {}), i = /* @__PURE__ */ ((n) => (n[n.DEACTIVATED = 0] = "DEACTIVATED", n[n.ENABLED = 1] = "ENABLED", n[n.DISABLED = 2] = "DISABLED", n))(i || {});
|
|
2
|
+
const a = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
3
|
+
function E(n) {
|
|
4
4
|
let t = "";
|
|
5
5
|
do
|
|
6
|
-
t =
|
|
6
|
+
t = a.charAt(Number(n % 62n)) + t, n = n / 62n;
|
|
7
7
|
while (n > 0n);
|
|
8
8
|
return t;
|
|
9
9
|
}
|
|
10
|
-
const
|
|
10
|
+
const y = /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\v\f\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|\\[\x01-\x09\v\f\x0E-\x7F])\*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d{1,2}|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\v\f\x0E-\x1F\x21-\x5A\x53-\x7F]|\\[\x01-\x09\v\f\x0E-\x7F])+)\])$/, A = /^1[3-9]\d{9}$/;
|
|
11
|
+
function b(n) {
|
|
12
|
+
const { passwd: t, passwdSalt: r, ...o } = n;
|
|
13
|
+
return o;
|
|
14
|
+
}
|
|
15
|
+
function h(n) {
|
|
16
|
+
const { userId: t, userName: r, nickName: o } = n;
|
|
17
|
+
return { userId: t, userName: r, nickName: o };
|
|
18
|
+
}
|
|
19
|
+
const e = [];
|
|
11
20
|
for (let n = 0; n < 256; ++n)
|
|
12
21
|
e.push((n + 256).toString(16).slice(1));
|
|
13
|
-
function
|
|
22
|
+
function s(n, t = 0) {
|
|
14
23
|
return (e[n[t + 0]] + e[n[t + 1]] + e[n[t + 2]] + e[n[t + 3]] + "-" + e[n[t + 4]] + e[n[t + 5]] + "-" + e[n[t + 6]] + e[n[t + 7]] + "-" + e[n[t + 8]] + e[n[t + 9]] + "-" + e[n[t + 10]] + e[n[t + 11]] + e[n[t + 12]] + e[n[t + 13]] + e[n[t + 14]] + e[n[t + 15]]).toLowerCase();
|
|
15
24
|
}
|
|
16
25
|
let c;
|
|
17
|
-
const
|
|
18
|
-
function
|
|
26
|
+
const g = new Uint8Array(16);
|
|
27
|
+
function D() {
|
|
19
28
|
if (!c) {
|
|
20
29
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
21
30
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
22
31
|
c = crypto.getRandomValues.bind(crypto);
|
|
23
32
|
}
|
|
24
|
-
return c(
|
|
33
|
+
return c(g);
|
|
25
34
|
}
|
|
26
|
-
const
|
|
27
|
-
function
|
|
35
|
+
const l = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), u = { randomUUID: l };
|
|
36
|
+
function p(n, t, r) {
|
|
28
37
|
n = n || {};
|
|
29
|
-
const o = n.random ?? n.rng?.() ??
|
|
38
|
+
const o = n.random ?? n.rng?.() ?? D();
|
|
30
39
|
if (o.length < 16)
|
|
31
40
|
throw new Error("Random bytes length must be >= 16");
|
|
32
|
-
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128,
|
|
41
|
+
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, s(o);
|
|
33
42
|
}
|
|
34
|
-
function
|
|
35
|
-
return
|
|
43
|
+
function I(n, t, r) {
|
|
44
|
+
return u.randomUUID && !n ? u.randomUUID() : p(n);
|
|
36
45
|
}
|
|
37
|
-
function
|
|
38
|
-
return
|
|
46
|
+
function m() {
|
|
47
|
+
return I();
|
|
39
48
|
}
|
|
40
|
-
function
|
|
41
|
-
n = n ||
|
|
42
|
-
const t = n.replace(/-/g, ""),
|
|
43
|
-
return
|
|
49
|
+
function U(n) {
|
|
50
|
+
n = n || m();
|
|
51
|
+
const t = n.replace(/-/g, ""), r = BigInt(`0x${t.substring(0, 16)}`), o = BigInt(`0x${t.substring(16, 32)}`), d = r ^ o;
|
|
52
|
+
return E(d).substring(0, 6);
|
|
44
53
|
}
|
|
45
54
|
export {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
55
|
+
y as REGEX_EMAIL,
|
|
56
|
+
A as REGEX_MOBILE_PHONE,
|
|
57
|
+
x as RoleEnum,
|
|
49
58
|
i as UserStatus,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
59
|
+
E as base62Encode,
|
|
60
|
+
U as encodeUUID,
|
|
61
|
+
m as getUUID,
|
|
62
|
+
h as toMinimalUser,
|
|
63
|
+
b as toPublicUser
|
|
53
64
|
};
|
package/dist/utils/index.d.ts
CHANGED