From ca35f6b87f3cb6fa65316d3c60f11d0ed9c7216f Mon Sep 17 00:00:00 2001 From: Travis Vachon Date: Thu, 30 Mar 2023 10:12:48 -0700 Subject: [PATCH] feat: use new faster auth function * update `@w3storage/access` dep to make the minimum version the one that has this new auth function * use new polling-based auth function - auth feels muuuuuch faster in local testing --- packages/keyring-core/package.json | 2 +- packages/react-keyring/package.json | 2 +- .../react-keyring/src/providers/Keyring.tsx | 4 +-- packages/solid-keyring/package.json | 2 +- .../solid-keyring/src/providers/Keyring.ts | 4 +-- packages/vue-keyring/package.json | 2 +- pnpm-lock.yaml | 33 +++++++++++-------- 7 files changed, 28 insertions(+), 21 deletions(-) diff --git a/packages/keyring-core/package.json b/packages/keyring-core/package.json index 45d444ec..b78899d0 100644 --- a/packages/keyring-core/package.json +++ b/packages/keyring-core/package.json @@ -33,7 +33,7 @@ "dependencies": { "@ucanto/interface": "^6.2.0", "@ucanto/principal": "^5.1.0", - "@web3-storage/access": "^11.0.0" + "@web3-storage/access": "^11.2.0" }, "eslintConfig": { "extends": [ diff --git a/packages/react-keyring/package.json b/packages/react-keyring/package.json index 00dd5420..6d90f933 100644 --- a/packages/react-keyring/package.json +++ b/packages/react-keyring/package.json @@ -39,7 +39,7 @@ "@testing-library/user-event": "^14.4.3", "@ucanto/interface": "^6.2.0", "@ucanto/principal": "^5.1.0", - "@web3-storage/access": "^11.0.0" + "@web3-storage/access": "^11.2.0" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0" diff --git a/packages/react-keyring/src/providers/Keyring.tsx b/packages/react-keyring/src/providers/Keyring.tsx index bf44d301..97faaaaf 100644 --- a/packages/react-keyring/src/providers/Keyring.tsx +++ b/packages/react-keyring/src/providers/Keyring.tsx @@ -15,7 +15,7 @@ import type { } from '@w3ui/keyring-core' import type { Agent } from '@web3-storage/access' import type { Abilities } from '@web3-storage/access/types' -import { authorizeWithSocket } from '@web3-storage/access/agent' +import { authorizeWaitAndClaim } from '@web3-storage/access/agent' import type { Capability, Delegation, @@ -100,7 +100,7 @@ export function KeyringProvider ({ setRegisterAbortController(controller) try { - await authorizeWithSocket(agent, email, { signal: controller.signal }) + await authorizeWaitAndClaim(agent, email, { signal: controller.signal }) // TODO is there other state that needs to be initialized? setAccount(email) const newSpaces = getSpaces(agent) diff --git a/packages/solid-keyring/package.json b/packages/solid-keyring/package.json index cb17e970..bd42e57d 100644 --- a/packages/solid-keyring/package.json +++ b/packages/solid-keyring/package.json @@ -31,7 +31,7 @@ "@ucanto/interface": "^6.2.0", "@ucanto/principal": "^5.1.0", "@w3ui/keyring-core": "workspace:^", - "@web3-storage/access": "^11.0.0" + "@web3-storage/access": "^11.2.0" }, "peerDependencies": { "solid-js": "^1.5.0" diff --git a/packages/solid-keyring/src/providers/Keyring.ts b/packages/solid-keyring/src/providers/Keyring.ts index fed07894..ae15d134 100644 --- a/packages/solid-keyring/src/providers/Keyring.ts +++ b/packages/solid-keyring/src/providers/Keyring.ts @@ -7,7 +7,7 @@ import type { } from '@w3ui/keyring-core' import type { Agent } from '@web3-storage/access' import type { Abilities } from '@web3-storage/access/types' -import { authorizeWithSocket } from '@web3-storage/access/agent' +import { authorizeWaitAndClaim } from '@web3-storage/access/agent' import type { Delegation, Capability, DID, Principal } from '@ucanto/interface' @@ -95,7 +95,7 @@ export const KeyringProvider: ParentComponent = ( setRegisterAbortController(controller) try { - await authorizeWithSocket(agent, email, { signal: controller.signal }) + await authorizeWaitAndClaim(agent, email, { signal: controller.signal }) // TODO is there other state that needs to be initialized? setState('account', email) const newSpaces = getSpaces(agent) diff --git a/packages/vue-keyring/package.json b/packages/vue-keyring/package.json index 902f5581..4b59b7fb 100644 --- a/packages/vue-keyring/package.json +++ b/packages/vue-keyring/package.json @@ -35,7 +35,7 @@ "devDependencies": { "@ucanto/interface": "^6.2.0", "@ucanto/principal": "^5.1.0", - "@web3-storage/access": "^11.0.0" + "@web3-storage/access": "^11.2.0" }, "eslintConfig": { "extends": [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b420b035..55184692 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -466,11 +466,11 @@ importers: specifiers: '@ucanto/interface': ^6.2.0 '@ucanto/principal': ^5.1.0 - '@web3-storage/access': ^11.0.0 + '@web3-storage/access': ^11.2.0 dependencies: '@ucanto/interface': 6.2.0 '@ucanto/principal': 5.1.0 - '@web3-storage/access': 11.0.0 + '@web3-storage/access': 11.2.0 packages/react: specifiers: @@ -495,7 +495,7 @@ importers: '@ucanto/interface': ^6.2.0 '@ucanto/principal': ^5.1.0 '@w3ui/keyring-core': workspace:^ - '@web3-storage/access': ^11.0.0 + '@web3-storage/access': ^11.2.0 ariakit-react-utils: 0.17.0-next.27 use-local-storage-state: ^18.2.1 dependencies: @@ -507,7 +507,7 @@ importers: '@testing-library/user-event': 14.4.3 '@ucanto/interface': 6.2.0 '@ucanto/principal': 5.1.0 - '@web3-storage/access': 11.0.0 + '@web3-storage/access': 11.2.0 packages/react-uploader: specifiers: @@ -550,12 +550,12 @@ importers: '@ucanto/interface': ^6.2.0 '@ucanto/principal': ^5.1.0 '@w3ui/keyring-core': workspace:^ - '@web3-storage/access': ^11.0.0 + '@web3-storage/access': ^11.2.0 dependencies: '@ucanto/interface': 6.2.0 '@ucanto/principal': 5.1.0 '@w3ui/keyring-core': link:../keyring-core - '@web3-storage/access': 11.0.0 + '@web3-storage/access': 11.2.0 packages/solid-uploader: specifiers: @@ -611,13 +611,13 @@ importers: '@ucanto/interface': ^6.2.0 '@ucanto/principal': ^5.1.0 '@w3ui/keyring-core': workspace:^ - '@web3-storage/access': ^11.0.0 + '@web3-storage/access': ^11.2.0 dependencies: '@w3ui/keyring-core': link:../keyring-core devDependencies: '@ucanto/interface': 6.2.0 '@ucanto/principal': 5.1.0 - '@web3-storage/access': 11.0.0 + '@web3-storage/access': 11.2.0 packages/vue-uploader: specifiers: @@ -5521,12 +5521,11 @@ packages: web-streams-polyfill: 3.2.1 dev: false - /@web3-storage/access/11.0.0: - resolution: {integrity: sha512-hWzuxvDjtBze6KGErwZljUx0OtsO1Se938OoWlG155YnW+k0m8pu75KNcSVbiQCIWHfS+HcKeS1+ZY7W2bY2tA==} + /@web3-storage/access/11.2.0: + resolution: {integrity: sha512-eN0FQ0G1bZSdQYK6xUnqV6Ueyx5DWtfsFOuH9+pVabyH6T6CHqI9NyimQPH67JlEszHdSAxxod3H54QVhUNT/Q==} hasBin: true dependencies: '@ipld/car': 5.1.1 - '@ipld/dag-cbor': 9.0.0 '@ipld/dag-ucan': 3.2.0 '@ucanto/client': 5.1.0 '@ucanto/core': 5.2.0 @@ -5534,7 +5533,7 @@ packages: '@ucanto/principal': 5.1.0 '@ucanto/transport': 5.1.1 '@ucanto/validator': 6.1.0 - '@web3-storage/capabilities': 4.0.0 + '@web3-storage/capabilities': 4.0.1 bigint-mod-arith: 3.1.2 conf: 10.2.0 inquirer: 9.1.5 @@ -5547,7 +5546,6 @@ packages: p-wait-for: 5.0.1 type-fest: 3.7.0 uint8arrays: 4.0.3 - varint: 6.0.0 ws: 8.13.0 zod: 3.21.4 transitivePeerDependencies: @@ -5563,6 +5561,15 @@ packages: '@ucanto/transport': 5.1.1 '@ucanto/validator': 6.1.0 + /@web3-storage/capabilities/4.0.1: + resolution: {integrity: sha512-Shl6ZGXOpCKL+wohQsAMjW6cN+eadk7vigSXyNW8iI2TUSgkILzfNOQtkC1nWhXw/d4bh3OuzS84QN8V0wO4fw==} + dependencies: + '@ucanto/core': 5.2.0 + '@ucanto/interface': 6.2.0 + '@ucanto/principal': 5.1.0 + '@ucanto/transport': 5.1.1 + '@ucanto/validator': 6.1.0 + /@web3-storage/upload-client/8.0.0: resolution: {integrity: sha512-i8YdTlByGoegyolVxku10nTbZkaZuMGVQjMoCl8auacFnV4dbC5WUg0nG0/KpAkHSHEqr5HyfO8bwOdgpUhrsg==} dependencies: