@shad-claiborne/basic-oidc 1.1.9 → 1.1.11

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/README.md CHANGED
@@ -23,6 +23,6 @@ const authResponse =
23
23
  Object.fromEntries(authResponseParams) as AuthorizationResponse;
24
24
  const tokenSet:TokenSet =
25
25
  await client.requestAccess(authResponse, { codeVerifier: codeChallenge });
26
- const id:Identity = await provider.getIdentity(client, tokenSet);
26
+ const id:Identity = await provider.getIdentity(tokenSet);
27
27
  // await client.revokeAccess(tokenSet);
28
28
  ```
package/dist/index.d.ts CHANGED
@@ -216,13 +216,18 @@ export declare class IdentityProvider {
216
216
  * @returns Client
217
217
  */
218
218
  createClient(id: string, secret: string): Client;
219
+ /**
220
+ * decodeIdentityToken
221
+ * @param token string
222
+ * @returns Promise<Identity>
223
+ */
224
+ decodeIdentityToken(token: string): Promise<Identity>;
219
225
  /**
220
226
  * getIdentity
221
- * @param client Client
222
227
  * @param tokenSet TokenSet
223
228
  * @returns Promise<Identity>
224
229
  */
225
- getIdentity(client: Client, tokenSet: TokenSet): Promise<Identity>;
230
+ getIdentity(tokenSet: TokenSet): Promise<Identity>;
226
231
  }
227
232
  /**
228
233
  * class Client
package/dist/index.js CHANGED
@@ -323,18 +323,26 @@ class IdentityProvider {
323
323
  const client = new Client(this, id, secret);
324
324
  return client;
325
325
  }
326
+ /**
327
+ * decodeIdentityToken
328
+ * @param token string
329
+ * @returns Promise<Identity>
330
+ */
331
+ async decodeIdentityToken(token) {
332
+ const jwks = (0, jose_1.createRemoteJWKSet)(new URL(this.config.jwks_uri));
333
+ const { payload } = await (0, jose_1.jwtVerify)(token, jwks, { issuer: this.config.issuer });
334
+ const id = payload;
335
+ return id;
336
+ }
326
337
  /**
327
338
  * getIdentity
328
- * @param client Client
329
339
  * @param tokenSet TokenSet
330
340
  * @returns Promise<Identity>
331
341
  */
332
- async getIdentity(client, tokenSet) {
342
+ async getIdentity(tokenSet) {
333
343
  let id;
334
344
  if (tokenSet.id_token) {
335
- const jwks = (0, jose_1.createRemoteJWKSet)(new URL(this.config.jwks_uri));
336
- const { payload } = await (0, jose_1.jwtVerify)(tokenSet.id_token, jwks, { issuer: this.config.issuer });
337
- id = payload;
345
+ id = await this.decodeIdentityToken(tokenSet.id_token);
338
346
  }
339
347
  else if (tokenSet.access_token) {
340
348
  const api = new IdentityProviderApi(this, tokenSet);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shad-claiborne/basic-oidc",
3
- "version": "1.1.9",
3
+ "version": "1.1.11",
4
4
  "description": "Basic OpenID Connect library",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",