项目作者: ayanworks

项目描述 :
Aries React-NatIve Mobile Agent
高级语言: TypeScript
项目地址: git://github.com/ayanworks/ARNIMA-reactnative-sdk.git
创建时间: 2019-12-23T10:20:22Z
项目社区:https://github.com/ayanworks/ARNIMA-reactnative-sdk

开源协议:Apache License 2.0

下载


ARNIMA SDK (Aries React-NatIve Mobile Agent)

ARNIMA is an open-source React Native SDK for building Aries Mobile Agents. ARNIMA attempts to meet the needs / asks of many members from the Aries community, mainly React Native developers, who are looking forward to build cross-platform Aries Mobile Agents using React Native stack.

This React-Native SDK is compatible to be used with both Android and iOS platforms. Please refer Installation section on how to set up the sdk and start running. This SDK is compliant and interoperable with the standards defined in the Aries RFCs.

What’s in the name

Arnima (Hindi: अर्निमा, meaning “First ray of Sun”) is a girl name in India whose zodiac sign is Aries 😉

Apps built using this SDK

App Name Android Ios
ADEYA Link Link
DIT Wallet
(The Digital Identity Trust Foundation)
Link Link

Features

Finished

TODO

Notes:
Currently, SDK supports our custom build mediator agent and we are planning to open-source the mediator agent soon.

Dependencies

  • The node 10.18.1 (To check, nvm ls) is required to install mobile agent specific dependencies like realm
  1. Install nvm
  1. curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
  1. Restart the terminal
  2. Confirm it’s been installed with the following command:
  1. nvm --version
  1. Install node 10 using nvm
  1. nvm install 10.18.1
  1. Make sure you’re using the right version of node
  1. nvm use 10.18.1

Installation

  1. Clone this repository git clone *****
  2. cd into the repo cd mobile-sdk
  3. Create the ARNIMA mobile agent package by using the following command npm pack
  4. This will create a *.tgzfile inside current directory.
  5. Copy the *.tgzfile and paste it inside the root of your mobile wallet project.
  6. Inside your project of mobile app wallet’s package.json, add this to the dependencies block:
  1. "react-native-arnima-sdk": "./<MOBILE_AGENT_PACKAGE>.tgz"
  1. After this, run npm install, and the sdk will automatically unpack and install inside node_modules.
  2. Install the following SDK dependencies in your wallet application:
  • Realm
  1. npm install realm
  • buffer
  1. npm install buffer
  • Socket Client
  1. npm install socket.io-client
  • Base64Url
  1. npm install base64url
  • EventListener
  1. npm i react-native-event-listeners
  1. Execute react-native link
  2. Edit the android/ level build.gradle file and add a repositories section:
  1. repositories {
  2. maven { url 'https://repo.sovrin.org/repository/maven-public' }
  3. }
  1. Include below lines on top of your project’s Podfile.
  1. source 'https://github.com/CocoaPods/Specs.git'
  2. source 'https://github.com/hyperledger/indy-sdk.git'
  1. Change platform :ios, ‘9.0’ to platform :ios, ‘13.0’
  2. Add following line to include sdk pod to your project.
  1. pod 'ArnimaSdk', :path => '../node_modules/react-native-arnima-sdk'
  1. Do pod install.
  2. You need to download and replace the file Indy.framework from Pods folder inside your Mobile app project from the following link (base on your xcode & swift version) Download from - https://drive.google.com/drive/folders/1_WJ3mEHqk5GHH9p5SI4bRKRXPwy5w_0e?usp=sharing, Replace at - /ios/Pods/libindy/

React Native Compatibility

If there are any compatibility issue please add here.

Permissions

  • Internet Permission: To use internet in a device at time of access Restful API.
  1. <uses-permission android:name="android.permission.INTERNET" ></uses-permission>
  • Read/Write permissions: To access device storage for creating wallet.
  1. <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" ></uses-permission>
  2. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>

Using the SDK

  1. Import the library
  1. import ArnimaSDK from 'react-native-arnima-sdk'
  1. Use the following methods

Methods

createWallet(config, credential, label) -> Array


This method is called after the user has set up their wallet name & passcode for the first time.

config: JSON - Wallet configuration that takes in the wallet name as an id (e.g. Proof)

  1. {
  2. id: <WALLET_NAME>
  3. }

credential: JSON - Wallet credentials json that takes in the passcode the user has setup during onboarding

  1. {
  2. key: <PASSCODE>
  3. }

label : String - Your label to show to the counter party during connection

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const wallet = await ArnimaSDK.createWallet(
  3. { id: 'John' },
  4. { key: '354016' },
  5. 'John'
  6. )

Returns:

Success: Array[, , ]
Sample Output: ["K7P6Xoe31NBYn7md8qBm4F", "AsVcY4GUvJyeP2k78vJK2mTuPHT1sSdZjQBXbCUyXEbz", "John"]

Error: Below is a list of anticipated errors

  1. Storage permissions error. Sample: {"code":"114","message":"org.hyperledger.indy.sdk.IOException: An IO error occurred."}]
  2. Wallet already error. Sample:
    {"code":"203","message":"Wallet already exists."}].

ConnectWithMediator(url, apiType, apiBody, poolConfig) -> Boolean


This method connects to an instantiated service of a mediator agent that is in charge of holding messages if the application is offline and to push messages to this sdk the moment mobile app is active.

url: String - endpoint url of the instantiated mediator agent

  1. "http://10.10.10.10:8001/discover/"

apiType: String - Describes the way by which we are accessing the endpoint (in this case, we are using POST)

  1. "POST"

apiBody: String - Stringified JSON that contains the wallet information needed to attach to the mediator agent

  1. JSON.stringify({
  2. myDid: "<WALLET_PUBLIC_DID>",
  3. verkey: "<WALLET_VERIFIED_KEY>",
  4. label: "<WALLET_LABEL>",
  5. firebaseToken: "<FIREBASE_TOKEN> OR '' "
  6. })

poolConfig: String - A genesis transaction string received in response of /register-device endpoint.

  1. {"reqSignature": {}, "txn": {"data": {"data": {"alias": "Node1", "blskey": "4N8aUNHSgjQVgkpm8nhNEfDf6txHznoYREg9kirmJrkivgL4oSEimFF6nsQ6M41QvhM2Z33nves5vfSn9n1UwNFJBYtWVnHYMATn76vLuL3zU88KyeAYcHfsih3He6UHcXDxcaecHVz6jhCYz1P2UZn2bDVruL5wXpehgBfBaLKm3Ba", "blskey_pop": "RahHYiCvoNCtPTrVtP7nMC5eTYrsUA8WjXbdhNc8debh1agE9bGiJxWBXYNFbnJXoXhWFMvyqhqhRoq737YQemH5ik9oL7R4NTTCz2LEZhkgLJzB3QRQqJyBNyv7acbdHrAT8nQ9UkLbaVL9NBpnWXBTw4LEMePaSHEw66RzPNdAX1", "client_ip": "34.71.218.3", "client_port": 9702, "node_ip": "34.71.218.3", "node_port": 9701, "services": ["VALIDATOR"]}, "dest": "Gw6pDLhcBcoQesN72qfotTgFa7cbuqZpkX3Xo6pLhPhv"}, "metadata": {"from": "Th7MpTaRZVRYnPiabds81Y"}, "type": "0"}, "txnMetadata": {"seqNo": 1, "txnId": "fea82e10e894419fe2bea7d96296a6d46f50f93f9eeda954ec461b2ed2950b62"}, "ver": "1"}
  2. {"reqSignature": {}, "txn": {"data": {"data": {"alias": "Node2", "blskey": "37rAPpXVoxzKhz7d9gkUe52XuXryuLXoM6P6LbWDB7LSbG62Lsb33sfG7zqS8TK1MXwuCHj1FKNzVpsnafmqLG1vXN88rt38mNFs9TENzm4QHdBzsvCuoBnPH7rpYYDo9DZNJePaDvRvqJKByCabubJz3XXKbEeshzpz4Ma5QYpJqjk", "blskey_pop": "Qr658mWZ2YC8JXGXwMDQTzuZCWF7NK9EwxphGmcBvCh6ybUuLxbG65nsX4JvD4SPNtkJ2w9ug1yLTj6fgmuDg41TgECXjLCij3RMsV8CwewBVgVN67wsA45DFWvqvLtu4rjNnE9JbdFTc1Z4WCPA3Xan44K1HoHAq9EVeaRYs8zoF5", "client_ip": "34.71.218.3", "client_port": 9704, "node_ip": "34.71.218.3", "node_port": 9703, "services": ["VALIDATOR"]}, "dest": "8ECVSk179mjsjKRLWiQtssMLgp6EPhWXtaYyStWPSGAb"}, "metadata": {"from": "EbP4aYNeTHL6q385GuVpRV"}, "type": "0"}, "txnMetadata": {"seqNo": 2, "txnId": "1ac8aece2a18ced660fef8694b61aac3af08ba875ce3026a160acbc3a3af35fc"}, "ver": "1"}
  3. {"reqSignature": {}, "txn": {"data": {"data": {"alias": "Node3", "blskey": "3WFpdbg7C5cnLYZwFZevJqhubkFALBfCBBok15GdrKMUhUjGsk3jV6QKj6MZgEubF7oqCafxNdkm7eswgA4sdKTRc82tLGzZBd6vNqU8dupzup6uYUf32KTHTPQbuUM8Yk4QFXjEf2Usu2TJcNkdgpyeUSX42u5LqdDDpNSWUK5deC5", "blskey_pop": "QwDeb2CkNSx6r8QC8vGQK3GRv7Yndn84TGNijX8YXHPiagXajyfTjoR87rXUu4G4QLk2cF8NNyqWiYMus1623dELWwx57rLCFqGh7N4ZRbGDRP4fnVcaKg1BcUxQ866Ven4gw8y4N56S5HzxXNBZtLYmhGHvDtk6PFkFwCvxYrNYjh", "client_ip": "34.71.218.3", "client_port": 9706, "node_ip": "34.71.218.3", "node_port": 9705, "services": ["VALIDATOR"]}, "dest": "DKVxG2fXXTU8yT5N7hGEbXB3dfdAnYv1JczDUHpmDxya"}, "metadata": {"from": "4cU41vWW82ArfxJxHkzXPG"}, "type": "0"}, "txnMetadata": {"seqNo": 3, "txnId": "7e9f355dffa78ed24668f0e0e369fd8c224076571c51e2ea8be5f26479edebe4"}, "ver": "1"}
  4. {"reqSignature": {}, "txn": {"data": {"data": {"alias": "Node4", "blskey": "2zN3bHM1m4rLz54MJHYSwvqzPchYp8jkHswveCLAEJVcX6Mm1wHQD1SkPYMzUDTZvWvhuE6VNAkK3KxVeEmsanSmvjVkReDeBEMxeDaayjcZjFGPydyey1qxBHmTvAnBKoPydvuTAqx5f7YNNRAdeLmUi99gERUU7TD8KfAa6MpQ9bw", "blskey_pop": "RPLagxaR5xdimFzwmzYnz4ZhWtYQEj8iR5ZU53T2gitPCyCHQneUn2Huc4oeLd2B2HzkGnjAff4hWTJT6C7qHYB1Mv2wU5iHHGFWkhnTX9WsEAbunJCV2qcaXScKj4tTfvdDKfLiVuU2av6hbsMztirRze7LvYBkRHV3tGwyCptsrP", "client_ip": "34.71.218.3", "client_port": 9708, "node_ip": "34.71.218.3", "node_port": 9707, "services": ["VALIDATOR"]}, "dest": "4PS3EDQ3dW1tci1Bp6543CfuuebjFrg36kLAUcskGfaA"}, "metadata": {"from": "TWwCRQRZ2ZHMJFn9TzLp7W"}, "type": "0"}, "txnMetadata": {"seqNo": 4, "txnId": "aa5e817d7cc626170eca175822029339a444eb0ee8f0bd20d3b0b76e566fb008"}, "ver": "1"}

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const wallet = await ArnimaSDK.ConnectWithMediator(
  3. 'http://localhost:8080/discover',
  4. 'POST',
  5. JSON.stringify({
  6. myDid: ArnimaSDK.getWallet().publicDid,
  7. verkey: ArnimaSDK.getWallet().verKey,
  8. label: ArnimaSDK.getWallet().label,
  9. firebaseToken: '',
  10. }),
  11. poolConfig
  12. )

Returns:

Success: true

createInvitation(didJson) -> String


Returns a url for connection

didJson: Json - Identity information as json

  1. {
  2. "did": string, (optional;
  3. if not provided and cid param is false then the first 16 bit of the verkey will be used as a new DID;
  4. if not provided and cid is true then the full verkey will be used as a new DID;
  5. if provided, then keys will be replaced - key rotation use case)
  6. "seed": string, (optional) Seed that allows deterministic did creation (if not set random one will be created).
  7. Can be UTF-8, base64 or hex string.
  8. "crypto_type": string, (optional; if not set then ed25519 curve is used;
  9. currently only 'ed25519' value is supported for this field)
  10. "cid": bool, (optional; if not set then false is used;)
  11. "method_name": string, (optional) method name to create fully qualified did (Example: `did:method_name:NcYxiDXkpYi6ov5FcYDi1e`).
  12. }

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const response = await ArnimaSDK.createInvitation({})

Returns:

Success: string

  1. "http://10.10.10.10:8001?c_i=eyJAdHlwZSI6ICJkaWQ6csdsd2OkJ6Q2JzTlloTXJqSGlxWkRUVUFTSGc7c3BlYy9jb25uZWN0aW9ucy8xLjAvaW52aXRhdGlvbiIsICJAaWQiOiAiMmMzYjY5NjMtODc3YS00NDEwLWIwNTctZjVkZWU2NDNjZDc5IiwgImxhYmVsIjogInF3ZXJ0eSIsICJzZXJ2aWNlRW5kcG9pbnQiOiAiaHRvfgfDovLzEwLjEwLjEwLjIwds5MDAyIiwgInJlY2lwaWVudEtleXMiOiBbIjljYXVFbzhpMkdFa0pBYnZTRFBvQ0I0dnU3N05lTDZiUWRORm1RSmF6THJEIl19"

acceptInvitation(didJson, invitationUrl) -> Boolean


didJson: Json - Identity information as json if you don’t have pass empty object - {}.

  1. {
  2. "did": string, (optional;
  3. if not provided and cid param is false then the first 16 bit of the verkey will be used as a new DID;
  4. if not provided and cid is true then the full verkey will be used as a new DID;
  5. if provided, then keys will be replaced - key rotation use case)
  6. "seed": string, (optional) Seed that allows deterministic did creation (if not set random one will be created).
  7. Can be UTF-8, base64 or hex string.
  8. "crypto_type": string, (optional; if not set then ed25519 curve is used;
  9. currently only 'ed25519' value is supported for this field)
  10. "cid": bool, (optional; if not set then false is used;)
  11. "method_name": string, (optional) method name to create fully qualified did (Example: `did:method_name:NcYxiDXkpYi6ov5FcYDi1e`).
  12. }

invitationUrl: String - Encoded url invitation.

  1. "http://10.10.10.10:8001?c_i=eyJAdHlwZSI6ICJkaWQ6csdsd2OkJ6Q2JzTlloTXJqSGlxWkRUVUFTSGc7c3BlYy9jb25uZWN0aW9ucy8xLjAvaW52aXRhdGlvbiIsICJAaWQiOiAiMmMzYjY5NjMtODc3YS00NDEwLWIwNTctZjVkZWU2NDNjZDc5IiwgImxhYmVsIjogInF3ZXJ0eSIsICJzZXJ2aWNlRW5kcG9pbnQiOiAiaHRvfgfDovLzEwLjEwLjEwLjIwds5MDAyIiwgInJlY2lwaWVudEtleXMiOiBbIjljYXVFbzhpMkdFa0pBYnZTRFBvQ0I0dnU3N05lTDZiUWRORm1RSmF6THJEIl19"

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const wallet = await ArnimaSDK.acceptInvitation({}, InvitationUrl)

Returns:

Success: true

getAllConnections() -> Array


Function returns an array of Objects.

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const wallet = await ArnimaSDK.getAllConnections()

Returns:

Success: Array[
{
connectionId: string,
connection: string,
}, …
]

Sample Output:

  1. [{
  2. connection: "{"did":"ADGeeTatN2KSqRaSXDb3jv","didDoc":{"@context":"https://w3id.org/did/v1","id":"ADGeeTatN2KSqRaSXDb3jv","publicKey":[{"id":"ADGeeTatN2KSqRaSXDb3jv#1","type":"Ed25519VerificationKey2018","controller":"ADGeeTatN2KSqRaSXDb3jv","publicKeyBase58":"62CKgBmargJ8mpCw5HWvcn2u3KAmvWNQ1ToyUzY5EkiV"}],"authentication":[{"type":"Ed25519SignatureAuthentication2018","publicKey":"ADGeeTatN2KSqRaSXDb3jv#1"}],"service":[{"id":"ADGeeTatN2KSqRaSXDb3jv;indy","type":"IndyAgent","priority":0,"serviceEndpoint":"http://35.188.200.216:4001/endpoint","recipientKeys":["62CKgBmargJ8mpCw5HWvcn2u3KAmvWNQ1ToyUzY5EkiV"],"routingKeys":["ApWggHJ9wSVCjLbjvjgRthjEC8jS1sUKJbBXxjVpPRxS"]}]},"verkey":"62CKgBmargJ8mpCw5HWvcn2u3KAmvWNQ1ToyUzY5EkiV","theirLabel":"ABC FIRM","state":"COMPLETE","theirDid":"6rLDWC9VPNz4f2TNePno9t","theirDidDoc":{"@context":"https://w3id.org/did/v1","id":"did:sov:6rLDWC9VPNz4f2TNePno9t","publicKey":[{"id":"did:sov:6rLDWC9VPNz4f2TNePno9t#1","type":"Ed25519VerificationKey2018","controller":"did:sov:6rLDWC9VPNz4f2TNePno9t","publicKeyBase58":"4Bww2NMiuWy2NBHyJUZXxU16SXydchHJfBwWohuzqTWd"}],"authentication":[{"type":"Ed25519SignatureAuthentication2018","publicKey":"did:sov:6rLDWC9VPNz4f2TNePno9t#1"}],"service":[{"id":"did:sov:6rLDWC9VPNz4f2TNePno9t;indy","type":"IndyAgent","priority":0,"recipientKeys":["4Bww2NMiuWy2NBHyJUZXxU16SXydchHJfBwWohuzqTWd"],"serviceEndpoint":"http://34.71.218.3:8004"}]}}"
  3. connectionId: "62CKgBmargJ8mpCw5HWvcn2u3KAmvWNQ1ToyUzY5EkiV"
  4. }, ...]

deleteConnection(connectionId) -> Boolean


Deletes a connection from database.

connectionId: Unique connection Id

  1. 230c830d-4bb2-4564-8671-586b45ab8935

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const wallet = await ArnimaSDK.deleteConnection(id)

Returns:

Success: true

Error: false

getWallet() -> JSON


Get wallet information

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const sdkDB = await ArnimaSDK.getWallet()

Returns:

Success:

  1. {
  2. walletConfig: 'string',
  3. walletCredentials: 'string',
  4. label: 'string',
  5. did: 'string',
  6. verKey: 'string',
  7. serviceEndpoint: 'string',
  8. routingKey: 'string',
  9. masterSecret: 'string',
  10. }

openWallet() -> boolean


To open wallet

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const sdkDB = await ArnimaSDK.openWallet()

Returns:

Success: true

Error: false

importWallet(config, credentials, filePath, key) -> JSON


To import a wallet.

config: WalletConfig
credentials: WalletCredentials
filePath: string
key: string

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const response = await Arnima.importWallet(
  3. walletName,
  4. walletPassword,
  5. walletFilePath,
  6. hashedPassphrase
  7. )

Returns:

Success:

  1. {
  2. mediatorRecord: {
  3. walletConfig: '{"id":string}',
  4. label: string,
  5. serviceEndpoint: string,
  6. routingKey: string,
  7. publicDid: string,
  8. verKey: string,
  9. masterSecretId: string
  10. }
  11. }

sendCredentialProposal(connectionId,credentialProposal, schemaId, credDefId, issuerDid, comment) -> Boolean


To send credential proposal.

connectionId: object
credentialProposal: string
schemaId: string
credDefId: string
issuerDid: string
comment: string

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const response = await ArnimaSDK.sendCredentialProposal(
  3. connectionId,
  4. credentialProposal,
  5. schemaId,
  6. credDefId,
  7. issuerDid,
  8. comment
  9. )

Returns:

Success: true

Error: false

acceptCredentialOffer(messageId, inboundMessage) -> Boolean


To credential offer.

messageId: string
inboundMessage: InboundMessage

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const response = await ArnimaSDK.acceptCredentialOffer(
  3. messageId,
  4. inboundMessage
  5. )

Returns:

Success: true

getAllActionMessagesByMessageId(messageId) -> JSON


To get all action messages by using messageId.

messageId: string

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const response = await Arnima.getAllActionMessagesByMessageId(messageId)

Returns:

Success:

  1. {
  2. message: {
  3. '@type': string,
  4. '@id': string,
  5. '~thread': {},
  6. comment: string,
  7. credential_preview: {
  8. '@type': string,
  9. attributes: [{
  10. name: string,
  11. value: string
  12. }]
  13. },
  14. 'offers~attach': [{
  15. '@id': string,
  16. 'mime-type': string,
  17. data: {
  18. base64: string
  19. }
  20. }]
  21. },
  22. recipient_verkey: string,
  23. sender_verkey: string
  24. }

getAllCredential(filter) -> Array


To get all credential.

filter: Object

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const response = await Arnima.getAllCredential(filter)

Returns:

Success:

  1. [{
  2. referent: string,
  3. attrs: {
  4. name: string
  5. },
  6. schema_id: string,
  7. cred_def_id: string,
  8. rev_reg_id: string,
  9. cred_rev_id: string
  10. }]

sendBasicMessage(message, connectionId) -> Boolean


Send a basic message.

message: string
connectionId: string

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const sdkDB = await ArnimaSDK.sendBasicMessage(message, connectionId)

Returns:

Success: true

Error: false

createPool(poolName, poolConfig, defaultPool) -> String


To create Pool.

poolName: string
poolConfig: string
defaultPool: boolean

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const response = await ArnimaSDK.createPool(poolName, poolConfig, defaultPool)

Returns:

Success: string

getAllPool() -> Array


To get all pools.

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const response = await Arnima.getAllPool()

Returns:

Success:

  1. [{
  2. type: string,
  3. id: string,
  4. value: '{
  5. "poolName": string,
  6. "poolConfig": "{"
  7. reqSignature ": {},
  8. "txn": {
  9. "data": {
  10. "data": {
  11. "alias": string,
  12. "blskey": string,
  13. "blskey_pop": string,
  14. "client_ip": string,
  15. "client_port": 9702,
  16. "node_ip": string,
  17. "node_port": 9701,
  18. "services": [string]
  19. },
  20. "dest": string
  21. },
  22. "metadata": {
  23. "from": string
  24. },
  25. "type": string
  26. },
  27. "txnMetadata": {
  28. "seqNo": 1,
  29. "txnId": string
  30. },
  31. "ver": string
  32. }
  33. "}',
  34. tags: {
  35. poolName: string,
  36. isSelected: string
  37. }
  38. }]

selectDefaultPool(poolName) -> Boolean


Send a basic message.

poolName: string

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const sdkDB = await ArnimaSDK.selectDefaultPool(poolName)

Returns:

Success: true

IssueCredentialByConnectionId(connectionId) -> Array


To get issue credential by using connection Id.

connectionId: string

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const response = await Arnima.getIssueCredentialByConnectionId(connectionId)

Returns:

Success:

  1. [{
  2. type: string,
  3. id: string,
  4. value: '{
  5. "connectionId": string,
  6. "theirLabel": string,
  7. "schemaId": string,
  8. "credentialDefinitionId": string,
  9. "state": string,
  10. "createdAt": string,
  11. "updatedAt": string
  12. }',
  13. tags: {
  14. issueCredentialId: string,
  15. connectionId: string
  16. }
  17. }]

exportWallet(filePath, key) -> Boolean


To export a wallet.

filePath: string
key: string

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const response = await ArnimaSDK.exportWallet(filePath, key)

Returns:

Success: true

Error: false

sendProof(messageId,inboundMessage, revealAttributes) -> Boolean


To send a proof.

messageId: string
inboundMessage: InboundMessage
revealAttributes: boolean

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const response = await ArnimaSDK.sendProof(
  3. messageId,
  4. inboundMessage,
  5. revealAttributes
  6. )

Returns:

Success: true

Error: false

verifyProof(messageId, inboundMessage) -> Boolean


To send a proof.

messageId: string
inboundMessage: InboundMessage

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const response = await ArnimaSDK.verifyProof(messageId, inboundMessage)

Returns:

Success: true

Error: false

getPresentationByConnectionId(connectionId) -> Array


To get connection presented by using connection Id.

connectionId: string

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const response = await Arnima.getPresentationByConnectionId(connectionId)

Returns:

Success:

  1. [{
  2. type: string,
  3. id: string,
  4. value: '{
  5. "connectionId": string,
  6. "theirLabel": string,
  7. "threadId": string,
  8. "presentationRequest": {
  9. "name": string,
  10. "requested_predicates": {},
  11. "requested_attributes": {
  12. "additionalProp1": {
  13. "name": string,
  14. "non_revoked": {
  15. "to": long
  16. },
  17. "restrictions": [{
  18. "cred_def_id": string
  19. }]
  20. }
  21. },
  22. "version": string,
  23. "nonce": string
  24. },
  25. "state": string,
  26. "updatedAt": string,
  27. "createdAt": string
  28. }',
  29. tags: {
  30. connectionId: string,
  31. messageId: string,
  32. presentationId: string
  33. }
  34. }]

getConnectionRecord(query) -> Array


To get connection record.

query: Object

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const response = await Arnima.getConnectionRecord(query)

Returns:

Success:

  1. [{
  2. type: string,
  3. id: string,
  4. value: '{
  5. "didDoc": {
  6. "@context": string,
  7. "id": string,
  8. "publicKey": [{
  9. "id": string,
  10. "type": string,
  11. "controller": string,
  12. "publicKeyBase58": string
  13. }],
  14. "authentication": [{
  15. "type": string,
  16. "publicKey": string
  17. }],
  18. "service": [{
  19. "id": string,
  20. "type": string,
  21. "priority": int,
  22. "serviceEndpoint": string,
  23. "recipientKeys": [string],
  24. "routingKeys": [string]
  25. }]
  26. },
  27. "verkey": string,
  28. "alias": {},
  29. "state": string,
  30. "createdAt": string,
  31. "updatedAt": string
  32. }',
  33. tags: {
  34. connectionId: string
  35. }
  36. }]

getPresentationRecord(query) -> Array


To get connection record.

query: Object

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const response = await Arnima.getPresentationRecord(query)

Returns:

Success:

  1. [{
  2. "type": string,
  3. "id": string,
  4. "value": '{
  5. "connectionId": string,
  6. "theirLabel": string,
  7. "threadId": string ",
  8. "presentationRequest": {
  9. "name": string,
  10. "requested_predicates": {},
  11. "requested_attributes": {
  12. "additionalProp1": {
  13. "name": string,
  14. "non_revoked": {
  15. "to": long
  16. },
  17. "restrictions": [{
  18. "cred_def_id": string
  19. }]
  20. }
  21. },
  22. "version": string,
  23. "nonce": string
  24. },
  25. "presentation": {
  26. "proof": {
  27. "proofs": [{
  28. "primary_proof": {
  29. "eq_proof": {
  30. "revealed_attrs": {
  31. "name": string
  32. },
  33. "a_prime": string,
  34. "v": string,
  35. "m": {
  36. "master_secret": string
  37. },
  38. "m2": string
  39. },
  40. "ge_proofs": []
  41. },
  42. "non_revoc_proof": string
  43. }],
  44. "aggregated_proof": {
  45. "c_hash": string,
  46. "c_list": [
  47. [int, int, int....]
  48. ]
  49. }
  50. },
  51. "requested_proof": {
  52. "revealed_attrs": {
  53. "additionalProp1": {
  54. sub_proof_index ":int,
  55. "raw": string,
  56. "encoded": string
  57. }
  58. }
  59. }
  60. }
  61. }
  62. }]

sendPresentProofRequest(connectionId, proofRequest, comment) -> Boolean


To send a present proof.

connectionId: string
proofRequest: object
comment: string

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const response = await ArnimaSDK.sendPresentProofRequest(
  3. connectionId,
  4. proofRequest,
  5. comment
  6. )

Returns:

Success: true

Error: false

sendProposePresentation(connectionId, presentationProposal) -> Boolean


To send a present proof.

connectionId: string
presentationProposal: object

Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. const response = await ArnimaSDK.sendProposePresentation(
  3. connectionId,
  4. presentationProposal
  5. )

Returns:

Success: true

Error: false

Socket Methods

We are using socket for communication between app and mediator agent.

socketInit() -> void


Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. indy.socketInit()

socketEmit() -> void


Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. indy.socketEmit()

socketListener() -> void


Example:

  1. import ArnimaSDK from 'react-native-arnima-sdk'
  2. indy.socketListener()

Receive an event on your mobile app

You can receive event in mobile application when connection is established. Receive the credentials and proof request.

  1. import { EventRegister } from 'react-native-event-listeners';
  2. componentDidMount() {
  3. this.listener = EventRegister.addEventListener('SDKEvent', (data) => {
  4. // write your code here...
  5. });
  6. }
  7. componentWillUnmount() {
  8. EventRegister.removeEventListener(this.listener);
  9. }