@t4h.framework/jwks 0.5.1 → 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.
- package/.ai/skills/framework-jwks/SKILL.md +3 -2
- package/CHANGELOG.md +51 -0
- package/README.md +1 -0
- package/dist/jwks-callback.d.ts +3 -0
- package/dist/jwks-callback.d.ts.map +1 -0
- package/dist/jwks-callback.js +20 -0
- package/dist/jwks-callback.js.map +1 -0
- package/dist/jwks.d.ts +1 -0
- package/dist/jwks.d.ts.map +1 -1
- package/dist/jwks.js +1 -0
- package/dist/jwks.js.map +1 -1
- package/package.json +7 -3
|
@@ -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
|
-
|
|
136
|
-
|
|
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,56 @@
|
|
|
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
|
+
|
|
47
|
+
## 0.5.2
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- Updated dependencies [[`72e08ff`](https://github.com/tech4humans-brasil/framework/commit/72e08ff86e0ce735ef73ccdf33b0dc01cdb8b6f5)]:
|
|
52
|
+
- @t4h.framework/core@0.12.0
|
|
53
|
+
|
|
3
54
|
## 0.5.1
|
|
4
55
|
|
|
5
56
|
### Patch Changes
|
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
package/dist/jwks.d.ts.map
CHANGED
|
@@ -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
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.
|
|
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.
|
|
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.
|
|
50
|
+
"@t4h.framework/core": "^0.13.0"
|
|
47
51
|
},
|
|
48
52
|
"packageManager": "yarn@4.12.0",
|
|
49
53
|
"engines": {
|