Skip to content

Commit

Permalink
fix: Integrate rust auto-generated code through submodules. (#136)
Browse files Browse the repository at this point in the history
Co-authored-by: Curtis <[email protected]>
  • Loading branch information
elribonazo and curtis-h authored Dec 12, 2023
1 parent 3487815 commit 86691ae
Show file tree
Hide file tree
Showing 71 changed files with 28,465 additions and 17,986 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
build/*
build/**/*
/**/*.d.ts
integration-tests
externals
generated
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,24 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'true'

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/*"

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Install wasm-pack
run: |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Install
run: npm install

Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
submodules: 'true'

- name: Setup Node.js for @input-output-hk
uses: actions/setup-node@v3
Expand All @@ -63,6 +64,16 @@ jobs:
registry-url: https://npm.pkg.github.com/
scope: "@input-output-hk"

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Install wasm-pack
run: |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Setup Node.js for @hyperledger-labs
uses: actions/setup-node@v3
env:
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/release-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,22 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v4

submodules: 'true'
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/*"

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Install wasm-pack
run: |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Install dependencies
run: npm install

Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,24 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v4
submodules: 'true'

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/*"
registry-url: 'https://registry.npmjs.org/'

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Install wasm-pack
run: |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Install dependencies
run: npm install

Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
node_modules
/.pnp
.pnp.js

generated
# testing
/coverage
.nyc_output
Expand All @@ -23,4 +23,5 @@ yarn-debug.log*
yarn-error.log*
*.db
didcomm-pkg
generated-docs
generated-docs
*.commit
7 changes: 7 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[submodule "externals/anoncreds"]
path = externals/anoncreds
url = [email protected]:curtis-h/anoncreds-rs.git
branch = wasm-prism
[submodule "externals/didcomm"]
path = externals/didcomm
url = [email protected]:sicpa-dlab/didcomm-rust.git
31 changes: 22 additions & 9 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,38 @@
"version": "0.2.0",
"configurations": [
{
"name": "NODE DEMO",
"type": "node",
"name": "CJS DEMO",
"program": "${workspaceRoot}/demos/node-cjs/src/index.js",
"request": "launch",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
},
{
"name": "ESM DEMO",
"program": "${workspaceRoot}/demos/node-esm/src/index.js",
"request": "launch",
"runtimeExecutable": "${workspaceRoot}/demos/node/node_modules/.bin/ts-node",
"runtimeArgs": ["--transpile-only"],
"program": "${workspaceRoot}/demos/node/src/index.ts",
"skipFiles": ["<node_internals>/**"],
"cwd": "${workspaceRoot}"
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
},
{
"name": "TESTS",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
"args": ["--colors", "--workerThreads", "--maxWorkers", "1"],
"args": [
"--colors",
"--workerThreads",
"--maxWorkers",
"1"
],
"skipFiles": [
"${workspaceRoot}/../../node_modules/**/*",
"<node_internals>/**/*"
]
}
]
}
}
99 changes: 64 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
# Welcome to Atala PRISM TypeScript SDK

Atala PRISM TypeScript SDK provides a library and documentation for developers to build
TypeScript-based SSI applications with Atala PRISM. It provides a set of
utilities for building SSI Edge Agents speaking DIDComm V2 protocols.

## Basic considerations

### Atala PRISM
# Atala PRISM TypeScript SDK

Atala PRISM is a self-sovereign identity (SSI) platform and service suite for
verifiable data and digital identity. Built on Cardano, it offers core
Expand All @@ -20,7 +12,7 @@ The complete platform is separated into multiple repositories:
- [atala-prism-building-blocks](https://github.com/hyperledger-labs/open-enterprise-agent) - Repo that contains the servers Building Blocks.
- [atala-prism-mediator](https://github.com/input-output-hk/atala-prism-mediator) - Repo for DIDComm V2 Mediator

### SDK Overview
## SDK Overview

- Apollo: Provides a suite of necessary cryptographic operations.
- Castor: Provides a suite of operations to create, manage and resolve decentralized identifiers.
Expand All @@ -29,61 +21,98 @@ The complete platform is separated into multiple repositories:
- Pluto: Provides an interface for storage operations in a portable, storage-agnostic manner.
- PrismAgent: PrismAgent, a component using all other building blocks, provides basic edge agent capabilities, including implementing DIDComm V2 protocols.

### Getting started
## Getting started

This repository includes a browser and a Node.js demo application, and also a step-by-step documented process to run it.
This repository includes a browser and a Node.js demo application, and also a step-by-step documented process on [how to run it](#running-a-demo-project).

#### Running a demo project
### Use in your project
You can install and use this library in browsers and nodejs.

To be able to run the demos, we have to build `prism-wallet-sdk-ts`.
```bash
npm i @atala/prism-wallet-sdk --save
```

From the repository root run:
or with yarn

```bash
yarn add @atala/prism-wallet-sdk
```

> **Note for Webpack:**
>
> The application builds code with wasm files for DIDComm and Anoncreds for both browsers and nodejs. When webpack builds public website the wasm files need to be copied manually into the public folder. See examples



### Running a demo project

#### Building from source
This repository contains compiles typescript code and some rust dependencies for DIDComm and AnonCreds, so in order to build the code from source you will need the following:

* Bash
* Have Rust (cargo) and wasm-pack installed.
* Node JS Version (20/LTS Recommended)

Clone the repository
```
git clone [email protected]:input-output-hk/atala-prism-wallet-sdk-ts.git
```

To be able to run the demos, we have to build `prism-wallet-sdk`.
From the repository root run:

```bash
npm i
npm run build
```

#### For NodeJS
### For NodeJS CJS

After building `prism-wallet-sdk-ts`, cd into `{path}/prism-wallet-sdk-ts/demos/node`:
After building `prism-wallet-sdk`, cd into `{path}/demos/node-cjs` or use visual studio debugger "CJS DEMO":

```bash
cd demos/node-cjs
npm i
node index.js
npm run start
```

:::note
The installation in the `demos/node` directory requires the `build` folder from the wallet-sdk to be available.
:::
> **Note:**
>
> The installation in the `{path}/demos/node-cjs` directory requires the `build` folder from the wallet-sdk to be available.
#### For browser
### For NodeJS ESM

After building `prism-wallet-sdk-ts`, cd into the demo directory "demos/browser"
After building `prism-wallet-sdk`, cd into `{path}/demos/node-esm` or use visual studio debugger "ESM DEMO":

```bash
cd demos/browser
cd demos/node-esm
npm i
npm run start
```

#### Implementing storage for the SDK
This SDK exposes Pluto, a storage interface that should be implemented by the user, in the most appropriate way for a particular use case.
> **Note:**
>
> The installation in the `{path}/demos/node-esm` directory requires the `build` folder from the wallet-sdk to be available.
We don't provide a default implementation out of the box at the moment, but we do provide a couple of demo implementations that can be used to get started with demos and testing.

Provided demo implementations are intentionally oversimplified and SHOULD NOT be used in production.
### For browser

#### Use in your project
In order to use this SDK in your project you now just need to install the package as follows
After building `prism-wallet-sdk`, cd into the demo directory `{path}/demos/browser`

```bash
npm @atala/prism-wallet-sdk --save
cd demos/browser
npm i
npm run start
```

or with yarn

```bash
yarn add @atala/prism-wallet-sdk
```


### Implementing storage for the SDK
This SDK exposes Pluto, a storage interface that should be implemented by the user, in the most appropriate way for a particular use case.

We don't provide a default implementation out of the box at the moment, but we do provide a couple of demo implementations that can be used to get started with demos and testing.

Provided demo implementations are intentionally oversimplified and SHOULD NOT be used in production.

Loading

1 comment on commit 86691ae

@github-actions
Copy link

Choose a reason for hiding this comment

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

Lines Statements Branches Functions
Coverage: 60%
60.11% (1195/1988) 48.18% (505/1048) 62.08% (352/567)

JUnit

Tests Skipped Failures Errors Time
282 2 💤 0 ❌ 0 🔥 36.371s ⏱️

Please sign in to comment.