# linkfeed-record

> record operations ## Installation

Latest version **1.0.17** (published 2023-02-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install linkfeed-record
pnpm add linkfeed-record
yarn add linkfeed-record
bun add linkfeed-record
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.17 |
| Published | 2023-02-07 |
| First published | 2022-11-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 13 |
| Unpacked size | 106.7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Dugubuyan |
| Maintainers | dugubuyan |

## Links

- npm: https://www.npmjs.com/package/linkfeed-record
- npm.io page: https://npm.io/package/linkfeed-record

## Dependencies (13)

- [dids](https://npm.io/package/dids.md) ^3.4.0
- [uuid](https://npm.io/package/uuid.md) ^9.0.0
- [@3id/connect](https://npm.io/package/@3id/connect.md) ^0.4.1
- [@glazed/types](https://npm.io/package/@glazed/types.md) ^0.2.0
- [ipfs-core-types](https://npm.io/package/ipfs-core-types.md) ^0.13.0
- [key-did-resolver](https://npm.io/package/key-did-resolver.md) ^2.3.0
- [@glazed/datamodel](https://npm.io/package/@glazed/datamodel.md) ^0.3.1
- [@glazed/tile-loader](https://npm.io/package/@glazed/tile-loader.md) ^0.2.1
- [@glazed/did-datastore](https://npm.io/package/@glazed/did-datastore.md) ^0.3.2
- [key-did-provider-ed25519](https://npm.io/package/key-did-provider-ed25519.md) ^2.0.1
- [@ceramicnetwork/http-client](https://npm.io/package/@ceramicnetwork/http-client.md) ^2.7.0
- [@glazed/did-datastore-model](https://npm.io/package/@glazed/did-datastore-model.md) ^0.2.0
- [@ceramicnetwork/3id-did-resolver](https://npm.io/package/@ceramicnetwork/3id-did-resolver.md) ^2.6.0

## Recent versions

- 1.0.17 (latest) — 2023-02-07
- 1.0.16 — 2023-02-07
- 1.0.15 — 2022-11-22
- 1.0.14 — 2022-11-22
- 1.0.12 — 2022-11-22
- 1.0.11 — 2022-11-22
- 1.0.9 — 2022-11-22
- 1.0.8 — 2022-11-22
- 1.0.7 — 2022-11-22
- 1.0.6 — 2022-11-22
- 1.0.5 — 2022-11-22
- 1.0.4 — 2022-11-22
- 1.0.3 — 2022-11-16
- 1.0.2 — 2022-11-16
- 1.0.1 — 2022-11-16
- … 1 more at https://npm.io/package/linkfeed-record/versions

## README

# linkfeed record
record operations 
## Installation

```sh
npm install linkfeed-record
```

## Example
How to create a record class? 
```ts
import  Record  from 'linkfeed/record'
// the ceramic is optional, if not be set, we would use Testnet node 
const rec = new Record({did: did, ceramic: ceramic})
// first, we should anthenticate the did
await rec.auth()
```
We can use the record to collect an item
```ts
// we can create a item by create function 
// we will generate a uuid if the uuid is not set.
// Notice : not only the three feild can be provided, you can set any feild into the item
const item = {"title":"my title","source_url":"my url", "uuid": uuid}
await rec.create(item)
```
To get all the item we collected, we can use the list function
```ts
// show the list we collect, a array will be returned
const list = rec.list()
```
We also can remove an item, or update an item like below
```ts
// remove by uid, the uid can be found in the results of the list function
await rec.remove(uid)
// update an item, uid can be found by the same way 
// we change the item to be newItem by uid
const newItem = {"title":"new title","source_url":"new url"}
await rec.update(newItem, uid)
```
## prerequisite
In order to create a record instance, we need a Ceramic instance and an DID.
### Ceramic instance
If you have run a local node, you can get a ceramic instance like this 
```ts
import { CeramicClient } from '@ceramicnetwork/http-client'
// the node port is 7007 by default, you must set it to be right if you have changed on the local node
const ceramic = new CeramicClient('http://localhost:7007')
```
Or, you can get a ceramic instance from the Clay Testnet
```ts
import { CeramicClient } from '@ceramicnetwork/http-client'
const ceramic = new CeramicClient("https://ceramic-clay.3boxlabs.com")
```
### DID
If you are developing an App and you have to connect a blockchain wallet, maybe the 3ID Connect is what you want.

3ID Connect is an in-browser 3ID DID provider, using blockchain wallets to create deterministic authentication secrets using to control a DID.

Using 3ID Connect, web apps do not need to take care of key custody directly, but rather to use an authentication provider such as EthereumAuthProvider to allow 3ID Connect to generate the necessarry authentication secrets.
#### installation
```sh
npm install @3id/connect
```
#### Usage
```ts
import { CeramicClient } from '@ceramicnetwork/http-client'
import { DID } from 'dids'
import { getResolver as getKeyResolver } from 'key-did-resolver'
import { getResolver as get3IDResolver } from '@ceramicnetwork/3id-did-resolver'
import { EthereumAuthProvider, ThreeIdConnect } from '@3id/connect'

// Create a ThreeIdConnect connect instance as soon as possible in your app to start loading assets
const threeID = new ThreeIdConnect()

async function getDidWithEthereum(ethereumProvider) {
  // Request accounts from the Ethereum provider
  const accounts = await ethereumProvider.request({
    method: 'eth_requestAccounts',
  })
  // Create an EthereumAuthProvider using the Ethereum provider and requested account
  const authProvider = new EthereumAuthProvider(ethereumProvider, accounts[0])
  // Connect the created EthereumAuthProvider to the 3ID Connect instance so it can be used to
  // generate the authentication secret
  await threeID.connect(authProvider)

  const did = new DID({
    // Get the DID provider from the 3ID Connect instance
    provider: threeID.getDidProvider(),
    resolver: {
      ...get3IDResolver(ceramic),
      ...getKeyResolver(),
    },
  })

  return did
}
// When using extensions such as MetaMask, an Ethereum provider may be injected as `window.ethereum`
if (window.ethereum == null) {
    throw new Error('No injected Ethereum provider')
}
const did = await getDidWithEthereum(window.ethereum)
```
## Maintainers

- dugubuyan ([@dugubuyan](https://github.com/dugubuyan))

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