Skip to content

Commit

Permalink
Add API reference for hasValidCredential (#1586)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasamonrc authored May 8, 2024
1 parent 05ea569 commit a86977c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
38 changes: 38 additions & 0 deletions docs/reference/services/connect-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,44 @@ A session cannot be canceled if it is in the {{ field_ref("CancelSessionResponse

---

## Invoke Headless Verification Flow

In scenarios where a relying party (or attestation provider) wants to preemptively check whether or not a user has a reusable credential, the `HasValidCredential` method runs a headless verification flow with the provided identity. It returns a boolean value, `true` if the identity has a reusable credential `false` otherwise.

No PII will be included in the response, if you are interested in obtaining results you will need to invoke a verification flow on the client.

{{ proto_sample_start() }}

=== "TypeScript"
```ts
import { TrinsicService } from "@trinsic/trinsic";

const trinsic = new TrinsicService({ authToken: "<auth token>" });

const result = await trinsic.connect().hasValidCredential({
identity: {
identity: "<phone number>",
provider: IdentityProvider.PHONE,
},
credentialRequestData: {
type: VerificationType.GOVERNMENT_ID
},
});

console.log(result.hasValidCredential);
```

=== "C#"
<!--codeinclude-->
```csharp
[Has Valid Credential](../../../dotnet/Tests/Tests.cs) inside_block:hasValidCredential
```
<!--/codeinclude-->

{{ proto_method_tabs("services.connect.v1.Connect.HasValidCredential") }}

---

## Invoke Verification Flow on the Client

Once a Session has been [created](#create-session), the verification flow must be run on your end-user's device, using the {{ field_ref("CreateSessionResponse", "session.client_token") }} returned during Session creation.
Expand Down
12 changes: 12 additions & 0 deletions dotnet/Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,18 @@ await trinsic.Connect.CancelSessionAsync(new() {
});
// }

// hasValidCredential() {
await trinsic.Connect.HasValidCredentialAsync(new() {
Identity = new() {
Identity = "<phone number>",
Provider = IdentityProvider.Phone
},
CredentialRequestData = new() {
Type = VerificationType.GovernmentId
}
});
// }

} catch {
// We expect the above calls to fail due to lack of privileges
}
Expand Down

0 comments on commit a86977c

Please sign in to comment.