@blocklet/js-sdk 1.16.33-beta-20241023-050633-f64145a7 → 1.16.33-beta-20241028-005826-60afb7c4

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.d.mts CHANGED
@@ -112,6 +112,7 @@ type Blocklet = {
112
112
  appLogo: string;
113
113
  appLogoRect: string;
114
114
  appUrl: string;
115
+ domainAliases?: string[];
115
116
  isComponent: boolean;
116
117
  prefix: string;
117
118
  groupPrefix: string;
@@ -181,8 +182,17 @@ declare class UserSessionService {
181
182
  api: Axios;
182
183
  blocklet?: BlockletService;
183
184
  });
184
- getUserSessions({ did }: {
185
+ getBaseUrl(appUrl?: string): string | undefined;
186
+ getUserSessions({ did, appUrl }: {
185
187
  did: string;
188
+ appUrl?: string;
189
+ }): Promise<UserSession[]>;
190
+ loginByUserSession({ appPid, userDid, visitorId, passportId, appUrl, }: {
191
+ appPid: string;
192
+ userDid: string;
193
+ visitorId: string;
194
+ passportId: string;
195
+ appUrl?: string;
186
196
  }): Promise<UserSession[]>;
187
197
  }
188
198
 
@@ -208,5 +218,6 @@ declare class BlockletSDK {
208
218
  }
209
219
  declare function createAxios(config?: AxiosRequestConfig, requestParams?: RequestParams): axios.AxiosInstance;
210
220
  declare function createFetch(options?: RequestInit, requestParams?: RequestParams): (input: string | Request | URL, options?: RequestInit) => Promise<Response>;
221
+ declare const getBlockletSDK: () => BlockletSDK;
211
222
 
212
- export { AuthService, BlockletSDK, BlockletService, ComponentService, type NotificationConfig, type PrivacyConfig, TokenService, type UserPublicInfo, type UserSession, UserSessionService, type UserSessionUser, type Webhook, createAxios, createFetch, getCSRFToken };
223
+ export { AuthService, BlockletSDK, BlockletService, ComponentService, type NotificationConfig, type PrivacyConfig, TokenService, type UserPublicInfo, type UserSession, UserSessionService, type UserSessionUser, type Webhook, createAxios, createFetch, getBlockletSDK, getCSRFToken };
package/dist/index.d.ts CHANGED
@@ -112,6 +112,7 @@ type Blocklet = {
112
112
  appLogo: string;
113
113
  appLogoRect: string;
114
114
  appUrl: string;
115
+ domainAliases?: string[];
115
116
  isComponent: boolean;
116
117
  prefix: string;
117
118
  groupPrefix: string;
@@ -181,8 +182,17 @@ declare class UserSessionService {
181
182
  api: Axios;
182
183
  blocklet?: BlockletService;
183
184
  });
184
- getUserSessions({ did }: {
185
+ getBaseUrl(appUrl?: string): string | undefined;
186
+ getUserSessions({ did, appUrl }: {
185
187
  did: string;
188
+ appUrl?: string;
189
+ }): Promise<UserSession[]>;
190
+ loginByUserSession({ appPid, userDid, visitorId, passportId, appUrl, }: {
191
+ appPid: string;
192
+ userDid: string;
193
+ visitorId: string;
194
+ passportId: string;
195
+ appUrl?: string;
186
196
  }): Promise<UserSession[]>;
187
197
  }
188
198
 
@@ -208,5 +218,6 @@ declare class BlockletSDK {
208
218
  }
209
219
  declare function createAxios(config?: AxiosRequestConfig, requestParams?: RequestParams): axios.AxiosInstance;
210
220
  declare function createFetch(options?: RequestInit, requestParams?: RequestParams): (input: string | Request | URL, options?: RequestInit) => Promise<Response>;
221
+ declare const getBlockletSDK: () => BlockletSDK;
211
222
 
212
- export { AuthService, BlockletSDK, BlockletService, ComponentService, type NotificationConfig, type PrivacyConfig, TokenService, type UserPublicInfo, type UserSession, UserSessionService, type UserSessionUser, type Webhook, createAxios, createFetch, getCSRFToken };
223
+ export { AuthService, BlockletSDK, BlockletService, ComponentService, type NotificationConfig, type PrivacyConfig, TokenService, type UserPublicInfo, type UserSession, UserSessionService, type UserSessionUser, type Webhook, createAxios, createFetch, getBlockletSDK, getCSRFToken };
package/dist/index.mjs CHANGED
@@ -163,9 +163,14 @@ class UserSessionService {
163
163
  this.api = api;
164
164
  this.blocklet = blocklet || new BlockletService();
165
165
  }
166
- async getUserSessions({ did }) {
166
+ getBaseUrl(appUrl) {
167
+ return appUrl ? joinURL(appUrl, WELLKNOWN_SERVICE_PATH_PREFIX) : void 0;
168
+ }
169
+ async getUserSessions({ did, appUrl }) {
170
+ const baseURL = this.getBaseUrl(appUrl);
167
171
  const blocklet = await this.blocklet.getBlocklet();
168
172
  const { data } = await this.api.get("/api/user-session", {
173
+ baseURL,
169
174
  params: {
170
175
  userDid: did,
171
176
  appPid: blocklet.appPid
@@ -173,6 +178,26 @@ class UserSessionService {
173
178
  });
174
179
  return data;
175
180
  }
181
+ async loginByUserSession({
182
+ appPid,
183
+ userDid,
184
+ visitorId,
185
+ passportId,
186
+ appUrl
187
+ }) {
188
+ const baseURL = this.getBaseUrl(appUrl);
189
+ const { data } = await this.api.post(
190
+ "/api/user-session/login",
191
+ {
192
+ appPid,
193
+ userDid,
194
+ visitorId,
195
+ passportId
196
+ },
197
+ { baseURL }
198
+ );
199
+ return data;
200
+ }
176
201
  }
177
202
 
178
203
  var __defProp$1 = Object.defineProperty;
@@ -560,5 +585,14 @@ function createFetch(options, requestParams) {
560
585
  requestParams
561
586
  );
562
587
  }
588
+ const getBlockletSDK = /* @__PURE__ */ (() => {
589
+ let instance;
590
+ return () => {
591
+ if (!instance) {
592
+ instance = new BlockletSDK();
593
+ }
594
+ return instance;
595
+ };
596
+ })();
563
597
 
564
- export { BlockletSDK, createAxios, createFetch, getCSRFToken };
598
+ export { BlockletSDK, createAxios, createFetch, getBlockletSDK, getCSRFToken };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/js-sdk",
3
- "version": "1.16.33-beta-20241023-050633-f64145a7",
3
+ "version": "1.16.33-beta-20241028-005826-60afb7c4",
4
4
  "main": "dist/index.mjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -32,8 +32,8 @@
32
32
  "watch": "nodemon -w src -e ts -x 'npm run build'"
33
33
  },
34
34
  "dependencies": {
35
- "@abtnode/constant": "1.16.33-beta-20241023-050633-f64145a7",
36
- "@blocklet/meta": "1.16.33-beta-20241023-050633-f64145a7",
35
+ "@abtnode/constant": "1.16.33-beta-20241028-005826-60afb7c4",
36
+ "@blocklet/meta": "1.16.33-beta-20241028-005826-60afb7c4",
37
37
  "axios": "^1.7.5",
38
38
  "is-url": "^1.2.4",
39
39
  "js-cookie": "^3.0.5",
@@ -45,5 +45,5 @@
45
45
  "unbuild": "^2.0.0",
46
46
  "vitest": "^2.0.5"
47
47
  },
48
- "gitHead": "ed8130f55cb68a23c72ea0fd58c2bad38de18719"
48
+ "gitHead": "12b595141a023fe3c3fdb2d7083b3f11624601e8"
49
49
  }