Skip to content

fix: update credo api routes #1311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 72 additions & 57 deletions apps/cloud-wallet/src/cloud-wallet.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
IConnectionDetailsById,
ITenantDetail,
ICredentialDetails,
ICreateConnection,
ICreateConnection,
IConnectionInvitationResponse,
GetAllCloudWalletConnections,
IBasicMessage,
Expand Down Expand Up @@ -99,24 +99,25 @@ export class CloudWalletService {

/**
* Create connection
* @param createConnection
* @param createConnection
* @returns connection details
*/
async createConnection(createConnection: ICreateConnection): Promise<IConnectionInvitationResponse> {
try {

const { userId, ...connectionPayload } = createConnection;
const [baseWalletDetails, getTenant, decryptedApiKey] = await this._commonCloudWalletInfo(userId);
const [baseWalletDetails, getTenant, decryptedApiKey] = await this._commonCloudWalletInfo(userId);

delete connectionPayload.email;

delete connectionPayload.email;
const { tenantId } = getTenant;
const { agentEndpoint } = baseWalletDetails;

const { tenantId } = getTenant;
const { agentEndpoint } = baseWalletDetails;
const url = `${agentEndpoint}${CommonConstants.CLOUD_WALLET_CREATE_CONNECTION_INVITATION}/${tenantId}`;

const url = `${agentEndpoint}${CommonConstants.CLOUD_WALLET_CREATE_CONNECTION_INVITATION}/${tenantId}`;

const createConnectionDetails = await this.commonService.httpPost(url, connectionPayload, { headers: { authorization: decryptedApiKey } });
return createConnectionDetails;
const createConnectionDetails = await this.commonService.httpPost(url, connectionPayload, {
headers: { authorization: decryptedApiKey }
});
return createConnectionDetails;
} catch (error) {
await this.commonService.handleError(error);
throw error;
Expand Down Expand Up @@ -223,7 +224,7 @@ export class CloudWalletService {
}

const getTenant = await this.cloudWalletRepository.getCloudSubWallet(userId);

if (!getTenant || !getTenant?.tenantId) {
throw new NotFoundException(ResponseMessages.cloudWallet.error.walletRecordNotFound);
}
Expand Down Expand Up @@ -253,7 +254,7 @@ export class CloudWalletService {
if (checkUserExist) {
throw new ConflictException(ResponseMessages.cloudWallet.error.userExist);
}

const baseWalletDetails = await this.cloudWalletRepository.getCloudWalletDetails(CloudWalletType.BASE_WALLET);

const { agentEndpoint, agentApiKey } = baseWalletDetails;
Expand Down Expand Up @@ -326,7 +327,7 @@ export class CloudWalletService {

const { tenantId } = getTenant;
const { agentEndpoint } = baseWalletDetails;
const url = `${agentEndpoint}${CommonConstants.RECEIVE_INVITATION_BY_URL}${tenantId}`;
const url = `${agentEndpoint}${CommonConstants.CLOUD_WALLET_RECEIVE_INVITATION_BY_URL}${tenantId}`;

const checkCloudWalletAgentHealth = await this.commonService.checkAgentHealth(agentEndpoint, decryptedApiKey);

Expand Down Expand Up @@ -371,7 +372,7 @@ export class CloudWalletService {
const { tenantId } = getTenant;
const { agentEndpoint } = baseWalletDetails;

const url = `${agentEndpoint}${CommonConstants.ACCEPT_OFFER}${tenantId}`;
const url = `${agentEndpoint}${CommonConstants.CLOUD_WALLET_ACCEPT_OFFER}${tenantId}`;

const checkCloudWalletAgentHealth = await this.commonService.checkAgentHealth(agentEndpoint, decryptedApiKey);

Expand Down Expand Up @@ -479,43 +480,47 @@ export class CloudWalletService {

const url = `${agentEndpoint}${CommonConstants.CLOUD_WALLET_CONNECTION_BY_ID}${connectionId}/${tenantId}`;

const connectionDetailResponse = await this.commonService.httpGet(url, { headers: { authorization: decryptedApiKey } });
const connectionDetailResponse = await this.commonService.httpGet(url, {
headers: { authorization: decryptedApiKey }
});
return connectionDetailResponse;
} catch (error) {
await this.commonService.handleError(error);
throw error;
}
}

/**
/**
* Get connection list by tenant id
* @param connectionDetails
* @returns Connection Details
*/
async getAllconnectionById(connectionDetails: GetAllCloudWalletConnections): Promise<Response> {
try {
const { userId, alias, myDid, outOfBandId, theirDid, theirLabel } = connectionDetails;
const [baseWalletDetails, getTenant, decryptedApiKey] = await this._commonCloudWalletInfo(userId);
const urlOptions = {
alias,
myDid,
outOfBandId,
theirDid,
theirLabel
};
const optionalParameter = await this.commonService.createDynamicUrl(urlOptions);
const { tenantId } = getTenant;
const { agentEndpoint } = baseWalletDetails;

const url = `${agentEndpoint}${CommonConstants.CLOUD_WALLET_CONNECTION_BY_ID}${tenantId}${optionalParameter}`;

const connectionDetailList = await this.commonService.httpGet(url, { headers: { authorization: decryptedApiKey } });
return connectionDetailList;
} catch (error) {
await this.commonService.handleError(error);
throw error;
}
async getAllconnectionById(connectionDetails: GetAllCloudWalletConnections): Promise<Response> {
try {
const { userId, alias, myDid, outOfBandId, theirDid, theirLabel } = connectionDetails;
const [baseWalletDetails, getTenant, decryptedApiKey] = await this._commonCloudWalletInfo(userId);
const urlOptions = {
alias,
myDid,
outOfBandId,
theirDid,
theirLabel
};
const optionalParameter = await this.commonService.createDynamicUrl(urlOptions);
const { tenantId } = getTenant;
const { agentEndpoint } = baseWalletDetails;

const url = `${agentEndpoint}${CommonConstants.CLOUD_WALLET_CONNECTION_BY_ID}${tenantId}${optionalParameter}`;

const connectionDetailList = await this.commonService.httpGet(url, {
headers: { authorization: decryptedApiKey }
});
return connectionDetailList;
} catch (error) {
await this.commonService.handleError(error);
throw error;
}
}

/**
* Get credential list by tenant id
Expand All @@ -531,14 +536,16 @@ export class CloudWalletService {
state,
threadId
};
const {tenantId} = getTenant;
const optionalParameter = await this.commonService.createDynamicUrl(urlOptions);
const { tenantId } = getTenant;
const optionalParameter = await this.commonService.createDynamicUrl(urlOptions);

const { agentEndpoint } = baseWalletDetails;

const url = `${agentEndpoint}${CommonConstants.CLOUD_WALLET_CREDENTIAL}/${tenantId}${optionalParameter}`;

const credentialDetailResponse = await this.commonService.httpGet(url, { headers: { authorization: decryptedApiKey } });
const credentialDetailResponse = await this.commonService.httpGet(url, {
headers: { authorization: decryptedApiKey }
});
return credentialDetailResponse;
} catch (error) {
await this.commonService.handleError(error);
Expand All @@ -555,13 +562,15 @@ export class CloudWalletService {
try {
const { userId, credentialRecordId } = credentialDetails;
const [baseWalletDetails, getTenant, decryptedApiKey] = await this._commonCloudWalletInfo(userId);
const {tenantId} = getTenant;

const { tenantId } = getTenant;
const { agentEndpoint } = baseWalletDetails;

const url = `${agentEndpoint}${CommonConstants.CLOUD_WALLET_CREDENTIAL}/${credentialRecordId}${tenantId}`;

const credentialDetailResponse = await this.commonService.httpGet(url, { headers: { authorization: decryptedApiKey } });
const credentialDetailResponse = await this.commonService.httpGet(url, {
headers: { authorization: decryptedApiKey }
});
return credentialDetailResponse;
} catch (error) {
await this.commonService.handleError(error);
Expand All @@ -578,37 +587,43 @@ export class CloudWalletService {
try {
const { userId, connectionId } = connectionDetails;
const [baseWalletDetails, getTenant, decryptedApiKey] = await this._commonCloudWalletInfo(userId);
const {tenantId} = getTenant;

const { tenantId } = getTenant;
const { agentEndpoint } = baseWalletDetails;

const url = `${agentEndpoint}${CommonConstants.CLOUD_WALLET_BASIC_MESSAGE}${connectionId}/${tenantId}`;

const basicMessageResponse = await this.commonService.httpGet(url, { headers: { authorization: decryptedApiKey } });
const basicMessageResponse = await this.commonService.httpGet(url, {
headers: { authorization: decryptedApiKey }
});
return basicMessageResponse;
} catch (error) {
await this.commonService.handleError(error);
throw error;
}
}

/**
/**
* Send basic-message by connection id
* @param messageDetails
* @returns Basic message Details
*/
async sendBasicMessage(messageDetails: IBasicMessageDetails): Promise<Response> {
async sendBasicMessage(messageDetails: IBasicMessageDetails): Promise<Response> {
try {
const { userId, connectionId, content } = messageDetails;
const [baseWalletDetails, getTenant, decryptedApiKey] = await this._commonCloudWalletInfo(userId);
const {tenantId} = getTenant;

const { tenantId } = getTenant;
const { agentEndpoint } = baseWalletDetails;

const url = `${agentEndpoint}${CommonConstants.CLOUD_WALLET_BASIC_MESSAGE}${connectionId}/${tenantId}`;
const basicMessageResponse = await this.commonService.httpPost(url, {content}, {
headers: { authorization: decryptedApiKey }
});
const basicMessageResponse = await this.commonService.httpPost(
url,
{ content },
{
headers: { authorization: decryptedApiKey }
}
);
return basicMessageResponse;
} catch (error) {
await this.commonService.handleError(error);
Expand Down
4 changes: 2 additions & 2 deletions apps/issuance/src/issuance.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ export class IssuanceService {
case 'get-issue-credentials': {
url =
orgAgentType === OrgAgentType.DEDICATED
? `${agentEndPoint}${CommonConstants.URL_ISSUE_GET_CREDS_AFJ}`
? `${agentEndPoint}${CommonConstants.URL_ISSUE_GET_CREDS}`
: orgAgentType === OrgAgentType.SHARED
? `${agentEndPoint}${CommonConstants.URL_SHAGENT_GET_CREDENTIALS}`.replace('#', tenantId)
: null;
Expand All @@ -1179,7 +1179,7 @@ export class IssuanceService {
case 'get-issue-credential-by-credential-id': {
url =
orgAgentType === OrgAgentType.DEDICATED
? `${agentEndPoint}${CommonConstants.URL_ISSUE_GET_CREDS_AFJ_BY_CRED_REC_ID}/${credentialRecordId}`
? `${agentEndPoint}${CommonConstants.URL_ISSUE_GET_CREDS}/${credentialRecordId}`
: orgAgentType === OrgAgentType.SHARED
? `${agentEndPoint}${CommonConstants.URL_SHAGENT_GET_CREDENTIALS_BY_CREDENTIAL_ID}`
.replace('#', credentialRecordId)
Expand Down
Loading