Skip to content

Commit 35caefb

Browse files
authored
🤖 Merge PR DefinitelyTyped#54348 feat: add revocation methods by @TimoGlastra
* feat: add revocation methods Signed-off-by: Timo Glastra <[email protected]> * prettier styling Signed-off-by: Timo Glastra <[email protected]>
1 parent d4f392f commit 35caefb

File tree

2 files changed

+222
-123
lines changed

2 files changed

+222
-123
lines changed

types/indy-sdk/index.d.ts

Lines changed: 80 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,31 @@ export function parseGetSchemaResponse(response: LedgerResponse): Promise<[Schem
8080
export function buildCredDefRequest(submitterDid: Did, credDef: CredDef): Promise<LedgerRequest>;
8181
export function buildGetCredDefRequest(submitterDid: Did | null, credDefId: CredDefId): Promise<LedgerRequest>;
8282
export function parseGetCredDefResponse(response: LedgerResponse): Promise<[CredDefId, CredDef]>;
83+
84+
// Revocation Ledger methods
85+
export function buildRevocRegDefRequest(submitterDid: Did, data: RevocRegDef): Promise<LedgerRequest>;
86+
export function buildGetRevocRegDefRequest(submitterDid: Did | null, revRegId: RevRegId): Promise<LedgerRequest>;
87+
export function parseGetRevocRegDefResponse(response: LedgerResponse): Promise<[RevRegId, RevocRegDef]>;
88+
export function buildRevocRegEntryRequest(
89+
submitterDid: Did,
90+
revRegId: RevRegId,
91+
revDefType: 'CL_ACCUM',
92+
value: RevocRegDelta,
93+
): Promise<LedgerRequest>;
94+
export function buildGetRevocRegRequest(
95+
submitterDid: Did | null,
96+
revRegId: RevRegId,
97+
timestamp: number,
98+
): Promise<LedgerRequest>;
99+
export function parseGetRevocRegResponse(response: LedgerResponse): Promise<[RevRegId, RevocReg, number]>;
100+
export function buildGetRevocRegDeltaRequest(
101+
submitterDid: Did | null,
102+
revRegId: RevRegId,
103+
from: number | null,
104+
to: number,
105+
): Promise<LedgerRequest>;
106+
export function parseGetRevocRegDeltaResponse(response: LedgerResponse): Promise<[RevRegId, RevocRegDelta, number]>;
107+
83108
export function signRequest(wh: WalletHandle, submitterDid: Did, request: LedgerRequest): Promise<SignedLedgerRequest>;
84109
export function signAndSubmitRequest(
85110
poolHandle: PoolHandle,
@@ -123,7 +148,19 @@ export function issuerCreateAndStoreCredentialDef(
123148
): Promise<[CredDefId, CredDef]>;
124149
// TODO: issuerRotateCredentialDefStart
125150
// TODO: issuerRotateCredentialDefApply
126-
// TODO: issuerCreateAndStoreRevocReg
151+
export function issuerCreateAndStoreRevocReg(
152+
wh: WalletHandle,
153+
issuerDid: Did,
154+
revocDefType: 'CL_ACCUM' | null,
155+
tag: string,
156+
credDefId: CredDefId,
157+
config: {
158+
issuance_type?: 'ISSUANCE_BY_DEFAULT' | 'ISSUANCE_ON_DEMAND';
159+
max_cred_num?: number;
160+
},
161+
tailsWriterHandle: BlobWriterHandle,
162+
): Promise<[RevRegId, RevocRegDef, RevocRegDelta]>;
163+
127164
export function issuerCreateCredentialOffer(wh: WalletHandle, credDefId: CredDefId): Promise<CredOffer>;
128165
export function issuerCreateCredential(
129166
wh: WalletHandle,
@@ -133,8 +170,17 @@ export function issuerCreateCredential(
133170
revRegId: RevRegId | null,
134171
blobStorageReaderHandle: BlobStorageReaderHandle | 0,
135172
): Promise<[Cred, CredRevocId, RevocRegDelta]>;
136-
// TODO: issuerRevokeCredential
137-
// TODO: issuerMergeRevocationRegistryDeltas
173+
174+
export function issuerRevokeCredential(
175+
wh: WalletHandle,
176+
blobStorageReaderHandle: BlobStorageReaderHandle,
177+
revRegId: RevRegId,
178+
credRevocId: CredRevocId,
179+
): Promise<RevocRegDelta>;
180+
export function issuerMergeRevocationRegistryDeltas(
181+
revRegDelta: RevocRegDelta,
182+
otherRevRegDelta: RevocRegDelta,
183+
): Promise<RevocRegDelta>;
138184

139185
// ---- PROVER ---- //
140186
export function proverCreateMasterSecret(wh: WalletHandle, masterSecretId: string): Promise<string>;
@@ -357,6 +403,21 @@ export interface CredDefConfig {
357403
support_revocation?: boolean;
358404
}
359405

406+
export interface RevocRegDef {
407+
id: RevRegId;
408+
revocDefType: 'CL_ACCUM';
409+
tag: string;
410+
credDefId: CredDefId;
411+
value: {
412+
issuanceType: 'ISSUANCE_BY_DEFAULT' | 'ISSUANCE_ON_DEMAND';
413+
maxCredNum: number;
414+
tailsHash: string;
415+
tailsLocation: string;
416+
publicKeys: string[];
417+
};
418+
ver: string;
419+
}
420+
360421
export interface CredOffer {
361422
schema_id: SchemaId;
362423
cred_def_id: CredDefId;
@@ -520,7 +581,22 @@ export interface Cred {
520581
}
521582

522583
export type CredRevocId = string;
523-
export type RevocRegDelta = Record<string, unknown>;
584+
export interface RevocRegDelta {
585+
value: {
586+
prevAccum: string;
587+
accum: string;
588+
issued: number[];
589+
revoked: number[];
590+
};
591+
ver: string;
592+
}
593+
594+
export interface RevocReg {
595+
value: {
596+
accum: string;
597+
};
598+
ver: string;
599+
}
524600

525601
export interface KeyConfig {
526602
seed?: string;

0 commit comments

Comments
 (0)