From 4fa99f00c9d64bff1b7d86aeefe33ab8ddb84ba0 Mon Sep 17 00:00:00 2001 From: Phat <39623143+lukachi@users.noreply.github.com> Date: Wed, 29 Nov 2023 13:47:54 +0200 Subject: [PATCH] Identity migration hotfix (#24) * add logs * remove logs, bump version * hotfix changelog * hotfix snap types import --- CHANGELOG.md | 9 +++++++-- packages/connector/package.json | 2 +- packages/connector/src/version.json | 2 +- packages/site/package.json | 2 +- packages/snap/package.json | 4 ++-- packages/snap/snap.manifest.json | 4 ++-- packages/snap/src/index.ts | 21 ++++++++++----------- yarn.lock | 4 ++-- 8 files changed, 26 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5da9d544..21bac8f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -## [1.0.0] - 2023-11-27 +## [1.0.1] - 2023-11-29 +### Fixed +- `@rarimo/rarime` - `identity` creation +## [1.0.0] - 2023-11-27 ### Added - `@rarimo/rarime` new dev dependencies: - `@metamask/snaps-sdk` @@ -117,7 +120,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Implemented `@rarimo/rarime-connector` and `@rarimo/rarime` packages -[Unreleased]: https://github.com/rarimo/rarime/compare/0.8.0...HEAD +[Unreleased]: https://github.com/rarimo/rarime/compare/1.0.1...HEAD +[1.0.1]: https://github.com/rarimo/rarime/compare/1.0.0...1.0.1 +[1.0.0]: https://github.com/rarimo/rarime/compare/0.8.0...1.0.0 [0.8.0]: https://github.com/rarimo/rarime/compare/0.7.2...0.8.0 [0.7.2]: https://github.com/rarimo/rarime/compare/0.7.1...0.7.2 [0.7.1]: https://github.com/rarimo/rarime/compare/0.7.0...0.7.1 diff --git a/packages/connector/package.json b/packages/connector/package.json index df57ceb8..4397dcb0 100644 --- a/packages/connector/package.json +++ b/packages/connector/package.json @@ -1,6 +1,6 @@ { "name": "@rarimo/rarime-connector", - "version": "1.0.0", + "version": "1.0.1", "description": "Facilitates interaction between a DApp and RariMe MetaMask snap", "repository": { "type": "git", diff --git a/packages/connector/src/version.json b/packages/connector/src/version.json index 1587a669..ca84e70e 100644 --- a/packages/connector/src/version.json +++ b/packages/connector/src/version.json @@ -1,3 +1,3 @@ { - "version": "1.0.0" + "version": "1.0.1" } diff --git a/packages/site/package.json b/packages/site/package.json index 770ed0b6..e5dcf810 100644 --- a/packages/site/package.json +++ b/packages/site/package.json @@ -1,6 +1,6 @@ { "name": "site", - "version": "1.0.0", + "version": "1.0.1", "private": true, "license": "(MIT-0 OR Apache-2.0)", "scripts": { diff --git a/packages/snap/package.json b/packages/snap/package.json index 379e0e83..432192ec 100644 --- a/packages/snap/package.json +++ b/packages/snap/package.json @@ -1,6 +1,6 @@ { "name": "@rarimo/rarime", - "version": "1.0.0", + "version": "1.0.1", "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", @@ -48,7 +48,7 @@ "@metamask/snaps-jest": "^4.0.0", "@metamask/snaps-sdk": "^1.1.0", "@metamask/snaps-utils": "^4.0.0", - "@rarimo/rarime-connector": "1.0.0", + "@rarimo/rarime-connector": "1.0.1", "buffer": "6.0.3", "dids": "4.0.4", "ethers": "5.7.2", diff --git a/packages/snap/snap.manifest.json b/packages/snap/snap.manifest.json index 378317b7..8f750df8 100644 --- a/packages/snap/snap.manifest.json +++ b/packages/snap/snap.manifest.json @@ -1,5 +1,5 @@ { - "version": "1.0.0", + "version": "1.0.1", "description": "Securely store and manage all of your identity credentials. Use them across chains with ZK-protected privacy guarantees.", "proposedName": "RariMe", "repository": { @@ -7,7 +7,7 @@ "url": "https://github.com/rarimo/rarime.git" }, "source": { - "shasum": "GZ36GgxHZWjfiaw8YRYo5VdzYaGa8VXv15la/1pSVCg=", + "shasum": "xmQkggEgEuYf4rN+OAmiJBYwMWS7Xy+SpIMkEsNU5e4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/snap/src/index.ts b/packages/snap/src/index.ts index bfeccb85..b597ba6c 100644 --- a/packages/snap/src/index.ts +++ b/packages/snap/src/index.ts @@ -1,15 +1,9 @@ // eslint-disable-next-line import/no-unassigned-import import './polyfill'; -import { - OnRpcRequestHandler, - copyable, - divider, - heading, - panel, - text, -} from '@metamask/snaps-sdk'; +import { copyable, divider, heading, panel, text } from '@metamask/snaps-sdk'; import { RPCMethods } from '@rarimo/rarime-connector'; import { DID } from '@iden3/js-iden3-core'; +import type { JsonRpcRequest } from '@metamask/utils'; import { Identity } from './identity'; import { getItemFromStore, setItemInStore } from './rpc'; import { CircuitId, StorageKeys } from './enums'; @@ -40,9 +34,12 @@ import { import { GET_CREDENTIALS_SUPPORTED_HOSTNAMES } from './config'; import { getDecryptedCredentials } from './helpers/ceramic-helpers'; -export const onRpcRequest: OnRpcRequestHandler = async ({ +export const onRpcRequest = async ({ request, origin, +}: { + request: JsonRpcRequest; + origin: string; }) => { if (request.method !== RPCMethods.CreateIdentity) { await moveStoreVCtoCeramic(); @@ -93,7 +90,8 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ case RPCMethods.CreateIdentity: { const identityStorage = await getItemFromStore(StorageKeys.identity); - if (identityStorage) { + + if (identityStorage?.did && identityStorage?.didBigInt) { return { identityIdString: identityStorage.did, identityIdBigIntString: identityStorage.didBigInt, @@ -123,13 +121,14 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ : entropy; const identity = await Identity.create(keyHex); + await setItemInStore(StorageKeys.identity, { privateKeyHex: identity.privateKeyHex, did: identity.didString, didBigInt: identity.identityIdBigIntString, }); - snap.request({ + await snap.request({ method: 'snap_dialog', params: { type: 'alert', diff --git a/yarn.lock b/yarn.lock index bce340fc..adb0d22e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6503,7 +6503,7 @@ __metadata: languageName: node linkType: hard -"@rarimo/rarime-connector@1.0.0, @rarimo/rarime-connector@workspace:^, @rarimo/rarime-connector@workspace:packages/connector": +"@rarimo/rarime-connector@1.0.1, @rarimo/rarime-connector@workspace:^, @rarimo/rarime-connector@workspace:packages/connector": version: 0.0.0-use.local resolution: "@rarimo/rarime-connector@workspace:packages/connector" dependencies: @@ -6540,7 +6540,7 @@ __metadata: "@metamask/snaps-jest": ^4.0.0 "@metamask/snaps-sdk": ^1.1.0 "@metamask/snaps-utils": ^4.0.0 - "@rarimo/rarime-connector": 1.0.0 + "@rarimo/rarime-connector": 1.0.1 "@typechain/ethers-v5": 11.1.1 "@types/intl": 1.2.0 "@types/uuid": 9.0.2