Skip to content

Commit

Permalink
Use W3c instead of capitalized W3C
Browse files Browse the repository at this point in the history
Signed-off-by: artem.ivanov <[email protected]>
  • Loading branch information
Artemkaaas committed Dec 11, 2023
1 parent 2b903fe commit c436949
Show file tree
Hide file tree
Showing 15 changed files with 186 additions and 186 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ export class NodeJSAnoncreds implements Anoncreds {
return new ObjectHandle(handleReturnPointer<number>(ret))
}

public createW3CCredentialOffer(options: {
public createW3cCredentialOffer(options: {
schemaId: string
credentialDefinitionId: string
keyCorrectnessProof: ObjectHandle
Expand All @@ -646,7 +646,7 @@ export class NodeJSAnoncreds implements Anoncreds {
return new ObjectHandle(handleReturnPointer<number>(ret))
}

public createW3CCredentialRequest(options: {
public createW3cCredentialRequest(options: {
entropy?: string
proverDid?: string
credentialDefinition: ObjectHandle
Expand Down Expand Up @@ -678,7 +678,7 @@ export class NodeJSAnoncreds implements Anoncreds {
}
}

public createW3CCredential(options: {
public createW3cCredential(options: {
credentialDefinition: ObjectHandle
credentialDefinitionPrivate: ObjectHandle
credentialOffer: ObjectHandle
Expand Down Expand Up @@ -730,7 +730,7 @@ export class NodeJSAnoncreds implements Anoncreds {
return new ObjectHandle(handleReturnPointer<number>(credentialPtr))
}

public processW3CCredential(options: {
public processW3cCredential(options: {
credential: ObjectHandle
credentialRequestMetadata: ObjectHandle
linkSecret: string
Expand All @@ -754,7 +754,7 @@ export class NodeJSAnoncreds implements Anoncreds {
return new ObjectHandle(handleReturnPointer<number>(ret))
}

public createW3CPresentation(options: {
public createW3cPresentation(options: {
presentationRequest: ObjectHandle
credentials: NativeCredentialEntry[]
credentialsProve: NativeCredentialProve[]
Expand Down Expand Up @@ -842,7 +842,7 @@ export class NodeJSAnoncreds implements Anoncreds {
return new ObjectHandle(handleReturnPointer<number>(ret))
}

public verifyW3CPresentation(options: {
public verifyW3cPresentation(options: {
presentation: ObjectHandle
presentationRequest: ObjectHandle
schemas: ObjectHandle[]
Expand Down Expand Up @@ -907,7 +907,7 @@ export class NodeJSAnoncreds implements Anoncreds {
return Boolean(handleReturnPointer<number>(ret))
}

public credentialToW3C(options: { objectHandle: ObjectHandle; credentialDefinition: ObjectHandle }): ObjectHandle {
public credentialToW3c(options: { objectHandle: ObjectHandle; credentialDefinition: ObjectHandle }): ObjectHandle {
const { objectHandle, credentialDefinition } = serializeArguments(options)

const ret = allocatePointer()
Expand All @@ -918,7 +918,7 @@ export class NodeJSAnoncreds implements Anoncreds {
return new ObjectHandle(handleReturnPointer<number>(ret))
}

public credentialFromW3C(options: { objectHandle: ObjectHandle }): ObjectHandle {
public credentialFromW3c(options: { objectHandle: ObjectHandle }): ObjectHandle {
const { objectHandle } = serializeArguments(options)

const ret = allocatePointer()
Expand Down Expand Up @@ -990,12 +990,12 @@ export class NodeJSAnoncreds implements Anoncreds {
return new ObjectHandle(handleReturnPointer<number>(ret))
}

public w3cCredentialAddType(options: { objectHandle: ObjectHandle; type_: string }): ObjectHandle {
const { objectHandle, type_ } = serializeArguments(options)
public w3cCredentialAddType(options: { objectHandle: ObjectHandle; type: string }): ObjectHandle {
const { objectHandle, type } = serializeArguments(options)

const ret = allocatePointer()

this.nativeAnoncreds.anoncreds_w3c_credential_add_type(objectHandle, type_, ret)
this.nativeAnoncreds.anoncreds_w3c_credential_add_type(objectHandle, type, ret)
this.handleError()

return new ObjectHandle(handleReturnPointer<number>(ret))
Expand Down
50 changes: 25 additions & 25 deletions wrappers/javascript/packages/anoncreds-nodejs/tests/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import {
RevocationRegistryDefinition,
RevocationStatusList,
Schema,
W3CCredential,
W3CCredentialOffer,
W3CCredentialRequest,
W3CPresentation
W3cCredential,
W3cCredentialOffer,
W3cCredentialRequest,
W3cPresentation
} from '@hyperledger/anoncreds-shared'

import { setup } from './utils'
Expand Down Expand Up @@ -608,7 +608,7 @@ describe('API W3C', () => {
timestamp: timeCreateRevStatusList
})

const credentialOffer = W3CCredentialOffer.create({
const credentialOffer = W3cCredentialOffer.create({
schemaId: 'mock:uri',
credentialDefinitionId: 'mock:uri',
keyCorrectnessProof
Expand All @@ -617,15 +617,15 @@ describe('API W3C', () => {
const linkSecret = LinkSecret.create()
const linkSecretId = 'link secret id'

const { credentialRequestMetadata, credentialRequest } = W3CCredentialRequest.create({
const { credentialRequestMetadata, credentialRequest } = W3cCredentialRequest.create({
entropy: 'entropy',
credentialDefinition,
linkSecret,
linkSecretId,
credentialOffer
})

const credential = W3CCredential.create({
const credential = W3cCredential.create({
credentialDefinition,
credentialDefinitionPrivate,
credentialOffer,
Expand All @@ -643,19 +643,19 @@ describe('API W3C', () => {
expect('mock:uri').toEqual(legacyCredential.schemaId)
expect('mock:uri').toEqual(legacyCredential.credentialDefinitionId)

const legacyCredentialFrom = Credential.fromW3C({ credential })
const legacyCredentialFrom = Credential.fromW3c({ credential })
expect('mock:uri').toEqual(legacyCredentialFrom.schemaId)
expect('mock:uri').toEqual(legacyCredentialFrom.credentialDefinitionId)

const w3cCredential = W3CCredential.fromLegacy({ credential: legacyCredential, credentialDefinition })
const w3cCredential = W3cCredential.fromLegacy({ credential: legacyCredential, credentialDefinition })
expect('mock:uri').toEqual(w3cCredential.schemaId)
expect('mock:uri').toEqual(w3cCredential.credentialDefinitionId)

const convertedW3CCredential = legacyCredential.toW3C({ credentialDefinition })
expect('mock:uri').toEqual(convertedW3CCredential.schemaId)
expect('mock:uri').toEqual(convertedW3CCredential.credentialDefinitionId)
const convertedW3cCredential = legacyCredential.toW3c({ credentialDefinition })
expect('mock:uri').toEqual(convertedW3cCredential.schemaId)
expect('mock:uri').toEqual(convertedW3cCredential.credentialDefinitionId)

convertedW3CCredential.addNonAnonCredsIntegrityProof({
convertedW3cCredential.addNonAnonCredsIntegrityProof({
type: 'Ed25519Signature2020',
created: '2021-11-13T18:19:39Z',
verificationMethod: 'did:sov:3avoBCqDMFHFaKUHug9s8W#key-1',
Expand All @@ -666,14 +666,14 @@ describe('API W3C', () => {
const id = 'http://example.com/credentials/3732'
const subjectId = 'did:example:ebfeb1f712ebc6f1c276e12ec21'

convertedW3CCredential.setId(id)
convertedW3CCredential.setSubjectId(subjectId)
convertedW3CCredential.addContext('https://www.w3.org/2018/credentials/examples/v1')
convertedW3CCredential.addType('UniversityDegreeCredential')
const convertedW3CCredentialJson = convertedW3CCredential.toJson()
convertedW3cCredential.setId(id)
convertedW3cCredential.setSubjectId(subjectId)
convertedW3cCredential.addContext('https://www.w3.org/2018/credentials/examples/v1')
convertedW3cCredential.addType('UniversityDegreeCredential')
const convertedW3cCredentialJson = convertedW3cCredential.toJson()

expect(id).toEqual(convertedW3CCredentialJson.id)
expect(subjectId).toEqual(convertedW3CCredentialJson.credentialSubject.id)
expect(id).toEqual(convertedW3cCredentialJson.id)
expect(subjectId).toEqual(convertedW3cCredentialJson.credentialSubject.id)

const credentialReceived = credential.process({
credentialDefinition,
Expand All @@ -691,7 +691,7 @@ describe('API W3C', () => {
tailsPath
})

const presentation = W3CPresentation.create({
const presentation = W3cPresentation.create({
presentationRequest,
credentials: [
{
Expand Down Expand Up @@ -773,7 +773,7 @@ describe('API W3C', () => {
tag: 'TAG'
})

const credentialOffer = W3CCredentialOffer.create({
const credentialOffer = W3cCredentialOffer.create({
schemaId: 'mock:uri',
credentialDefinitionId: 'mock:uri',
keyCorrectnessProof
Expand All @@ -782,15 +782,15 @@ describe('API W3C', () => {
const linkSecret = LinkSecret.create()
const linkSecretId = 'link secret id'

const { credentialRequestMetadata, credentialRequest } = W3CCredentialRequest.create({
const { credentialRequestMetadata, credentialRequest } = W3cCredentialRequest.create({
entropy: 'entropy',
credentialDefinition,
linkSecret,
linkSecretId,
credentialOffer
})

const credential = W3CCredential.create({
const credential = W3cCredential.create({
credentialDefinition,
credentialDefinitionPrivate,
credentialOffer,
Expand Down Expand Up @@ -824,7 +824,7 @@ describe('API W3C', () => {
}
})

const presentation = W3CPresentation.create({
const presentation = W3cPresentation.create({
presentationRequest,
credentials: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ describe('bindings', () => {
timestamp: timeCreateRevStatusList
})

const credentialOffer = anoncreds.createW3CCredentialOffer({
const credentialOffer = anoncreds.createW3cCredentialOffer({
schemaId: 'mock:uri',
credentialDefinitionId: 'mock:uri',
keyCorrectnessProof
Expand All @@ -383,15 +383,15 @@ describe('bindings', () => {
const linkSecret = anoncreds.createLinkSecret()
const linkSecretId = 'link secret id'

const { credentialRequestMetadata, credentialRequest } = anoncreds.createW3CCredentialRequest({
const { credentialRequestMetadata, credentialRequest } = anoncreds.createW3cCredentialRequest({
entropy: ENTROPY,
credentialDefinition,
linkSecret,
linkSecretId,
credentialOffer
})

const credential = anoncreds.createW3CCredential({
const credential = anoncreds.createW3cCredential({
credentialDefinition,
credentialDefinitionPrivate,
credentialOffer,
Expand All @@ -406,7 +406,7 @@ describe('bindings', () => {
encoding: undefined
})

const credReceived = anoncreds.processW3CCredential({
const credReceived = anoncreds.processW3cCredential({
credential,
credentialDefinition,
credentialRequestMetadata,
Expand Down Expand Up @@ -672,7 +672,7 @@ describe('bindings', () => {
timestamp: timeCreateRevStatusList
})

const credentialOffer = anoncreds.createW3CCredentialOffer({
const credentialOffer = anoncreds.createW3cCredentialOffer({
schemaId: 'mock:uri',
credentialDefinitionId: 'mock:uri',
keyCorrectnessProof
Expand All @@ -681,15 +681,15 @@ describe('bindings', () => {
const linkSecret = anoncreds.createLinkSecret()
const linkSecretId = 'link secret id'

const { credentialRequestMetadata, credentialRequest } = anoncreds.createW3CCredentialRequest({
const { credentialRequestMetadata, credentialRequest } = anoncreds.createW3cCredentialRequest({
entropy: ENTROPY,
credentialDefinition,
linkSecret,
linkSecretId,
credentialOffer
})

const credential = anoncreds.createW3CCredential({
const credential = anoncreds.createW3cCredential({
credentialDefinition,
credentialDefinitionPrivate,
credentialOffer,
Expand All @@ -704,7 +704,7 @@ describe('bindings', () => {
encoding: undefined
})

const credentialReceived = anoncreds.processW3CCredential({
const credentialReceived = anoncreds.processW3cCredential({
credential,
credentialDefinition,
credentialRequestMetadata,
Expand All @@ -726,7 +726,7 @@ describe('bindings', () => {
tailsPath
})

const presentation = anoncreds.createW3CPresentation({
const presentation = anoncreds.createW3cPresentation({
presentationRequest,
credentials: [
{
Expand Down Expand Up @@ -762,7 +762,7 @@ describe('bindings', () => {

expect(presentation.handle).toStrictEqual(expect.any(Number))

const verify = anoncreds.verifyW3CPresentation({
const verify = anoncreds.verifyW3cPresentation({
presentation,
presentationRequest,
schemas: [schemaObj],
Expand Down Expand Up @@ -944,7 +944,7 @@ describe('bindings', () => {
tag: 'TAG'
})

const credentialOffer = anoncreds.createW3CCredentialOffer({
const credentialOffer = anoncreds.createW3cCredentialOffer({
schemaId: 'mock:uri',
credentialDefinitionId: 'mock:uri',
keyCorrectnessProof
Expand All @@ -953,23 +953,23 @@ describe('bindings', () => {
const linkSecret = anoncreds.createLinkSecret()
const linkSecretId = 'link secret id'

const { credentialRequestMetadata, credentialRequest } = anoncreds.createW3CCredentialRequest({
const { credentialRequestMetadata, credentialRequest } = anoncreds.createW3cCredentialRequest({
entropy: ENTROPY,
credentialDefinition,
linkSecret,
linkSecretId,
credentialOffer
})

const credential = anoncreds.createW3CCredential({
const credential = anoncreds.createW3cCredential({
credentialDefinition,
credentialDefinitionPrivate,
credentialOffer,
credentialRequest,
attributeRawValues: { name: 'Alex', height: '175', age: '28', sex: 'male' }
})

const credReceived = anoncreds.processW3CCredential({
const credReceived = anoncreds.processW3cCredential({
credential,
credentialDefinition,
credentialRequestMetadata,
Expand Down Expand Up @@ -998,7 +998,7 @@ describe('bindings', () => {
})
})

const presentation = anoncreds.createW3CPresentation({
const presentation = anoncreds.createW3cPresentation({
presentationRequest,
credentials: [
{
Expand Down Expand Up @@ -1032,7 +1032,7 @@ describe('bindings', () => {

expect(presentation.handle).toStrictEqual(expect.any(Number))

const verify = anoncreds.verifyW3CPresentation({
const verify = anoncreds.verifyW3cPresentation({
presentation,
presentationRequest,
schemas: [schemaObj],
Expand Down
Loading

0 comments on commit c436949

Please sign in to comment.