@thunderid/browser 1.9.0 → 1.9.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.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Buffer } from 'buffer/index.js';
2
2
  if (typeof window !== 'undefined' && !window.Buffer) { window.Buffer = Buffer; }
3
- import { DEFAULT_THEME, HttpClient, OIDCRequestConstants, ThunderIDAuthException, ThunderIDJavaScriptClient, ThunderIDRuntimeError, TokenConstants, arrayBufferToBase64url, base64urlToArrayBuffer, createPackageComponentLogger, extractEmojiFromUri, extractPkceStorageKeyFromState, generateFlattenedUserProfile, getUsersMe, isEmojiUri, resolveBackendEndpoints, resolveResourceEndpoint } from "@thunderid/javascript";
3
+ import { DEFAULT_THEME, HttpClient, OIDCRequestConstants, ThunderIDAuthException, ThunderIDJavaScriptClient, ThunderIDRuntimeError, TokenConstants, arrayBufferToBase64url, base64urlToArrayBuffer, createPackageComponentLogger, extractEmojiFromUri, extractPkceStorageKeyFromState, generateFlattenedUserProfile, getTokenPermissions, getUsersMe, isEmojiUri, resolveBackendEndpoints, resolveResourceEndpoint } from "@thunderid/javascript";
4
4
  import base64url from "base64url";
5
5
  import sha256 from "fast-sha256";
6
6
  import { createLocalJWKSet, jwtVerify } from "jose";
@@ -3097,6 +3097,23 @@ var ThunderIDBrowserClient = class ThunderIDBrowserClient extends ThunderIDJavaS
3097
3097
  return super.getAccessToken(sessionId);
3098
3098
  }
3099
3099
  /**
3100
+ * The permissions the signed-in user's access token grants, for example to hide a page the user
3101
+ * cannot use. The server still checks every request.
3102
+ *
3103
+ * In backend mode they come only from the backend's session (`scope`): the token stays on the backend,
3104
+ * so a session without `scope` grants nothing. Otherwise they are read from the access token's `scope`
3105
+ * or `scopes` claim.
3106
+ *
3107
+ * @returns The granted permissions, or an empty list when none can be read.
3108
+ */
3109
+ async getGrantedPermissions() {
3110
+ if (this._backend) {
3111
+ const { scope } = await this._backend.getSession();
3112
+ return typeof scope === "string" ? scope.split(" ").filter((entry) => entry.length > 0) : [];
3113
+ }
3114
+ return getTokenPermissions(await this.getAccessToken());
3115
+ }
3116
+ /**
3100
3117
  * The access token for requests under `endpoints.backend.bypass`. Like a client credentials token it
3101
3118
  * has no refresh token: it is kept in the session storage until it nears expiry, then requested again.
3102
3119
  *