Skip to content
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

feat: added messageType on the credo core #87

Merged
merged 1 commit into from
Apr 10, 2024
Merged
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
97 changes: 67 additions & 30 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,43 +1,80 @@
FROM ubuntu:20.04
# FROM ubuntu:20.04

ENV DEBIAN_FRONTEND noninteractive
# ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update -y && apt-get install -y \
software-properties-common \
apt-transport-https \
curl \
# Only needed to build indy-sdk
build-essential
# RUN apt-get update -y && apt-get install -y \
# software-properties-common \
# apt-transport-https \
# curl \
# # Only needed to build indy-sdk
# build-essential

# nodejs
# RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
# RUN /bin/bash -c "source /root/.nvm/nvm.sh && nvm install 18 && nvm use 18"
# # nodejs
# # RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
# # RUN /bin/bash -c "source /root/.nvm/nvm.sh && nvm install 18 && nvm use 18"

RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
# RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -

# yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
# # yarn
# RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
# echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list

# install depdencies
RUN apt-get update -y && apt-get install -y --allow-unauthenticated \
nodejs
# # install depdencies
# RUN apt-get update -y && apt-get install -y --allow-unauthenticated \
# nodejs

# Install yarn seperately due to `no-install-recommends` to skip nodejs install
RUN apt-get install -y --no-install-recommends yarn
# # Install yarn seperately due to `no-install-recommends` to skip nodejs install
# RUN apt-get install -y --no-install-recommends yarn

# RUN yarn global add patch-package
# # AFJ specifc setup
# WORKDIR /www

# COPY bin ./bin
# COPY package.json ./package.json
# COPY patches ./patches

# RUN yarn install --production

# COPY build ./build
# # COPY libindy_vdr.so /usr/lib/
# # COPY libindy_vdr.so /usr/local/lib/

# ENTRYPOINT [ "./bin/afj-rest.js", "start" ]


# Stage 1: Builder stage
FROM node:18.19.0 AS builder

WORKDIR /app

# Copy package.json and yarn.lock files
COPY package.json yarn.lock ./

# Install dependencies
RUN yarn install --frozen-lockfile

# Copy the rest of the application code
COPY . .

RUN yarn global add patch-package
# AFJ specifc setup
WORKDIR /www

COPY bin ./bin
COPY package.json ./package.json
COPY patches ./patches
# Build the application
RUN yarn build

# Stage 2: Production stage
FROM node:18.19.0-slim

WORKDIR /app

# Copy built files and node_modules from the builder stage
COPY --from=builder /app/build ./build
COPY --from=builder /app/bin ./bin
COPY --from=builder /app/package.json ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/patches ./patches

RUN yarn install --production
# Set entry point
ENTRYPOINT ["node", "./bin/afj-rest.js", "start"]

COPY build ./build
# COPY libindy_vdr.so /usr/lib/
# COPY libindy_vdr.so /usr/local/lib/

ENTRYPOINT [ "./bin/afj-rest.js", "start" ]
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"cors": "^2.8.5",
"express": "^4.18.1",
"express-rate-limit": "^7.1.5",
"joi": "^17.12.3",
"jsonwebtoken": "^9.0.2",
"node-fetch": "^2.6.7",
"patch-package": "^8.0.0",
Expand Down
50 changes: 50 additions & 0 deletions patches/@credo-ts+core+0.5.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
diff --git a/node_modules/@credo-ts/core/build/agent/EnvelopeService.js b/node_modules/@credo-ts/core/build/agent/EnvelopeService.js
index 12261a9..0238d59 100644
--- a/node_modules/@credo-ts/core/build/agent/EnvelopeService.js
+++ b/node_modules/@credo-ts/core/build/agent/EnvelopeService.js
@@ -32,12 +32,14 @@ let EnvelopeService = class EnvelopeService {
let encryptedMessage = await agentContext.wallet.pack(message, recipientKeysBase58, senderKeyBase58 !== null && senderKeyBase58 !== void 0 ? senderKeyBase58 : undefined);
// If the message has routing keys (mediator) pack for each mediator
for (const routingKeyBase58 of routingKeysBase58) {
+ console.log(`message['@type']`, JSON.stringify(message['@type']))
const forwardMessage = new messages_1.ForwardMessage({
// Forward to first recipient key
to: recipientKeysBase58[0],
message: encryptedMessage,
});
recipientKeysBase58 = [routingKeyBase58];
+ forwardMessage["messageType"] = message['@type'];
this.logger.debug('Forward message created', forwardMessage);
const forwardJson = forwardMessage.toJSON({
useDidSovPrefixWhereAllowed: agentContext.config.useDidSovPrefixWhereAllowed,
diff --git a/node_modules/@credo-ts/core/build/modules/routing/messages/ForwardMessage.d.ts b/node_modules/@credo-ts/core/build/modules/routing/messages/ForwardMessage.d.ts
index 4f8577b..396f78a 100644
--- a/node_modules/@credo-ts/core/build/modules/routing/messages/ForwardMessage.d.ts
+++ b/node_modules/@credo-ts/core/build/modules/routing/messages/ForwardMessage.d.ts
@@ -3,6 +3,7 @@ import { EncryptedMessage } from '../../../types';
export interface ForwardMessageOptions {
id?: string;
to: string;
+ messageType: string;
message: EncryptedMessage;
}
/**
@@ -19,5 +20,6 @@ export declare class ForwardMessage extends AgentMessage {
readonly type: string;
static readonly type: import("../../../utils/messageType").ParsedMessageType;
to: string;
+ messageType: string;
message: EncryptedMessage;
}
diff --git a/node_modules/@credo-ts/core/build/types.d.ts b/node_modules/@credo-ts/core/build/types.d.ts
index e0384d9..0a669fb 100644
--- a/node_modules/@credo-ts/core/build/types.d.ts
+++ b/node_modules/@credo-ts/core/build/types.d.ts
@@ -81,6 +81,7 @@ export interface PlaintextMessage {
thid?: string;
pthid?: string;
};
+ messageType: string;
[key: string]: unknown;
}
export interface OutboundPackage {
4 changes: 2 additions & 2 deletions src/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export async function expressAuthentication(
) {
const logger = new TsLogger(LogLevel.info)

logger.info(`secMethod::: ${JSON.stringify(secMethod)}`)
logger.info(`scopes::: ${JSON.stringify(scopes)}`)
logger.info(`secMethod::: ${secMethod}`)
logger.info(`scopes::: ${scopes}`)

const apiKeyHeader = request.headers['authorization']

Expand Down