@silkweave/auth 1.3.1 → 1.4.0

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/src/validate.ts CHANGED
@@ -1,5 +1,6 @@
1
+ import { SilkweaveContext } from '@silkweave/core'
1
2
  import { AuthError, insufficientScope, invalidToken } from './errors.js'
2
- import { extractBearerToken, buildWWWAuthenticate } from './extract.js'
3
+ import { buildWWWAuthenticate, extractBearerToken } from './extract.js'
3
4
  import { AuthConfig, AuthInfo } from './types.js'
4
5
 
5
6
  export interface ValidateResult {
@@ -13,7 +14,8 @@ export interface ValidateResult {
13
14
 
14
15
  export async function validateToken(
15
16
  authorizationHeader: string | null | undefined,
16
- config: AuthConfig
17
+ config: AuthConfig,
18
+ context: SilkweaveContext
17
19
  ): Promise<ValidateResult> {
18
20
  const required = config.required ?? true
19
21
  const resourceMetadataUrl = config.resourceUrl
@@ -29,7 +31,7 @@ export async function validateToken(
29
31
 
30
32
  let authInfo: AuthInfo | undefined
31
33
  try {
32
- authInfo = await config.verifyToken(token)
34
+ authInfo = await config.verifyToken(token, context)
33
35
  } catch (_e) {
34
36
  const err = invalidToken()
35
37
  return buildErrorResult(err, resourceMetadataUrl)