@bedrock/account-http
Advanced tools
Comparing version 7.1.2 to 8.0.0
# bedrock-account-http ChangeLog | ||
## 8.0.0 - 2023-10-24 | ||
### Added | ||
- Add optional `authorization` value when registering an account and | ||
define first instance of it that uses a captcha via the Cloudflare | ||
Turnstile service. | ||
### Changed | ||
- **BREAKING**: Drop support for Node.js < 18. | ||
- Add `@bedrock/turnstile` peer dependency. This module requires Node.js 18+ and | ||
must be installed by top-level applications. | ||
## 7.1.2 - 2023-10-24 | ||
@@ -4,0 +16,0 @@ |
/*! | ||
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved. | ||
* Copyright (c) 2019-2023 Digital Bazaar, Inc. All rights reserved. | ||
*/ | ||
@@ -10,3 +10,9 @@ import {config} from '@bedrock/core'; | ||
const cfg = config['account-http'] = {}; | ||
const cfg = config['account-http'] = { | ||
// account registration options | ||
registration: { | ||
// default to false, set name of service as string | ||
authorizationRequired: false | ||
} | ||
}; | ||
@@ -13,0 +19,0 @@ cfg.routes = { |
@@ -9,2 +9,3 @@ /*! | ||
import {asyncHandler} from '@bedrock/express'; | ||
import {authorizeRegistration} from './authorizations.js'; | ||
import boolParser from 'express-query-boolean'; | ||
@@ -46,2 +47,6 @@ import {createValidateMiddleware} from '@bedrock/validation'; | ||
if(cfg.registration.authorizationRequired.length > 0) { | ||
await authorizeRegistration({req}); | ||
} | ||
// anyone may create a new account; must be rate limited via another | ||
@@ -221,2 +226,1 @@ // means if necessary | ||
} | ||
{ | ||
"name": "@bedrock/account-http", | ||
"version": "7.1.2", | ||
"version": "8.0.0", | ||
"type": "module", | ||
@@ -30,2 +30,3 @@ "description": "HTTP API for Bedrock User Accounts", | ||
"express-query-int": "^3.0.0", | ||
"forwarded": "^0.2.0", | ||
"uuid": "^9.0.0" | ||
@@ -38,2 +39,3 @@ }, | ||
"@bedrock/passport": "^11.0.0", | ||
"@bedrock/turnstile": "^1.0.2", | ||
"@bedrock/validation": "^7.0.0" | ||
@@ -45,7 +47,10 @@ }, | ||
"devDependencies": { | ||
"eslint": "^8.32.0", | ||
"eslint-config-digitalbazaar": "^4.2.0", | ||
"eslint-plugin-jsdoc": "^39.6.8", | ||
"eslint": "^8.52.0", | ||
"eslint-config-digitalbazaar": "^5.0.1", | ||
"eslint-plugin-jsdoc": "^46.8.2", | ||
"jsdoc-to-markdown": "^8.0.0" | ||
}, | ||
"engines": { | ||
"node": ">=18" | ||
} | ||
} |
@@ -13,3 +13,17 @@ /*! | ||
properties: { | ||
email: schemas.email() | ||
email: schemas.email(), | ||
authorization: { | ||
type: 'object', | ||
additionalProperties: false, | ||
required: ['type', 'token'], | ||
properties: { | ||
type: { | ||
type: 'string', | ||
enum: ['turnstile'] | ||
}, | ||
token: { | ||
type: 'string' | ||
} | ||
} | ||
} | ||
} | ||
@@ -16,0 +30,0 @@ }; |
@@ -88,2 +88,18 @@ /*! | ||
describe('post /', function() { | ||
it('should create account with authorization', async function() { | ||
config['account-http'].registration.authorizationRequired = 'turnstile'; | ||
const authorization = { | ||
token: 'XXXX.DUMMY.TOKEN.XXXX', | ||
type: 'turnstile' | ||
}; | ||
const email = {email: 'auth@digitalbazaar.com', authorization}; | ||
const result = await api.post('/', email); | ||
result.status.should.equal(201); | ||
config['account-http'].registration.authorizationRequired = false; | ||
}); | ||
it('should create account without authorization', async function() { | ||
const email = {email: 'noauth@digitalbazaar.com'}; | ||
const result = await api.post('/', email); | ||
result.status.should.equal(201); | ||
}); | ||
it('should return 400 if there is no email', async function() { | ||
@@ -95,3 +111,5 @@ const result = await api.post('/'); | ||
it('should return 201 if there is an email', async function() { | ||
const result = await api.post('/', {email: 'newuser@digitalbazaar.com'}); | ||
const result = await api.post('/', { | ||
email: 'newuser@digitalbazaar.com' | ||
}); | ||
result.status.should.equal(201); | ||
@@ -98,0 +116,0 @@ }); |
@@ -34,2 +34,3 @@ { | ||
"@bedrock/test": "^8.0.0", | ||
"@bedrock/turnstile": "^1.0.2", | ||
"@bedrock/validation": "^7.0.0", | ||
@@ -39,3 +40,4 @@ "apisauce": "^2.0.0", | ||
"cross-env": "^7.0.2", | ||
"sinon": "^9.0.2" | ||
"sinon": "^17.0.0", | ||
"uuid": "^9.0.0" | ||
}, | ||
@@ -42,0 +44,0 @@ "c8": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42596
17
795
10
+ Addedforwarded@^0.2.0
+ Added@bedrock/core@6.2.0(transitive)
+ Added@bedrock/https-agent@4.1.0(transitive)
+ Added@bedrock/turnstile@1.0.2(transitive)
+ Added@digitalbazaar/http-client@4.1.1(transitive)
+ Addedky@1.7.2(transitive)
+ Addedundici@6.21.0(transitive)
- Removed@bedrock/core@6.3.0(transitive)