Skip to content

Commit ce8fa87

Browse files
committed
feat(support logout): support logout
1 parent 8d1886c commit ce8fa87

24 files changed

+3749
-6
lines changed

dist/anyweb-js-sdk.umd.min.js

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/anyweb-js-sdk.umd.min.js.map

Lines changed: 2739 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/package.json

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
{
2+
"name": "@idealight-labs/anyweb-js-sdk",
3+
"description": "AnyWeb JavaScript Software Development Kit",
4+
"version": "1.1.6",
5+
"license": "LGPL-3.0",
6+
"author": "common@idealight.ltd",
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/IdeaLightLabs/AnyWeb-JS-SDK.git"
10+
},
11+
"keywords": [
12+
"anyweb",
13+
"sdk"
14+
],
15+
"main": "dist/src/index.js",
16+
"types": "dist/src/index.d.ts",
17+
"browser": "dist/anyweb-js-sdk.umd.min.js",
18+
"browserify-browser": {
19+
"secp256k1": "secp256k1/elliptic"
20+
},
21+
"files": [
22+
"dist",
23+
"src",
24+
"lib",
25+
"types",
26+
"anyweb-js-sdk.umd.min.js"
27+
],
28+
"browserslit": "cover 99.5%",
29+
"dependencies": {
30+
"@commitlint/config-conventional": "^16.0.0",
31+
"@conflux-dev/conflux-address-js": "^1.3.12",
32+
"abi-util-lite": "^0.1.0",
33+
"big.js": "^5.2.2",
34+
"commander": "^8.0.0",
35+
"conventional-changelog-cli": "^2.2.2",
36+
"js-conflux-sdk": "^2.0.0",
37+
"keccak": "^2.0.0",
38+
"node-forge": "^1.2.1",
39+
"rlp": "^2.2.7",
40+
"scrypt-js": "^3.0.1",
41+
"secp256k1": "^3.7.1",
42+
"superagent": "^6.1.0",
43+
"typescript": "^4.5.5",
44+
"websocket": "^1.0.31"
45+
},
46+
"devDependencies": {
47+
"@babel/core": "^7.8.4",
48+
"@babel/plugin-transform-runtime": "^7.8.3",
49+
"@babel/preset-env": "^7.8.4",
50+
"@babel/preset-typescript": "^7.16.7",
51+
"@babel/runtime": "^7.8.4",
52+
"@commitlint/cli": "^16.1.0",
53+
"@commitlint/config-angular": "^16.0.0",
54+
"@types/jest": "^27.4.0",
55+
"@types/node": "^14.0.23",
56+
"@types/node-forge": "^1.0.0",
57+
"@typescript-eslint/eslint-plugin": "^5.10.2",
58+
"@typescript-eslint/parser": "^5.10.2",
59+
"babel-plugin-lodash": "^3.3.4",
60+
"babelify": "^10.0.0",
61+
"browserify": "^16.5.1",
62+
"commitizen": "^4.2.4",
63+
"concurrently": "^5.1.0",
64+
"cz-conventional-changelog": "^3.3.0",
65+
"eslint": "^7.12.0",
66+
"eslint-config-airbnb-base": "^14.0.0",
67+
"eslint-config-prettier": "^8.3.0",
68+
"eslint-plugin-import": "^2.18.2",
69+
"eslint-plugin-prettier": "^4.0.0",
70+
"exorcist": "^1.0.1",
71+
"fs-extra": "^8.1.0",
72+
"husky": "^7.0.0",
73+
"jest": "^27.4.7",
74+
"jsbi": "^3.1.4",
75+
"jsdoc-to-markdown": "^7.1.0",
76+
"minify-stream": "^2.0.1",
77+
"mold-source-map": "^0.4.0",
78+
"prettier": "^2.5.1",
79+
"solc": "^0.6.10",
80+
"standard-version": "^9.3.2",
81+
"ts-jest": "^27.1.3",
82+
"tsify": "^5.0.4",
83+
"typedoc": "^0.22.11",
84+
"typedoc-plugin-markdown": "^3.11.12"
85+
},
86+
"resolutions": {
87+
"tinyify/acorn-node/acorn": "7.1.1",
88+
"eslint/espree/acorn": "7.1.1",
89+
"tinyify/unassertify/unassert/acorn": "7.1.1",
90+
"**/minimist": "^1.2.3",
91+
"**/kind-of": "^6.0.3",
92+
"**/elliptic": "^6.5.3",
93+
"**/lodash": "^4.17.20",
94+
"**/babel-jest": "^26.6.0",
95+
"jest/jest-cli/jest-config/jest-environment-jsdom/jsdom/acorn-globals/acorn": "6.4.1"
96+
},
97+
"scripts": {
98+
"lint": "eslint ./src ./test",
99+
"lint:fix": "eslint ./src ./test --fix",
100+
"build": "node scripts/build-frontend.js",
101+
"document": "typedoc --plugin typedoc-plugin-markdown --out docs/api/ src/index.ts",
102+
"prepublishOnly": "npm run build:lib && npm run build",
103+
"test": "jest --coverage",
104+
"build:lib": "tsc",
105+
"dev": "tsc --watch",
106+
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1",
107+
"commit": "git cz",
108+
"release": "standard-version --release-as",
109+
"prepare": "husky install"
110+
},
111+
"config": {
112+
"commitizen": {
113+
"path": "./node_modules/cz-conventional-changelog"
114+
}
115+
},
116+
"bugs": {
117+
"url": "https://github.com/IdeaLightLabs/AnyWeb-JS-SDK/issues"
118+
},
119+
"homepage": "https://github.com/IdeaLightLabs/AnyWeb-JS-SDK#readme",
120+
"directories": {
121+
"example": "example",
122+
"lib": "lib",
123+
"test": "test"
124+
}
125+
}

dist/src/config.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* @author Littleor <me@littleor.cn>
3+
* @since 2022/2/12
4+
*/
5+
export declare const BASE_URL = "https://app.anyweb.cc/#/";
6+
export declare const API_BASE_URL = "https://api.anyweb.cc";

dist/src/config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.API_BASE_URL = exports.BASE_URL = void 0;
4+
/**
5+
* @author Littleor <me@littleor.cn>
6+
* @since 2022/2/12
7+
*/
8+
exports.BASE_URL = 'https://app.anyweb.cc/#/';
9+
exports.API_BASE_URL = 'https://api.anyweb.cc';

dist/src/error/provider.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* @author Littleor <me@littleor.cn>
3+
* @since 2022/2/4
4+
*/

dist/src/error/provider.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"use strict";
2+
/**
3+
* @author Littleor <me@littleor.cn>
4+
* @since 2022/2/4
5+
*/

dist/src/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { Provider } from './provider';
2+
export { Provider };

dist/src/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.Provider = void 0;
4+
const provider_1 = require("./provider");
5+
Object.defineProperty(exports, "Provider", { enumerable: true, get: function () { return provider_1.Provider; } });
6+
module.exports = {
7+
Provider: provider_1.Provider,
8+
};

dist/src/interface/provider.d.ts

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/**
2+
* @author Littleor <me@littleor.cn>
3+
* @since 2022/2/4
4+
*/
5+
import { ConsoleLike } from '../utils/types';
6+
/**
7+
* Request Args
8+
*/
9+
export interface IRequestArguments {
10+
readonly method: string;
11+
readonly params?: any;
12+
readonly chainId?: number;
13+
}
14+
export interface IBaseProviderOptions {
15+
logger?: ConsoleLike;
16+
appId: string;
17+
}
18+
/**
19+
* Provider RPC Error
20+
*/
21+
export interface IProviderRpcError extends Error {
22+
message: string;
23+
code: number;
24+
data?: unknown;
25+
}
26+
/**
27+
* Base Provider
28+
*/
29+
export interface IProvider {
30+
/**
31+
* Request
32+
* @param args {IRequestArguments} Request Arguments: {method, params}
33+
* @returns {Promise<any>}
34+
*/
35+
request(args: IRequestArguments): Promise<unknown>;
36+
/**
37+
* monitor information
38+
* @param type {string} monitor type
39+
* @param listener {Function} callback
40+
*/
41+
on(type: string, listener: (...args: any[]) => void): void;
42+
}
43+
/**
44+
* @author Littleor <me@littleor.cn>
45+
* @since 2022/2/18
46+
*/
47+
export interface IAuthResult {
48+
chainId: number;
49+
networkId: number;
50+
address: string[];
51+
url: string;
52+
code: string;
53+
scopes: string[];
54+
}
55+
export interface IProviderRpcError extends Error {
56+
message: string;
57+
code: number;
58+
data?: unknown;
59+
}
60+
export interface IProviderConnectInfo {
61+
readonly chainId: string;
62+
}
63+
export interface IProviderMessage {
64+
readonly type: string;
65+
readonly data: unknown;
66+
}
67+
export interface IIframeOptions {
68+
appId: string;
69+
params: string;
70+
chainId: number;
71+
scopes?: string[];
72+
authType?: 'account' | 'createContract' | 'callContract' | 'createTransaction' | 'importAccount' | 'exit_accounts' | 'logout';
73+
waitResult?: boolean;
74+
}
75+
export interface IIframeData {
76+
type: 'event' | 'callback' | 'router' | 'default';
77+
data: unknown;
78+
success?: boolean;
79+
}
80+
export interface IIframeEventData {
81+
type: 'changeNetwork' | 'changeChain';
82+
data: unknown;
83+
}
84+
export declare type IRequestParams = IRequestParamsAccounts | {
85+
payload: IPayload;
86+
gatewayPayload?: IGatewayPayload;
87+
} | IPayload;
88+
export interface IRequestParamsAccounts {
89+
scopes: string[];
90+
[key: string]: unknown;
91+
}
92+
export interface IPayload {
93+
to: string;
94+
[key: string]: unknown;
95+
}
96+
export interface IGatewayPayload {
97+
[key: string]: unknown;
98+
}

dist/src/interface/provider.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });

dist/src/provider.d.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* @author Littleor <me@littleor.cn>
3+
* @since 2022/2/2
4+
*/
5+
import { IBaseProviderOptions, IProvider, IProviderConnectInfo, IProviderMessage, IProviderRpcError, IRequestArguments } from './interface/provider';
6+
import { ConsoleLike } from './utils/types';
7+
/**
8+
* AnyWeb Provider
9+
* @class Provider
10+
* @author Littleor
11+
* @since 2020/2/2
12+
* @example
13+
* const provider = new Provider()
14+
*/
15+
export declare class Provider implements IProvider {
16+
logger: ConsoleLike;
17+
readonly appId: string;
18+
private chainId;
19+
events: {
20+
onConnect?: (connectInfo: IProviderConnectInfo) => void;
21+
onDisconnect?: (error: IProviderRpcError) => void;
22+
onChainChanged?: (chainId: string) => void;
23+
onAccountsChanged?: (accounts: string[]) => void;
24+
onMessage?: (message: IProviderMessage) => void;
25+
onNetworkChanged?: (networkId: string) => void;
26+
};
27+
constructor({ logger, appId }: IBaseProviderOptions);
28+
/**
29+
* Deprecated: use `request` instead
30+
* @param arg
31+
*/
32+
send(...arg: any[]): Promise<unknown>;
33+
/**
34+
* Deprecated: use `request` instead
35+
* @param arg
36+
*/
37+
call(...arg: any[]): Promise<unknown>;
38+
/**
39+
* Submits an RPC request
40+
* @param args {IRequestArguments} Request Arguments: {method, params}
41+
* @returns {Promise<any>}
42+
* @example
43+
* const result = await provider.request({ method: 'cfx_sendTransaction', params})
44+
*/
45+
request(args: IRequestArguments): Promise<unknown>;
46+
/**
47+
* Deprecated: use `request` instead
48+
*/
49+
enable(): Promise<unknown>;
50+
/**
51+
* Submits an RPC request
52+
* @param method
53+
* @param params
54+
* @protected
55+
*/
56+
protected rawRequest(method: string, params?: any): Promise<unknown>;
57+
/**
58+
* Monitor information
59+
* @param type {string} Type of information
60+
* @param listener {Function} Event listener
61+
* @example
62+
* provider.on('connected', listener)
63+
*/
64+
on(type: string, listener: (...args: any[]) => void): void;
65+
}

0 commit comments

Comments
 (0)