Skip to content

Commit

Permalink
Deno SDK v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
anudit committed Jun 16, 2022
1 parent 0a0abf0 commit bfc1f57
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 19 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
[`@theconvospace/sdk`](https://github.com/anudit/convosdk/tree/main/packages/sdk)
- Node
[`@theconvospace/react`](https://github.com/anudit/convosdk/tree/main/packages/react)
- Deno [`convo`](https://github.com/anudit/convosdk/tree/main/packages/react)
- Deno
[`convo-sdk`](https://github.com/anudit/convosdk/tree/main/packages/sdk-deno)
- Examples
- Benchmarks
- Scripts
12 changes: 10 additions & 2 deletions packages/sdk-deno/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.1.1

- Start Support for `convo.omnid`
- `convo.omnid.computeTrustScore` coming soon.

## 0.1.0
- Release Deno Support for `convo.comments`, `convo.threads`, `convo.auth`, `convo.utils`.
- `convo.omnid`, `convo.auth.getSignatureDataV2`, `convo.auth.parseSignatureV2` coming soon.

- Release Deno Support for `convo.comments`, `convo.threads`, `convo.auth`,
`convo.utils`.
- `convo.omnid`, `convo.auth.getSignatureDataV2`,
`convo.auth.parseSignatureV2` coming soon.
20 changes: 20 additions & 0 deletions packages/sdk-deno/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# @theconvospace/sdk ![npm/v](https://img.shields.io/npm/v/@theconvospace/sdk)

![npm/types](https://img.shields.io/npm/types/@theconvospace/sdk)
![nodeVersion](https://img.shields.io/node/v/@theconvospace/sdk)
![bundlephobia/dependency-count](https://img.shields.io/librariesio/release/npm/@theconvospace/sdk)
![bundlephobia/minzip](https://img.shields.io/bundlephobia/minzip/@theconvospace/sdk)
![bundlephobia/min/](https://img.shields.io/bundlephobia/min/@theconvospace/sdk)

SDK containing all the functions you'll need to build on
[theconvo.space](https://theconvo.space)

Check out the [Changelog](/packages/sdk/CHANGELOG.md)

## Installation

```bash
yarn add @theconvospace/sdk
npm i --save @theconvospace/sdk
pnpm i --save @theconvospace/sdk
```
2 changes: 1 addition & 1 deletion packages/sdk-deno/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { fetcher } from './utils.ts';
class ConvoBase {
apikey: string;
node: string;
version = '0.1.0';
version = '0.1.1';

constructor(apikey: string, node: string) {
this.apikey = apikey;
Expand Down
7 changes: 7 additions & 0 deletions packages/sdk-deno/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"lint": {
"rules": {
"exclude": ["no-explicit-any"]
}
}
}
3 changes: 3 additions & 0 deletions packages/sdk-deno/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@ import ConvoBase from './base.ts';
import Auth from './auth.ts';
import Comments from './comments.ts';
import Threads from './threads.ts';
import Omnid from './omnid.ts';

class Convo extends ConvoBase {

auth: Auth;
comments: Comments;
threads: Threads;
omnid: Omnid;

constructor(apikey: string, node = 'https://theconvo.space/api') {
super(apikey, node);
this.auth = new Auth(apikey, this.node);
this.comments = new Comments(apikey, this.node);
this.threads = new Threads(apikey, this.node);
this.omnid = new Omnid(apikey, this.node);
return this;
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk-deno/mod_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { assertEquals } from "./test_deps.ts";

Deno.test("test comments.query", async () => {

let convo = new Convo('CSCpPwHnkB3niBJiUjy92YGP6xVkVZbWfK8xriDO');
let comments = await convo.comments.query({threadId: 'KIGZUnR4RzXDFheXoOwo', page: 1, pageSize: 10});
const convo = new Convo('CSCpPwHnkB3niBJiUjy92YGP6xVkVZbWfK8xriDO');
const comments = await convo.comments.query({threadId: 'KIGZUnR4RzXDFheXoOwo', page: 1, pageSize: 10});
assertEquals(comments.length, 10);

});
50 changes: 50 additions & 0 deletions packages/sdk-deno/omnid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { fetcher } from './utils.ts';
import Credentials from './omnid/credentials.ts';
import {
ComputeConfig,
ErrorType,
AdaptorFunctionType,
AdaptorFunctionWithConfigType,
Dictionary,
} from './types.ts';

class Omnid {
apikey: string;
node: string;
credentials: Credentials;

constructor(apikey: string, node: string) {
this.apikey = apikey;
this.node = node;
this.credentials = new Credentials(apikey, this.node);
return this;
}

getTrustScore = async (
address: string,
noCache?: boolean
): Promise<any | ErrorType> => {
return await fetcher(
'GET',
`${this.node}/identity?address=${address}${
Boolean(noCache) == true ? '&noCache=true' : ''
}`,
this.apikey,
{}
);
};

getTrustScoreWithProof = async (
address: string
): Promise<any | ErrorType> => {
return await fetcher(
'GET',
`${this.node}/zkidentity?address=${address}`,
this.apikey,
{}
);
};

}

export default Omnid;
35 changes: 35 additions & 0 deletions packages/sdk-deno/omnid/credentials.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Dictionary } from '../types.ts';
import { fetcher } from './../utils.ts';

class Credentials {
apikey: string;
node: string;

constructor(apikey: string, node: string) {
this.apikey = apikey;
this.node = node;
return this;
}

issue = async (address: string, adaptor: string): Promise<string> => {
const resp = await fetcher(
'POST',
`${this.node}/omnid/credentials/issue`,
this.apikey,
{ address, adaptor }
);
return resp;
};

verify = async (verifiableCredential: Dictionary<any>): Promise<string> => {
const resp = await fetcher(
'POST',
`${this.node}/omnid/credentials/verify`,
this.apikey,
{ verifiableCredential }
);
return resp;
};
}

export default Credentials;
18 changes: 5 additions & 13 deletions packages/sdk/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
# @theconvospace/sdk ![npm/v](https://img.shields.io/npm/v/@theconvospace/sdk)
# Convo Space SDK for Deno

![npm/types](https://img.shields.io/npm/types/@theconvospace/sdk)
![nodeVersion](https://img.shields.io/node/v/@theconvospace/sdk)
![bundlephobia/dependency-count](https://img.shields.io/librariesio/release/npm/@theconvospace/sdk)
![bundlephobia/minzip](https://img.shields.io/bundlephobia/minzip/@theconvospace/sdk)
![bundlephobia/min/](https://img.shields.io/bundlephobia/min/@theconvospace/sdk)
SDK for building on [theconvo.space](https://theconvo.space)

SDK containing all the functions you'll need to build on [theconvo.space](https://theconvo.space)

Check out the [Changelog](/packages/sdk/CHANGELOG.md)
Check out the [Changelog](/packages/sdk-deno/CHANGELOG.md)

## Installation

```bash
yarn add @theconvospace/sdk
npm i --save @theconvospace/sdk
pnpm i --save @theconvospace/sdk
```js
import * as convo from "https://deno.land/x/convo@v0.1.0/packages/sdk-deno/mod.ts";
```

2 comments on commit bfc1f57

@vercel
Copy link

@vercel vercel bot commented on bfc1f57 Jun 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

convosdk-examples-nextjs – ./examples/nextjs

convosdk-examples-nextjs-anudit.vercel.app
convosdk-examples-nextjs.vercel.app
convosdk-examples-nextjs-git-main-anudit.vercel.app

@vercel
Copy link

@vercel vercel bot commented on bfc1f57 Jun 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

convosdk-examples-browser – ./examples/browser

convosdk-examples-browser-git-main-anudit.vercel.app
convosdk-examples-browser-anudit.vercel.app
convosdk-examples-browser.vercel.app

Please sign in to comment.