Skip to content

Commit

Permalink
Add initial files.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlongley committed Jan 26, 2025
1 parent 3639179 commit 20eb7f9
Show file tree
Hide file tree
Showing 27 changed files with 1,151 additions and 119 deletions.
15 changes: 15 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
root: true,
env: {
node: true
},
extends: [
'digitalbazaar',
'digitalbazaar/jsdoc',
'digitalbazaar/module'
],
ignorePatterns: ['node_modules/'],
rules: {
'unicorn/prefer-node-protocol': 'error'
}
};
7 changes: 0 additions & 7 deletions .eslintrc.js

This file was deleted.

27 changes: 15 additions & 12 deletions .github/workflows/main.yml → .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
timeout-minutes: 10
strategy:
matrix:
node-version: [14.x]
node-version: [22.x]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand All @@ -24,19 +24,20 @@ jobs:
timeout-minutes: 10
services:
mongodb:
image: mongo:4.2
image: mongo:5
ports:
- 27017:27017
strategy:
matrix:
node-version: [12.x, 14.x]
node-version: [20.x, 22.x]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: |
npm install
cd test
npm install
- name: Run test with Node.js ${{ matrix.node-version }}
Expand All @@ -49,27 +50,29 @@ jobs:
timeout-minutes: 10
services:
mongodb:
image: mongo:4.2
image: mongo:5
ports:
- 27017:27017
strategy:
matrix:
node-version: [14.x]
node-version: [22.x]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: |
npm install
cd test
npm install
- name: Generate coverage report
run: |
cd test
npm run coverage-ci
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
file: ./test/coverage/lcov.info
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
legacy-peer-deps=true
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# bedrock-module-template-http ChangeLog
# bedrock-basic-authz-server ChangeLog

## 1.0.0 - TBD
## 1.0.0 - 2025-mm-dd

- See git history for changes.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Bedrock Non-Commercial License v1.0
===================================

Copyright (c) 2011-2021 Digital Bazaar, Inc.
Copyright (c) 2011-2025 Digital Bazaar, Inc.
All rights reserved.

Summary
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# bedrock-module-template-http
# bedrock-basic-authz-server
56 changes: 48 additions & 8 deletions lib/config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,53 @@
/*!
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
* Copyright (c) 2024-2025 Digital Bazaar, Inc. All rights reserved.
*/
import bedrock from 'bedrock';
const {config} = bedrock;
import {config} from '@bedrock/core';
import {NAMESPACE} from './constants.js';

const namespace = 'module-template-http';
const cfg = config[namespace] = {};
const cfg = config[NAMESPACE] = {};

const basePath = '/foo';
cfg.routes = {
basePath
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
};

cfg.authorization = {
oauth2: {
accessTokens: {
// TTL in seconds (default 24 hours = 86400 seconds)
ttl: 86400
},
routes: {
asMetadata: `/.well-known/oauth-authorization-server`,
token: `/openid/token`,
jwks: `/openid/jwks`
},
// 300 second clock skew permitted by default
maxClockSkew: 300,
// note: using undefined `allowedAlgorithms` will use the defaults set
// by the `jose` library that are appropriate for the key / secret type;
// (i.e., only asymmetric crypto will be used here); the top-level/parent
// app should choose to either use `undefined` as the default or specify
// a more restrictive list
/*allowedAlgorithms: [
// RSASSA-PKCS1-v1_ w/sha-XXX
'RS256',
'RS384',
'RS512',
// RSASSA-PSS w/ SHA-XXX
'PS256',
'PS384',
'PS512',
// ECDSA w/ SHA-XXX
'ES256',
'ES256K',
'ES384',
'ES512',
// ed25519 / ed448
'EdDSA'
]*/
}
};
4 changes: 4 additions & 0 deletions lib/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*!
* Copyright (c) 2025 Digital Bazaar, Inc. All rights reserved.
*/
export const NAMESPACE = 'basic-authz-server';
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-2025 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);
}
14 changes: 0 additions & 14 deletions lib/http.js

This file was deleted.

7 changes: 7 additions & 0 deletions lib/http/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*!
* Copyright (c) 2024-2025 Digital Bazaar, Inc. All rights reserved.
*/
import * as middleware from './middleware.js';
import {addOAuth2AuthzServer} from './oauth2.js';

export {middleware, addOAuth2AuthzServer};
Loading

0 comments on commit 20eb7f9

Please sign in to comment.