@logto/js 2.1.0 → 2.1.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.
@@ -2,7 +2,6 @@
2
2
 
3
3
  var essentials = require('@silverhand/essentials');
4
4
  var arbitraryObject = require('./arbitrary-object.cjs');
5
- var errors = require('./errors.cjs');
6
5
 
7
6
  // https://docs.logto.io/docs/recipes/protect-your-api/
8
7
  function assertAccessTokenClaims(data) {
@@ -29,7 +28,8 @@ function assertAccessTokenClaims(data) {
29
28
  const decodeAccessToken = (accessToken) => {
30
29
  const { 1: encodedPayload } = accessToken.split('.');
31
30
  if (!encodedPayload) {
32
- throw new errors.LogtoError('access_token.invalid_token');
31
+ // Non-JWT format token string
32
+ return {};
33
33
  }
34
34
  const json = essentials.urlSafeBase64.decode(encodedPayload);
35
35
  const accessTokenClaims = JSON.parse(json);
@@ -1,6 +1,5 @@
1
1
  import { urlSafeBase64 } from '@silverhand/essentials';
2
2
  import { isArbitraryObject } from './arbitrary-object.js';
3
- import { LogtoError } from './errors.js';
4
3
 
5
4
  // https://docs.logto.io/docs/recipes/protect-your-api/
6
5
  function assertAccessTokenClaims(data) {
@@ -27,7 +26,8 @@ function assertAccessTokenClaims(data) {
27
26
  const decodeAccessToken = (accessToken) => {
28
27
  const { 1: encodedPayload } = accessToken.split('.');
29
28
  if (!encodedPayload) {
30
- throw new LogtoError('access_token.invalid_token');
29
+ // Non-JWT format token string
30
+ return {};
31
31
  }
32
32
  const json = urlSafeBase64.decode(encodedPayload);
33
33
  const accessTokenClaims = JSON.parse(json);
@@ -12,7 +12,6 @@ const logtoErrorCodes = Object.freeze({
12
12
  'callback_uri_verification.missing_code': 'Missing code in the callback URI',
13
13
  crypto_subtle_unavailable: 'Crypto.subtle is unavailable in insecure contexts (non-HTTPS).',
14
14
  unexpected_response_error: 'Unexpected response error from the server.',
15
- 'access_token.invalid_token': 'Invalid access token',
16
15
  });
17
16
  class LogtoError extends Error {
18
17
  constructor(code, data) {
@@ -8,7 +8,6 @@ declare const logtoErrorCodes: Readonly<{
8
8
  'callback_uri_verification.missing_code': "Missing code in the callback URI";
9
9
  crypto_subtle_unavailable: "Crypto.subtle is unavailable in insecure contexts (non-HTTPS).";
10
10
  unexpected_response_error: "Unexpected response error from the server.";
11
- 'access_token.invalid_token': "Invalid access token";
12
11
  }>;
13
12
  export type LogtoErrorCode = keyof typeof logtoErrorCodes;
14
13
  export declare class LogtoError extends Error {
@@ -10,7 +10,6 @@ const logtoErrorCodes = Object.freeze({
10
10
  'callback_uri_verification.missing_code': 'Missing code in the callback URI',
11
11
  crypto_subtle_unavailable: 'Crypto.subtle is unavailable in insecure contexts (non-HTTPS).',
12
12
  unexpected_response_error: 'Unexpected response error from the server.',
13
- 'access_token.invalid_token': 'Invalid access token',
14
13
  });
15
14
  class LogtoError extends Error {
16
15
  constructor(code, data) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logto/js",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "type": "module",
5
5
  "main": "./lib/index.cjs",
6
6
  "module": "./lib/index.js",