@t4h.framework/jwks 0.5.2 → 0.6.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.
@@ -27,6 +27,7 @@ Package path: `framework/packages/jwks`. See [README.md](../../../README.md) for
27
27
  |-------|---------|
28
28
  | `@t4h.framework/jwks` | `JWKSAuthorization`, `JWKSAuthorizationContext`, `JWKSAuthorizationManifest`, `JWKSAlgorithm`, re-exports authorize module |
29
29
  | `@t4h.framework/jwks/authorize` | Default async handler: `(context) => Promise<boolean>` |
30
+ | `@t4h.framework/jwks/callback` | Default export `jwksCallback`: `(auth, request) => Promise<boolean>`, the `jwt` authorizer hosts pass to the core `AsyncActivityCallback.authorize` |
30
31
 
31
32
  ```typescript
32
33
  import {
@@ -132,8 +133,8 @@ Behavior (from `jwks-authorize.ts` and tests):
132
133
  Uses Node `crypto.createVerify` with public key from JWKS:
133
134
 
134
135
  ```typescript
135
- verifier.update(options.rawPayload)
136
- verifier.verify(signingKey, options.signature, signatureFormat)
136
+ authorizer.update(options.rawPayload)
137
+ authorizer.verify(signingKey, options.signature, signatureFormat)
137
138
  ```
138
139
 
139
140
  Throws if any required field is missing:
package/CHANGELOG.md CHANGED
@@ -1,5 +1,49 @@
1
1
  # @t4h.framework/jwks
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#167](https://github.com/tech4humans-brasil/framework/pull/167) [`1b1509f`](https://github.com/tech4humans-brasil/framework/commit/1b1509f9b6d2554dfab1f7633c3d022249e4fa01) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - Moves the callbacks route helpers from `@t4h.framework/webhook` to
8
+ `@t4h.framework/core`. The route advances any pending async activity, not only
9
+ `webhook()`, and the core already owned its contract (`AsyncActivityCallbackAuth`,
10
+ `GetActivityCallbackUrlClaim`, `AsyncActivityAdvanceContext`).
11
+
12
+ **core**: new `AsyncActivityCallback` namespace with `deriveToken`, `isTokenValid`,
13
+ `parseBody`, `getHeader`, `getBearerToken`, `flattenHeaders`, `authorize` and
14
+ the types `AsyncActivityCallback.Delivery`, `AsyncActivityCallback.Headers`, `AsyncActivityCallback.Json`,
15
+ `AsyncActivityCallback.AuthType`, `AsyncActivityCallback.Authorizer`, `AsyncActivityCallback.Authorizers`.
16
+ `AsyncActivityCallback.authorize(auth, request, authorizers?)` ships `basic`, `header` and
17
+ `bearer`; `hmac` and `jwt` are authorizers the host passes in, so the core does not
18
+ depend on `@t4h.framework/hmac` or `@t4h.framework/jwks`. A declared type without
19
+ a authorizer throws `AsyncActivityCallbackAuthorizerMissingException`; an unknown type throws
20
+ `AsyncActivityCallbackAuthUnsupportedException`.
21
+
22
+ **hmac**: new `@t4h.framework/hmac/callback` entry whose default export is the
23
+ `hmac` callback authorizer, `hmacCallback`.
24
+
25
+ **jwks**: new `@t4h.framework/jwks/callback` entry whose default export is the
26
+ `jwt` callback authorizer, `jwksCallback`.
27
+
28
+ **webhook**: no longer exports `deriveCallbackToken`, `isCallbackTokenValid`,
29
+ `verifyCallbackAuth`, `parseCallbackBody`, `getHeader`, `flattenHeaders` nor
30
+ `CallbackRequest`/`CallbackHeaders`, and no longer depends on `hmac` and `jwks`;
31
+ `WebhookJson` is now an alias of the core `AsyncActivityCallback.Json`. Hosts import the
32
+ helpers from the core `AsyncActivityCallback` namespace and the authorizers from the two entries.
33
+
34
+ **dev**: `@t4h.framework/webhook` becomes an optional peer like the other
35
+ integrations. Only `@t4h.framework/core` is required again, which fixes
36
+ `ERR_MODULE_NOT_FOUND: Cannot find package '@t4h.framework/webhook'` on
37
+ projects that never call `webhook()`. `hmac` and `jwt` callback authorizers are
38
+ loaded from the project when `@t4h.framework/hmac` / `@t4h.framework/jwks` are
39
+ installed; a callback whose declared `auth` needs a missing package answers 500
40
+ naming the package to install.
41
+
42
+ ### Patch Changes
43
+
44
+ - Updated dependencies [[`1b1509f`](https://github.com/tech4humans-brasil/framework/commit/1b1509f9b6d2554dfab1f7633c3d022249e4fa01), [`1b1509f`](https://github.com/tech4humans-brasil/framework/commit/1b1509f9b6d2554dfab1f7633c3d022249e4fa01)]:
45
+ - @t4h.framework/core@0.13.0
46
+
3
47
  ## 0.5.2
4
48
 
5
49
  ### Patch Changes
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Tech for humans
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -12,6 +12,7 @@ Requires `@t4h.framework/core` (same major line as this package).
12
12
  |------------------|---------|
13
13
  | `@t4h.framework/jwks` | `JWKSAuthorization`, `JWKSAuthorizationContext`, and related types |
14
14
  | `@t4h.framework/jwks/authorize` | Default async handler invoked by the runtime with the manifest context |
15
+ | `@t4h.framework/jwks/callback` | Default export `jwksCallback`: `jwt` callback authorizer for the core `AsyncActivityCallback.authorize` (`pending({ auth: { type: 'jwt' } })`) |
15
16
 
16
17
  ## `JWKSAuthorization`
17
18
 
@@ -0,0 +1,3 @@
1
+ import { AsyncActivityCallback, type AsyncActivityCallbackAuthJwt } from '@t4h.framework/core';
2
+ export default function jwksCallback(auth: AsyncActivityCallbackAuthJwt, request: AsyncActivityCallback.Delivery): Promise<boolean>;
3
+ //# sourceMappingURL=jwks-callback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwks-callback.d.ts","sourceRoot":"","sources":["../src/jwks-callback.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,4BAA4B,EAClC,MAAM,qBAAqB,CAAA;AAI5B,wBAA8B,YAAY,CACxC,IAAI,EAAE,4BAA4B,EAClC,OAAO,EAAE,qBAAqB,CAAC,QAAQ,GACtC,OAAO,CAAC,OAAO,CAAC,CAmBlB"}
@@ -0,0 +1,20 @@
1
+ import { AsyncActivityCallback, } from '@t4h.framework/core';
2
+ import jwks from './jwks-authorize.js';
3
+ export default async function jwksCallback(auth, request) {
4
+ const token = AsyncActivityCallback.getBearerToken(request.headers, auth.header);
5
+ if (!token)
6
+ return false;
7
+ try {
8
+ return await jwks({
9
+ url: auth.jwksUri,
10
+ signature: token,
11
+ rawPayload: '',
12
+ issuer: auth.issuer,
13
+ audience: auth.audience,
14
+ });
15
+ }
16
+ catch {
17
+ return false;
18
+ }
19
+ }
20
+ //# sourceMappingURL=jwks-callback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwks-callback.js","sourceRoot":"","sources":["../src/jwks-callback.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,GAEtB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,IAAI,MAAM,qBAAqB,CAAA;AAEtC,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,YAAY,CACxC,IAAkC,EAClC,OAAuC;IAEvC,MAAM,KAAK,GAAG,qBAAqB,CAAC,cAAc,CAChD,OAAO,CAAC,OAAO,EACf,IAAI,CAAC,MAAM,CACZ,CAAA;IAED,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAA;IAExB,IAAI,CAAC;QACH,OAAO,MAAM,IAAI,CAAC;YAChB,GAAG,EAAE,IAAI,CAAC,OAAO;YACjB,SAAS,EAAE,KAAK;YAChB,UAAU,EAAE,EAAE;YACd,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC,CAAA;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC"}
package/dist/jwks.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './jwks-authorize.js';
2
+ export * from './jwks-callback.js';
2
3
  export * from './models/JWKSAuthorization.js';
3
4
  //# sourceMappingURL=jwks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jwks.d.ts","sourceRoot":"","sources":["../src/jwks.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,+BAA+B,CAAA"}
1
+ {"version":3,"file":"jwks.d.ts","sourceRoot":"","sources":["../src/jwks.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,+BAA+B,CAAA"}
package/dist/jwks.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './jwks-authorize.js';
2
+ export * from './jwks-callback.js';
2
3
  export * from './models/JWKSAuthorization.js';
3
4
  //# sourceMappingURL=jwks.js.map
package/dist/jwks.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"jwks.js","sourceRoot":"","sources":["../src/jwks.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,+BAA+B,CAAA"}
1
+ {"version":3,"file":"jwks.js","sourceRoot":"","sources":["../src/jwks.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,+BAA+B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t4h.framework/jwks",
3
- "version": "0.5.2",
3
+ "version": "0.6.0",
4
4
  "description": "JWKS module for the T4H Framework authorization",
5
5
  "homepage": "https://github.com/tech4humans-brasil/framework/tree/main/packages/jwks",
6
6
  "bugs": "https://github.com/tech4humans-brasil/framework/issues",
@@ -20,6 +20,10 @@
20
20
  "./authorize": {
21
21
  "types": "./dist/jwks-authorize.d.ts",
22
22
  "import": "./dist/jwks-authorize.js"
23
+ },
24
+ "./callback": {
25
+ "types": "./dist/jwks-callback.d.ts",
26
+ "import": "./dist/jwks-callback.js"
23
27
  }
24
28
  },
25
29
  "module": "./dist/jwks.js",
@@ -37,13 +41,13 @@
37
41
  "test:watch": "vitest"
38
42
  },
39
43
  "devDependencies": {
40
- "@t4h.framework/core": "^0.12.0",
44
+ "@t4h.framework/core": "^0.13.0",
41
45
  "@types/jsonwebtoken": "^9",
42
46
  "typescript": "^5.9.3",
43
47
  "vitest": "^4.0.18"
44
48
  },
45
49
  "peerDependencies": {
46
- "@t4h.framework/core": "^0.12.0"
50
+ "@t4h.framework/core": "^0.13.0"
47
51
  },
48
52
  "packageManager": "yarn@4.12.0",
49
53
  "engines": {