@0xpolygonid/js-sdk 1.30.0 → 1.31.3
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/browser/esm/index.js +972 -367
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +975 -365
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/credentials/credential-wallet.js +1 -1
- package/dist/node/cjs/credentials/status/on-chain-revocation.js +3 -10
- package/dist/node/cjs/iden3comm/handlers/common.js +51 -24
- package/dist/node/cjs/identity/identity-wallet.js +29 -16
- package/dist/node/cjs/proof/proof-service.js +5 -4
- package/dist/node/cjs/proof/verifiers/query.js +25 -1
- package/dist/node/cjs/schema-processor/json/validator.js +11 -0
- package/dist/node/cjs/storage/blockchain/onchain-zkp-verifier.js +0 -1
- package/dist/node/cjs/storage/blockchain/state.js +120 -3
- package/dist/node/cjs/storage/memory/cache-lru.js +25 -0
- package/dist/node/cjs/storage/memory/index.js +1 -0
- package/dist/node/cjs/storage/shared/identity-storage.js +7 -0
- package/dist/node/cjs/verifiable/constants.js +26 -2
- package/dist/node/cjs/verifiable/presentation.js +3 -3
- package/dist/node/esm/credentials/credential-wallet.js +1 -1
- package/dist/node/esm/credentials/status/on-chain-revocation.js +4 -11
- package/dist/node/esm/iden3comm/handlers/common.js +51 -24
- package/dist/node/esm/identity/identity-wallet.js +29 -16
- package/dist/node/esm/proof/proof-service.js +6 -5
- package/dist/node/esm/proof/verifiers/query.js +21 -0
- package/dist/node/esm/schema-processor/json/validator.js +11 -0
- package/dist/node/esm/storage/blockchain/onchain-zkp-verifier.js +0 -1
- package/dist/node/esm/storage/blockchain/state.js +120 -3
- package/dist/node/esm/storage/memory/cache-lru.js +18 -0
- package/dist/node/esm/storage/memory/index.js +1 -0
- package/dist/node/esm/storage/shared/identity-storage.js +7 -0
- package/dist/node/esm/verifiable/constants.js +25 -1
- package/dist/node/esm/verifiable/presentation.js +3 -3
- package/dist/types/credentials/status/on-chain-revocation.d.ts +6 -2
- package/dist/types/iden3comm/types/protocol/auth.d.ts +2 -2
- package/dist/types/identity/identity-wallet.d.ts +18 -3
- package/dist/types/proof/verifiers/query.d.ts +3 -0
- package/dist/types/storage/blockchain/state.d.ts +65 -1
- package/dist/types/storage/entities/identity.d.ts +1 -0
- package/dist/types/storage/interfaces/identity.d.ts +8 -1
- package/dist/types/storage/memory/cache-lru.d.ts +10 -0
- package/dist/types/storage/memory/index.d.ts +1 -0
- package/dist/types/storage/shared/identity-storage.d.ts +5 -0
- package/dist/types/verifiable/constants.d.ts +21 -0
- package/package.json +3 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import QuickLRU from 'quick-lru';
|
|
2
|
+
export function createInMemoryCache(params) {
|
|
3
|
+
const cache = new QuickLRU({ maxSize: params.maxSize, maxAge: params.ttl });
|
|
4
|
+
return {
|
|
5
|
+
get: async (key) => {
|
|
6
|
+
return cache.get(key);
|
|
7
|
+
},
|
|
8
|
+
set: async (key, value, ttl) => {
|
|
9
|
+
cache.set(key, value, { maxAge: ttl ?? params.ttl });
|
|
10
|
+
},
|
|
11
|
+
clear: async () => {
|
|
12
|
+
cache.clear();
|
|
13
|
+
},
|
|
14
|
+
delete: async (key) => {
|
|
15
|
+
cache.delete(key);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -24,9 +24,16 @@ export class IdentityStorage {
|
|
|
24
24
|
await this._profileDataSource.save(element.id, element);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated The method should not be used. It returns only one profile per verifier, which can potentially restrict business use cases
|
|
29
|
+
* Use getProfilesByVerifier instead.
|
|
30
|
+
*/
|
|
27
31
|
async getProfileByVerifier(verifier) {
|
|
28
32
|
return this._profileDataSource.get(verifier, 'verifier');
|
|
29
33
|
}
|
|
34
|
+
async getProfilesByVerifier(verifier, tags) {
|
|
35
|
+
return (await this._profileDataSource.load()).filter((p) => p.verifier === verifier && (!tags || tags.every((tag) => p.tags?.includes(tag))));
|
|
36
|
+
}
|
|
30
37
|
async getProfileById(profileId) {
|
|
31
38
|
return this._profileDataSource.get(profileId);
|
|
32
39
|
}
|
|
@@ -5,7 +5,27 @@ export const VerifiableConstants = Object.freeze({
|
|
|
5
5
|
CONTEXT_TYPE_IS_EMPTY: 'ctxType is empty',
|
|
6
6
|
// ErrStateNotFound issuer state is genesis state.
|
|
7
7
|
IDENTITY_DOES_NOT_EXIST: 'Identity does not exist',
|
|
8
|
-
NO_AUTH_CRED_FOUND: 'no auth credentials found'
|
|
8
|
+
NO_AUTH_CRED_FOUND: 'no auth credentials found',
|
|
9
|
+
// identity wallet
|
|
10
|
+
ID_WALLET_NO_CREDENTIAL_SATISFIED_QUERY: 'no credential satisfied query',
|
|
11
|
+
ID_WALLET_SIGNER_IS_REQUIRED: 'Ethereum signer is required to create Ethereum identities in order to transit state',
|
|
12
|
+
ID_WALLET_PROVER_IS_REQUIRED: 'prover is required to generate proofs for non ethereum identities',
|
|
13
|
+
ID_WALLET_CORE_CLAIM_REQUIRED_IN_SIG_PROOF: 'credential must have coreClaim representation in the signature proof',
|
|
14
|
+
ID_WALLET_CORE_CLAIM_REQUIRED_IN_ANY_PROOF: 'credential must have coreClaim representation in proofs',
|
|
15
|
+
ID_WALLET_CORE_CLAIM_MISMATCH: 'core claim representations is set in both proofs but they are not equal',
|
|
16
|
+
ID_WALLET_CORE_CLAIM_IS_NOT_SET: 'core claim is not set in credential proofs',
|
|
17
|
+
ID_WALLET_PROFILE_OR_IDENTITY_NOT_FOUND: 'profile or identity not found',
|
|
18
|
+
ID_WALLET_PROFILE_ALREADY_EXISTS: 'profile with given nonce or verifier already exists',
|
|
19
|
+
ID_WALLET_PROFILE_ALREADY_EXISTS_VERIFIER_TAGS: 'profile with given verifier and tags already exists',
|
|
20
|
+
ID_WALLET_ISSUER_AUTH_BJJ_CRED_MUST_HAVE_ANY_PROOF: 'issuer auth credential must have proof',
|
|
21
|
+
ID_WALLET_ISSUER_AUTH_BJJ_CRED_MUST_HAVE_MTP_PROOF: 'mtp is required for auth bjj key to issue new credentials',
|
|
22
|
+
// proof service
|
|
23
|
+
PROOF_SERVICE_NO_CREDENTIAL_FOR_IDENTITY_OR_PROFILE: 'no credentials belong to did or its profiles',
|
|
24
|
+
PROOF_SERVICE_NO_CREDENTIAL_FOR_QUERY: 'credential not found for query',
|
|
25
|
+
PROOF_SERVICE_PROFILE_GENESIS_DID_MISMATCH: 'subject and auth profiles are not derived from the same did',
|
|
26
|
+
PROOF_SERVICE_NO_QUERIES_IN_ZKP_REQUEST: 'no queries in zkp request',
|
|
27
|
+
// credential wallet
|
|
28
|
+
CREDENTIAL_WALLET_ALL_CREDENTIALS_ARE_REVOKED: 'all claims are revoked'
|
|
9
29
|
},
|
|
10
30
|
CREDENTIAL_TYPE: {
|
|
11
31
|
// VerifiableCredential is a W3C verifiable credential type
|
|
@@ -178,3 +198,7 @@ export var DisplayMethodType;
|
|
|
178
198
|
(function (DisplayMethodType) {
|
|
179
199
|
DisplayMethodType["Iden3BasicDisplayMethodV1"] = "Iden3BasicDisplayMethodV1";
|
|
180
200
|
})(DisplayMethodType || (DisplayMethodType = {}));
|
|
201
|
+
/**
|
|
202
|
+
* Default cache max size for in-memory cache
|
|
203
|
+
*/
|
|
204
|
+
export const DEFAULT_CACHE_MAX_SIZE = 10000;
|
|
@@ -41,12 +41,12 @@ export const createVerifiablePresentation = (context, tp, credential, queries) =
|
|
|
41
41
|
}
|
|
42
42
|
const skeleton = {
|
|
43
43
|
'@context': baseContext,
|
|
44
|
-
|
|
44
|
+
type: VerifiableConstants.CREDENTIAL_TYPE.W3C_VERIFIABLE_PRESENTATION,
|
|
45
45
|
verifiableCredential: {
|
|
46
46
|
'@context': ldContext,
|
|
47
|
-
|
|
47
|
+
type: vcTypes,
|
|
48
48
|
credentialSubject: {
|
|
49
|
-
|
|
49
|
+
type: tp
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
};
|
|
@@ -2,6 +2,10 @@ import { RevocationStatus, CredentialStatus } from '../../verifiable';
|
|
|
2
2
|
import { EthConnectionConfig } from '../../storage/blockchain';
|
|
3
3
|
import { CredentialStatusResolver, CredentialStatusResolveOptions } from './resolver';
|
|
4
4
|
import { DID } from '@iden3/js-iden3-core';
|
|
5
|
+
import { EthStateStorageOptions } from '../../storage/blockchain/state';
|
|
6
|
+
export type OnChainResolverOptions = {
|
|
7
|
+
stateStorageOptions?: EthStateStorageOptions;
|
|
8
|
+
};
|
|
5
9
|
/**
|
|
6
10
|
* OnChainIssuer is a class that allows to interact with the onchain contract
|
|
7
11
|
* and build the revocation status.
|
|
@@ -11,13 +15,14 @@ import { DID } from '@iden3/js-iden3-core';
|
|
|
11
15
|
*/
|
|
12
16
|
export declare class OnChainResolver implements CredentialStatusResolver {
|
|
13
17
|
private readonly _configs;
|
|
18
|
+
private readonly _stateStorage;
|
|
14
19
|
/**
|
|
15
20
|
*
|
|
16
21
|
* Creates an instance of OnChainIssuer.
|
|
17
22
|
* @public
|
|
18
23
|
* @param {Array<EthConnectionConfig>} _configs - list of ethereum network connections
|
|
19
24
|
*/
|
|
20
|
-
constructor(_configs: EthConnectionConfig[]);
|
|
25
|
+
constructor(_configs: EthConnectionConfig[], _opts?: OnChainResolverOptions);
|
|
21
26
|
/**
|
|
22
27
|
* resolve is a method to resolve a credential status from the blockchain.
|
|
23
28
|
*
|
|
@@ -48,6 +53,5 @@ export declare class OnChainResolver implements CredentialStatusResolver {
|
|
|
48
53
|
stateHex: string;
|
|
49
54
|
};
|
|
50
55
|
networkByChainId(chainId: number): EthConnectionConfig;
|
|
51
|
-
private _getStateStorageForIssuer;
|
|
52
56
|
private _getOnChainRevocationStorageForIssuer;
|
|
53
57
|
}
|
|
@@ -70,10 +70,10 @@ export type ZeroKnowledgeProofAuthResponse = Omit<ZeroKnowledgeProofResponse, 'i
|
|
|
70
70
|
/** VerifiablePresentation represents structure of Verifiable Presentation */
|
|
71
71
|
export type VerifiablePresentation = {
|
|
72
72
|
'@context': string | (string | object)[];
|
|
73
|
-
|
|
73
|
+
type: string;
|
|
74
74
|
verifiableCredential: {
|
|
75
75
|
'@context': string | string[];
|
|
76
|
-
|
|
76
|
+
type: string | string[];
|
|
77
77
|
credentialSubject: JsonDocumentObject;
|
|
78
78
|
};
|
|
79
79
|
};
|
|
@@ -117,9 +117,10 @@ export interface IIdentityWallet {
|
|
|
117
117
|
* @param {DID} did - identity to derive profile from
|
|
118
118
|
* @param {number |string} nonce - unique integer number to generate a profile
|
|
119
119
|
* @param {string} verifier - verifier identity/alias in a string from
|
|
120
|
+
* @param {string[]} tags - optional tag that can be assigned to profile by client
|
|
120
121
|
* @returns `Promise<DID>` - profile did
|
|
121
122
|
*/
|
|
122
|
-
createProfile(did: DID, nonce: number | string, verifier: string): Promise<DID>;
|
|
123
|
+
createProfile(did: DID, nonce: number | string, verifier: string, tags?: string[]): Promise<DID>;
|
|
123
124
|
/**
|
|
124
125
|
* Generates a new key
|
|
125
126
|
*
|
|
@@ -291,11 +292,19 @@ export interface IIdentityWallet {
|
|
|
291
292
|
/**
|
|
292
293
|
*
|
|
293
294
|
* gets profile identity by verifier
|
|
294
|
-
*
|
|
295
|
+
* @deprecated The method should not be used. It returns only one profile per verifier, which can potentially restrict business use cases
|
|
295
296
|
* @param {string} verifier - identifier of the verifier
|
|
296
297
|
* @returns `{Promise<Profile>}`
|
|
297
298
|
*/
|
|
298
299
|
getProfileByVerifier(verifier: string): Promise<Profile | undefined>;
|
|
300
|
+
/**
|
|
301
|
+
* gets profile by verifiers
|
|
302
|
+
*
|
|
303
|
+
* @param {string} verifier - verifier to which profile has been shared
|
|
304
|
+
* @param {string} tags - optional, tags to filter profile entry
|
|
305
|
+
* @returns `{Promise<Profile[]>}`
|
|
306
|
+
*/
|
|
307
|
+
getProfilesByVerifier(verifier: string, tags?: string[]): Promise<Profile[]>;
|
|
299
308
|
/**
|
|
300
309
|
*
|
|
301
310
|
* updates latest identity state in storage with given state or latest from the trees.
|
|
@@ -398,7 +407,7 @@ export declare class IdentityWallet implements IIdentityWallet {
|
|
|
398
407
|
genesisDID: DID;
|
|
399
408
|
}>;
|
|
400
409
|
/** {@inheritDoc IIdentityWallet.createProfile} */
|
|
401
|
-
createProfile(did: DID, nonce: number | string, verifier: string): Promise<DID>;
|
|
410
|
+
createProfile(did: DID, nonce: number | string, verifier: string, tags?: string[]): Promise<DID>;
|
|
402
411
|
/**
|
|
403
412
|
*
|
|
404
413
|
* gets profile identity by genesis identifiers
|
|
@@ -409,7 +418,13 @@ export declare class IdentityWallet implements IIdentityWallet {
|
|
|
409
418
|
getProfilesByDID(did: DID): Promise<Profile[]>;
|
|
410
419
|
/** {@inheritDoc IIdentityWallet.generateKey} */
|
|
411
420
|
generateKey(keyType: KmsKeyType): Promise<KmsKeyId>;
|
|
421
|
+
/**
|
|
422
|
+
* @deprecated The method should not be used. It returns only one profile per verifier, which can potentially restrict business use cases
|
|
423
|
+
* {@inheritDoc IIdentityWallet.getProfileByVerifier}
|
|
424
|
+
*/
|
|
412
425
|
getProfileByVerifier(verifier: string): Promise<Profile | undefined>;
|
|
426
|
+
/** {@inheritDoc IIdentityWallet.getProfilesByVerifier} */
|
|
427
|
+
getProfilesByVerifier(verifier: string, tags?: string[]): Promise<Profile[]>;
|
|
413
428
|
/** {@inheritDoc IIdentityWallet.getDIDTreeModel} */
|
|
414
429
|
getDIDTreeModel(did: DID): Promise<TreesModel>;
|
|
415
430
|
/** {@inheritDoc IIdentityWallet.generateClaimMtp} */
|
|
@@ -37,3 +37,6 @@ export declare function validateDisclosureV2Circuit(cq: QueryMetadata, outputs:
|
|
|
37
37
|
export declare function validateDisclosureNativeSDSupport(cq: QueryMetadata, outputs: ClaimOutputs, verifiablePresentation?: VerifiablePresentation, ldLoader?: DocumentLoader): Promise<void>;
|
|
38
38
|
export declare function validateEmptyCredentialSubjectNoopNativeSupport(outputs: ClaimOutputs): Promise<void>;
|
|
39
39
|
export declare const fieldValueFromVerifiablePresentation: (fieldName: string, verifiablePresentation?: VerifiablePresentation, ldLoader?: DocumentLoader) => Promise<bigint>;
|
|
40
|
+
export declare function calculateGroupId(requestIds: bigint[]): bigint;
|
|
41
|
+
export declare function calculateRequestId(requestParams: string, creatorAddress: string): bigint;
|
|
42
|
+
export declare function calculateMultiRequestId(requestIds: bigint[], groupIds: bigint[], creatorAddress: string): bigint;
|
|
@@ -3,6 +3,53 @@ import { ZKProof } from '@iden3/js-jwz';
|
|
|
3
3
|
import { IStateStorage, UserStateTransitionInfo } from '../interfaces/state';
|
|
4
4
|
import { Contract, JsonRpcProvider, Signer } from 'ethers';
|
|
5
5
|
import { StateInfo } from '../entities/state';
|
|
6
|
+
import { ICache } from '../memory';
|
|
7
|
+
/**
|
|
8
|
+
* Configuration options for caching behavior
|
|
9
|
+
*/
|
|
10
|
+
export type ResolverCacheOptions = {
|
|
11
|
+
/** TTL in milliseconds for latest states/roots (shorter since they can change) */
|
|
12
|
+
notReplacedTtl?: number;
|
|
13
|
+
/** TTL in milliseconds for historical states/roots (longer since they can change with less probability) */
|
|
14
|
+
replacedTtl?: number;
|
|
15
|
+
/** Maximum number of entries to store in cache */
|
|
16
|
+
maxSize?: number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Simplified cache config with a single TTL (used for latest/gist proofs etc.)
|
|
20
|
+
*/
|
|
21
|
+
export type SimpleCacheOptions = {
|
|
22
|
+
/** TTL in milliseconds for latest states/gist proof */
|
|
23
|
+
ttl?: number;
|
|
24
|
+
/** Maximum number of entries to store in cache */
|
|
25
|
+
maxSize?: number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* EthStateStorageOptions options for the Ethereum state storage.
|
|
29
|
+
*/
|
|
30
|
+
export type EthStateStorageOptions = {
|
|
31
|
+
/** Disable caching */
|
|
32
|
+
disableCache?: boolean;
|
|
33
|
+
/** Configuration for latest state resolution caching */
|
|
34
|
+
latestStateCacheOptions?: {
|
|
35
|
+
/** Custom cache implementation (if not provided, uses in-memory cache) */
|
|
36
|
+
cache?: ICache<StateInfo>;
|
|
37
|
+
} & SimpleCacheOptions;
|
|
38
|
+
/** Configuration for state resolution caching */
|
|
39
|
+
stateCacheOptions?: {
|
|
40
|
+
/** Custom cache implementation (if not provided, uses in-memory cache) */
|
|
41
|
+
cache?: ICache<StateInfo>;
|
|
42
|
+
} & ResolverCacheOptions;
|
|
43
|
+
/** Configuration for GIST root resolution caching */
|
|
44
|
+
rootCacheOptions?: {
|
|
45
|
+
/** Custom cache implementation (if not provided, uses in-memory cache) */
|
|
46
|
+
cache?: ICache<RootInfo>;
|
|
47
|
+
} & ResolverCacheOptions;
|
|
48
|
+
gistProofCacheOptions?: {
|
|
49
|
+
/** Custom cache implementation for GIST proofs (if not provided, uses in-memory cache) */
|
|
50
|
+
cache?: ICache<StateProof>;
|
|
51
|
+
} & SimpleCacheOptions;
|
|
52
|
+
};
|
|
6
53
|
/**
|
|
7
54
|
* Configuration of ethereum based blockchain connection
|
|
8
55
|
*
|
|
@@ -38,11 +85,20 @@ export declare class EthStateStorage implements IStateStorage {
|
|
|
38
85
|
readonly stateContract: Contract;
|
|
39
86
|
private readonly provider;
|
|
40
87
|
private readonly _transactionService;
|
|
88
|
+
private _latestStateResolveCache;
|
|
89
|
+
private _stateResolveCache;
|
|
90
|
+
private _rootResolveCache;
|
|
91
|
+
private _gistProofResolveCache;
|
|
92
|
+
private _latestStateCacheOptions;
|
|
93
|
+
private _stateCacheOptions;
|
|
94
|
+
private _rootCacheOptions;
|
|
95
|
+
private _gistProofCacheOptions;
|
|
96
|
+
private _disableCache;
|
|
41
97
|
/**
|
|
42
98
|
* Creates an instance of EthStateStorage.
|
|
43
99
|
* @param {EthConnectionConfig} [ethConfig=defaultEthConnectionConfig]
|
|
44
100
|
*/
|
|
45
|
-
constructor(ethConfig: EthConnectionConfig | EthConnectionConfig[]);
|
|
101
|
+
constructor(ethConfig: EthConnectionConfig | EthConnectionConfig[], options?: EthStateStorageOptions);
|
|
46
102
|
/** {@inheritdoc IStateStorage.getLatestStateById} */
|
|
47
103
|
getLatestStateById(id: bigint): Promise<StateInfo>;
|
|
48
104
|
/** {@inheritdoc IStateStorage.getStateInfoByIdAndState} */
|
|
@@ -57,6 +113,14 @@ export declare class EthStateStorage implements IStateStorage {
|
|
|
57
113
|
getGISTRootInfo(root: bigint, id: bigint): Promise<RootInfo>;
|
|
58
114
|
/** {@inheritdoc IStateStorage.getRpcProvider} */
|
|
59
115
|
getRpcProvider(): JsonRpcProvider;
|
|
116
|
+
/** enable caching */
|
|
117
|
+
enableCache(): void;
|
|
118
|
+
/** disable caching */
|
|
119
|
+
disableCache(): void;
|
|
60
120
|
private getStateContractAndProviderForId;
|
|
61
121
|
private networkByChainId;
|
|
122
|
+
private getGistProofCacheKey;
|
|
123
|
+
private getLatestStateCacheKey;
|
|
124
|
+
private getStateCacheKey;
|
|
125
|
+
private getRootCacheKey;
|
|
62
126
|
}
|
|
@@ -39,11 +39,18 @@ export interface IIdentityStorage {
|
|
|
39
39
|
saveProfile(profile: Profile): Promise<void>;
|
|
40
40
|
/**
|
|
41
41
|
* gets profile by verifier
|
|
42
|
-
*
|
|
42
|
+
* @deprecated The method should not be used. It returns only one profile per verifier, which can potentially restrict business use cases
|
|
43
43
|
* @param {string} verifier - verifier to which profile has been shared
|
|
44
44
|
* @returns `{Promise<Profile>}`
|
|
45
45
|
*/
|
|
46
46
|
getProfileByVerifier(verifier: string): Promise<Profile | undefined>;
|
|
47
|
+
/**
|
|
48
|
+
* gets profile by verifiers
|
|
49
|
+
* @param {string} verifier - verifier to which profile has been shared
|
|
50
|
+
* @param {string[]} tags - optional tag to filter profile entry
|
|
51
|
+
* @returns `{Promise<Profile[]>}`
|
|
52
|
+
*/
|
|
53
|
+
getProfilesByVerifier(verifier: string, tags?: string[]): Promise<Profile[]>;
|
|
47
54
|
/**
|
|
48
55
|
* gets profile by identifier
|
|
49
56
|
*
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface ICache<T> {
|
|
2
|
+
get(key: string): Promise<T | undefined>;
|
|
3
|
+
set(key: string, value: T, ttl?: number): Promise<void>;
|
|
4
|
+
delete(key: string): Promise<void>;
|
|
5
|
+
clear(): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export declare function createInMemoryCache<T>(params: {
|
|
8
|
+
ttl?: number;
|
|
9
|
+
maxSize: number;
|
|
10
|
+
}): ICache<T>;
|
|
@@ -30,7 +30,12 @@ export declare class IdentityStorage implements IIdentityStorage {
|
|
|
30
30
|
*/
|
|
31
31
|
constructor(_identityDataSource: IDataSource<Identity>, _profileDataSource: IDataSource<Profile>);
|
|
32
32
|
saveProfile(profile: Profile): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated The method should not be used. It returns only one profile per verifier, which can potentially restrict business use cases
|
|
35
|
+
* Use getProfilesByVerifier instead.
|
|
36
|
+
*/
|
|
33
37
|
getProfileByVerifier(verifier: string): Promise<Profile | undefined>;
|
|
38
|
+
getProfilesByVerifier(verifier: string, tags?: string[]): Promise<Profile[]>;
|
|
34
39
|
getProfileById(profileId: string): Promise<Profile | undefined>;
|
|
35
40
|
getProfilesByGenesisIdentifier(genesisIdentifier: string): Promise<Profile[]>;
|
|
36
41
|
getAllIdentities(): Promise<Identity[]>;
|
|
@@ -5,6 +5,23 @@ export declare const VerifiableConstants: Readonly<{
|
|
|
5
5
|
CONTEXT_TYPE_IS_EMPTY: string;
|
|
6
6
|
IDENTITY_DOES_NOT_EXIST: string;
|
|
7
7
|
NO_AUTH_CRED_FOUND: string;
|
|
8
|
+
ID_WALLET_NO_CREDENTIAL_SATISFIED_QUERY: string;
|
|
9
|
+
ID_WALLET_SIGNER_IS_REQUIRED: string;
|
|
10
|
+
ID_WALLET_PROVER_IS_REQUIRED: string;
|
|
11
|
+
ID_WALLET_CORE_CLAIM_REQUIRED_IN_SIG_PROOF: string;
|
|
12
|
+
ID_WALLET_CORE_CLAIM_REQUIRED_IN_ANY_PROOF: string;
|
|
13
|
+
ID_WALLET_CORE_CLAIM_MISMATCH: string;
|
|
14
|
+
ID_WALLET_CORE_CLAIM_IS_NOT_SET: string;
|
|
15
|
+
ID_WALLET_PROFILE_OR_IDENTITY_NOT_FOUND: string;
|
|
16
|
+
ID_WALLET_PROFILE_ALREADY_EXISTS: string;
|
|
17
|
+
ID_WALLET_PROFILE_ALREADY_EXISTS_VERIFIER_TAGS: string;
|
|
18
|
+
ID_WALLET_ISSUER_AUTH_BJJ_CRED_MUST_HAVE_ANY_PROOF: string;
|
|
19
|
+
ID_WALLET_ISSUER_AUTH_BJJ_CRED_MUST_HAVE_MTP_PROOF: string;
|
|
20
|
+
PROOF_SERVICE_NO_CREDENTIAL_FOR_IDENTITY_OR_PROFILE: string;
|
|
21
|
+
PROOF_SERVICE_NO_CREDENTIAL_FOR_QUERY: string;
|
|
22
|
+
PROOF_SERVICE_PROFILE_GENESIS_DID_MISMATCH: string;
|
|
23
|
+
PROOF_SERVICE_NO_QUERIES_IN_ZKP_REQUEST: string;
|
|
24
|
+
CREDENTIAL_WALLET_ALL_CREDENTIALS_ARE_REVOKED: string;
|
|
8
25
|
};
|
|
9
26
|
CREDENTIAL_TYPE: {
|
|
10
27
|
W3C_VERIFIABLE_CREDENTIAL: string;
|
|
@@ -146,3 +163,7 @@ export declare enum PaymentFeatures {
|
|
|
146
163
|
export declare enum DisplayMethodType {
|
|
147
164
|
Iden3BasicDisplayMethodV1 = "Iden3BasicDisplayMethodV1"
|
|
148
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Default cache max size for in-memory cache
|
|
168
|
+
*/
|
|
169
|
+
export declare const DEFAULT_CACHE_MAX_SIZE = 10000;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xpolygonid/js-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.31.3",
|
|
4
4
|
"description": "SDK to work with Polygon ID",
|
|
5
5
|
"main": "dist/node/cjs/index.js",
|
|
6
6
|
"module": "dist/node/esm/index.js",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
},
|
|
100
100
|
"dependencies": {
|
|
101
101
|
"@iden3/onchain-non-merklized-issuer-base-abi": "^0.0.3",
|
|
102
|
-
"@iden3/universal-verifier-v2-abi": "^2.0.
|
|
102
|
+
"@iden3/universal-verifier-v2-abi": "^2.0.2",
|
|
103
103
|
"@noble/curves": "^1.9.2",
|
|
104
104
|
"ajv": "8.12.0",
|
|
105
105
|
"ajv-formats": "2.1.1",
|
|
@@ -110,6 +110,7 @@
|
|
|
110
110
|
"js-sha3": "0.9.3",
|
|
111
111
|
"jsonld": "8.3.1",
|
|
112
112
|
"pubsub-js": "1.9.4",
|
|
113
|
+
"quick-lru": "^7.0.1",
|
|
113
114
|
"uuid": "9.0.1"
|
|
114
115
|
},
|
|
115
116
|
"browserslist": {
|