# @inco/js (called `@inco/js` for now)

The @inco/js package contains the TypeScript SDK for creating dapps built on Inco.

## Install the package

Since the package is private in the Github package registry, you'll need to use npm to log in into the registry first. Obviously, this is only needed if you want to access the package from outside the monorepo, as the monorepo already has workspaces set up.

1. Create a Github Personal Access Token (Classic)

Go to the [Personal Access Tokens](https://github.com/settings/tokens) page on Github, and create a new access token with the `read:packages` permission. Give it an explicit name like `inco-js-npm-github-pkg-registry`, and save the access token in a secure place, e.g. your password manager.

2. Login via npm to Github Package Registry.

```bash
cd /path/to/my/project
npm login --scope=@inco-fhevm --registry=https://npm.pkg.github.com
```

You'll be asked to enter Username and Password. Put in your Github username, and paste the access token on step 1 as password.

3. Tell npm to look into Github Package Registry.

Create a new `.npmrc` in `/path/to/my/project`, with the following lines:

```
@inco-fhevm:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${READ_PACKAGE_TOKEN}
```

Then, you can do `npm install @inco/js`!

Note: If using bun or another package manager, take a look how they manage install scopes.

4. Resources

- Github docs: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry
- Medium article: https://medium.com/@aamiralihussain53/a-guide-to-publishing-private-npm-package-on-github-9c533a251e2d

## Usage

Currently, there are no docs as how to use the @inco/js package, as it only exposes low-level functions. There's some API work to do to make it more user-friendly.

To take a look at the low-level functions, see [the E2E test](./test/incolite.ts), which shows how to encrypt, send an encrypted input to the host chain, request a reencrypt and wait for a decrypt.

## Publishing the package

Currently the publishing process is manual, and anyone with enough rights can run `bun run publish:github` to publish to the Github Packages registry.

Some gitops process should replace this manual setup.
