lxns-rhythm-api 0.1.13 → 0.1.14

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
@@ -1597,6 +1597,28 @@ const LXNS_HTTP_OPTIONS = {
1597
1597
  throwHttpErrors: true,
1598
1598
  hooks: { beforeError: [wrapKyError] }
1599
1599
  };
1600
+ async function wrapOAuthError(error) {
1601
+ const status = error.response.status;
1602
+ let body;
1603
+ try {
1604
+ body = await error.response.clone().json();
1605
+ } catch {}
1606
+ if (body && typeof body.error === "string") throw new LxnsApiError({
1607
+ success: false,
1608
+ code: status,
1609
+ message: body.error_description ?? body.error,
1610
+ data: { ...body }
1611
+ }, status);
1612
+ throw new LxnsApiError({
1613
+ success: false,
1614
+ code: status,
1615
+ message: error.message
1616
+ }, status);
1617
+ }
1618
+ const LXNS_OAUTH_TOKEN_HTTP_OPTIONS = {
1619
+ throwHttpErrors: true,
1620
+ hooks: { beforeError: [wrapOAuthError] }
1621
+ };
1600
1622
  //#endregion
1601
1623
  //#region src/client/lxns-api-client.ts
1602
1624
  var LxnsApiClient = class {
@@ -1690,7 +1712,7 @@ var LxnsOAuthClient = class {
1690
1712
  };
1691
1713
  this.http = ky.create({
1692
1714
  prefixUrl: new URL("oauth/", this.config.baseURL),
1693
- ...LXNS_HTTP_OPTIONS
1715
+ ...LXNS_OAUTH_TOKEN_HTTP_OPTIONS
1694
1716
  });
1695
1717
  }
1696
1718
  /**
package/dist/index.mjs CHANGED
@@ -1585,6 +1585,28 @@ const LXNS_HTTP_OPTIONS = {
1585
1585
  throwHttpErrors: true,
1586
1586
  hooks: { beforeError: [wrapKyError] }
1587
1587
  };
1588
+ async function wrapOAuthError(error) {
1589
+ const status = error.response.status;
1590
+ let body;
1591
+ try {
1592
+ body = await error.response.clone().json();
1593
+ } catch {}
1594
+ if (body && typeof body.error === "string") throw new LxnsApiError({
1595
+ success: false,
1596
+ code: status,
1597
+ message: body.error_description ?? body.error,
1598
+ data: { ...body }
1599
+ }, status);
1600
+ throw new LxnsApiError({
1601
+ success: false,
1602
+ code: status,
1603
+ message: error.message
1604
+ }, status);
1605
+ }
1606
+ const LXNS_OAUTH_TOKEN_HTTP_OPTIONS = {
1607
+ throwHttpErrors: true,
1608
+ hooks: { beforeError: [wrapOAuthError] }
1609
+ };
1588
1610
  //#endregion
1589
1611
  //#region src/client/lxns-api-client.ts
1590
1612
  var LxnsApiClient = class {
@@ -1678,7 +1700,7 @@ var LxnsOAuthClient = class {
1678
1700
  };
1679
1701
  this.http = ky.create({
1680
1702
  prefixUrl: new URL("oauth/", this.config.baseURL),
1681
- ...LXNS_HTTP_OPTIONS
1703
+ ...LXNS_OAUTH_TOKEN_HTTP_OPTIONS
1682
1704
  });
1683
1705
  }
1684
1706
  /**
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "api-client"
13
13
  ],
14
14
  "author": "amatsuka <amatsukamao@qq.com>",
15
- "version": "0.1.13",
15
+ "version": "0.1.14",
16
16
  "license": "MIT",
17
17
  "repository": {
18
18
  "type": "git",