@korajs/auth 0.3.0 → 0.3.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.cjs CHANGED
@@ -233,8 +233,9 @@ var AuthClient = class {
233
233
  method: "POST",
234
234
  body: params
235
235
  });
236
- this.storage.setTokens(response.accessToken, response.refreshToken);
237
- const user = await this.fetchUserProfile(response.accessToken);
236
+ const tokens = "tokens" in response ? response.tokens : response;
237
+ this.storage.setTokens(tokens.accessToken, tokens.refreshToken);
238
+ const user = await this.fetchUserProfile(tokens.accessToken);
238
239
  this.setState("authenticated", user);
239
240
  return user;
240
241
  }
@@ -250,8 +251,9 @@ var AuthClient = class {
250
251
  method: "POST",
251
252
  body: params
252
253
  });
253
- this.storage.setTokens(response.accessToken, response.refreshToken);
254
- const user = await this.fetchUserProfile(response.accessToken);
254
+ const tokens = "tokens" in response ? response.tokens : response;
255
+ this.storage.setTokens(tokens.accessToken, tokens.refreshToken);
256
+ const user = await this.fetchUserProfile(tokens.accessToken);
255
257
  this.setState("authenticated", user);
256
258
  return user;
257
259
  }
@@ -479,7 +481,8 @@ var AuthClient = class {
479
481
  { path, status: response.status, serverError }
480
482
  );
481
483
  }
482
- const data = await response.json();
484
+ const json = await response.json();
485
+ const data = json["data"] !== void 0 ? json["data"] : json;
483
486
  return data;
484
487
  }
485
488
  };