Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use cross-fetch instead of XMLHttpRequest to handle redirects #15

Merged
merged 5 commits into from
Oct 1, 2019

Conversation

mi-xu
Copy link
Contributor

@mi-xu mi-xu commented Sep 26, 2019

This PR fixes #14

  • Replaced XMLHttpRequest with axios for making Ajax requests. This provides a higher level syntax for simpler and more robust handling of HTTP responses with a status other than 200. It comes at the cost of an additional 1.8kb package dependency (gzipped + minified), which I feel is worth the tradeoff compared to reinventing the wheel for handling a lot of edge cases.

Test by registering the resolver to resolve "did:web:uport.me"

import { Resolver } from 'did-resolver'
import getResolver from 'web-did-resolver'

const resolver = new Resolver(getResolver())
const doc = resolver.resolve('did:web:uport.me')
console.log(doc)

@ajunge @mirceanis does this solution work for the issues you encountered?

@mi-xu mi-xu requested review from mirceanis and ajunge September 26, 2019 18:19
@pelle
Copy link
Contributor

pelle commented Sep 26, 2019

Since fetch is now everywhere, I'd prefer to use one of the fetch compatibility layers. Such as (but not necessarily) https://www.npmjs.com/package/cross-fetch

@mi-xu mi-xu changed the title feat: use axios instead of XMLHttpRequest to handle redirects feat: use cross-fetch instead of XMLHttpRequest to handle redirects Sep 27, 2019
.vscode/settings.json Outdated Show resolved Hide resolved
Copy link
Member

@mirceanis mirceanis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@mi-xu mi-xu merged commit 4378c71 into develop Oct 1, 2019
@mi-xu mi-xu deleted the bug/redirect-did-doc branch October 1, 2019 15:47
mirceanis pushed a commit that referenced this pull request Oct 24, 2019
* feat: use axios instead of XMLHttpRequest to handle redirects

* bump version to publish dev version

* refactor: replace axios with cross-fetch

* style: remove some trailing commas

* chore: fix trailing comma auto-format
uport-automation-bot pushed a commit that referenced this pull request Oct 24, 2019
# [1.1.0](1.0.1...1.1.0) (2019-10-24)

### Features

* remove default export ([3952bef](3952bef))
* use cross-fetch instead of XMLHttpRequest ([#15](#15)) ([dadf682](dadf682))
uport-automation-bot pushed a commit that referenced this pull request Oct 24, 2019
# [1.2.0](1.1.0...1.2.0) (2019-10-24)

### Features

* remove default export ([9ef0b37](9ef0b37))
* use cross-fetch instead of XMLHttpRequest ([#15](#15)) ([4378c71](4378c71))
@uport-automation-bot
Copy link
Collaborator

🎉 This PR is included in version 1.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@uport-automation-bot uport-automation-bot added the triage This issue is currently being examined label Oct 24, 2019
veramo-bot pushed a commit to veramolabs/plc-did-resolver that referenced this pull request Apr 26, 2023
# 1.0.0 (2023-04-26)

### Bug Fixes

* **build:** publish types in package.json ([174afe8](174afe8))
* CORS bug ([decentralized-identity#88](https://github.com/veramolabs/plc-did-resolver/issues/88)) ([2a5b5d1](2a5b5d1))
* **deps:** bump did-resolver to 3.1.0 ([08358ec](08358ec))
* **deps:** bump did-resolver to 3.1.3 ([f62af45](f62af45))
* **deps:** groom the build scripts and dependencies ([decentralized-identity#120](https://github.com/veramolabs/plc-did-resolver/issues/120)) ([757f6ec](757f6ec))
* **deps:** pin dependencies ([decentralized-identity#89](https://github.com/veramolabs/plc-did-resolver/issues/89)) ([926eb1f](926eb1f))
* **deps:** update all non-major dependencies ([decentralized-identity#93](https://github.com/veramolabs/plc-did-resolver/issues/93)) ([13d8f18](13d8f18))
* **deps:** update all non-major dependencies to v17.0.2 ([0e9e2f0](0e9e2f0))
* **deps:** update all non-major dependencies to v18.1.0 ([cd3ed19](cd3ed19))
* **deps:** update all non-major dependencies to v18.2.0 ([cd99aa3](cd99aa3))
* **deps:** update dependencies, remove ts-jest ([789ec69](789ec69))
* **deps:** update dependency did-resolver to v1.1.0 ([decentralized-identity#39](https://github.com/veramolabs/plc-did-resolver/issues/39)) ([4ade39d](4ade39d))
* **deps:** update dependency did-resolver to v2 ([decentralized-identity#56](https://github.com/veramolabs/plc-did-resolver/issues/56)) ([b420866](b420866))
* **deps:** update dependency did-resolver to v2.1.1 ([decentralized-identity#70](https://github.com/veramolabs/plc-did-resolver/issues/70)) ([0a0f902](0a0f902))
* **deps:** update dependency did-resolver to v3 ([decentralized-identity#94](https://github.com/veramolabs/plc-did-resolver/issues/94)) ([18d1a1d](18d1a1d))
* **deps:** Update dependency did-resolver to v3.1.1 ([91cc1c6](91cc1c6))
* **deps:** Update dependency did-resolver to v3.1.2 ([7902b3f](7902b3f))
* **deps:** Update dependency did-resolver to v3.1.3 ([d77839f](d77839f))
* **deps:** Update dependency did-resolver to v3.1.4 ([02d4c7d](02d4c7d))
* **deps:** Update dependency did-resolver to v3.1.5 ([0728ffb](0728ffb))
* **deps:** Update dependency did-resolver to v3.2.0 ([d33f51e](d33f51e))
* **deps:** Update dependency did-resolver to v3.2.2 ([f494fbe](f494fbe))
* **deps:** Update dependency did-resolver to v4 ([74b825f](74b825f))
* **deps:** Update dependency did-resolver to v4.0.1 ([63d7fc2](63d7fc2))
* **deps:** Update dependency did-resolver to v4.1.0 ([81fa649](81fa649))
* **deps:** update dependency react-scripts to v5 ([bbc4b35](bbc4b35))
* **deps:** update dependency react-scripts to v5.0.1 ([36d0e22](36d0e22))
* **deps:** update react monorepo to v18 ([8f21c88](8f21c88))
* remove checks for a [@context](https://github.com/context) field ([b814b6c](b814b6c)), closes [decentralized-identity#26](https://github.com/veramolabs/plc-did-resolver/issues/26)

### Features

* forked web-did-resolver and refactored to be plc-did-resolver ([7fdeefe](7fdeefe))
* remove default export ([3952bef](3952bef))
* remove default export ([9ef0b37](9ef0b37))
* support for path in the did ([904d88c](904d88c)), closes [decentralized-identity#32](https://github.com/veramolabs/plc-did-resolver/issues/32) [decentralized-identity#33](https://github.com/veramolabs/plc-did-resolver/issues/33)
* update to latest did spec ([decentralized-identity#92](https://github.com/veramolabs/plc-did-resolver/issues/92)) ([4779436](4779436)), closes [decentralized-identity#91](https://github.com/veramolabs/plc-did-resolver/issues/91)
* use cross-fetch instead of XMLHttpRequest ([decentralized-identity#15](https://github.com/veramolabs/plc-did-resolver/issues/15)) ([dadf682](dadf682))
* use cross-fetch instead of XMLHttpRequest ([decentralized-identity#15](https://github.com/veramolabs/plc-did-resolver/issues/15)) ([4378c71](4378c71))

### BREAKING CHANGES

* Resolver now returns a `DIDResolutionResult` that wraps a DIDDocument. No errors are thrown, instead returned as `didResolutionMetadata.error/message`
veramo-bot pushed a commit to veramolabs/peer-did-resolver that referenced this pull request Jan 22, 2024
# 1.0.0 (2024-01-22)

### Bug Fixes

* CORS bug ([decentralized-identity#88](https://github.com/veramolabs/peer-did-resolver/issues/88)) ([2a5b5d1](2a5b5d1))
* **deps:** bump @aviarytech/did-peer to 0.0.22 ([#3](#3)) ([3605a4a](3605a4a))
* **deps:** bump did-resolver to 3.1.0 ([08358ec](08358ec))
* **deps:** bump did-resolver to 3.1.3 ([f62af45](f62af45))
* **deps:** groom the build scripts and dependencies ([decentralized-identity#120](https://github.com/veramolabs/peer-did-resolver/issues/120)) ([757f6ec](757f6ec))
* **deps:** pin dependencies ([decentralized-identity#89](https://github.com/veramolabs/peer-did-resolver/issues/89)) ([926eb1f](926eb1f))
* **deps:** update all non-major dependencies ([decentralized-identity#93](https://github.com/veramolabs/peer-did-resolver/issues/93)) ([13d8f18](13d8f18))
* **deps:** update all non-major dependencies to v17.0.2 ([0e9e2f0](0e9e2f0))
* **deps:** update all non-major dependencies to v18.1.0 ([cd3ed19](cd3ed19))
* **deps:** update all non-major dependencies to v18.2.0 ([cd99aa3](cd99aa3))
* **deps:** update dependencies, remove ts-jest ([789ec69](789ec69))
* **deps:** update dependency did-resolver to v1.1.0 ([decentralized-identity#39](https://github.com/veramolabs/peer-did-resolver/issues/39)) ([4ade39d](4ade39d))
* **deps:** update dependency did-resolver to v2 ([decentralized-identity#56](https://github.com/veramolabs/peer-did-resolver/issues/56)) ([b420866](b420866))
* **deps:** update dependency did-resolver to v2.1.1 ([decentralized-identity#70](https://github.com/veramolabs/peer-did-resolver/issues/70)) ([0a0f902](0a0f902))
* **deps:** update dependency did-resolver to v3 ([decentralized-identity#94](https://github.com/veramolabs/peer-did-resolver/issues/94)) ([18d1a1d](18d1a1d))
* **deps:** Update dependency did-resolver to v3.1.1 ([91cc1c6](91cc1c6))
* **deps:** Update dependency did-resolver to v3.1.2 ([7902b3f](7902b3f))
* **deps:** Update dependency did-resolver to v3.1.3 ([d77839f](d77839f))
* **deps:** Update dependency did-resolver to v3.1.4 ([02d4c7d](02d4c7d))
* **deps:** Update dependency did-resolver to v3.1.5 ([0728ffb](0728ffb))
* **deps:** Update dependency did-resolver to v3.2.0 ([d33f51e](d33f51e))
* **deps:** Update dependency did-resolver to v3.2.2 ([f494fbe](f494fbe))
* **deps:** Update dependency did-resolver to v4 ([74b825f](74b825f))
* **deps:** Update dependency did-resolver to v4.0.1 ([63d7fc2](63d7fc2))
* **deps:** update dependency react-scripts to v5 ([bbc4b35](bbc4b35))
* **deps:** update dependency react-scripts to v5.0.1 ([36d0e22](36d0e22))
* **deps:** update react monorepo to v18 ([8f21c88](8f21c88))
* remove checks for a [@context](https://github.com/context) field ([b814b6c](b814b6c)), closes [decentralized-identity#26](https://github.com/veramolabs/peer-did-resolver/issues/26)

### Features

* refactor to resolve peer-did ([e04640c](e04640c))
* remove default export ([3952bef](3952bef))
* remove default export ([9ef0b37](9ef0b37))
* support for path in the did ([904d88c](904d88c)), closes [decentralized-identity#32](https://github.com/veramolabs/peer-did-resolver/issues/32) [decentralized-identity#33](https://github.com/veramolabs/peer-did-resolver/issues/33)
* update to latest did spec ([decentralized-identity#92](https://github.com/veramolabs/peer-did-resolver/issues/92)) ([4779436](4779436)), closes [decentralized-identity#91](https://github.com/veramolabs/peer-did-resolver/issues/91)
* use cross-fetch instead of XMLHttpRequest ([decentralized-identity#15](https://github.com/veramolabs/peer-did-resolver/issues/15)) ([dadf682](dadf682))
* use cross-fetch instead of XMLHttpRequest ([decentralized-identity#15](https://github.com/veramolabs/peer-did-resolver/issues/15)) ([4378c71](4378c71))

### BREAKING CHANGES

* Resolver now returns a `DIDResolutionResult` that wraps a DIDDocument. No errors are thrown, instead returned as `didResolutionMetadata.error/message`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage This issue is currently being examined
Projects
None yet
Development

Successfully merging this pull request may close these issues.

did.json hosted under a redirect does not resolve
4 participants