@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth
Version:
895 lines (889 loc) • 29.7 kB
text/typescript
import { IPluginMethodMap, IAgentContext, IResolver, IDIDManager, IKeyManager, ICredentialVerifier, IAgentPlugin } from '@veramo/core';
import { ResponseURIType, ClaimPayloadCommonOpts, CallbackOpts, AuthorizationRequestPayload, RequestObjectPayload, AuthorizationRequestState, AuthorizationResponseStateWithVerifiedData, AuthorizationResponsePayload, VerifiedAuthorizationResponse, ResponseMode, SupportedVersion, IRPSessionManager, ClientMetadataOpts, VerifyJwtCallback, RelyingPartyAttestation, RequestUriMethod, PresentationVerificationCallback, RP, URI, AuthorizationRequest } from '@sphereon/did-auth-siop';
import { CheckLinkedDomain } from '@sphereon/did-auth-siop-adapter';
import { DIDDocument } from '@sphereon/did-uni-client';
import { JwtIssuer } from '@sphereon/oid4vc-common';
import { IPresentationDefinition } from '@sphereon/pex';
import { IDIDOptions } from '@sphereon/ssi-sdk-ext.did-utils';
import { IIdentifierResolution, ManagedIdentifierOptsOrResult, ExternalIdentifierOIDFEntityIdOpts } from '@sphereon/ssi-sdk-ext.identifier-resolution';
import { IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service';
import { ICredentialValidation, SchemaValidation } from '@sphereon/ssi-sdk.credential-validation';
import { ImDLMdoc } from '@sphereon/ssi-sdk.mdl-mdoc';
import { IPDManager, ImportDcqlQueryItem, VersionControlMode } from '@sphereon/ssi-sdk.pd-manager';
import { IPresentationExchange } from '@sphereon/ssi-sdk.presentation-exchange';
import { ISDJwtPlugin } from '@sphereon/ssi-sdk.sd-jwt';
import { AuthorizationRequestStateStatus } from '@sphereon/ssi-sdk.siopv2-oid4vp-common';
import { HasherSync } from '@sphereon/ssi-types';
import { VerifyCallback } from '@sphereon/wellknown-dids-client';
import { DcqlQuery } from 'dcql';
import { Resolvable } from 'did-resolver';
import { EventEmitter } from 'events';
var IDidAuthSiopOpAuthenticator = {
components: {
schemas: {
IGetSiopSessionArgs: {
type: "object",
properties: {
sessionId: {
type: "string"
},
additionalProperties: false
},
required: [
"sessionId"
],
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.getSessionForSiop } "
},
IRegisterSiopSessionArgs: {
type: "object",
properties: {
identifier: {
type: "object",
properties: {
did: {
type: "string"
},
alias: {
type: "string"
},
provider: {
type: "string"
},
controllerKeyId: {
type: "string"
},
keys: {
type: "array",
items: {
type: "object",
properties: {
additionalProperties: true
}
}
},
services: {
type: "array",
items: {
type: "object",
properties: {
additionalProperties: true
}
}
}
},
additionalProperties: false,
required: [
"did",
"provider",
"keys",
"services"
]
},
sessionId: {
type: "string"
},
expiresIn: {
type: "number"
},
additionalProperties: false
},
required: [
"identifier"
],
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.registerSessionForSiop } "
},
IRemoveSiopSessionArgs: {
type: "object",
properties: {
sessionId: {
type: "string"
},
additionalProperties: false
},
required: [
"sessionId"
],
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.removeSessionForSiop } "
},
IAuthenticateWithSiopArgs: {
type: "object",
properties: {
sessionId: {
type: "string"
},
stateId: {
type: "string"
},
redirectUrl: {
type: "string"
},
additionalProperties: false
},
required: [
"sessionId",
"stateId",
"redirectUrl"
],
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.authenticateWithSiop } "
},
IResponse: {
type: "object",
properties: {
status: {
type: "number"
},
additionalProperties: true
},
required: [
"status"
],
description: "Result of {@link DidAuthSiopOpAuthenticator.authenticateWithSiop & DidAuthSiopOpAuthenticator.sendSiopAuthenticationResponse } "
},
IGetSiopAuthenticationRequestFromRpArgs: {
type: "object",
properties: {
sessionId: {
type: "string"
},
stateId: {
type: "string"
},
redirectUrl: {
type: "string"
},
additionalProperties: false
},
required: [
"sessionId",
"stateId",
"redirectUrl"
],
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.getSiopAuthenticationRequestFromRP } "
},
ParsedAuthenticationRequestURI: {
type: "object",
properties: {
jwt: {
type: "string"
},
requestPayload: {
type: "object",
properties: {
additionalProperties: true
}
},
registration: {
type: "object",
properties: {
additionalProperties: true
}
},
additionalProperties: false
},
required: [
"jwt",
"requestPayload",
"registration"
],
description: "Result of {@link DidAuthSiopOpAuthenticator.getSiopAuthenticationRequestFromRP } "
},
IGetSiopAuthenticationRequestDetailsArgs: {
type: "object",
properties: {
sessionId: {
type: "string"
},
verifiedAuthenticationRequest: {
type: "object",
properties: {
additionalProperties: true
}
},
credentialFilter: {
type: "object",
properties: {
additionalProperties: true
}
},
additionalProperties: false
},
required: [
"sessionId",
"verifiedAuthenticationRequest"
],
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.getSiopAuthenticationRequestDetails } "
},
IAuthRequestDetails: {
type: "object",
properties: {
id: {
type: "string"
},
alsoKnownAs: {
type: "array",
items: {
type: "string"
}
},
vpResponseOpts: {
type: "object",
properties: {
additionalProperties: true
}
},
additionalProperties: false
},
required: [
"id",
"vpResponseOpts"
],
description: "Result of {@link DidAuthSiopOpAuthenticator.getSiopAuthenticationRequestDetails } "
},
IVerifySiopAuthenticationRequestUriArgs: {
type: "object",
properties: {
sessionId: {
type: "string"
},
ParsedAuthenticationRequestURI: {
type: "object",
properties: {
additionalProperties: true
}
},
additionalProperties: false
},
required: [
"sessionId",
"ParsedAuthenticationRequestURI"
],
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.verifySiopAuthenticationRequestURI } "
},
VerifiedAuthorizationRequest: {
type: "object",
properties: {
payload: {
type: "object",
properties: {
additionalProperties: true
}
},
presentationDefinitions: {
type: "object",
properties: {
additionalProperties: true
}
},
verifyOpts: {
type: "object",
properties: {
additionalProperties: true
}
},
additionalProperties: false
},
required: [
"payload",
"verifyOpts"
],
description: "Result of {@link DidAuthSiopOpAuthenticator.verifySiopAuthenticationRequestURI } "
},
ISendSiopAuthenticationResponseArgs: {
type: "object",
properties: {
sessionId: {
type: "string"
},
verifiedAuthenticationRequest: {
type: "object",
properties: {
additionalProperties: true
}
},
verifiablePresentationResponse: {
type: "object",
properties: {
additionalProperties: true
}
},
additionalProperties: false
},
required: [
"sessionId",
"verifiedAuthenticationRequest"
],
description: "Arguments needed for {@link DidAuthSiopOpAuthenticator.sendSiopAuthenticationResponse } "
}
},
methods: {
getSessionForSiop: {
description: "Get SIOP session",
"arguments": {
$ref: "#/components/schemas/IGetSiopSessionArgs"
},
returnType: "object"
},
registerSessionForSiop: {
description: "Register SIOP session",
"arguments": {
$ref: "#/components/schemas/IRegisterSiopSessionArgs"
},
returnType: "object"
},
removeSessionForSiop: {
description: "Remove SIOP session",
"arguments": {
$ref: "#/components/schemas/IRemoveSiopSessionArgs"
},
returnType: "boolean"
},
authenticateWithSiop: {
description: "Authenticate using DID Auth SIOP",
"arguments": {
$ref: "#/components/schemas/IAuthenticateWithSiopArgs"
},
returnType: {
$ref: "#/components/schemas/Response"
}
},
getSiopAuthenticationRequestFromRP: {
description: "Get authentication request from RP",
"arguments": {
$ref: "#/components/schemas/IGetSiopAuthenticationRequestFromRpArgs"
},
returnType: {
$ref: "#/components/schemas/ParsedAuthenticationRequestURI"
}
},
getSiopAuthenticationRequestDetails: {
description: "Get authentication request details",
"arguments": {
$ref: "#/components/schemas/IGetSiopAuthenticationRequestDetailsArgs"
},
returnType: {
$ref: "#/components/schemas/IAuthRequestDetails"
}
},
verifySiopAuthenticationRequestURI: {
description: "Verify authentication request URI",
"arguments": {
$ref: "#/components/schemas/IVerifySiopAuthenticationRequestUriArgs"
},
returnType: {
$ref: "#/components/schemas/VerifiedAuthorizationRequest"
}
},
sendSiopAuthenticationResponse: {
description: "Send authentication response",
"arguments": {
$ref: "#/components/schemas/ISendSiopAuthenticationResponseArgs"
},
returnType: {
$ref: "#/components/schemas/IRequiredContext"
}
}
}
}
};
var plugin_schema = {
IDidAuthSiopOpAuthenticator: IDidAuthSiopOpAuthenticator
};
interface ISIOPv2RP extends IPluginMethodMap {
siopCreateAuthRequestURI(createArgs: ICreateAuthRequestArgs, context: IRequiredContext): Promise<string>;
siopCreateAuthRequestPayloads(createArgs: ICreateAuthRequestArgs, context: IRequiredContext): Promise<IAuthorizationRequestPayloads>;
siopGetAuthRequestState(args: IGetAuthRequestStateArgs, context: IRequiredContext): Promise<AuthorizationRequestState | undefined>;
siopGetAuthResponseState(args: IGetAuthResponseStateArgs, context: IRequiredContext): Promise<AuthorizationResponseStateWithVerifiedData | undefined>;
siopUpdateAuthRequestState(args: IUpdateRequestStateArgs, context: IRequiredContext): Promise<AuthorizationRequestState>;
siopDeleteAuthState(args: IDeleteAuthStateArgs, context: IRequiredContext): Promise<boolean>;
siopVerifyAuthResponse(args: IVerifyAuthResponseStateArgs, context: IRequiredContext): Promise<VerifiedAuthorizationResponse>;
siopImportDefinitions(args: ImportDefinitionsArgs, context: IRequiredContext): Promise<void>;
siopGetRedirectURI(args: IGetRedirectUriArgs, context: IRequiredContext): Promise<string | undefined>;
}
interface ISiopv2RPOpts {
defaultOpts?: IRPDefaultOpts;
instanceOpts?: IPEXInstanceOptions[];
}
interface IRPDefaultOpts extends IRPOptions {
}
interface ICreateAuthRequestArgs {
queryId: string;
correlationId: string;
useQueryIdInstance?: boolean;
responseURIType: ResponseURIType;
responseURI: string;
responseRedirectURI?: string;
jwtIssuer?: JwtIssuer;
requestByReferenceURI?: string;
nonce?: string;
state?: string;
claims?: ClaimPayloadCommonOpts;
callback?: CallbackOpts;
}
interface IGetAuthRequestStateArgs {
correlationId: string;
queryId?: string;
errorOnNotFound?: boolean;
}
interface IGetAuthResponseStateArgs {
correlationId: string;
queryId?: string;
errorOnNotFound?: boolean;
progressRequestStateTo?: AuthorizationRequestStateStatus;
}
interface IUpdateRequestStateArgs {
queryId?: string;
correlationId: string;
state: AuthorizationRequestStateStatus;
error?: string;
}
interface IDeleteAuthStateArgs {
correlationId: string;
queryId?: string;
}
interface IVerifyAuthResponseStateArgs {
authorizationResponse: string | AuthorizationResponsePayload;
queryId?: string;
correlationId: string;
audience?: string;
dcqlQuery?: DcqlQuery;
}
interface ImportDefinitionsArgs {
importItems: Array<ImportDcqlQueryItem>;
tenantId?: string;
version?: string;
versionControlMode?: VersionControlMode;
}
interface IGetRedirectUriArgs {
correlationId: string;
queryId?: string;
state?: string;
}
interface IAuthorizationRequestPayloads {
authorizationRequest: AuthorizationRequestPayload;
requestObject?: string;
requestObjectDecoded?: RequestObjectPayload;
}
interface IPEXDefinitionPersistArgs extends IPEXInstanceOptions {
definition: IPresentationDefinition;
ttl?: number;
}
interface ISiopRPInstanceArgs {
createWhenNotPresent: boolean;
queryId?: string;
responseRedirectURI?: string;
}
interface IPEXInstanceOptions extends IPresentationOptions {
rpOpts?: IRPOptions;
}
interface IRPOptions {
responseMode?: ResponseMode;
supportedVersions?: SupportedVersion[];
sessionManager?: IRPSessionManager;
clientMetadataOpts?: ClientMetadataOpts;
expiresIn?: number;
eventEmitter?: EventEmitter;
credentialOpts?: CredentialOpts;
verificationPolicies?: VerificationPolicies;
identifierOpts: ISIOPIdentifierOptions;
verifyJwtCallback?: VerifyJwtCallback;
responseRedirectUri?: string;
transactionData?: string[];
verifierInfo?: RelyingPartyAttestation[];
verifierAttestations?: RelyingPartyAttestation[];
requestUriMethod?: RequestUriMethod;
expectedOrigins?: string[];
walletNonce?: string;
}
interface IPresentationOptions {
queryId: string;
presentationVerifyCallback?: PresentationVerificationCallback;
}
type VerificationPolicies = {
schemaValidation: SchemaValidation;
};
interface PerDidResolver {
didMethod: string;
resolver: Resolvable;
}
interface IAuthRequestDetails {
rpDIDDocument?: DIDDocument;
id: string;
alsoKnownAs?: string[];
}
interface ISIOPIdentifierOptions extends Omit<IDIDOptions, 'idOpts'> {
idOpts: ManagedIdentifierOptsOrResult;
oidfOpts?: ExternalIdentifierOIDFEntityIdOpts;
checkLinkedDomains?: CheckLinkedDomain;
wellknownDIDVerifyCallback?: VerifyCallback;
}
type CredentialOpts = {
hasher?: HasherSync;
};
type IRequiredContext = IAgentContext<IResolver & IDIDManager & IKeyManager & IIdentifierResolution & ICredentialValidation & ICredentialVerifier & IPresentationExchange & IPDManager & ISDJwtPlugin & IJwtService & ImDLMdoc>;
declare class RPInstance {
private _rp;
private readonly _presentationOptions;
private readonly _rpOptions;
constructor({ rpOpts, pexOpts }: {
rpOpts: IRPOptions;
pexOpts?: IPresentationOptions;
});
get(context: IRequiredContext): Promise<RP>;
get rpOptions(): IRPOptions;
get presentationOptions(): IPresentationOptions | undefined;
createAuthorizationRequestURI(createArgs: ICreateAuthRequestArgs, context: IRequiredContext): Promise<URI>;
createAuthorizationRequest(createArgs: Omit<ICreateAuthRequestArgs, 'queryId'>, context: IRequiredContext): Promise<AuthorizationRequest>;
}
declare class SIOPv2RP implements IAgentPlugin {
private readonly opts;
private static readonly _DEFAULT_OPTS_KEY;
private readonly instances;
readonly schema: {
components: {
schemas: {
IGetSiopSessionArgs: {
type: string;
properties: {
sessionId: {
type: string;
};
additionalProperties: boolean;
};
required: string[];
description: string;
};
IRegisterSiopSessionArgs: {
type: string;
properties: {
identifier: {
type: string;
properties: {
did: {
type: string;
};
alias: {
type: string;
};
provider: {
type: string;
};
controllerKeyId: {
type: string;
};
keys: {
type: string;
items: {
type: string;
properties: {
additionalProperties: boolean;
};
};
};
services: {
type: string;
items: {
type: string;
properties: {
additionalProperties: boolean;
};
};
};
};
additionalProperties: boolean;
required: string[];
};
sessionId: {
type: string;
};
expiresIn: {
type: string;
};
additionalProperties: boolean;
};
required: string[];
description: string;
};
IRemoveSiopSessionArgs: {
type: string;
properties: {
sessionId: {
type: string;
};
additionalProperties: boolean;
};
required: string[];
description: string;
};
IAuthenticateWithSiopArgs: {
type: string;
properties: {
sessionId: {
type: string;
};
stateId: {
type: string;
};
redirectUrl: {
type: string;
};
additionalProperties: boolean;
};
required: string[];
description: string;
};
IResponse: {
type: string;
properties: {
status: {
type: string;
};
additionalProperties: boolean;
};
required: string[];
description: string;
};
IGetSiopAuthenticationRequestFromRpArgs: {
type: string;
properties: {
sessionId: {
type: string;
};
stateId: {
type: string;
};
redirectUrl: {
type: string;
};
additionalProperties: boolean;
};
required: string[];
description: string;
};
ParsedAuthenticationRequestURI: {
type: string;
properties: {
jwt: {
type: string;
};
requestPayload: {
type: string;
properties: {
additionalProperties: boolean;
};
};
registration: {
type: string;
properties: {
additionalProperties: boolean;
};
};
additionalProperties: boolean;
};
required: string[];
description: string;
};
IGetSiopAuthenticationRequestDetailsArgs: {
type: string;
properties: {
sessionId: {
type: string;
};
verifiedAuthenticationRequest: {
type: string;
properties: {
additionalProperties: boolean;
};
};
credentialFilter: {
type: string;
properties: {
additionalProperties: boolean;
};
};
additionalProperties: boolean;
};
required: string[];
description: string;
};
IAuthRequestDetails: {
type: string;
properties: {
id: {
type: string;
};
alsoKnownAs: {
type: string;
items: {
type: string;
};
};
vpResponseOpts: {
type: string;
properties: {
additionalProperties: boolean;
};
};
additionalProperties: boolean;
};
required: string[];
description: string;
};
IVerifySiopAuthenticationRequestUriArgs: {
type: string;
properties: {
sessionId: {
type: string;
};
ParsedAuthenticationRequestURI: {
type: string;
properties: {
additionalProperties: boolean;
};
};
additionalProperties: boolean;
};
required: string[];
description: string;
};
VerifiedAuthorizationRequest: {
type: string;
properties: {
payload: {
type: string;
properties: {
additionalProperties: boolean;
};
};
presentationDefinitions: {
type: string;
properties: {
additionalProperties: boolean;
};
};
verifyOpts: {
type: string;
properties: {
additionalProperties: boolean;
};
};
additionalProperties: boolean;
};
required: string[];
description: string;
};
ISendSiopAuthenticationResponseArgs: {
type: string;
properties: {
sessionId: {
type: string;
};
verifiedAuthenticationRequest: {
type: string;
properties: {
additionalProperties: boolean;
};
};
verifiablePresentationResponse: {
type: string;
properties: {
additionalProperties: boolean;
};
};
additionalProperties: boolean;
};
required: string[];
description: string;
};
};
methods: {
getSessionForSiop: {
description: string;
arguments: {
$ref: string;
};
returnType: string;
};
registerSessionForSiop: {
description: string;
arguments: {
$ref: string;
};
returnType: string;
};
removeSessionForSiop: {
description: string;
arguments: {
$ref: string;
};
returnType: string;
};
authenticateWithSiop: {
description: string;
arguments: {
$ref: string;
};
returnType: {
$ref: string;
};
};
getSiopAuthenticationRequestFromRP: {
description: string;
arguments: {
$ref: string;
};
returnType: {
$ref: string;
};
};
getSiopAuthenticationRequestDetails: {
description: string;
arguments: {
$ref: string;
};
returnType: {
$ref: string;
};
};
verifySiopAuthenticationRequestURI: {
description: string;
arguments: {
$ref: string;
};
returnType: {
$ref: string;
};
};
sendSiopAuthenticationResponse: {
description: string;
arguments: {
$ref: string;
};
returnType: {
$ref: string;
};
};
};
};
};
readonly methods: ISIOPv2RP;
constructor(opts: ISiopv2RPOpts);
setDefaultOpts(rpDefaultOpts: IRPDefaultOpts, context: IRequiredContext): void;
private createAuthorizationRequestURI;
private createAuthorizationRequestPayloads;
private siopGetRequestState;
private siopGetResponseState;
private presentationOrClaimsFrom;
private siopUpdateRequestState;
private siopDeleteState;
private siopVerifyAuthResponse;
private siopImportDefinitions;
private siopGetRedirectURI;
getRPInstance({ createWhenNotPresent, queryId, responseRedirectURI }: ISiopRPInstanceArgs, context: IRequiredContext): Promise<RPInstance>;
getRPOptions(context: IRequiredContext, opts: {
queryId?: string;
responseRedirectURI?: string;
}): Promise<IRPOptions>;
getInstanceOpts(queryId?: string): IPEXInstanceOptions | undefined;
private getDefaultOptions;
}
export { type CredentialOpts, type IAuthRequestDetails, type IAuthorizationRequestPayloads, type ICreateAuthRequestArgs, type IDeleteAuthStateArgs, type IGetAuthRequestStateArgs, type IGetAuthResponseStateArgs, type IGetRedirectUriArgs, type IPEXDefinitionPersistArgs, type IPEXInstanceOptions, type IPresentationOptions, type IRPDefaultOpts, type IRPOptions, type IRequiredContext, type ISIOPIdentifierOptions, type ISIOPv2RP, type ISiopRPInstanceArgs, type ISiopv2RPOpts, type IUpdateRequestStateArgs, type IVerifyAuthResponseStateArgs, type ImportDefinitionsArgs, type PerDidResolver, SIOPv2RP, type VerificationPolicies, plugin_schema as schema };