UNPKG

@microsoft/useragent-sdk

Version:

SDK for building decentralized identity wallets and enterprise agents.

77 lines (76 loc) 2.43 kB
import Identifier from '../Identifier'; import ClaimObject from '../credentials/ClaimObject'; import CryptoFactory from '../crypto/plugin/CryptoFactory'; /** * Optional Parameters to add to OIDCRequests. */ export declare type OptionalOIDCRequestParams = { /** * Opaque value to represent state on serverside. */ state?: string; /** * ClaimObject if OIDC Request involves issuance of credential. */ claimObject?: ClaimObject; /** * Claim Requests if requesting to be presented with credential. */ claimsRequested?: string[]; }; /** * Class to represent Open ID Connect Self-Issued Tokens * @class */ export default class OidcRequest { /** * Redirect URL for SIOP. */ redirectUrl: string; /** * Nonce for SIOP. */ nonce: string; /** * Sender of the request. */ sender: Identifier; /** * Optional claimObject attached to OIDC request. */ claimObject?: ClaimObject; /** * Opaque value to represent state on serverside. */ state?: string; /** * Optional Claim that is requested for presentation. */ claimsRequested?: string[]; /** * Instantiates an self-signed OIDC Request. * @param sender Identifier who will sign request. * @param redirectUrl Redirect URL for SIOP. * @param nonce Nonce for SIOP. * @param claimObject optional claimObject to attach to request. */ constructor(sender: Identifier, redirectUrl: string, nonce: string, options?: OptionalOIDCRequestParams); /** * Forms the request to spec and sign the request. * @param keyReference * @returns jwt in compact form. */ sign(keyReference: string): Promise<string>; /** * Parses and Verifies signed JWT. * @param signedRequest signed JWT containing OIDC request. * @returns OidcRequest Object if verified. */ static verifyAndParse(signedRequest: string, cryptoFactory?: CryptoFactory): Promise<OidcRequest>; /** * Respond to OIDC Request using identifier on the client side. * @param identifier the identifier used to sign response * @returns the body of the HTTP response if receive status 200. */ respondWith(identifier: Identifier, keyReference: string, claimObjects?: ClaimObject[]): Promise<string>; }