Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
ocm-engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
svdh
ocm-engine
Commits
62bb1bea
Commit
62bb1bea
authored
8 months ago
by
Alexey Lunin
Browse files
Options
Downloads
Patches
Plain Diff
save did svdx, email, public keys in storage
parent
cd65c347
No related branches found
No related tags found
1 merge request
!93
OCM key - svdx id mapping OP#252
Pipeline
#74569
waiting for manual action
Stage: build
Stage: trigger-deploy
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libs/askar/src/agent.utils.ts
+37
-2
37 additions, 2 deletions
libs/askar/src/agent.utils.ts
libs/askar/src/askar/services/agent.ocm.service.ts
+5
-2
5 additions, 2 deletions
libs/askar/src/askar/services/agent.ocm.service.ts
with
42 additions
and
4 deletions
libs/askar/src/agent.utils.ts
+
37
−
2
View file @
62bb1bea
...
...
@@ -65,6 +65,7 @@ import {
SvdxDidResolver
,
SvdxModule
,
DefaultIpfsClient
,
SvdxRecordsApi
,
}
from
"
@vereign/credo-did-svdx
"
;
import
{
SubjectInboundTransport
}
from
"
./askar/transports/agent.subject.inbound.transport
"
;
...
...
@@ -204,9 +205,43 @@ export const generateDidWeb = async ({
console
.
log
(
JSON
.
stringify
(
didDocumentInstance
.
toJSON
(),
null
,
2
));
};
export
const
generate
Random
DidSvdx
=
async
(
agent
:
Agent
)
=>
{
export
const
generateDidSvdx
ForEmail
=
async
(
agent
:
Agent
,
email
:
string
)
=>
{
const
seed
=
crypto
.
randomBytes
(
46
).
toString
(
"
hex
"
);
return
generateDidSvdx
({
agent
,
seed
});
const
activeKey
=
await
generateKey
({
seed
,
agent
});
const
nextKey
=
await
generateKey
({
seed
,
agent
});
// TODO Where to find next key?
const
WalletKeyPair
=
createWalletKeyPairClass
(
agent
.
context
.
wallet
);
const
keyPair
=
new
WalletKeyPair
({
id
:
`key-1`
,
controller
:
`did:svdx:
${
activeKey
.
fingerprint
}
`
,
key
:
activeKey
,
wallet
:
agent
.
context
.
wallet
,
});
const
didResult
=
await
agent
.
dids
.
create
({
method
:
"
svdx
"
,
options
:
{
inceptionKey
:
activeKey
,
nextKey
:
nextKey
,
signer
:
{
signer
:
()
=>
keyPair
.
signer
()
},
},
});
console
.
log
(
didResult
);
if
(
!
didResult
.
didState
.
didDocument
)
{
throw
new
Error
(
"
Could not create did svdx
"
);
}
const
svdxApi
:
SvdxRecordsApi
=
agent
.
modules
[
"
svdx
"
];
await
svdxApi
.
save
({
email
:
email
,
did
:
didResult
.
didState
.
did
!
,
activeKey
:
activeKey
.
publicKeyBase58
,
nextKey
:
nextKey
.
publicKeyBase58
,
});
return
didResult
;
};
export
const
generateDidSvdx
=
async
({
...
...
This diff is collapsed.
Click to expand it.
libs/askar/src/askar/services/agent.ocm.service.ts
+
5
−
2
View file @
62bb1bea
import
{
Injectable
,
Logger
}
from
"
@nestjs/common
"
;
import
{
EntityNotFoundError
,
RequestSenderEmailVcDto
}
from
"
@ocm-engine/dtos
"
;
import
{
CatalogClient
}
from
"
../clients/catalog.client
"
;
import
{
generate
Random
DidSvdx
}
from
"
../../agent.utils
"
;
import
{
generateDidSvdx
ForEmail
}
from
"
../../agent.utils
"
;
import
{
AskarService
}
from
"
./askar.service
"
;
import
{
IConfCatalog
}
from
"
@ocm-engine/config
"
;
import
{
ConfigService
}
from
"
@nestjs/config
"
;
...
...
@@ -55,7 +55,10 @@ export class AgentOcmService {
};
}
const
newDidSvdx
=
await
generateRandomDidSvdx
(
this
.
askar
.
agent
);
const
newDidSvdx
=
await
generateDidSvdxForEmail
(
this
.
askar
.
agent
,
dto
.
email
,
);
if
(
!
newDidSvdx
.
didState
.
did
)
{
throw
new
Error
(
"
Svdx did generation failed
"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment