@sud-web/utils 0.0.1
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.d.mts +15 -0
- package/dist/index.mjs +1 -0
- package/package.json +36 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** 统一处理token */
|
|
2
|
+
declare function getCsrfToken(): string | null;
|
|
3
|
+
declare function setCsrfToken(token: string): void;
|
|
4
|
+
declare function removeCsrfToken(): void;
|
|
5
|
+
|
|
6
|
+
interface IRedirectToLoginParams {
|
|
7
|
+
channel: string;
|
|
8
|
+
authBaseUrl: string;
|
|
9
|
+
authPath?: string;
|
|
10
|
+
redirect_uri?: string;
|
|
11
|
+
debug?: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare function redirectToLogin(props?: IRedirectToLoginParams): void;
|
|
14
|
+
|
|
15
|
+
export { getCsrfToken, redirectToLogin, removeCsrfToken, setCsrfToken };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c="sud_auth_code",n=class{static XSRFSTART="x-xsrf-token"},t=n;function d(){return localStorage.getItem(t.XSRFSTART)}function T(r){return localStorage.setItem(t.XSRFSTART,r)}function l(){localStorage.removeItem(t.XSRFSTART);}function x(r={authBaseUrl:"",channel:""}){let{authBaseUrl:a,authPath:u="",redirect_uri:h,debug:f,channel:i}=r;if(!a){console.error("authBaseUrl must be has value");return}if(!i){console.error("channel must be has value");return}let o=h||location.href;if(console.log("[ redirect_uri ] >",o),!o){console.log("[ error ] > no redirect_uri");return}let s=new URL(o);s.searchParams.delete(c),l();let e=new URL(a+u);e.searchParams.append("channel",i),e.searchParams.append("redirect_uri",s.toString()),console.log("[ to.fullPath ] >",e.toString()),f||(location.href=e.toString());}export{d as getCsrfToken,x as redirectToLogin,l as removeCsrfToken,T as setCsrfToken};
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sud-web/utils",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.mts",
|
|
9
|
+
"import": "./dist/index.mjs"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "vitest run",
|
|
14
|
+
"test:watch": "vitest",
|
|
15
|
+
"test:ui": "vitest --ui",
|
|
16
|
+
"test:coverage": "vitest run --coverage",
|
|
17
|
+
"build": "pnpm run test && tsup && pnpm obfuscate",
|
|
18
|
+
"obfuscate": "node obfuscate.js",
|
|
19
|
+
"prepub": "pnpm test",
|
|
20
|
+
"pub": "npm publish --access public"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [],
|
|
23
|
+
"author": "",
|
|
24
|
+
"license": "ISC",
|
|
25
|
+
"packageManager": "pnpm@10.27.0",
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^20.19.30",
|
|
28
|
+
"@vitest/coverage-v8": "2.1.9",
|
|
29
|
+
"@vitest/ui": "^2.1.9",
|
|
30
|
+
"happy-dom": "^15.11.7",
|
|
31
|
+
"javascript-obfuscator": "^5.1.0",
|
|
32
|
+
"tsup": "^8.5.1",
|
|
33
|
+
"typescript": "^5.9.3",
|
|
34
|
+
"vitest": "^2.1.9"
|
|
35
|
+
}
|
|
36
|
+
}
|