Skip to content

Commit

Permalink
Added enum as a type on connection, credential and proof methods
Browse files Browse the repository at this point in the history
Signed-off-by: KulkarniShashank <[email protected]>
  • Loading branch information
KulkarniShashank committed Apr 4, 2024
1 parent 0cee2a7 commit b793ae6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
32 changes: 16 additions & 16 deletions src/cliAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import { randomBytes } from 'crypto'
import { readFile } from 'fs/promises'
import jwt from 'jsonwebtoken'

import { IndicioTransactionAuthorAgreement, Network, NetworkName } from './enums/enum'
import { IndicioAcceptanceMechanism, IndicioTransactionAuthorAgreement, Network, NetworkName } from './enums/enum'
import { setupServer } from './server'
import { TsLogger } from './utils/logger'
import {
Expand Down Expand Up @@ -106,7 +106,7 @@ export interface AriesRestConfig {
rpcUrl?: string
fileServerUrl?: string
fileServerToken?: string
walletScheme?: string
walletScheme?: AskarMultiWalletDatabaseScheme
}

export async function readRestConfig(path: string) {
Expand All @@ -128,9 +128,9 @@ const getModules = (
rpcUrl: string,
schemaManagerContractAddress: string,
autoAcceptConnections: boolean,
autoAcceptCredentials: string,
autoAcceptProofs: string,
walletScheme: string
autoAcceptCredentials: AutoAcceptCredential,
autoAcceptProofs: AutoAcceptProof,
walletScheme: AskarMultiWalletDatabaseScheme
) => {
const legacyIndyCredentialFormat = new LegacyIndyCredentialFormatService()
const legacyIndyProofFormat = new LegacyIndyProofFormatService()
Expand Down Expand Up @@ -216,9 +216,9 @@ const getWithTenantModules = (
rpcUrl: string,
schemaManagerContractAddress: string,
autoAcceptConnections: boolean,
autoAcceptCredentials: string,
autoAcceptProofs: string,
walletScheme: string
autoAcceptCredentials: AutoAcceptCredential,
autoAcceptProofs: AutoAcceptProof,
walletScheme: AskarMultiWalletDatabaseScheme
) => {
const modules = getModules(
networkConfig,
Expand Down Expand Up @@ -321,12 +321,12 @@ export async function runRestAgent(restConfig: AriesRestConfig) {
) {
networkConfig.transactionAuthorAgreement = {
version: IndicioTransactionAuthorAgreement.Indicio_Testnet_Mainnet_Version,
acceptanceMechanism: IndicioTransactionAuthorAgreement.Indicio_Acceptance_Mechanism,
acceptanceMechanism: IndicioAcceptanceMechanism.Wallet_Agreement,
}
} else {
networkConfig.transactionAuthorAgreement = {
version: IndicioTransactionAuthorAgreement.Indicio_Demonet_Version,
acceptanceMechanism: IndicioTransactionAuthorAgreement.Indicio_Acceptance_Mechanism,
acceptanceMechanism: IndicioAcceptanceMechanism.Wallet_Agreement,
}
}
}
Expand Down Expand Up @@ -361,9 +361,9 @@ export async function runRestAgent(restConfig: AriesRestConfig) {
rpcUrl || '',
schemaManagerContractAddress || '',
autoAcceptConnections || true,
autoAcceptCredentials || '',
autoAcceptProofs || '',
walletScheme || ''
autoAcceptCredentials || AutoAcceptCredential.Always,
autoAcceptProofs || AutoAcceptProof.ContentApproved,
walletScheme || AskarMultiWalletDatabaseScheme.ProfilePerWallet
)
const modules = getModules(
networkConfig,
Expand All @@ -373,9 +373,9 @@ export async function runRestAgent(restConfig: AriesRestConfig) {
rpcUrl || '',
schemaManagerContractAddress || '',
autoAcceptConnections || true,
autoAcceptCredentials || '',
autoAcceptProofs || '',
walletScheme || ''
autoAcceptCredentials || AutoAcceptCredential.Always,
autoAcceptProofs || AutoAcceptProof.ContentApproved,
walletScheme || AskarMultiWalletDatabaseScheme.ProfilePerWallet
)
const agent = new Agent({
config: agentConfig,
Expand Down
6 changes: 5 additions & 1 deletion src/enums/enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export enum NetworkName {
export enum IndicioTransactionAuthorAgreement {
Indicio_Testnet_Mainnet_Version = '1.0',
Indicio_Demonet_Version = '1.3',
Indicio_Acceptance_Mechanism = 'wallet_agreement',
}

export enum Network {
Expand All @@ -32,3 +31,8 @@ export enum Network {
Indicio_Demonet = 'indicio:demonet',
Indicio_Mainnet = 'indicio:mainnet',
}

export enum IndicioAcceptanceMechanism {
Wallet_Agreement = 'wallet_agreement',
Accept = 'accept',
}
2 changes: 1 addition & 1 deletion src/utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export const SCHEMA_MANAGER_CONTRACT_ADDRESS = '0x552992e9f14b15bBd76488cD4c38c8
export const FILE_SERVER_TOKEN =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJBeWFuV29ya3MiLCJpZCI6ImNhZDI3ZjhjLTMyNWYtNDRmZC04ZmZkLWExNGNhZTY3NTMyMSJ9.I3IR7abjWbfStnxzn1BhxhV0OEzt1x3mULjDdUcgWHk'
export const RPC_URL = 'https://polygon-mumbai.infura.io/v3/0579d305568d404e996e49695e9272a3'

Check failure

Code scanning / SonarCloud

Infura API keys should not be disclosed High

Make sure this Infura API key gets revoked, changed, and removed from the code. See more on SonarCloud
export const SERVER_URL = 'https://schema.credebl.id/'
export const SERVER_URL = 'https://schema.credebl.id'

export const CONNECT_TIMEOUT = 10
export const MAX_CONNECTIONS = 1000
Expand Down

0 comments on commit b793ae6

Please sign in to comment.