@serv-official/vault-sdk
v0.0.0-alpha.22
Published
This is a SDK to integrate with Serv Vault+. In order to be able to use correctly you must hast the Extension already installed in your Chrome browser.
Downloads
49
Readme
#Vault-SDK
This is a SDK to integrate with Serv Vault+. In order to be able to use correctly you must hast the Extension already installed in your Chrome browser.
Installation
You can install the SDK with your favorite package manager:
npm i @serv-official/vault-sdk
yarn add @serv-official/vault-sdk
or
pnpm i @serv-official/vault-sdk
Usage
The SDK exposes different functions that you can use.
- First you need to request access from your website
import * as Serv from "@serv-official/vault-sdk";
// ... some code
const someName = async () => {
const isSuccess = await Serv.requestAccess();
if (isSuccess) {
// handle success
} else {
// handle error
}
};
After calling the requestAccess
function the Vault+ Chrome Extension should open. Follow the steps it requires you to do and, at the end you should grant or deny the access.
Right now we don't have error handling. If you close the extension window the promise requestAccess
returns won't be resolved or rejected. This behavior applies to every other function of the Serv
object.
Once you have succesfully granted access to you web application you can call what evet other function the Serv object has.
Documentation
requestAccess
Function used to request access for a specific website. It returns a boolean value stating if the access was successfully granted by the Vault+ Extension or not.
requestAccess(): Promise<boolean>
denyAccess
Function used to deny access for a specific website. It returns a boolean value stating if the access was successfully revoked by the Vault+ Extension or not.
denyAccess(): Promise<boolean>
getCertificates
Function that return all the granted certificates from the Vault+ Extension.
getCertificates(): Promise<EventGetCertificatesResponseData>
The type EventGetCertificatesResponseData
is a list of CredentialSchema
claimCertificate
Function that claims a specific cetificate.
type CertificateName =
| "marine-corps"
| "us-army"
| "us-air-force"
| "us-coast-guard"
| "us-navy";
claimCertificate(certificateName: CertificateName): Promise<EventClaimCertificateResponseData>
The type EventClaimCertificateResponseData
is also a CredentialSchema
CredentialSchema
Depending on the credential the credentialSubject can change its type.
export type CredentialSchema<
CredentialSubject extends object = Record<any, any>
> = {
issuanceDate: number;
credentialSubject: CredentialSubject;
issuer: {
id: string;
};
id: string;
type: string[];
credentialStatus: {
id: string;
type: "valid";
};
"@context": string[];
proof: {
type: "JwtProof2020";
jwt: string;
};
};