@logto/browser 0.1.11 → 0.1.17

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.
Files changed (2) hide show
  1. package/lib/index.js +12 -4
  2. package/package.json +5 -6
package/lib/index.js CHANGED
@@ -35,7 +35,10 @@ class LogtoClient {
35
35
  this.getJwtVerifyGetKey = (0, lodash_once_1.default)(this._getJwtVerifyGetKey);
36
36
  this.accessTokenMap = new Map();
37
37
  this.getAccessTokenPromiseMap = new Map();
38
- this.logtoConfig = logtoConfig;
38
+ this.logtoConfig = {
39
+ ...logtoConfig,
40
+ scopes: (0, js_1.withReservedScopes)(logtoConfig.scopes).split(' '),
41
+ };
39
42
  this.logtoStorageKey = (0, utils_1.buildLogtoKey)(logtoConfig.appId);
40
43
  this.requester = requester;
41
44
  this._idToken = localStorage.getItem((0, utils_1.buildIdTokenKey)(this.logtoStorageKey));
@@ -136,12 +139,11 @@ class LogtoClient {
136
139
  return (0, js_1.fetchUserInfo)(userinfoEndpoint, accessToken, this.requester);
137
140
  }
138
141
  async signIn(redirectUri) {
139
- const { appId: clientId, resources, scopes: customScopes } = this.logtoConfig;
142
+ const { appId: clientId, resources, scopes } = this.logtoConfig;
140
143
  const { authorizationEndpoint } = await this.getOidcConfig();
141
144
  const codeVerifier = (0, js_1.generateCodeVerifier)();
142
145
  const codeChallenge = await (0, js_1.generateCodeChallenge)(codeVerifier);
143
146
  const state = (0, js_1.generateState)();
144
- const scopes = (0, js_1.withReservedScopes)(customScopes).split(' ');
145
147
  const signInUri = (0, js_1.generateSignInUri)({
146
148
  authorizationEndpoint,
147
149
  clientId,
@@ -217,7 +219,13 @@ class LogtoClient {
217
219
  const accessTokenKey = (0, utils_1.buildAccessTokenKey)(resource);
218
220
  const { appId: clientId } = this.logtoConfig;
219
221
  const { tokenEndpoint } = await this.getOidcConfig();
220
- const { accessToken, refreshToken, idToken, scope, expiresIn } = await (0, js_1.fetchTokenByRefreshToken)({ clientId, tokenEndpoint, refreshToken: this.refreshToken, resource }, this.requester);
222
+ const { accessToken, refreshToken, idToken, scope, expiresIn } = await (0, js_1.fetchTokenByRefreshToken)({
223
+ clientId,
224
+ tokenEndpoint,
225
+ refreshToken: this.refreshToken,
226
+ resource,
227
+ scopes: resource ? ['offline_access'] : undefined, // Force remove openid scope from the request
228
+ }, this.requester);
221
229
  this.accessTokenMap.set(accessTokenKey, {
222
230
  token: accessToken,
223
231
  scope,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logto/browser",
3
- "version": "0.1.11",
3
+ "version": "0.1.17",
4
4
  "main": "./lib/index.js",
5
5
  "exports": "./lib/index.js",
6
6
  "typings": "./lib/index.d.ts",
@@ -15,7 +15,6 @@
15
15
  },
16
16
  "scripts": {
17
17
  "dev:tsc": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
18
- "preinstall": "npx only-allow pnpm",
19
18
  "precommit": "lint-staged",
20
19
  "build": "rm -rf lib/ && tsc -p tsconfig.build.json",
21
20
  "lint": "eslint --ext .ts src",
@@ -24,12 +23,12 @@
24
23
  "prepack": "pnpm test"
25
24
  },
26
25
  "dependencies": {
27
- "@logto/js": "^0.1.11",
26
+ "@logto/js": "^0.1.17",
28
27
  "@silverhand/essentials": "^1.1.6",
29
28
  "jose": "^4.5.0",
30
29
  "lodash.get": "^4.4.2",
31
30
  "lodash.once": "^4.1.1",
32
- "superstruct": "^0.15.3"
31
+ "superstruct": "^0.16.0"
33
32
  },
34
33
  "devDependencies": {
35
34
  "@jest/types": "^27.5.1",
@@ -42,7 +41,7 @@
42
41
  "jest": "^27.5.1",
43
42
  "jest-location-mock": "^1.0.9",
44
43
  "jest-matcher-specific-error": "^1.0.0",
45
- "lint-staged": "^12.3.3",
44
+ "lint-staged": "^13.0.0",
46
45
  "prettier": "^2.3.2",
47
46
  "text-encoder": "^0.0.4",
48
47
  "ts-jest": "^27.0.4",
@@ -55,5 +54,5 @@
55
54
  "publishConfig": {
56
55
  "access": "public"
57
56
  },
58
- "gitHead": "fb6df238f56049607af2c3b88bee07ba2aa45dae"
57
+ "gitHead": "57e93385829eceb3c1b2ffb92b90901aa174a59a"
59
58
  }