Skip to content

Commit

Permalink
remove unnecessary interfaces + update related docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammed-Mamoun98 committed Nov 13, 2024
1 parent 763342c commit 8fabab3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
5 changes: 1 addition & 4 deletions packages/issuer-sdk-js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,6 @@ const credential = {
// `createCredentialByGrant` will encrypt this for us, using the Issuer's secret encryption key, along with the user's public encryption key.
content: "VERIFIABLE_CREDENTIAL_CONTENT",

// The public encryption key of the issuer.
encryption_public_key: issuerConfig.issuerPublicEncryptionKey,

// The public encryption key of the user who is creating the credential.
userEncryptionPublicKey: session.user.userEncryptionPublicKey,
}
Expand Down Expand Up @@ -220,7 +217,7 @@ const credential = {
issuer: "ISSUER_NAME",
content: "VERIFIABLE_CREDENTIAL_CONTENT",
human_id: session.user.humanId,
encryption_public_key: issuerConfig.issuerPublicEncryptionKey,
userEncryptionPublicKey: session.user.userEncryptionPublicKey,
}

await createCredentialPermissioned(issuerConfig, credential);
Expand Down
18 changes: 11 additions & 7 deletions packages/issuer-sdk-js/src/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ import type { idOSCredential } from "../../types";
import type { IssuerConfig } from "./create-issuer-config";
import { createActionInput, encryptContent, ensureEntityId } from "./internal";

// Base interface for credential parameters
/**
* Interface for BaseCredentialParams.
*
* `id` could be provided manually, but it is randomly generated internally.
* `encryption_public_key` is **excluded** because it is derived internally
* from the issuer's secret key and should not be provided manually.
*
*/
interface BaseCredentialParams
extends Omit<idOSCredential, "id" | "original_id" | "encryption_public_key"> {
id?: string;
}

interface HasEncryptionPublicKey {
userEncryptionPublicKey: string;
}

interface CreateCredentialPermissionedParams extends BaseCredentialParams, HasEncryptionPublicKey {}
interface CreateCredentialPermissionedParams extends BaseCredentialParams {}

export async function createCredentialPermissioned(
{ dbid, kwilClient, keyPair, signer }: IssuerConfig,
Expand Down Expand Up @@ -47,7 +51,7 @@ export async function createCredentialPermissioned(
};
}

interface CreateCredentialByGrantParams extends BaseCredentialParams, HasEncryptionPublicKey {}
interface CreateCredentialByGrantParams extends BaseCredentialParams {}

export async function createCredentialByGrant(
{ dbid, kwilClient, keyPair, signer }: IssuerConfig,
Expand Down Expand Up @@ -80,7 +84,7 @@ export async function createCredentialByGrant(
};
}

interface ShareCredentialByGrantParams extends BaseCredentialParams, HasEncryptionPublicKey {
interface ShareCredentialByGrantParams extends BaseCredentialParams {
grantee: string;
locked_until: number;
original_credential_id: string;
Expand Down

0 comments on commit 8fabab3

Please sign in to comment.