Skip to content

Commit 9ba1950

Browse files
authored
feat: Implement sd+jwt for issuance and verification flows with cloud agent (#228)
Signed-off-by: Javier Ribó <[email protected]> BREAKING CHANGE: Pollux instance now requires to have Apollo first constructor parameter (used internally) Deprecated internal function processJWTCredential, processAnoncredsCredential and extractCredentialFormatFromMessage. Internally, in order to process any type of credential offer just call pollux.processCredentialOffer instead. In order to extract the credentialFormat from a DIDComm message if available, use message.credentialFormat (will return known CredentialType or unknown) In order to extract the payload of whatever DIDComm message, use message.payload which will decode it into the right object instance JWT class now needs apollo and castor in constructor as they now instantiate from JWTCore (used internally) Derivable Private key is not deriving using the derivationPath as a string not the DerivationPath class (used internally)
1 parent 6bcf0ea commit 9ba1950

File tree

81 files changed

+3453
-1652
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+3453
-1652
lines changed

Diff for: .eslintrc

+13-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
],
1919
"plugins": [
2020
"@typescript-eslint",
21-
"react"
21+
"react",
22+
"unused-imports"
2223
],
2324
"extends": [
2425
"eslint:recommended",
@@ -34,10 +35,18 @@
3435
"@typescript-eslint/no-explicit-any": "off",
3536
"@typescript-eslint/no-var-requires": "off",
3637
"@typescript-eslint/no-namespace": "off",
37-
"no-unused-vars": "off",
3838
"@typescript-eslint/no-unused-vars": [
39-
"warn"
40-
]
39+
"warn",
40+
{
41+
"vars": "all",
42+
"varsIgnorePattern": "^_",
43+
"args": "after-used",
44+
"argsIgnorePattern": "^_"
45+
}
46+
],
47+
"no-unused-vars": "off",
48+
"unused-imports/no-unused-imports": "error",
49+
"unused-imports/no-unused-vars": "off"
4150
},
4251
"settings": {
4352
"react": {

Diff for: .husky/pre-commit

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx eslint . --fix

Diff for: demos/next/src/components/Message.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ export function Message({ message }) {
484484
if (SDK.isPresentationDefinitionRequestType(requestPresentation, SDK.Domain.CredentialType.AnonCreds)) {
485485
const credentials = app.credentials;
486486
const fields =
487-
Object.keys(requestPresentation.requested_attributes).reduce(
487+
Object.keys(requestPresentation.requested_attributes || []).reduce(
488488
(_, key) => ([
489489
..._,
490490
{

Diff for: demos/next/src/pages/credentials.tsx

+16-29
Original file line numberDiff line numberDiff line change
@@ -28,38 +28,25 @@ function Credential(props) {
2828
const [claims, setClaims] = useState(protect(credential));
2929

3030
function revealAttributes(credential: SDK.Domain.Credential, claimIndex: number, field: string) {
31-
if (credential.credentialType === SDK.Domain.CredentialType.JWT) {
32-
const revealed = claims.map((claim, index) => {
33-
if (claimIndex === index) {
34-
return {
35-
...claim,
36-
[field]: credential.claims[index][field]
37-
}
38-
}
39-
return claim
40-
})
41-
setClaims(revealed)
42-
} else {
43-
app.agent.instance?.pluto.getLinkSecret()
44-
.then((linkSecret) => {
45-
app.agent.instance?.revealCredentialFields(
46-
credential,
47-
[field],
48-
linkSecret!.secret
49-
).then((revealedFields) => {
50-
const revealed = claims.map((claim, index) => {
51-
if (claimIndex === index) {
52-
return {
53-
...claim,
54-
[field]: revealedFields[field]
55-
}
31+
app.agent.instance?.pluto.getLinkSecret()
32+
.then((linkSecret) => {
33+
app.agent.instance?.revealCredentialFields(
34+
credential,
35+
[field],
36+
linkSecret!.secret
37+
).then((revealedFields) => {
38+
const revealed = claims.map((claim, index) => {
39+
if (claimIndex === index) {
40+
return {
41+
...claim,
42+
[field]: revealedFields[field]
5643
}
57-
return claim
58-
})
59-
setClaims(revealed)
44+
}
45+
return claim
6046
})
47+
setClaims(revealed)
6148
})
62-
}
49+
})
6350
}
6451

6552
return <div className="w-full mt-5 p-6 bg-white border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700">

Diff for: demos/next/src/reducers/app.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { v4 as uuidv4 } from "uuid";
44
import { DBPreload, Message, Credential } from "@/actions/types";
55
import { acceptCredentialOffer, acceptPresentationRequest, connectDatabase, initAgent, rejectCredentialOffer, sendMessage, startAgent, stopAgent } from "../actions";
66

7-
const defaultMediatorDID = "did:peer:2.Ez6LSghwSE437wnDE1pt3X6hVDUQzSjsHzinpX3XFvMjRAm7y.Vz6Mkhh1e5CEYYq6JBUcTZ6Cp2ranCWRrv7Yax3Le4N59R6dd.SeyJ0IjoiZG0iLCJzIjp7InVyaSI6Imh0dHBzOi8vc2l0LXByaXNtLW1lZGlhdG9yLmF0YWxhcHJpc20uaW8iLCJhIjpbImRpZGNvbW0vdjIiXX19.SeyJ0IjoiZG0iLCJzIjp7InVyaSI6IndzczovL3NpdC1wcmlzbS1tZWRpYXRvci5hdGFsYXByaXNtLmlvL3dzIiwiYSI6WyJkaWRjb21tL3YyIl19fQ";
7+
const defaultMediatorDID = "did:peer:2.Ez6LSghwSE437wnDE1pt3X6hVDUQzSjsHzinpX3XFvMjRAm7y.Vz6Mkhh1e5CEYYq6JBUcTZ6Cp2ranCWRrv7Yax3Le4N59R6dd.SeyJ0IjoiZG0iLCJzIjp7InVyaSI6Imh0dHA6Ly8xOTIuMTY4LjEuNDQ6ODA4MCIsImEiOlsiZGlkY29tbS92MiJdfX0.SeyJ0IjoiZG0iLCJzIjp7InVyaSI6IndzOi8vMTkyLjE2OC4xLjQ0OjgwODAvd3MiLCJhIjpbImRpZGNvbW0vdjIiXX19";
88

99
class TraceableError extends Error {
1010

@@ -137,7 +137,9 @@ const appSlice = createSlice({
137137
...action.meta.arg.message,
138138
isAnswering: true,
139139
hasAnswered: false,
140-
error: null
140+
error: null,
141+
safeBody: action.meta.arg.message.safeBody,
142+
credentialFormat: action.meta.arg.message.credentialFormat
141143
})
142144
})
143145

0 commit comments

Comments
 (0)