openx-js-sdk 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/app.js.gz ADDED
Binary file
package/cookie.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ declare const getCookie: (name: string) => string | null;
2
+ declare const setCookie: (name: string, value: string, expiresInSeconds?: number, domain?: string) => void;
3
+ declare const removeCookie: (name: string) => void;
4
+ export { getCookie, setCookie, removeCookie };
package/env.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ type Env = 'test' | 'development' | 'production';
2
+ export declare const getEnv: () => Env;
3
+ export {};
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ export declare const getAction: <T = any>(url: string, data?: Record<string, any>, config?: AxiosRequestConfig) => Promise<T>;
3
+ export declare const postAction: <T = any>(url: string, data?: Record<string, any>, config?: AxiosRequestConfig) => Promise<T>;
package/ip.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const getUserIp: () => Promise<any>;
package/main.d.ts ADDED
File without changes
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "openx-js-sdk",
3
+ "version": "0.0.1",
4
+ "main": "./app.js",
5
+ "scripts": {
6
+ "serve": "set NODE_ENV=development&& webpack-dev-server --config build/webpack.dev.js --env=development",
7
+ "test": "set NODE_ENV=test&&webpack --progress --config build/webpack.pro.js&& node build/zip.js",
8
+ "build": "set NODE_ENV=production&&webpack --progress --config build/webpack.pro.js&& node build && cd dist && npm publish"
9
+ },
10
+ "keywords": [
11
+ "webpack",
12
+ "webpack 5"
13
+ ],
14
+ "types": "./app.d.ts",
15
+ "author": "charlie",
16
+ "license": "ISC",
17
+ "devDependencies": {
18
+ "@babel/core": "^7.5.4",
19
+ "@babel/preset-env": "^7.5.0",
20
+ "@typescript-eslint/eslint-plugin": "^5.61.0",
21
+ "@typescript-eslint/parser": "^5.61.0",
22
+ "archiver": "^6.0.1",
23
+ "babel-eslint": "^10.1.0",
24
+ "babel-loader": "^8.2.5",
25
+ "babel-plugin-transform-remove-console": "^6.9.4",
26
+ "clean-webpack-plugin": "^4.0.0",
27
+ "compression-webpack-plugin": "^10.0.0",
28
+ "copy-webpack-plugin": "^11.0.0",
29
+ "css-loader": "^6.7.1",
30
+ "dotenv-webpack": "^8.0.1",
31
+ "eslint": "^8.44.0",
32
+ "html-webpack-plugin": "^5.5.0",
33
+ "less": "^4.1.3",
34
+ "less-loader": "^11.0.0",
35
+ "mini-css-extract-plugin": "^2.6.1",
36
+ "postcss-loader": "^7.0.1",
37
+ "style-loader": "^3.3.1",
38
+ "terser-webpack-plugin": "^5.3.9",
39
+ "ts-loader": "^9.5.1",
40
+ "typescript": "^5.6.3",
41
+ "webpack": "^5.74.0",
42
+ "webpack-cli": "^4.10.0",
43
+ "webpack-dev-server": "^4.11.1",
44
+ "zip-webpack-plugin": "^4.0.1"
45
+ },
46
+ "dependencies": {
47
+ "axios": "^1.12.2",
48
+ "cnki-x-jwt": "^0.0.17",
49
+ "core-js": "^3.6.5"
50
+ }
51
+ }
@@ -0,0 +1 @@
1
+ export declare const getBaseUrl: (url: string) => string;
@@ -0,0 +1,25 @@
1
+ declare const proxy: {
2
+ '/proxy-sdk-jwt': {
3
+ open: boolean;
4
+ ws: boolean;
5
+ target: string;
6
+ changeOrigin: boolean;
7
+ pathRewrite: {
8
+ '^/proxy-sdk-jwt': string;
9
+ };
10
+ };
11
+ '/proxy-sdk-ip': {
12
+ open: boolean;
13
+ ws: boolean;
14
+ target: string;
15
+ changeOrigin: boolean;
16
+ pathRewrite: {
17
+ '^/proxy-sdk-ip': string;
18
+ };
19
+ headers: {
20
+ origin: string;
21
+ referer: string;
22
+ };
23
+ };
24
+ };
25
+ export default proxy;
@@ -0,0 +1,29 @@
1
+ declare const proxy: {
2
+ '/proxy-sdk-jwt': {
3
+ open: boolean;
4
+ ws: boolean;
5
+ target: string;
6
+ changeOrigin: boolean;
7
+ pathRewrite: {
8
+ '^/proxy-sdk-jwt': string;
9
+ };
10
+ headers: {
11
+ origin: string;
12
+ referer: string;
13
+ };
14
+ };
15
+ '/proxy-sdk-ip': {
16
+ open: boolean;
17
+ ws: boolean;
18
+ target: string;
19
+ changeOrigin: boolean;
20
+ pathRewrite: {
21
+ '^/proxy-sdk-ip': string;
22
+ };
23
+ headers: {
24
+ origin: string;
25
+ referer: string;
26
+ };
27
+ };
28
+ };
29
+ export default proxy;
@@ -0,0 +1,18 @@
1
+ import { AxiosInstance, AxiosResponse } from 'axios';
2
+ /**
3
+ * 获取或刷新 JWT Token
4
+ * @returns {Promise<{ code: number; content?: string; message?: string }>}
5
+ */
6
+ export declare const getRefreshToken: () => Promise<{
7
+ code: number;
8
+ content?: string;
9
+ message?: string;
10
+ }>;
11
+ /**
12
+ * 刷新 Token 并重试原请求
13
+ * @param service Axios 实例
14
+ * @param response Axios 响应对象
15
+ * @returns Promise<AxiosResponse>
16
+ */
17
+ declare const refreshToken: (service: AxiosInstance, response: AxiosResponse) => Promise<AxiosResponse | void>;
18
+ export default refreshToken;
package/store.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ import type { ConfigOptions } from './types';
2
+ declare class Store {
3
+ private static instance;
4
+ private options;
5
+ static getInstance(): Store;
6
+ /** 初始化或整体替换配置 */
7
+ config(opts: Partial<ConfigOptions>): void;
8
+ /** 获取完整配置 */
9
+ getOptions(): ConfigOptions;
10
+ /** 获取 JWT key */
11
+ getJwtKey(): string;
12
+ /** 可注册响应钩子 */
13
+ setResponseHandler(fn: ConfigOptions['response']): void;
14
+ }
15
+ export declare const store: Store;
16
+ export declare const getJwtKey: () => string;
17
+ export default store;
@@ -0,0 +1,7 @@
1
+ export interface ConfigOptions {
2
+ appid: string;
3
+ env?: string;
4
+ platForm?: string;
5
+ proxy?: any;
6
+ response?: (...args: any[]) => void;
7
+ }