Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SSI Service Backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ESSIF-Lab
TNO SSI Service
SSI Service Backend
Commits
e013aaec
Commit
e013aaec
authored
May 14, 2020
by
Hidde-Jan Jongsma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add connector registration in organization service
parent
7e829cbc
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
448 additions
and
9 deletions
+448
-9
src/connectors/connectors.module.ts
src/connectors/connectors.module.ts
+1
-0
src/connectors/connectors.service.ts
src/connectors/connectors.service.ts
+9
-0
src/connectors/irma/irma.service.ts
src/connectors/irma/irma.service.ts
+1
-0
src/connectors/jolocom/jolocom-credential-type.entity.ts
src/connectors/jolocom/jolocom-credential-type.entity.ts
+33
-0
src/connectors/jolocom/jolocom-wallet.entity.ts
src/connectors/jolocom/jolocom-wallet.entity.ts
+54
-0
src/connectors/jolocom/jolocom.module.ts
src/connectors/jolocom/jolocom.module.ts
+5
-0
src/connectors/jolocom/jolocom.service.ts
src/connectors/jolocom/jolocom.service.ts
+323
-3
src/organizations/organizations.module.ts
src/organizations/organizations.module.ts
+2
-1
src/organizations/organizations.service.ts
src/organizations/organizations.service.ts
+20
-5
No files found.
src/connectors/connectors.module.ts
View file @
e013aaec
import
{
Module
}
from
'
@nestjs/common
'
;
import
{
JolocomModule
}
from
'
./jolocom/jolocom.module
'
;
import
{
IrmaModule
}
from
'
./irma/irma.module
'
;
import
{
ConnectorsService
}
from
'
./connectors.service
'
;
...
...
src/connectors/connectors.service.ts
View file @
e013aaec
...
...
@@ -2,6 +2,7 @@ import { Injectable } from '@nestjs/common';
import
{
JolocomService
}
from
'
./jolocom/jolocom.service
'
;
import
{
IrmaService
}
from
'
./irma/irma.service
'
;
import
{
ConnectorService
}
from
'
./connector-service.interface
'
;
import
{
Organization
}
from
'
../organizations/organization.entity
'
;
@
Injectable
()
export
class
ConnectorsService
{
...
...
@@ -18,4 +19,12 @@ export class ConnectorsService {
getConnector
(
type
:
string
)
{
return
this
.
connectors
.
find
(
connector
=>
connector
.
type
===
type
);
}
async
registerOrganization
(
organization
:
Organization
)
{
await
Promise
.
all
(
this
.
connectors
.
map
(
async
connector
=>
await
connector
.
registerOrganization
(
organization
),
),
);
}
}
src/connectors/irma/irma.service.ts
View file @
e013aaec
...
...
@@ -7,6 +7,7 @@ export class IrmaService implements ConnectorService {
type
=
'
irma
'
;
async
registerOrganization
(
organization
:
Organization
)
{
// We don't need to do anything for IRMA.
return
;
}
}
src/connectors/jolocom/jolocom-credential-type.entity.ts
0 → 100644
View file @
e013aaec
import
{
BaseEntity
,
Entity
,
PrimaryGeneratedColumn
,
ManyToOne
,
Column
,
}
from
'
typeorm
'
;
import
{
JolocomWallet
}
from
'
./jolocom-wallet.entity
'
;
import
{
BaseMetadata
}
from
'
cred-types-jolocom-core/js/types
'
;
@
Entity
()
export
class
JolocomCredentialType
extends
BaseEntity
{
@
PrimaryGeneratedColumn
()
id
:
number
;
@
ManyToOne
(
()
=>
JolocomWallet
,
wallet
=>
wallet
.
credentialOffers
,
)
wallet
:
JolocomWallet
;
@
Column
({
unique
:
true
})
type
:
string
;
@
Column
()
name
:
string
;
@
Column
(
'
simple-json
'
)
context
:
BaseMetadata
[
'
context
'
];
@
Column
(
'
simple-json
'
)
claimInterface
:
BaseMetadata
[
'
claimInterface
'
];
}
src/connectors/jolocom/jolocom-wallet.entity.ts
View file @
e013aaec
import
{
BaseEntity
,
Entity
,
PrimaryGeneratedColumn
,
Column
,
OneToOne
,
JoinColumn
,
OneToMany
,
}
from
'
typeorm
'
;
import
{
randomBytes
}
from
'
crypto
'
;
import
{
Organization
}
from
'
../../organizations/organization.entity
'
;
import
{
JolocomCredentialType
}
from
'
./jolocom-credential-type.entity
'
;
const
JOLOCOM_WALLET_SEED_BYTES
=
32
;
const
JOLOCOM_WALLET_PASSWORD_BYTES
=
16
;
@
Entity
()
export
class
JolocomWallet
extends
BaseEntity
{
@
PrimaryGeneratedColumn
()
id
:
number
;
@
Column
({
update
:
false
})
encryptedSeedHex
:
string
;
@
Column
({
update
:
false
})
password
:
string
;
@
OneToOne
(()
=>
Organization
)
@
JoinColumn
()
organization
:
Organization
;
@
OneToMany
(
()
=>
JolocomCredentialType
,
credentialOffer
=>
credentialOffer
.
wallet
,
)
credentialOffers
:
JolocomCredentialType
[];
static
randomPassword
()
{
return
randomBytes
(
JOLOCOM_WALLET_PASSWORD_BYTES
).
toString
(
'
hex
'
);
}
static
randomSeed
()
{
return
randomBytes
(
JOLOCOM_WALLET_SEED_BYTES
);
}
get
encryptedSeed
():
Buffer
{
return
Buffer
.
from
(
this
.
encryptedSeedHex
,
'
hex
'
);
}
set
encryptedSeed
(
seed
:
Buffer
)
{
this
.
encryptedSeedHex
=
seed
.
toString
(
'
hex
'
);
}
}
src/connectors/jolocom/jolocom.module.ts
View file @
e013aaec
import
{
Module
}
from
'
@nestjs/common
'
;
import
{
TypeOrmModule
}
from
'
@nestjs/typeorm
'
;
import
{
JolocomService
}
from
'
./jolocom.service
'
;
import
{
JolocomWallet
}
from
'
./jolocom-wallet.entity
'
;
import
{
JolocomCredentialType
}
from
'
./jolocom-credential-type.entity
'
;
@
Module
({
imports
:
[
TypeOrmModule
.
forFeature
([
JolocomWallet
,
JolocomCredentialType
])],
providers
:
[
JolocomService
],
exports
:
[
JolocomService
],
})
...
...
src/connectors/jolocom/jolocom.service.ts
View file @
e013aaec
This diff is collapsed.
Click to expand it.
src/organizations/organizations.module.ts
View file @
e013aaec
...
...
@@ -4,9 +4,10 @@ import { TypeOrmModule } from '@nestjs/typeorm';
import
{
OrganizationsController
}
from
'
./organizations.controller
'
;
import
{
OrganizationsService
}
from
'
./organizations.service
'
;
import
{
Organization
}
from
'
./organization.entity
'
;
import
{
ConnectorsModule
}
from
'
src/connectors/connectors.module
'
;
@
Module
({
imports
:
[
TypeOrmModule
.
forFeature
([
Organization
])],
imports
:
[
TypeOrmModule
.
forFeature
([
Organization
])
,
ConnectorsModule
],
controllers
:
[
OrganizationsController
],
providers
:
[
OrganizationsService
],
})
...
...
src/organizations/organizations.service.ts
View file @
e013aaec
import
{
Injectable
}
from
'
@nestjs/common
'
;
import
{
Injectable
,
Logger
}
from
'
@nestjs/common
'
;
import
{
InjectRepository
}
from
'
@nestjs/typeorm
'
;
import
{
Repository
}
from
'
typeorm
'
;
import
{
Organization
}
from
'
./organization.entity
'
;
import
{
ConnectorsService
}
from
'
src/connectors/connectors.service
'
;
@
Injectable
()
export
class
OrganizationsService
{
logger
:
Logger
;
constructor
(
@
InjectRepository
(
Organization
)
private
organizationsRepository
:
Repository
<
Organization
>
,
)
{}
private
connectorsService
:
ConnectorsService
,
)
{
this
.
logger
=
new
Logger
(
Organization
.
name
);
}
findAll
()
{
async
findAll
()
{
return
this
.
organizationsRepository
.
find
();
}
createFromName
(
name
:
string
)
{
async
findByIdentifier
(
uuid
:
string
)
{
const
results
=
await
this
.
organizationsRepository
.
find
({
take
:
1
});
return
results
[
0
];
}
async
createFromName
(
name
:
string
)
{
this
.
logger
.
log
(
`Creating organization with name
${
name
}
`
);
const
organization
=
new
Organization
();
organization
.
name
=
name
;
organization
.
sharedSecret
=
Organization
.
randomSecret
();
return
this
.
organizationsRepository
.
save
(
organization
);
await
this
.
organizationsRepository
.
save
(
organization
);
await
this
.
connectorsService
.
registerOrganization
(
organization
);
this
.
logger
.
log
(
`Created organization (id:
${
organization
.
id
}
)`
);
return
organization
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment