You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tutorials/javascript/compliance/verify-credential.md
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ This tutorial uses sample code in Javascript using the [xrpl-js library](../inde
17
17
18
18
## Prerequisites
19
19
20
-
- You must have Node.js insalled and know how to run Javascript code from the command line. Node.js v18 is required for xrpl.js.
20
+
- You must have Node.js installed and know how to run Javascript code from the command line. Node.js v18 is required for xrpl.js.
21
21
- You should have a basic understanding of the XRP Ledger.
22
22
- The credential you want to verify should exist in the ledger already, and you should know the addresses of both the issuer and the holder, as well as the official credential type you want to check.
23
23
- For sample code showing how to create credentials, see [Build a Credential Issuing Service](../build-apps/credential-issuing-service.md).
@@ -253,27 +253,27 @@ Then it defines a type of exception to throw if something goes wrong when connec
253
253
254
254
{% code-snippet file="/_code-samples/verify-credential/js/verify_credential.js" language="js" from="// Define an error to throw" before="const CREDENTIAL" /%}
255
255
256
-
Finally, a regular expression to validate the credential format and the `lsfAccepted` flag are defined as constants for use further on in the code.
256
+
Finally, a regular expression to validate the credential format and the [lsfAccepted](../../../references/protocol/ledger-data/ledger-entry-types/credential.md#credential-flags) flag are defined as constants for use further on in the code.
257
257
258
258
{% code-snippet file="/_code-samples/verify-credential/js/verify_credential.js" language="js" from="const CREDENTIAL" before="async function verifyCredential" /%}
259
259
260
260
### 2. verifyCredential function
261
261
262
262
The `verifyCredential(...)` function performs the main work for this tutorial. The function definition and comments define the parameters:
263
263
264
-
{% code-snippet file="/_code-samples/verify-credential/js/verify_credential.js" language="js" from="async function verifyCredential" before="// Handle function inputs" /%}
264
+
{% code-snippet file="/_code-samples/verify-credential/js/verify_credential.js" language="js" from="async function verifyCredential" before="// Encode credentialType as uppercase hex" /%}
265
265
266
-
The first thing the function does is verify that a credential type is provided. The XRP Ledger APIs require the credential type to be hexadecimal, so it converts the user input if necessary:
266
+
The XRP Ledger APIs require the credential type to be hexadecimal, so it converts the user input if necessary:
Next, it calls the [ledger_entry method](/docs/references/http-websocket-apis/public-api-methods/ledger-methods/ledger_entry#get-credential-entry) to look up the requested Credential ledger entry:
271
271
272
-
{% code-snippet file="/_code-samples/verify-credential/js/verify_credential.js" language="js" from="// Perform XRPL lookup" before="// Confirm that the credential has been accepted" /%}
272
+
{% code-snippet file="/_code-samples/verify-credential/js/verify_credential.js" language="js" from="// Perform XRPL lookup" before="// Check if the credential has been accepted" /%}
273
273
274
274
If it succeeds in finding the credential, the function continues by checking that the credential has been accepted by its holder. Since anyone can issue a credential to anyone else, a credential is only considered valid if its subject has accepted it.
275
275
276
-
{% code-snippet file="/_code-samples/verify-credential/js/verify_credential.js" language="js" from="// Confirm that the credential has been accepted" before="// Confirm that the credential is not expired" /%}
276
+
{% code-snippet file="/_code-samples/verify-credential/js/verify_credential.js" language="js" from="Check if the credential has been accepted" before="// Confirm that the credential is not expired" /%}
277
277
278
278
Then, if the credential has an expiration time, the function checks that the credential is not expired. If the credential has no expiration, this step can be skipped. A credential is officially considered expired if its expiration time is before the [official close time](/docs/concepts/ledgers/ledger-close-times) of the most recently validated ledger. This is more universal than comparing the expiration to your own local clock. Thus, the code uses the [ledger method][] to look up the most recently validated ledger:
0 commit comments