Skip to content

Commit

Permalink
Update-did-txn
Browse files Browse the repository at this point in the history
  • Loading branch information
Pratap2018 committed Aug 1, 2024
1 parent 96be2d5 commit d24aae2
Show file tree
Hide file tree
Showing 15 changed files with 502 additions and 7 deletions.
11 changes: 11 additions & 0 deletions .deploy/SSL2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# secret.yaml
apiVersion: v1
kind: Secret

metadata:
name: entity-ssl-test
namespace: hypermine-development
type: kubernetes.io/tls
stringData:
tls.key: ""
tls.crt: ""
13 changes: 13 additions & 0 deletions .deploy/cert2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: entity-ssl
namespace: hypermine-development
spec:
dnsNames:
- api.entity-test.hypersign.id
- "*.api.entity-test.hypersign.id"
issuerRef:
kind: Issuer
name: letsencrypt-production
secretName: entity-ssl-test
137 changes: 137 additions & 0 deletions .deploy/deployment2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: entity-api-test
namespace: hypermine-development
spec:
replicas: 1

selector:
matchLabels:
app: entity-api-test
template:
metadata:
labels:
app: entity-api-test
spec:
containers:
- name: entity-api-test
image: __GOOGLE_ARTIFACT_URL__/__GOOGLE_PROJECT_ID__/__GOOGLE_ARTIFACT_REPO__/enity-api-test-service:__LATEST_RELEASE_TAG__
imagePullPolicy: Always
livenessProbe:
httpGet:
path: /api/v1/edv/state
port: 3001
initialDelaySeconds: 120
periodSeconds: 30
failureThreshold: 3

resources:
limits:
memory: "1Gi"
cpu: "500m"
ports:
- containerPort: __PORT__
env:
- name: PORT
value: "__PORT__"
- name: BASE_DB_PATH
value: __BASE_DB_PATH__
- name: DB_CONFIG
value: __DB_CONFIG__
- name: HID_NETWORK_RPC
value: __HID_NETWORK_RPC__
- name: HID_NETWORK_API
value: __HID_NETWORK_API__
- name: HID_NETWORK_NAMESPACE
value: __HID_NETWORK_NAMESPACE__
- name: EDV_BASE_URL
value: __EDV_BASE_URL__
- name: EDV_CONFIG_DIR
value: __EDV_CONFIG_DIR__
- name: EDV_DID_FILE_PATH
value: __EDV_DID_FILE_PATH__
- name: EDV_KEY_FILE_PATH
value: __EDV_KEY_FILE_PATH__
- name: MNEMONIC
value: __MNEMONIC__
- name: JWT_SECRET
value: __JWT_SECRET__
- name: GLOBAL_TXN_CONTROLLER_QUEUE
value: __GLOBAL_TXN_CONTROLLER_QUEUE__
- name: RABBIT_MQ_URI
value: __RABBIT_MQ_URI__
- name: WHITELISTED_CORS
value: "['https://entity.hypersign.id','https://api.entity.hypersign.id','https://wallet-prajna.hypersign.id']"
volumeMounts:
- name: mongo
mountPath: "/data"
volumes:
- name: mongo
secret:
secretName: mongo
---
apiVersion: v1
kind: Service
metadata:
name: entity-api-test-service
namespace: hypermine-development
annotations:
cloud.google.com/neg: '{"ingress": true}'

spec:
type: NodePort
selector:
app: entity-api-test
ports:
- port: __PORT__
targetPort: __PORT__
protocol: TCP
# ---
# apiVersion: apps/v1
# kind: Deployment
# metadata:
# name: nginx-entity
# namespace: hypermine-development
# spec:
# replicas: 1

# selector:
# matchLabels:
# app: nginx-entity
# template:
# metadata:
# labels:
# app: nginx-entity
# spec:
# containers:
# - name: nginx-entity
# image: __GOOGLE_ARTIFACT_URL__/__GOOGLE_PROJECT_ID__/__GOOGLE_ARTIFACT_REPO__/nginx-entity:latest
# imagePullPolicy: Always

# resources:
# limits:
# memory: "256m"
# cpu: "500m"
# ports:
# - containerPort: 8080
# ---
# apiVersion: v1
# kind: Service
# metadata:
# name: nginx-entity-service
# namespace: hypermine-development
# annotations:
# cloud.google.com/neg: '{"ingress": true}'

# spec:
# type: NodePort
# selector:
# app: nginx-entity
# ports:
# - port: 8080
# targetPort: 8080
# protocol: TCP



120 changes: 120 additions & 0 deletions .deploy/ingress2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: entity-ingress
namespace: hypermine-development
annotations:
kubernetes.io/ingress.allow-http: "false"
kubernetes.io/force-ssl-redirect: redirect
ingressClassName: "gce"
kubernetes.io/ingress.global-static-ip-name: entity-ip
cert-manager.io/issuer: letsencrypt-production
labels:
name: ingress

spec:
tls:
- secretName: entity-ssl
hosts:
- "api.entity.hypersign.id"
- "*.api.entity.hypersign.id"
- "api.entity-test.hypersign.id"
- "*.api.entity-test.hypersign.id"

rules:
- host: "api.entity.hypersign.id"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: entity-api-service
port:
number: 3001
- path: /ssi/
pathType: Prefix
backend:
service:
name: entity-api-service
port:
number: 3001
- path: /api/
pathType: Prefix
backend:
service:
name: entity-api-service
port:
number: 3001
- host: "*.api.entity.hypersign.id"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: entity-api-service
port:
number: 3001
- path: /ssi/
pathType: Prefix
backend:
service:
name: entity-api-service
port:
number: 3001
- path: /api/
pathType: Prefix
backend:
service:
name: entity-api-service
port:
number: 3001
- host: "api.entity-test.hypersign.id"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: entity-api-test-service
port:
number: 3001
- path: /ssi/
pathType: Prefix
backend:
service:
name: entity-api-test-service
port:
number: 3001
- path: /api/
pathType: Prefix
backend:
service:
name: entity-api-test-service
port:
number: 3001
- host: "*.api.entity-test.hypersign.id"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: entity-api-test-service
port:
number: 3001
- path: /ssi/
pathType: Prefix
backend:
service:
name: entity-api-test-service
port:
number: 3001
- path: /api/
pathType: Prefix
backend:
service:
name: entity-api-test-service
port:
number: 3001
10 changes: 7 additions & 3 deletions .github/workflows/CI-CD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ jobs:
GOOGLE_ARTIFACT_URL: ${{secrets.GOOGLE_ARTIFACT_URL}}
GOOGLE_ARTIFACT_REPO: ${{secrets.GOOGLE_ARTIFACT_REPO}}
run:
docker build -t $GOOGLE_ARTIFACT_URL/$GOOGLE_PROJECT_ID/$GOOGLE_ARTIFACT_REPO/enity-api-service:${{ env.LATEST_RELEASE_TAG }} .
docker build -t $GOOGLE_ARTIFACT_URL/$GOOGLE_PROJECT_ID/$GOOGLE_ARTIFACT_REPO/enity-api-test-service:${{ env.LATEST_RELEASE_TAG }} .

docker push $GOOGLE_ARTIFACT_URL/$GOOGLE_PROJECT_ID/$GOOGLE_ARTIFACT_REPO/enity-api-service:${{ env.LATEST_RELEASE_TAG }}
docker push $GOOGLE_ARTIFACT_URL/$GOOGLE_PROJECT_ID/$GOOGLE_ARTIFACT_REPO/enity-api-test-service:${{ env.LATEST_RELEASE_TAG }}
- name: "Docker Build and Push"
env:
GOOGLE_PROJECT_ID: ${{secrets.GOOGLE_PROJECT_ID}}
Expand Down Expand Up @@ -103,6 +103,10 @@ jobs:
run: find .deploy/deployment.yaml -type f -exec sed -i -e "s#__EDV_DID_FILE_PATH__#${{ secrets.EDV_DID_FILE_PATH }}#" {} \;
- name: "Replace secrets"
run: find .deploy/deployment.yaml -type f -exec sed -i -e "s#__EDV_KEY_FILE_PATH__#${{ secrets.EDV_KEY_FILE_PATH }}#" {} \;
- name: "Replace secrets"
run: find .deploy/deployment.yaml -type f -exec sed -i -e "s#__GLOBAL_TXN_CONTROLLER_QUEUE__#${{ secrets.GLOBAL_TXN_CONTROLLER_QUEUE }}#" {} \;
- name: "Replace secrets"
run: find .deploy/deployment.yaml -type f -exec sed -i -e "s#__RABBIT_MQ_URI__#${{ secrets.RABBIT_MQ_URI }}#" {} \;
- name: "Replace secrets"
run: find .deploy/deployment.yaml -type f -exec sed -i -e "s#__MNEMONIC__#${{ secrets.MNEMONIC }}#" {} \;
- name: "Replace secrets"
Expand All @@ -114,4 +118,4 @@ jobs:
- name: "Replace secrets"
run: find .deploy/deployment.yaml -type f -exec sed -i ''s/__GOOGLE_PROJECT_ID__/${{ secrets.GOOGLE_PROJECT_ID }}/g'' {} \;
- name: "Deploy to GKE"
run: kubectl apply -f .deploy/deployment.yaml
run: kubectl apply -f .deploy/deployment2.yaml
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@
"@nestjs/passport": "^9.0.0",
"@nestjs/platform-express": "^9.0.0",
"@nestjs/swagger": "^6.1.4",
"amqp-connection-manager": "^4.1.14",
"amqplib": "^0.10.4",
"argon2": "^0.30.3",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"express-session": "^1.17.3",
"fs": "^0.0.1-security",
"hid-hd-wallet": "git+https://github.com/hypersign-protocol/hid-hd-wallet.git#main",
"hs-ssi-sdk": "github:hypersign-protocol/hid-ssi-js-sdk#testcase/bjj",
"hypersign-edv-client": "github:hypersign-protocol/hypersign-edv-client#develop",
"hypersign-edv-client": "github:hypersign-protocol/hypersign-edv-client#deleteByDocumentId",
"idb-keyval": "^6.2.1",
"mongoose": "^6.8.3",
"passport": "^0.6.0",
Expand Down
2 changes: 2 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { DidModule } from './did/did.module';
import { SchemaModule } from './schema/schema.module';
import { CredentialModule } from './credential/credential.module';
import { PresentationModule } from './presentation/presentation.module';
import { TxSendModuleModule } from './tx-send-module/tx-send-module.module';
@Module({
imports: [
ConfigModule.forRoot({
Expand All @@ -18,6 +19,7 @@ import { PresentationModule } from './presentation/presentation.module';
SchemaModule,
CredentialModule,
PresentationModule,
TxSendModuleModule,
],
controllers: [],
providers: [{ provide: APP_FILTER, useClass: AllExceptionsFilter }],
Expand Down
3 changes: 2 additions & 1 deletion src/did/did.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ import { TrimMiddleware } from 'src/utils/middleware/trim.middleware';
import { databaseProviders } from '../mongoose/tenant-mongoose-connections';
import { didProviders } from './providers/did.provider';
import { JwtStrategy } from '../utils/jwt.strategy';
import { TxSendModuleModule } from 'src/tx-send-module/tx-send-module.module';
@Module({
imports: [EdvModule, HidWalletModule],
imports: [EdvModule, HidWalletModule, TxSendModuleModule],
controllers: [DidController],
providers: [
JwtStrategy,
Expand Down
17 changes: 16 additions & 1 deletion src/did/services/did.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { Did as IDidDto } from '../schemas/did.schema';
import { AddVerificationMethodDto } from '../dto/addVm.dto';
import { getAppVault, getAppMenemonic } from '../../utils/app-vault-service';
import { ConfigService } from '@nestjs/config';
import { TxSendModuleService } from 'src/tx-send-module/tx-send-module.service';

@Injectable({ scope: Scope.REQUEST })
export class DidService {
Expand All @@ -39,6 +40,7 @@ export class DidService {
private readonly hidWallet: HidWalletService,
private readonly didSSIService: DidSSIService,
private readonly config: ConfigService,
private readonly txnService: TxSendModuleService,
) {}

// TODO: need to fix this once ed25519 is finished.
Expand Down Expand Up @@ -376,7 +378,20 @@ export class DidService {
'register() method: before calling hypersignDid.register ',
'DidService',
);
registerDidDoc = await hypersignDid.register(params);

const signInfos = await hypersignDid.createSignInfos({
didDocument,
privateKeyMultibase,
verificationMethodId: verificationMethodId,
});
await this.txnService.sendDIDTxn(
didDocument,
signInfos,
verificationMethodId,
appMenemonic,
);

// registerDidDoc = await hypersignDid.register(params);
data = await this.didRepositiory.findOneAndUpdate(
{ did: didDocument['id'] },
{
Expand Down
Loading

0 comments on commit d24aae2

Please sign in to comment.