Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 9f88783
Author: Peter Langenkamp <[email protected]>
Date:   Tue Nov 30 11:12:59 2021 -0800

    fix redirect after issuing + put back ida code in issue.controller

commit 68651f7
Author: Galit Rahim <[email protected]>
Date:   Tue Nov 30 19:23:40 2021 +0100

    Added Trinsic issue response

commit d62c354
Author: Galit Rahim <[email protected]>
Date:   Tue Nov 30 17:24:10 2021 +0100

    Working Trinsic verify response

commit 57af51f
Author: Peter Langenkamp <[email protected]>
Date:   Tue Nov 30 02:41:17 2021 -0800

    fix for sending trinsic requests

commit 6b21590
Author: Peter Langenkamp <[email protected]>
Date:   Fri Nov 19 06:43:16 2021 -0800

    add migration for trinsic credential

commit bf2d1a0
Merge: 5a8cb99 f46259b
Author: Peter Langenkamp <[email protected]>
Date:   Fri Nov 19 06:23:51 2021 -0800

    Merge branch 'master' into trinsic

commit 5a8cb99
Author: Galit Rahim <[email protected]>
Date:   Thu Oct 14 11:25:02 2021 +0200

    Fixed bug and removed api key

commit a746c2d
Author: Galit Rahim <[email protected]>
Date:   Wed Oct 13 17:42:56 2021 +0200

    Working issue

commit eb46841
Author: Galit Rahim <[email protected]>
Date:   Tue Oct 5 14:23:02 2021 +0200

    Working verify

commit f32b910
Author: Galit Rahim <[email protected]>
Date:   Mon Oct 4 16:31:51 2021 +0200

    System now asks to setup connection

commit 722c258
Author: Galit Rahim <[email protected]>
Date:   Thu Sep 30 17:20:53 2021 +0200

    Working Trinsic implementation!

commit 5a3505b
Author: Galit Rahim <[email protected]>
Date:   Mon Sep 27 17:02:28 2021 +0200

    Working qr code generator

commit 9dff2e0
Author: Galit Rahim <[email protected]>
Date:   Wed Sep 22 15:05:05 2021 +0200

    Working trinsic verify

commit 31dcc5a
Author: Galit Rahim <[email protected]>
Date:   Fri Aug 20 15:00:30 2021 +0200

    Working Trinsic Credential Types

commit dc1e418
Author: Galit Rahim <[email protected]>
Date:   Thu Aug 5 16:56:33 2021 +0200

    Added get Trinsic credentials

commit 0b526d3
Author: Galit Rahim <[email protected]>
Date:   Wed Jul 14 16:59:20 2021 +0200

    Added extra trinsic code

commit 8aadaa7
Author: Galit Rahim <[email protected]>
Date:   Fri Jul 9 15:18:53 2021 +0200

    Working creating schemas and creddef

commit bc89ad4
Author: Galit Rahim <[email protected]>
Date:   Thu Jul 8 15:19:30 2021 +0200

    Changing trinsic schema

commit 77a8ab0
Author: Galit <[email protected]>
Date:   Fri Jun 18 15:56:48 2021 +0200

    Fixed build bug

commit eee1801
Author: Galit Rahim <[email protected]>
Date:   Mon May 31 16:12:09 2021 +0200

    More connection code for Trinsic

commit fe4b981
Author: Galit Rahim <[email protected]>
Date:   Tue May 18 12:19:24 2021 +0200

    Changed code for connection

commit f72292c
Author: Galit Rahim <[email protected]>
Date:   Fri Apr 30 14:55:08 2021 +0200

    More code for Trinsic connection

commit 9b2f212
Author: Galit Rahim <[email protected]>
Date:   Wed Apr 28 16:46:35 2021 +0200

    Further work on Trinsic connection

commit b6a2a5a
Author: Galit Rahim <[email protected]>
Date:   Thu Apr 22 15:03:46 2021 +0200

    Add template for Trinsic
  • Loading branch information
peterlangenkamp committed Nov 30, 2021
1 parent f46259b commit 0b1de82
Show file tree
Hide file tree
Showing 19 changed files with 753 additions and 4 deletions.
96 changes: 96 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
"@nestjs/swagger": "^4.7.16",
"@nestjs/typeorm": "^7.1.5",
"@nestjs/websockets": "^7.6.14",
"@trinsic/service-clients": "^1.1.5018",
"class-transformer": "^0.4.0",
"class-validator": "^0.13.1",
"dotenv": "^8.2.0",
"jolocom-lib": "^5.2.0",
"jsonwebtoken": "^8.5.1",
"pg": "^8.5.1",
Expand All @@ -44,7 +46,8 @@
"rxjs": "^6.6.6",
"socket.io": "^4.0.0",
"swagger-ui-express": "^4.1.6",
"typeorm": "^0.2.31"
"typeorm": "^0.2.31",
"uuid": "^8.3.0"
},
"devDependencies": {
"@nestjs/cli": "^7.5.6",
Expand Down
8 changes: 8 additions & 0 deletions src/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ export class ConfigService {
return process.env.ACAPY_ADMIN_URL || 'http://acapy:9001';
}

getTrinsicUrl(): string {
return process.env.TRINSIC_ADMIN_URL || 'https://api.trinsic.id';
}

getIndyDID(): string {
return process.env.ACAPY_INDY_DID || '';
}

getTrinsicAPIKey(): string {
return process.env.TRINSIC_API_KEY || '';
}
}
9 changes: 6 additions & 3 deletions src/connectors/connectors.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ import { IrmaModule } from './irma/irma.module';
import { IrmaService } from './irma/irma.service';
import { JolocomModule } from './jolocom/jolocom.module';
import { JolocomService } from './jolocom/jolocom.service';
import { TrinsicModule } from './trinsic/trinsic.module';
import { TrinsicService } from './trinsic/trinsic.service';

export const CONNECTOR_SERVICES = 'CONNECTOR_SERVICES';

@Module({
imports: [JolocomModule, IdaModule, IrmaModule, IndyModule, TypeOrmModule.forFeature()],
imports: [JolocomModule, IdaModule, IrmaModule, IndyModule, TrinsicModule, TypeOrmModule.forFeature()],
providers: [
ConnectorsService,
GetConnectorPipe,
{
provide: CONNECTOR_SERVICES,
useFactory: (jolocom, ida, irma, indy) => [jolocom, ida, irma, indy],
inject: [JolocomService, IdaService, IrmaService, IndyService],
useFactory: (jolocom, ida, irma, indy, trinsic) => [jolocom, ida, irma, indy, trinsic],
inject: [JolocomService, IdaService, IrmaService, IndyService, TrinsicService],
},
],
exports: [
Expand All @@ -34,6 +36,7 @@ export const CONNECTOR_SERVICES = 'CONNECTOR_SERVICES';
IdaModule,
IrmaModule,
IndyModule,
TrinsicModule,
],
})
export class ConnectorsModule {}
3 changes: 3 additions & 0 deletions src/connectors/connectors.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { IdaService } from './ida/ida.service';
import { IndyService } from './indy/indy.service';
import { IrmaService } from './irma/irma.service';
import { JolocomService } from './jolocom/jolocom.service';
import { TrinsicService } from './trinsic/trinsic.service';

@Injectable()
export class ConnectorsService {
Expand All @@ -19,11 +20,13 @@ export class ConnectorsService {
private idaService: IdaService,
private irmaService: IrmaService,
private indyService: IndyService,
private trinsicService: TrinsicService
) {
this.connectors.push(this.jolocomService);
this.connectors.push(this.idaService);
this.connectors.push(this.irmaService);
this.connectors.push(this.indyService);
this.connectors.push(this.trinsicService);
}

getConnector(name: string) {
Expand Down
25 changes: 25 additions & 0 deletions src/connectors/trinsic/create-trinsic-schema.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { IsNotEmpty, IsOptional, IsString, Matches } from 'class-validator';

export class CreateTrinsicSchemaDto {
@IsString()
@IsNotEmpty()
name: string;

@IsString()
@Matches(/^\d+(\.\d+)*$/)
version: string;

@IsString({ each: true })
@IsNotEmpty({ each: true })
attributeNames: string[];

@IsOptional()
@IsString()
@IsNotEmpty()
trinsicSchemaId?: string;

@IsOptional()
@IsString()
@IsNotEmpty()
trinsicCredentialDefinitionId?: string;
}
46 changes: 46 additions & 0 deletions src/connectors/trinsic/trinsic-invitation.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';
import { randomBytes } from 'crypto';

export interface TrinsicConnectionResponse {
connectionId: string;
name: string;
imageUrl: string;
myDid: string;
theirDid: string;
myKey: string;
theirKey: string;
state: string;
invitation: string;
invitationUrl: string;
endpoint: {
did: string;
reciverkeypientKeys: string[];
uri: string;
};
createdAtUtc: string;
multiParty: boolean;
}

const TRINSIC_INVITATION_IDENTIFIER_BYTES = 6;

@Entity()
export class TrinsicInvitation {
@PrimaryGeneratedColumn()
id: number;

@Column()
name: string;

@Column({ unique: true })
connectionId: string;

@Column()
multiParty: boolean;

@Column('simple-json')
connectionResponse: TrinsicConnectionResponse;

static randomIdentifier() {
return randomBytes(TRINSIC_INVITATION_IDENTIFIER_BYTES).toString('base64');
}
}
60 changes: 60 additions & 0 deletions src/connectors/trinsic/trinsic-schema.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { CredentialType } from 'src/types/credential-type.entity';
import { PrimaryGeneratedColumn, Column, OneToMany, Entity } from 'typeorm';

export interface TrinsicSchemaResponse {
schemaId: string;
name: string;
version: string;
attributeNames: string[];
}

export interface TrinsicCredDefResponse {
schemaId: string;
definitionId: string;
supportRevocation: boolean;
tag: string;
}

@Entity()
export class TrinsicSchema {
@PrimaryGeneratedColumn()
id: number;

@Column()
name: string;

@Column()
version: string;

@Column('simple-json')
attributeNames: string[];

@Column({ nullable: true, default: null })
supportRevocation: boolean;

@Column({ nullable: true})
trinsicSchemaId: string;

@Column({ nullable: true })
trinsicCredentialDefinitionId: string;

@OneToMany(
() => CredentialType,
type => type.trinsicSchema,
)
credentialTypes: CredentialType[];

//TODO: change to real unique tag
//Trinsic docs: "Unique tag to differentiate definitions of the same schema"
//@Column({ unique: true })
@Column({ nullable: true })
tag: string;

get schemaIssuerDid() {
return this.trinsicSchemaId.split(':')[0];
}

get credDefIssuerDid() {
return this.trinsicCredentialDefinitionId.split(':')[0];
}
}
18 changes: 18 additions & 0 deletions src/connectors/trinsic/trinsic.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { TrinsicController } from './trinsic.controller';

describe('Trinsic Controller', () => {
let controller: TrinsicController;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [TrinsicController],
}).compile();

controller = module.get<TrinsicController>(TrinsicController);
});

it('should be defined', () => {
expect(controller).toBeDefined();
});
});
Loading

0 comments on commit 0b1de82

Please sign in to comment.