Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • svdh/ocm-engine
1 result
Show changes
Commits on Source (2)
......@@ -3,6 +3,13 @@
All notable changes to this project will be documented in this file. See
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.10.0](https://code.vereign.com/gaiax/ocm/ocm-engine/compare/v1.9.0...v1.10.0) (2023-09-25)
### Features
* implement url shortener for invitation urls ([5ee43e8](https://code.vereign.com/gaiax/ocm/ocm-engine/commit/5ee43e86320b46e53e5e6cb9c658500ec1f14e51))
## [1.9.0](https://code.vereign.com/gaiax/ocm/ocm-engine/compare/v1.8.0...v1.9.0) (2023-09-19)
......
# OCM ENGINE - AGENT
# OCM ENGINE - AGENT
Agent service is a wrapper around @ocm-engine/askar library.
......
# OCM ENGINE - Gateway
# OCM ENGINE - Gateway
External service.
......
......@@ -134,9 +134,9 @@ export class ConnectionController {
},
})
@ApiOperation({
summary: "Accept invitation for connection",
summary: "Accept invitation long and short urls for connection",
description:
"Method will accept the invitation and will return connection thought the websocket. The id of the response will be matched when you receive event from the websocket",
"Method will accept long and short invitation urls and will return connection thought the websocket. The id of the response will be matched when you receive event from the websocket",
tags: ["Connections"],
})
async acceptInvitation(
......
......@@ -22,6 +22,7 @@ import {
V2ProofProtocol,
WalletError,
WalletKeyExistsError,
OutOfBandState,
} from "@aries-framework/core";
import {
AnonCredsCredentialFormatService,
......@@ -62,6 +63,7 @@ export type SubjectMessage = {
message: EncryptedMessage;
replySubject?: Subject<SubjectMessage>;
};
import { Request, Response, Express } from "express";
export const importDidsToWallet = async (
agent: Agent,
......@@ -385,3 +387,34 @@ export const waitForProofExchangeRecordSubject = (
),
);
};
export const attachShortUrlHandler = (server: Express, agent: Agent): void => {
server.get(
"/invitations/:invitationId",
async (req: Request, res: Response) => {
try {
const { invitationId } = req.params;
const outOfBandRecord = await agent.oob.findByCreatedInvitationId(
invitationId,
);
if (
!outOfBandRecord ||
outOfBandRecord.state !== OutOfBandState.AwaitResponse
) {
return res.status(404).send("Not found");
}
const invitationJson = outOfBandRecord.outOfBandInvitation.toJSON();
return res
.header("Content-Type", "application/json")
.send(invitationJson);
} catch (error) {
console.error(error);
return res.status(500).send("Internal Server Error");
}
},
);
};
......@@ -42,6 +42,7 @@ export class AgentService {
domain: this.askar.agentConfig.agentPeerAddress,
});
i.shortInvitationUrl = `${this.askar.agentConfig.agentPeerAddress}/invitations/${outOfBoundRecord.outOfBandInvitation.id}`;
return i;
};
......
......@@ -24,11 +24,13 @@ import {
generateKey,
getAskarAnonCredsIndyModules,
importDidsToWallet,
attachShortUrlHandler,
setupEventReplaySubjects,
setupSubjectTransports,
} from "../agent.utils";
import { IConfAgent } from "@ocm-engine/config";
import { ReplaySubject } from "rxjs";
import express from "express";
@Injectable()
export class AskarService implements OnModuleInit, OnModuleDestroy {
......@@ -36,13 +38,14 @@ export class AskarService implements OnModuleInit, OnModuleDestroy {
public agentR: ReplaySubject<BaseEvent>;
public agentConfig: IConfAgent;
private readonly logger: Logger = new Logger(AskarService.name);
private readonly server = express();
constructor(
private readonly configService: ConfigService,
private readonly ledgersSerivce: LedgersService,
) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.agentConfig = configService.get<IConfAgent>("agent")!;
this.agentConfig = this.configService.get<IConfAgent>("agent")!;
const config = {
label: this.agentConfig.agentName,
......@@ -72,8 +75,14 @@ export class AskarService implements OnModuleInit, OnModuleDestroy {
),
});
//handler for short url invitations, look at agent service createInvitation
attachShortUrlHandler(this.server, this.agent);
this.agent.registerInboundTransport(
new HttpInboundTransport({ port: this.agentConfig.agentPeerPort }),
new HttpInboundTransport({
app: this.server,
port: this.agentConfig.agentPeerPort,
}),
);
this.agent.registerOutboundTransport(new WsOutboundTransport());
......
export class CreateInvitationResponseDto {
/**
* A list of user's roles
* Example of long invitation url
* @example "http://0.0.0.0:8001?oob=eyJAdHlwZSI6Imh0dHBzOi8vZGlkY29tbS5vcmcvb3V0LW9mLWJhbmQvMS4xL2ludml0YXRpb24iLCJAaWQiOiIzYWExNGIzNC04YTk5LTQxY2UtYTY3NC1jODUxYmVhMTIxMWEiLCJsYWJlbCI6IkRFeGNWYXNkX0FHRU5UXzQ1IiwiYWNjZXB0IjpbImRpZGNvbW0vYWlwMSIsImRpZGNvbW0vYWlwMjtlbnY9cmZjMTkiXSwiaGFuZHNoYWtlX3Byb3RvY29scyI6WyJodHRwczovL2RpZGNvbW0ub3JnL2RpZGV4Y2hhbmdlLzEuMCIsImh0dHBzOi8vZGlkY29tbS5vcmcvY29ubmVjdGlvbnMvMS4wIl0sInNlcnZpY2VzIjpbeyJpZCI6IiNpbmxpbmUtMCIsInNlcnZpY2VFbmRwb2ludCI6Imh0dHA6Ly8wLjAuMC4wOjgwMDEiLCJ0eXBlIjoiZGlkLWNvbW11bmljYXRpb24iLCJyZWNpcGllbnRLZXlzIjpbImRpZDprZXk6ejZNa3VFcHllc1pNa3k0a1BpQzhEOEplZERlcm55YTFuaTREMUF3ZmdnWWt6YmR4Il0sInJvdXRpbmdLZXlzIjpbXX1dfQ"
*/
public invitationUrl: string;
/**
*
* @example "http://0.0.0.0:8001/invitations/85a7c179-122b-4d2d-9a86-d92ad31cef2b"
*/
public shortInvitationUrl: string;
}