X-Git-Url: https://git.squeep.com/?p=squeep-indieauth-helper;a=blobdiff_plain;f=lib%2Fcommunication.js;h=8f6110f6e3a9c3438a0855ead9af3db3eb59b0e9;hp=0116548d6539eb70fe229df71aee35cf86305034;hb=dca6a761e6fe437a3fbeb24540bb6fa5d0b8eb12;hpb=f0b47c066530ba4cba9aebf0181ca20d1da13815 diff --git a/lib/communication.js b/lib/communication.js index 0116548..8f6110f 100644 --- a/lib/communication.js +++ b/lib/communication.js @@ -124,6 +124,17 @@ class Communication { } + /** + * Valid response statuses. + * Allow 401 as a workaround for one specific client which return such on + * its client identifier endpoint when not yet authenticated. + * @param {Number} status + * @returns {Boolean} + */ + static _validateStatus(status) { + return (status >= 200 && status < 300) || status == 401; + } + /** * A request config skeleton. * @param {String} method @@ -144,6 +155,8 @@ class Communication { responseType: 'text', // So force the matter by eliding all response transformations transformResponse: [ (res) => res ], + + validateStatus: Communication._validateStatus, }; Object.entries(params).map(([k, v]) => config.params.set(k, v)); return config;