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

Commit

Permalink
feat: Remove settings, move delegation bits to client
Browse files Browse the repository at this point in the history
Clean up CI, switch to NPM for ci.
Misc cleanup.
Remove prettier plugin.
Fix typecheck / api build.
  • Loading branch information
ice-breaker-tg committed Nov 3, 2022
1 parent b46b12a commit d383f59
Show file tree
Hide file tree
Showing 21 changed files with 22,309 additions and 6,857 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
node-version: 16
- name: Run Tests
run: |
yarn install --immutable --immutable-cache --check-cache
npm ci
npm test
- name: Build
run: npm run build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
node-version: 16
- name: Run Tests
run: |
yarn install --immutable --immutable-cache --check-cache
npm ci
npm test
- name: Run semantic release
env: # Or as an environment variable
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 16
- run: yarn install --immutable --immutable-cache --check-cache
- run: npm ci
- run: npm test
3 changes: 3 additions & 0 deletions .jsdoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["node_modules/jsdoc-tsimport-plugin/index.js"]
}
3 changes: 0 additions & 3 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@ module.exports = {
trailingComma: 'es5',
semi: false,
singleQuote: true,
importOrder: ['^[./]'],
importOrderSeparation: true,
importOrderSortSpecifiers: true,
}
32 changes: 19 additions & 13 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
* [new Client(options)](#new_Client_new)
* [.agent()](#Client+agent) ⇒ <code>Promise.&lt;API.SigningPrincipal&gt;</code>
* [.account()](#Client+account) ⇒ <code>Promise.&lt;API.SigningPrincipal&gt;</code>
* [.currentDelegation()](#Client+currentDelegation) ⇒ <code>Promise.&lt;(API.Delegation\|null)&gt;</code>
* [.identity()](#Client+identity)[<code>Promise.&lt;IdentityInfo&gt;</code>](#IdentityInfo)
* [.register(email)](#Client+register)
* [.whoami()](#Client+whoami)[<code>Promise.&lt;Result&gt;</code>](#Result)
* [.stat()](#Client+stat)[<code>Promise.&lt;Result&gt;</code>](#Result)
* [.list()](#Client+list)[<code>Promise.&lt;Result&gt;</code>](#Result)
* [.makeDelegation(opts)](#Client+makeDelegation) ⇒ <code>Promise.&lt;Uint8Array&gt;</code>
* [.importDelegation(bytes, alias)](#Client+importDelegation) ⇒ <code>Promise.&lt;API.Delegation&gt;</code>
* [.makeDelegation(opts)](#Client+makeDelegation)
* [.exportDelegation(opts)](#Client+exportDelegation) ⇒ <code>Promise.&lt;string&gt;</code>
* [.importDelegation(delegationString, alias)](#Client+importDelegation) ⇒ <code>Promise.&lt;API.Delegation&gt;</code>
* [.upload(bytes, [origin])](#Client+upload)[<code>Promise.&lt;strResult&gt;</code>](#strResult)
* [.uploadAdd(dataCID, shardCIDs)](#Client+uploadAdd)
* [.remove(link)](#Client+remove)
Expand Down Expand Up @@ -72,10 +72,6 @@ Get the current "machine" DID
### client.account() ⇒ <code>Promise.&lt;API.SigningPrincipal&gt;</code>
Get the current "account" DID

**Kind**: instance method of [<code>Client</code>](#Client)
<a name="Client+currentDelegation"></a>

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

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

### client.makeDelegation(opts) ⇒ <code>Promise.&lt;Uint8Array&gt;</code>
### client.makeDelegation(opts)
**Kind**: instance method of [<code>Client</code>](#Client)

| Param | Type |
| --- | --- |
| opts | [<code>DelegationOptions</code>](#DelegationOptions) |

<a name="Client+exportDelegation"></a>

### client.exportDelegation(opts) ⇒ <code>Promise.&lt;string&gt;</code>
**Kind**: instance method of [<code>Client</code>](#Client)
**Returns**: <code>Promise.&lt;string&gt;</code> - delegation

| Param | Type |
| --- | --- |
| opts | [<code>DelegationOptions</code>](#DelegationOptions) |

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

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

| Param | Type |
| --- | --- |
| bytes | <code>Uint8Array</code> |
| delegationString | <code>string</code> |
| alias | <code>string</code> |

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

| Name | Type | Description |
| --- | --- | --- |
| [serviceDID] | <code>API.DID</code> | The DID of the service to talk to. |
| [serviceURL] | <code>string</code> | The URL of the service to talk to. |
| [serviceDID] | <code>API.DID</code> | The DID of the w3up service. |
| [serviceURL] | <code>string</code> | The URL of the w3up service. |
| [accessURL] | <code>string</code> | The URL of the access service. |
| [accessDID] | <code>API.DID</code> | The DID of the access service. |
| 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. |
| settings | <code>SettingsRaw</code> | Settings to use for the client. |

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

Expand Down
1 change: 0 additions & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,3 @@ THE SOFTWARE.
```

</details>

26 changes: 12 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> A client SDK for the w3up service, providing content addressed storage for any application.
`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.
`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.

## Install

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

/** The URL of the w3up service */
serviceURL: string,
serviceURL: string

/** The DID of the access service */
accessDID: string,
accessDID: string

/** The URL of the access service */
accessURL: string,
accessURL: string

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

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

Expand Down Expand Up @@ -88,7 +88,7 @@ import { createClient } from '@web3-storage/w3up-client'
async function tryToRegister(emailAddress) {
// CLIENT_OPTS should be defined as described in "Creating a client object"
const client = createClient(CLIENT_OPTS)
const client = createClient(CLIENT_OPTS)
try {
const successMessage = await client.register(emailAddress)
console.log('Success: ', successMessage)
Expand All @@ -100,7 +100,6 @@ async function tryToRegister(emailAddress) {

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.


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.

### Uploading data
Expand All @@ -123,7 +122,7 @@ async function uploadCAR(carData) {
}
```

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.
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.

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.

Expand Down Expand Up @@ -165,9 +164,8 @@ async function tryRemove(cid) {

**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.


[w3up-cli-github]: https://github.com/web3-storage/w3up-cli
[elastic-ipfs]: https://github.com/elastic-ipfs/elastic-ipfs
[elastic-ipfs]: https://github.com/elastic-ipfs/elastic-ipfs
[ucanto]: https://github.com/web3-storage/ucanto
[car-spec]: https://ipld.io/specs/transport/car/
[web3storage-docs-cars]: https://web3.storage/docs/how-tos/work-with-car-files/
Loading

0 comments on commit d383f59

Please sign in to comment.