@logto/client
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -24,5 +24,3 @@ import { Requester, Prompt, IdTokenClaims, UserInfoResponse, InteractionMode } from "@logto/js"; | ||
not_authenticated: "Not authenticated."; | ||
get_access_token_by_refresh_token_failed: "Failed to get access token by refresh token."; | ||
fetch_user_info_failed: "Unable to fetch user info. The access token may be invalid."; | ||
invalid_id_token: "Invalid id token."; | ||
}>; | ||
@@ -29,0 +27,0 @@ export type LogtoClientErrorCode = NormalizeKeyPaths<typeof logtoClientErrorCodes>; |
@@ -55,5 +55,3 @@ var $4R6L3$logtojs = require("@logto/js"); | ||
not_authenticated: "Not authenticated.", | ||
get_access_token_by_refresh_token_failed: "Failed to get access token by refresh token.", | ||
fetch_user_info_failed: "Unable to fetch user info. The access token may be invalid.", | ||
invalid_id_token: "Invalid id token." | ||
fetch_user_info_failed: "Unable to fetch user info. The access token may be invalid." | ||
}); | ||
@@ -273,27 +271,23 @@ const $9166104b36889c59$var$getMessageByErrorCode = (errorCode)=>{ | ||
if (!currentRefreshToken) throw new (0, $9166104b36889c59$export$877962ca249b8fc8)("not_authenticated"); | ||
try { | ||
const accessTokenKey = (0, $e2aabdbdb3cc09f0$export$8f595bd2a47bcea6)(resource); | ||
const { appId: clientId } = this.logtoConfig; | ||
const { tokenEndpoint: tokenEndpoint } = await this.getOidcConfig(); | ||
const { accessToken: accessToken , refreshToken: refreshToken , idToken: idToken , scope: scope , expiresIn: expiresIn } = await (0, $4R6L3$logtojs.fetchTokenByRefreshToken)({ | ||
clientId: clientId, | ||
tokenEndpoint: tokenEndpoint, | ||
refreshToken: currentRefreshToken, | ||
resource: resource | ||
}, this.adapter.requester); | ||
this.accessTokenMap.set(accessTokenKey, { | ||
token: accessToken, | ||
scope: scope, | ||
expiresAt: Math.round(Date.now() / 1000) + expiresIn | ||
}); | ||
await this.saveAccessTokenMap(); | ||
await this.setRefreshToken(refreshToken); | ||
if (idToken) { | ||
await this.verifyIdToken(idToken); | ||
await this.setIdToken(idToken); | ||
} | ||
return accessToken; | ||
} catch (error) { | ||
throw new (0, $9166104b36889c59$export$877962ca249b8fc8)("get_access_token_by_refresh_token_failed", error); | ||
const accessTokenKey = (0, $e2aabdbdb3cc09f0$export$8f595bd2a47bcea6)(resource); | ||
const { appId: clientId } = this.logtoConfig; | ||
const { tokenEndpoint: tokenEndpoint } = await this.getOidcConfig(); | ||
const { accessToken: accessToken , refreshToken: refreshToken , idToken: idToken , scope: scope , expiresIn: expiresIn } = await (0, $4R6L3$logtojs.fetchTokenByRefreshToken)({ | ||
clientId: clientId, | ||
tokenEndpoint: tokenEndpoint, | ||
refreshToken: currentRefreshToken, | ||
resource: resource | ||
}, this.adapter.requester); | ||
this.accessTokenMap.set(accessTokenKey, { | ||
token: accessToken, | ||
scope: scope, | ||
expiresAt: Math.round(Date.now() / 1000) + expiresIn | ||
}); | ||
await this.saveAccessTokenMap(); | ||
await this.setRefreshToken(refreshToken); | ||
if (idToken) { | ||
await this.verifyIdToken(idToken); | ||
await this.setIdToken(idToken); | ||
} | ||
return accessToken; | ||
} | ||
@@ -313,7 +307,3 @@ async _getOidcConfig() { | ||
const jwtVerifyGetKey = await this.getJwtVerifyGetKey(); | ||
try { | ||
await (0, $4R6L3$logtojs.verifyIdToken)(idToken, appId, issuer, jwtVerifyGetKey); | ||
} catch (error) { | ||
throw new (0, $9166104b36889c59$export$877962ca249b8fc8)("invalid_id_token", error); | ||
} | ||
await (0, $4R6L3$logtojs.verifyIdToken)(idToken, appId, issuer, jwtVerifyGetKey); | ||
} | ||
@@ -347,3 +337,5 @@ async saveCodeToken({ refreshToken: refreshToken , idToken: idToken , scope: scope , accessToken: accessToken , expiresIn: expiresIn }) { | ||
for (const [key, accessToken] of Object.entries(json))this.accessTokenMap.set(key, accessToken); | ||
} catch {} | ||
} catch (error) { | ||
console.warn(error); | ||
} | ||
} | ||
@@ -350,0 +342,0 @@ } |
{ | ||
"name": "@logto/client", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"source": "./src/index.ts", | ||
@@ -69,3 +69,3 @@ "main": "./lib/index.js", | ||
}, | ||
"gitHead": "f24174a6f840b8db968ad3886878d1b6e92b1b9d" | ||
"gitHead": "f74d96813d0bcc07a5134d43318f1e167a6f47ff" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
101240
680