@logto/browser
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -8,3 +8,3 @@ import { IdTokenClaims, Requester, UserInfoResponse } from '@logto/js'; | ||
endpoint: string; | ||
clientId: string; | ||
appId: string; | ||
scopes?: string[]; | ||
@@ -45,3 +45,2 @@ resources?: string[]; | ||
private readonly getAccessTokenPromiseMap; | ||
private _refreshToken; | ||
private _idToken; | ||
@@ -48,0 +47,0 @@ constructor(logtoConfig: LogtoConfig, requester?: <T>(input: RequestInfo, init?: RequestInit | undefined) => Promise<T>); |
@@ -36,5 +36,4 @@ "use strict"; | ||
this.logtoConfig = logtoConfig; | ||
this.logtoStorageKey = (0, utils_1.buildLogtoKey)(logtoConfig.clientId); | ||
this.logtoStorageKey = (0, utils_1.buildLogtoKey)(logtoConfig.appId); | ||
this.requester = requester; | ||
this._refreshToken = localStorage.getItem((0, utils_1.buildRefreshTokenKey)(this.logtoStorageKey)); | ||
this._idToken = localStorage.getItem((0, utils_1.buildIdTokenKey)(this.logtoStorageKey)); | ||
@@ -68,6 +67,5 @@ } | ||
get refreshToken() { | ||
return this._refreshToken; | ||
return localStorage.getItem((0, utils_1.buildRefreshTokenKey)(this.logtoStorageKey)); | ||
} | ||
set refreshToken(refreshToken) { | ||
this._refreshToken = refreshToken; | ||
const refreshTokenKey = (0, utils_1.buildRefreshTokenKey)(this.logtoStorageKey); | ||
@@ -139,3 +137,3 @@ if (!refreshToken) { | ||
async signIn(redirectUri) { | ||
const { clientId, resources, scopes: customScopes } = this.logtoConfig; | ||
const { appId: clientId, resources, scopes: customScopes } = this.logtoConfig; | ||
const { authorizationEndpoint } = await this.getOidcConfig(); | ||
@@ -174,3 +172,3 @@ const codeVerifier = (0, js_1.generateCodeVerifier)(); | ||
const code = (0, js_1.verifyAndParseCodeFromCallbackUri)(callbackUri, redirectUri, state); | ||
const { clientId } = logtoConfig; | ||
const { appId: clientId } = logtoConfig; | ||
const { tokenEndpoint } = await this.getOidcConfig(); | ||
@@ -186,2 +184,3 @@ const codeTokenResponse = await (0, js_1.fetchTokenByAuthorizationCode)({ | ||
this.saveCodeToken(codeTokenResponse); | ||
this.signInSession = null; | ||
} | ||
@@ -192,3 +191,3 @@ async signOut(postLogoutRedirectUri) { | ||
} | ||
const { clientId } = this.logtoConfig; | ||
const { appId: clientId } = this.logtoConfig; | ||
const { endSessionEndpoint, revocationEndpoint } = await this.getOidcConfig(); | ||
@@ -219,3 +218,3 @@ if (this.refreshToken) { | ||
const accessTokenKey = (0, utils_1.buildAccessTokenKey)(resource); | ||
const { clientId } = this.logtoConfig; | ||
const { appId: clientId } = this.logtoConfig; | ||
const { tokenEndpoint } = await this.getOidcConfig(); | ||
@@ -249,7 +248,7 @@ const { accessToken, refreshToken, idToken, scope, expiresIn } = await (0, js_1.fetchTokenByRefreshToken)({ clientId, tokenEndpoint, refreshToken: this.refreshToken, resource }, this.requester); | ||
async verifyIdToken(idToken) { | ||
const { clientId } = this.logtoConfig; | ||
const { appId } = this.logtoConfig; | ||
const { issuer } = await this.getOidcConfig(); | ||
const jwtVerifyGetKey = await this.getJwtVerifyGetKey(); | ||
try { | ||
await (0, js_1.verifyIdToken)(idToken, clientId, issuer, jwtVerifyGetKey); | ||
await (0, js_1.verifyIdToken)(idToken, appId, issuer, jwtVerifyGetKey); | ||
} | ||
@@ -256,0 +255,0 @@ catch (error) { |
{ | ||
"name": "@logto/browser", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"main": "./lib/index.js", | ||
@@ -24,6 +24,6 @@ "exports": "./lib/index.js", | ||
"test:coverage": "jest --silent --coverage", | ||
"prepack": "pnpm test && pnpm build" | ||
"prepack": "pnpm test" | ||
}, | ||
"dependencies": { | ||
"@logto/js": "^0.1.3", | ||
"@logto/js": "^0.1.5", | ||
"@silverhand/essentials": "^1.1.6", | ||
@@ -37,4 +37,4 @@ "jose": "^4.5.0", | ||
"@jest/types": "^27.5.1", | ||
"@silverhand/eslint-config": "^0.9.1", | ||
"@silverhand/ts-config": "^0.9.1", | ||
"@silverhand/eslint-config": "^0.10.0", | ||
"@silverhand/ts-config": "^0.10.0", | ||
"@types/jest": "^27.4.0", | ||
@@ -60,3 +60,3 @@ "@types/lodash.get": "^4.4.6", | ||
}, | ||
"gitHead": "a5eed81a3e3db3184a53f04f843db8ac707dd3ad" | ||
"gitHead": "ed98d55270ae923f95a57fe4f3bc5a5959518c06" | ||
} |
19490
397
Updated@logto/js@^0.1.5