@twin.org/identity-connector-entity-storage 0.0.1-next.3 → 0.0.1-next.5

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.
@@ -3,6 +3,7 @@
3
3
  var entity = require('@twin.org/entity');
4
4
  var core = require('@twin.org/core');
5
5
  var crypto = require('@twin.org/crypto');
6
+ var dataJsonLd = require('@twin.org/data-json-ld');
6
7
  var entityStorageModels = require('@twin.org/entity-storage-models');
7
8
  var identityModels = require('@twin.org/identity-models');
8
9
  var standardsW3cDid = require('@twin.org/standards-w3c-did');
@@ -440,15 +441,9 @@ class EntityStorageIdentityConnector {
440
441
  else if (core.Is.stringValue(types)) {
441
442
  finalTypes.push(types);
442
443
  }
443
- const finalContexts = ["https://www.w3.org/2018/credentials/v1"];
444
- if (core.Is.array(contexts)) {
445
- finalContexts.push(...contexts);
446
- }
447
- else if (core.Is.stringValue(contexts)) {
448
- finalContexts.push(contexts);
449
- }
450
444
  const verifiableCredential = {
451
- "@context": finalContexts,
445
+ "@context": dataJsonLd.JsonLdProcessor.combineContexts("https://www.w3.org/2018/credentials/v1", contexts) ??
446
+ null,
452
447
  id: credentialId,
453
448
  type: finalTypes,
454
449
  credentialSubject: subject,
@@ -720,15 +715,9 @@ class EntityStorageIdentityConnector {
720
715
  else if (core.Is.stringValue(types)) {
721
716
  finalTypes.push(types);
722
717
  }
723
- const finalContexts = ["https://www.w3.org/2018/credentials/v1"];
724
- if (core.Is.array(contexts)) {
725
- finalContexts.push(...contexts);
726
- }
727
- else if (core.Is.stringValue(contexts)) {
728
- finalContexts.push(contexts);
729
- }
730
718
  const verifiablePresentation = {
731
- "@context": finalContexts,
719
+ "@context": dataJsonLd.JsonLdProcessor.combineContexts("https://www.w3.org/2018/credentials/v1", contexts) ??
720
+ null,
732
721
  type: finalTypes,
733
722
  verifiableCredential: verifiableCredentials,
734
723
  holder: idParts.id
@@ -1,6 +1,7 @@
1
1
  import { property, entity, ComparisonOperator, EntitySchemaFactory, EntitySchemaHelper } from '@twin.org/entity';
2
2
  import { Guards, Converter, RandomHelper, BitString, Compression, CompressionType, GeneralError, Is, NotFoundError, ObjectHelper, Coerce, JsonHelper, AlreadyExistsError, BaseError } from '@twin.org/core';
3
3
  import { Sha256 } from '@twin.org/crypto';
4
+ import { JsonLdProcessor } from '@twin.org/data-json-ld';
4
5
  import { EntityStorageConnectorFactory } from '@twin.org/entity-storage-models';
5
6
  import { DocumentHelper } from '@twin.org/identity-models';
6
7
  import { DidVerificationMethodType } from '@twin.org/standards-w3c-did';
@@ -438,15 +439,9 @@ class EntityStorageIdentityConnector {
438
439
  else if (Is.stringValue(types)) {
439
440
  finalTypes.push(types);
440
441
  }
441
- const finalContexts = ["https://www.w3.org/2018/credentials/v1"];
442
- if (Is.array(contexts)) {
443
- finalContexts.push(...contexts);
444
- }
445
- else if (Is.stringValue(contexts)) {
446
- finalContexts.push(contexts);
447
- }
448
442
  const verifiableCredential = {
449
- "@context": finalContexts,
443
+ "@context": JsonLdProcessor.combineContexts("https://www.w3.org/2018/credentials/v1", contexts) ??
444
+ null,
450
445
  id: credentialId,
451
446
  type: finalTypes,
452
447
  credentialSubject: subject,
@@ -718,15 +713,9 @@ class EntityStorageIdentityConnector {
718
713
  else if (Is.stringValue(types)) {
719
714
  finalTypes.push(types);
720
715
  }
721
- const finalContexts = ["https://www.w3.org/2018/credentials/v1"];
722
- if (Is.array(contexts)) {
723
- finalContexts.push(...contexts);
724
- }
725
- else if (Is.stringValue(contexts)) {
726
- finalContexts.push(contexts);
727
- }
728
716
  const verifiablePresentation = {
729
- "@context": finalContexts,
717
+ "@context": JsonLdProcessor.combineContexts("https://www.w3.org/2018/credentials/v1", contexts) ??
718
+ null,
730
719
  type: finalTypes,
731
720
  verifiableCredential: verifiableCredentials,
732
721
  holder: idParts.id
@@ -1,3 +1,4 @@
1
+ import { type IJsonLdContextDefinitionRoot } from "@twin.org/data-json-ld";
1
2
  import { type IIdentityConnector } from "@twin.org/identity-models";
2
3
  import { DidVerificationMethodType, type IDidDocument, type IDidDocumentVerificationMethod, type IDidService, type IDidVerifiableCredential, type IDidVerifiablePresentation } from "@twin.org/standards-w3c-did";
3
4
  /**
@@ -86,7 +87,7 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
86
87
  * @returns The created verifiable credential and its token.
87
88
  * @throws NotFoundError if the id can not be resolved.
88
89
  */
89
- createVerifiableCredential<T>(controller: string, verificationMethodId: string, credentialId: string | undefined, types: string | string[] | undefined, subject: T | T[], contexts?: string | string[], revocationIndex?: number): Promise<{
90
+ createVerifiableCredential<T>(controller: string, verificationMethodId: string, credentialId: string | undefined, types: string | string[] | undefined, subject: T | T[], contexts?: IJsonLdContextDefinitionRoot, revocationIndex?: number): Promise<{
90
91
  verifiableCredential: IDidVerifiableCredential<T>;
91
92
  jwt: string;
92
93
  }>;
@@ -126,7 +127,7 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
126
127
  * @returns The created verifiable presentation and its token.
127
128
  * @throws NotFoundError if the id can not be resolved.
128
129
  */
129
- createVerifiablePresentation(controller: string, presentationMethodId: string, types: string | string[] | undefined, verifiableCredentials: string[], contexts?: string | string[], expiresInMinutes?: number): Promise<{
130
+ createVerifiablePresentation(controller: string, presentationMethodId: string, types: string | string[] | undefined, verifiableCredentials: string[], contexts?: IJsonLdContextDefinitionRoot, expiresInMinutes?: number): Promise<{
130
131
  verifiablePresentation: IDidVerifiablePresentation;
131
132
  jwt: string;
132
133
  }>;
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/identity-connector-entity-storage- Changelog
2
2
 
3
- ## v0.0.1-next.3
3
+ ## v0.0.1-next.5
4
4
 
5
5
  - Initial Release
@@ -294,7 +294,7 @@ The type for the data stored in the verifiable credential.
294
294
 
295
295
  The subject data to store for the credential.
296
296
 
297
- • **contexts?**: `string` \| `string`[]
297
+ • **contexts?**: `IJsonLdContextDefinitionRoot`
298
298
 
299
299
  Additional contexts to include in the credential.
300
300
 
@@ -450,7 +450,7 @@ The types for the data stored in the verifiable credential.
450
450
 
451
451
  The credentials to use for creating the presentation in jwt format.
452
452
 
453
- • **contexts?**: `string` \| `string`[]
453
+ • **contexts?**: `IJsonLdContextDefinitionRoot`
454
454
 
455
455
  Additional contexts to include in the presentation.
456
456
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/identity-connector-entity-storage",
3
- "version": "0.0.1-next.3",
3
+ "version": "0.0.1-next.5",
4
4
  "description": "Identity connector implementation using entity storage",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,48 +13,18 @@
13
13
  "engines": {
14
14
  "node": ">=20.0.0"
15
15
  },
16
- "scripts": {
17
- "clean": "rimraf dist coverage docs/reference",
18
- "build": "tspc",
19
- "test": "vitest --run --config ./vitest.config.ts --no-cache",
20
- "coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
21
- "bundle:esm": "rollup --config rollup.config.mjs --environment MODULE:esm",
22
- "bundle:cjs": "rollup --config rollup.config.mjs --environment MODULE:cjs",
23
- "bundle": "npm run bundle:esm && npm run bundle:cjs",
24
- "docs:clean": "rimraf docs/reference",
25
- "docs:generate": "typedoc",
26
- "docs": "npm run docs:clean && npm run docs:generate",
27
- "dist": "npm run clean && npm run build && npm run test && npm run bundle && npm run docs"
28
- },
29
16
  "dependencies": {
30
17
  "@twin.org/core": "next",
31
18
  "@twin.org/crypto": "next",
32
19
  "@twin.org/data-core": "next",
33
20
  "@twin.org/data-json-ld": "next",
34
21
  "@twin.org/entity": "next",
35
- "@twin.org/identity-models": "0.0.1-next.3",
22
+ "@twin.org/identity-models": "0.0.1-next.5",
36
23
  "@twin.org/nameof": "next",
37
24
  "@twin.org/standards-w3c-did": "next",
38
25
  "@twin.org/vault-models": "next",
39
26
  "@twin.org/web": "next"
40
27
  },
41
- "devDependencies": {
42
- "@twin.org/entity-storage-connector-memory": "next",
43
- "@twin.org/nameof-transformer": "next",
44
- "@twin.org/vault-connector-entity-storage": "next",
45
- "@vitest/coverage-v8": "2.1.1",
46
- "copyfiles": "2.4.1",
47
- "dotenv": "16.4.5",
48
- "rimraf": "6.0.1",
49
- "rollup": "4.22.0",
50
- "rollup-plugin-copy": "3.5.0",
51
- "rollup-plugin-typescript2": "0.36.0",
52
- "ts-patch": "3.2.1",
53
- "typedoc": "0.26.7",
54
- "typedoc-plugin-markdown": "4.2.7",
55
- "typescript": "5.6.2",
56
- "vitest": "2.1.1"
57
- },
58
28
  "main": "./dist/cjs/index.cjs",
59
29
  "module": "./dist/esm/index.mjs",
60
30
  "types": "./dist/types/index.d.ts",