zigap-utils 0.0.2 → 0.0.6
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/README.md +82 -24
- package/package.json +8 -3
- package/dist/App.d.ts +0 -2
- package/dist/components/AddressProvideQR/AddressProvideQR.d.ts +0 -4
- package/dist/components/AddressProvideQR/AddressProvideQR.types.d.ts +0 -14
- package/dist/components/AddressProvideQR/index.d.ts +0 -2
- package/dist/components/LoginQR/LoginQR.d.ts +0 -4
- package/dist/components/LoginQR/LoginQR.types.d.ts +0 -15
- package/dist/components/LoginQR/index.d.ts +0 -2
- package/dist/components/index.d.ts +0 -2
- package/dist/index.cjs.js +0 -56
- package/dist/index.d.ts +0 -1
- package/dist/index.es.js +0 -16505
- package/dist/main.d.ts +0 -1
- package/dist/util/addressProvide.d.ts +0 -9
- package/dist/util/cryptoUtils.d.ts +0 -18
- package/dist/util/login.d.ts +0 -11
- package/dist/util/qrService.d.ts +0 -7
- package/dist/util/socketInstance.d.ts +0 -9
- package/dist/util/types.d.ts +0 -16
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# zigap-utils
|
|
2
2
|
|
|
3
|
-
It is a library that collects utils that help communicate between dapp and zigap.
|
|
3
|
+
It is a library that collects utils that help communicate between dapp and zigap.<br /> You can find out more at https://seoul-labs.gitbook.io/zigap-utils
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```
|
|
8
|
-
npm i zigap-utils
|
|
8
|
+
npm i zigap-utils
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
@@ -19,11 +19,19 @@ const App = () => {
|
|
|
19
19
|
return (
|
|
20
20
|
<div>
|
|
21
21
|
<LoginQR
|
|
22
|
-
|
|
22
|
+
dapp='yourDappName'
|
|
23
|
+
url='http://sample.yours.com'
|
|
24
|
+
availableNetworks={['xphere']}
|
|
25
|
+
isShowLogo={false}
|
|
26
|
+
logoSize={25}
|
|
27
|
+
validSeconds={600}
|
|
23
28
|
sigMessage="hello world"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
expire={{ type: 'EXTEND', seconds: 3600 }}
|
|
30
|
+
icon="http://sample.icon-url.com"
|
|
31
|
+
onReceive={({ status }) => {
|
|
32
|
+
if(status === 'SUCCESS') {
|
|
33
|
+
// something to do after login (refresh page...)
|
|
34
|
+
// status type: 'REQUEST' | 'ACCOUNT' | 'SUCCESS' | 'ERROR'
|
|
27
35
|
}
|
|
28
36
|
}}
|
|
29
37
|
/>
|
|
@@ -38,26 +46,76 @@ const App = () => {
|
|
|
38
46
|
|
|
39
47
|
### `LoginQR` props
|
|
40
48
|
|
|
41
|
-
| prop
|
|
42
|
-
|
|
|
43
|
-
| `
|
|
44
|
-
| `
|
|
45
|
-
| `
|
|
46
|
-
| `
|
|
47
|
-
| `
|
|
48
|
-
| `
|
|
49
|
-
| `
|
|
49
|
+
| prop | type | description |
|
|
50
|
+
| --- | --- | --- |
|
|
51
|
+
| `dapp` | string | Name of the dapp to use |
|
|
52
|
+
| `url` | string | The url of dapp to connect |
|
|
53
|
+
| `availableNetworks` | string[] | List of connectable networks in dapp |
|
|
54
|
+
| `sigMessage` | string | Messages signed to verify the identity of the user |
|
|
55
|
+
| `validSeconds` | number | QR code valid time(minutes) |
|
|
56
|
+
| `onReceive` | (res) => void | Function called after login request |
|
|
57
|
+
| `expire` | {type: "NONE / FIX / EXTEND", seconds: number} | time and type for user login to expire |
|
|
58
|
+
| `icon` | string | Your dapp icon url to be displayed on zigap app |
|
|
59
|
+
| `processingMark` | {type: "DEFAULT" / "CUSTOM" / "NONE", component: React.ReactNode} | How to show the QR image when it's being processed |
|
|
50
60
|
|
|
51
61
|
<br>
|
|
52
62
|
|
|
53
63
|
### `AddressProvideQR` props
|
|
54
64
|
|
|
55
|
-
| prop
|
|
56
|
-
|
|
|
57
|
-
| `
|
|
58
|
-
| `
|
|
59
|
-
| `
|
|
60
|
-
| `
|
|
61
|
-
| `
|
|
62
|
-
| `
|
|
63
|
-
|
|
65
|
+
| prop type | type | description |
|
|
66
|
+
| ------------------- | ------------- | ----------------------------------------------- |
|
|
67
|
+
| `dapp` | string | Name of the dapp to use |
|
|
68
|
+
| `url` | string | The url of dapp to connect |
|
|
69
|
+
| `availableNetworks` | string[] | List of connectable networks in dapp |
|
|
70
|
+
| `validSeconds` | number | QR code valid time(seconds) |
|
|
71
|
+
| `onReceive` | (res) => void | Function called after login request |
|
|
72
|
+
| `icon` | string | Your dapp icon url to be displayed on zigap app |
|
|
73
|
+
|
|
74
|
+
<br>
|
|
75
|
+
|
|
76
|
+
### `CommonStyle` props (optional)
|
|
77
|
+
|
|
78
|
+
| prop | type | default value | description |
|
|
79
|
+
| ------------ | ------------- | ------------- | --------------------------------------- |
|
|
80
|
+
| `size` | number | 128 | canvas width |
|
|
81
|
+
| `bgColor` | string | #fff | background color |
|
|
82
|
+
| `fgColor` | string | #000 | foreground color |
|
|
83
|
+
| `style` | CSSProperties | | custom css style |
|
|
84
|
+
| `isShowLogo` | boolean | false | Zigap logo in the middle of the QR code |
|
|
85
|
+
| `logoSize` | number | 30 | logo width & height |
|
|
86
|
+
|
|
87
|
+
<br>
|
|
88
|
+
|
|
89
|
+
### `useZigap`
|
|
90
|
+
|
|
91
|
+
useZigap is a hook that fetches the information of the logged-in user in the zigap app and provides a logout function.
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
import { useZigap } from 'zigap-utils';
|
|
95
|
+
|
|
96
|
+
...
|
|
97
|
+
|
|
98
|
+
const Component = () => {
|
|
99
|
+
const { userInfo, logout, isWindowLoaded } = useZigap();
|
|
100
|
+
|
|
101
|
+
const handleLogout = () => {
|
|
102
|
+
if(isWindowLoaded) {
|
|
103
|
+
logout();
|
|
104
|
+
window.location.reload();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<div>
|
|
110
|
+
<p>Address: {userInfo.address}</p>
|
|
111
|
+
<p>Network: {userInfo.network}</p>
|
|
112
|
+
<p>Nickname: {userInfo.nickName}</p>
|
|
113
|
+
<p>Token: {userInfo.token}</p>
|
|
114
|
+
<p>Issued DateTime: {userInfo.issuedDateTime}</p>
|
|
115
|
+
<p>Expire DateTime: {userInfo.expireDateTime}</p>
|
|
116
|
+
|
|
117
|
+
<button onClick={handleLogout}> LOGOUT </button>
|
|
118
|
+
</div>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
```
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zigap-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.es.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"author": "Seoullabs",
|
|
8
8
|
"license": "ISC",
|
|
9
|
+
"homepage": "https://seoul-labs.gitbook.io/zigap-utils",
|
|
9
10
|
"repository": {
|
|
10
11
|
"type": "git",
|
|
11
12
|
"url": "https://github.com/Seoullabs-official/zigap-utils"
|
|
@@ -16,15 +17,19 @@
|
|
|
16
17
|
"scripts": {
|
|
17
18
|
"preinstall": "npx only-allow pnpm",
|
|
18
19
|
"dev": "vite",
|
|
19
|
-
"build": "rm -rf dist && tsc -p ./tsconfig.node.json && vite build",
|
|
20
|
+
"build": "rm -rf dist && tsc -p ./tsconfig.node.json && tsx ./src/preprocessEnv.js && vite build",
|
|
20
21
|
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
21
22
|
"preview": "vite preview"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
25
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
26
|
+
"dayjs": "^1.11.11",
|
|
27
|
+
"dotenv": "^16.4.5",
|
|
24
28
|
"react": "^18.2.0",
|
|
25
29
|
"react-dom": "^18.2.0",
|
|
26
|
-
"saseul": "^2.8.0",
|
|
27
30
|
"styled-components": "^6.1.11",
|
|
31
|
+
"tsx": "^4.16.2",
|
|
32
|
+
"tweetnacl": "^1.0.3",
|
|
28
33
|
"vite-plugin-commonjs": "^0.10.1"
|
|
29
34
|
},
|
|
30
35
|
"devDependencies": {
|
package/dist/App.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { CSSProperties } from 'react';
|
|
2
|
-
|
|
3
|
-
export type AddressProvideResultType = {
|
|
4
|
-
isSuccess: boolean;
|
|
5
|
-
address?: string;
|
|
6
|
-
};
|
|
7
|
-
export type AddressProvideQRProps = {
|
|
8
|
-
validTime: number;
|
|
9
|
-
onReceive: (result: AddressProvideResultType) => void;
|
|
10
|
-
size?: number;
|
|
11
|
-
bgColor?: string;
|
|
12
|
-
fgColor?: string;
|
|
13
|
-
style?: CSSProperties;
|
|
14
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { CSSProperties } from 'react';
|
|
2
|
-
|
|
3
|
-
export type LoginResultType = {
|
|
4
|
-
isSuccess: boolean;
|
|
5
|
-
address?: string;
|
|
6
|
-
};
|
|
7
|
-
export type LoginQRProps = {
|
|
8
|
-
sigMessage: string;
|
|
9
|
-
validTime: number;
|
|
10
|
-
onReceive: (result: LoginResultType) => void;
|
|
11
|
-
size?: number;
|
|
12
|
-
bgColor?: string;
|
|
13
|
-
fgColor?: string;
|
|
14
|
-
style?: CSSProperties;
|
|
15
|
-
};
|