@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth 0.34.1-feature.SSISDK.45.135 → 0.34.1-feature.SSISDK.45.189
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +25 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -11
- package/dist/index.d.ts +8 -11
- package/dist/index.js +26 -40
- package/dist/index.js.map +1 -1
- package/package.json +17 -17
- package/src/agent/SIOPv2RP.ts +14 -25
- package/src/functions.ts +21 -22
- package/src/types/ISIOPv2RP.ts +6 -12
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IPluginMethodMap, IAgentContext, IResolver, IDIDManager, IKeyManager,
|
|
1
|
+
import { IPluginMethodMap, IAgentContext, IResolver, IDIDManager, IKeyManager, ICredentialVerifier, IAgentPlugin } from '@veramo/core';
|
|
2
2
|
import { ResponseURIType, ClaimPayloadCommonOpts, CallbackOpts, AuthorizationRequestPayload, RequestObjectPayload, AuthorizationRequestState, AuthorizationResponseStateWithVerifiedData, AuthorizationResponsePayload, VerifiedAuthorizationResponse, ResponseMode, SupportedVersion, IRPSessionManager, ClientMetadataOpts, VerifyJwtCallback, PresentationVerificationCallback, RP, URI, AuthorizationRequest } from '@sphereon/did-auth-siop';
|
|
3
3
|
import { CheckLinkedDomain } from '@sphereon/did-auth-siop-adapter';
|
|
4
4
|
import { DIDDocument } from '@sphereon/did-uni-client';
|
|
@@ -9,12 +9,13 @@ import { IIdentifierResolution, ManagedIdentifierOptsOrResult, ExternalIdentifie
|
|
|
9
9
|
import { IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service';
|
|
10
10
|
import { ICredentialValidation, SchemaValidation } from '@sphereon/ssi-sdk.credential-validation';
|
|
11
11
|
import { ImDLMdoc } from '@sphereon/ssi-sdk.mdl-mdoc';
|
|
12
|
-
import { IPDManager, VersionControlMode } from '@sphereon/ssi-sdk.pd-manager';
|
|
12
|
+
import { IPDManager, ImportDcqlQueryItem, VersionControlMode } from '@sphereon/ssi-sdk.pd-manager';
|
|
13
13
|
import { IPresentationExchange } from '@sphereon/ssi-sdk.presentation-exchange';
|
|
14
14
|
import { ISDJwtPlugin } from '@sphereon/ssi-sdk.sd-jwt';
|
|
15
15
|
import { AuthorizationRequestStateStatus } from '@sphereon/ssi-sdk.siopv2-oid4vp-common';
|
|
16
|
-
import {
|
|
16
|
+
import { HasherSync } from '@sphereon/ssi-types';
|
|
17
17
|
import { VerifyCallback } from '@sphereon/wellknown-dids-client';
|
|
18
|
+
import { DcqlQuery } from 'dcql';
|
|
18
19
|
import { Resolvable } from 'did-resolver';
|
|
19
20
|
import { EventEmitter } from 'events';
|
|
20
21
|
|
|
@@ -452,14 +453,10 @@ interface IVerifyAuthResponseStateArgs {
|
|
|
452
453
|
queryId?: string;
|
|
453
454
|
correlationId: string;
|
|
454
455
|
audience?: string;
|
|
455
|
-
|
|
456
|
-
}
|
|
457
|
-
interface IDefinitionPair {
|
|
458
|
-
definitionPayload?: IPresentationDefinition;
|
|
459
|
-
dcqlPayload?: DcqlQueryPayload;
|
|
456
|
+
dcqlQuery?: DcqlQuery;
|
|
460
457
|
}
|
|
461
458
|
interface ImportDefinitionsArgs {
|
|
462
|
-
|
|
459
|
+
importItems: Array<ImportDcqlQueryItem>;
|
|
463
460
|
tenantId?: string;
|
|
464
461
|
version?: string;
|
|
465
462
|
versionControlMode?: VersionControlMode;
|
|
@@ -525,7 +522,7 @@ interface ISIOPIdentifierOptions extends Omit<IDIDOptions, 'idOpts'> {
|
|
|
525
522
|
type CredentialOpts = {
|
|
526
523
|
hasher?: HasherSync;
|
|
527
524
|
};
|
|
528
|
-
type IRequiredContext = IAgentContext<IResolver & IDIDManager & IKeyManager & IIdentifierResolution &
|
|
525
|
+
type IRequiredContext = IAgentContext<IResolver & IDIDManager & IKeyManager & IIdentifierResolution & ICredentialValidation & ICredentialVerifier & IPresentationExchange & IPDManager & ISDJwtPlugin & IJwtService & ImDLMdoc>;
|
|
529
526
|
|
|
530
527
|
declare class RPInstance {
|
|
531
528
|
private _rp;
|
|
@@ -898,4 +895,4 @@ declare class SIOPv2RP implements IAgentPlugin {
|
|
|
898
895
|
private getDefaultOptions;
|
|
899
896
|
}
|
|
900
897
|
|
|
901
|
-
export { type CredentialOpts, type IAuthRequestDetails, type IAuthorizationRequestPayloads, type ICreateAuthRequestArgs, type
|
|
898
|
+
export { type CredentialOpts, type IAuthRequestDetails, type IAuthorizationRequestPayloads, type ICreateAuthRequestArgs, type IDeleteAuthStateArgs, type IGetAuthRequestStateArgs, type IGetAuthResponseStateArgs, type IGetRedirectUriArgs, type IPEXDefinitionPersistArgs, type IPEXInstanceOptions, type IPEXOptions, 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, VerifiedDataMode, plugin_schema as schema };
|
package/dist/index.js
CHANGED
|
@@ -335,11 +335,12 @@ var plugin_schema_default = {
|
|
|
335
335
|
// src/agent/SIOPv2RP.ts
|
|
336
336
|
import { AuthorizationResponseStateStatus, decodeUriAsJson } from "@sphereon/did-auth-siop";
|
|
337
337
|
import { getAgentResolver as getAgentResolver2 } from "@sphereon/ssi-sdk-ext.did-utils";
|
|
338
|
+
import { shaHasher as defaultHasher2 } from "@sphereon/ssi-sdk.core";
|
|
338
339
|
import { CredentialMapper as CredentialMapper2 } from "@sphereon/ssi-types";
|
|
339
340
|
import { DcqlQuery } from "dcql";
|
|
340
341
|
|
|
341
342
|
// src/functions.ts
|
|
342
|
-
import { InMemoryRPSessionManager, PassBy, PropertyTarget, ResponseMode, ResponseType, RevocationVerification, RP, Scope, SubjectType, SupportedVersion } from "@sphereon/did-auth-siop";
|
|
343
|
+
import { ClientIdentifierPrefix, InMemoryRPSessionManager, PassBy, PropertyTarget, ResponseMode, ResponseType, RevocationVerification, RP, Scope, SubjectType, SupportedVersion } from "@sphereon/did-auth-siop";
|
|
343
344
|
import { SigningAlgo } from "@sphereon/oid4vc-common";
|
|
344
345
|
import { getAgentDIDMethods, getAgentResolver } from "@sphereon/ssi-sdk-ext.did-utils";
|
|
345
346
|
import { isExternalIdentifierOIDFEntityIdOpts, isManagedIdentifierDidOpts, isManagedIdentifierDidResult, isManagedIdentifierX5cOpts } from "@sphereon/ssi-sdk-ext.identifier-resolution";
|
|
@@ -369,8 +370,7 @@ function getPresentationVerificationCallback(idOpts, context) {
|
|
|
369
370
|
async function presentationVerificationCallback(args, presentationSubmission) {
|
|
370
371
|
if (CredentialMapper.isSdJwtEncoded(args)) {
|
|
371
372
|
const result2 = await context.agent.verifySdJwtPresentation({
|
|
372
|
-
presentation: args
|
|
373
|
-
kb: true
|
|
373
|
+
presentation: args
|
|
374
374
|
});
|
|
375
375
|
return {
|
|
376
376
|
verified: !!result2.payload
|
|
@@ -413,7 +413,7 @@ async function createRPBuilder(args) {
|
|
|
413
413
|
const presentationDefinitionItems = await context.agent.pdmGetDefinitions({
|
|
414
414
|
filter: [
|
|
415
415
|
{
|
|
416
|
-
|
|
416
|
+
queryId: pexOpts.queryId,
|
|
417
417
|
version: pexOpts.version,
|
|
418
418
|
tenantId: pexOpts.tenantId
|
|
419
419
|
}
|
|
@@ -421,9 +421,8 @@ async function createRPBuilder(args) {
|
|
|
421
421
|
});
|
|
422
422
|
if (presentationDefinitionItems.length > 0) {
|
|
423
423
|
const presentationDefinitionItem = presentationDefinitionItems[0];
|
|
424
|
-
definition = presentationDefinitionItem.definitionPayload;
|
|
425
424
|
if (!dcqlQuery && presentationDefinitionItem.dcqlPayload) {
|
|
426
|
-
dcqlQuery = presentationDefinitionItem.dcqlPayload;
|
|
425
|
+
dcqlQuery = presentationDefinitionItem.dcqlPayload.dcqlQuery;
|
|
427
426
|
}
|
|
428
427
|
}
|
|
429
428
|
}
|
|
@@ -493,19 +492,16 @@ async function createRPBuilder(args) {
|
|
|
493
492
|
}, context)).withRevocationVerification(RevocationVerification.NEVER).withPresentationVerification(getPresentationVerificationCallback(identifierOpts.idOpts, context));
|
|
494
493
|
const oidfOpts = identifierOpts.oidfOpts;
|
|
495
494
|
if (oidfOpts && isExternalIdentifierOIDFEntityIdOpts(oidfOpts)) {
|
|
496
|
-
builder.withEntityId(oidfOpts.identifier, PropertyTarget.REQUEST_OBJECT)
|
|
495
|
+
builder.withEntityId(oidfOpts.identifier, PropertyTarget.REQUEST_OBJECT);
|
|
497
496
|
} else {
|
|
498
497
|
const resolution = await context.agent.identifierManagedGet(identifierOpts.idOpts);
|
|
499
|
-
|
|
498
|
+
const clientId = rpOpts.clientMetadataOpts?.client_id ?? resolution.issuer ?? (isManagedIdentifierDidResult(resolution) ? resolution.did : resolution.jwkThumbprint);
|
|
499
|
+
const clientIdPrefixed = prefixClientId(clientId);
|
|
500
|
+
builder.withClientId(clientIdPrefixed, PropertyTarget.REQUEST_OBJECT);
|
|
500
501
|
}
|
|
501
502
|
if (hasher) {
|
|
502
503
|
builder.withHasher(hasher);
|
|
503
504
|
}
|
|
504
|
-
if (definition) {
|
|
505
|
-
builder.withPresentationDefinition({
|
|
506
|
-
definition
|
|
507
|
-
}, PropertyTarget.REQUEST_OBJECT);
|
|
508
|
-
}
|
|
509
505
|
if (dcqlQuery) {
|
|
510
506
|
builder.withDcqlQuery(dcqlQuery);
|
|
511
507
|
}
|
|
@@ -565,6 +561,13 @@ function getSigningAlgo(type) {
|
|
|
565
561
|
}
|
|
566
562
|
}
|
|
567
563
|
__name(getSigningAlgo, "getSigningAlgo");
|
|
564
|
+
function prefixClientId(clientId) {
|
|
565
|
+
if (clientId.startsWith("did:")) {
|
|
566
|
+
return `${ClientIdentifierPrefix.DECENTRALIZED_IDENTIFIER}:${clientId}`;
|
|
567
|
+
}
|
|
568
|
+
return clientId;
|
|
569
|
+
}
|
|
570
|
+
__name(prefixClientId, "prefixClientId");
|
|
568
571
|
|
|
569
572
|
// src/RPInstance.ts
|
|
570
573
|
import { v4 as uuidv4 } from "uuid";
|
|
@@ -687,7 +690,6 @@ var RPInstance = class {
|
|
|
687
690
|
};
|
|
688
691
|
|
|
689
692
|
// src/agent/SIOPv2RP.ts
|
|
690
|
-
import { shaHasher as defaultHasher2 } from "@sphereon/ssi-sdk.core";
|
|
691
693
|
var SIOPv2RP = class _SIOPv2RP {
|
|
692
694
|
static {
|
|
693
695
|
__name(this, "SIOPv2RP");
|
|
@@ -830,39 +832,23 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
830
832
|
queryId: args.queryId
|
|
831
833
|
}, context).then((rp) => rp.get(context).then((rp2) => rp2.verifyAuthorizationResponse(authResponse, {
|
|
832
834
|
correlationId: args.correlationId,
|
|
833
|
-
...args.
|
|
834
|
-
dcqlQuery: args.
|
|
835
|
+
...args.dcqlQuery ? {
|
|
836
|
+
dcqlQuery: args.dcqlQuery
|
|
835
837
|
} : {},
|
|
836
838
|
audience: args.audience
|
|
837
839
|
})));
|
|
838
840
|
}
|
|
839
841
|
async siopImportDefinitions(args, context) {
|
|
840
|
-
const {
|
|
841
|
-
await Promise.all(
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
return Promise.reject(Error("Either dcqlPayload or definitionPayload must be suppplied"));
|
|
845
|
-
}
|
|
846
|
-
let definitionId;
|
|
847
|
-
if (definitionPair.dcqlPayload) {
|
|
848
|
-
DcqlQuery.validate(definitionPair.dcqlPayload.dcqlQuery);
|
|
849
|
-
console.log(`persisting DCQL definition ${definitionPair.dcqlPayload.queryId} with versionControlMode ${versionControlMode}`);
|
|
850
|
-
definitionId = definitionPair.dcqlPayload.queryId;
|
|
851
|
-
}
|
|
852
|
-
if (definitionPayload) {
|
|
853
|
-
await context.agent.pexValidateDefinition({
|
|
854
|
-
definition: definitionPayload
|
|
855
|
-
});
|
|
856
|
-
console.log(`persisting PEX definition ${definitionPayload.id} / ${definitionPayload.name} with versionControlMode ${versionControlMode}`);
|
|
857
|
-
definitionId = definitionPayload.id;
|
|
858
|
-
}
|
|
842
|
+
const { importItems, tenantId, version, versionControlMode } = args;
|
|
843
|
+
await Promise.all(importItems.map(async (importItem) => {
|
|
844
|
+
DcqlQuery.validate(importItem.query);
|
|
845
|
+
console.log(`persisting DCQL definition ${importItem.queryId} with versionControlMode ${versionControlMode}`);
|
|
859
846
|
return context.agent.pdmPersistDefinition({
|
|
860
847
|
definitionItem: {
|
|
861
|
-
|
|
848
|
+
queryId: importItem.queryId,
|
|
862
849
|
tenantId,
|
|
863
850
|
version,
|
|
864
|
-
|
|
865
|
-
dcqlPayload: definitionPair.dcqlPayload
|
|
851
|
+
query: importItem.query
|
|
866
852
|
},
|
|
867
853
|
opts: {
|
|
868
854
|
versionControlMode
|
|
@@ -980,12 +966,12 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
980
966
|
};
|
|
981
967
|
|
|
982
968
|
// src/types/ISIOPv2RP.ts
|
|
983
|
-
var VerifiedDataMode = /* @__PURE__ */ function(VerifiedDataMode2) {
|
|
969
|
+
var VerifiedDataMode = /* @__PURE__ */ (function(VerifiedDataMode2) {
|
|
984
970
|
VerifiedDataMode2["NONE"] = "none";
|
|
985
971
|
VerifiedDataMode2["VERIFIED_PRESENTATION"] = "vp";
|
|
986
972
|
VerifiedDataMode2["CREDENTIAL_SUBJECT_FLATTENED"] = "cs-flat";
|
|
987
973
|
return VerifiedDataMode2;
|
|
988
|
-
}({});
|
|
974
|
+
})({});
|
|
989
975
|
export {
|
|
990
976
|
SIOPv2RP,
|
|
991
977
|
VerifiedDataMode,
|