Skip to content

Commit

Permalink
Merge pull request #24 from web3-storage/delegation
Browse files Browse the repository at this point in the history
Delegation
  • Loading branch information
ice-breaker-tg committed Sep 28, 2022
2 parents 76ba74f + 9af7b1d commit 4ef710f
Show file tree
Hide file tree
Showing 28 changed files with 1,184 additions and 1,075 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/next.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: next

on:
push:
branches:
- next
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
semantic_release:
name: semantic_release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Run Tests
run: |
yarn install --immutable --immutable-cache --check-cache
npm test
- name: Run semantic release
env: # Or as an environment variable
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
run: |
npx semantic-release --branches next
99 changes: 70 additions & 29 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
<dd></dd>
</dl>

## Constants

<dl>
<dt><a href="#importToken">importToken</a> ⇒ <code>Promise.&lt;(API.Delegation|Failure)&gt;</code></dt>
<dd></dd>
</dl>

## Functions

<dl>
Expand All @@ -22,15 +15,16 @@
## Typedefs

<dl>
<dt><a href="#Link">Link</a> : <code>API.Link</code></dt>
<dd><p>A string representing a link to another object in IPLD</p>
</dd>
<dt><a href="#Result">Result</a> : <code>API.Result.&lt;unknown, ({error: true}|API.HandlerExecutionError|API.Failure)&gt;</code></dt>
<dd></dd>
<dt><a href="#strResult">strResult</a> : <code>API.Result.&lt;string, ({error: true}|API.HandlerExecutionError|API.Failure)&gt;</code></dt>
<dd></dd>
<dt><a href="#ClientOptions">ClientOptions</a> : <code>object</code></dt>
<dd></dd>
<dt><a href="#IdentityInfo">IdentityInfo</a> : <code>object</code></dt>
<dd></dd>
<dt><a href="#DelegationOptions">DelegationOptions</a> : <code>object</code></dt>
<dd></dd>
</dl>

<a name="Client"></a>
Expand All @@ -40,11 +34,16 @@

* [Client](#Client)
* [new Client(options)](#new_Client_new)
* [.identity()](#Client+identity) ⇒ <code>Promise.&lt;API.SigningAuthority&gt;</code>
* [.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)
* [.checkRegistration()](#Client+checkRegistration) ⇒ <code>Promise.&lt;UCAN.JWT&gt;</code>
* [.whoami()](#Client+whoami)[<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>
* [.upload(bytes)](#Client+upload)[<code>Promise.&lt;strResult&gt;</code>](#strResult)
* [.remove(link)](#Client+remove)
* [.insights(link)](#Client+insights) ⇒ <code>Promise.&lt;object&gt;</code>
Expand All @@ -59,11 +58,25 @@ Create an instance of the w3 client.
| --- | --- |
| options | [<code>ClientOptions</code>](#ClientOptions) |

<a name="Client+identity"></a>
<a name="Client+agent"></a>

### client.identity() ⇒ <code>Promise.&lt;API.SigningAuthority&gt;</code>
### client.agent() ⇒ <code>Promise.&lt;API.SigningPrincipal&gt;</code>
Get the current "machine" DID

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

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

### client.identity() ⇒ [<code>Promise.&lt;IdentityInfo&gt;</code>](#IdentityInfo)
**Kind**: instance method of [<code>Client</code>](#Client)
<a name="Client+register"></a>

Expand Down Expand Up @@ -94,6 +107,25 @@ Register a user by email.
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>
**Kind**: instance method of [<code>Client</code>](#Client)

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

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

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

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

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

### client.upload(bytes) ⇒ [<code>Promise.&lt;strResult&gt;</code>](#strResult)
Expand Down Expand Up @@ -123,16 +155,7 @@ Remove an uploaded file by CID

| Param | Type | Description |
| --- | --- | --- |
| link | [<code>Link</code>](#Link) | the CID to get insights for |

<a name="importToken"></a>

## importToken ⇒ <code>Promise.&lt;(API.Delegation\|Failure)&gt;</code>
**Kind**: global constant

| Param | Type |
| --- | --- |
| input | <code>UCAN.JWT</code> |
| link | <code>API.Link</code> | the CID to get insights for |

<a name="createClient"></a>

Expand All @@ -144,12 +167,6 @@ Remove an uploaded file by CID
| --- | --- |
| options | [<code>ClientOptions</code>](#ClientOptions) |

<a name="Link"></a>

## Link : <code>API.Link</code>
A string representing a link to another object in IPLD

**Kind**: global typedef
<a name="Result"></a>

## Result : <code>API.Result.&lt;unknown, ({error: true}\|API.HandlerExecutionError\|API.Failure)&gt;</code>
Expand All @@ -172,3 +189,27 @@ A string representing a link to another object in IPLD
| accessDID | <code>API.DID</code> | The DID of the access service. |
| settings | <code>Map.&lt;string, any&gt;</code> | A map/db of settings to use for the client. |

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

## IdentityInfo : <code>object</code>
**Kind**: global typedef
**Properties**

| Name | Type | Description |
| --- | --- | --- |
| agent | <code>API.SigningPrincipal</code> | The local agent principal |
| account | <code>API.SigningPrincipal</code> | The local account principal |
| with | <code>API.DID</code> | The current acccount (delegated) DID |
| proofs | <code>Array.&lt;API.Delegation&gt;</code> | The current delegation as a proof set. |

<a name="DelegationOptions"></a>

## DelegationOptions : <code>object</code>
**Kind**: global typedef
**Properties**

| Name | Type |
| --- | --- |
| to | <code>API.DID</code> |
| [expiration] | <code>number</code> |

32 changes: 14 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,40 @@
"license": "Apache-2.0 OR MIT",
"type": "module",
"main": "src/index.js",
"types": "types/src/index.d.ts",
"types": "dist/src/index.d.ts",
"publishConfig": {
"access": "public"
},
"files": [
"src",
"types",
"dist",
"patches"
],
"scripts": {
"build": "npm run build:api_docs && npm run build:types",
"build:types": "tsc --declaration --emitDeclarationOnly --declarationDir ./types",
"build:types": "tsc --declaration --emitDeclarationOnly --declarationDir ./dist",
"build:api_docs": "jsdoc2md -f src/index.js > API.md",
"pretest": "npm run prettier && npm run typecheck",
"x-pretest": "npm run prettier && npm run typecheck",
"test": "vitest run",
"typecheck": "tsc --noEmit",
"prettier": "prettier -c '{src,patches,test}/**/*.{js,ts,yml,json}' --ignore-path .gitignore",
"test:coverage": "vitest run --coverage",
"test:dev": "vitest",
"setup:hooks": "simple-git-hooks"
"test:dev": "vitest -w"
},
"dependencies": {
"@ucanto/authority": "^0.5.0",
"@ucanto/client": "0.6.0",
"@ucanto/core": "^0.6.0",
"@ucanto/interface": "^0.7.0",
"@ucanto/transport": "^0.7.0",
"@ucanto/validator": "^0.6.0",
"@web3-storage/access": "^0.1.2-rc.2",
"@ucanto/client": "^1.0.1",
"@ucanto/core": "^1.0.1",
"@ucanto/interface": "^1.0.0",
"@ucanto/principal": "^1.0.1",
"@ucanto/transport": "^1.0.1",
"@ucanto/validator": "^1.0.1",
"@web3-storage/access": "^1.0.0",
"cross-fetch": "^3.1.5",
"tweetnacl": "^1.0.3"
},
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "^3.3.0",
"@vitest/coverage-c8": "^0.23.2",
"@vitest/coverage-c8": "^0.23.4",
"ipjs": "^5.2.0",
"jsdoc-to-markdown": "^7.1.1",
"lint-staged": "^13.0.3",
Expand All @@ -49,10 +48,7 @@
"standard": "^17.0.0",
"tsc": "^2.0.4",
"typescript": "^4.8.3",
"vitest": "^0.23.2"
},
"simple-git-hooks": {
"pre-commit": "npx lint-staged && npm run build && git add API.md && git add types"
"vitest": "^0.23.4"
},
"lint-staged": {
"*.*": "prettier --write '{src,patches,test}/**/*.{js,ts,yml,json}' --ignore-path .gitignore"
Expand Down
Loading

0 comments on commit 4ef710f

Please sign in to comment.