@sphereon/ssi-sdk.data-store 0.29.1-unstable.93 → 0.29.1-unstable.94

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,6 +1,5 @@
1
- import { AddCredentialArgs } from '../../types';
2
1
  import { DigitalCredentialEntity } from '../../entities/digitalCredential/DigitalCredentialEntity';
3
- import { DigitalCredential, NonPersistedDigitalCredential } from '../../types';
2
+ import { AddCredentialArgs, DigitalCredential, NonPersistedDigitalCredential } from '../../types';
4
3
  export declare const nonPersistedDigitalCredentialEntityFromAddArgs: (addCredentialArgs: AddCredentialArgs) => NonPersistedDigitalCredential;
5
4
  export declare const digitalCredentialFrom: (credentialEntity: DigitalCredentialEntity) => DigitalCredential;
6
5
  export declare const digitalCredentialsFrom: (credentialEntities: Array<DigitalCredentialEntity>) => DigitalCredential[];
@@ -1 +1 @@
1
- {"version":3,"file":"MappingUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/digitalCredential/MappingUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,0DAA0D,CAAA;AAWlG,OAAO,EAA0C,iBAAiB,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAqEtH,eAAO,MAAM,8CAA8C,sBAAuB,iBAAiB,KAAG,6BA0BrG,CAAA;AAED,eAAO,MAAM,qBAAqB,qBAAsB,uBAAuB,KAAG,iBAIjF,CAAA;AAED,eAAO,MAAM,sBAAsB,uBAAwB,MAAM,uBAAuB,CAAC,KAAG,iBAAiB,EAE5G,CAAA"}
1
+ {"version":3,"file":"MappingUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/digitalCredential/MappingUtils.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,uBAAuB,EAAE,MAAM,0DAA0D,CAAA;AAClG,OAAO,EACL,iBAAiB,EAEjB,iBAAiB,EAEjB,6BAA6B,EAC9B,MAAM,aAAa,CAAA;AAoEpB,eAAO,MAAM,8CAA8C,sBAAuB,iBAAiB,KAAG,6BAwBrG,CAAA;AAED,eAAO,MAAM,qBAAqB,qBAAsB,uBAAuB,KAAG,iBAIjF,CAAA;AAED,eAAO,MAAM,sBAAsB,uBAAwB,MAAM,uBAAuB,CAAC,KAAG,iBAAiB,EAE5G,CAAA"}
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.digitalCredentialsFrom = exports.digitalCredentialFrom = exports.nonPersistedDigitalCredentialEntityFromAddArgs = void 0;
4
4
  const ssi_types_1 = require("@sphereon/ssi-types");
5
- const types_1 = require("../../types");
6
5
  const utils_1 = require("@veramo/utils");
6
+ const types_1 = require("../../types");
7
7
  function determineDocumentType(raw) {
8
8
  const rawDocument = parseRawDocument(raw);
9
9
  if (!rawDocument) {
@@ -71,20 +71,18 @@ function getValidFrom(uniformDocument) {
71
71
  return undefined;
72
72
  }
73
73
  const nonPersistedDigitalCredentialEntityFromAddArgs = (addCredentialArgs) => {
74
- var _a;
74
+ var _a, _b, _c;
75
75
  const documentType = determineDocumentType(addCredentialArgs.rawDocument);
76
76
  const documentFormat = ssi_types_1.CredentialMapper.detectDocumentType(addCredentialArgs.rawDocument);
77
77
  if (documentFormat === 2 /* DocumentFormat.SD_JWT_VC */ && !((_a = addCredentialArgs.opts) === null || _a === void 0 ? void 0 : _a.hasher)) {
78
78
  throw new Error('No hasher function is provided for SD_JWT credential.');
79
79
  }
80
- const uniformDocument = documentFormat === 2 /* DocumentFormat.SD_JWT_VC */
81
- ? (0, ssi_types_1.decodeSdJwtVc)(addCredentialArgs.rawDocument, addCredentialArgs.opts.hasher).decodedPayload
82
- : documentType === types_1.DocumentType.VC || documentType === types_1.DocumentType.C
83
- ? ssi_types_1.CredentialMapper.toUniformCredential(addCredentialArgs.rawDocument)
84
- : ssi_types_1.CredentialMapper.toUniformPresentation(addCredentialArgs.rawDocument);
80
+ const hasher = (_b = addCredentialArgs.opts) === null || _b === void 0 ? void 0 : _b.hasher;
81
+ const uniformDocument = (documentType === types_1.DocumentType.VC || documentType === types_1.DocumentType.C) ? ssi_types_1.CredentialMapper.toUniformCredential(addCredentialArgs.rawDocument, { hasher }) : ssi_types_1.CredentialMapper.toUniformPresentation(addCredentialArgs.rawDocument);
85
82
  const validFrom = getValidFrom(uniformDocument);
86
83
  const validUntil = getValidUntil(uniformDocument);
87
- return Object.assign(Object.assign({}, addCredentialArgs), { documentType, documentFormat: determineCredentialDocumentFormat(documentFormat), createdAt: new Date(), credentialId: uniformDocument.id, hash: (0, utils_1.computeEntryHash)(addCredentialArgs.rawDocument), uniformDocument: JSON.stringify(uniformDocument), validFrom,
84
+ const hash = (0, utils_1.computeEntryHash)(addCredentialArgs.rawDocument);
85
+ return Object.assign(Object.assign({}, addCredentialArgs), { documentType, documentFormat: determineCredentialDocumentFormat(documentFormat), createdAt: new Date(), credentialId: (_c = uniformDocument.id) !== null && _c !== void 0 ? _c : hash, hash, uniformDocument: JSON.stringify(uniformDocument), validFrom,
88
86
  validUntil, lastUpdatedAt: new Date() });
89
87
  };
90
88
  exports.nonPersistedDigitalCredentialEntityFromAddArgs = nonPersistedDigitalCredentialEntityFromAddArgs;
@@ -1 +1 @@
1
- {"version":3,"file":"MappingUtils.js","sourceRoot":"","sources":["../../../src/utils/digitalCredential/MappingUtils.ts"],"names":[],"mappings":";;;AAEA,mDAS4B;AAC5B,uCAAsH;AACtH,yCAAgD;AAEhD,SAAS,qBAAqB,CAAC,GAAW;IACxC,MAAM,WAAW,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAA;IACzC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,kCAAkC,GAAG,EAAE,CAAC,CAAA;IAC1D,CAAC;IAED,MAAM,QAAQ,GAAG,4BAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;IACvD,MAAM,YAAY,GAAG,4BAAgB,CA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I,EACJ,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,EAChD,SAAS;QACT,UAAU,EACV,aAAa,EAAE,IAAI,IAAI,EAAE,IAC1B;AACH,CAAC,CAAA;AAxBY,QAAA,8CAA8C,kDAwB1D;AAEM,MAAM,qBAAqB,GAAG,CAAC,gBAAyC,EAAqB,EAAE;IACpG,yBACK,gBAAgB,EACpB;AACH,CAAC,CAAA;AAJY,QAAA,qBAAqB,yBAIjC;AAEM,MAAM,sBAAsB,GAAG,CAAC,kBAAkD,EAAuB,EAAE;IAChH,OAAO,kBAAkB,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAE,EAAE,CAAC,IAAA,6BAAqB,EAAC,gBAAgB,CAAC,CAAC,CAAA;AAC9F,CAAC,CAAA;AAFY,QAAA,sBAAsB,0BAElC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sphereon/ssi-sdk.data-store",
3
- "version": "0.29.1-unstable.93+1703d1a0",
3
+ "version": "0.29.1-unstable.94+4a4414be",
4
4
  "source": "src/index.ts",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -17,9 +17,9 @@
17
17
  "@sphereon/pex": "^4.0.1",
18
18
  "@sphereon/ssi-sdk-ext.did-utils": "0.24.1-next.96",
19
19
  "@sphereon/ssi-sdk-ext.identifier-resolution": "0.24.1-next.96",
20
- "@sphereon/ssi-sdk.agent-config": "0.29.1-unstable.93+1703d1a0",
21
- "@sphereon/ssi-sdk.core": "0.29.1-unstable.93+1703d1a0",
22
- "@sphereon/ssi-types": "0.29.1-unstable.93+1703d1a0",
20
+ "@sphereon/ssi-sdk.agent-config": "0.29.1-unstable.94+4a4414be",
21
+ "@sphereon/ssi-sdk.core": "0.29.1-unstable.94+4a4414be",
22
+ "@sphereon/ssi-types": "0.29.1-unstable.94+4a4414be",
23
23
  "@veramo/core": "4.2.0",
24
24
  "@veramo/utils": "4.2.0",
25
25
  "blakejs": "^1.2.1",
@@ -50,5 +50,5 @@
50
50
  "PostgreSQL",
51
51
  "Contact Store"
52
52
  ],
53
- "gitHead": "1703d1a01e2e697d9e4bcdd8e1b570372425b27a"
53
+ "gitHead": "4a4414be606cdfe4634fb76ebbd136c34ee40ac3"
54
54
  }
@@ -1,17 +1,21 @@
1
- import { AddCredentialArgs } from '../../types'
2
- import { DigitalCredentialEntity } from '../../entities/digitalCredential/DigitalCredentialEntity'
3
1
  import {
4
2
  CredentialMapper,
5
- decodeSdJwtVc,
6
3
  DocumentFormat,
7
4
  IVerifiableCredential,
8
5
  IVerifiablePresentation,
9
6
  OriginalVerifiableCredential,
10
7
  OriginalVerifiablePresentation,
11
- SdJwtDecodedVerifiableCredentialPayload,
8
+ SdJwtDecodedVerifiableCredentialPayload
12
9
  } from '@sphereon/ssi-types'
13
- import { CredentialDocumentFormat, DocumentType, DigitalCredential, NonPersistedDigitalCredential } from '../../types'
14
10
  import { computeEntryHash } from '@veramo/utils'
11
+ import { DigitalCredentialEntity } from '../../entities/digitalCredential/DigitalCredentialEntity'
12
+ import {
13
+ AddCredentialArgs,
14
+ CredentialDocumentFormat,
15
+ DigitalCredential,
16
+ DocumentType,
17
+ NonPersistedDigitalCredential
18
+ } from '../../types'
15
19
 
16
20
  function determineDocumentType(raw: string): DocumentType {
17
21
  const rawDocument = parseRawDocument(raw)
@@ -85,31 +89,29 @@ export const nonPersistedDigitalCredentialEntityFromAddArgs = (addCredentialArgs
85
89
  if (documentFormat === DocumentFormat.SD_JWT_VC && !addCredentialArgs.opts?.hasher) {
86
90
  throw new Error('No hasher function is provided for SD_JWT credential.')
87
91
  }
92
+ const hasher = addCredentialArgs.opts?.hasher
88
93
  const uniformDocument =
89
- documentFormat === DocumentFormat.SD_JWT_VC
90
- ? decodeSdJwtVc(addCredentialArgs.rawDocument, addCredentialArgs.opts!.hasher!).decodedPayload
91
- : documentType === DocumentType.VC || documentType === DocumentType.C
92
- ? CredentialMapper.toUniformCredential(addCredentialArgs.rawDocument)
93
- : CredentialMapper.toUniformPresentation(addCredentialArgs.rawDocument)
94
+ (documentType === DocumentType.VC || documentType === DocumentType.C) ? CredentialMapper.toUniformCredential(addCredentialArgs.rawDocument, {hasher }) : CredentialMapper.toUniformPresentation(addCredentialArgs.rawDocument)
94
95
  const validFrom: Date | undefined = getValidFrom(uniformDocument)
95
96
  const validUntil: Date | undefined = getValidUntil(uniformDocument)
97
+ const hash = computeEntryHash(addCredentialArgs.rawDocument)
96
98
  return {
97
99
  ...addCredentialArgs,
98
100
  documentType,
99
101
  documentFormat: determineCredentialDocumentFormat(documentFormat),
100
102
  createdAt: new Date(),
101
- credentialId: uniformDocument.id as string | undefined, // uniformDocument.id is being inferred as JsonValue somehow
102
- hash: computeEntryHash(addCredentialArgs.rawDocument),
103
+ credentialId: uniformDocument.id ?? hash,
104
+ hash,
103
105
  uniformDocument: JSON.stringify(uniformDocument),
104
106
  validFrom,
105
107
  validUntil,
106
- lastUpdatedAt: new Date(),
108
+ lastUpdatedAt: new Date()
107
109
  }
108
110
  }
109
111
 
110
112
  export const digitalCredentialFrom = (credentialEntity: DigitalCredentialEntity): DigitalCredential => {
111
113
  return {
112
- ...credentialEntity,
114
+ ...credentialEntity
113
115
  }
114
116
  }
115
117