Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
Vereign Credential Manager
Manage
Activity
Members
Labels
Plan
Issues
33
Issue boards
Milestones
Wiki
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container 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
SSI Space
Vereign Personal Wallet
Vereign Credential Manager
Commits
c37af735
Commit
c37af735
authored
1 year ago
by
Alexey Lunin
Browse files
Options
Downloads
Patches
Plain Diff
Remove constant notification pulling logic and fix receiving oob messages
parent
a1e52480
No related branches found
No related tags found
1 merge request
!19
Fix accepting oob credentials and proof
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/hooks/notifications.ts
+30
-15
30 additions, 15 deletions
src/hooks/notifications.ts
src/utils/agentUtils.ts
+1
-42
1 addition, 42 deletions
src/utils/agentUtils.ts
todo
+0
-22
0 additions, 22 deletions
todo
with
31 additions
and
79 deletions
src/hooks/notifications.ts
+
30
−
15
View file @
c37af735
import
{
useEffect
,
useState
}
from
'
react
'
;
import
{
getNotifications
,
AgentNotification
}
from
"
src/utils/agentUtils
"
;
import
rootStore
from
"
src/store/rootStore
"
;
import
{
useMemo
}
from
'
react
'
;
import
{
AgentNotification
}
from
"
src/utils/agentUtils
"
;
import
{
Results
,
useQuery
}
from
"
@realm/react
"
;
import
{
useConnections
,
useCredentialByState
,
useProofByState
}
from
"
@aries-framework/react-hooks
"
;
import
Email
from
"
../db-models/Email
"
;
import
{
CredentialState
,
ProofState
}
from
"
@aries-framework/core
"
;
import
{
ConnectionRecord
}
from
"
@aries-framework/core/build/modules/connections/repository/ConnectionRecord
"
;
export
const
useAgentNotifications
=
():
AgentNotification
[]
=>
{
const
[
notifications
,
setNotifications
]
=
useState
<
AgentNotification
[]
>
([]);
const
fetchNotifications
=
async
()
=>
{
const
data
=
await
getNotifications
(
rootStore
.
agentStore
.
agent
);
setNotifications
(
data
);
}
useEffect
(()
=>
{
const
interval
=
setInterval
(
fetchNotifications
,
2000
);
fetchNotifications
();
return
()
=>
clearInterval
(
interval
);
},
[]);
const
allConnections
=
useConnections
();
const
newOffers
=
useCredentialByState
(
CredentialState
.
OfferReceived
);
const
newProofRequests
=
useProofByState
(
ProofState
.
RequestReceived
);
const
notifications
=
useMemo
(()
=>
{
const
result
:
AgentNotification
[]
=
[];
for
(
const
offer
of
newOffers
)
{
let
connection
:
ConnectionRecord
|
null
=
null
;
if
(
offer
.
connectionId
)
{
connection
=
allConnections
.
records
.
find
(
p
=>
p
.
id
===
offer
.
connectionId
)
||
null
;
}
result
.
push
({
key
:
offer
.
id
,
credentialOffer
:
offer
,
connection
:
connection
});
}
for
(
const
request
of
newProofRequests
)
{
let
connection
:
ConnectionRecord
|
null
=
null
;
if
(
request
.
connectionId
)
{
connection
=
allConnections
.
records
.
find
(
p
=>
p
.
id
===
request
.
connectionId
)
||
null
;
}
result
.
push
({
key
:
request
.
id
,
proofRequest
:
request
,
connection
:
connection
});
}
return
result
;
},
[
newOffers
,
newProofRequests
,
allConnections
]);
return
notifications
;
};
...
...
This diff is collapsed.
Click to expand it.
src/utils/agentUtils.ts
+
1
−
42
View file @
c37af735
import
{
Agent
,
CredentialExchangeRecord
,
CredentialState
,
ProofExchangeRecord
,
ProofState
}
from
"
@aries-framework/core
"
;
import
{
CredentialExchangeRecord
,
ProofExchangeRecord
}
from
"
@aries-framework/core
"
;
export
interface
AgentNotification
{
...
...
@@ -7,44 +7,3 @@ export interface AgentNotification {
credentialOffer
?:
CredentialExchangeRecord
;
proofRequest
?:
ProofExchangeRecord
;
}
export
const
getNotifications
=
async
(
agent
:
Agent
):
Promise
<
AgentNotification
[]
>
=>
{
const
newOffers
=
await
agent
.
credentials
.
findAllByQuery
({
state
:
CredentialState
.
OfferReceived
});
const
newProofRequests
=
await
agent
.
proofs
.
findAllByQuery
({
state
:
ProofState
.
RequestReceived
});
const
rejectedIds
:
string
[]
=
[];
// Declining the credential if connection is deleted
for
await
(
const
offer
of
newOffers
)
{
if
(
!
offer
.
connectionId
)
{
await
agent
.
credentials
.
declineOffer
(
offer
.
id
);
rejectedIds
.
push
(
offer
.
id
);
}
}
// Declining the proof if connection is deleted and message doesn't have ~service decorator
for
await
(
const
proof
of
newProofRequests
)
{
if
(
!
proof
.
connectionId
)
{
await
agent
.
proofs
.
declineRequest
(
proof
.
id
);
rejectedIds
.
push
(
proof
.
id
);
}
}
const
notifications
:
AgentNotification
[]
=
[];
const
filteredOffers
=
newOffers
.
filter
(
p
=>
!
rejectedIds
.
some
(
rejId
=>
rejId
===
p
.
id
));
for
await
(
const
offer
of
filteredOffers
)
{
const
connection
=
await
agent
.
connections
.
getById
(
offer
.
connectionId
as
string
);
notifications
.
push
({
key
:
offer
.
id
,
credentialOffer
:
offer
,
connection
:
connection
});
}
const
filteredProofRequests
=
newProofRequests
.
filter
(
p
=>
!
rejectedIds
.
some
(
rejId
=>
rejId
===
p
.
id
))
for
await
(
const
request
of
filteredProofRequests
)
{
const
connection
=
await
agent
.
connections
.
getById
(
request
.
connectionId
as
string
);
notifications
.
push
({
key
:
request
.
id
,
proofRequest
:
request
,
connection
:
connection
});
}
return
notifications
.
sort
((
a
,
b
)
=>
{
const
aCreatedAt
=
a
.
credentialOffer
?.
createdAt
||
a
.
proofRequest
?.
createdAt
as
Date
;
const
bCreatedAt
=
b
.
credentialOffer
?.
createdAt
||
b
.
proofRequest
?.
createdAt
as
Date
;
return
new
Date
(
bCreatedAt
).
getTime
()
-
new
Date
(
aCreatedAt
).
getTime
();
});
};
This diff is collapsed.
Click to expand it.
todo
deleted
100644 → 0
+
0
−
22
View file @
a1e52480
ConnectionInvitation
CredentialDetails
CredentialOffer
ListCredentials
Notifications
ProofRequest
Scan
Import Wallet Select Wallet does not work (For some reason android does not want to show file selector)
Export Wallet - Does not have access to write files
SealDetailsInfo - issue on chain component. First two steps displays as broken
App is crashed after pin change
Wallet does not work at all after pin change
SCAN issue. it should display accept connection screen, but actually it do it automatically
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