# @rarimo/rarime

> RariMe is a MetaMask Snap that safely holds any of your credentials and allows you to prove your identity without revealing any personal data. Powered by Rarimo Protocol and Zero-Knowledge Proof technology.

Latest version **2.1.1** (published 2024-06-18) · (MIT-0 OR Apache-2.0) license · 0 weekly downloads

## Install

```sh
npm install @rarimo/rarime
pnpm add @rarimo/rarime
yarn add @rarimo/rarime
bun add @rarimo/rarime
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; large bundle.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2024-06-18 |
| First published | 2023-08-27 |
| Weekly downloads | 0 |
| License | (MIT-0 OR Apache-2.0) |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=16.0.0 |
| Dependencies | 29 |
| Unpacked size | 101 MB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 13 |
| Maintainers | lukachi, ihor.diachenko, electr1xx, arvolear, volendi, semen_rarify |

## Links

- npm: https://www.npmjs.com/package/@rarimo/rarime
- Repository: https://github.com/rarimo/rarime
- npm.io page: https://npm.io/package/@rarimo/rarime

## Dependencies (29)

- [dids](https://npm.io/package/dids.md) 4.0.4
- [intl](https://npm.io/package/intl.md) 1.2.5
- [uuid](https://npm.io/package/uuid.md) 9.0.0
- [typia](https://npm.io/package/typia.md) 4.1.3
- [buffer](https://npm.io/package/buffer.md) 6.0.3
- [ethers](https://npm.io/package/ethers.md) 5.7.2
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [graphql](https://npm.io/package/graphql.md) ^16.8.1
- [snarkjs](https://npm.io/package/snarkjs.md) ^0.7.2
- [graphql-tag](https://npm.io/package/graphql-tag.md) ^2.12.6
- [@iden3/js-jwz](https://npm.io/package/@iden3/js-jwz.md) 1.3.0
- [@apollo/client](https://npm.io/package/@apollo/client.md) ^3.8.7
- [@iden3/js-crypto](https://npm.io/package/@iden3/js-crypto.md) 1.0.3
- [key-did-resolver](https://npm.io/package/key-did-resolver.md) 3.0.0
- [@composedb/client](https://npm.io/package/@composedb/client.md) ^0.6.0
- [@ethersproject/abi](https://npm.io/package/@ethersproject/abi.md) 5.0.0
- [@metamask/snaps-sdk](https://npm.io/package/@metamask/snaps-sdk.md) ^3.0.1
- [@ethersproject/bytes](https://npm.io/package/@ethersproject/bytes.md) 5.7.0
- [@iden3/js-iden3-core](https://npm.io/package/@iden3/js-iden3-core.md) 1.2.1
- [@iden3/js-merkletree](https://npm.io/package/@iden3/js-merkletree.md) 1.1.2
- [@metamask/snaps-jest](https://npm.io/package/@metamask/snaps-jest.md) ^5.0.0
- [@glazed/did-datastore](https://npm.io/package/@glazed/did-datastore.md) 0.3.2
- [@metamask/snaps-utils](https://npm.io/package/@metamask/snaps-utils.md) ^7.0.3
- [@ethersproject/keccak256](https://npm.io/package/@ethersproject/keccak256.md) 5.7.0
- [@ethersproject/providers](https://npm.io/package/@ethersproject/providers.md) 5.7.2
- [@rarimo/rarime-connector](https://npm.io/package/@rarimo/rarime-connector.md) ^2.1.1
- [key-did-provider-ed25519](https://npm.io/package/key-did-provider-ed25519.md) 3.0.2
- [@ceramicnetwork/http-client](https://npm.io/package/@ceramicnetwork/http-client.md) 2.27.0
- [@iden3/js-jsonld-merklization](https://npm.io/package/@iden3/js-jsonld-merklization.md) 1.1.2

## Recent versions

- 2.1.1 (latest) — 2024-06-18
- 3.0.0-rc.2 (next) — 2024-08-02
- 3.0.0-rc.1 — 2024-08-02
- 3.0.0-rc.0 — 2024-05-24
- 2.1.0 — 2024-04-08
- 2.1.0-rc.25 — 2024-04-05
- 2.1.0-rc.24 — 2024-04-01
- 2.1.0-rc.22 — 2024-04-01
- 2.1.0-rc.21 — 2024-04-01
- 2.1.0-rc.20 — 2024-04-01
- 2.1.0-rc.19 — 2024-04-01
- 2.1.0-rc.18 — 2024-04-01
- 2.1.0-rc.17 — 2024-03-21
- 2.1.0-rc.16 — 2024-03-21
- 2.1.0-rc.311 — 2024-03-20
- … 58 more at https://npm.io/package/@rarimo/rarime/versions

## README

# RariMe

RariMe is a MetaMask Snap that safely holds any of your credentials and allows you to prove your identity without revealing any personal data. Powered by Rarimo Protocol and Zero-Knowledge Proof technology.

## Methods

### Create an identity

To create an identity you need to call this method:

```javascript
await window.ethereum.request({
  method: 'wallet_invokeSnap',
  params: {
    snapId: 'snapId',
    request: { method: 'create_identity' },
  },
});
```

### Get identity

Returns DID and DID in big int string format if they are exists, otherwise method throws error.

```javascript
await window.ethereum.request({
  method: 'wallet_invokeSnap',
  params: {
    snapId: 'snapId',
    request: { method: 'get_identity' },
  },
});
```

### Export identity

To export an identity you need to call this method:

```javascript
await window.ethereum.request({
  method: 'wallet_invokeSnap',
  params: {
    snapId: 'snapId',
    request: { method: 'export_identity' },
  },
});
```

### Save Verifiable Credentials

To save Verifiable Credentials you need to call this method with params:

```javascript
await window.ethereum.request({
  method: 'wallet_invokeSnap',
  params: {
    snapId: 'snapId',
    request: {
      method: 'save_credentials',
      params: {
        body: {
          credentials: [
            {
              description: 'Natural Person',
              id: '86531650-023c-4c6c-a437-a82e137ead68',
            },
          ],
          url: 'http://127.0.0.1:8000/integrations/issuer/v1/public/claims/offers/callback',
        },
        from: 'did:iden3:tJnRoZ1KqUPbsfVGrk8io51iqoRc5dGhj5LLMHSrD',
        id: '026035f6-42f6-4a2d-b516-0b11d2674850',
        thid: '348b7198-7cb1-46f4-bc0a-98a358f65539',
        to: 'did:iden3:tTxif8ahrSqRWavS8Qatrp4ZEJvPdu3ELSMgqTEQN',
        typ: 'application/iden3comm-plain-json',
        type: 'https://iden3-communication.io/credentials/1.0/offer',
      },
    },
  },
});
```

where:

- **id**: request identifier
- **thid**: ID of the message thread
- **from**: identifier of the person from whom the offer was received
- **to**: identifier of the person who received the offer
- **typ**: media type of the message. In our case, it is the type of the protocol of the packed message application/iden3comm-plain-json
- **type**: type of iden3comm protocol message
- **body**
  - **credentials[0]**
    - **description**: description of the schema
    - **id**: credential id
  - **url**: URL to which requested information is sent and response is received

### Remove Verifiable Credentials

```javascript
return await window.ethereum.request({
  method: 'wallet_invokeSnap',
  params: {
    request: {
      method: 'remove_credentials',
      params: {
        ids: [
          'https://example.issuer.node.api.com/v1/credentials/86531650-023c-4c6c-a437-a82e137ead68',
        ],
      },
    },
    snapId: 'local:http://localhost:8081',
  },
});
```

where:

- **ids**: list of claim ids to remove, e. g. `W3CCredential.id`

### Create a proof

Make sure you are on the correct network before creating a proof!
Returns ZKProof for off-chain and updateStateTx, statesMerkleData, ZKProof for on-chain
To create a proof you need to call this method with params:

```javascript
await window.ethereum.request({
  method: 'wallet_invokeSnap',
  params: {
    snapId: 'snapId',
    request: {
      method: 'create_proof',
      params: {
        circuitId: 'credentialAtomicQuerySigV2OnChain',
        issuerDid: 'did:iden3:[...]',
        accountAddress: '0x......',
        challenge: '1251760352881625298994789945427452069454957821390', // BigInt string
        query: {
          allowedIssuers: ['*'],
          credentialSubject: {
            isNatural: {
              $eq: 1,
            },
          },
          type: 'IdentityProviders',
        },
      },
    },
  },
});
```

where:

- **circuitId**: type of proof
- **accountAddress**(optional): Metamask user address for onchain proofs
- **issuerDid**: did of the issuer trusted by the verifier
- **challenge**(optional): text that will be signed
- **query**
  - **allowedIssuers**: types of issuers allowed
    - **\***: all types of Issuers are allowed
  - **context**: URL for getting the vocabulary for the credential
  - **type**: type of credentials allowed
  - **credentialSubject**: query request to a query circuit

### Check state contract

Returns `true` if the state contract on current chain need to be synced:

```javascript
await window.ethereum.request({
  method: 'wallet_invokeSnap',
  params: {
    snapId: 'snapId',
    request: {
      method: 'check_state_contract_sync',
    },
  },
});
```

### Get Verifiable Credentials

- Only supported domains

Return a list of Verifiable Credentials:

```javascript
await window.ethereum.request({
  method: 'wallet_invokeSnap',
  params: {
    snapId: 'snapId',
    request: {
      method: 'get_credentials',
    },
  },
});
```

## Testing

The snap comes with some basic tests, to demonstrate how to write tests for
snaps. To test the snap, run `yarn test` in this directory. This will use
[`@metamask/snaps-jest`](https://github.com/MetaMask/snaps/tree/main/packages/snaps-jest)
to run the tests in `src/index.test.ts`.

## Development

## Prepare ceramic json files and deploy (example)

### Prerequisites

First things first, follow steps on Ceramic composeDB [guide](https://developers.ceramic.network/docs/composedb/set-up-your-environment#setup) to prepare environment and get `CERAMIC_URL` with `DID_PRIVATE_KEY` variables.

### Run script to prepare json files

```bash
CERAMIC_URL=http://... DID_PRIVATE_KEY=fbb8731ecc9c36542f9caf9d9e3535c8... yarn workspace @rarimo/rarime ceramic:prepare-vc
```

### Run Graphql server locally

```bash
CERAMIC_URL=http://... DID_PRIVATE_KEY=fbb8731ecc9c36542f9caf9d9e3535c8... yarn workspace @rarimo/rarime ceramic:graphql-server
```

## Notes

- Babel is used for transpiling TypeScript to JavaScript, so when building with
  the CLI, `transpilationMode` must be set to `localOnly` (default) or
  `localAndDeps`.

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