Socket
Socket
Sign inDemoInstall

@urql/exchange-auth

Package Overview
Dependencies
Maintainers
25
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@urql/exchange-auth - npm Package Compare versions

Comparing version 2.1.4 to 2.1.5-canary-657bd0c6

9

CHANGELOG.md
# Changelog
## 2.1.5-canary-657bd0c6
### Patch Changes
- Handle `refreshAuth` rejections and pass the resulting error on to `OperationResult`s on the authentication queue
Submitted by [@kitten](https://github.com/kitten) (See [#3307](https://github.com/urql-graphql/urql/pull/3307))
- Updated dependencies (See [#3298](https://github.com/urql-graphql/urql/pull/3298), [#3288](https://github.com/urql-graphql/urql/pull/3288), and [#3299](https://github.com/urql-graphql/urql/pull/3299))
- @urql/core@4.0.11-canary-657bd0c6
## 2.1.4

@@ -4,0 +13,0 @@

23

dist/urql-exchange-auth.js

@@ -71,5 +71,5 @@ Object.defineProperty(exports, '__esModule', { value: true });

var retries = wonka.makeSubject();
var errors = wonka.makeSubject();
var retryQueue = new Map();
function flushQueue(_config) {
if (_config) config = _config;
function flushQueue() {
authPromise = undefined;

@@ -80,2 +80,10 @@ var queue = retryQueue;

}
function errorQueue(error) {
authPromise = undefined;
var queue = retryQueue;
retryQueue = new Map();
queue.forEach(operation => {
errors.next(core.makeErrorResult(operation, error));
});
}
var authPromise;

@@ -106,3 +114,6 @@ var config = null;

}
})).then(flushQueue);
})).then(_config => {
if (_config) config = _config;
flushQueue();
});
function refreshAuth(operation) {

@@ -114,3 +125,3 @@ // add to retry queue to try again later

if (config && !authPromise) {
authPromise = config.refreshAuth().finally(flushQueue);
authPromise = config.refreshAuth().then(flushQueue).catch(errorQueue);
}

@@ -147,3 +158,3 @@ }

var result$ = forward(opsWithAuth$);
return wonka.filter(result => {
return wonka.merge([errors.source, wonka.filter(result => {
if (!bypassQueue.has(result.operation.context._instance) && result.error && didAuthError(result) && !result.operation.context.authAttempt) {

@@ -157,3 +168,3 @@ refreshAuth(result.operation);

return true;
})(result$);
})(result$)]);
};

@@ -160,0 +171,0 @@ };

@@ -1,2 +0,2 @@

Object.defineProperty(exports,"__esModule",{value:!0});var t=require("wonka"),e=require("@urql/core"),n=(t,n)=>e.makeOperation(t.kind,t,{...t.context,authAttempt:n});exports.authExchange=function(r){return({client:o,forward:a})=>{var i,c=new Set,u=t.makeSubject(),s=new Map;function p(t){t&&(h=t),i=void 0;var e=s;s=new Map,e.forEach(u.next)}var h=null;return l=>{function d(t){s.set(t.key,n(t,!0)),h&&!i&&(i=h.refreshAuth().finally(p))}function x(t){return h?h.addAuthToOperation(t):t}i=Promise.resolve().then((()=>r({mutate(n,r,a){var i=o.createRequestOperation("mutation",e.createRequest(n,r),a);return t.toPromise(t.take(1)(t.filter((t=>t.operation.key===i.key&&i.context._instance===t.operation.context._instance))(t.onStart((()=>{var t=x(i);c.add(t.context._instance),u.next(t)}))(k))))},appendHeaders(t,n){var r="function"==typeof t.context.fetchOptions?t.context.fetchOptions():t.context.fetchOptions||{};return e.makeOperation(t.kind,t,{...t.context,fetchOptions:{...r,headers:{...r.headers,...n}}})}}))).then(p);var f=t.filter(Boolean)(t.map((t=>"teardown"===t.kind?(s.delete(t.key),t):t.context._instance&&c.has(t.context._instance)?t:t.context.authAttempt?x(t):i?(s.has(t.key)||s.set(t.key,n(t,!1)),null):function(t){return!t.context.authAttempt&&h&&h.willAuthError&&h.willAuthError(t)}(t)?(d(t),null):x(n(t,!1))))(t.merge([u.source,l]))),k=a(f);return t.filter((t=>!c.has(t.operation.context._instance)&&t.error&&function(t){return h&&h.didAuthError&&h.didAuthError(t.error,t.operation)}(t)&&!t.operation.context.authAttempt?(d(t.operation),!1):(c.has(t.operation.context._instance)&&c.delete(t.operation.context._instance),!0)))(k)}}};
Object.defineProperty(exports,"__esModule",{value:!0});var e=require("wonka"),t=require("@urql/core"),n=(e,n)=>t.makeOperation(e.kind,e,{...e.context,authAttempt:n});exports.authExchange=function(r){return({client:o,forward:a})=>{var i,c=new Set,u=e.makeSubject(),s=e.makeSubject(),p=new Map;function h(){i=void 0;var e=p;p=new Map,e.forEach(u.next)}function d(e){i=void 0;var n=p;p=new Map,n.forEach((n=>{s.next(t.makeErrorResult(n,e))}))}var l=null;return x=>{function f(e){p.set(e.key,n(e,!0)),l&&!i&&(i=l.refreshAuth().then(h).catch(d))}function k(e){return l?l.addAuthToOperation(e):e}i=Promise.resolve().then((()=>r({mutate(n,r,a){var i=o.createRequestOperation("mutation",t.createRequest(n,r),a);return e.toPromise(e.take(1)(e.filter((e=>e.operation.key===i.key&&i.context._instance===e.operation.context._instance))(e.onStart((()=>{var e=k(i);c.add(e.context._instance),u.next(e)}))(v))))},appendHeaders(e,n){var r="function"==typeof e.context.fetchOptions?e.context.fetchOptions():e.context.fetchOptions||{};return t.makeOperation(e.kind,e,{...e.context,fetchOptions:{...r,headers:{...r.headers,...n}}})}}))).then((e=>{e&&(l=e),h()}));var m=e.filter(Boolean)(e.map((e=>"teardown"===e.kind?(p.delete(e.key),e):e.context._instance&&c.has(e.context._instance)?e:e.context.authAttempt?k(e):i?(p.has(e.key)||p.set(e.key,n(e,!1)),null):function(e){return!e.context.authAttempt&&l&&l.willAuthError&&l.willAuthError(e)}(e)?(f(e),null):k(n(e,!1))))(e.merge([u.source,x]))),v=a(m);return e.merge([s.source,e.filter((e=>!c.has(e.operation.context._instance)&&e.error&&function(e){return l&&l.didAuthError&&l.didAuthError(e.error,e.operation)}(e)&&!e.operation.context.authAttempt?(f(e.operation),!1):(c.has(e.operation.context._instance)&&c.delete(e.operation.context._instance),!0)))(v)])}}};
//# sourceMappingURL=urql-exchange-auth.min.js.map
{
"name": "@urql/exchange-auth",
"version": "2.1.4",
"version": "2.1.5-canary-657bd0c6",
"description": "An exchange for managing authentication and token refresh in urql",

@@ -9,2 +9,3 @@ "sideEffects": false,

"license": "MIT",
"author": "urql GraphQL Contributors",
"repository": {

@@ -43,3 +44,3 @@ "type": "git",

"dependencies": {
"@urql/core": ">=4.0.0",
"@urql/core": "4.0.11-canary-657bd0c6",
"wonka": "^6.3.2"

@@ -49,3 +50,3 @@ },

"graphql": "^16.0.0",
"@urql/core": "4.0.8"
"@urql/core": "4.0.11-canary-657bd0c6"
},

@@ -52,0 +53,0 @@ "publishConfig": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc