@idos-network/issuer 4.0.0 → 5.0.0

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.mts CHANGED
@@ -8,7 +8,7 @@ import "@idos-network/utils/blob-gateway";
8
8
  type DelegatedWriteGrantParams = DelegatedWriteGrantBaseParams & {
9
9
  signature: string;
10
10
  };
11
- type CredentialByDelegatedWriteGrantBaseParams = Omit<BuildPreliminaryIDOSCredentialArgs, "issuerSigningSecretKey" | "broaderMessageFor">;
11
+ type CredentialByDelegatedWriteGrantBaseParams = Omit<BuildPreliminaryIDOSCredentialArgs, "issuerSigningSecretKey" | "broaderMessageFor" | "ukycStorageId">;
12
12
  //#endregion
13
13
  //#region src/services/user.service.d.ts
14
14
  type CreateProfileReqParams = Omit<idOSUser$1, "id"> & {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/services/credential.service.ts","../src/services/user.service.ts","../src/index.ts"],"mappings":";;;;;;;KA4BY,4BAA4B;EACtC;;KAGU,4CAA4C,KACtD;;;KCnBU,yBAAyB,KAAK;EACxC;;KAGU,wBAAwB,KAAK;EACvC;;KAGU,wBAAwB,KAAK;EACvC;;;;KCYG;EACH;EACA;EACA;EACA,gBAAgB;;qBAGL;;SAIE,KAAK,QAAQ,qBAAqB,QAAQ;UAqB/C;EAMR,WAAiB,sBAAsB;EAIvC,kBAAwB,QAAQ,yBAAyB,QAAQ;EAIjE,uBAA6B,QAAQ,wBAAwB,QAAQ;EAIrE,iBAAuB,QAAQ,wBAAwB;EAIvD,WACE,MAAM,wBACN,QAAQ,wBACP,SAAS,UAAU;EAItB,QAAc,aAAa,QAAQ;EAInC,kCAAwC,QAAQ,0BAA0B;EAI1E,sCACE,kBAAkB,2CAClB,qBAAqB,2BACrB,6BAA6B,aAC5B;IACD,oBAAoB,KAAK;IACzB,gBAAgB,KAAK;;EASvB,uBACE,uBACA,sBACC,QAAQ;EAIX,6BAAmC,sBAAsB;EAIzD,oBAA0B,aAAa,QAAQ"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/services/credential.service.ts","../src/services/user.service.ts","../src/index.ts"],"mappings":";;;;;;;KA4BY,4BAA4B;EACtC;;KAIU,4CAA4C,KACtD;;;KCpBU,yBAAyB,KAAK;EACxC;;KAGU,wBAAwB,KAAK;EACvC;;KAGU,wBAAwB,KAAK;EACvC;;;;KCYG;EACH;EACA;EACA;EACA,gBAAgB;;qBAGL;;SAIE,KAAK,QAAQ,qBAAqB,QAAQ;UAqB/C;EAMR,WAAiB,sBAAsB;EAIvC,kBAAwB,QAAQ,yBAAyB,QAAQ;EAIjE,uBAA6B,QAAQ,wBAAwB,QAAQ;EAIrE,iBAAuB,QAAQ,wBAAwB;EAIvD,WACE,MAAM,wBACN,QAAQ,wBACP,SAAS,UAAU;EAItB,QAAc,aAAa,QAAQ;EAInC,kCAAwC,QAAQ,0BAA0B;EAI1E,sCACE,kBAAkB,2CAClB,qBAAqB,2BACrB,6BAA6B,aAC5B;IACD,oBAAoB,KAAK;IACzB,gBAAgB,KAAK;;EASvB,uBACE,uBACA,sBACC,QAAQ;EAIX,6BAAmC,sBAAsB;EAIzD,oBAA0B,aAAa,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["_hasProfile","_upsertWalletAsInserter","_addWalletMessage"],"sources":["../../../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","../src/services/credential.service.ts","../src/services/user.service.ts","../src/index.ts"],"sourcesContent":["var isProduction = process.env.NODE_ENV === 'production';\nvar prefix = 'Invariant failed';\nfunction invariant(condition, message) {\n if (condition) {\n return;\n }\n if (isProduction) {\n throw new Error(prefix);\n }\n var provided = typeof message === 'function' ? message() : message;\n var value = provided ? \"\".concat(prefix, \": \").concat(provided) : prefix;\n throw new Error(value);\n}\n\nexport { invariant as default };\n","import type { idOSCredential, idOSCredentialRecord } from \"@idos-network/credentials/types\";\nimport type { KwilActionClient } from \"@idos-network/kwil-infra\";\n\nimport {\n buildPreliminaryIDOSCredential,\n BuildPreliminaryIDOSCredentialArgs,\n mapPreliminaryToIDOSCredential,\n PreliminaryIDOSCredential,\n} from \"@idos-network/credentials/utils\";\nimport {\n type CreatePreliminaryCredentialsByDwgInput,\n createPreliminaryCredentialsByDwg,\n credentialBroaderMessage,\n dwgMessage,\n type EditPublicNotesAsIssuerInput,\n editPublicNotesAsIssuer,\n getCredentialShared,\n getSiblingCredentialId,\n type idOSDelegatedWriteGrant,\n type DelegatedWriteGrantBaseParams,\n} from \"@idos-network/kwil-infra/actions\";\nimport { BlobGateway } from \"@idos-network/utils/blob-gateway\";\nimport { hexEncodeSha256Hash } from \"@idos-network/utils/codecs\";\nimport invariant from \"tiny-invariant\";\nimport nacl from \"tweetnacl\";\n\nexport type { DelegatedWriteGrantBaseParams };\n\nexport type DelegatedWriteGrantParams = DelegatedWriteGrantBaseParams & {\n signature: string;\n};\n\nexport type CredentialByDelegatedWriteGrantBaseParams = Omit<\n BuildPreliminaryIDOSCredentialArgs,\n \"issuerSigningSecretKey\" | \"broaderMessageFor\"\n>;\n\nexport class CredentialService {\n readonly #kwilClient: KwilActionClient;\n readonly #signingKeyPair: nacl.SignKeyPair;\n readonly #blobGateway: BlobGateway;\n\n constructor(\n kwilClient: KwilActionClient,\n signingKeyPair: nacl.SignKeyPair,\n blobGateway: BlobGateway,\n ) {\n this.#kwilClient = kwilClient;\n this.#signingKeyPair = signingKeyPair;\n this.#blobGateway = blobGateway;\n }\n\n async requestDelegatedWriteGrantMessage(params: idOSDelegatedWriteGrant): Promise<string> {\n return dwgMessage(this.#kwilClient, params).then((res) => {\n if (!res) throw new Error(\"dwg_message returned no rows\");\n return res.message;\n });\n }\n\n async createCredentialByDelegatedWriteGrant(\n credentialParams: CredentialByDelegatedWriteGrantBaseParams,\n delegatedWriteGrant: DelegatedWriteGrantParams,\n consumerEncryptionPublicKey: Uint8Array,\n ): Promise<{\n originalCredential: Omit<idOSCredential, \"user_id\">;\n copyCredential: Omit<idOSCredential, \"user_id\">;\n }> {\n const broaderMessageFor = (publicNotesSignature: string, contentUri: string) =>\n credentialBroaderMessage(this.#kwilClient, {\n public_notes_signature: publicNotesSignature,\n content_uri: contentUri,\n recipient_wallet: delegatedWriteGrant.ownerWalletIdentifier,\n }).then((row) => row.message);\n const originalCredential: PreliminaryIDOSCredential = {\n ...(await buildPreliminaryIDOSCredential({\n ...credentialParams,\n broaderMessageFor,\n issuerSigningSecretKey: this.#signingKeyPair.secretKey,\n })),\n id: crypto.randomUUID(),\n };\n\n const contentHash = hexEncodeSha256Hash(credentialParams.plaintextContent);\n\n const copyCredential: PreliminaryIDOSCredential = {\n ...(await buildPreliminaryIDOSCredential({\n ...credentialParams,\n publicNotes: \"\",\n recipientEncryptionPublicKey: consumerEncryptionPublicKey,\n broaderMessageFor,\n issuerSigningSecretKey: this.#signingKeyPair.secretKey,\n })),\n id: crypto.randomUUID(),\n };\n\n invariant(\n originalCredential.contentUri !== copyCredential.contentUri,\n \"Original and copy credentials must use distinct content URIs\",\n );\n\n const requestId = crypto.randomUUID();\n const payload: CreatePreliminaryCredentialsByDwgInput = {\n request_id: requestId,\n issuer_auth_public_key: originalCredential.issuerAuthPublicKey,\n original_encryptor_public_key: originalCredential.encryptorPublicKey,\n original_id: originalCredential.id,\n original_content_uri: originalCredential.contentUri,\n original_content_size: originalCredential.contentSize,\n original_public_notes: originalCredential.publicNotes,\n original_public_notes_signature: originalCredential.publicNotesSignature,\n original_broader_signature: originalCredential.broaderSignature,\n copy_encryptor_public_key: copyCredential.encryptorPublicKey,\n copy_id: copyCredential.id,\n copy_content_uri: copyCredential.contentUri,\n copy_content_size: copyCredential.contentSize,\n copy_public_notes_signature: copyCredential.publicNotesSignature,\n copy_broader_signature: copyCredential.broaderSignature,\n content_hash: contentHash,\n dwg_owner: delegatedWriteGrant.ownerWalletIdentifier,\n dwg_grantee: delegatedWriteGrant.consumerWalletIdentifier,\n dwg_issuer_public_key: delegatedWriteGrant.issuerPublicKey,\n dwg_id: delegatedWriteGrant.id,\n dwg_access_grant_timelock: delegatedWriteGrant.accessGrantTimelock,\n dwg_not_before: delegatedWriteGrant.notUsableBefore,\n dwg_not_after: delegatedWriteGrant.notUsableAfter,\n dwg_signature: delegatedWriteGrant.signature,\n };\n\n await createPreliminaryCredentialsByDwg(this.#kwilClient, payload);\n\n await this.#blobGateway.uploadCredentialBlobs({\n requestId,\n credentialIds: [originalCredential.id, copyCredential.id],\n original: originalCredential.encryptedContent,\n copy: copyCredential.encryptedContent,\n });\n\n return {\n originalCredential: mapPreliminaryToIDOSCredential(originalCredential),\n copyCredential: mapPreliminaryToIDOSCredential(copyCredential),\n };\n }\n\n async editCredentialAsIssuer(\n publicNotesId: string,\n publicNotes: string,\n ): Promise<EditPublicNotesAsIssuerInput | null> {\n const payload = {\n public_notes_id: publicNotesId,\n public_notes: publicNotes,\n };\n\n await editPublicNotesAsIssuer(this.#kwilClient, payload);\n\n return payload;\n }\n\n async getCredentialIdByContentHash(contentHash: string): Promise<string | null> {\n const id = await getSiblingCredentialId(this.#kwilClient, { content_hash: contentHash }).then(\n (res) => res?.id,\n );\n\n invariant(id, \"Required `idOSCredential` id not found\");\n\n return id;\n }\n\n async getCredentialShared(id: string): Promise<idOSCredentialRecord | null> {\n const result = await getCredentialShared(this.#kwilClient, { id }).then((res) => res[0]);\n\n return result ?? null;\n }\n}\n","import type { KwilActionClient } from \"@idos-network/kwil-infra\";\n\nimport {\n hasProfile as _hasProfile,\n upsertWalletAsInserter as _upsertWalletAsInserter,\n addUserAsInserter,\n addWalletMessage as _addWalletMessage,\n type AddWalletMessageInput,\n type GetUserAsInserterInput,\n getUserAsInserter,\n type idOSUser,\n type idOSWallet,\n} from \"@idos-network/kwil-infra/actions\";\n\nexport type CreateProfileReqParams = Omit<idOSUser, \"id\"> & {\n id?: string;\n};\n\nexport type UpsertWalletReqParams = Omit<idOSWallet, \"id\"> & {\n id?: string;\n};\n\nexport type CreateWalletReqParams = Omit<UpsertWalletReqParams, \"user_id\"> & {\n id?: string;\n};\n\nexport class UserService {\n readonly #kwilClient: KwilActionClient;\n\n constructor(kwilClient: KwilActionClient) {\n this.#kwilClient = kwilClient;\n }\n\n #ensureEntityId<T extends { id?: string }>(entity: T): T & { id: string } {\n if (!entity.id) {\n (entity as T & { id: string }).id = crypto.randomUUID();\n }\n return entity as T & { id: string };\n }\n\n async hasProfile(address: string): Promise<boolean> {\n return _hasProfile(this.#kwilClient, { address }).then((res) => {\n if (!res) throw new Error(\"has_profile returned no rows\");\n return res.has_profile;\n });\n }\n\n async createUserProfile(params: CreateProfileReqParams): Promise<idOSUser> {\n const payload = this.#ensureEntityId(params);\n await addUserAsInserter(this.#kwilClient, payload);\n return payload;\n }\n\n async upsertWalletAsInserter(params: UpsertWalletReqParams): Promise<idOSWallet> {\n const payload = this.#ensureEntityId(params);\n await _upsertWalletAsInserter(this.#kwilClient, payload);\n return payload;\n }\n\n async addWalletMessage(params: AddWalletMessageInput): Promise<string> {\n const result = await _addWalletMessage(this.#kwilClient, params);\n return result.message;\n }\n\n /// Useful to understand if a user id already exists.\n async getUser(params: GetUserAsInserterInput): Promise<idOSUser> {\n const user = await getUserAsInserter(this.#kwilClient, this.#ensureEntityId(params));\n if (!user) throw new Error(\"get_user_as_inserter returned no rows\");\n return user;\n }\n\n async createUser(\n user: CreateProfileReqParams,\n wallet: CreateWalletReqParams,\n ): Promise<[idOSUser, idOSWallet]> {\n const user_id = user.id ?? crypto.randomUUID();\n const wallet_id = wallet.id ?? crypto.randomUUID();\n\n const userReqParams = {\n ...user,\n id: user_id,\n };\n\n const userResponse = await this.createUserProfile(userReqParams);\n\n const walletReqParams = {\n ...wallet,\n user_id,\n id: wallet_id,\n };\n\n const walletResponse = await this.upsertWalletAsInserter(walletReqParams);\n\n return [userResponse, walletResponse];\n }\n}\n","import type {\n AvailableIssuerType,\n idOSCredential,\n idOSCredentialRecord,\n} from \"@idos-network/credentials/types\";\nimport type {\n AddWalletMessageInput,\n EditPublicNotesAsIssuerInput,\n idOSDelegatedWriteGrant,\n idOSGrant,\n idOSUser,\n idOSUserAttribute,\n idOSWallet,\n} from \"@idos-network/kwil-infra/actions\";\nimport type { SignKeyPair } from \"tweetnacl\";\n\nimport {\n createKgwAuthenticatedBlobGateway,\n createNodeKwilClient,\n createServerKwilSigner,\n} from \"@idos-network/kwil-infra\";\n\nimport {\n CredentialService,\n type CredentialByDelegatedWriteGrantBaseParams,\n type DelegatedWriteGrantBaseParams,\n type DelegatedWriteGrantParams,\n} from \"./services/credential.service\";\nimport {\n type CreateProfileReqParams,\n type CreateWalletReqParams,\n type UpsertWalletReqParams,\n UserService,\n} from \"./services/user.service\";\n\ntype CreateIssuerParams = {\n chainId?: string;\n nodeUrl: string;\n blobGatewayUrl?: string;\n signingKeyPair: SignKeyPair;\n};\n\nexport class idOSIssuer {\n readonly #credentialService: CredentialService;\n readonly #userService: UserService;\n\n static async init(params: CreateIssuerParams): Promise<idOSIssuer> {\n const kwilClient = await createNodeKwilClient({\n nodeUrl: params.nodeUrl,\n chainId: params.chainId,\n });\n\n const [signer] = await createServerKwilSigner(params.signingKeyPair);\n kwilClient.setSigner(signer);\n\n const blobGateway = createKgwAuthenticatedBlobGateway({\n url: params.blobGatewayUrl ?? params.nodeUrl,\n kwilClient,\n signer,\n });\n\n const credentialService = new CredentialService(kwilClient, params.signingKeyPair, blobGateway);\n const userService = new UserService(kwilClient);\n\n return new idOSIssuer(credentialService, userService);\n }\n\n private constructor(credentialService: CredentialService, userService: UserService) {\n this.#credentialService = credentialService;\n this.#userService = userService;\n }\n\n // User Service facade methods\n async hasProfile(userAddress: string): Promise<boolean> {\n return this.#userService.hasProfile(userAddress);\n }\n\n async createUserProfile(params: CreateProfileReqParams): Promise<idOSUser> {\n return this.#userService.createUserProfile(params);\n }\n\n async upsertWalletAsInserter(params: UpsertWalletReqParams): Promise<idOSWallet> {\n return this.#userService.upsertWalletAsInserter(params);\n }\n\n async addWalletMessage(params: AddWalletMessageInput): Promise<string> {\n return this.#userService.addWalletMessage(params);\n }\n\n async createUser(\n user: CreateProfileReqParams,\n wallet: CreateWalletReqParams,\n ): Promise<[idOSUser, idOSWallet]> {\n return this.#userService.createUser(user, wallet);\n }\n\n async getUser(id: string): Promise<idOSUser> {\n return this.#userService.getUser({ id });\n }\n\n async requestDelegatedWriteGrantMessage(params: idOSDelegatedWriteGrant): Promise<string> {\n return this.#credentialService.requestDelegatedWriteGrantMessage(params);\n }\n\n async createCredentialByDelegatedWriteGrant(\n credentialParams: CredentialByDelegatedWriteGrantBaseParams,\n delegatedWriteGrant: DelegatedWriteGrantParams,\n consumerEncryptionPublicKey: Uint8Array,\n ): Promise<{\n originalCredential: Omit<idOSCredential, \"user_id\">;\n copyCredential: Omit<idOSCredential, \"user_id\">;\n }> {\n return this.#credentialService.createCredentialByDelegatedWriteGrant(\n credentialParams,\n delegatedWriteGrant,\n consumerEncryptionPublicKey,\n );\n }\n\n async editCredentialAsIssuer(\n publicNotesId: string,\n publicNotes: string,\n ): Promise<EditPublicNotesAsIssuerInput | null> {\n return this.#credentialService.editCredentialAsIssuer(publicNotesId, publicNotes);\n }\n\n async getCredentialIdByContentHash(contentHash: string): Promise<string | null> {\n return this.#credentialService.getCredentialIdByContentHash(contentHash);\n }\n\n async getCredentialShared(id: string): Promise<idOSCredentialRecord | null> {\n return this.#credentialService.getCredentialShared(id);\n }\n}\n\nexport type {\n idOSCredential,\n idOSGrant,\n idOSUser,\n idOSUserAttribute,\n idOSDelegatedWriteGrant,\n idOSWallet,\n AvailableIssuerType,\n CredentialByDelegatedWriteGrantBaseParams,\n DelegatedWriteGrantBaseParams,\n DelegatedWriteGrantParams,\n};\n\nexport { toDelegatedWriteGrantBaseParams } from \"@idos-network/kwil-infra/actions\";\n"],"x_google_ignoreList":[0],"mappings":"mqBAAA,IAAI,EAAe,QAAQ,IAAI,WAAa,aACxC,EAAS,mBACb,SAAS,EAAU,EAAW,EAAS,CAC/B,MA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eAAgB,CAAW,EACxF,EAAc,IAAI,EAAY,CAAU,EAE9C,OAAO,IAAI,EAAW,EAAmB,CAAW,CACtD,CAEA,YAAoB,EAAsC,EAA0B,CAClF,KAAK,GAAqB,EAC1B,KAAK,GAAe,CACtB,CAGA,MAAM,WAAW,EAAuC,CACtD,OAAO,KAAK,GAAa,WAAW,CAAW,CACjD,CAEA,MAAM,kBAAkB,EAAmD,CACzE,OAAO,KAAK,GAAa,kBAAkB,CAAM,CACnD,CAEA,MAAM,uBAAuB,EAAoD,CAC/E,OAAO,KAAK,GAAa,uBAAuB,CAAM,CACxD,CAEA,MAAM,iBAAiB,EAAgD,CACrE,OAAO,KAAK,GAAa,iBAAiB,CAAM,CAClD,CAEA,MAAM,WACJ,EACA,EACiC,CACjC,OAAO,KAAK,GAAa,WAAW,EAAM,CAAM,CAClD,CAEA,MAAM,QAAQ,EAA+B,CAC3C,OAAO,KAAK,GAAa,QAAQ,CAAE,IAAG,CAAC,CACzC,CAEA,MAAM,kCAAkC,EAAkD,CACxF,OAAO,KAAK,GAAmB,kCAAkC,CAAM,CACzE,CAEA,MAAM,sCACJ,EACA,EACA,EAIC,CACD,OAAO,KAAK,GAAmB,sCAC7B,EACA,EACA,CACF,CACF,CAEA,MAAM,uBACJ,EACA,EAC8C,CAC9C,OAAO,KAAK,GAAmB,uBAAuB,EAAe,CAAW,CAClF,CAEA,MAAM,6BAA6B,EAA6C,CAC9E,OAAO,KAAK,GAAmB,6BAA6B,CAAW,CACzE,CAEA,MAAM,oBAAoB,EAAkD,CAC1E,OAAO,KAAK,GAAmB,oBAAoB,CAAE,CACvD,CACF"}
1
+ {"version":3,"file":"index.mjs","names":["_hasProfile","_upsertWalletAsInserter","_addWalletMessage"],"sources":["../../../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","../src/services/credential.service.ts","../src/services/user.service.ts","../src/index.ts"],"sourcesContent":["var isProduction = process.env.NODE_ENV === 'production';\nvar prefix = 'Invariant failed';\nfunction invariant(condition, message) {\n if (condition) {\n return;\n }\n if (isProduction) {\n throw new Error(prefix);\n }\n var provided = typeof message === 'function' ? message() : message;\n var value = provided ? \"\".concat(prefix, \": \").concat(provided) : prefix;\n throw new Error(value);\n}\n\nexport { invariant as default };\n","import type { idOSCredential, idOSCredentialRecord } from \"@idos-network/credentials/types\";\nimport type { KwilActionClient } from \"@idos-network/kwil-infra\";\n\nimport {\n buildPreliminaryIDOSCredential,\n BuildPreliminaryIDOSCredentialArgs,\n mapPreliminaryToIDOSCredential,\n PreliminaryIDOSCredential,\n} from \"@idos-network/credentials/utils\";\nimport {\n type CreatePreliminaryCredentialsByDwgInput,\n createPreliminaryCredentialsByDwg,\n credentialBroaderMessage,\n dwgMessage,\n type EditPublicNotesAsIssuerInput,\n editPublicNotesAsIssuer,\n getCredentialShared,\n getSiblingCredentialId,\n type idOSDelegatedWriteGrant,\n type DelegatedWriteGrantBaseParams,\n} from \"@idos-network/kwil-infra/actions\";\nimport { BlobGateway } from \"@idos-network/utils/blob-gateway\";\nimport { hexEncodeSha256Hash } from \"@idos-network/utils/codecs\";\nimport invariant from \"tiny-invariant\";\nimport nacl from \"tweetnacl\";\n\nexport type { DelegatedWriteGrantBaseParams };\n\nexport type DelegatedWriteGrantParams = DelegatedWriteGrantBaseParams & {\n signature: string;\n};\n\n// MM users' ukyc:// credentials are created by their MM operator only (@idos-network/mm-operator).\nexport type CredentialByDelegatedWriteGrantBaseParams = Omit<\n BuildPreliminaryIDOSCredentialArgs,\n \"issuerSigningSecretKey\" | \"broaderMessageFor\" | \"ukycStorageId\"\n>;\n\nexport class CredentialService {\n readonly #kwilClient: KwilActionClient;\n readonly #signingKeyPair: nacl.SignKeyPair;\n readonly #blobGateway: BlobGateway;\n\n constructor(\n kwilClient: KwilActionClient,\n signingKeyPair: nacl.SignKeyPair,\n blobGateway: BlobGateway,\n ) {\n this.#kwilClient = kwilClient;\n this.#signingKeyPair = signingKeyPair;\n this.#blobGateway = blobGateway;\n }\n\n async requestDelegatedWriteGrantMessage(params: idOSDelegatedWriteGrant): Promise<string> {\n return dwgMessage(this.#kwilClient, params).then((res) => {\n if (!res) throw new Error(\"dwg_message returned no rows\");\n return res.message;\n });\n }\n\n async createCredentialByDelegatedWriteGrant(\n credentialParams: CredentialByDelegatedWriteGrantBaseParams,\n delegatedWriteGrant: DelegatedWriteGrantParams,\n consumerEncryptionPublicKey: Uint8Array,\n ): Promise<{\n originalCredential: Omit<idOSCredential, \"user_id\">;\n copyCredential: Omit<idOSCredential, \"user_id\">;\n }> {\n const broaderMessageFor = (publicNotesSignature: string, contentUri: string) =>\n credentialBroaderMessage(this.#kwilClient, {\n public_notes_signature: publicNotesSignature,\n content_uri: contentUri,\n recipient_wallet: delegatedWriteGrant.ownerWalletIdentifier,\n }).then((row) => row.message);\n const originalCredential: PreliminaryIDOSCredential = {\n ...(await buildPreliminaryIDOSCredential({\n ...credentialParams,\n broaderMessageFor,\n issuerSigningSecretKey: this.#signingKeyPair.secretKey,\n })),\n id: crypto.randomUUID(),\n };\n\n const contentHash = hexEncodeSha256Hash(credentialParams.plaintextContent);\n\n const copyCredential: PreliminaryIDOSCredential = {\n ...(await buildPreliminaryIDOSCredential({\n ...credentialParams,\n publicNotes: \"\",\n recipientEncryptionPublicKey: consumerEncryptionPublicKey,\n broaderMessageFor,\n issuerSigningSecretKey: this.#signingKeyPair.secretKey,\n })),\n id: crypto.randomUUID(),\n };\n\n invariant(\n originalCredential.contentUri !== copyCredential.contentUri,\n \"Original and copy credentials must use distinct content URIs\",\n );\n\n const requestId = crypto.randomUUID();\n const payload: CreatePreliminaryCredentialsByDwgInput = {\n request_id: requestId,\n issuer_auth_public_key: originalCredential.issuerAuthPublicKey,\n original_encryptor_public_key: originalCredential.encryptorPublicKey,\n original_id: originalCredential.id,\n original_content_uri: originalCredential.contentUri,\n original_content_size: originalCredential.contentSize,\n original_public_notes: originalCredential.publicNotes,\n original_public_notes_signature: originalCredential.publicNotesSignature,\n original_broader_signature: originalCredential.broaderSignature,\n copy_encryptor_public_key: copyCredential.encryptorPublicKey,\n copy_id: copyCredential.id,\n copy_content_uri: copyCredential.contentUri,\n copy_content_size: copyCredential.contentSize,\n copy_public_notes_signature: copyCredential.publicNotesSignature,\n copy_broader_signature: copyCredential.broaderSignature,\n content_hash: contentHash,\n dwg_owner: delegatedWriteGrant.ownerWalletIdentifier,\n dwg_grantee: delegatedWriteGrant.consumerWalletIdentifier,\n dwg_issuer_public_key: delegatedWriteGrant.issuerPublicKey,\n dwg_id: delegatedWriteGrant.id,\n dwg_access_grant_timelock: delegatedWriteGrant.accessGrantTimelock,\n dwg_not_before: delegatedWriteGrant.notUsableBefore,\n dwg_not_after: delegatedWriteGrant.notUsableAfter,\n dwg_signature: delegatedWriteGrant.signature,\n };\n\n await createPreliminaryCredentialsByDwg(this.#kwilClient, payload);\n\n await this.#blobGateway.uploadCredentialBlobs({\n requestId,\n credentialIds: [originalCredential.id, copyCredential.id],\n original: originalCredential.encryptedContent,\n copy: copyCredential.encryptedContent,\n });\n\n return {\n originalCredential: mapPreliminaryToIDOSCredential(originalCredential),\n copyCredential: mapPreliminaryToIDOSCredential(copyCredential),\n };\n }\n\n async editCredentialAsIssuer(\n publicNotesId: string,\n publicNotes: string,\n ): Promise<EditPublicNotesAsIssuerInput | null> {\n const payload = {\n public_notes_id: publicNotesId,\n public_notes: publicNotes,\n };\n\n await editPublicNotesAsIssuer(this.#kwilClient, payload);\n\n return payload;\n }\n\n async getCredentialIdByContentHash(contentHash: string): Promise<string | null> {\n const id = await getSiblingCredentialId(this.#kwilClient, { content_hash: contentHash }).then(\n (res) => res?.id,\n );\n\n invariant(id, \"Required `idOSCredential` id not found\");\n\n return id;\n }\n\n async getCredentialShared(id: string): Promise<idOSCredentialRecord | null> {\n const result = await getCredentialShared(this.#kwilClient, { id }).then((res) => res[0]);\n\n return result ?? null;\n }\n}\n","import type { KwilActionClient } from \"@idos-network/kwil-infra\";\n\nimport {\n hasProfile as _hasProfile,\n upsertWalletAsInserter as _upsertWalletAsInserter,\n addUserAsInserter,\n addWalletMessage as _addWalletMessage,\n type AddWalletMessageInput,\n type GetUserAsInserterInput,\n getUserAsInserter,\n type idOSUser,\n type idOSWallet,\n} from \"@idos-network/kwil-infra/actions\";\n\nexport type CreateProfileReqParams = Omit<idOSUser, \"id\"> & {\n id?: string;\n};\n\nexport type UpsertWalletReqParams = Omit<idOSWallet, \"id\"> & {\n id?: string;\n};\n\nexport type CreateWalletReqParams = Omit<UpsertWalletReqParams, \"user_id\"> & {\n id?: string;\n};\n\nexport class UserService {\n readonly #kwilClient: KwilActionClient;\n\n constructor(kwilClient: KwilActionClient) {\n this.#kwilClient = kwilClient;\n }\n\n #ensureEntityId<T extends { id?: string }>(entity: T): T & { id: string } {\n if (!entity.id) {\n (entity as T & { id: string }).id = crypto.randomUUID();\n }\n return entity as T & { id: string };\n }\n\n async hasProfile(address: string): Promise<boolean> {\n return _hasProfile(this.#kwilClient, { address }).then((res) => {\n if (!res) throw new Error(\"has_profile returned no rows\");\n return res.has_profile;\n });\n }\n\n async createUserProfile(params: CreateProfileReqParams): Promise<idOSUser> {\n const payload = this.#ensureEntityId(params);\n await addUserAsInserter(this.#kwilClient, payload);\n return payload;\n }\n\n async upsertWalletAsInserter(params: UpsertWalletReqParams): Promise<idOSWallet> {\n const payload = this.#ensureEntityId(params);\n await _upsertWalletAsInserter(this.#kwilClient, payload);\n return payload;\n }\n\n async addWalletMessage(params: AddWalletMessageInput): Promise<string> {\n const result = await _addWalletMessage(this.#kwilClient, params);\n return result.message;\n }\n\n /// Useful to understand if a user id already exists.\n async getUser(params: GetUserAsInserterInput): Promise<idOSUser> {\n const user = await getUserAsInserter(this.#kwilClient, this.#ensureEntityId(params));\n if (!user) throw new Error(\"get_user_as_inserter returned no rows\");\n return user;\n }\n\n async createUser(\n user: CreateProfileReqParams,\n wallet: CreateWalletReqParams,\n ): Promise<[idOSUser, idOSWallet]> {\n const user_id = user.id ?? crypto.randomUUID();\n const wallet_id = wallet.id ?? crypto.randomUUID();\n\n const userReqParams = {\n ...user,\n id: user_id,\n };\n\n const userResponse = await this.createUserProfile(userReqParams);\n\n const walletReqParams = {\n ...wallet,\n user_id,\n id: wallet_id,\n };\n\n const walletResponse = await this.upsertWalletAsInserter(walletReqParams);\n\n return [userResponse, walletResponse];\n }\n}\n","import type {\n AvailableIssuerType,\n idOSCredential,\n idOSCredentialRecord,\n} from \"@idos-network/credentials/types\";\nimport type {\n AddWalletMessageInput,\n EditPublicNotesAsIssuerInput,\n idOSDelegatedWriteGrant,\n idOSGrant,\n idOSUser,\n idOSUserAttribute,\n idOSWallet,\n} from \"@idos-network/kwil-infra/actions\";\nimport type { SignKeyPair } from \"tweetnacl\";\n\nimport {\n createKgwAuthenticatedBlobGateway,\n createNodeKwilClient,\n createServerKwilSigner,\n} from \"@idos-network/kwil-infra\";\n\nimport {\n CredentialService,\n type CredentialByDelegatedWriteGrantBaseParams,\n type DelegatedWriteGrantBaseParams,\n type DelegatedWriteGrantParams,\n} from \"./services/credential.service\";\nimport {\n type CreateProfileReqParams,\n type CreateWalletReqParams,\n type UpsertWalletReqParams,\n UserService,\n} from \"./services/user.service\";\n\ntype CreateIssuerParams = {\n chainId?: string;\n nodeUrl: string;\n blobGatewayUrl?: string;\n signingKeyPair: SignKeyPair;\n};\n\nexport class idOSIssuer {\n readonly #credentialService: CredentialService;\n readonly #userService: UserService;\n\n static async init(params: CreateIssuerParams): Promise<idOSIssuer> {\n const kwilClient = await createNodeKwilClient({\n nodeUrl: params.nodeUrl,\n chainId: params.chainId,\n });\n\n const [signer] = await createServerKwilSigner(params.signingKeyPair);\n kwilClient.setSigner(signer);\n\n const blobGateway = createKgwAuthenticatedBlobGateway({\n url: params.blobGatewayUrl ?? params.nodeUrl,\n kwilClient,\n signer,\n });\n\n const credentialService = new CredentialService(kwilClient, params.signingKeyPair, blobGateway);\n const userService = new UserService(kwilClient);\n\n return new idOSIssuer(credentialService, userService);\n }\n\n private constructor(credentialService: CredentialService, userService: UserService) {\n this.#credentialService = credentialService;\n this.#userService = userService;\n }\n\n // User Service facade methods\n async hasProfile(userAddress: string): Promise<boolean> {\n return this.#userService.hasProfile(userAddress);\n }\n\n async createUserProfile(params: CreateProfileReqParams): Promise<idOSUser> {\n return this.#userService.createUserProfile(params);\n }\n\n async upsertWalletAsInserter(params: UpsertWalletReqParams): Promise<idOSWallet> {\n return this.#userService.upsertWalletAsInserter(params);\n }\n\n async addWalletMessage(params: AddWalletMessageInput): Promise<string> {\n return this.#userService.addWalletMessage(params);\n }\n\n async createUser(\n user: CreateProfileReqParams,\n wallet: CreateWalletReqParams,\n ): Promise<[idOSUser, idOSWallet]> {\n return this.#userService.createUser(user, wallet);\n }\n\n async getUser(id: string): Promise<idOSUser> {\n return this.#userService.getUser({ id });\n }\n\n async requestDelegatedWriteGrantMessage(params: idOSDelegatedWriteGrant): Promise<string> {\n return this.#credentialService.requestDelegatedWriteGrantMessage(params);\n }\n\n async createCredentialByDelegatedWriteGrant(\n credentialParams: CredentialByDelegatedWriteGrantBaseParams,\n delegatedWriteGrant: DelegatedWriteGrantParams,\n consumerEncryptionPublicKey: Uint8Array,\n ): Promise<{\n originalCredential: Omit<idOSCredential, \"user_id\">;\n copyCredential: Omit<idOSCredential, \"user_id\">;\n }> {\n return this.#credentialService.createCredentialByDelegatedWriteGrant(\n credentialParams,\n delegatedWriteGrant,\n consumerEncryptionPublicKey,\n );\n }\n\n async editCredentialAsIssuer(\n publicNotesId: string,\n publicNotes: string,\n ): Promise<EditPublicNotesAsIssuerInput | null> {\n return this.#credentialService.editCredentialAsIssuer(publicNotesId, publicNotes);\n }\n\n async getCredentialIdByContentHash(contentHash: string): Promise<string | null> {\n return this.#credentialService.getCredentialIdByContentHash(contentHash);\n }\n\n async getCredentialShared(id: string): Promise<idOSCredentialRecord | null> {\n return this.#credentialService.getCredentialShared(id);\n }\n}\n\nexport type {\n idOSCredential,\n idOSGrant,\n idOSUser,\n idOSUserAttribute,\n idOSDelegatedWriteGrant,\n idOSWallet,\n AvailableIssuerType,\n CredentialByDelegatedWriteGrantBaseParams,\n DelegatedWriteGrantBaseParams,\n DelegatedWriteGrantParams,\n};\n\nexport { toDelegatedWriteGrantBaseParams } from \"@idos-network/kwil-infra/actions\";\n"],"x_google_ignoreList":[0],"mappings":"mqBAAA,IAAI,EAAe,QAAQ,IAAI,WAAa,aACxC,EAAS,mBACb,SAAS,EAAU,EAAW,EAAS,CAC/B,MAGJ,IAAI,EACA,MAAU,MAAM,CAAM,EAE1B,IAAI,EAAW,OAAO,GAAY,WAAa,EAAQ,EAAI,EACvD,EAAQ,EAAW,GAAU,MAAqB,IAAY,EAClE,MAAU,MAAM,CAAK,CAJK,CAK9B,CC0BA,IAAa,EAAb,KAA+B,CAC7B,GACA,GACA,GAEA,YACE,EACA,EACA,EACA,CACA,KAAK,GAAc,EACnB,KAAK,GAAkB,EACvB,KAAK,GAAe,CACtB,CAEA,MAAM,kCAAkC,EAAkD,CACxF,OAAO,EAAW,KAAK,GAAa,CAAM,CAAC,CAAC,KAAM,GAAQ,CACxD,GAAI,CAAC,EAAK,MAAU,MAAM,8BAA8B,EACxD,OAAO,EAAI,OACb,CAAC,CACH,CAEA,MAAM,sCACJ,EACA,EACA,EAIC,CACD,IAAM,GAAqB,EAA8B,IACvD,EAAyB,KAAK,GAAa,CACzC,uBAAwB,EACxB,YAAa,EACb,iBAAkB,EAAoB,qBACxC,CAAC,CAAC,CAAC,KAAM,GAAQ,EAAI,OAAO,EACxB,EAAgD,CACpD,GAAI,MAAM,EAA+B,CACvC,GAAG,EACH,oBACA,uBAAwB,KAAK,GAAgB,SAC/C,CAAC,EACD,GAAI,OAAO,WAAW,CACxB,EAEM,EAAc,EAAoB,EAAiB,gBAAgB,EAEnE,EAA4C,CAChD,GAAI,MAAM,EAA+B,CACvC,GAAG,EACH,YAAa,GACb,6BAA8B,EAC9B,oBACA,uBAAwB,KAAK,GAAgB,SAC/C,CAAC,EACD,GAAI,OAAO,WAAW,C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AAkD,CAC1E,OAAO,KAAK,GAAmB,oBAAoB,CAAE,CACvD,CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idos-network/issuer",
3
- "version": "4.0.0",
3
+ "version": "5.0.0",
4
4
  "description": "idOS Issuer JavaScript SDK for server environments",
5
5
  "homepage": "https://idos.network",
6
6
  "license": "MIT",
@@ -28,10 +28,10 @@
28
28
  "access": "public"
29
29
  },
30
30
  "dependencies": {
31
- "@idos-network/credentials": "4.0.0",
32
- "@idos-network/kwil-infra": "4.0.0",
31
+ "@idos-network/credentials": "4.0.1",
32
+ "@idos-network/kwil-infra": "5.0.0",
33
33
  "@idos-network/kwil-js": "0.2.2",
34
- "@idos-network/utils": "3.1.0",
34
+ "@idos-network/utils": "3.2.0",
35
35
  "tweetnacl": "^1.0.3"
36
36
  },
37
37
  "devDependencies": {
package/src/index.test.ts CHANGED
@@ -110,44 +110,6 @@ describe("idOSIssuer", () => {
110
110
  );
111
111
  });
112
112
 
113
- it("addresses both delegated write grant blobs from one ukyc storage id", async () => {
114
- const issuer = await idOSIssuer.init({
115
- nodeUrl: "https://nodes.example",
116
- blobGatewayUrl: "https://blob.example",
117
- signingKeyPair: nacl.sign.keyPair(),
118
- });
119
- const credentialParams = {
120
- publicNotes: "{}",
121
- plaintextContent: new Uint8Array([1, 2, 3]),
122
- recipientEncryptionPublicKey: nacl.box.keyPair().publicKey,
123
- ukycStorageId: "storage-abc",
124
- };
125
- const delegatedWriteGrant = {
126
- id: crypto.randomUUID(),
127
- ownerWalletIdentifier: "owner",
128
- consumerWalletIdentifier: "consumer",
129
- issuerPublicKey: "issuer",
130
- accessGrantTimelock: "2026-01-01T00:00:00Z",
131
- notUsableBefore: "2026-01-01T00:00:00Z",
132
- notUsableAfter: "2026-01-02T00:00:00Z",
133
- signature: "signature",
134
- };
135
- const consumerEncryptionPublicKey = nacl.box.keyPair().publicKey;
136
-
137
- const result = await issuer.createCredentialByDelegatedWriteGrant(
138
- credentialParams,
139
- delegatedWriteGrant,
140
- consumerEncryptionPublicKey,
141
- );
142
-
143
- const payload = mocks.createPreliminaryCredentialsByDwg.mock.calls[0]?.[1];
144
- expect(payload.original_content_uri).toMatch(/^ukyc:\/\/storage-abc\/blobs\/[0-9a-f]{64}$/);
145
- expect(payload.copy_content_uri).toMatch(/^ukyc:\/\/storage-abc\/blobs\/[0-9a-f]{64}$/);
146
- expect(payload.original_content_uri).not.toBe(payload.copy_content_uri);
147
- expect(result.originalCredential.content_uri).toBe(payload.original_content_uri);
148
- expect(result.copyCredential.content_uri).toBe(payload.copy_content_uri);
149
- });
150
-
151
113
  it("maps request params for createCredentialByDelegatedWriteGrant via toDelegatedWriteGrantBaseParams", async () => {
152
114
  const issuer = await idOSIssuer.init({
153
115
  nodeUrl: "https://nodes.example",
@@ -30,9 +30,10 @@ export type DelegatedWriteGrantParams = DelegatedWriteGrantBaseParams & {
30
30
  signature: string;
31
31
  };
32
32
 
33
+ // MM users' ukyc:// credentials are created by their MM operator only (@idos-network/mm-operator).
33
34
  export type CredentialByDelegatedWriteGrantBaseParams = Omit<
34
35
  BuildPreliminaryIDOSCredentialArgs,
35
- "issuerSigningSecretKey" | "broaderMessageFor"
36
+ "issuerSigningSecretKey" | "broaderMessageFor" | "ukycStorageId"
36
37
  >;
37
38
 
38
39
  export class CredentialService {