@blocklet/js-sdk 1.16.25-beta-e3dbef52 → 1.16.25-beta-be3a37f4

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.cjs CHANGED
@@ -10,15 +10,15 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
10
10
  const Cookie__default = /*#__PURE__*/_interopDefaultCompat(Cookie);
11
11
  const axios__default = /*#__PURE__*/_interopDefaultCompat(axios);
12
12
 
13
- var __defProp$1 = Object.defineProperty;
14
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15
- var __publicField$1 = (obj, key, value) => {
16
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
13
+ var __defProp$2 = Object.defineProperty;
14
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15
+ var __publicField$2 = (obj, key, value) => {
16
+ __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
17
17
  return value;
18
18
  };
19
19
  class AuthService {
20
20
  constructor({ api }) {
21
- __publicField$1(this, "api");
21
+ __publicField$2(this, "api");
22
22
  this.api = api;
23
23
  }
24
24
  async getUserPublicInfo({ did }) {
@@ -56,6 +56,12 @@ class AuthService {
56
56
  locale
57
57
  });
58
58
  }
59
+ async logout({ visitorId }) {
60
+ const { data } = await this.api.post("/api/user/logout", {
61
+ visitorId
62
+ });
63
+ return data;
64
+ }
59
65
  }
60
66
 
61
67
  class TokenService {
@@ -79,6 +85,27 @@ class TokenService {
79
85
  }
80
86
  }
81
87
 
88
+ var __defProp$1 = Object.defineProperty;
89
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
90
+ var __publicField$1 = (obj, key, value) => {
91
+ __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
92
+ return value;
93
+ };
94
+ class UserSessionService {
95
+ constructor({ api }) {
96
+ __publicField$1(this, "api");
97
+ this.api = api;
98
+ }
99
+ async getUserSessions({ did }) {
100
+ const { data } = await this.api.get("/api/user-session", {
101
+ params: {
102
+ userDid: did
103
+ }
104
+ });
105
+ return data;
106
+ }
107
+ }
108
+
82
109
  const version = "1.16.24";
83
110
 
84
111
  const sleep = (time = 0) => {
@@ -218,6 +245,7 @@ class BlockletSDK {
218
245
  constructor() {
219
246
  __publicField(this, "api");
220
247
  __publicField(this, "user");
248
+ __publicField(this, "userSession");
221
249
  __publicField(this, "token");
222
250
  const tokenService = new TokenService();
223
251
  const api = createRequest({
@@ -234,6 +262,7 @@ class BlockletSDK {
234
262
  }
235
263
  });
236
264
  this.user = new AuthService({ api });
265
+ this.userSession = new UserSessionService({ api });
237
266
  this.api = api;
238
267
  this.token = tokenService;
239
268
  }
package/dist/index.d.cts CHANGED
@@ -1,5 +1,10 @@
1
1
  import { Axios } from 'axios';
2
2
 
3
+ type UserPublicInfo = {
4
+ avatar: string;
5
+ did: string;
6
+ fullName: string;
7
+ };
3
8
  type Webhook = {
4
9
  type: 'slack' | 'api';
5
10
  url: string;
@@ -22,18 +27,23 @@ declare class AuthService {
22
27
  });
23
28
  getUserPublicInfo({ did }: {
24
29
  did: string;
25
- }): Promise<any>;
30
+ }): Promise<UserPublicInfo>;
26
31
  getUserPrivacyConfig({ did }: {
27
32
  did: string;
28
- }): Promise<any>;
29
- saveUserPrivacyConfig(config: PrivacyConfig): Promise<any>;
30
- getUserNotificationConfig(): Promise<any>;
31
- saveUserNotificationConfig(config: NotificationConfig): Promise<any>;
32
- testNotificationWebhook(webhook: Webhook): Promise<any>;
33
+ }): Promise<PrivacyConfig>;
34
+ saveUserPrivacyConfig(config: PrivacyConfig): Promise<PrivacyConfig>;
35
+ getUserNotificationConfig(): Promise<NotificationConfig>;
36
+ saveUserNotificationConfig(config: NotificationConfig): Promise<NotificationConfig>;
37
+ testNotificationWebhook(webhook: Webhook): Promise<{
38
+ success: boolean;
39
+ }>;
33
40
  getProfileUrl({ did, locale }: {
34
41
  did: string;
35
42
  locale: string;
36
43
  }): Promise<string>;
44
+ logout({ visitorId }: {
45
+ visitorId: string;
46
+ }): Promise<void>;
37
47
  }
38
48
 
39
49
  declare class TokenService {
@@ -45,11 +55,49 @@ declare class TokenService {
45
55
  removeRefreshToken(): void;
46
56
  }
47
57
 
48
- declare class BlockletSDK {
58
+ type UserSessionUser = {
59
+ avatar: string;
60
+ did: string;
61
+ email: string;
62
+ fullName: string;
63
+ pk: string;
64
+ remark?: string;
65
+ role: string;
66
+ roleTitle: string;
67
+ sourceAppPid: string | null;
68
+ sourceProvider: 'wallet' | 'auth0' | 'nft';
69
+ };
70
+ type UserSession = {
71
+ appName: string;
72
+ appPid: string;
73
+ extra: {
74
+ walletOS: 'android' | 'ios' | 'web';
75
+ };
76
+ id: string;
77
+ lastLoginIp: string;
78
+ passportId: string | null;
79
+ ua: string;
80
+ updatedAt: string;
81
+ user?: UserSessionUser;
82
+ userDid: string;
83
+ visitorId: string;
84
+ };
85
+ declare class UserSessionService {
49
86
  private api;
87
+ constructor({ api }: {
88
+ api: Axios;
89
+ });
90
+ getUserSessions({ did }: {
91
+ did: string;
92
+ }): Promise<UserSession[]>;
93
+ }
94
+
95
+ declare class BlockletSDK {
96
+ api: Axios;
50
97
  user: AuthService;
98
+ userSession: UserSessionService;
51
99
  token: TokenService;
52
100
  constructor();
53
101
  }
54
102
 
55
- export { BlockletSDK };
103
+ export { AuthService, BlockletSDK, type NotificationConfig, type PrivacyConfig, TokenService, type UserPublicInfo, type UserSession, UserSessionService, type UserSessionUser, type Webhook };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,10 @@
1
1
  import { Axios } from 'axios';
2
2
 
3
+ type UserPublicInfo = {
4
+ avatar: string;
5
+ did: string;
6
+ fullName: string;
7
+ };
3
8
  type Webhook = {
4
9
  type: 'slack' | 'api';
5
10
  url: string;
@@ -22,18 +27,23 @@ declare class AuthService {
22
27
  });
23
28
  getUserPublicInfo({ did }: {
24
29
  did: string;
25
- }): Promise<any>;
30
+ }): Promise<UserPublicInfo>;
26
31
  getUserPrivacyConfig({ did }: {
27
32
  did: string;
28
- }): Promise<any>;
29
- saveUserPrivacyConfig(config: PrivacyConfig): Promise<any>;
30
- getUserNotificationConfig(): Promise<any>;
31
- saveUserNotificationConfig(config: NotificationConfig): Promise<any>;
32
- testNotificationWebhook(webhook: Webhook): Promise<any>;
33
+ }): Promise<PrivacyConfig>;
34
+ saveUserPrivacyConfig(config: PrivacyConfig): Promise<PrivacyConfig>;
35
+ getUserNotificationConfig(): Promise<NotificationConfig>;
36
+ saveUserNotificationConfig(config: NotificationConfig): Promise<NotificationConfig>;
37
+ testNotificationWebhook(webhook: Webhook): Promise<{
38
+ success: boolean;
39
+ }>;
33
40
  getProfileUrl({ did, locale }: {
34
41
  did: string;
35
42
  locale: string;
36
43
  }): Promise<string>;
44
+ logout({ visitorId }: {
45
+ visitorId: string;
46
+ }): Promise<void>;
37
47
  }
38
48
 
39
49
  declare class TokenService {
@@ -45,11 +55,49 @@ declare class TokenService {
45
55
  removeRefreshToken(): void;
46
56
  }
47
57
 
48
- declare class BlockletSDK {
58
+ type UserSessionUser = {
59
+ avatar: string;
60
+ did: string;
61
+ email: string;
62
+ fullName: string;
63
+ pk: string;
64
+ remark?: string;
65
+ role: string;
66
+ roleTitle: string;
67
+ sourceAppPid: string | null;
68
+ sourceProvider: 'wallet' | 'auth0' | 'nft';
69
+ };
70
+ type UserSession = {
71
+ appName: string;
72
+ appPid: string;
73
+ extra: {
74
+ walletOS: 'android' | 'ios' | 'web';
75
+ };
76
+ id: string;
77
+ lastLoginIp: string;
78
+ passportId: string | null;
79
+ ua: string;
80
+ updatedAt: string;
81
+ user?: UserSessionUser;
82
+ userDid: string;
83
+ visitorId: string;
84
+ };
85
+ declare class UserSessionService {
49
86
  private api;
87
+ constructor({ api }: {
88
+ api: Axios;
89
+ });
90
+ getUserSessions({ did }: {
91
+ did: string;
92
+ }): Promise<UserSession[]>;
93
+ }
94
+
95
+ declare class BlockletSDK {
96
+ api: Axios;
50
97
  user: AuthService;
98
+ userSession: UserSessionService;
51
99
  token: TokenService;
52
100
  constructor();
53
101
  }
54
102
 
55
- export { BlockletSDK };
103
+ export { AuthService, BlockletSDK, type NotificationConfig, type PrivacyConfig, TokenService, type UserPublicInfo, type UserSession, UserSessionService, type UserSessionUser, type Webhook };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  import { Axios } from 'axios';
2
2
 
3
+ type UserPublicInfo = {
4
+ avatar: string;
5
+ did: string;
6
+ fullName: string;
7
+ };
3
8
  type Webhook = {
4
9
  type: 'slack' | 'api';
5
10
  url: string;
@@ -22,18 +27,23 @@ declare class AuthService {
22
27
  });
23
28
  getUserPublicInfo({ did }: {
24
29
  did: string;
25
- }): Promise<any>;
30
+ }): Promise<UserPublicInfo>;
26
31
  getUserPrivacyConfig({ did }: {
27
32
  did: string;
28
- }): Promise<any>;
29
- saveUserPrivacyConfig(config: PrivacyConfig): Promise<any>;
30
- getUserNotificationConfig(): Promise<any>;
31
- saveUserNotificationConfig(config: NotificationConfig): Promise<any>;
32
- testNotificationWebhook(webhook: Webhook): Promise<any>;
33
+ }): Promise<PrivacyConfig>;
34
+ saveUserPrivacyConfig(config: PrivacyConfig): Promise<PrivacyConfig>;
35
+ getUserNotificationConfig(): Promise<NotificationConfig>;
36
+ saveUserNotificationConfig(config: NotificationConfig): Promise<NotificationConfig>;
37
+ testNotificationWebhook(webhook: Webhook): Promise<{
38
+ success: boolean;
39
+ }>;
33
40
  getProfileUrl({ did, locale }: {
34
41
  did: string;
35
42
  locale: string;
36
43
  }): Promise<string>;
44
+ logout({ visitorId }: {
45
+ visitorId: string;
46
+ }): Promise<void>;
37
47
  }
38
48
 
39
49
  declare class TokenService {
@@ -45,11 +55,49 @@ declare class TokenService {
45
55
  removeRefreshToken(): void;
46
56
  }
47
57
 
48
- declare class BlockletSDK {
58
+ type UserSessionUser = {
59
+ avatar: string;
60
+ did: string;
61
+ email: string;
62
+ fullName: string;
63
+ pk: string;
64
+ remark?: string;
65
+ role: string;
66
+ roleTitle: string;
67
+ sourceAppPid: string | null;
68
+ sourceProvider: 'wallet' | 'auth0' | 'nft';
69
+ };
70
+ type UserSession = {
71
+ appName: string;
72
+ appPid: string;
73
+ extra: {
74
+ walletOS: 'android' | 'ios' | 'web';
75
+ };
76
+ id: string;
77
+ lastLoginIp: string;
78
+ passportId: string | null;
79
+ ua: string;
80
+ updatedAt: string;
81
+ user?: UserSessionUser;
82
+ userDid: string;
83
+ visitorId: string;
84
+ };
85
+ declare class UserSessionService {
49
86
  private api;
87
+ constructor({ api }: {
88
+ api: Axios;
89
+ });
90
+ getUserSessions({ did }: {
91
+ did: string;
92
+ }): Promise<UserSession[]>;
93
+ }
94
+
95
+ declare class BlockletSDK {
96
+ api: Axios;
50
97
  user: AuthService;
98
+ userSession: UserSessionService;
51
99
  token: TokenService;
52
100
  constructor();
53
101
  }
54
102
 
55
- export { BlockletSDK };
103
+ export { AuthService, BlockletSDK, type NotificationConfig, type PrivacyConfig, TokenService, type UserPublicInfo, type UserSession, UserSessionService, type UserSessionUser, type Webhook };
package/dist/index.mjs CHANGED
@@ -3,15 +3,15 @@ import { withQuery } from 'ufo';
3
3
  import Cookie from 'js-cookie';
4
4
  import axios from 'axios';
5
5
 
6
- var __defProp$1 = Object.defineProperty;
7
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __publicField$1 = (obj, key, value) => {
9
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
6
+ var __defProp$2 = Object.defineProperty;
7
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __publicField$2 = (obj, key, value) => {
9
+ __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
10
10
  return value;
11
11
  };
12
12
  class AuthService {
13
13
  constructor({ api }) {
14
- __publicField$1(this, "api");
14
+ __publicField$2(this, "api");
15
15
  this.api = api;
16
16
  }
17
17
  async getUserPublicInfo({ did }) {
@@ -49,6 +49,12 @@ class AuthService {
49
49
  locale
50
50
  });
51
51
  }
52
+ async logout({ visitorId }) {
53
+ const { data } = await this.api.post("/api/user/logout", {
54
+ visitorId
55
+ });
56
+ return data;
57
+ }
52
58
  }
53
59
 
54
60
  class TokenService {
@@ -72,6 +78,27 @@ class TokenService {
72
78
  }
73
79
  }
74
80
 
81
+ var __defProp$1 = Object.defineProperty;
82
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
83
+ var __publicField$1 = (obj, key, value) => {
84
+ __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
85
+ return value;
86
+ };
87
+ class UserSessionService {
88
+ constructor({ api }) {
89
+ __publicField$1(this, "api");
90
+ this.api = api;
91
+ }
92
+ async getUserSessions({ did }) {
93
+ const { data } = await this.api.get("/api/user-session", {
94
+ params: {
95
+ userDid: did
96
+ }
97
+ });
98
+ return data;
99
+ }
100
+ }
101
+
75
102
  const version = "1.16.24";
76
103
 
77
104
  const sleep = (time = 0) => {
@@ -211,6 +238,7 @@ class BlockletSDK {
211
238
  constructor() {
212
239
  __publicField(this, "api");
213
240
  __publicField(this, "user");
241
+ __publicField(this, "userSession");
214
242
  __publicField(this, "token");
215
243
  const tokenService = new TokenService();
216
244
  const api = createRequest({
@@ -227,6 +255,7 @@ class BlockletSDK {
227
255
  }
228
256
  });
229
257
  this.user = new AuthService({ api });
258
+ this.userSession = new UserSessionService({ api });
230
259
  this.api = api;
231
260
  this.token = tokenService;
232
261
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/js-sdk",
3
- "version": "1.16.25-beta-e3dbef52",
3
+ "version": "1.16.25-beta-be3a37f4",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -31,7 +31,7 @@
31
31
  "build": "unbuild"
32
32
  },
33
33
  "dependencies": {
34
- "@abtnode/constant": "1.16.25-beta-e3dbef52",
34
+ "@abtnode/constant": "1.16.25-beta-be3a37f4",
35
35
  "axios": "^0.27.2",
36
36
  "js-cookie": "^3.0.5",
37
37
  "ufo": "^1.3.2"
@@ -39,5 +39,5 @@
39
39
  "devDependencies": {
40
40
  "unbuild": "^2.0.0"
41
41
  },
42
- "gitHead": "a740380dd98d1677f7da1233d753f28ea50f77ce"
42
+ "gitHead": "cd99ea556cdd402ecc12e017d79f13e8e8bb83c7"
43
43
  }