# @dashkite/zinc

> Manage profiles and Web grants locally in the browser.

Latest version **0.4.0** (published 2021-09-07) · SEE LICENSE IN LICENSE.md license · 0 weekly downloads

## Install

```sh
npm install @dashkite/zinc
pnpm add @dashkite/zinc
yarn add @dashkite/zinc
bun add @dashkite/zinc
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.0 |
| Published | 2021-09-07 |
| First published | 2020-05-10 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN LICENSE.md |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 53.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | dyoder, freeformflow |

## Links

- npm: https://www.npmjs.com/package/@dashkite/zinc
- Repository: https://github.com/dashkite/zinc
- Homepage: https://github.com/dashkite/zinc#readme
- Issues: https://github.com/dashkite/zinc/issues
- npm.io page: https://npm.io/package/@dashkite/zinc

## Dependencies (5)

- [idb](https://npm.io/package/idb.md) ^6.1.3
- [@dashkite/joy](https://npm.io/package/@dashkite/joy.md) ^0.3.11
- [@dashkite/cobalt](https://npm.io/package/@dashkite/cobalt.md) ^2.1.0
- [@dashkite/events](https://npm.io/package/@dashkite/events.md) ^0.1.0
- [panda-confidential](https://npm.io/package/panda-confidential.md) ^3.1.0

## Recent versions

- 0.4.0 (latest) — 2021-09-07
- 0.3.0 — 2021-08-05
- 0.2.0 — 2021-05-21
- 0.1.3 — 2020-10-17
- 0.1.2 — 2020-09-11
- 0.1.0 — 2020-07-29
- 0.0.10 — 2020-06-23
- 0.0.9 — 2020-05-15
- 0.0.8 — 2020-05-15
- 0.0.7 — 2020-05-15
- 0.0.6 — 2020-05-14
- 0.0.4 — 2020-05-12
- 0.0.3 — 2020-05-12
- 0.0.2 — 2020-05-10
- 0.0.1 — 2020-05-10

## README

# Zinc

_Manage profile and Web capabilities using IndexedDB._

## Install

`npm i @dashkite/zinc`

Use with your favorite bundler.

## Scenarios

#### List All Profiles

If you want to allow for multiple identities, you’ll need a way to list the choices.

```coffeescript
profiles = await Profile.all
```

#### Create A New Profile

```coffeescript
alice = await Profile.create authority, nickname: "alice"
```

#### Get Current Profile

```coffeescript
alice = await Profile.current
```

#### Set Current Profile

```coffeescript
Profile.current = alice
```

#### Update And Store A Profile

```coffeescript
await profile.update -> @data.nickname = "alice"
```

#### Create An Adjunct Profile

```coffeescript
await profile.createAdjunct authority, nickname: "alice"
```

#### Get An Adjunct Profile

```coffeescript
await profile.getAdjunct authority
```

#### Listen For Changes To A Profile

```coffeescript
Profile.on update: (profile) -> console.log "Profile [#{profile.address}] updated"
```

#### Add Grants To The Grants Directory

The `key` and `ciphertext` variables are the sender’s public encryption key and the Base64 ciphertext of the grants.

```coffeescript
alice = await Profile.current
await alice.receive key, ciphertext
```

#### Exercise A Grant For Use With A Request

```coffeescript
alice = await Profile.current
claim = grants.exercise request
```

#### Delete A Profile

```coffeescript
alice = await Profile.current
await alice.delete()
```

## API

Conventions:

- A function or method with a dotted arrow ⇢ yields or returns a Promise
- The `::` indicates the prototype. Ex: `Profile::exercise` is a method, not a class function.

### Profile

#### Property: *Profile.Confidential*

Returns the instance of Confidential used by Zinc to generate key pairs and other cryptographic elements, and to perform cryptographic operations.

#### Function: *Profile.on event-handlers*

Set event handlers for Profile-related events based on the *event-handlers*, which is a dictionary of events and handlers. Handlers should be functions that take an optional _target_ argument.

```coffeescript
Profile.on update: (profile) -> console.log "Profile [#{profile.address}] updated"
```

#### Function: *Profile.dispatch event, value*

Fire a. Profile-related event. You typically do not need to call this directly.

#### Event: *update → profile*

Fired whenever a profile is updated. The updated profile is passed to the event handler.

#### Function: *Profile.create authority, data ⇢ profile*

Creates a profile for a given authority and data and stores it. Automatically generates encryption and signature keypairs for use with the profile. Returns a promise for the profile.

#### Function: *Profile.createAdjunct authority, data ⇢ profile*

Creates a profile using the address for the current profile for a given authority and data and stores it. Automatically generates encryption and signature keypairs for use with the profile. Returns a promise for the profile.

#### Function: *Profile.getAdjunct authority ⇢ profile*

Loads and returns the adjunct profile for given authority. Returns a promise for the profile.

#### Function: *Profile.load authority, address ⇢ profile*

Load the profile corresponding to the given authority and address.

#### Property: *Profile.all ⇢ array*

Returns a promise for an array of all profiles.

#### Property: *Profile.current ⇢ profile*

Gets or sets the current profile. Getter returns a promise for the profile. Returns undefined if the current profile is not set or has been deleted.

#### Method: *Profile::createAdjunct authority, data ⇢ profile*
Convenience method for `Profile.createAdjunct`.

#### Method: *Profile::getAdjunct authority ⇢ profile*
Convenience method for `Profile.getAdjunct`.


#### Method: *Profile::exercise request → claim*

Exercise the grant corresponding to the given claim. Returns a claim (a countersigned grant). The request argument must provide `path`, `parameters`, and `method` properties.

#### Method: *Profile::receive key, ciphertext ⇢ undefined*

Decrypts a directory of grants from base64 ciphertext using the given base64 encoded sender public encryption key, adds them to the profile’s grants directory, and stores the profile.

#### Method: *Profile::update handler ⇢ undefined*

Runs handler bound to profile and stores the profile. Useful for ensuring that profile updates are stored. Promise resolves when the update has been stored.

#### Method: *Profile::delete ⇢ undefined*

Deletes the given profile. If this the current profile, `Profile.current` will return undefined.

---
_Source: https://npm.io/package/@dashkite/zinc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
