@sphereon/ssi-sdk.credential-store 0.33.1-next.3 → 0.33.1-next.68

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.d.ts CHANGED
@@ -1,12 +1,235 @@
1
+ import * as _sphereon_ssi_types from '@sphereon/ssi-types';
2
+ import { HasherSync, OriginalVerifiableCredential, OriginalVerifiablePresentation, ICredential, IPresentation, IVerifiableCredential, IVerifiablePresentation } from '@sphereon/ssi-types';
3
+ import { NonPersistedDigitalCredential, DigitalCredential, UpdateCredentialStateArgs, FindDigitalCredentialArgs, CredentialRole, AbstractDigitalCredentialStore } from '@sphereon/ssi-sdk.data-store';
4
+ export { CredentialCorrelationType, CredentialDocumentFormat, CredentialRole, CredentialStateType, DigitalCredential, DocumentType, FindDigitalCredentialArgs, UpdateCredentialStateArgs } from '@sphereon/ssi-sdk.data-store';
5
+ import { IPluginMethodMap, IAgentContext, IAgentPlugin } from '@veramo/core';
6
+
7
+ type TClaimsColumns = 'context' | 'credentialType' | 'type' | 'value' | 'isObj' | 'id' | 'issuer' | 'subject' | 'expirationDate' | 'issuanceDate';
8
+ /**
9
+ * Represents the sort order of results from a {@link FindArgs} query.
10
+ *
11
+ * @beta This API may change without a BREAKING CHANGE notice.
12
+ */
13
+ interface Order<TColumns> {
14
+ column: TColumns;
15
+ direction: 'ASC' | 'DESC';
16
+ }
17
+ /**
18
+ * Represents a WHERE predicate for a {@link FindArgs} query.
19
+ * In situations where multiple WHERE predicates are present, they are combined with AND.
20
+ *
21
+ * @beta This API may change without a BREAKING CHANGE notice.
22
+ */
23
+ interface Where<TColumns> {
24
+ column: TColumns;
25
+ value?: string[];
26
+ not?: boolean;
27
+ op?: 'LessThan' | 'LessThanOrEqual' | 'MoreThan' | 'MoreThanOrEqual' | 'Equal' | 'Like' | 'Between' | 'In' | 'Any' | 'IsNull';
28
+ }
29
+ interface FindArgs<TColumns> {
30
+ /**
31
+ * Imposes constraints on the values of the given columns.
32
+ * WHERE clauses are combined using AND.
33
+ */
34
+ where?: Where<TColumns>[];
35
+ /**
36
+ * Sorts the results according to the given array of column priorities.
37
+ */
38
+ order?: Order<TColumns>[];
39
+ /**
40
+ * Ignores the first number of entries in a {@link IDataStoreORM} query result.
41
+ */
42
+ skip?: number;
43
+ /**
44
+ * Returns at most this number of results from a {@link IDataStoreORM} query.
45
+ */
46
+ take?: number;
47
+ }
48
+ type FindClaimsArgs = FindArgs<TClaimsColumns>;
49
+
50
+ interface ICredentialStore extends IPluginMethodMap {
51
+ /**
52
+ * Add a new credential.
53
+ * @param args
54
+ */
55
+ crsAddCredential(args: AddCredentialArgs): Promise<DigitalCredential>;
56
+ /**
57
+ * Update credential the state of an existing credential.
58
+ * @param args
59
+ */
60
+ crsUpdateCredentialState(args: UpdateCredentialStateArgs): Promise<DigitalCredential>;
61
+ /**
62
+ * Get a single credentials by primary key
63
+ * @param args
64
+ */
65
+ crsGetCredential(args: GetCredentialArgs): Promise<DigitalCredential>;
66
+ /**
67
+ * Find one or more credentials using filters
68
+ * @param args
69
+ */
70
+ crsGetCredentials(args: GetCredentialsArgs): Promise<Array<DigitalCredential>>;
71
+ /**
72
+ * Find one or more credentials using filters
73
+ * @param args
74
+ */
75
+ crsGetUniqueCredentials(args: GetCredentialsArgs): Promise<Array<UniqueDigitalCredential>>;
76
+ /**
77
+ * Find one credential by id or hash
78
+ * @param args
79
+ */
80
+ crsGetUniqueCredentialByIdOrHash(args: GetCredentialsByIdOrHashArgs): Promise<OptionalUniqueDigitalCredential>;
81
+ /**
82
+ * Returns a list of UniqueDigitalCredentials that match the given filter based on the claims they contain.
83
+ * @param args
84
+ */
85
+ crsGetCredentialsByClaims(args: GetCredentialsByClaimsArgs): Promise<Array<UniqueDigitalCredential>>;
86
+ /**
87
+ * Returns a count of UniqueDigitalCredentials that match the given filter based on the claims they contain.
88
+ * @param args
89
+ */
90
+ crsGetCredentialsByClaimsCount(args: GetCredentialsByClaimsArgs): Promise<number>;
91
+ /**
92
+ * Delete a single credentials by primary key
93
+ * @param args
94
+ */
95
+ crsDeleteCredential(args: DeleteCredentialArgs): Promise<boolean>;
96
+ /**
97
+ * Delete multiple credentials records using filters
98
+ * @param args
99
+ */
100
+ crsDeleteCredentials(args: DeleteCredentialsArgs): Promise<number>;
101
+ }
102
+ /**
103
+ *
104
+ * @param context
105
+ * @internal
106
+ */
107
+ declare function contextHasCredentialStore(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<ICredentialStore>;
108
+ type GetCredentialArgs = {
109
+ id: string;
110
+ };
111
+ type GetCredentialsArgs = {
112
+ filter: FindDigitalCredentialArgs;
113
+ };
114
+ type GetCredentialsByClaimsArgs = {
115
+ filter: FindClaimsArgs;
116
+ credentialRole?: CredentialRole;
117
+ tenantId?: string;
118
+ };
119
+ type GetCredentialsByIdOrHashArgs = {
120
+ credentialRole: CredentialRole;
121
+ idOrHash: string;
122
+ };
123
+ type DeleteCredentialArgs = {
124
+ id: string;
125
+ } | {
126
+ hash: string;
127
+ };
128
+ type DeleteCredentialsArgs = GetCredentialsArgs;
129
+ type AddDigitalCredential = Omit<NonPersistedDigitalCredential, 'id' | 'documentType' | 'documentFormat' | 'uniformDocument' | 'hash' | 'createdAt' | 'lastUpdatedAt' | 'validFrom' | 'validUntil'>;
130
+ type AddCredentialArgs = {
131
+ credential: AddDigitalCredential;
132
+ opts?: {
133
+ maxTimeSkewInMS?: number;
134
+ hasher?: HasherSync;
135
+ };
136
+ };
137
+ interface UniqueDigitalCredential {
138
+ hash: string;
139
+ id?: string;
140
+ digitalCredential: DigitalCredential;
141
+ originalVerifiableCredential?: OriginalVerifiableCredential;
142
+ originalVerifiablePresentation?: OriginalVerifiablePresentation;
143
+ originalCredential?: ICredential;
144
+ originalPresentation?: IPresentation;
145
+ uniformVerifiableCredential?: IVerifiableCredential;
146
+ uniformVerifiablePresentation?: IVerifiablePresentation;
147
+ }
148
+ type OptionalUniqueDigitalCredential = UniqueDigitalCredential | undefined;
149
+ type RequiredContext = IAgentContext<never>;
150
+
151
+ declare const credentialStoreMethods: Array<string>;
152
+ /**
153
+ * {@inheritDoc ICRManager}
154
+ */
155
+ declare class CredentialStore implements IAgentPlugin {
156
+ readonly schema: any;
157
+ readonly methods: ICredentialStore;
158
+ private readonly store;
159
+ constructor(options: {
160
+ store: AbstractDigitalCredentialStore;
161
+ });
162
+ /** {@inheritDoc ICredentialStore.crsAddCredential} */
163
+ private crsAddCredential;
164
+ /** {@inheritDoc ICredentialStore.crsUpdateCredentialState} */
165
+ private crsUpdateCredentialState;
166
+ /** {@inheritDoc ICredentialStore.crsGetCredential} */
167
+ private crsGetCredential;
168
+ /** {@inheritDoc ICredentialStore.crsGetCredentials} */
169
+ private crsGetCredentials;
170
+ /** {@inheritDoc ICredentialStore.crsGetUniqueCredentialByIdOrHash} */
171
+ private crsGetUniqueCredentialByIdOrHash;
172
+ /** {@inheritDoc ICredentialStore.crsGetUniqueCredentials} */
173
+ private crsGetUniqueCredentials;
174
+ /** {@inheritDoc ICredentialStore.crsDeleteCredential} */
175
+ private crsDeleteCredential;
176
+ /** {@inheritDoc ICredentialStore.crsDeleteCredentials} */
177
+ private crsDeleteCredentials;
178
+ /**
179
+ * Returns a list of UniqueDigitalCredentials that match the given filter based on the claims they contain.
180
+ * @param args
181
+ */
182
+ private crsGetCredentialsByClaims;
183
+ private getValueFromCredential;
184
+ /**
185
+ * Returns a count of UniqueDigitalCredentials that match the given filter based on the claims they contain.
186
+ * @param args
187
+ */
188
+ private crsGetCredentialsByClaimsCount;
189
+ private secureParse;
190
+ private toUniqueCredentials;
191
+ }
192
+
193
+ /**
194
+ * Creates a filter to find a digital credential by its ID or hash.
195
+ *
196
+ * @param credentialRole - The role to filter by (e.g., ISSUER, HOLDER).
197
+ * @param idOrHash - The ID or hash of the credential to search for.
198
+ * @returns A FindDigitalCredentialArgs array for filtering by ID or hash.
199
+ */
200
+ declare const credentialIdOrHashFilter: (credentialRole: CredentialRole, idOrHash: string) => FindDigitalCredentialArgs;
201
+ /**
202
+ * Creates a filter for verifiable credentials with a specific role.
203
+ *
204
+ * @param credentialRole - The role to filter by (e.g., ISSUER, HOLDER).
205
+ * @param withFilter - Optional additional filter criteria.
206
+ * @returns A FindDigitalCredentialArgs array for filtering verifiable credentials by role.
207
+ */
208
+ declare const verifiableCredentialForRoleFilter: (credentialRole: CredentialRole, withFilter?: FindDigitalCredentialArgs) => FindDigitalCredentialArgs;
209
+ /**
210
+ * Merges two FindDigitalCredentialArgs arrays into a single array.
211
+ *
212
+ * This function combines two filter arrays, merging objects at the same index
213
+ * and adding unique objects from both arrays. When merging objects, properties
214
+ * from filter2 overwrite those from filter1 if they exist in both.
215
+ *
216
+ * @param filter1 - The first FindDigitalCredentialArgs array to merge.
217
+ * @param filter2 - The second FindDigitalCredentialArgs array to merge.
218
+ * @returns A new FindDigitalCredentialArgs array containing the merged result.
219
+ *
220
+ * @example
221
+ * const filter1 = [{ documentType: DocumentType.VC }, { credentialRole: CredentialRole.ISSUER }];
222
+ * const filter2 = [{ documentType: DocumentType.VP }, { hash: 'abc123' }];
223
+ * const mergedFilter = mergeFilter(filter1, filter2);
224
+ * // Result: [{ documentType: DocumentType.VP }, { credentialRole: CredentialRole.ISSUER, hash: 'abc123' }]
225
+ */
226
+ declare const mergeFilter: (filter1: FindDigitalCredentialArgs, filter2: FindDigitalCredentialArgs) => FindDigitalCredentialArgs;
227
+
1
228
  /**
2
229
  * @public
3
230
  */
4
231
  declare const schema: any;
5
- export { schema };
6
- export declare const logger: import("@sphereon/ssi-types").ISimpleLogger<unknown>;
7
- export { CredentialStore, credentialStoreMethods } from './agent/CredentialStore';
8
- export { CredentialRole, CredentialStateType, CredentialCorrelationType, CredentialDocumentFormat, DocumentType, DigitalCredential, FindDigitalCredentialArgs, } from '@sphereon/ssi-sdk.data-store';
9
- export * from './types/ICredentialStore';
10
- export * from './types/claims';
11
- export * from './utils/filters';
12
- //# sourceMappingURL=index.d.ts.map
232
+
233
+ declare const logger: _sphereon_ssi_types.ISimpleLogger<unknown>;
234
+
235
+ export { type AddCredentialArgs, type AddDigitalCredential, CredentialStore, type DeleteCredentialArgs, type DeleteCredentialsArgs, type FindArgs, type FindClaimsArgs, type GetCredentialArgs, type GetCredentialsArgs, type GetCredentialsByClaimsArgs, type GetCredentialsByIdOrHashArgs, type ICredentialStore, type OptionalUniqueDigitalCredential, type Order, type RequiredContext, type TClaimsColumns, type UniqueDigitalCredential, type Where, contextHasCredentialStore, credentialIdOrHashFilter, credentialStoreMethods, logger, mergeFilter, schema, verifiableCredentialForRoleFilter };