@spacelr/sdk 0.8.1 → 0.9.1

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.mjs CHANGED
@@ -1261,6 +1261,16 @@ function localStorageCursorStorage(prefix = "spacelr:cursor:") {
1261
1261
  }
1262
1262
 
1263
1263
  // libs/sdk/src/modules/auth.module.ts
1264
+ function mapProfile(u) {
1265
+ const name = u.name ?? ([u.firstName, u.lastName].filter(Boolean).join(" ") || void 0) ?? u.displayName;
1266
+ return {
1267
+ id: u.id ?? u._id ?? u.userId ?? u.sub ?? "",
1268
+ email: u.email ?? "",
1269
+ username: u.username,
1270
+ name,
1271
+ roles: u.roles ?? []
1272
+ };
1273
+ }
1264
1274
  var AuthModule = class {
1265
1275
  constructor(http, tokenManager, config) {
1266
1276
  this.stateListeners = /* @__PURE__ */ new Set();
@@ -1384,11 +1394,12 @@ var AuthModule = class {
1384
1394
  });
1385
1395
  }
1386
1396
  async getProfile() {
1387
- return this.http.request({
1397
+ const data = await this.http.request({
1388
1398
  method: "GET",
1389
1399
  path: "/auth/me",
1390
1400
  authenticated: true
1391
1401
  });
1402
+ return mapProfile(data.user ?? data);
1392
1403
  }
1393
1404
  async logout() {
1394
1405
  try {
@@ -3056,6 +3067,9 @@ function createClient(config) {
3056
3067
  onTokenRefreshed(listener) {
3057
3068
  return tokenManager.onTokenRefreshed(listener);
3058
3069
  },
3070
+ getAccessToken() {
3071
+ return tokenManager.getAccessToken();
3072
+ },
3059
3073
  onConnectionStateChanged(listener) {
3060
3074
  return realtime.onConnectionStateChanged(listener);
3061
3075
  },