Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
bb14d49
Refactor HTTP routes into separate files.
dlongley Sep 24, 2025
99743b1
Add structure for zcap routes.
dlongley Sep 29, 2025
b3ce380
Simplify zcap object model for zcap refresh/policy.
dlongley Sep 30, 2025
6e01944
Add more refresh zcap infrastructure/skeleton code.
dlongley Oct 5, 2025
897c296
Add refreshed zcap cache + zcap refresh implementation.
dlongley Oct 5, 2025
dc13471
Fix linting errors.
dlongley Oct 5, 2025
3ac0f70
Implement zcap refresh policy fetch endpoint.
dlongley Oct 5, 2025
d5b15bc
Update zcap policy data model/use.
dlongley Oct 16, 2025
8b8bf88
Add configurable hard limits on profile agents and zcap policies.
dlongley Oct 17, 2025
d151093
Use `profileAgents.getRootAgents()` for zcap refresh.
dlongley Oct 17, 2025
e2e4032
Set `expires` for refreshed zcap based on policy or default.
dlongley Oct 17, 2025
95fa185
Use `@bedrock/zcap-storage@9.4`.
dlongley Oct 17, 2025
839f2bf
Update changelog.
dlongley Oct 17, 2025
423306d
Set default number of zcap policies to 1000.
dlongley Nov 15, 2025
9e9fd2b
Implement get and delete zcap policy routes.
dlongley Nov 15, 2025
bc71dde
Include `req.host` in redirection URL.
dlongley Nov 16, 2025
da6358a
Implement zcap policy insert and update.
dlongley Nov 16, 2025
eded548
Remove unused code.
dlongley Nov 16, 2025
b9b397a
Improve zcap policy JSON schemas; fix interaction JSON schema.
dlongley Nov 16, 2025
2fd50d3
Load and fix up zcap policy HTTP APIs.
dlongley Nov 16, 2025
5029d8b
Add zcap policy tests.
dlongley Nov 16, 2025
493b84e
Add tests for managing zcap policies.
dlongley Nov 16, 2025
7188d4e
Move config-based var inside `describe()` function.
dlongley Nov 16, 2025
90384b8
Add test infrastructure for zcap refresh tests.
dlongley Nov 16, 2025
e87eba2
Remove unused code.
dlongley Nov 16, 2025
13007b6
Return delegated zcap directly (not nested under `zcap`).
dlongley Nov 16, 2025
53d5dc4
Fix refreshed zcap cache date and cache key computations.
dlongley Nov 16, 2025
b881f67
Create test meter using app identity.
dlongley Nov 16, 2025
ecf4811
Include `baseUrl` in test mock data.
dlongley Nov 16, 2025
347c7f2
Fix zcap refresh tests.
dlongley Nov 16, 2025
40ea7f6
Clean up changelog entry.
dlongley Nov 16, 2025
1cf83c1
Add test for already-expired zcaps.
dlongley Nov 17, 2025
fdc3901
Update github actions.
dlongley Nov 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
timeout-minutes: 10
strategy:
matrix:
node-version: [22.x]
node-version: [24.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
Expand All @@ -29,7 +29,7 @@ jobs:
- 27017:27017
strategy:
matrix:
node-version: [20.x, 22.x]
node-version: [22.x, 24.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
Expand All @@ -55,7 +55,7 @@ jobs:
- 27017:27017
strategy:
matrix:
node-version: [22.x]
node-version: [24.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# bedrock-profile-http ChangeLog

## 26.2.0 - 2025-10-dd

### Added
- Add zcap refresh capability. Policies for zcaps can be created per profile
and delegate, enabling delegates to auto-refresh previously issued that
are compliant with their associated policy. New HTTP routes:
- `/profiles/<profileId>/zcaps/policies`: For creating new policies on
behalf of a controlling profile.
- `/profiles/<profileId>/zcaps/policies/<delegateId>`: For updating
and fetching existing policies on behalf of a controlling profile.
- `/profiles/<profileId>/zcaps/policies/<delegateId>/refresh`: For delegates
to refresh their zcaps according to the matching policy, if any.
- `/profiles/<profileId>/zcaps/policies/<delegateId>/refresh/policy`: For
delegates to view any elements exposed by the controller (profile) of
the policy associated with this endpoint.

## 26.1.0 - 2025-09-19

### Added
Expand Down
33 changes: 32 additions & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,33 @@ cfg.routes = {
basePath
};

cfg.caches = {
// refreshed zcap cache
refreshedZcap: {
// zcaps are not typically large objects (hundreds of bytes); but this
// cache isn't expected to be used frequently either, just for zcap refresh
// retries or misbehaving zcap refresh clients
max: 100,
ttl: 5 * 60 * 1000
}
};

// profile agent zcap config
cfg.zcap = {
// default: 24 hour expiration
// default: 24 hour TTL for delegated zcaps (when a profile agent's zcaps
// are delegated)
ttl: 24 * 60 * 60 * 1000
};

// for middleware that uses zcap-authz
cfg.authorizeZcapInvocationOptions = {
maxChainLength: 10,
// 300 second clock skew permitted by default
maxClockSkew: 300,
// 1 year max TTL by default
maxDelegationTtl: 1 * 60 * 60 * 24 * 365 * 1000
};

// default products (if none specified in request)
cfg.defaultProducts = {
// mock ID for default edv service product
Expand Down Expand Up @@ -67,3 +89,12 @@ cfg.interactions = {
*/
types: {}
};

// optional default limits on number of profile agents, zcap policies etc.
cfg.limits = {
// limit per account; -1 is unlimited; default to -1 for backwards compat;
// future version may set another default limit, e.g., 1000
profileAgents: -1,
// limit per profile; -1 is unlimited; default to 1000
zcapPolicies: 1000
};
27 changes: 27 additions & 0 deletions lib/documentLoader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*!
* Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
*/
import {documentLoader as brDocumentLoader}
from '@bedrock/jsonld-document-loader';
import {didIo} from '@bedrock/did-io';

import '@bedrock/did-context';
import '@bedrock/security-context';
import '@bedrock/veres-one-context';

// load config defaults
import './config.js';

export async function documentLoader(url) {
if(url.startsWith('did:')) {
const document = await didIo.get({did: url});
return {
contextUrl: null,
documentUrl: url,
document
};
}

// finally, try the bedrock document loader
return brDocumentLoader(url);
}
26 changes: 26 additions & 0 deletions lib/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*!
* Copyright (c) 2020-2025 Digital Bazaar, Inc. All rights reserved.
*/
import * as bedrock from '@bedrock/core';
import {ZCAP_CLIENT} from './zcapClient.js';

export async function createMeter({controller, productId, capability} = {}) {
let url;
if(capability) {
url = capability.invocationTarget;
} else {
// only use `url` from config if `capability` is not provided
({url} = bedrock.config['profile-http'].meterService);
}

// create a meter
let meter = {controller, product: {id: productId}};
({data: {meter}} = await ZCAP_CLIENT.write({url, json: meter, capability}));

// return fully qualified meter ID
const {id} = meter;
// ensure `URL` terminates at `/meters` -- in case zcap invocation target
// was attenuated
url = url.slice(0, url.indexOf('/meters') + '/meters'.length);
return {id: `${url}/${id}`};
}
Loading