Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API reference for hasValidCredential #1586

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions docs/reference/services/connect-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,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
Loading