From c4369493aa7daed0535bdda3908b6145a484472e Mon Sep 17 00:00:00 2001 From: "artem.ivanov" Date: Mon, 11 Dec 2023 12:00:24 +0300 Subject: [PATCH] Use `W3c` instead of capitalized `W3C` Signed-off-by: artem.ivanov --- .../anoncreds-nodejs/src/NodeJSAnoncreds.ts | 22 ++++---- .../anoncreds-nodejs/tests/api.test.ts | 50 +++++++++---------- .../anoncreds-nodejs/tests/bindings.test.ts | 32 ++++++------ .../anoncreds-react-native/cpp/HostObject.cpp | 24 ++++----- .../anoncreds-react-native/cpp/anoncreds.cpp | 20 ++++---- .../anoncreds-react-native/cpp/anoncreds.h | 18 +++---- .../src/NativeBindings.ts | 18 +++---- .../src/ReactNativeAnoncreds.ts | 34 ++++++------- .../anoncreds-shared/src/Anoncreds.ts | 18 +++---- .../anoncreds-shared/src/api/Credential.ts | 18 +++---- .../{W3CCredential.ts => W3cCredential.ts} | 48 +++++++++--------- ...edentialOffer.ts => W3cCredentialOffer.ts} | 12 ++--- ...tialRequest.ts => W3cCredentialRequest.ts} | 20 ++++---- ...{W3CPresentation.ts => W3cPresentation.ts} | 30 +++++------ .../anoncreds-shared/src/api/index.ts | 8 +-- 15 files changed, 186 insertions(+), 186 deletions(-) rename wrappers/javascript/packages/anoncreds-shared/src/api/{W3CCredential.ts => W3cCredential.ts} (84%) rename wrappers/javascript/packages/anoncreds-shared/src/api/{W3CCredentialOffer.ts => W3cCredentialOffer.ts} (76%) rename wrappers/javascript/packages/anoncreds-shared/src/api/{W3CCredentialRequest.ts => W3cCredentialRequest.ts} (73%) rename wrappers/javascript/packages/anoncreds-shared/src/api/{W3CPresentation.ts => W3cPresentation.ts} (88%) diff --git a/wrappers/javascript/packages/anoncreds-nodejs/src/NodeJSAnoncreds.ts b/wrappers/javascript/packages/anoncreds-nodejs/src/NodeJSAnoncreds.ts index 5f25e62c..1f4e36d4 100644 --- a/wrappers/javascript/packages/anoncreds-nodejs/src/NodeJSAnoncreds.ts +++ b/wrappers/javascript/packages/anoncreds-nodejs/src/NodeJSAnoncreds.ts @@ -627,7 +627,7 @@ export class NodeJSAnoncreds implements Anoncreds { return new ObjectHandle(handleReturnPointer(ret)) } - public createW3CCredentialOffer(options: { + public createW3cCredentialOffer(options: { schemaId: string credentialDefinitionId: string keyCorrectnessProof: ObjectHandle @@ -646,7 +646,7 @@ export class NodeJSAnoncreds implements Anoncreds { return new ObjectHandle(handleReturnPointer(ret)) } - public createW3CCredentialRequest(options: { + public createW3cCredentialRequest(options: { entropy?: string proverDid?: string credentialDefinition: ObjectHandle @@ -678,7 +678,7 @@ export class NodeJSAnoncreds implements Anoncreds { } } - public createW3CCredential(options: { + public createW3cCredential(options: { credentialDefinition: ObjectHandle credentialDefinitionPrivate: ObjectHandle credentialOffer: ObjectHandle @@ -730,7 +730,7 @@ export class NodeJSAnoncreds implements Anoncreds { return new ObjectHandle(handleReturnPointer(credentialPtr)) } - public processW3CCredential(options: { + public processW3cCredential(options: { credential: ObjectHandle credentialRequestMetadata: ObjectHandle linkSecret: string @@ -754,7 +754,7 @@ export class NodeJSAnoncreds implements Anoncreds { return new ObjectHandle(handleReturnPointer(ret)) } - public createW3CPresentation(options: { + public createW3cPresentation(options: { presentationRequest: ObjectHandle credentials: NativeCredentialEntry[] credentialsProve: NativeCredentialProve[] @@ -842,7 +842,7 @@ export class NodeJSAnoncreds implements Anoncreds { return new ObjectHandle(handleReturnPointer(ret)) } - public verifyW3CPresentation(options: { + public verifyW3cPresentation(options: { presentation: ObjectHandle presentationRequest: ObjectHandle schemas: ObjectHandle[] @@ -907,7 +907,7 @@ export class NodeJSAnoncreds implements Anoncreds { return Boolean(handleReturnPointer(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() @@ -918,7 +918,7 @@ export class NodeJSAnoncreds implements Anoncreds { return new ObjectHandle(handleReturnPointer(ret)) } - public credentialFromW3C(options: { objectHandle: ObjectHandle }): ObjectHandle { + public credentialFromW3c(options: { objectHandle: ObjectHandle }): ObjectHandle { const { objectHandle } = serializeArguments(options) const ret = allocatePointer() @@ -990,12 +990,12 @@ export class NodeJSAnoncreds implements Anoncreds { return new ObjectHandle(handleReturnPointer(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(ret)) diff --git a/wrappers/javascript/packages/anoncreds-nodejs/tests/api.test.ts b/wrappers/javascript/packages/anoncreds-nodejs/tests/api.test.ts index c9f5b642..2b44a40d 100644 --- a/wrappers/javascript/packages/anoncreds-nodejs/tests/api.test.ts +++ b/wrappers/javascript/packages/anoncreds-nodejs/tests/api.test.ts @@ -12,10 +12,10 @@ import { RevocationRegistryDefinition, RevocationStatusList, Schema, - W3CCredential, - W3CCredentialOffer, - W3CCredentialRequest, - W3CPresentation + W3cCredential, + W3cCredentialOffer, + W3cCredentialRequest, + W3cPresentation } from '@hyperledger/anoncreds-shared' import { setup } from './utils' @@ -608,7 +608,7 @@ describe('API W3C', () => { timestamp: timeCreateRevStatusList }) - const credentialOffer = W3CCredentialOffer.create({ + const credentialOffer = W3cCredentialOffer.create({ schemaId: 'mock:uri', credentialDefinitionId: 'mock:uri', keyCorrectnessProof @@ -617,7 +617,7 @@ 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, @@ -625,7 +625,7 @@ describe('API W3C', () => { credentialOffer }) - const credential = W3CCredential.create({ + const credential = W3cCredential.create({ credentialDefinition, credentialDefinitionPrivate, credentialOffer, @@ -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', @@ -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, @@ -691,7 +691,7 @@ describe('API W3C', () => { tailsPath }) - const presentation = W3CPresentation.create({ + const presentation = W3cPresentation.create({ presentationRequest, credentials: [ { @@ -773,7 +773,7 @@ describe('API W3C', () => { tag: 'TAG' }) - const credentialOffer = W3CCredentialOffer.create({ + const credentialOffer = W3cCredentialOffer.create({ schemaId: 'mock:uri', credentialDefinitionId: 'mock:uri', keyCorrectnessProof @@ -782,7 +782,7 @@ 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, @@ -790,7 +790,7 @@ describe('API W3C', () => { credentialOffer }) - const credential = W3CCredential.create({ + const credential = W3cCredential.create({ credentialDefinition, credentialDefinitionPrivate, credentialOffer, @@ -824,7 +824,7 @@ describe('API W3C', () => { } }) - const presentation = W3CPresentation.create({ + const presentation = W3cPresentation.create({ presentationRequest, credentials: [ { diff --git a/wrappers/javascript/packages/anoncreds-nodejs/tests/bindings.test.ts b/wrappers/javascript/packages/anoncreds-nodejs/tests/bindings.test.ts index 741a448a..8a1eb72f 100644 --- a/wrappers/javascript/packages/anoncreds-nodejs/tests/bindings.test.ts +++ b/wrappers/javascript/packages/anoncreds-nodejs/tests/bindings.test.ts @@ -374,7 +374,7 @@ describe('bindings', () => { timestamp: timeCreateRevStatusList }) - const credentialOffer = anoncreds.createW3CCredentialOffer({ + const credentialOffer = anoncreds.createW3cCredentialOffer({ schemaId: 'mock:uri', credentialDefinitionId: 'mock:uri', keyCorrectnessProof @@ -383,7 +383,7 @@ 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, @@ -391,7 +391,7 @@ describe('bindings', () => { credentialOffer }) - const credential = anoncreds.createW3CCredential({ + const credential = anoncreds.createW3cCredential({ credentialDefinition, credentialDefinitionPrivate, credentialOffer, @@ -406,7 +406,7 @@ describe('bindings', () => { encoding: undefined }) - const credReceived = anoncreds.processW3CCredential({ + const credReceived = anoncreds.processW3cCredential({ credential, credentialDefinition, credentialRequestMetadata, @@ -672,7 +672,7 @@ describe('bindings', () => { timestamp: timeCreateRevStatusList }) - const credentialOffer = anoncreds.createW3CCredentialOffer({ + const credentialOffer = anoncreds.createW3cCredentialOffer({ schemaId: 'mock:uri', credentialDefinitionId: 'mock:uri', keyCorrectnessProof @@ -681,7 +681,7 @@ 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, @@ -689,7 +689,7 @@ describe('bindings', () => { credentialOffer }) - const credential = anoncreds.createW3CCredential({ + const credential = anoncreds.createW3cCredential({ credentialDefinition, credentialDefinitionPrivate, credentialOffer, @@ -704,7 +704,7 @@ describe('bindings', () => { encoding: undefined }) - const credentialReceived = anoncreds.processW3CCredential({ + const credentialReceived = anoncreds.processW3cCredential({ credential, credentialDefinition, credentialRequestMetadata, @@ -726,7 +726,7 @@ describe('bindings', () => { tailsPath }) - const presentation = anoncreds.createW3CPresentation({ + const presentation = anoncreds.createW3cPresentation({ presentationRequest, credentials: [ { @@ -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], @@ -944,7 +944,7 @@ describe('bindings', () => { tag: 'TAG' }) - const credentialOffer = anoncreds.createW3CCredentialOffer({ + const credentialOffer = anoncreds.createW3cCredentialOffer({ schemaId: 'mock:uri', credentialDefinitionId: 'mock:uri', keyCorrectnessProof @@ -953,7 +953,7 @@ 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, @@ -961,7 +961,7 @@ describe('bindings', () => { credentialOffer }) - const credential = anoncreds.createW3CCredential({ + const credential = anoncreds.createW3cCredential({ credentialDefinition, credentialDefinitionPrivate, credentialOffer, @@ -969,7 +969,7 @@ describe('bindings', () => { attributeRawValues: { name: 'Alex', height: '175', age: '28', sex: 'male' } }) - const credReceived = anoncreds.processW3CCredential({ + const credReceived = anoncreds.processW3cCredential({ credential, credentialDefinition, credentialRequestMetadata, @@ -998,7 +998,7 @@ describe('bindings', () => { }) }) - const presentation = anoncreds.createW3CPresentation({ + const presentation = anoncreds.createW3cPresentation({ presentationRequest, credentials: [ { @@ -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], diff --git a/wrappers/javascript/packages/anoncreds-react-native/cpp/HostObject.cpp b/wrappers/javascript/packages/anoncreds-react-native/cpp/HostObject.cpp index b12ac831..f073ffd1 100644 --- a/wrappers/javascript/packages/anoncreds-react-native/cpp/HostObject.cpp +++ b/wrappers/javascript/packages/anoncreds-react-native/cpp/HostObject.cpp @@ -16,17 +16,17 @@ FunctionMap AnoncredsTurboModuleHostObject::functionMapping(jsi::Runtime &rt) { fMap.insert( std::make_tuple("createCredential", &anoncreds::createCredential)); fMap.insert( - std::make_tuple("createW3CCredential", &anoncreds::createW3CCredential)); + std::make_tuple("createW3cCredential", &anoncreds::createW3cCredential)); fMap.insert(std::make_tuple("createCredentialDefinition", &anoncreds::createCredentialDefinition)); fMap.insert(std::make_tuple("createCredentialOffer", &anoncreds::createCredentialOffer)); - fMap.insert(std::make_tuple("createW3CCredentialOffer", - &anoncreds::createW3CCredentialOffer)); + fMap.insert(std::make_tuple("createW3cCredentialOffer", + &anoncreds::createW3cCredentialOffer)); fMap.insert(std::make_tuple("createCredentialRequest", &anoncreds::createCredentialRequest)); - fMap.insert(std::make_tuple("createW3CCredentialRequest", - &anoncreds::createW3CCredentialRequest)); + fMap.insert(std::make_tuple("createW3cCredentialRequest", + &anoncreds::createW3cCredentialRequest)); fMap.insert( std::make_tuple("createLinkSecret", &anoncreds::createLinkSecret)); fMap.insert(std::make_tuple("createOrUpdateRevocationState", @@ -34,7 +34,7 @@ FunctionMap AnoncredsTurboModuleHostObject::functionMapping(jsi::Runtime &rt) { fMap.insert( std::make_tuple("createPresentation", &anoncreds::createPresentation)); fMap.insert( - std::make_tuple("createW3CPresentation", &anoncreds::createW3CPresentation)); + std::make_tuple("createW3cPresentation", &anoncreds::createW3cPresentation)); fMap.insert(std::make_tuple("createRevocationRegistryDefinition", &anoncreds::createRevocationRegistryDefinition)); fMap.insert(std::make_tuple("createSchema", &anoncreds::createSchema)); @@ -50,7 +50,7 @@ FunctionMap AnoncredsTurboModuleHostObject::functionMapping(jsi::Runtime &rt) { fMap.insert( std::make_tuple("processCredential", &anoncreds::processCredential)); fMap.insert( - std::make_tuple("processW3CCredential", &anoncreds::processW3CCredential)); + std::make_tuple("processW3cCredential", &anoncreds::processW3cCredential)); fMap.insert( std::make_tuple("revocationRegistryDefinitionGetAttribute", &anoncreds::revocationRegistryDefinitionGetAttribute)); @@ -59,7 +59,7 @@ FunctionMap AnoncredsTurboModuleHostObject::functionMapping(jsi::Runtime &rt) { fMap.insert( std::make_tuple("verifyPresentation", &anoncreds::verifyPresentation)); fMap.insert( - std::make_tuple("verifyW3CPresentation", &anoncreds::verifyW3CPresentation)); + std::make_tuple("verifyW3cPresentation", &anoncreds::verifyW3cPresentation)); fMap.insert(std::make_tuple("createRevocationStatusList", &anoncreds::createRevocationStatusList)); fMap.insert(std::make_tuple("updateRevocationStatusList", @@ -125,11 +125,11 @@ fMap.insert(std::make_tuple("createRevocationStatusList", std::make_tuple("w3cCredentialAddType", &anoncreds::w3cCredentialAddType)); fMap.insert( - std::make_tuple("credentialToW3C", - &anoncreds::credentialToW3C)); + std::make_tuple("credentialToW3c", + &anoncreds::credentialToW3c)); fMap.insert( - std::make_tuple("credentialFromW3C", - &anoncreds::credentialFromW3C)); + std::make_tuple("credentialFromW3c", + &anoncreds::credentialFromW3c)); return fMap; } diff --git a/wrappers/javascript/packages/anoncreds-react-native/cpp/anoncreds.cpp b/wrappers/javascript/packages/anoncreds-react-native/cpp/anoncreds.cpp index 046b1462..ac836e7c 100644 --- a/wrappers/javascript/packages/anoncreds-react-native/cpp/anoncreds.cpp +++ b/wrappers/javascript/packages/anoncreds-react-native/cpp/anoncreds.cpp @@ -742,7 +742,7 @@ jsi::Value w3cCredentialFromJson(jsi::Runtime &rt, jsi::Object options) { return returnValue; }; -jsi::Value createW3CPresentation(jsi::Runtime &rt, jsi::Object options) { +jsi::Value createW3cPresentation(jsi::Runtime &rt, jsi::Object options) { auto presentationRequest = jsiToValue(rt, options, "presentationRequest"); auto credentials = @@ -782,7 +782,7 @@ jsi::Value createW3CPresentation(jsi::Runtime &rt, jsi::Object options) { return returnValue; }; -jsi::Value verifyW3CPresentation(jsi::Runtime &rt, jsi::Object options) { +jsi::Value verifyW3cPresentation(jsi::Runtime &rt, jsi::Object options) { auto presentation = jsiToValue(rt, options, "presentation"); auto presentationRequest = jsiToValue(rt, options, "presentationRequest"); @@ -825,7 +825,7 @@ jsi::Value verifyW3CPresentation(jsi::Runtime &rt, jsi::Object options) { return returnValue; }; -jsi::Value createW3CCredential(jsi::Runtime &rt, jsi::Object options) { +jsi::Value createW3cCredential(jsi::Runtime &rt, jsi::Object options) { auto credentialDefinition = jsiToValue(rt, options, "credentialDefinition"); auto credentialDefinitionPrivate = @@ -853,7 +853,7 @@ jsi::Value createW3CCredential(jsi::Runtime &rt, jsi::Object options) { return createReturnValue(rt, code, &out); }; -jsi::Value createW3CCredentialOffer(jsi::Runtime &rt, jsi::Object options) { +jsi::Value createW3cCredentialOffer(jsi::Runtime &rt, jsi::Object options) { auto schemaId = jsiToValue(rt, options, "schemaId"); auto credentialDefinitionId = jsiToValue(rt, options, "credentialDefinitionId"); @@ -869,7 +869,7 @@ jsi::Value createW3CCredentialOffer(jsi::Runtime &rt, jsi::Object options) { return createReturnValue(rt, code, &out); }; -jsi::Value createW3CCredentialRequest(jsi::Runtime &rt, jsi::Object options) { +jsi::Value createW3cCredentialRequest(jsi::Runtime &rt, jsi::Object options) { auto entropy = jsiToValue(rt, options, "entropy", true); auto proverDid = jsiToValue(rt, options, "proverDid", true); auto credentialDefinition = @@ -902,7 +902,7 @@ jsi::Value w3cCredentialGetAttribute(jsi::Runtime &rt, jsi::Object options) { return createReturnValue(rt, code, &out); }; -jsi::Value processW3CCredential(jsi::Runtime &rt, jsi::Object options) { +jsi::Value processW3cCredential(jsi::Runtime &rt, jsi::Object options) { auto credential = jsiToValue(rt, options, "credential"); auto credentialRequestMetadata = jsiToValue(rt, options, "credentialRequestMetadata"); @@ -971,17 +971,17 @@ jsi::Value w3cCredentialAddContext(jsi::Runtime &rt, jsi::Object options) { jsi::Value w3cCredentialAddType(jsi::Runtime &rt, jsi::Object options) { auto credential = jsiToValue(rt, options, "objectHandle"); - auto type_ = jsiToValue(rt, options, "type_"); + auto type = jsiToValue(rt, options, "type"); ObjectHandle out; ErrorCode code = anoncreds_w3c_credential_add_type( - credential, type_.c_str(), &out); + credential, type.c_str(), &out); return createReturnValue(rt, code, &out); }; -jsi::Value credentialToW3C(jsi::Runtime &rt, jsi::Object options) { +jsi::Value credentialToW3c(jsi::Runtime &rt, jsi::Object options) { auto credential = jsiToValue(rt, options, "objectHandle"); auto credentialDefinition = jsiToValue(rt, options, "credentialDefinition"); @@ -994,7 +994,7 @@ jsi::Value credentialToW3C(jsi::Runtime &rt, jsi::Object options) { return createReturnValue(rt, code, &out); }; -jsi::Value credentialFromW3C(jsi::Runtime &rt, jsi::Object options) { +jsi::Value credentialFromW3c(jsi::Runtime &rt, jsi::Object options) { auto credential = jsiToValue(rt, options, "objectHandle"); ObjectHandle out; diff --git a/wrappers/javascript/packages/anoncreds-react-native/cpp/anoncreds.h b/wrappers/javascript/packages/anoncreds-react-native/cpp/anoncreds.h index 7e91203e..919dce35 100644 --- a/wrappers/javascript/packages/anoncreds-react-native/cpp/anoncreds.h +++ b/wrappers/javascript/packages/anoncreds-react-native/cpp/anoncreds.h @@ -20,7 +20,7 @@ struct CredentialRequestReturn { ObjectHandle credentialRequestMetadata; }; -struct W3CCredentialRequestReturn { +struct W3cCredentialRequestReturn { ObjectHandle credentialRequest; ObjectHandle credentialRequestMetadata; }; @@ -74,8 +74,8 @@ jsi::Value w3cPresentationFromJson(jsi::Runtime &rt, jsi::Object options); // Proofs jsi::Value createPresentation(jsi::Runtime &rt, jsi::Object options); jsi::Value verifyPresentation(jsi::Runtime &rt, jsi::Object options); -jsi::Value createW3CPresentation(jsi::Runtime &rt, jsi::Object options); -jsi::Value verifyW3CPresentation(jsi::Runtime &rt, jsi::Object options); +jsi::Value createW3cPresentation(jsi::Runtime &rt, jsi::Object options); +jsi::Value verifyW3cPresentation(jsi::Runtime &rt, jsi::Object options); // Credentials jsi::Value createCredential(jsi::Runtime &rt, jsi::Object options); @@ -85,18 +85,18 @@ jsi::Value credentialGetAttribute(jsi::Runtime &rt, jsi::Object options); jsi::Value encodeCredentialAttributes(jsi::Runtime &rt, jsi::Object options); jsi::Value processCredential(jsi::Runtime &rt, jsi::Object options); -jsi::Value createW3CCredential(jsi::Runtime &rt, jsi::Object options); -jsi::Value createW3CCredentialOffer(jsi::Runtime &rt, jsi::Object options); -jsi::Value createW3CCredentialRequest(jsi::Runtime &rt, jsi::Object options); +jsi::Value createW3cCredential(jsi::Runtime &rt, jsi::Object options); +jsi::Value createW3cCredentialOffer(jsi::Runtime &rt, jsi::Object options); +jsi::Value createW3cCredentialRequest(jsi::Runtime &rt, jsi::Object options); jsi::Value w3cCredentialGetAttribute(jsi::Runtime &rt, jsi::Object options); -jsi::Value processW3CCredential(jsi::Runtime &rt, jsi::Object options); +jsi::Value processW3cCredential(jsi::Runtime &rt, jsi::Object options); jsi::Value w3cCredentialAddNonAnonCredsIntegrityProof(jsi::Runtime &rt, jsi::Object options); jsi::Value w3cCredentialSetId(jsi::Runtime &rt, jsi::Object options); jsi::Value w3cCredentialSetSubjectId(jsi::Runtime &rt, jsi::Object options); jsi::Value w3cCredentialAddContext(jsi::Runtime &rt, jsi::Object options); jsi::Value w3cCredentialAddType(jsi::Runtime &rt, jsi::Object options); -jsi::Value credentialToW3C(jsi::Runtime &rt, jsi::Object options); -jsi::Value credentialFromW3C(jsi::Runtime &rt, jsi::Object options); +jsi::Value credentialToW3c(jsi::Runtime &rt, jsi::Object options); +jsi::Value credentialFromW3c(jsi::Runtime &rt, jsi::Object options); // Revocation jsi::Value createOrUpdateRevocationState(jsi::Runtime &rt, jsi::Object options); diff --git a/wrappers/javascript/packages/anoncreds-react-native/src/NativeBindings.ts b/wrappers/javascript/packages/anoncreds-react-native/src/NativeBindings.ts index 60344f5c..e2663168 100644 --- a/wrappers/javascript/packages/anoncreds-react-native/src/NativeBindings.ts +++ b/wrappers/javascript/packages/anoncreds-react-native/src/NativeBindings.ts @@ -186,13 +186,13 @@ export type NativeBindings = { keyCorrectnessProofFromJson(options: { json: string }): ReturnObject - createW3CCredentialOffer(options: { + createW3cCredentialOffer(options: { schemaId: string credentialDefinitionId: string keyCorrectnessProof: number }): ReturnObject - createW3CCredentialRequest(options: { + createW3cCredentialRequest(options: { entropy?: string proverDid?: string credentialDefinition: number @@ -201,7 +201,7 @@ export type NativeBindings = { credentialOffer: number }): ReturnObject<{ credentialRequest: Handle; credentialRequestMetadata: Handle }> - createW3CCredential(options: { + createW3cCredential(options: { credentialDefinition: number credentialDefinitionPrivate: number credentialOffer: number @@ -217,7 +217,7 @@ export type NativeBindings = { encoding?: string }): ReturnObject - processW3CCredential(options: { + processW3cCredential(options: { credential: number credentialRequestMetadata: number linkSecret: string @@ -235,13 +235,13 @@ export type NativeBindings = { w3cCredentialAddContext(options: { objectHandle: number; context: string }): ReturnObject - w3cCredentialAddType(options: { objectHandle: number; type_: string }): ReturnObject + w3cCredentialAddType(options: { objectHandle: number; type: string }): ReturnObject - credentialToW3C(options: { objectHandle: number; credentialDefinition: number }): ReturnObject + credentialToW3c(options: { objectHandle: number; credentialDefinition: number }): ReturnObject - credentialFromW3C(options: { objectHandle: number }): ReturnObject + credentialFromW3c(options: { objectHandle: number }): ReturnObject - createW3CPresentation(options: { + createW3cPresentation(options: { presentationRequest: number credentials: { credential: number; timestamp?: number; revocationState?: number }[] credentialsProve: NativeCredentialProve[] @@ -252,7 +252,7 @@ export type NativeBindings = { credentialDefinitions: number[] }): ReturnObject - verifyW3CPresentation(options: { + verifyW3cPresentation(options: { presentation: number presentationRequest: number schemas: number[] diff --git a/wrappers/javascript/packages/anoncreds-react-native/src/ReactNativeAnoncreds.ts b/wrappers/javascript/packages/anoncreds-react-native/src/ReactNativeAnoncreds.ts index 8d55cf44..0c3855f6 100644 --- a/wrappers/javascript/packages/anoncreds-react-native/src/ReactNativeAnoncreds.ts +++ b/wrappers/javascript/packages/anoncreds-react-native/src/ReactNativeAnoncreds.ts @@ -393,7 +393,7 @@ export class ReactNativeAnoncreds implements Anoncreds { return new ObjectHandle(handle) } - public createW3CCredential(options: { + public createW3cCredential(options: { credentialDefinition: ObjectHandle credentialDefinitionPrivate: ObjectHandle credentialOffer: ObjectHandle @@ -408,7 +408,7 @@ export class ReactNativeAnoncreds implements Anoncreds { const credential = this.handleError( // eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error // @ts-ignore - this.anoncreds.createW3CCredential({ + this.anoncreds.createW3cCredential({ // eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error // @ts-ignore ...serializeArguments(options), @@ -430,27 +430,27 @@ export class ReactNativeAnoncreds implements Anoncreds { return new ObjectHandle(credential) } - public processW3CCredential(options: { + public processW3cCredential(options: { credential: ObjectHandle credentialRequestMetadata: ObjectHandle linkSecret: string credentialDefinition: ObjectHandle revocationRegistryDefinition?: ObjectHandle }): ObjectHandle { - const handle = this.handleError(this.anoncreds.processW3CCredential(serializeArguments(options))) + const handle = this.handleError(this.anoncreds.processW3cCredential(serializeArguments(options))) return new ObjectHandle(handle) } - public createW3CCredentialOffer(options: { + public createW3cCredentialOffer(options: { schemaId: string credentialDefinitionId: string keyCorrectnessProof: ObjectHandle }): ObjectHandle { - const handle = this.handleError(this.anoncreds.createW3CCredentialOffer(serializeArguments(options))) + const handle = this.handleError(this.anoncreds.createW3cCredentialOffer(serializeArguments(options))) return new ObjectHandle(handle) } - public createW3CCredentialRequest(options: { + public createW3cCredentialRequest(options: { entropy?: string proverDid?: string credentialDefinition: ObjectHandle @@ -459,7 +459,7 @@ export class ReactNativeAnoncreds implements Anoncreds { credentialOffer: ObjectHandle }): { credentialRequest: ObjectHandle; credentialRequestMetadata: ObjectHandle } { const { credentialRequest, credentialRequestMetadata } = this.handleError( - this.anoncreds.createW3CCredentialRequest(serializeArguments(options)) + this.anoncreds.createW3cCredentialRequest(serializeArguments(options)) ) return { @@ -468,7 +468,7 @@ export class ReactNativeAnoncreds implements Anoncreds { } } - public createW3CPresentation(options: { + public createW3cPresentation(options: { presentationRequest: ObjectHandle credentials: NativeCredentialEntry[] credentialsProve: NativeCredentialProve[] @@ -488,7 +488,7 @@ export class ReactNativeAnoncreds implements Anoncreds { })) const handle = this.handleError( - this.anoncreds.createW3CPresentation({ + this.anoncreds.createW3cPresentation({ presentationRequest: options.presentationRequest.handle, linkSecret: options.linkSecret, credentialsProve: options.credentialsProve, @@ -502,7 +502,7 @@ export class ReactNativeAnoncreds implements Anoncreds { return new ObjectHandle(handle) } - public verifyW3CPresentation(options: { + public verifyW3cPresentation(options: { presentation: ObjectHandle presentationRequest: ObjectHandle schemas: ObjectHandle[] @@ -514,7 +514,7 @@ export class ReactNativeAnoncreds implements Anoncreds { revocationStatusLists?: ObjectHandle[] nonRevokedIntervalOverrides?: NativeNonRevokedIntervalOverride[] }): boolean { - return Boolean(this.handleError(this.anoncreds.verifyW3CPresentation(serializeArguments(options)))) + return Boolean(this.handleError(this.anoncreds.verifyW3cPresentation(serializeArguments(options)))) } public w3cCredentialGetAttribute(options: { objectHandle: ObjectHandle; name: string }): string { @@ -566,18 +566,18 @@ export class ReactNativeAnoncreds implements Anoncreds { return new ObjectHandle(handle) } - public w3cCredentialAddType(options: { objectHandle: ObjectHandle; type_: string }): ObjectHandle { + public w3cCredentialAddType(options: { objectHandle: ObjectHandle; type: string }): ObjectHandle { const handle = this.handleError(this.anoncreds.w3cCredentialAddType(serializeArguments(options))) return new ObjectHandle(handle) } - public credentialToW3C(options: { objectHandle: ObjectHandle; credentialDefinition: ObjectHandle }): ObjectHandle { - const handle = this.handleError(this.anoncreds.credentialToW3C(serializeArguments(options))) + public credentialToW3c(options: { objectHandle: ObjectHandle; credentialDefinition: ObjectHandle }): ObjectHandle { + const handle = this.handleError(this.anoncreds.credentialToW3c(serializeArguments(options))) return new ObjectHandle(handle) } - public credentialFromW3C(options: { objectHandle: ObjectHandle }): ObjectHandle { - const handle = this.handleError(this.anoncreds.credentialFromW3C(serializeArguments(options))) + public credentialFromW3c(options: { objectHandle: ObjectHandle }): ObjectHandle { + const handle = this.handleError(this.anoncreds.credentialFromW3c(serializeArguments(options))) return new ObjectHandle(handle) } } diff --git a/wrappers/javascript/packages/anoncreds-shared/src/Anoncreds.ts b/wrappers/javascript/packages/anoncreds-shared/src/Anoncreds.ts index a8debf1b..6b922e43 100644 --- a/wrappers/javascript/packages/anoncreds-shared/src/Anoncreds.ts +++ b/wrappers/javascript/packages/anoncreds-shared/src/Anoncreds.ts @@ -205,13 +205,13 @@ export type Anoncreds = { objectFree(options: { objectHandle: ObjectHandle }): void - createW3CCredentialOffer(options: { + createW3cCredentialOffer(options: { schemaId: string credentialDefinitionId: string keyCorrectnessProof: ObjectHandle }): ObjectHandle - createW3CCredentialRequest(options: { + createW3cCredentialRequest(options: { entropy?: string proverDid?: string credentialDefinition: ObjectHandle @@ -220,7 +220,7 @@ export type Anoncreds = { credentialOffer: ObjectHandle }): { credentialRequest: ObjectHandle; credentialRequestMetadata: ObjectHandle } - createW3CCredential(options: { + createW3cCredential(options: { credentialDefinition: ObjectHandle credentialDefinitionPrivate: ObjectHandle credentialOffer: ObjectHandle @@ -230,7 +230,7 @@ export type Anoncreds = { encoding?: string }): ObjectHandle - processW3CCredential(options: { + processW3cCredential(options: { credential: ObjectHandle credentialRequestMetadata: ObjectHandle linkSecret: string @@ -238,7 +238,7 @@ export type Anoncreds = { revocationRegistryDefinition?: ObjectHandle }): ObjectHandle - createW3CPresentation(options: { + createW3cPresentation(options: { presentationRequest: ObjectHandle credentials: NativeCredentialEntry[] credentialsProve: NativeCredentialProve[] @@ -247,7 +247,7 @@ export type Anoncreds = { credentialDefinitions: Record }): ObjectHandle - verifyW3CPresentation(options: { + verifyW3cPresentation(options: { presentation: ObjectHandle presentationRequest: ObjectHandle schemas: ObjectHandle[] @@ -270,7 +270,7 @@ export type Anoncreds = { w3cCredentialAddContext(options: { objectHandle: ObjectHandle; context: string }): ObjectHandle - w3cCredentialAddType(options: { objectHandle: ObjectHandle; type_: string }): ObjectHandle + w3cCredentialAddType(options: { objectHandle: ObjectHandle; type: string }): ObjectHandle w3cCredentialGetAttribute(options: { objectHandle: ObjectHandle; name: string }): string @@ -280,7 +280,7 @@ export type Anoncreds = { w3cCredentialFromJson(options: { json: string }): ObjectHandle - credentialToW3C(options: { objectHandle: ObjectHandle; credentialDefinition: ObjectHandle }): ObjectHandle + credentialToW3c(options: { objectHandle: ObjectHandle; credentialDefinition: ObjectHandle }): ObjectHandle - credentialFromW3C(options: { objectHandle: ObjectHandle }): ObjectHandle + credentialFromW3c(options: { objectHandle: ObjectHandle }): ObjectHandle } diff --git a/wrappers/javascript/packages/anoncreds-shared/src/api/Credential.ts b/wrappers/javascript/packages/anoncreds-shared/src/api/Credential.ts index 19b6a4d5..5081a1b9 100644 --- a/wrappers/javascript/packages/anoncreds-shared/src/api/Credential.ts +++ b/wrappers/javascript/packages/anoncreds-shared/src/api/Credential.ts @@ -12,7 +12,7 @@ import { CredentialOffer } from './CredentialOffer' import { CredentialRequest } from './CredentialRequest' import { CredentialRequestMetadata } from './CredentialRequestMetadata' import { RevocationRegistryDefinition } from './RevocationRegistryDefinition' -import { W3CCredential } from './W3CCredential' +import { W3cCredential } from './W3cCredential' import { pushToArray } from './utils' export type CreateCredentialOptions = { @@ -34,12 +34,12 @@ export type ProcessCredentialOptions = { revocationRegistryDefinition?: RevocationRegistryDefinition | JsonObject } -export type CredentialToW3COptions = { +export type CredentialToW3cOptions = { credentialDefinition: CredentialDefinition | JsonObject } -export type CredentialFromW3COptions = { - credential: W3CCredential +export type CredentialFromW3cOptions = { + credential: W3cCredential } export class Credential extends AnoncredsObject { @@ -149,7 +149,7 @@ export class Credential extends AnoncredsObject { return index ? Number(index) : undefined } - public toW3C(options: CredentialToW3COptions): W3CCredential { + public toW3c(options: CredentialToW3cOptions): W3cCredential { let credential // Objects created within this method must be freed up const objectHandles: ObjectHandle[] = [] @@ -159,8 +159,8 @@ export class Credential extends AnoncredsObject { ? options.credentialDefinition.handle : pushToArray(CredentialDefinition.fromJson(options.credentialDefinition).handle, objectHandles) - credential = new W3CCredential( - anoncreds.credentialToW3C({ + credential = new W3cCredential( + anoncreds.credentialToW3c({ objectHandle: this.handle, credentialDefinition }).handle @@ -173,7 +173,7 @@ export class Credential extends AnoncredsObject { return credential } - public static fromW3C(options: CredentialFromW3COptions) { - return new Credential(anoncreds.credentialFromW3C({ objectHandle: options.credential.handle }).handle) + public static fromW3c(options: CredentialFromW3cOptions) { + return new Credential(anoncreds.credentialFromW3c({ objectHandle: options.credential.handle }).handle) } } diff --git a/wrappers/javascript/packages/anoncreds-shared/src/api/W3CCredential.ts b/wrappers/javascript/packages/anoncreds-shared/src/api/W3cCredential.ts similarity index 84% rename from wrappers/javascript/packages/anoncreds-shared/src/api/W3CCredential.ts rename to wrappers/javascript/packages/anoncreds-shared/src/api/W3cCredential.ts index 7ae213fc..e922432d 100644 --- a/wrappers/javascript/packages/anoncreds-shared/src/api/W3CCredential.ts +++ b/wrappers/javascript/packages/anoncreds-shared/src/api/W3cCredential.ts @@ -11,15 +11,15 @@ import { CredentialDefinition } from './CredentialDefinition' import { CredentialDefinitionPrivate } from './CredentialDefinitionPrivate' import { CredentialRequestMetadata } from './CredentialRequestMetadata' import { RevocationRegistryDefinition } from './RevocationRegistryDefinition' -import { W3CCredentialOffer } from './W3CCredentialOffer' -import { W3CCredentialRequest } from './W3CCredentialRequest' +import { W3cCredentialOffer } from './W3cCredentialOffer' +import { W3cCredentialRequest } from './W3cCredentialRequest' import { pushToArray } from './utils' -export type CreateW3CCredentialOptions = { +export type CreateW3cCredentialOptions = { credentialDefinition: CredentialDefinition | JsonObject credentialDefinitionPrivate: CredentialDefinitionPrivate | JsonObject - credentialOffer: W3CCredentialOffer | JsonObject - credentialRequest: W3CCredentialRequest | JsonObject + credentialOffer: W3cCredentialOffer | JsonObject + credentialRequest: W3cCredentialRequest | JsonObject attributeRawValues: Record revocationRegistryId?: string revocationConfiguration?: CredentialRevocationConfig @@ -27,20 +27,20 @@ export type CreateW3CCredentialOptions = { encoding?: string } -export type ProcessW3CCredentialOptions = { +export type ProcessW3cCredentialOptions = { credentialRequestMetadata: CredentialRequestMetadata | JsonObject linkSecret: string credentialDefinition: CredentialDefinition | JsonObject revocationRegistryDefinition?: RevocationRegistryDefinition | JsonObject } -export type W3CCredentialFromLegacyOptions = { +export type W3cCredentialFromLegacyOptions = { credential: Credential credentialDefinition: CredentialDefinition | JsonObject } -export class W3CCredential extends AnoncredsObject { - public static create(options: CreateW3CCredentialOptions) { +export class W3cCredential extends AnoncredsObject { + public static create(options: CreateW3cCredentialOptions) { let credential // Objects created within this method must be freed up const objectHandles: ObjectHandle[] = [] @@ -56,16 +56,16 @@ export class W3CCredential extends AnoncredsObject { : pushToArray(CredentialDefinitionPrivate.fromJson(options.credentialDefinitionPrivate).handle, objectHandles) const credentialOffer = - options.credentialOffer instanceof W3CCredentialOffer + options.credentialOffer instanceof W3cCredentialOffer ? options.credentialOffer.handle - : pushToArray(W3CCredentialOffer.fromJson(options.credentialOffer).handle, objectHandles) + : pushToArray(W3cCredentialOffer.fromJson(options.credentialOffer).handle, objectHandles) const credentialRequest = - options.credentialRequest instanceof W3CCredentialRequest + options.credentialRequest instanceof W3cCredentialRequest ? options.credentialRequest.handle - : pushToArray(W3CCredentialRequest.fromJson(options.credentialRequest).handle, objectHandles) + : pushToArray(W3cCredentialRequest.fromJson(options.credentialRequest).handle, objectHandles) - credential = anoncreds.createW3CCredential({ + credential = anoncreds.createW3cCredential({ credentialDefinition, credentialDefinitionPrivate, credentialOffer, @@ -79,14 +79,14 @@ export class W3CCredential extends AnoncredsObject { handle.clear() }) } - return new W3CCredential(credential.handle) + return new W3cCredential(credential.handle) } public static fromJson(json: JsonObject) { - return new W3CCredential(anoncreds.w3cCredentialFromJson({ json: JSON.stringify(json) }).handle) + return new W3cCredential(anoncreds.w3cCredentialFromJson({ json: JSON.stringify(json) }).handle) } - public process(options: ProcessW3CCredentialOptions) { + public process(options: ProcessW3cCredentialOptions) { let credential // Objects created within this method must be freed up const objectHandles: ObjectHandle[] = [] @@ -111,7 +111,7 @@ export class W3CCredential extends AnoncredsObject { ) : undefined - credential = anoncreds.processW3CCredential({ + credential = anoncreds.processW3cCredential({ credential: this.handle, credentialDefinition, credentialRequestMetadata, @@ -149,13 +149,13 @@ export class W3CCredential extends AnoncredsObject { public toLegacy(): Credential { return new Credential( - anoncreds.credentialFromW3C({ + anoncreds.credentialFromW3c({ objectHandle: this.handle }).handle ) } - public static fromLegacy(options: W3CCredentialFromLegacyOptions): W3CCredential { + public static fromLegacy(options: W3cCredentialFromLegacyOptions): W3cCredential { let credential // Objects created within this method must be freed up const objectHandles: ObjectHandle[] = [] @@ -165,8 +165,8 @@ export class W3CCredential extends AnoncredsObject { ? options.credentialDefinition.handle : pushToArray(CredentialDefinition.fromJson(options.credentialDefinition).handle, objectHandles) - credential = new W3CCredential( - anoncreds.credentialToW3C({ + credential = new W3cCredential( + anoncreds.credentialToW3c({ objectHandle: options.credential.handle, credentialDefinition }).handle @@ -219,10 +219,10 @@ export class W3CCredential extends AnoncredsObject { this.handle = credential } - public addType(type_: string) { + public addType(type: string) { const credential = anoncreds.w3cCredentialAddType({ objectHandle: this.handle, - type_ + type }) this.handle.clear() diff --git a/wrappers/javascript/packages/anoncreds-shared/src/api/W3CCredentialOffer.ts b/wrappers/javascript/packages/anoncreds-shared/src/api/W3cCredentialOffer.ts similarity index 76% rename from wrappers/javascript/packages/anoncreds-shared/src/api/W3CCredentialOffer.ts rename to wrappers/javascript/packages/anoncreds-shared/src/api/W3cCredentialOffer.ts index 7009eec0..7db405fb 100644 --- a/wrappers/javascript/packages/anoncreds-shared/src/api/W3CCredentialOffer.ts +++ b/wrappers/javascript/packages/anoncreds-shared/src/api/W3cCredentialOffer.ts @@ -7,14 +7,14 @@ import { anoncreds } from '../register' import { KeyCorrectnessProof } from './KeyCorrectnessProof' import { pushToArray } from './utils' -export type CreateW3CCredentialOfferOptions = { +export type CreateW3cCredentialOfferOptions = { schemaId: string credentialDefinitionId: string keyCorrectnessProof: KeyCorrectnessProof | JsonObject } -export class W3CCredentialOffer extends AnoncredsObject { - public static create(options: CreateW3CCredentialOfferOptions) { +export class W3cCredentialOffer extends AnoncredsObject { + public static create(options: CreateW3cCredentialOfferOptions) { let credentialOfferHandle // Objects created within this method must be freed up const objectHandles: ObjectHandle[] = [] @@ -24,7 +24,7 @@ export class W3CCredentialOffer extends AnoncredsObject { ? options.keyCorrectnessProof.handle : pushToArray(KeyCorrectnessProof.fromJson(options.keyCorrectnessProof).handle, objectHandles) - credentialOfferHandle = anoncreds.createW3CCredentialOffer({ + credentialOfferHandle = anoncreds.createW3cCredentialOffer({ schemaId: options.schemaId, credentialDefinitionId: options.credentialDefinitionId, keyCorrectnessProof @@ -34,10 +34,10 @@ export class W3CCredentialOffer extends AnoncredsObject { handle.clear() }) } - return new W3CCredentialOffer(credentialOfferHandle) + return new W3cCredentialOffer(credentialOfferHandle) } public static fromJson(json: JsonObject) { - return new W3CCredentialOffer(anoncreds.w3cCredentialOfferFromJson({ json: JSON.stringify(json) }).handle) + return new W3cCredentialOffer(anoncreds.w3cCredentialOfferFromJson({ json: JSON.stringify(json) }).handle) } } diff --git a/wrappers/javascript/packages/anoncreds-shared/src/api/W3CCredentialRequest.ts b/wrappers/javascript/packages/anoncreds-shared/src/api/W3cCredentialRequest.ts similarity index 73% rename from wrappers/javascript/packages/anoncreds-shared/src/api/W3CCredentialRequest.ts rename to wrappers/javascript/packages/anoncreds-shared/src/api/W3cCredentialRequest.ts index e92f1c23..b2d6fb8b 100644 --- a/wrappers/javascript/packages/anoncreds-shared/src/api/W3CCredentialRequest.ts +++ b/wrappers/javascript/packages/anoncreds-shared/src/api/W3cCredentialRequest.ts @@ -6,20 +6,20 @@ import { anoncreds } from '../register' import { CredentialDefinition } from './CredentialDefinition' import { CredentialRequestMetadata } from './CredentialRequestMetadata' -import { W3CCredentialOffer } from './W3CCredentialOffer' +import { W3cCredentialOffer } from './W3cCredentialOffer' import { pushToArray } from './utils' -export type CreateW3CCredentialRequestOptions = { +export type CreateW3cCredentialRequestOptions = { entropy?: string proverDid?: string credentialDefinition: CredentialDefinition | JsonObject linkSecret: string linkSecretId: string - credentialOffer: W3CCredentialOffer | JsonObject + credentialOffer: W3cCredentialOffer | JsonObject } -export class W3CCredentialRequest extends AnoncredsObject { - public static create(options: CreateW3CCredentialRequestOptions) { +export class W3cCredentialRequest extends AnoncredsObject { + public static create(options: CreateW3cCredentialRequestOptions) { let createReturnObj: { credentialRequest: ObjectHandle credentialRequestMetadata: ObjectHandle @@ -33,11 +33,11 @@ export class W3CCredentialRequest extends AnoncredsObject { : pushToArray(CredentialDefinition.fromJson(options.credentialDefinition).handle, objectHandles) const credentialOffer = - options.credentialOffer instanceof W3CCredentialOffer + options.credentialOffer instanceof W3cCredentialOffer ? options.credentialOffer.handle - : pushToArray(W3CCredentialOffer.fromJson(options.credentialOffer).handle, objectHandles) + : pushToArray(W3cCredentialOffer.fromJson(options.credentialOffer).handle, objectHandles) - createReturnObj = anoncreds.createW3CCredentialRequest({ + createReturnObj = anoncreds.createW3cCredentialRequest({ entropy: options.entropy, proverDid: options.proverDid, credentialDefinition, @@ -51,12 +51,12 @@ export class W3CCredentialRequest extends AnoncredsObject { }) } return { - credentialRequest: new W3CCredentialRequest(createReturnObj.credentialRequest.handle), + credentialRequest: new W3cCredentialRequest(createReturnObj.credentialRequest.handle), credentialRequestMetadata: new CredentialRequestMetadata(createReturnObj.credentialRequestMetadata.handle) } } public static fromJson(json: JsonObject) { - return new W3CCredentialRequest(anoncreds.w3cCredentialRequestFromJson({ json: JSON.stringify(json) }).handle) + return new W3cCredentialRequest(anoncreds.w3cCredentialRequestFromJson({ json: JSON.stringify(json) }).handle) } } diff --git a/wrappers/javascript/packages/anoncreds-shared/src/api/W3CPresentation.ts b/wrappers/javascript/packages/anoncreds-shared/src/api/W3cPresentation.ts similarity index 88% rename from wrappers/javascript/packages/anoncreds-shared/src/api/W3CPresentation.ts rename to wrappers/javascript/packages/anoncreds-shared/src/api/W3cPresentation.ts index 1607906a..f233bc8f 100644 --- a/wrappers/javascript/packages/anoncreds-shared/src/api/W3CPresentation.ts +++ b/wrappers/javascript/packages/anoncreds-shared/src/api/W3cPresentation.ts @@ -11,27 +11,27 @@ import { PresentationRequest } from './PresentationRequest' import { RevocationRegistryDefinition } from './RevocationRegistryDefinition' import { RevocationStatusList } from './RevocationStatusList' import { Schema } from './Schema' -import { W3CCredential } from './W3CCredential' +import { W3cCredential } from './W3cCredential' import { pushToArray } from './utils' // TODO: Simplify Presentation API (see PresentCredentials object in python wrapper)) -export type W3CCredentialEntry = { - credential: W3CCredential | JsonObject +export type W3cCredentialEntry = { + credential: W3cCredential | JsonObject timestamp?: number revocationState?: CredentialRevocationState | JsonObject } -export type CreateW3CPresentationOptions = { +export type CreateW3cPresentationOptions = { presentationRequest: PresentationRequest | JsonObject - credentials: W3CCredentialEntry[] + credentials: W3cCredentialEntry[] credentialsProve: CredentialProve[] linkSecret: string schemas: Record credentialDefinitions: Record } -export type VerifyW3CPresentationOptions = { +export type VerifyW3cPresentationOptions = { presentationRequest: PresentationRequest | JsonObject schemas: Record credentialDefinitions: Record @@ -40,8 +40,8 @@ export type VerifyW3CPresentationOptions = { nonRevokedIntervalOverrides?: NonRevokedIntervalOverride[] } -export class W3CPresentation extends AnoncredsObject { - public static create(options: CreateW3CPresentationOptions) { +export class W3cPresentation extends AnoncredsObject { + public static create(options: CreateW3cPresentationOptions) { let presentationHandle // Objects created within this method must be freed up const objectHandles: ObjectHandle[] = [] @@ -51,13 +51,13 @@ export class W3CPresentation extends AnoncredsObject { ? options.presentationRequest.handle : pushToArray(PresentationRequest.fromJson(options.presentationRequest).handle, objectHandles) - presentationHandle = anoncreds.createW3CPresentation({ + presentationHandle = anoncreds.createW3cPresentation({ presentationRequest, credentials: options.credentials.map((item) => ({ credential: - item.credential instanceof W3CCredential + item.credential instanceof W3cCredential ? item.credential.handle - : pushToArray(W3CCredential.fromJson(item.credential).handle, objectHandles), + : pushToArray(W3cCredential.fromJson(item.credential).handle, objectHandles), revocationState: item.revocationState instanceof CredentialRevocationState ? item.revocationState.handle @@ -94,14 +94,14 @@ export class W3CPresentation extends AnoncredsObject { handle.clear() }) } - return new W3CPresentation(presentationHandle) + return new W3cPresentation(presentationHandle) } public static fromJson(json: JsonObject) { - return new W3CPresentation(anoncreds.w3cPresentationFromJson({ json: JSON.stringify(json) }).handle) + return new W3cPresentation(anoncreds.w3cPresentationFromJson({ json: JSON.stringify(json) }).handle) } - public verify(options: VerifyW3CPresentationOptions) { + public verify(options: VerifyW3cPresentationOptions) { const schemas = Object.values(options.schemas) const schemaIds = Object.keys(options.schemas) @@ -124,7 +124,7 @@ export class W3CPresentation extends AnoncredsObject { ? options.presentationRequest.handle : pushToArray(PresentationRequest.fromJson(options.presentationRequest).handle, objectHandles) - verified = anoncreds.verifyW3CPresentation({ + verified = anoncreds.verifyW3cPresentation({ presentation: this.handle, presentationRequest, schemas: schemas.map((o) => diff --git a/wrappers/javascript/packages/anoncreds-shared/src/api/index.ts b/wrappers/javascript/packages/anoncreds-shared/src/api/index.ts index b6aa73ed..6ac21014 100644 --- a/wrappers/javascript/packages/anoncreds-shared/src/api/index.ts +++ b/wrappers/javascript/packages/anoncreds-shared/src/api/index.ts @@ -15,7 +15,7 @@ export * from './RevocationRegistry' export * from './RevocationRegistryDefinition' export * from './RevocationRegistryDefinitionPrivate' export * from './RevocationStatusList' -export * from './W3CCredential' -export * from './W3CCredentialOffer' -export * from './W3CCredentialRequest' -export * from './W3CPresentation' +export * from './W3cCredential' +export * from './W3cCredentialOffer' +export * from './W3cCredentialRequest' +export * from './W3cPresentation'