File tree Expand file tree Collapse file tree 5 files changed +30
-10
lines changed Expand file tree Collapse file tree 5 files changed +30
-10
lines changed Original file line number Diff line number Diff line change 1
1
# bedrock-oauth2-client ChangeLog
2
2
3
+ ## 7.2.0 - 2024-05-dd
4
+
5
+ ### Changed
6
+ - Use ` @digitalbazaar/lru-memoize@4 ` . Existing cache defaults and options
7
+ are coerced from previous versions to the new version.
8
+
3
9
## 7.1.0 - 2024-05-09
4
10
5
11
### Changed
Original file line number Diff line number Diff line change 1
1
/*!
2
- * Copyright 2021 - 2024 Digital Bazaar, Inc.
2
+ * Copyright 2021 - 2025 Digital Bazaar, Inc.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -20,9 +20,9 @@ import {config} from '@bedrock/core';
20
20
21
21
config [ 'oauth2-client' ] = {
22
22
accessTokenCache : {
23
- maxSize : 100 ,
23
+ max : 100 ,
24
24
// 5 minutes
25
- maxAge : 5 * 60 * 1000
25
+ ttl : 5 * 60 * 1000
26
26
} ,
27
27
// time to live - the amount of a time a record will stay in the database
28
28
// before it is expired. 2 week expiration in milliseconds.
Original file line number Diff line number Diff line change 1
1
/*!
2
- * Copyright 2021 - 2024 Digital Bazaar, Inc.
2
+ * Copyright 2021 - 2025 Digital Bazaar, Inc.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -32,10 +32,22 @@ const RETRY_MAX_TIMEOUT = 30000;
32
32
33
33
bedrock . events . on ( 'bedrock.init' , async ( ) => {
34
34
const cfg = bedrock . config [ 'oauth2-client' ] ;
35
- ACCESS_TOKEN_CACHE = new LruCache ( {
36
- max : cfg . accessTokenCache . maxSize ,
37
- maxAge : cfg . accessTokenCache . maxAge
38
- } ) ;
35
+ let cacheConfig = cfg . accessTokenCache ;
36
+
37
+ // coerce `maxSize` w/o `sizeCalculation` to `max`
38
+ if ( cacheConfig . maxSize !== undefined &&
39
+ cacheConfig . sizeCalculation === undefined ) {
40
+ cacheConfig = { ...cacheConfig , max : cacheConfig . maxSize } ;
41
+ delete cacheConfig . maxSize ;
42
+ }
43
+
44
+ // coerce `maxAge` to `ttl` in `cacheConfig`
45
+ if ( cacheConfig . maxAge !== undefined ) {
46
+ cacheConfig = { ...cacheConfig , ttl : cacheConfig . maxAge } ;
47
+ delete cacheConfig . maxAge ;
48
+ }
49
+
50
+ ACCESS_TOKEN_CACHE = new LruCache ( cacheConfig ) ;
39
51
} ) ;
40
52
41
53
/**
Original file line number Diff line number Diff line change 26
26
"homepage" : " https://github.com/digitalbazaar/bedrock-oauth2-client" ,
27
27
"dependencies" : {
28
28
"@digitalbazaar/http-client" : " ^4.0.0" ,
29
- "@digitalbazaar/lru-memoize" : " ^3 .0.0" ,
29
+ "@digitalbazaar/lru-memoize" : " ^4 .0.0" ,
30
30
"p-retry" : " ^6.0.0"
31
31
},
32
32
"peerDependencies" : {
Original file line number Diff line number Diff line change @@ -130,7 +130,9 @@ describe('oauth2-client', () => {
130
130
}
131
131
should . exist ( err ) ;
132
132
should . not . exist ( result ) ;
133
- err . message . should . equal ( 'Request failed with status code 403 Forbidden' ) ;
133
+ err . message . should . equal (
134
+ 'Request failed with status code 403 Forbidden: ' +
135
+ 'GET https://localhost:18443/geterrortest' ) ;
134
136
err . status . should . equal ( 403 ) ;
135
137
} ) ;
136
138
} ) ;
You can’t perform that action at this time.
0 commit comments