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: bring your own principal #672

Merged
merged 2 commits into from
Mar 29, 2023
Merged

feat: bring your own principal #672

merged 2 commits into from
Mar 29, 2023

Conversation

alanshaw
Copy link
Member

This is web3-storage/w3up-client#74 ported here.


This PR allows passing your own principal to the client create factory function instead of loading one from a pre-existing store. The caveat is that if you pass your own and the store is not empty then it needs to match the principal that was loaded from the store (otherwise any saved delegations will be unusable).

This makes https://gist.github.com/alanshaw/e949abfcf6728f590ac9fa083dba5648#on-the-server a little easier, you won't need to install @web3-storage/access or deal with the AgentData class.

Currently:

import * as Signer from '@ucanto/principal/ed25519'
import { AgentData } from '@web3-storage/access/agent'
import { Client } from '@web3-storage/w3up-client'

const principal = Signer.parse(process.env.KEY)
const data = await AgentData.create({ principal })
const client = new Client(data)

After this PR:

import * as Signer from '@ucanto/principal/ed25519'
import * as Client from '@web3-storage/w3up-client'

const principal = Signer.parse(process.env.KEY)
const client = await Client.create({ principal })

@alanshaw
Copy link
Member Author

This has already received approval so I will merge when CI is 🟢.

@alanshaw alanshaw merged commit 4586df2 into main Mar 29, 2023
@alanshaw alanshaw deleted the feat/byo-principal branch March 29, 2023 13:22
alanshaw pushed a commit that referenced this pull request Mar 29, 2023
🤖 I have created a release *beep* *boop*
---


##
[5.4.0](w3up-client-v5.3.0...w3up-client-v5.4.0)
(2023-03-29)


### Features

* bring your own principal
([#672](#672))
([4586df2](4586df2))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
gobengo pushed a commit that referenced this pull request Apr 11, 2023
This is web3-storage/w3up-client#74 ported here.

---

This PR allows passing your own principal to the client `create` factory
function instead of loading one from a pre-existing store. The caveat is
that if you pass your own and the store is not empty then it needs to
match the principal that was loaded from the store (otherwise any saved
delegations will be unusable).

This makes
https://gist.github.com/alanshaw/e949abfcf6728f590ac9fa083dba5648#on-the-server
a little easier, you won't need to install `@web3-storage/access` or
deal with the `AgentData` class.

Currently:

```js
import * as Signer from '@ucanto/principal/ed25519'
import { AgentData } from '@web3-storage/access/agent'
import { Client } from '@web3-storage/w3up-client'

const principal = Signer.parse(process.env.KEY)
const data = await AgentData.create({ principal })
const client = new Client(data)
```

After this PR:

```js
import * as Signer from '@ucanto/principal/ed25519'
import * as Client from '@web3-storage/w3up-client'

const principal = Signer.parse(process.env.KEY)
const client = await Client.create({ principal })
```
gobengo pushed a commit that referenced this pull request Apr 11, 2023
🤖 I have created a release *beep* *boop*
---


##
[5.4.0](w3up-client-v5.3.0...w3up-client-v5.4.0)
(2023-03-29)


### Features

* bring your own principal
([#672](#672))
([afade7c](afade7c))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant