Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes made to upstream since fork #4

Open
wants to merge 25 commits into
base: upstream
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7fc397c
Linked and built package
theblockstalk Sep 23, 2022
b18f972
createVerifiableCredentialJwt() takes issuer array
theblockstalk Sep 26, 2022
b6ebaff
Fixed type issues
theblockstalk Sep 26, 2022
aedc8ee
throw error on unfinished function
theblockstalk Sep 26, 2022
27a6bf1
sending expiration in options
theblockstalk Sep 30, 2022
fb7e9a7
Merge pull request #1 from Tonomy-Foundation/feature/3-issue-testing
theblockstalk Oct 4, 2022
e9055fa
change naming
Rebal17 Nov 1, 2022
55c8960
fix package json
Rebal17 Nov 12, 2022
514e765
Merge pull request #2 from Tonomy-Foundation/feature/14-verify-2-thre…
theblockstalk Nov 15, 2022
e9f5916
Changed to relative did-resolver
theblockstalk Nov 16, 2022
5ef572b
fixed DEFAULT_VC_TYPE
theblockstalk Nov 21, 2022
31b67aa
Merge pull request #3 from Tonomy-Foundation/feature/13-delegated-acc…
theblockstalk Nov 23, 2022
3a16d75
edit package settings
Rebal17 Dec 17, 2022
9c3932e
updated to use @tonomy package names
theblockstalk Feb 4, 2023
7108e22
updated references to tonomy packages
theblockstalk Feb 7, 2023
06f4d48
updated did-jwt version
theblockstalk Feb 7, 2023
a3aa6e7
added package to readme
theblockstalk Feb 7, 2023
7d9703c
bumped minor version
theblockstalk Feb 7, 2023
b565cc9
v3.1.3
theblockstalk Feb 7, 2023
41455fb
feat: using DIF did-resolver and did-jwt
theblockstalk May 3, 2023
20b6d17
Merge branch 'upstream'
theblockstalk May 3, 2023
a3939b7
docs: cleaned up docs and package.json
theblockstalk May 3, 2023
b5a5a70
refactor: removes unimplemented function
theblockstalk May 8, 2023
cc9c87f
Merge branch 'upstream'
theblockstalk May 8, 2023
da59ff5
chore: fixed lint error
theblockstalk May 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
],
"license": "ISC",
"dependencies": {
"did-jwt": "^7.0.0",
"did-resolver": "^4.0.0"
"did-jwt": "^7.1.0",
"did-resolver": "^4.1.0"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -83,4 +83,4 @@
"engines": {
"node": ">=18"
}
}
}
44 changes: 31 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createJWT, verifyJWT } from 'did-jwt'
import { createJWT, createMultisignatureJWT, verifyJWT } from 'did-jwt'
import { Resolvable } from 'did-resolver'
import * as validators from './validators'
import {
Expand Down Expand Up @@ -79,26 +79,44 @@ export {
*/
export async function createVerifiableCredentialJwt(
payload: JwtCredentialPayload | CredentialPayload,
issuer: Issuer,
issuer: Issuer | Issuer[],
options: CreateCredentialOptions = {}
): Promise<JWT> {
const parsedPayload: JwtCredentialPayload = {
iat: undefined,
...transformCredentialInput(payload, options.removeOriginalFields),
}
validateJwtCredentialPayload(parsedPayload)
return createJWT(
parsedPayload,
{
...options,
issuer: issuer.did || parsedPayload.iss || '',
signer: issuer.signer,
},
{
...options.header,
alg: issuer.alg || options.header?.alg || JWT_ALG,

if (!Array.isArray(issuer)) {
return createJWT(
parsedPayload,
{
...options,
issuer: issuer.did || parsedPayload.iss || '',
signer: issuer.signer,
},
{
...options.header,
alg: issuer.alg || options.header?.alg || JWT_ALG,
}
)
} else {
const did = issuer[0].did
const issuers = []
for (const iss of issuer) {
if (iss.did !== did) {
throw new Error('All issuers must be the same did to comply with the Verifiable Conditions spec')
}
issuers.push({
issuer: iss.did || parsedPayload.iss || '',
signer: iss.signer,
alg: iss.alg || options.header?.alg || JWT_ALG,
})
}
)

return createMultisignatureJWT(parsedPayload, { ...options }, issuers)
}
}

/**
Expand Down
Loading