Skip to content

Commit 4107aee

Browse files
committed
chore: trying to merge json ld changes with current 0.5.6
Signed-off-by: ryankoch13 <[email protected]>
2 parents 0952fca + 2a10e10 commit 4107aee

File tree

15 files changed

+10035
-96
lines changed

15 files changed

+10035
-96
lines changed

packages/anoncreds/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"dependencies": {
2929
"@astronautlabs/jsonpath": "^1.1.2",
30-
"@credo-ts/core": "workspace:*",
30+
"@credo-ts/core": "file:./../core",
3131
"@sphereon/pex-models": "^2.2.4",
3232
"big-integer": "^1.6.51",
3333
"bn.js": "^5.2.1",

packages/anoncreds/src/utils/w3cAnonCredsUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ export function getW3cRecordAnonCredsTags(options: {
222222
...((isIndyDid(issuerId) || isUnqualifiedIndyDid(issuerId)) && {
223223
anonCredsUnqualifiedIssuerId: getUnQualifiedDidIndyDid(issuerId),
224224
anonCredsUnqualifiedCredentialDefinitionId: getUnQualifiedDidIndyDid(credentialDefinitionId),
225-
anonCredsUnqualifiedSchemaId: getUnQualifiedDidIndyDid(schemaId),
225+
anonCredsUnqualifiedSchemaId: getUnQualifiedDidIndyDid(issuerId),
226226
anonCredsUnqualifiedSchemaIssuerId: getUnQualifiedDidIndyDid(schema.issuerId),
227227
anonCredsUnqualifiedRevocationRegistryId: revocationRegistryId
228228
? getUnQualifiedDidIndyDid(revocationRegistryId)

packages/core/src/modules/connections/DidExchangeProtocol.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -504,10 +504,13 @@ export class DidExchangeProtocol {
504504
message: DidExchangeRequestMessage | DidExchangeResponseMessage,
505505
invitationKeysBase58: string[] = []
506506
) {
507-
// The only supported case where we expect to receive a did-document attachment is did:peer algo 1
508-
return isDid(message.did, 'peer') && getNumAlgoFromPeerDid(message.did) === PeerDidNumAlgo.GenesisDoc
509-
? this.extractAttachedDidDocument(agentContext, message, invitationKeysBase58)
510-
: this.extractResolvableDidDocument(agentContext, message, invitationKeysBase58)
507+
// Not all agents use didRotate yet, some may still send a didDoc attach with various did types
508+
// we should check if the didDoc attach is there and if not require that the didRotate be present
509+
if (message.didDoc) {
510+
return this.extractAttachedDidDocument(agentContext, message, invitationKeysBase58)
511+
} else {
512+
return this.extractResolvableDidDocument(agentContext, message, invitationKeysBase58)
513+
}
511514
}
512515

513516
/**
@@ -522,11 +525,11 @@ export class DidExchangeProtocol {
522525
// Validate did-rotate attachment in case of DID Exchange response
523526
if (message instanceof DidExchangeResponseMessage) {
524527
const didRotateAttachment = message.didRotate
525-
526528
if (!didRotateAttachment) {
527-
throw new DidExchangeProblemReportError('DID Rotate attachment is missing.', {
528-
problemCode: DidExchangeProblemReportReason.ResponseNotAccepted,
529-
})
529+
throw new DidExchangeProblemReportError(
530+
'Either a DID Rotate attachment or a didDoc attachment must be provided to make a secure connection',
531+
{ problemCode: DidExchangeProblemReportReason.ResponseNotAccepted }
532+
)
530533
}
531534

532535
const jws = didRotateAttachment.data.jws

packages/core/src/modules/credentials/protocol/v2/messages/V2OfferCredentialMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export class V2OfferCredentialMessage extends AgentMessage {
5858

5959
@Expose({ name: 'credential_preview' })
6060
@Type(() => V2CredentialPreview)
61+
@IsOptional()
6162
@ValidateNested()
6263
@IsInstance(V2CredentialPreview)
6364
public credentialPreview?: V2CredentialPreview

packages/core/src/modules/dids/domain/verificationMethod/Bls12381G1Key2020.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ export function isBls12381G1Key2020(verificationMethod: VerificationMethod): ver
3232
* Get a key from a Bls12381G1Key2020 verification method.
3333
*/
3434
export function getKeyFromBls12381G1Key2020(verificationMethod: Bls12381G1Key2020) {
35-
if (!verificationMethod.publicKeyBase58) {
36-
throw new CredoError('verification method is missing publicKeyBase58')
35+
if (verificationMethod.publicKeyBase58) {
36+
return Key.fromPublicKeyBase58(verificationMethod.publicKeyBase58, KeyType.Bls12381g1)
3737
}
3838

39-
return Key.fromPublicKeyBase58(verificationMethod.publicKeyBase58, KeyType.Bls12381g1)
39+
throw new CredoError('verification method is missing publicKeyBase58')
4040
}

packages/core/src/modules/dids/domain/verificationMethod/Bls12381G2Key2020.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ export function isBls12381G2Key2020(verificationMethod: VerificationMethod): ver
3232
* Get a key from a Bls12381G2Key2020 verification method.
3333
*/
3434
export function getKeyFromBls12381G2Key2020(verificationMethod: Bls12381G2Key2020) {
35-
if (!verificationMethod.publicKeyBase58) {
36-
throw new CredoError('verification method is missing publicKeyBase58')
35+
if (verificationMethod.publicKeyBase58) {
36+
return Key.fromPublicKeyBase58(verificationMethod.publicKeyBase58, KeyType.Bls12381g2)
3737
}
3838

39-
return Key.fromPublicKeyBase58(verificationMethod.publicKeyBase58, KeyType.Bls12381g2)
39+
throw new CredoError('verification method is missing publicKeyBase58')
4040
}

packages/core/src/modules/dids/domain/verificationMethod/EcdsaSecp256k1VerificationKey2019.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ export function isEcdsaSecp256k1VerificationKey2019(
4343
* Get a key from a EcdsaSecp256k1VerificationKey2019 verification method.
4444
*/
4545
export function getKeyFromEcdsaSecp256k1VerificationKey2019(verificationMethod: EcdsaSecp256k1VerificationKey2019) {
46-
if (!verificationMethod.publicKeyBase58) {
47-
throw new CredoError('verification method is missing publicKeyBase58')
46+
if (verificationMethod.publicKeyBase58) {
47+
return Key.fromPublicKeyBase58(verificationMethod.publicKeyBase58, KeyType.K256)
4848
}
4949

50-
return Key.fromPublicKeyBase58(verificationMethod.publicKeyBase58, KeyType.K256)
50+
throw new CredoError('verification method is missing publicKeyBase58')
5151
}

packages/core/src/modules/dids/domain/verificationMethod/Ed25519VerificationKey2018.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ export function isEd25519VerificationKey2018(
3434
* Get a key from a Ed25519VerificationKey2018 verification method.
3535
*/
3636
export function getKeyFromEd25519VerificationKey2018(verificationMethod: Ed25519VerificationKey2018) {
37-
if (!verificationMethod.publicKeyBase58) {
38-
throw new CredoError('verification method is missing publicKeyBase58')
37+
if (verificationMethod.publicKeyBase58) {
38+
return Key.fromPublicKeyBase58(verificationMethod.publicKeyBase58, KeyType.Ed25519)
3939
}
4040

41-
return Key.fromPublicKeyBase58(verificationMethod.publicKeyBase58, KeyType.Ed25519)
41+
throw new CredoError('verification method is missing publicKeyBase58')
4242
}

packages/core/src/modules/dids/domain/verificationMethod/Multikey.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,20 @@ export function getMultikey({ did, key, verificationMethodId }: GetMultikeyOptio
3232
*/
3333
export function isMultikey(
3434
verificationMethod: VerificationMethod
35-
): verificationMethod is VerificationMethod & { type: 'Multikey' } {
35+
): verificationMethod is
36+
| (VerificationMethod & { type: 'Multikey' })
37+
| (VerificationMethod & { publicKeyMultibase: string }) {
3638
return verificationMethod.type === VERIFICATION_METHOD_TYPE_MULTIKEY
3739
}
3840

3941
/**
4042
* Get a key from a Multikey verification method.
4143
*/
42-
export function getKeyFromMultikey(verificationMethod: VerificationMethod & { type: 'Multikey' }) {
44+
export function getKeyFromMultikey(
45+
verificationMethod:
46+
| (VerificationMethod & { type: 'Multikey' })
47+
| (VerificationMethod & { publicKeyMultibase: string })
48+
) {
4349
if (!verificationMethod.publicKeyMultibase) {
4450
throw new CredoError(
4551
`Missing publicKeyMultibase on verification method with type ${VERIFICATION_METHOD_TYPE_MULTIKEY}`

packages/core/src/modules/dids/domain/verificationMethod/X25519KeyAgreementKey2019.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,17 @@ export function isX25519KeyAgreementKey2019(
3434
* Get a key from a X25519KeyAgreementKey2019 verification method.
3535
*/
3636
export function getKeyFromX25519KeyAgreementKey2019(verificationMethod: X25519KeyAgreementKey2019) {
37-
if (!verificationMethod.publicKeyBase58) {
38-
throw new CredoError('verification method is missing publicKeyBase58')
37+
if (verificationMethod.publicKeyBase58) {
38+
return Key.fromPublicKeyBase58(verificationMethod.publicKeyBase58, KeyType.X25519)
39+
}
40+
if (verificationMethod.publicKeyMultibase) {
41+
const key = Key.fromFingerprint(verificationMethod.publicKeyMultibase)
42+
if (key.keyType === KeyType.X25519) return key
43+
else
44+
throw new CredoError(
45+
`Unexpected key type from resolving multibase encoding, key type was ${key.keyType} but expected ${KeyType.X25519}`
46+
)
3947
}
4048

41-
return Key.fromPublicKeyBase58(verificationMethod.publicKeyBase58, KeyType.X25519)
49+
throw new CredoError('verification method is missing publicKeyBase58 or publicKeyMultibase')
4250
}

0 commit comments

Comments
 (0)