@tdxvolt/volt-client-grpc 0.16.0-beta.2 → 0.16.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.cjs CHANGED
@@ -1775,7 +1775,7 @@ function findDIDDocumentService(document, serviceType) {
1775
1775
  return matches;
1776
1776
  }
1777
1777
 
1778
- async function authenticateInternal(createDID = true) {
1778
+ async function authenticateInternal(useDID = true) {
1779
1779
  try {
1780
1780
  // Check if we need to resolve a Relay volt.
1781
1781
  if (
@@ -1812,7 +1812,9 @@ async function authenticateInternal(createDID = true) {
1812
1812
  }
1813
1813
 
1814
1814
  const keyPair = this._credential.getKey();
1815
- const publicKeyPem = pki.publicKeyToPem(keyPair.publicKey);
1815
+ const publicKeyPem = removeCarriageReturn(
1816
+ pki.publicKeyToPem(keyPair.publicKey)
1817
+ );
1816
1818
 
1817
1819
  if (!this._credential.cache.bindIp) {
1818
1820
  // Default the IP address if none is specified. This is used to set the SAN in the
@@ -1839,13 +1841,11 @@ async function authenticateInternal(createDID = true) {
1839
1841
  );
1840
1842
  }
1841
1843
 
1842
- if (!createDID) {
1844
+ if (!useDID) {
1843
1845
  authenticateRequest.public_key = publicKeyPem;
1844
- } else {
1845
- if (!this._credential.cache.identity_id) {
1846
- // If we don't have an identity id, then we need to create a DID.
1847
- this._credential.cache.identity_id = `did:volt:${uuid.v4()}`;
1848
- }
1846
+ } else if (!this._credential.cache.identity_id) {
1847
+ // If we don't have an identity id, then we need to create a DID.
1848
+ this._credential.cache.identity_id = `did:volt:${uuid.v4()}`;
1849
1849
 
1850
1850
  const did = this._credential.cache.identity_id;
1851
1851
 
@@ -1901,6 +1901,8 @@ async function authenticateInternal(createDID = true) {
1901
1901
 
1902
1902
  log$1("did document is %s", authenticateRequest.did_document);
1903
1903
  log$1("did signature is %s", authenticateRequest.did_document_signature);
1904
+ } else {
1905
+ authenticateRequest.did = this._credential.cache.identity_id;
1904
1906
  }
1905
1907
 
1906
1908
  log$1("authenticate TTL is ", this._config.bindRequestTTL);
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.16.0-beta.2",
6
+ "version": "0.16.0-beta.4",
7
7
  "description": "tdx Volt library for nodejs clients",
8
8
  "type": "module",
9
9
  "exports": {
@@ -91,7 +91,7 @@ function findDIDDocumentService(document, serviceType) {
91
91
  return matches;
92
92
  }
93
93
 
94
- export async function authenticateInternal(createDID = true) {
94
+ export async function authenticateInternal(useDID = true) {
95
95
  try {
96
96
  // Check if we need to resolve a Relay volt.
97
97
  if (
@@ -128,7 +128,9 @@ export async function authenticateInternal(createDID = true) {
128
128
  }
129
129
 
130
130
  const keyPair = this._credential.getKey();
131
- const publicKeyPem = pki.publicKeyToPem(keyPair.publicKey);
131
+ const publicKeyPem = voltUtils.removeCarriageReturn(
132
+ pki.publicKeyToPem(keyPair.publicKey)
133
+ );
132
134
 
133
135
  if (!this._credential.cache.bindIp) {
134
136
  // Default the IP address if none is specified. This is used to set the SAN in the
@@ -155,13 +157,11 @@ export async function authenticateInternal(createDID = true) {
155
157
  );
156
158
  }
157
159
 
158
- if (!createDID) {
160
+ if (!useDID) {
159
161
  authenticateRequest.public_key = publicKeyPem;
160
- } else {
161
- if (!this._credential.cache.identity_id) {
162
- // If we don't have an identity id, then we need to create a DID.
163
- this._credential.cache.identity_id = `did:volt:${generateId()}`;
164
- }
162
+ } else if (!this._credential.cache.identity_id) {
163
+ // If we don't have an identity id, then we need to create a DID.
164
+ this._credential.cache.identity_id = `did:volt:${generateId()}`;
165
165
 
166
166
  const did = this._credential.cache.identity_id;
167
167
 
@@ -217,6 +217,8 @@ export async function authenticateInternal(createDID = true) {
217
217
 
218
218
  log("did document is %s", authenticateRequest.did_document);
219
219
  log("did signature is %s", authenticateRequest.did_document_signature);
220
+ } else {
221
+ authenticateRequest.did = this._credential.cache.identity_id;
220
222
  }
221
223
 
222
224
  log("authenticate TTL is ", this._config.bindRequestTTL);