@zvonimirsun/iszy-common 1.1.4 → 1.1.5

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 CHANGED
@@ -1 +1 @@
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;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=function(e){return e.SUPERADMIN=`superadmin`,e.ADMIN=`admin`,e}({}),t=function(e){return e[e.DEACTIVATED=0]=`DEACTIVATED`,e[e.ENABLED=1]=`ENABLED`,e[e.DISABLED=2]=`DISABLED`,e}({}),n=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`;function r(e){let t=``;do t=n.charAt(Number(e%62n))+t,e/=62n;while(e>0n);return t}var i=/^(?:[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}$/;function o(e){let{passwd:t,passwdSalt:n,...r}=e;return r}function s(e){let{userId:t,userName:n,nickName:r}=e;return{userId:t,userName:n,nickName:r}}var c=[];for(let e=0;e<256;++e)c.push((e+256).toString(16).slice(1));function l(e,t=0){return(c[e[t+0]]+c[e[t+1]]+c[e[t+2]]+c[e[t+3]]+`-`+c[e[t+4]]+c[e[t+5]]+`-`+c[e[t+6]]+c[e[t+7]]+`-`+c[e[t+8]]+c[e[t+9]]+`-`+c[e[t+10]]+c[e[t+11]]+c[e[t+12]]+c[e[t+13]]+c[e[t+14]]+c[e[t+15]]).toLowerCase()}var u=new Uint8Array(16);function d(){return crypto.getRandomValues(u)}function f(e,t,n){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():p(e,t,n)}function p(e,t,n){e||={};let r=e.random??e.rng?.()??d();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return l(r)}function m(){return f()}function h(e){e||=m();let t=e.replace(/-/g,``);return r(BigInt(`0x${t.substring(0,16)}`)^BigInt(`0x${t.substring(16,32)}`)).substring(0,6)}exports.REGEX_EMAIL=i,exports.REGEX_MOBILE_PHONE=a,exports.RoleEnum=e,exports.UserStatus=t,exports.base62Encode=r,exports.encodeUUID=h,exports.getUUID=m,exports.toMinimalUser=s,exports.toPublicUser=o;
package/dist/index.js CHANGED
@@ -1,64 +1,71 @@
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
- let t = "";
5
- do
6
- t = a.charAt(Number(n % 62n)) + t, n = n / 62n;
7
- while (n > 0n);
8
- return t;
1
+ //#region src/enums/role.enum.ts
2
+ var e = /* @__PURE__ */ function(e) {
3
+ return e.SUPERADMIN = "superadmin", e.ADMIN = "admin", e;
4
+ }({}), t = /* @__PURE__ */ function(e) {
5
+ return e[e.DEACTIVATED = 0] = "DEACTIVATED", e[e.ENABLED = 1] = "ENABLED", e[e.DISABLED = 2] = "DISABLED", e;
6
+ }({}), n = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
7
+ function r(e) {
8
+ let t = "";
9
+ do
10
+ t = n.charAt(Number(e % 62n)) + t, e /= 62n;
11
+ while (e > 0n);
12
+ return t;
9
13
  }
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
+ //#endregion
15
+ //#region src/utils/regexUtils.ts
16
+ var i = /^(?:[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}$/;
17
+ //#endregion
18
+ //#region src/utils/user.ts
19
+ function o(e) {
20
+ let { passwd: t, passwdSalt: n, ...r } = e;
21
+ return r;
14
22
  }
15
- function h(n) {
16
- const { userId: t, userName: r, nickName: o } = n;
17
- return { userId: t, userName: r, nickName: o };
23
+ function s(e) {
24
+ let { userId: t, userName: n, nickName: r } = e;
25
+ return {
26
+ userId: t,
27
+ userName: n,
28
+ nickName: r
29
+ };
18
30
  }
19
- const e = [];
20
- for (let n = 0; n < 256; ++n)
21
- e.push((n + 256).toString(16).slice(1));
22
- function s(n, t = 0) {
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();
31
+ //#endregion
32
+ //#region node_modules/.pnpm/uuid@14.0.0/node_modules/uuid/dist/stringify.js
33
+ var c = [];
34
+ for (let e = 0; e < 256; ++e) c.push((e + 256).toString(16).slice(1));
35
+ function l(e, t = 0) {
36
+ return (c[e[t + 0]] + c[e[t + 1]] + c[e[t + 2]] + c[e[t + 3]] + "-" + c[e[t + 4]] + c[e[t + 5]] + "-" + c[e[t + 6]] + c[e[t + 7]] + "-" + c[e[t + 8]] + c[e[t + 9]] + "-" + c[e[t + 10]] + c[e[t + 11]] + c[e[t + 12]] + c[e[t + 13]] + c[e[t + 14]] + c[e[t + 15]]).toLowerCase();
24
37
  }
25
- let c;
26
- const g = new Uint8Array(16);
27
- function D() {
28
- if (!c) {
29
- if (typeof crypto > "u" || !crypto.getRandomValues)
30
- throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
31
- c = crypto.getRandomValues.bind(crypto);
32
- }
33
- return c(g);
38
+ //#endregion
39
+ //#region node_modules/.pnpm/uuid@14.0.0/node_modules/uuid/dist/rng.js
40
+ var u = new Uint8Array(16);
41
+ function d() {
42
+ return crypto.getRandomValues(u);
34
43
  }
35
- const l = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), u = { randomUUID: l };
36
- function p(n, t, r) {
37
- n = n || {};
38
- const o = n.random ?? n.rng?.() ?? D();
39
- if (o.length < 16)
40
- throw new Error("Random bytes length must be >= 16");
41
- return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, s(o);
44
+ //#endregion
45
+ //#region node_modules/.pnpm/uuid@14.0.0/node_modules/uuid/dist/v4.js
46
+ function f(e, t, n) {
47
+ return !t && !e && crypto.randomUUID ? crypto.randomUUID() : p(e, t, n);
42
48
  }
43
- function I(n, t, r) {
44
- return u.randomUUID && !n ? u.randomUUID() : p(n);
49
+ function p(e, t, n) {
50
+ e ||= {};
51
+ let r = e.random ?? e.rng?.() ?? d();
52
+ if (r.length < 16) throw Error("Random bytes length must be >= 16");
53
+ if (r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, t) {
54
+ if (n ||= 0, n < 0 || n + 16 > t.length) throw RangeError(`UUID byte range ${n}:${n + 15} is out of buffer bounds`);
55
+ for (let e = 0; e < 16; ++e) t[n + e] = r[e];
56
+ return t;
57
+ }
58
+ return l(r);
45
59
  }
60
+ //#endregion
61
+ //#region src/utils/uuid.ts
46
62
  function m() {
47
- return I();
63
+ return f();
48
64
  }
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);
65
+ function h(e) {
66
+ e ||= m();
67
+ let t = e.replace(/-/g, "");
68
+ return r(BigInt(`0x${t.substring(0, 16)}`) ^ BigInt(`0x${t.substring(16, 32)}`)).substring(0, 6);
53
69
  }
54
- export {
55
- y as REGEX_EMAIL,
56
- A as REGEX_MOBILE_PHONE,
57
- x as RoleEnum,
58
- i as UserStatus,
59
- E as base62Encode,
60
- U as encodeUUID,
61
- m as getUUID,
62
- h as toMinimalUser,
63
- b as toPublicUser
64
- };
70
+ //#endregion
71
+ export { i as REGEX_EMAIL, a as REGEX_MOBILE_PHONE, e as RoleEnum, t as UserStatus, r as base62Encode, h as encodeUUID, m as getUUID, s as toMinimalUser, o as toPublicUser };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "author": "ZvonimirSun",
5
5
  "license": "MIT",
6
- "version": "1.1.4",
6
+ "version": "1.1.5",
7
7
  "exports": {
8
8
  ".": {
9
9
  "types": "./dist/index.d.ts",
@@ -18,15 +18,18 @@
18
18
  "files": [
19
19
  "./dist"
20
20
  ],
21
+ "repository": {
22
+ "url": "https://github.com/ZvonimirSun/iszy-common"
23
+ },
21
24
  "dependencies": {
22
- "uuid": "^13.0.0"
25
+ "uuid": "^14.0.0"
23
26
  },
24
27
  "devDependencies": {
25
- "@antfu/eslint-config": "^7.2.0",
26
- "eslint": "^9.39.2",
27
- "taze": "^19.9.2",
28
- "typescript": "~5.9.3",
29
- "vite": "^7.3.1"
28
+ "@antfu/eslint-config": "^9.0.0",
29
+ "eslint": "^10.4.0",
30
+ "taze": "^19.13.0",
31
+ "typescript": "~6.0.3",
32
+ "vite": "^8.0.13"
30
33
  },
31
34
  "scripts": {
32
35
  "dev": "vite",