@t4h.framework/hmac 0.0.0-experimental-20260907215424 → 0.0.0-experimental-20260909045544

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/hmac`. See [README.md](../../../README.md) for
27
27
  |-------|---------|
28
28
  | `@t4h.framework/hmac` | `HMACAuthorization`, `HMACAuthorizationContext`, `HMACAuthorizationManifest`, `HMACAlgorithm`, `HMAC_DEFAULT_ALGORITHM`, `HMAC_DEFAULT_SIGNATURE_FORMAT`, re-exports authorize module |
29
29
  | `@t4h.framework/hmac/authorize` | Default async handler: `(context) => Promise<boolean>` |
30
+ | `@t4h.framework/hmac/callback` | Default export `hmacCallback`: `(auth, request) => Promise<boolean>`, the `hmac` authorizer hosts pass to the core `AsyncActivityCallback.authorize` |
30
31
 
31
32
  ```typescript
32
33
  import {
package/CHANGELOG.md CHANGED
@@ -1,11 +1,69 @@
1
1
  # @t4h.framework/hmac
2
2
 
3
- ## 0.0.0-experimental-20260907215424
3
+ ## 0.0.0-experimental-20260909045544
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - Updated dependencies [[`230b382`](https://github.com/tech4humans-brasil/framework/commit/230b3829eadecce8fedd806bd2f9514ba792c541)]:
8
- - @t4h.framework/core@0.0.0-experimental-20260907215424
7
+ - Updated dependencies [[`cb4a5df`](https://github.com/tech4humans-brasil/framework/commit/cb4a5df7b04d6c942abb6ac96be5ffab94243172)]:
8
+ - @t4h.framework/core@0.0.0-experimental-20260909045544
9
+
10
+ ## 0.3.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [#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
15
+ `@t4h.framework/core`. The route advances any pending async activity, not only
16
+ `webhook()`, and the core already owned its contract (`AsyncActivityCallbackAuth`,
17
+ `GetActivityCallbackUrlClaim`, `AsyncActivityAdvanceContext`).
18
+
19
+ **core**: new `AsyncActivityCallback` namespace with `deriveToken`, `isTokenValid`,
20
+ `parseBody`, `getHeader`, `getBearerToken`, `flattenHeaders`, `authorize` and
21
+ the types `AsyncActivityCallback.Delivery`, `AsyncActivityCallback.Headers`, `AsyncActivityCallback.Json`,
22
+ `AsyncActivityCallback.AuthType`, `AsyncActivityCallback.Authorizer`, `AsyncActivityCallback.Authorizers`.
23
+ `AsyncActivityCallback.authorize(auth, request, authorizers?)` ships `basic`, `header` and
24
+ `bearer`; `hmac` and `jwt` are authorizers the host passes in, so the core does not
25
+ depend on `@t4h.framework/hmac` or `@t4h.framework/jwks`. A declared type without
26
+ a authorizer throws `AsyncActivityCallbackAuthorizerMissingException`; an unknown type throws
27
+ `AsyncActivityCallbackAuthUnsupportedException`.
28
+
29
+ **hmac**: new `@t4h.framework/hmac/callback` entry whose default export is the
30
+ `hmac` callback authorizer, `hmacCallback`.
31
+
32
+ **jwks**: new `@t4h.framework/jwks/callback` entry whose default export is the
33
+ `jwt` callback authorizer, `jwksCallback`.
34
+
35
+ **webhook**: no longer exports `deriveCallbackToken`, `isCallbackTokenValid`,
36
+ `verifyCallbackAuth`, `parseCallbackBody`, `getHeader`, `flattenHeaders` nor
37
+ `CallbackRequest`/`CallbackHeaders`, and no longer depends on `hmac` and `jwks`;
38
+ `WebhookJson` is now an alias of the core `AsyncActivityCallback.Json`. Hosts import the
39
+ helpers from the core `AsyncActivityCallback` namespace and the authorizers from the two entries.
40
+
41
+ **dev**: `@t4h.framework/webhook` becomes an optional peer like the other
42
+ integrations. Only `@t4h.framework/core` is required again, which fixes
43
+ `ERR_MODULE_NOT_FOUND: Cannot find package '@t4h.framework/webhook'` on
44
+ projects that never call `webhook()`. `hmac` and `jwt` callback authorizers are
45
+ loaded from the project when `@t4h.framework/hmac` / `@t4h.framework/jwks` are
46
+ installed; a callback whose declared `auth` needs a missing package answers 500
47
+ naming the package to install.
48
+
49
+ ### Patch Changes
50
+
51
+ - Updated dependencies [[`1b1509f`](https://github.com/tech4humans-brasil/framework/commit/1b1509f9b6d2554dfab1f7633c3d022249e4fa01), [`1b1509f`](https://github.com/tech4humans-brasil/framework/commit/1b1509f9b6d2554dfab1f7633c3d022249e4fa01)]:
52
+ - @t4h.framework/core@0.13.0
53
+
54
+ ## 0.2.2
55
+
56
+ ### Patch Changes
57
+
58
+ - Updated dependencies [[`72e08ff`](https://github.com/tech4humans-brasil/framework/commit/72e08ff86e0ce735ef73ccdf33b0dc01cdb8b6f5)]:
59
+ - @t4h.framework/core@0.12.0
60
+
61
+ ## 0.2.1
62
+
63
+ ### Patch Changes
64
+
65
+ - Updated dependencies [[`8e8ffb2`](https://github.com/tech4humans-brasil/framework/commit/8e8ffb2ac0739e2f2a1f0af2ed9ebeffe2964776)]:
66
+ - @t4h.framework/core@0.11.0
9
67
 
10
68
  ## 0.2.0
11
69
 
package/README.md CHANGED
@@ -12,6 +12,7 @@ Requires `@t4h.framework/core` (same major line as this package).
12
12
  |------------------|---------|
13
13
  | `@t4h.framework/hmac` | `HMACAuthorization`, `HMACAuthorizationContext`, `HMACAlgorithm`, and related types |
14
14
  | `@t4h.framework/hmac/authorize` | Default async handler invoked by the runtime with the manifest context |
15
+ | `@t4h.framework/hmac/callback` | Default export `hmacCallback`: `hmac` callback authorizer for the core `AsyncActivityCallback.authorize` (`pending({ auth: { type: 'hmac' } })`) |
15
16
 
16
17
  ## `HMACAuthorization`
17
18
 
@@ -0,0 +1,3 @@
1
+ import { AsyncActivityCallback, type AsyncActivityCallbackAuthHmac } from '@t4h.framework/core';
2
+ export default function hmacCallback(auth: AsyncActivityCallbackAuthHmac, request: AsyncActivityCallback.Delivery): Promise<boolean>;
3
+ //# sourceMappingURL=hmac-callback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmac-callback.d.ts","sourceRoot":"","sources":["../src/hmac-callback.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,6BAA6B,EACnC,MAAM,qBAAqB,CAAA;AAI5B,wBAA8B,YAAY,CACxC,IAAI,EAAE,6BAA6B,EACnC,OAAO,EAAE,qBAAqB,CAAC,QAAQ,GACtC,OAAO,CAAC,OAAO,CAAC,CA4BlB"}
@@ -0,0 +1,26 @@
1
+ import { AsyncActivityCallback, } from '@t4h.framework/core';
2
+ import hmac from './hmac-authorize.js';
3
+ export default async function hmacCallback(auth, request) {
4
+ const signature = AsyncActivityCallback.getHeader(request.headers, auth.header);
5
+ if (!signature)
6
+ return false;
7
+ const timestamp = auth.timestampHeader
8
+ ? AsyncActivityCallback.getHeader(request.headers, auth.timestampHeader)
9
+ : undefined;
10
+ if (auth.timestampHeader && !timestamp)
11
+ return false;
12
+ const rawPayload = (auth.signedPayload ?? '{body}')
13
+ .replaceAll('{timestamp}', timestamp ?? '')
14
+ .replaceAll('{body}', request.rawBody);
15
+ return hmac({
16
+ secret: auth.secret,
17
+ signature,
18
+ rawPayload,
19
+ algorithm: auth.algorithm,
20
+ signatureFormat: auth.signatureFormat,
21
+ signaturePrefix: auth.signaturePrefix,
22
+ timestamp,
23
+ toleranceInSeconds: auth.toleranceInSeconds,
24
+ });
25
+ }
26
+ //# sourceMappingURL=hmac-callback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmac-callback.js","sourceRoot":"","sources":["../src/hmac-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,IAAmC,EACnC,OAAuC;IAEvC,MAAM,SAAS,GAAG,qBAAqB,CAAC,SAAS,CAC/C,OAAO,CAAC,OAAO,EACf,IAAI,CAAC,MAAM,CACZ,CAAA;IAED,IAAI,CAAC,SAAS;QAAE,OAAO,KAAK,CAAA;IAE5B,MAAM,SAAS,GAAG,IAAI,CAAC,eAAe;QACpC,CAAC,CAAC,qBAAqB,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC;QACxE,CAAC,CAAC,SAAS,CAAA;IAEb,IAAI,IAAI,CAAC,eAAe,IAAI,CAAC,SAAS;QAAE,OAAO,KAAK,CAAA;IAEpD,MAAM,UAAU,GAAG,CAAC,IAAI,CAAC,aAAa,IAAI,QAAQ,CAAC;SAChD,UAAU,CAAC,aAAa,EAAE,SAAS,IAAI,EAAE,CAAC;SAC1C,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;IAExC,OAAO,IAAI,CAAC;QACV,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,SAAS;QACT,UAAU;QACV,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,eAAe,EAAE,IAAI,CAAC,eAAe;QACrC,eAAe,EAAE,IAAI,CAAC,eAAe;QACrC,SAAS;QACT,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;KAC5C,CAAC,CAAA;AACJ,CAAC"}
package/dist/hmac.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './hmac-authorize.js';
2
+ export * from './hmac-callback.js';
2
3
  export * from './models/HMACAuthorization.js';
3
4
  //# sourceMappingURL=hmac.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hmac.d.ts","sourceRoot":"","sources":["../src/hmac.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,+BAA+B,CAAA"}
1
+ {"version":3,"file":"hmac.d.ts","sourceRoot":"","sources":["../src/hmac.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,+BAA+B,CAAA"}
package/dist/hmac.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './hmac-authorize.js';
2
+ export * from './hmac-callback.js';
2
3
  export * from './models/HMACAuthorization.js';
3
4
  //# sourceMappingURL=hmac.js.map
package/dist/hmac.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hmac.js","sourceRoot":"","sources":["../src/hmac.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,+BAA+B,CAAA"}
1
+ {"version":3,"file":"hmac.js","sourceRoot":"","sources":["../src/hmac.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/hmac",
3
- "version": "0.0.0-experimental-20260907215424",
3
+ "version": "0.0.0-experimental-20260909045544",
4
4
  "description": "HMAC module for the T4H Framework authorization",
5
5
  "homepage": "https://github.com/tech4humans-brasil/framework/tree/main/packages/hmac",
6
6
  "bugs": "https://github.com/tech4humans-brasil/framework/issues",
@@ -20,6 +20,10 @@
20
20
  "./authorize": {
21
21
  "types": "./dist/hmac-authorize.d.ts",
22
22
  "import": "./dist/hmac-authorize.js"
23
+ },
24
+ "./callback": {
25
+ "types": "./dist/hmac-callback.d.ts",
26
+ "import": "./dist/hmac-callback.js"
23
27
  }
24
28
  },
25
29
  "module": "./dist/hmac.js",
@@ -37,12 +41,12 @@
37
41
  "test:watch": "vitest"
38
42
  },
39
43
  "devDependencies": {
40
- "@t4h.framework/core": "^0.0.0-experimental-20260907215424",
44
+ "@t4h.framework/core": "^0.0.0-experimental-20260909045544",
41
45
  "typescript": "^5.9.3",
42
46
  "vitest": "^4.0.18"
43
47
  },
44
48
  "peerDependencies": {
45
- "@t4h.framework/core": "^0.0.0-experimental-20260907215424"
49
+ "@t4h.framework/core": "^0.0.0-experimental-20260909045544"
46
50
  },
47
51
  "packageManager": "yarn@4.12.0",
48
52
  "engines": {