@urql/exchange-auth
Advanced tools
Comparing version 2.0.0 to 2.1.0
# Changelog | ||
## 2.1.0 | ||
### Minor Changes | ||
- Update exchanges to drop redundant `share` calls, since `@urql/core`’s `composeExchanges` utility now automatically does so for us | ||
Submitted by [@kitten](https://github.com/kitten) (See [#3082](https://github.com/urql-graphql/urql/pull/3082)) | ||
### Patch Changes | ||
- ⚠️ Fix source maps included with recently published packages, which lost their `sourcesContent`, including additional source files, and had incorrect paths in some of them | ||
Submitted by [@kitten](https://github.com/kitten) (See [#3053](https://github.com/urql-graphql/urql/pull/3053)) | ||
- Upgrade to `wonka@^6.3.0` | ||
Submitted by [@kitten](https://github.com/kitten) (See [#3104](https://github.com/urql-graphql/urql/pull/3104)) | ||
- Avoid infinite loop when `didAuthError` keeps returning true | ||
Submitted by [@JoviDeCroock](https://github.com/JoviDeCroock) (See [#3112](https://github.com/urql-graphql/urql/pull/3112)) | ||
- Updated dependencies (See [#3101](https://github.com/urql-graphql/urql/pull/3101), [#3033](https://github.com/urql-graphql/urql/pull/3033), [#3054](https://github.com/urql-graphql/urql/pull/3054), [#3053](https://github.com/urql-graphql/urql/pull/3053), [#3060](https://github.com/urql-graphql/urql/pull/3060), [#3081](https://github.com/urql-graphql/urql/pull/3081), [#3039](https://github.com/urql-graphql/urql/pull/3039), [#3104](https://github.com/urql-graphql/urql/pull/3104), [#3082](https://github.com/urql-graphql/urql/pull/3082), [#3097](https://github.com/urql-graphql/urql/pull/3097), [#3061](https://github.com/urql-graphql/urql/pull/3061), [#3055](https://github.com/urql-graphql/urql/pull/3055), [#3085](https://github.com/urql-graphql/urql/pull/3085), [#3079](https://github.com/urql-graphql/urql/pull/3079), [#3087](https://github.com/urql-graphql/urql/pull/3087), [#3059](https://github.com/urql-graphql/urql/pull/3059), [#3055](https://github.com/urql-graphql/urql/pull/3055), [#3057](https://github.com/urql-graphql/urql/pull/3057), [#3050](https://github.com/urql-graphql/urql/pull/3050), [#3062](https://github.com/urql-graphql/urql/pull/3062), [#3051](https://github.com/urql-graphql/urql/pull/3051), [#3043](https://github.com/urql-graphql/urql/pull/3043), [#3063](https://github.com/urql-graphql/urql/pull/3063), [#3054](https://github.com/urql-graphql/urql/pull/3054), [#3102](https://github.com/urql-graphql/urql/pull/3102), [#3097](https://github.com/urql-graphql/urql/pull/3097), [#3106](https://github.com/urql-graphql/urql/pull/3106), [#3058](https://github.com/urql-graphql/urql/pull/3058), and [#3062](https://github.com/urql-graphql/urql/pull/3062)) | ||
- @urql/core@4.0.0 | ||
## 2.0.0 | ||
@@ -4,0 +22,0 @@ |
@@ -1,3 +0,2 @@ | ||
import { AnyVariables, TypedDocumentNode, OperationContext, OperationResult, Operation, CombinedError, Exchange } from '@urql/core'; | ||
import { DocumentNode } from 'graphql'; | ||
import { AnyVariables, DocumentInput, OperationContext, OperationResult, Operation, CombinedError, Exchange } from '@urql/core'; | ||
@@ -22,3 +21,3 @@ /** Utilities to use while refreshing authentication tokens. */ | ||
*/ | ||
mutate<Data = any, Variables extends AnyVariables = AnyVariables>(query: DocumentNode | TypedDocumentNode<Data, Variables> | string, variables: Variables, context?: Partial<OperationContext>): Promise<OperationResult<Data>>; | ||
mutate<Data = any, Variables extends AnyVariables = AnyVariables>(query: DocumentInput<Data, Variables>, variables: Variables, context?: Partial<OperationContext>): Promise<OperationResult<Data>>; | ||
/** Adds additional HTTP headers to an `Operation`. | ||
@@ -25,0 +24,0 @@ * |
@@ -6,2 +6,5 @@ Object.defineProperty(exports, '__esModule', { | ||
var core = require('@urql/core'); | ||
/** Utilities to use while refreshing authentication tokens. */ | ||
var addAuthAttemptToOperation = (operation, authAttempt) => core.makeOperation(operation.kind, operation, { | ||
@@ -11,2 +14,3 @@ ...operation.context, | ||
}); | ||
/** Creates an `Exchange` handling control flow for authentication. | ||
@@ -105,2 +109,3 @@ * | ||
retryQueue.set(operation.key, addAuthAttemptToOperation(operation, true)); | ||
// check that another operation isn't already doing refresh | ||
@@ -120,7 +125,8 @@ if (config && !authPromise) { | ||
} | ||
var sharedOps$ = wonka.share(operations$); | ||
var teardownOps$ = wonka.filter(operation => operation.kind === 'teardown')(sharedOps$); | ||
var pendingOps$ = wonka.filter(operation => operation.kind !== 'teardown')(sharedOps$); | ||
var teardownOps$ = wonka.filter(operation => operation.kind === 'teardown')(operations$); | ||
var pendingOps$ = wonka.filter(operation => operation.kind !== 'teardown')(operations$); | ||
var opsWithAuth$ = wonka.filter(Boolean)(wonka.map(operation => { | ||
if (bypassQueue.has(operation)) { | ||
if (operation.context.authAttempt) { | ||
return addAuthToOperation(operation); | ||
} else if (bypassQueue.has(operation)) { | ||
return operation; | ||
@@ -138,3 +144,3 @@ } else if (authPromise) { | ||
})(wonka.merge([retries.source, pendingOps$]))); | ||
var result$ = wonka.share(forward(wonka.merge([opsWithAuth$, teardownOps$]))); | ||
var result$ = forward(wonka.merge([opsWithAuth$, teardownOps$])); | ||
return wonka.filter(result => { | ||
@@ -141,0 +147,0 @@ if (result.error && didAuthError(result) && !result.operation.context.authAttempt) { |
@@ -1,2 +0,2 @@ | ||
Object.defineProperty(exports,"__esModule",{value:!0});var e=require("wonka"),t=require("@urql/core"),r=(e,r)=>t.makeOperation(e.kind,e,{...e.context,authAttempt:r});exports.authExchange=function(n){return({client:o,forward:a})=>{var i,u=new WeakSet,c=e.makeSubject(),h=new Map;function p(e){e&&(l=e),i=void 0;var t=h;h=new Map,t.forEach(c.next)}var l=null;return s=>{function d(e){h.set(e.key,r(e,!0)),l&&!i&&(i=l.refreshAuth().finally(p))}function f(e){return l?l.addAuthToOperation(e):e}i=Promise.resolve().then((()=>n({mutate(r,n,a){var i=o.createRequestOperation("mutation",t.createRequest(r,n),a);return e.toPromise(e.take(1)(e.filter((e=>e.operation.key===i.key))(e.onStart((()=>{var e=f(i);u.add(e),c.next(e)}))(w))))},appendHeaders(e,r){var n="function"==typeof e.context.fetchOptions?e.context.fetchOptions():e.context.fetchOptions||{};return t.makeOperation(e.kind,e,{...e.context,fetchOptions:{...n,headers:{...n.headers,...r}}})}}))).then(p);var k=e.share(s),m=e.filter((e=>"teardown"===e.kind))(k),x=e.filter((e=>"teardown"!==e.kind))(k),v=e.filter(Boolean)(e.map((e=>u.has(e)?e:i?(h.has(e.key)||h.set(e.key,r(e,!1)),null):function(e){return!e.context.authAttempt&&l&&l.willAuthError&&l.willAuthError(e)}(e)?(d(e),null):f(r(e,!1))))(e.merge([c.source,x]))),w=e.share(a(e.merge([v,m])));return e.filter((e=>!(e.error&&function(e){return l&&l.didAuthError&&l.didAuthError(e.error,e.operation)}(e)&&!e.operation.context.authAttempt&&(d(e.operation),1))))(w)}}}; | ||
Object.defineProperty(exports,"__esModule",{value:!0});var e=require("wonka"),t=require("@urql/core"),r=(e,r)=>t.makeOperation(e.kind,e,{...e.context,authAttempt:r});exports.authExchange=function(n){return({client:o,forward:a})=>{var i,u=new WeakSet,c=e.makeSubject(),p=new Map;function h(e){e&&(l=e),i=void 0;var t=p;p=new Map,t.forEach(c.next)}var l=null;return d=>{function f(e){p.set(e.key,r(e,!0)),l&&!i&&(i=l.refreshAuth().finally(h))}function s(e){return l?l.addAuthToOperation(e):e}i=Promise.resolve().then((()=>n({mutate(r,n,a){var i=o.createRequestOperation("mutation",t.createRequest(r,n),a);return e.toPromise(e.take(1)(e.filter((e=>e.operation.key===i.key))(e.onStart((()=>{var e=s(i);u.add(e),c.next(e)}))(v))))},appendHeaders(e,r){var n="function"==typeof e.context.fetchOptions?e.context.fetchOptions():e.context.fetchOptions||{};return t.makeOperation(e.kind,e,{...e.context,fetchOptions:{...n,headers:{...n.headers,...r}}})}}))).then(h);var k=e.filter((e=>"teardown"===e.kind))(d),m=e.filter((e=>"teardown"!==e.kind))(d),x=e.filter(Boolean)(e.map((e=>e.context.authAttempt?s(e):u.has(e)?e:i?(p.has(e.key)||p.set(e.key,r(e,!1)),null):function(e){return!e.context.authAttempt&&l&&l.willAuthError&&l.willAuthError(e)}(e)?(f(e),null):s(r(e,!1))))(e.merge([c.source,m]))),v=a(e.merge([x,k]));return e.filter((e=>!(e.error&&function(e){return l&&l.didAuthError&&l.didAuthError(e.error,e.operation)}(e)&&!e.operation.context.authAttempt&&(f(e.operation),1))))(v)}}}; | ||
//# sourceMappingURL=urql-exchange-auth.min.js.map |
{ | ||
"name": "@urql/exchange-auth", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "An exchange for managing authentication and token refresh in urql", | ||
@@ -42,11 +42,8 @@ "sideEffects": false, | ||
"dependencies": { | ||
"@urql/core": ">=3.2.0", | ||
"wonka": "^6.0.0" | ||
"@urql/core": ">=4.0.0", | ||
"wonka": "^6.3.0" | ||
}, | ||
"peerDependencies": { | ||
"graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" | ||
}, | ||
"devDependencies": { | ||
"graphql": "^16.0.0", | ||
"@urql/core": "3.2.0" | ||
"@urql/core": "4.0.0" | ||
}, | ||
@@ -53,0 +50,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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
99580
2
406
0
- Removedgraphql@16.9.0(transitive)
Updated@urql/core@>=4.0.0
Updatedwonka@^6.3.0