Skip to content
This repository was archived by the owner on Mar 29, 2023. It is now read-only.

Commit c474d2a

Browse files
Merge pull request #45 from web3-storage/chore/delegation-settings-cleanup
feat: Remove old settings code, move delegation bits to client
2 parents b46b12a + 126d9cb commit c474d2a

21 files changed

+20435
-6858
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
node-version: 16
2020
- name: Run Tests
2121
run: |
22-
yarn install --immutable --immutable-cache --check-cache
22+
npm ci
2323
npm test
2424
- name: Build
2525
run: npm run build

.github/workflows/next.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
node-version: 16
2020
- name: Run Tests
2121
run: |
22-
yarn install --immutable --immutable-cache --check-cache
22+
npm ci
2323
npm test
2424
- name: Run semantic release
2525
env: # Or as an environment variable

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ jobs:
1313
uses: actions/setup-node@v3
1414
with:
1515
node-version: 16
16-
- run: yarn install --immutable --immutable-cache --check-cache
16+
- run: npm ci
1717
- run: npm test

.jsdoc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"plugins": ["node_modules/jsdoc-tsimport-plugin/index.js"]
3+
}

.prettierrc.cjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@ module.exports = {
22
trailingComma: 'es5',
33
semi: false,
44
singleQuote: true,
5-
importOrder: ['^[./]'],
6-
importOrderSeparation: true,
7-
importOrderSortSpecifiers: true,
85
}

API.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636
* [new Client(options)](#new_Client_new)
3737
* [.agent()](#Client+agent) ⇒ <code>Promise.&lt;API.SigningPrincipal&gt;</code>
3838
* [.account()](#Client+account) ⇒ <code>Promise.&lt;API.SigningPrincipal&gt;</code>
39-
* [.currentDelegation()](#Client+currentDelegation) ⇒ <code>Promise.&lt;(API.Delegation\|null)&gt;</code>
4039
* [.identity()](#Client+identity)[<code>Promise.&lt;IdentityInfo&gt;</code>](#IdentityInfo)
4140
* [.register(email)](#Client+register)
4241
* [.whoami()](#Client+whoami)[<code>Promise.&lt;Result&gt;</code>](#Result)
4342
* [.stat()](#Client+stat)[<code>Promise.&lt;Result&gt;</code>](#Result)
4443
* [.list()](#Client+list)[<code>Promise.&lt;Result&gt;</code>](#Result)
45-
* [.makeDelegation(opts)](#Client+makeDelegation) ⇒ <code>Promise.&lt;Uint8Array&gt;</code>
46-
* [.importDelegation(bytes, alias)](#Client+importDelegation) ⇒ <code>Promise.&lt;API.Delegation&gt;</code>
44+
* [.makeDelegation(opts)](#Client+makeDelegation)
45+
* [.exportDelegation(opts)](#Client+exportDelegation) ⇒ <code>Promise.&lt;string&gt;</code>
46+
* [.importDelegation(delegationString, alias)](#Client+importDelegation) ⇒ <code>Promise.&lt;API.Delegation&gt;</code>
4747
* [.upload(bytes, [origin])](#Client+upload)[<code>Promise.&lt;strResult&gt;</code>](#strResult)
4848
* [.uploadAdd(dataCID, shardCIDs)](#Client+uploadAdd)
4949
* [.remove(link)](#Client+remove)
@@ -72,10 +72,6 @@ Get the current "machine" DID
7272
### client.account() ⇒ <code>Promise.&lt;API.SigningPrincipal&gt;</code>
7373
Get the current "account" DID
7474

75-
**Kind**: instance method of [<code>Client</code>](#Client)
76-
<a name="Client+currentDelegation"></a>
77-
78-
### client.currentDelegation() ⇒ <code>Promise.&lt;(API.Delegation\|null)&gt;</code>
7975
**Kind**: instance method of [<code>Client</code>](#Client)
8076
<a name="Client+identity"></a>
8177

@@ -110,21 +106,31 @@ List all of the uploads connected to this user.
110106
**Kind**: instance method of [<code>Client</code>](#Client)
111107
<a name="Client+makeDelegation"></a>
112108

113-
### client.makeDelegation(opts) ⇒ <code>Promise.&lt;Uint8Array&gt;</code>
109+
### client.makeDelegation(opts)
110+
**Kind**: instance method of [<code>Client</code>](#Client)
111+
112+
| Param | Type |
113+
| --- | --- |
114+
| opts | [<code>DelegationOptions</code>](#DelegationOptions) |
115+
116+
<a name="Client+exportDelegation"></a>
117+
118+
### client.exportDelegation(opts) ⇒ <code>Promise.&lt;string&gt;</code>
114119
**Kind**: instance method of [<code>Client</code>](#Client)
120+
**Returns**: <code>Promise.&lt;string&gt;</code> - delegation
115121

116122
| Param | Type |
117123
| --- | --- |
118124
| opts | [<code>DelegationOptions</code>](#DelegationOptions) |
119125

120126
<a name="Client+importDelegation"></a>
121127

122-
### client.importDelegation(bytes, alias) ⇒ <code>Promise.&lt;API.Delegation&gt;</code>
128+
### client.importDelegation(delegationString, alias) ⇒ <code>Promise.&lt;API.Delegation&gt;</code>
123129
**Kind**: instance method of [<code>Client</code>](#Client)
124130

125131
| Param | Type |
126132
| --- | --- |
127-
| bytes | <code>Uint8Array</code> |
133+
| delegationString | <code>string</code> |
128134
| alias | <code>string</code> |
129135

130136
<a name="Client+upload"></a>
@@ -218,11 +224,11 @@ Remove an uploaded file by CID
218224

219225
| Name | Type | Description |
220226
| --- | --- | --- |
221-
| [serviceDID] | <code>API.DID</code> | The DID of the service to talk to. |
222-
| [serviceURL] | <code>string</code> | The URL of the service to talk to. |
227+
| [serviceDID] | <code>API.DID</code> | The DID of the w3up service. |
228+
| [serviceURL] | <code>string</code> | The URL of the w3up service. |
223229
| [accessURL] | <code>string</code> | The URL of the access service. |
224230
| [accessDID] | <code>API.DID</code> | The DID of the access service. |
225-
| settings | <code>Map.&lt;string, any&gt;</code> \| <code>string</code> \| <code>Settings.SettingsObject</code> | A map/db of settings to use for the client. |
231+
| settings | <code>SettingsRaw</code> | Settings to use for the client. |
226232

227233
<a name="IdentityInfo"></a>
228234

LICENSE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,3 @@ THE SOFTWARE.
230230
```
231231

232232
</details>
233-

README.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> A client SDK for the w3up service, providing content addressed storage for any application.
44
5-
`w3up-client` is a JavaScript libary that provides a convenient interface to the w3up platform, a simple "on-ramp" to the content-addressed decentralized IPFS network.
5+
`w3up-client` is a JavaScript libary that provides a convenient interface to the w3up platform, a simple "on-ramp" to the content-addressed decentralized IPFS network.
66

77
## Install
88

@@ -32,16 +32,16 @@ The API provides a `createClient` function that returns a `Client` object. To ca
3232
```ts
3333
type ClientOptions = {
3434
/** The DID of the w3up service */
35-
serviceDID: string,
35+
serviceDID: string
3636

3737
/** The URL of the w3up service */
38-
serviceURL: string,
38+
serviceURL: string
3939

4040
/** The DID of the access service */
41-
accessDID: string,
41+
accessDID: string
4242

4343
/** The URL of the access service */
44-
accessURL: string,
44+
accessURL: string
4545

4646
/** A Map of configuration settings for the client */
4747
settings: Map<string, any>
@@ -52,10 +52,10 @@ The client needs the URL and DID (Decentralized Identity Document) for two servi
5252
5353
Here are the values for the production w3up and access services:
5454
55-
| Service | URL | DID |
56-
|---------|-----|-----|
57-
| w3up | `https://8609r1772a.execute-api.us-east-1.amazonaws.com` | `did:key:z6MkrZ1r5XBFZjBU34qyD8fueMbMRkKw17BZaq2ivKFjnz2z` |
58-
| access | `https://access-api.web3.storage` | `did:key:z6MkkHafoFWxxWVNpNXocFdU6PL2RVLyTEgS1qTnD3bRP7V9` |
55+
| Service | URL | DID |
56+
| ------- | -------------------------------------------------------- | ---------------------------------------------------------- |
57+
| w3up | `https://8609r1772a.execute-api.us-east-1.amazonaws.com` | `did:key:z6MkrZ1r5XBFZjBU34qyD8fueMbMRkKw17BZaq2ivKFjnz2z` |
58+
| access | `https://access-api.web3.storage` | `did:key:z6MkkHafoFWxxWVNpNXocFdU6PL2RVLyTEgS1qTnD3bRP7V9` |
5959

6060
And here's an example of calling `createClient` with the correct values for the production services:
6161

@@ -88,7 +88,7 @@ import { createClient } from '@web3-storage/w3up-client'
8888
8989
async function tryToRegister(emailAddress) {
9090
// CLIENT_OPTS should be defined as described in "Creating a client object"
91-
const client = createClient(CLIENT_OPTS)
91+
const client = createClient(CLIENT_OPTS)
9292
try {
9393
const successMessage = await client.register(emailAddress)
9494
console.log('Success: ', successMessage)
@@ -100,7 +100,6 @@ async function tryToRegister(emailAddress) {
100100

101101
You can retrieve the identity keypair for the client by calling the `identity` method. This is an async method that will create the key if does not already exist in the client's `settings` map. The `identity` method returns an `Authority` from the [`ucanto` library][ucanto]. `ucanto` provides an RPC framework using UCANs, which `w3up-client` uses under the hood.
102102

103-
104103
The final identity-related client method is `whoami`, which queries the access service to see if your id has been registered, and returns the registered identity.
105104

106105
### Uploading data
@@ -123,7 +122,7 @@ async function uploadCAR(carData) {
123122
}
124123
```
125124

126-
Currently, the `upload` method accepts data in [CAR][car-spec] format. CARs are "content archives" that contain blocks of content-addressed data in an "IPFS native" format.
125+
Currently, the `upload` method accepts data in [CAR][car-spec] format. CARs are "content archives" that contain blocks of content-addressed data in an "IPFS native" format.
127126

128127
We expect to add CAR generation as a feature of this library in a future release. In the meantime, please see the guide to [working with Content Archives][web3storage-docs-cars] on the [Web3.Storage docs](https://web3.storage/docs) site for ways to prepare CAR data. You can also use the [`w3up-cli` tool][w3up-cli-github] to generate CAR data using the `generate-car` command.
129128

@@ -165,9 +164,8 @@ async function tryRemove(cid) {
165164

166165
**Important:** the `remove` method does not delete your data from the public IPFS network, Filecoin, or other decentralized storage systems used by w3up. Data that has been `remove`d and is not linked to any other accounts _may_ eventually be deleted from the internal storage systems used by the w3up service, but there are no guarantees about when (or whether) that will occur, and you should not depend on data being permanently deleted.
167166

168-
169167
[w3up-cli-github]: https://github.com/web3-storage/w3up-cli
170-
[elastic-ipfs]: https://github.com/elastic-ipfs/elastic-ipfs
168+
[elastic-ipfs]: https://github.com/elastic-ipfs/elastic-ipfs
171169
[ucanto]: https://github.com/web3-storage/ucanto
172170
[car-spec]: https://ipld.io/specs/transport/car/
173171
[web3storage-docs-cars]: https://web3.storage/docs/how-tos/work-with-car-files/

0 commit comments

Comments
 (0)