@sphereon/ssi-sdk.presentation-exchange 0.17.6-unstable.74 → 0.18.0

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.
@@ -1,13 +1,11 @@
1
- import { IIdentifierOpts } from '@sphereon/ssi-sdk-ext.did-utils';
2
1
  import { IPEXOptions, IPEXPresentationSignCallback, IRequiredContext } from './types/IPresentationExchange';
3
2
  import { IPresentationDefinition } from '@sphereon/pex';
4
- import { ProofFormat } from '@veramo/core';
5
3
  import { Format } from '@sphereon/pex-models';
6
4
  export declare function getPresentationDefinition(pexOptions?: IPEXOptions): Promise<IPresentationDefinition | undefined>;
7
- export declare function createPEXPresentationSignCallback(args: {
8
- idOpts: IIdentifierOpts;
5
+ export declare function createPEXPresentationSignCallback({ kid, fetchRemoteContexts, format, domain, challenge, }: {
6
+ kid: string;
9
7
  fetchRemoteContexts?: boolean;
10
- format?: Format | ProofFormat;
8
+ format?: Format;
11
9
  domain?: string;
12
10
  challenge?: string;
13
11
  }, context: IRequiredContext): Promise<IPEXPresentationSignCallback>;
@@ -1 +1 @@
1
- {"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6E,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAC5I,OAAO,EAAE,WAAW,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAC3G,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,EAAuB,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAE7C,wBAAsB,yBAAyB,CAAC,UAAU,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAAC,CAItH;AAED,wBAAsB,iCAAiC,CACrD,IAAI,EAAE;IACJ,MAAM,EAAE,eAAe,CAAA;IACvB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,CAAA;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,EACD,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,4BAA4B,CAAC,CA+DvC"}
1
+ {"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAC3G,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAGvD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAE7C,wBAAsB,yBAAyB,CAAC,UAAU,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAAC,CAItH;AAED,wBAAsB,iCAAiC,CACrD,EACE,GAAG,EACH,mBAAmB,EACnB,MAAM,EACN,MAAM,EACN,SAAS,GACV,EAAE;IACD,GAAG,EAAE,MAAM,CAAA;IACX,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,EACD,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,4BAA4B,CAAC,CA4BvC"}
package/dist/functions.js CHANGED
@@ -10,62 +10,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.createPEXPresentationSignCallback = exports.getPresentationDefinition = void 0;
13
- const ssi_sdk_ext_did_utils_1 = require("@sphereon/ssi-sdk-ext.did-utils");
14
13
  const ssi_types_1 = require("@sphereon/ssi-types");
15
14
  function getPresentationDefinition(pexOptions) {
16
15
  return __awaiter(this, void 0, void 0, function* () {
17
16
  return pexOptions === null || pexOptions === void 0 ? void 0 : pexOptions.definition;
18
17
  /*const store = await getPresentationDefinitionStore(pexOptions)
19
- return store && pexOptions?.definitionId ? store.get(pexOptions?.definitionId) : undefined*/
18
+ return store && pexOptions?.definitionId ? store.get(pexOptions?.definitionId) : undefined*/
20
19
  });
21
20
  }
22
21
  exports.getPresentationDefinition = getPresentationDefinition;
23
- function createPEXPresentationSignCallback(args, context) {
22
+ function createPEXPresentationSignCallback({ kid, fetchRemoteContexts, format, domain, challenge, }, context) {
24
23
  return __awaiter(this, void 0, void 0, function* () {
25
24
  return ({ presentation, domain, presentationDefinition, format, challenge, }) => __awaiter(this, void 0, void 0, function* () {
26
- var _a, _b;
27
- const idOpts = args.idOpts;
28
- const id = yield (0, ssi_sdk_ext_did_utils_1.getIdentifier)(idOpts, context);
29
- if (typeof idOpts.identifier === 'string') {
30
- idOpts.identifier = id;
31
- }
32
- const key = yield (0, ssi_sdk_ext_did_utils_1.getKey)(id, 'authentication', context, idOpts.kid);
33
- const didResolution = yield (0, ssi_sdk_ext_did_utils_1.getAgentResolver)(context).resolve(idOpts.identifier.did);
34
- const vms = yield (0, ssi_sdk_ext_did_utils_1.dereferenceDidKeysWithJwkSupport)(didResolution.didDocument, (_a = idOpts.verificationMethodSection) !== null && _a !== void 0 ? _a : 'authentication', context);
35
- const vm = vms.find((vm) => vm.publicKeyHex === key.publicKeyHex);
36
- if (!vm) {
37
- throw Error(`Could not resolve DID document or match signing key to did ${idOpts.identifier.did}`);
38
- }
39
- let proofFormat = 'jwt';
40
- const formatOptions = (_b = format !== null && format !== void 0 ? format : args.format) !== null && _b !== void 0 ? _b : presentationDefinition.format;
41
- if (formatOptions) {
42
- if (typeof formatOptions === 'object') {
43
- const formats = Object.keys(formatOptions).map((form) => (form.includes('ldp') ? 'lds' : 'jwt'));
44
- if (!formats.includes('jwt')) {
45
- proofFormat = 'lds';
46
- }
47
- }
48
- else {
49
- proofFormat = formatOptions;
50
- }
51
- }
52
- let header;
53
- if (format === 'jwt') {
54
- header = {
55
- kid: vm.id,
56
- };
57
- }
58
- // we ignore the alg / proof_format for now, as we already have the kid anyway at this point
59
- // todo: look for jwt_vc_json and remove types and @context
25
+ const formatOptions = format !== null && format !== void 0 ? format : presentationDefinition.format;
26
+ const proofFormat = formatOptions && (!!formatOptions.ldp || !!formatOptions.ldp_vp) ? 'lds' : 'jwt';
60
27
  const vp = yield context.agent.createVerifiablePresentation({
61
- presentation: presentation,
62
- removeOriginalFields: true,
63
- keyRef: key.kid,
64
- domain: domain !== null && domain !== void 0 ? domain : args.domain,
65
- challenge: challenge !== null && challenge !== void 0 ? challenge : args.challenge,
66
- fetchRemoteContexts: args.fetchRemoteContexts !== false,
28
+ presentation,
29
+ keyRef: kid,
30
+ domain,
31
+ challenge,
32
+ fetchRemoteContexts: fetchRemoteContexts !== undefined ? fetchRemoteContexts : true,
67
33
  proofFormat,
68
- header,
69
34
  });
70
35
  // makes sure we extract an actual JWT from the internal representation in case it is a JWT
71
36
  return ssi_types_1.CredentialMapper.storedPresentationToOriginalFormat(vp);
@@ -1 +1 @@
1
- {"version":3,"file":"functions.js","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2EAA4I;AAI5I,mDAA2H;AAG3H,SAAsB,yBAAyB,CAAC,UAAwB;;QACtE,OAAO,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,UAAU,CAAA;QAC7B;sGAC8F;IAChG,CAAC;CAAA;AAJD,8DAIC;AAED,SAAsB,iCAAiC,CACrD,IAMC,EACD,OAAyB;;QAEzB,OAAO,CAAO,EACZ,YAAY,EACZ,MAAM,EACN,sBAAsB,EACtB,MAAM,EACN,SAAS,GAOV,EAAsC,EAAE;;YACvC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;YAC1B,MAAM,EAAE,GAAG,MAAM,IAAA,qCAAa,EAAC,MAAM,EAAE,OAAO,CAAC,CAAA;YAC/C,IAA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AAE;YACvC,MAAM,aAAa,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,sBAAsB,CAAC,MAAM,CAAA;YAC7D,MAAM,WAAW,GAAG,aAAa,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAA;YAEpG,MAAM,EAAE,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,4BAA4B,CAAC;gBAC1D,YAAY;gBACZ,MAAM,EAAE,GAAG;gBACX,MAAM;gBACN,SAAS;gBACT,mBAAmB,EAAE,mBAAmB,KAAK,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI;gBACnF,WAAW;aACZ,CAAC,CAAA;YACF,2FAA2F;YAC3F,OAAO,4BAAgB,CAAC,kCAAkC,CAAC,EAA+B,CAAC,CAAA;QAC7F,CAAC,CAAA,CAAA;IACH,CAAC;CAAA;AA3CD,8EA2CC"}
@@ -1,5 +1,5 @@
1
- import { FindCredentialsArgs, IAgentContext, ICredentialPlugin, IDataStoreORM, IDIDManager, IIdentifier, IPluginMethodMap, IResolver, PresentationPayload } from '@veramo/core';
2
- import { IPresentation, Optional, W3CVerifiableCredential, W3CVerifiablePresentation } from '@sphereon/ssi-types';
1
+ import { DIDDocumentSection, FindCredentialsArgs, IAgentContext, IDataStoreORM, IDIDManager, IIdentifier, IPluginMethodMap, PresentationPayload } from '@veramo/core';
2
+ import { W3CVerifiableCredential, W3CVerifiablePresentation } from '@sphereon/ssi-types';
3
3
  import { IKeyValueStore, IValueData } from '@sphereon/ssi-sdk.kv-store-temp';
4
4
  import { IPresentationDefinition, PEVersion, SelectResults } from '@sphereon/pex';
5
5
  import { Format, InputDescriptorV1, InputDescriptorV2 } from '@sphereon/pex-models';
@@ -63,14 +63,19 @@ export interface IPEXFilterResult {
63
63
  selectResults: SelectResults;
64
64
  filteredCredentials: W3CVerifiableCredential[];
65
65
  }
66
+ export interface IIdentifierOpts {
67
+ identifier: IIdentifier | string;
68
+ verificationMethodSection?: DIDDocumentSection;
69
+ kid?: string;
70
+ }
66
71
  export interface VersionDiscoveryResult {
67
72
  version?: PEVersion;
68
73
  error?: string;
69
74
  }
70
75
  export type IPEXPresentationSignCallback = (args: IPEXPresentationSignCallBackParams) => Promise<W3CVerifiablePresentation>;
71
76
  export interface IPEXPresentationSignCallBackParams {
72
- presentation: IPresentation | Optional<PresentationPayload, 'holder'>;
77
+ presentation: PresentationPayload;
73
78
  presentationDefinition: IPresentationDefinition;
74
79
  }
75
- export type IRequiredContext = IAgentContext<IDataStoreORM & IResolver & IDIDManager & ICredentialPlugin>;
80
+ export type IRequiredContext = IAgentContext<IDataStoreORM & IDIDManager>;
76
81
  //# sourceMappingURL=IPresentationExchange.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IPresentationExchange.d.ts","sourceRoot":"","sources":["../../src/types/IPresentationExchange.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,mBAAmB,EACpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AACjH,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAC5E,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACjF,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAEnF,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D,qBAAqB,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAAC,CAAA;IAE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AAM,gBAAgB,GAAG,aAAa,CAAC,aAAa,GAAG,WAAW,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sphereon/ssi-sdk.presentation-exchange",
3
- "version": "0.17.6-unstable.74+1bd41ad0",
3
+ "version": "0.18.0",
4
4
  "source": "src/index.ts",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,16 +14,16 @@
14
14
  "build:clean": "tsc --build --clean && tsc --build"
15
15
  },
16
16
  "dependencies": {
17
- "@sphereon/pex": "2.2.1-unstable.0",
18
- "@sphereon/pex-models": "^2.1.1",
17
+ "@sphereon/pex": "2.1.2",
18
+ "@sphereon/pex-models": "^2.1.0",
19
19
  "@sphereon/ssi-sdk-ext.did-utils": "0.15.0",
20
- "@sphereon/ssi-sdk.kv-store-temp": "0.17.6-unstable.74+1bd41ad0",
21
- "@sphereon/ssi-types": "0.17.6-unstable.74+1bd41ad0",
20
+ "@sphereon/ssi-sdk.kv-store-temp": "0.18.0",
21
+ "@sphereon/ssi-types": "0.18.0",
22
22
  "@veramo/core": "4.2.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@sphereon/did-uni-client": "^0.6.0",
26
- "@sphereon/ssi-sdk.agent-config": "0.17.6-unstable.74+1bd41ad0",
26
+ "@sphereon/ssi-sdk.agent-config": "0.18.0",
27
27
  "@types/json-buffer": "^3.0.0",
28
28
  "@veramo/did-provider-key": "4.2.0",
29
29
  "@veramo/did-resolver": "4.2.0",
@@ -63,5 +63,5 @@
63
63
  "OpenID Connect",
64
64
  "Authenticator"
65
65
  ],
66
- "gitHead": "1bd41ad0458bafc1a6e23ca9f550bd2ebd214c3e"
66
+ "gitHead": "afad00bef1e0ce6ac1637169b2e8a3b46f287255"
67
67
  }
package/src/functions.ts CHANGED
@@ -1,21 +1,26 @@
1
- import { dereferenceDidKeysWithJwkSupport, getAgentResolver, getIdentifier, getKey, IIdentifierOpts } from '@sphereon/ssi-sdk-ext.did-utils'
2
1
  import { IPEXOptions, IPEXPresentationSignCallback, IRequiredContext } from './types/IPresentationExchange'
3
2
  import { IPresentationDefinition } from '@sphereon/pex'
4
- import { PresentationPayload, ProofFormat } from '@veramo/core'
5
- import { CredentialMapper, Optional, OriginalVerifiablePresentation, W3CVerifiablePresentation } from '@sphereon/ssi-types'
3
+ import { PresentationPayload } from '@veramo/core'
4
+ import { CredentialMapper, W3CVerifiablePresentation } from '@sphereon/ssi-types'
6
5
  import { Format } from '@sphereon/pex-models'
7
6
 
8
7
  export async function getPresentationDefinition(pexOptions?: IPEXOptions): Promise<IPresentationDefinition | undefined> {
9
8
  return pexOptions?.definition
10
9
  /*const store = await getPresentationDefinitionStore(pexOptions)
11
- return store && pexOptions?.definitionId ? store.get(pexOptions?.definitionId) : undefined*/
10
+ return store && pexOptions?.definitionId ? store.get(pexOptions?.definitionId) : undefined*/
12
11
  }
13
12
 
14
13
  export async function createPEXPresentationSignCallback(
15
- args: {
16
- idOpts: IIdentifierOpts
14
+ {
15
+ kid,
16
+ fetchRemoteContexts,
17
+ format,
18
+ domain,
19
+ challenge,
20
+ }: {
21
+ kid: string
17
22
  fetchRemoteContexts?: boolean
18
- format?: Format | ProofFormat
23
+ format?: Format
19
24
  domain?: string
20
25
  challenge?: string
21
26
  },
@@ -28,59 +33,24 @@ export async function createPEXPresentationSignCallback(
28
33
  format,
29
34
  challenge,
30
35
  }: {
31
- presentation: Optional<PresentationPayload, 'holder'>
36
+ presentation: PresentationPayload
32
37
  presentationDefinition: IPresentationDefinition
33
- format?: Format | ProofFormat
38
+ format?: Format
34
39
  domain?: string
35
40
  challenge?: string
36
41
  }): Promise<W3CVerifiablePresentation> => {
37
- const idOpts = args.idOpts
38
- const id = await getIdentifier(idOpts, context)
39
- if (typeof idOpts.identifier === 'string') {
40
- idOpts.identifier = id
41
- }
42
- const key = await getKey(id, 'authentication', context, idOpts.kid)
43
- const didResolution = await getAgentResolver(context).resolve(idOpts.identifier.did)
44
- const vms = await dereferenceDidKeysWithJwkSupport(didResolution.didDocument!, idOpts.verificationMethodSection ?? 'authentication', context)
45
- const vm = vms.find((vm) => vm.publicKeyHex === key.publicKeyHex)
46
- if (!vm) {
47
- throw Error(`Could not resolve DID document or match signing key to did ${idOpts.identifier.did}`)
48
- }
49
-
50
- let proofFormat: ProofFormat = 'jwt'
51
- const formatOptions = format ?? args.format ?? presentationDefinition.format
52
- if (formatOptions) {
53
- if (typeof formatOptions === 'object') {
54
- const formats = Object.keys(formatOptions).map((form) => (form.includes('ldp') ? 'lds' : 'jwt'))
55
- if (!formats.includes('jwt')) {
56
- proofFormat = 'lds'
57
- }
58
- } else {
59
- proofFormat = formatOptions
60
- }
61
- }
62
- let header: undefined | object
63
- if (format === 'jwt') {
64
- header = {
65
- kid: vm.id,
66
- }
67
- }
68
-
69
- // we ignore the alg / proof_format for now, as we already have the kid anyway at this point
70
-
71
- // todo: look for jwt_vc_json and remove types and @context
42
+ const formatOptions = format ?? presentationDefinition.format
43
+ const proofFormat = formatOptions && (!!formatOptions.ldp || !!formatOptions.ldp_vp) ? 'lds' : 'jwt'
72
44
 
73
45
  const vp = await context.agent.createVerifiablePresentation({
74
- presentation: presentation as PresentationPayload,
75
- removeOriginalFields: true,
76
- keyRef: key.kid,
77
- domain: domain ?? args.domain,
78
- challenge: challenge ?? args.challenge,
79
- fetchRemoteContexts: args.fetchRemoteContexts !== false,
46
+ presentation,
47
+ keyRef: kid,
48
+ domain,
49
+ challenge,
50
+ fetchRemoteContexts: fetchRemoteContexts !== undefined ? fetchRemoteContexts : true,
80
51
  proofFormat,
81
- header,
82
52
  })
83
53
  // makes sure we extract an actual JWT from the internal representation in case it is a JWT
84
- return CredentialMapper.storedPresentationToOriginalFormat(vp as OriginalVerifiablePresentation)
54
+ return CredentialMapper.storedPresentationToOriginalFormat(vp as W3CVerifiablePresentation)
85
55
  }
86
56
  }
@@ -1,15 +1,14 @@
1
1
  import {
2
+ DIDDocumentSection,
2
3
  FindCredentialsArgs,
3
4
  IAgentContext,
4
- ICredentialPlugin,
5
5
  IDataStoreORM,
6
6
  IDIDManager,
7
7
  IIdentifier,
8
8
  IPluginMethodMap,
9
- IResolver,
10
9
  PresentationPayload,
11
10
  } from '@veramo/core'
12
- import { IPresentation, Optional, W3CVerifiableCredential, W3CVerifiablePresentation } from '@sphereon/ssi-types'
11
+ import { W3CVerifiableCredential, W3CVerifiablePresentation } from '@sphereon/ssi-types'
13
12
  import { IKeyValueStore, IValueData } from '@sphereon/ssi-sdk.kv-store-temp'
14
13
  import { IPresentationDefinition, PEVersion, SelectResults } from '@sphereon/pex'
15
14
  import { Format, InputDescriptorV1, InputDescriptorV2 } from '@sphereon/pex-models'
@@ -94,13 +93,11 @@ export interface IPEXFilterResult {
94
93
  filteredCredentials: W3CVerifiableCredential[]
95
94
  }
96
95
 
97
- /*
98
96
  export interface IIdentifierOpts {
99
97
  identifier: IIdentifier | string
100
98
  verificationMethodSection?: DIDDocumentSection
101
99
  kid?: string
102
100
  }
103
- */
104
101
 
105
102
  export interface VersionDiscoveryResult {
106
103
  version?: PEVersion
@@ -110,8 +107,8 @@ export interface VersionDiscoveryResult {
110
107
  export type IPEXPresentationSignCallback = (args: IPEXPresentationSignCallBackParams) => Promise<W3CVerifiablePresentation>
111
108
 
112
109
  export interface IPEXPresentationSignCallBackParams {
113
- presentation: IPresentation | Optional<PresentationPayload, 'holder'>
110
+ presentation: PresentationPayload
114
111
  presentationDefinition: IPresentationDefinition
115
112
  }
116
113
 
117
- export type IRequiredContext = IAgentContext<IDataStoreORM & IResolver & IDIDManager & ICredentialPlugin>
114
+ export type IRequiredContext = IAgentContext<IDataStoreORM & IDIDManager>