This repository was archived by the owner on Mar 11, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change 1+ # Unreleased
2+ - [ FIXED] Parsing of max-age from Set-Cookie headers.
3+
14# 4.3.1 (2021-03-17)
25- [ NEW] Add migration guide to the newly supported cloudant-node-sdk
36 (package: @ibm-cloud/cloudant ).
Original file line number Diff line number Diff line change 1- // Copyright © 2019 IBM Corp. All rights reserved.
1+ // Copyright © 2019, 2021 IBM Corp. All rights reserved.
22//
33// Licensed under the Apache License, Version 2.0 (the "License");
44// you may not use this file except in compliance with the License.
@@ -32,7 +32,9 @@ class TokenManager {
3232 _autoRenew ( defaultMaxAgeSecs ) {
3333 debug ( 'Auto renewing token now...' ) ;
3434 this . _renew ( ) . then ( ( response ) => {
35- let maxAgeSecs = cookie . parse ( response . headers [ 'set-cookie' ] [ 0 ] ) [ 'Max-Age' ] || defaultMaxAgeSecs ;
35+ let setCookieHeader = response . headers [ 'set-cookie' ] ;
36+ let headerValue = Array . isArray ( setCookieHeader ) ? setCookieHeader [ 0 ] : setCookieHeader ;
37+ let maxAgeSecs = cookie . parse ( headerValue ) [ 'Max-Age' ] || defaultMaxAgeSecs ;
3638 let delayMSecs = maxAgeSecs / 2 * 1000 ;
3739 debug ( `Renewing token in ${ delayMSecs } milliseconds.` ) ;
3840 setTimeout ( this . _autoRenew . bind ( this , defaultMaxAgeSecs ) , delayMSecs ) . unref ( ) ;
You can’t perform that action at this time.
0 commit comments