Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: Clécio Varjão <[email protected]>
  • Loading branch information
cvarjao committed Aug 29, 2024
1 parent 55f184a commit 08aeeca
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 15 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ ngrok http "file://${PWD}/tmp"
```
## In terminal 2, run tests
```
yarn jest --runInBand --detectOpenHandles --forceExit
## For running using the mobile app. Open tmp/__qrcode.png to see the generated QR Codes
export HOLDER_TYPE=manual
yarn jest --runInBand --detectOpenHandles --forceExit src/basic.test.ts
```
8 changes: 7 additions & 1 deletion src/Agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ export type InvitationPayloadMapping = {
[INVITATION_TYPE.OOB_DIDX_1_1]: InvitationRecordV2
}

export type InvitationArgumentMapping = {
[INVITATION_TYPE.CONN_1_0]: Record<string, never>
[INVITATION_TYPE.OOB_CONN_1_0]: {goalCode: string}
[INVITATION_TYPE.OOB_DIDX_1_1]: {goalCode: string}
}

export type CreateInvitationResponse<T extends INVITATION_TYPE> = {type: T, payload: InvitationPayloadMapping[T]}


Expand All @@ -35,7 +41,7 @@ export type ReceiveInvitationResponse = { outOfBandRecord?: OutOfBandRecord; con
export interface AriesAgent {
readonly logger: Logger
sendBasicMessage(connection_id: string, content: string): Promise<any>
createInvitationToConnect<T extends INVITATION_TYPE>(invitationType: T): Promise<CreateInvitationResponse<T>>
createInvitationToConnect<T extends INVITATION_TYPE>(invitationType: T, args?: InvitationArgumentMapping[T]): Promise<CreateInvitationResponse<T>>
receiveInvitation(invitation: ResponseCreateInvitation): Promise<ReceiveInvitationResponse>;
startup(): Promise<void>;
shutdown(): Promise<void>;
Expand Down
18 changes: 18 additions & 0 deletions src/InvitationFactory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export abstract class CreateInvitationFactory {

}
export class CreateInvitationFactoryConn1_0 extends CreateInvitationFactory {
connectionless: boolean;
constructor(connectionless:boolean = false){
super();
this.connectionless = connectionless
}
}

export class CreateInvitationFactoryOOB extends CreateInvitationFactory {
connectionless: boolean;
constructor(connectionless:boolean = false){
super();
this.connectionless = connectionless
}
}
2 changes: 1 addition & 1 deletion src/attestation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const stepTimeout = 999999999
const shortTimeout = (2 * 60) * 1000

import { setGlobalDispatcher, Agent } from 'undici';
import { AriesAgent, INVITATION_TYPE, ResponseCreateInvitationV1 } from "./Agent";
import { AriesAgent, INVITATION_TYPE } from "./Agent";
import { AgentManual } from "./AgentManual";
setGlobalDispatcher(new Agent({ connect: { timeout: 20_000 } }));

Expand Down
8 changes: 4 additions & 4 deletions src/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe("Mandatory", () => {
beforeEach(async () => {
requests.length = 0
})
test("connected/v1/M1", async () => {
test.skip("connected/v1/M1", async () => {
const issuer = agentIssuer
const holder = agentB
logger.info(`Executing ${expect.getState().currentTestName}`)
Expand All @@ -94,7 +94,7 @@ describe("Mandatory", () => {
logger.info('Message Received:', msgRcvd)
//expect(requests).toMatchSnapshot();
}, shortTimeout);
test("OOB/connected/messaging", async () => {
test.skip("OOB/connected/messaging", async () => {
const issuer = agentIssuer
const holder = agentB
logger.info(`Executing ${expect.getState().currentTestName}`)
Expand Down Expand Up @@ -126,11 +126,11 @@ describe("Mandatory", () => {
}
//expect(requests).toMatchSnapshot();
}, stepTimeout)
test.only("OOB/connected/issue", async () => {
test("OOB/connected/issue", async () => {
logger.info(`Executing ${expect.getState().currentTestName}`)
const issuer = agentIssuer
const holder = agentB
const cred = new PersonCredential1(credDef)
const { logger } = issuer
const remoteInvitation = await issuer.createOOBInvitationToConnect(INVITATION_TYPE.OOB_CONN_1_0)
logger.info('remoteInvitation', remoteInvitation)
logger.info(`waiting for holder to accept connection`)
Expand Down
29 changes: 21 additions & 8 deletions src/setup-from-sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const checkTransactions = async (baseUrl:string, token:string) => {
console.dir(['transactions', transactions], {depth: 5})
return transactions
}
const run = async () => {

const getNewTenant = async () => {
console.log('Requesting tenant')
const baseUrl = 'https://traction-sandbox-tenant-proxy.apps.silver.devops.gov.bc.ca'
//${baseUiUrl}/api/innkeeperReservation
Expand Down Expand Up @@ -135,18 +136,30 @@ const run = async () => {
maxTransactionsChecks--
}

return {
base_url: baseUrl,
serviceEndpoint: baseUrl.replace('-tenant-proxy', '-acapy'),
tenant_id: tenant.tenant_id,
api_key: tenant.api_key,
wallet_id: checkin.wallet_id,
wallet_key: checkin.wallet_key
}
}
const run = async () => {

const keys = ['schema_owner', 'issuer', 'verifier', 'holder']
const config:any = {}
if (fs.existsSync(path.resolve('./local.env.json'))){
Object.assign(config, JSON.parse(fs.readFileSync(path.resolve('./local.env.json'), 'utf8')))
}

config['_new'] = config['default2']??{}
config['_new']['base_url'] = baseUrl
config['_new']['serviceEndpoint'] = baseUrl.replace('-tenant-proxy', '-acapy')
config['_new']['tenant_id'] = tenant.tenant_id
config['_new']['api_key'] = tenant.api_key
config['_new']['wallet_id'] = checkin.wallet_id
config['_new']['wallet_key'] = checkin.wallet_key
for (const key of keys) {
const teant = await getNewTenant()
const conf = config[key]??{}
//const config = {config[key]??{}, ...teant}
config[key] = {...conf, ...teant}
await new Promise(resolve => setTimeout(resolve, 2000))
}
fs.writeFileSync(path.resolve('./local.env.json'), JSON.stringify(config, undefined, 2), {encoding: 'utf8'})
}
run()

0 comments on commit 08aeeca

Please sign in to comment.