@blocklet/sdk 1.16.13-beta-ef672597 → 1.16.13-beta-0086a35d

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.
@@ -10,6 +10,14 @@ interface AuthService {
10
10
  login: (params: object) => Promise<{
11
11
  user: Object;
12
12
  token: string;
13
+ refreshToken: string;
14
+ }>;
15
+ refreshSession: (params: {
16
+ refreshToken: string;
17
+ }) => Promise<{
18
+ user: Object;
19
+ token: string;
20
+ refreshToken: string;
13
21
  }>;
14
22
  getUser(did: string, options?: {
15
23
  enableConnectedAccount?: boolean;
@@ -64,6 +64,7 @@ class AuthService {
64
64
  const apiList = [
65
65
  // user
66
66
  'login',
67
+ 'refreshSession',
67
68
  'getUsers',
68
69
  'getUser',
69
70
  'getOwner',
@@ -146,6 +147,25 @@ class AuthService {
146
147
  throw new Error(err.response ? err.response.data : err.message);
147
148
  }
148
149
  };
150
+ this.refreshSession = async (data) => {
151
+ try {
152
+ const { data: resData } = await service_api_1.default.post('/api/did/refreshSession', {
153
+ refresh_token: data.refreshToken,
154
+ });
155
+ if (resData?.user) {
156
+ fixAvatar(resData.user);
157
+ }
158
+ return {
159
+ user: resData.user,
160
+ token: resData.nextToken,
161
+ refreshToken: resData?.nextRefreshToken,
162
+ };
163
+ }
164
+ catch (err) {
165
+ console.error(err.response ? err.response.data : err);
166
+ throw new Error(err.response ? err.response.data : err.message);
167
+ }
168
+ };
149
169
  // eslint-disable-next-line no-constructor-return
150
170
  return new Proxy(this, {
151
171
  get(target, propKey) {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.13-beta-ef672597",
6
+ "version": "1.16.13-beta-0086a35d",
7
7
  "description": "graphql client to read/write data on abt node",
8
8
  "main": "lib/index.js",
9
9
  "typings": "lib/index.d.ts",
@@ -26,15 +26,15 @@
26
26
  "author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
27
27
  "license": "Apache-2.0",
28
28
  "dependencies": {
29
- "@abtnode/client": "1.16.13-beta-ef672597",
30
- "@abtnode/constant": "1.16.13-beta-ef672597",
29
+ "@abtnode/client": "1.16.13-beta-0086a35d",
30
+ "@abtnode/constant": "1.16.13-beta-0086a35d",
31
31
  "@arcblock/did": "1.18.84",
32
32
  "@arcblock/did-auth": "1.18.84",
33
33
  "@arcblock/jwt": "1.18.84",
34
34
  "@arcblock/ws": "1.18.84",
35
- "@blocklet/constant": "1.16.13-beta-ef672597",
36
- "@blocklet/env": "1.16.13-beta-ef672597",
37
- "@blocklet/meta": "1.16.13-beta-ef672597",
35
+ "@blocklet/constant": "1.16.13-beta-0086a35d",
36
+ "@blocklet/env": "1.16.13-beta-0086a35d",
37
+ "@blocklet/meta": "1.16.13-beta-0086a35d",
38
38
  "@did-connect/authenticator": "^2.1.59",
39
39
  "@did-connect/handler": "^2.1.59",
40
40
  "@nedb/core": "^2.1.5",
@@ -73,5 +73,5 @@
73
73
  "ts-node": "^10.9.1",
74
74
  "typescript": "^5.0.4"
75
75
  },
76
- "gitHead": "ed5abea5072dee26860ed43139bfee17461b19a1"
76
+ "gitHead": "cbf5c99e7cadf9fef4d77673cb45b44ef26436cf"
77
77
  }