Skip to content

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyr-basiuk committed Nov 29, 2024
1 parent a7d6e97 commit 9daab77
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 24 deletions.
5 changes: 3 additions & 2 deletions src/credentials/status/did-resolver-revocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ export class DidDocumentCredentialStatusResolver implements CredentialStatusReso
throw new Error('IssuerDID is not set in options');
}

const didString = opts?.issuerDID.string().replace(/:/g, '%3A');
const url = `${this.didResolverUrl}/1.0/credential-status/${didString}`;
const url = `${this.didResolverUrl}/1.0/credential-status/${encodeURIComponent(
opts.issuerDID.string()
)}`;
const resp = await fetch(url, {
method: 'POST',
body: JSON.stringify(credentialStatus)
Expand Down
30 changes: 12 additions & 18 deletions src/storage/blockchain/did-resolver-readonly-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ export class DidResolverStateReadonlyStorage implements IStateStorage {
DID.parseFromId(Id.fromBigInt(id)),
this.resolverUrl
);
const vm = (didDocument as DIDDocument).verificationMethod?.find(
(i) => i.type === 'Iden3StateInfo2023'
);
if (!vm) {
throw new Error('Iden3StateInfo2023 verification method not found');
}
const { global } = vm as VerificationMethod;
const { global } = this.getIden3StateInfo2023(didDocument);
if (!global) {
throw new Error('GIST root not found');
}
Expand Down Expand Up @@ -54,13 +48,7 @@ export class DidResolverStateReadonlyStorage implements IStateStorage {
gist: Hash.fromBigInt(root)
}
);
const vm = (didDocument as DIDDocument).verificationMethod?.find(
(i) => i.type === 'Iden3StateInfo2023'
);
if (!vm) {
throw new Error('Iden3StateInfo2023 verification method not found');
}
const { global } = vm as VerificationMethod;
const { global } = this.getIden3StateInfo2023(didDocument);
if (!global) {
throw new Error('GIST root not found');
}
Expand All @@ -70,9 +58,11 @@ export class DidResolverStateReadonlyStorage implements IStateStorage {
getRpcProvider(): JsonRpcProvider {
return new JsonRpcProvider();
}

publishState(): Promise<string> {
throw new Error('publishState method not implemented.');
}

publishStateGeneric(): Promise<string> {
throw new Error('publishStateGeneric method not implemented.');
}
Expand All @@ -84,13 +74,17 @@ export class DidResolverStateReadonlyStorage implements IStateStorage {
this.resolverUrl,
opts
);
const vm = (didDocument as DIDDocument).verificationMethod?.find(
(i) => i.type === 'Iden3StateInfo2023'
const { info } = this.getIden3StateInfo2023(didDocument);
return { ...info };
}

private getIden3StateInfo2023(didDocument: DIDDocument): VerificationMethod {
const vm: VerificationMethod | undefined = didDocument.verificationMethod?.find(
(i: VerificationMethod) => i.type === 'Iden3StateInfo2023'
);
if (!vm) {
throw new Error('Iden3StateInfo2023 verification method not found');
}
const { info } = vm as VerificationMethod;
return { ...info };
return vm;
}
}
2 changes: 1 addition & 1 deletion src/storage/blockchain/onchain-zkp-verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ export class OnChainZKPVerifier implements IOnChainZKPVerifier {
);
}

private static packGlobalStateMsg(msg: GlobalStateUpdate): string {
public static packGlobalStateMsg(msg: GlobalStateUpdate): string {
return new ethers.AbiCoder().encode(
[
'tuple(' +
Expand Down
6 changes: 3 additions & 3 deletions src/utils/did-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const resolveDIDDocumentAuth = async (
resolveURL: string,
state?: Hash
): Promise<VerificationMethod | undefined> => {
let url = `${resolveURL}/${did.string().replace(/:/g, '%3A')}`;
let url = `${resolveURL}/${encodeURIComponent(did.string())}`;
if (state) {
url += `?state=${state.hex()}`;
}
Expand Down Expand Up @@ -115,11 +115,11 @@ export const resolveDidDocument = async (
signature?: DIDDocumentSignature;
}
): Promise<DIDResolutionMetadata> => {
let didString = did.string().replace(/:/g, '%3A');
let didString = encodeURIComponent(did.string());
// for gist resolve we have to `hide` user did (look into resolver implementation)
const isGistRequest = opts?.gist && !opts.state;
if (isGistRequest) {
didString = emptyStateDID(did).string().replace(/:/g, '%3A');
didString = encodeURIComponent(emptyStateDID(did).string());
}
let url = `${resolverUrl}/1.0/identifiers/${didString}`;

Expand Down

0 comments on commit 9daab77

Please sign in to comment.