Skip to content

Commit

Permalink
Updated required MM version
Browse files Browse the repository at this point in the history
  • Loading branch information
ihordiachenko committed Apr 1, 2024
1 parent d1d4810 commit 88b5afc
Show file tree
Hide file tree
Showing 14 changed files with 527 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/connector/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rarimo/rarime-connector",
"version": "2.1.0-rc.17",
"version": "2.1.0-rc.18",
"description": "Facilitates interaction between a DApp and RariMe MetaMask snap",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/connector/src/consts/general.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const CORE_POLLING_INTERVAL = 5_000;
export const SUPPORTED_METAMASK_VERSION = '11.12.0';
export const SUPPORTED_METAMASK_VERSION = '11.13.0';
2 changes: 1 addition & 1 deletion packages/connector/src/version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "2.1.0-rc.17"
"version": "2.1.0-rc.18"
}
6 changes: 3 additions & 3 deletions packages/snap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rarimo/rarime",
"version": "2.1.0-rc.17",
"version": "2.1.0-rc.18",
"description": "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.",
"repository": {
"type": "git",
Expand All @@ -10,8 +10,8 @@
"files": [
"dist/",
"images/",
"assets/circuits/auth",
"assets/circuits/credentialAtomicQueryMTPV2OnChain",
"assets/circuits/auth/",
"assets/circuits/credentialAtomicQueryMTPV2OnChain/",
"snap.manifest.json",
"README.md"
],
Expand Down
230 changes: 230 additions & 0 deletions packages/snap/package/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
# 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`.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 88b5afc

Please sign in to comment.