@twin.org/identity-connector-entity-storage 0.0.3-next.2 → 0.0.3-next.21

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,6 @@
1
1
  import { type IJsonLdContextDefinitionRoot, type IJsonLdNodeObject } from "@twin.org/data-json-ld";
2
2
  import { type IIdentityConnector } from "@twin.org/identity-models";
3
- import { DidVerificationMethodType, ProofTypes, type IDidDocument, type IDidDocumentVerificationMethod, type IDidService, type IDidVerifiableCredentialV1, type IDidVerifiablePresentationV1, type IProof } from "@twin.org/standards-w3c-did";
3
+ import { DidVerificationMethodType, type IDidVerifiableCredential, ProofTypes, type IDidDocument, type IDidDocumentVerificationMethod, type IDidService, type IDidVerifiableCredentialV1, type IDidVerifiablePresentationV1, type IProof, type IDidVerifiablePresentation } from "@twin.org/standards-w3c-did";
4
4
  import type { IEntityStorageIdentityConnectorConstructorOptions } from "./models/IEntityStorageIdentityConnectorConstructorOptions.js";
5
5
  /**
6
6
  * Class for performing identity operations using entity storage.
@@ -76,6 +76,28 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
76
76
  * @throws NotFoundError if the id can not be resolved.
77
77
  */
78
78
  removeService(controller: string, serviceId: string): Promise<void>;
79
+ /**
80
+ * Add an alias to the alsoKnownAs property on the document.
81
+ * If the alias is already present the operation is a no-op.
82
+ * @param controller The controller of the identity who can make changes.
83
+ * @param documentId The id of the document to update.
84
+ * @param alias The alias to add. Must be a Url or Urn (typically another DID).
85
+ * @returns Nothing.
86
+ * @throws GeneralError if the alias is not a Url or Urn.
87
+ * @throws NotFoundError if the id can not be resolved.
88
+ */
89
+ addAlsoKnownAs(controller: string, documentId: string, alias: string): Promise<void>;
90
+ /**
91
+ * Remove an alias from the alsoKnownAs property on the document.
92
+ * If the alias is not present the operation is a no-op.
93
+ * @param controller The controller of the identity who can make changes.
94
+ * @param documentId The id of the document to update.
95
+ * @param alias The alias to remove. Must be a Url or Urn.
96
+ * @returns Nothing.
97
+ * @throws GeneralError if the alias is not a Url or Urn.
98
+ * @throws NotFoundError if the id can not be resolved.
99
+ */
100
+ removeAlsoKnownAs(controller: string, documentId: string, alias: string): Promise<void>;
79
101
  /**
80
102
  * Create a verifiable credential for a verification method.
81
103
  * @param controller The controller of the identity who can make changes.
@@ -97,12 +119,12 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
97
119
  }>;
98
120
  /**
99
121
  * Check a verifiable credential is valid.
100
- * @param credentialJwt The credential to verify.
122
+ * @param credential The credential to verify.
101
123
  * @returns The credential stored in the jwt and the revocation status.
102
124
  */
103
- checkVerifiableCredential(credentialJwt: string): Promise<{
125
+ checkVerifiableCredential(credential: string | IDidVerifiableCredential): Promise<{
104
126
  revoked: boolean;
105
- verifiableCredential?: IDidVerifiableCredentialV1;
127
+ verifiableCredential?: IDidVerifiableCredential;
106
128
  }>;
107
129
  /**
108
130
  * Revoke verifiable credential(s).
@@ -128,31 +150,38 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
128
150
  * @param contexts The contexts for the data stored in the verifiable credential.
129
151
  * @param types The types for the data stored in the verifiable credential.
130
152
  * @param verifiableCredentials The credentials to use for creating the presentation in jwt format.
131
- * @param expiresInMinutes The time in minutes for the presentation to expire.
153
+ * @param options Additional options for creating the verifiable presentation.
154
+ * @param options.expirationDate The date the verifiable presentation is valid until.
132
155
  * @returns The created verifiable presentation and its token.
133
156
  * @throws NotFoundError if the id can not be resolved.
134
157
  */
135
- createVerifiablePresentation(controller: string, verificationMethodId: string, presentationId: string | undefined, contexts: IJsonLdContextDefinitionRoot | undefined, types: string | string[] | undefined, verifiableCredentials: (string | IDidVerifiableCredentialV1)[], expiresInMinutes?: number): Promise<{
158
+ createVerifiablePresentation(controller: string, verificationMethodId: string, presentationId: string | undefined, contexts: IJsonLdContextDefinitionRoot | undefined, types: string | string[] | undefined, verifiableCredentials: (string | IDidVerifiableCredentialV1)[], options?: {
159
+ expirationDate?: Date;
160
+ }): Promise<{
136
161
  verifiablePresentation: IDidVerifiablePresentationV1;
137
162
  jwt: string;
138
163
  }>;
139
164
  /**
140
165
  * Check a verifiable presentation is valid.
141
- * @param presentationJwt The presentation to verify.
166
+ * @param presentation The presentation to verify.
142
167
  * @returns The presentation stored in the jwt and the revocation status.
143
168
  */
144
- checkVerifiablePresentation(presentationJwt: string): Promise<{
169
+ checkVerifiablePresentation(presentation: string | IDidVerifiablePresentation): Promise<{
145
170
  revoked: boolean;
146
171
  verifiablePresentation?: IDidVerifiablePresentationV1;
147
172
  issuers?: IDidDocument[];
148
173
  }>;
149
174
  /**
150
175
  * Create a proof for arbitrary data with the specified verification method.
176
+ * This method uses async signing to ensure the private key never leaves the vault,
177
+ * with algorithm validation to ensure key type compatibility.
151
178
  * @param controller The controller of the identity who can make changes.
152
179
  * @param verificationMethodId The verification method id to use.
153
180
  * @param proofType The type of proof to create.
154
181
  * @param unsecureDocument The unsecure document to create the proof for.
155
182
  * @returns The proof.
183
+ * @throws NotFoundError if the identity or method is not found.
184
+ * @throws GeneralError if algorithm doesn't match key type or proof creation fails.
156
185
  */
157
186
  createProof(controller: string, verificationMethodId: string, proofType: ProofTypes, unsecureDocument: IJsonLdNodeObject): Promise<IProof>;
158
187
  /**