@idos-network/issuer 1.1.0 → 1.2.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["#kwilClient","#signingKeyPair","#encryptionSecretKey","#ensureEntityId","#buildInsertableIDOSCredential","#kwilClient","#encryptionSecretKey","_createAgByDagForCopy","#kwilClient","_hasProfile","#ensureEntityId","_upsertWalletAsInserter","#credentialService","#grantService","#userService"],"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/grant.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 } from \"@idos-network/credentials/types\";\nimport type { KwilActionClient } from \"@idos-network/kwil-infra\";\n\nimport {\n type CreateCredentialsByDwgInput,\n createCredentialsByDwg,\n dwgMessage,\n type EditPublicNotesAsIssuerInput,\n editPublicNotesAsIssuer,\n getCredentialShared,\n getSiblingCredentialId,\n type idOSDelegatedWriteGrant,\n} from \"@idos-network/kwil-infra/actions\";\nimport {\n base64Decode,\n base64Encode,\n hexEncode,\n hexEncodeSha256Hash,\n utf8Encode,\n} from \"@idos-network/utils/codecs\";\nimport { encryptContent } from \"@idos-network/utils/cryptography\";\nimport invariant from \"tiny-invariant\";\nimport nacl from \"tweetnacl\";\n\ntype InsertableIDOSCredential = Omit<idOSCredential, \"id\" | \"original_id\"> & {\n id?: idOSCredential[\"id\"];\n content_hash?: string;\n public_notes_signature: string;\n broader_signature: string;\n};\n\ntype BuildInsertableIDOSCredentialArgs = {\n userId: string;\n publicNotes: string;\n plaintextContent: Uint8Array;\n recipientEncryptionPublicKey: Uint8Array;\n};\n\nexport type BaseCredentialParams = {\n id?: string;\n userId: string;\n publicNotes: string;\n plaintextContent: Uint8Array;\n recipientEncryptionPublicKey: Uint8Array;\n};\n\nexport type DelegatedWriteGrantBaseParams = Omit<BaseCredentialParams, \"userId\">;\n\nexport type DelegatedWriteGrantParams = {\n id: string;\n ownerWalletIdentifier: string;\n consumerWalletIdentifier: string;\n issuerPublicKey: string;\n accessGrantTimelock: string;\n notUsableBefore: string;\n notUsableAfter: string;\n signature: string;\n};\n\nexport class CredentialService {\n readonly #kwilClient: KwilActionClient;\n readonly #signingKeyPair: nacl.SignKeyPair;\n readonly #encryptionSecretKey: Uint8Array;\n\n constructor(\n kwilClient: KwilActionClient,\n signingKeyPair: nacl.SignKeyPair,\n encryptionSecretKey: Uint8Array,\n ) {\n this.#kwilClient = kwilClient;\n this.#signingKeyPair = signingKeyPair;\n this.#encryptionSecretKey = encryptionSecretKey;\n }\n\n #buildInsertableIDOSCredential({\n userId,\n publicNotes,\n plaintextContent,\n recipientEncryptionPublicKey,\n }: Omit<BuildInsertableIDOSCredentialArgs, \"userId\"> & { userId?: string }):\n | InsertableIDOSCredential\n | Omit<InsertableIDOSCredential, \"user_id\"> {\n const ephemeralKeyPair = nacl.box.keyPair();\n const content = encryptContent(\n plaintextContent,\n recipientEncryptionPublicKey,\n ephemeralKeyPair.secretKey,\n );\n\n const public_notes_signature = base64Encode(\n nacl.sign.detached(utf8Encode(publicNotes), this.#signingKeyPair.secretKey),\n );\n\n return {\n user_id: userId,\n content: base64Encode(content),\n public_notes: publicNotes,\n public_notes_signature,\n\n broader_signature: base64Encode(\n nacl.sign.detached(\n Uint8Array.from([...base64Decode(public_notes_signature), ...content]),\n this.#signingKeyPair.secretKey,\n ),\n ),\n\n issuer_auth_public_key: hexEncode(this.#signingKeyPair.publicKey, true),\n encryptor_public_key: base64Encode(ephemeralKeyPair.publicKey),\n };\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 requestDelegatedWriteGrantMessage(params: idOSDelegatedWriteGrant): Promise<string> {\n return dwgMessage(this.#kwilClient, params).then((res) => res.message);\n }\n\n async createCredentialByDelegatedWriteGrant(\n credentialParams: DelegatedWriteGrantBaseParams,\n delegatedWriteGrant: DelegatedWriteGrantParams,\n consumerEncryptionPublicKey?: Uint8Array,\n ): Promise<{\n originalCredential: Omit<idOSCredential, \"user_id\">;\n copyCredential: Omit<idOSCredential, \"user_id\">;\n }> {\n let recipientPublicKey = consumerEncryptionPublicKey;\n if (!recipientPublicKey) {\n // If we're not explicitly given a consumer enc pub key, we're assuming that the issuer is creating a copy\n // for themselves. So, we derive the recipient encryption public key from the issuer's encryption secret key.\n recipientPublicKey = nacl.box.keyPair.fromSecretKey(this.#encryptionSecretKey).publicKey;\n }\n\n const originalCredential = this.#ensureEntityId(\n this.#buildInsertableIDOSCredential(credentialParams),\n );\n\n const contentHash = hexEncodeSha256Hash(credentialParams.plaintextContent);\n\n const copyCredential = this.#ensureEntityId(\n this.#buildInsertableIDOSCredential({\n publicNotes: \"\",\n plaintextContent: credentialParams.plaintextContent,\n recipientEncryptionPublicKey: recipientPublicKey,\n }),\n );\n\n const payload: CreateCredentialsByDwgInput = {\n issuer_auth_public_key: originalCredential.issuer_auth_public_key,\n original_encryptor_public_key: originalCredential.encryptor_public_key,\n original_credential_id: originalCredential.id,\n original_content: originalCredential.content,\n original_public_notes: originalCredential.public_notes,\n original_public_notes_signature: originalCredential.public_notes_signature,\n original_broader_signature: originalCredential.broader_signature,\n copy_encryptor_public_key: copyCredential.encryptor_public_key,\n copy_credential_id: copyCredential.id,\n copy_content: copyCredential.content,\n copy_public_notes_signature: copyCredential.public_notes_signature,\n copy_broader_signature: copyCredential.broader_signature,\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 createCredentialsByDwg(this.#kwilClient, payload);\n\n return { originalCredential, copyCredential };\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<idOSCredential | null> {\n const result = await getCredentialShared(this.#kwilClient, { id }).then((res) => res[0]);\n\n return result ?? null;\n }\n}\n","import type { idOSCredential } from \"@idos-network/credentials/types\";\nimport type { KwilActionClient } from \"@idos-network/kwil-infra\";\n\nimport { createAgByDagForCopy as _createAgByDagForCopy } from \"@idos-network/kwil-infra/actions\";\nimport { base64Encode, hexEncodeSha256Hash, utf8Encode } from \"@idos-network/utils/codecs\";\nimport { NoncedBox } from \"@idos-network/utils/cryptography\";\nimport invariant from \"tiny-invariant\";\n\nexport type CreateAccessGrantFromDAGParams = {\n dag_data_id: string;\n dag_owner_wallet_identifier: string;\n dag_grantee_wallet_identifier: string;\n dag_signature: string;\n dag_locked_until: number;\n dag_content_hash: string;\n};\n\nexport class GrantService {\n readonly #kwilClient: KwilActionClient;\n readonly #encryptionSecretKey: Uint8Array;\n\n constructor(kwilClient: KwilActionClient, encryptionSecretKey: Uint8Array) {\n this.#kwilClient = kwilClient;\n this.#encryptionSecretKey = encryptionSecretKey;\n }\n\n async createAccessGrantFromDAG(\n params: CreateAccessGrantFromDAGParams,\n getCredentialIdByContentHash: (contentHash: string) => Promise<string | null>,\n getCredentialShared: (id: string) => Promise<idOSCredential | null>,\n ): Promise<CreateAccessGrantFromDAGParams | null> {\n const credentialId = await getCredentialIdByContentHash(params.dag_content_hash);\n\n invariant(credentialId, \"Missing `idOSCredential` id\");\n\n const credential = await getCredentialShared(credentialId);\n\n invariant(credential, \"`idOSCredential` with id `{credentialId}` not found\");\n\n const plaintextContent = await NoncedBox.nonceFromBase64SecretKey(\n base64Encode(this.#encryptionSecretKey),\n ).decrypt(credential.content, credential.encryptor_public_key);\n\n // Get the content hash from the plaintext content\n const contentHash = hexEncodeSha256Hash(utf8Encode(plaintextContent));\n\n // Check if the content hash matches the content hash in the credential\n if (contentHash !== params.dag_content_hash) {\n throw new Error(\"Hash mismatch between `DAG` and `idOSCredential` content\");\n }\n\n const result = await _createAgByDagForCopy(this.#kwilClient, params);\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 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) => res.has_profile);\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 /// Useful to understand if a user id already exists.\n async getUser(params: GetUserAsInserterInput): Promise<idOSUser> {\n return getUserAsInserter(this.#kwilClient, this.#ensureEntityId(params));\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 CredentialFields,\n CredentialSubject,\n CredentialSubjectFaceId,\n idOSCredential,\n} from \"@idos-network/credentials/types\";\nimport type {\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 buildCredential,\n buildFaceIdCredential,\n type Credential,\n type FaceIdCredential,\n} from \"@idos-network/credentials/builder\";\nimport { deriveLevel } from \"@idos-network/credentials/utils\";\nimport { createNodeKwilClient, createServerKwilSigner } from \"@idos-network/kwil-infra\";\n\nimport {\n CredentialService,\n type DelegatedWriteGrantBaseParams,\n type DelegatedWriteGrantParams,\n} from \"./services/credential.service\";\nimport { type CreateAccessGrantFromDAGParams, GrantService } from \"./services/grant.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 signingKeyPair: SignKeyPair;\n encryptionSecretKey: Uint8Array;\n};\n\nexport class idOSIssuer {\n readonly #credentialService: CredentialService;\n readonly #grantService: GrantService;\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 credentialService = new CredentialService(\n kwilClient,\n params.signingKeyPair,\n params.encryptionSecretKey,\n );\n\n const grantService = new GrantService(kwilClient, params.encryptionSecretKey);\n const userService = new UserService(kwilClient);\n\n return new idOSIssuer(credentialService, grantService, userService);\n }\n\n private constructor(\n credentialService: CredentialService,\n grantService: GrantService,\n userService: UserService,\n ) {\n this.#credentialService = credentialService;\n this.#grantService = grantService;\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 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: DelegatedWriteGrantBaseParams,\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<idOSCredential | null> {\n return this.#credentialService.getCredentialShared(id);\n }\n\n async createAccessGrantFromDAG(\n params: CreateAccessGrantFromDAGParams,\n ): Promise<CreateAccessGrantFromDAGParams | null> {\n return this.#grantService.createAccessGrantFromDAG(\n params,\n (contentHash: string) => this.getCredentialIdByContentHash(contentHash),\n (id: string) => this.getCredentialShared(id),\n );\n }\n\n async buildCredential(\n fields: CredentialFields,\n subject: CredentialSubject,\n issuer: AvailableIssuerType,\n validate = true,\n ): Promise<Credential> {\n return buildCredential(fields, subject, issuer, validate);\n }\n\n deriveCredentialLevel(subject: CredentialSubject): string {\n return deriveLevel(subject);\n }\n\n async buildFaceIdCredential(\n fields: CredentialFields,\n subject: CredentialSubjectFaceId,\n issuer: AvailableIssuerType,\n validate = true,\n ): Promise<FaceIdCredential> {\n return buildFaceIdCredential(fields, subject, issuer, validate);\n }\n}\n\nexport type {\n idOSCredential,\n idOSGrant,\n idOSUser,\n idOSUserAttribute,\n idOSDelegatedWriteGrant,\n idOSWallet,\n CredentialFields,\n CredentialSubject,\n AvailableIssuerType,\n Credential,\n CredentialSubjectFaceId,\n FaceIdCredential,\n};\n"],"x_google_ignoreList":[0],"mappings":";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M,uBACJ,eACA,aAC8C;AAC9C,SAAO,MAAA,kBAAwB,uBAAuB,eAAe,YAAY;;CAGnF,MAAM,6BAA6B,aAA6C;AAC9E,SAAO,MAAA,kBAAwB,6BAA6B,YAAY;;CAG1E,MAAM,oBAAoB,IAA4C;AACpE,SAAO,MAAA,kBAAwB,oBAAoB,GAAG;;CAGxD,MAAM,yBACJ,QACgD;AAChD,SAAO,MAAA,aAAmB,yBACxB,SACC,gBAAwB,KAAK,6BAA6B,YAAY,GACtE,OAAe,KAAK,oBAAoB,GAAG,CAC7C;;CAGH,MAAM,gBACJ,QACA,SACA,QACA,WAAW,MACU;AACrB,SAAO,gBAAgB,QAAQ,SAAS,QAAQ,SAAS;;CAG3D,sBAAsB,SAAoC;AACxD,SAAO,YAAY,QAAQ;;CAG7B,MAAM,sBACJ,QACA,SACA,QACA,WAAW,MACgB;AAC3B,SAAO,sBAAsB,QAAQ,SAAS,QAAQ,SAAS"}
1
+ {"version":3,"file":"index.mjs","names":["#kwilClient","#signingKeyPair","#encryptionSecretKey","#ensureEntityId","#buildInsertableIDOSCredential","#kwilClient","#encryptionSecretKey","_createAgByDagForCopy","#kwilClient","_hasProfile","#ensureEntityId","_upsertWalletAsInserter","#credentialService","#grantService","#userService"],"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/grant.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 } from \"@idos-network/credentials/types\";\nimport type { KwilActionClient } from \"@idos-network/kwil-infra\";\n\nimport {\n type CreateCredentialsByDwgInput,\n createCredentialsByDwg,\n dwgMessage,\n type EditPublicNotesAsIssuerInput,\n editPublicNotesAsIssuer,\n getCredentialShared,\n getSiblingCredentialId,\n type idOSDelegatedWriteGrant,\n} from \"@idos-network/kwil-infra/actions\";\nimport {\n base64Decode,\n base64Encode,\n hexEncode,\n hexEncodeSha256Hash,\n utf8Encode,\n} from \"@idos-network/utils/codecs\";\nimport { encryptContent } from \"@idos-network/utils/cryptography\";\nimport invariant from \"tiny-invariant\";\nimport nacl from \"tweetnacl\";\n\ntype InsertableIDOSCredential = Omit<idOSCredential, \"id\" | \"original_id\"> & {\n id?: idOSCredential[\"id\"];\n content_hash?: string;\n public_notes_signature: string;\n broader_signature: string;\n};\n\ntype BuildInsertableIDOSCredentialArgs = {\n userId: string;\n publicNotes: string;\n plaintextContent: Uint8Array;\n recipientEncryptionPublicKey: Uint8Array;\n};\n\nexport type BaseCredentialParams = {\n id?: string;\n userId: string;\n publicNotes: string;\n plaintextContent: Uint8Array;\n recipientEncryptionPublicKey: Uint8Array;\n};\n\nexport type DelegatedWriteGrantBaseParams = Omit<BaseCredentialParams, \"userId\">;\n\nexport type DelegatedWriteGrantParams = {\n id: string;\n ownerWalletIdentifier: string;\n consumerWalletIdentifier: string;\n issuerPublicKey: string;\n accessGrantTimelock: string;\n notUsableBefore: string;\n notUsableAfter: string;\n signature: string;\n};\n\nexport class CredentialService {\n readonly #kwilClient: KwilActionClient;\n readonly #signingKeyPair: nacl.SignKeyPair;\n readonly #encryptionSecretKey: Uint8Array;\n\n constructor(\n kwilClient: KwilActionClient,\n signingKeyPair: nacl.SignKeyPair,\n encryptionSecretKey: Uint8Array,\n ) {\n this.#kwilClient = kwilClient;\n this.#signingKeyPair = signingKeyPair;\n this.#encryptionSecretKey = encryptionSecretKey;\n }\n\n #buildInsertableIDOSCredential({\n userId,\n publicNotes,\n plaintextContent,\n recipientEncryptionPublicKey,\n }: Omit<BuildInsertableIDOSCredentialArgs, \"userId\"> & { userId?: string }):\n | InsertableIDOSCredential\n | Omit<InsertableIDOSCredential, \"user_id\"> {\n const ephemeralKeyPair = nacl.box.keyPair();\n const content = encryptContent(\n plaintextContent,\n recipientEncryptionPublicKey,\n ephemeralKeyPair.secretKey,\n );\n\n const public_notes_signature = base64Encode(\n nacl.sign.detached(utf8Encode(publicNotes), this.#signingKeyPair.secretKey),\n );\n\n return {\n user_id: userId,\n content: base64Encode(content),\n public_notes: publicNotes,\n public_notes_signature,\n\n broader_signature: base64Encode(\n nacl.sign.detached(\n Uint8Array.from([...base64Decode(public_notes_signature), ...content]),\n this.#signingKeyPair.secretKey,\n ),\n ),\n\n issuer_auth_public_key: hexEncode(this.#signingKeyPair.publicKey, true),\n encryptor_public_key: base64Encode(ephemeralKeyPair.publicKey),\n };\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 requestDelegatedWriteGrantMessage(params: idOSDelegatedWriteGrant): Promise<string> {\n return dwgMessage(this.#kwilClient, params).then((res) => res.message);\n }\n\n async createCredentialByDelegatedWriteGrant(\n credentialParams: DelegatedWriteGrantBaseParams,\n delegatedWriteGrant: DelegatedWriteGrantParams,\n consumerEncryptionPublicKey?: Uint8Array,\n ): Promise<{\n originalCredential: Omit<idOSCredential, \"user_id\">;\n copyCredential: Omit<idOSCredential, \"user_id\">;\n }> {\n let recipientPublicKey = consumerEncryptionPublicKey;\n if (!recipientPublicKey) {\n // If we're not explicitly given a consumer enc pub key, we're assuming that the issuer is creating a copy\n // for themselves. So, we derive the recipient encryption public key from the issuer's encryption secret key.\n recipientPublicKey = nacl.box.keyPair.fromSecretKey(this.#encryptionSecretKey).publicKey;\n }\n\n const originalCredential = this.#ensureEntityId(\n this.#buildInsertableIDOSCredential(credentialParams),\n );\n\n const contentHash = hexEncodeSha256Hash(credentialParams.plaintextContent);\n\n const copyCredential = this.#ensureEntityId(\n this.#buildInsertableIDOSCredential({\n publicNotes: \"\",\n plaintextContent: credentialParams.plaintextContent,\n recipientEncryptionPublicKey: recipientPublicKey,\n }),\n );\n\n const payload: CreateCredentialsByDwgInput = {\n issuer_auth_public_key: originalCredential.issuer_auth_public_key,\n original_encryptor_public_key: originalCredential.encryptor_public_key,\n original_credential_id: originalCredential.id,\n original_content: originalCredential.content,\n original_public_notes: originalCredential.public_notes,\n original_public_notes_signature: originalCredential.public_notes_signature,\n original_broader_signature: originalCredential.broader_signature,\n copy_encryptor_public_key: copyCredential.encryptor_public_key,\n copy_credential_id: copyCredential.id,\n copy_content: copyCredential.content,\n copy_public_notes_signature: copyCredential.public_notes_signature,\n copy_broader_signature: copyCredential.broader_signature,\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 createCredentialsByDwg(this.#kwilClient, payload);\n\n return { originalCredential, copyCredential };\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<idOSCredential | null> {\n const result = await getCredentialShared(this.#kwilClient, { id }).then((res) => res[0]);\n\n return result ?? null;\n }\n}\n","import type { idOSCredential } from \"@idos-network/credentials/types\";\nimport type { KwilActionClient } from \"@idos-network/kwil-infra\";\n\nimport { createAgByDagForCopy as _createAgByDagForCopy } from \"@idos-network/kwil-infra/actions\";\nimport { base64Encode, hexEncodeSha256Hash, utf8Encode } from \"@idos-network/utils/codecs\";\nimport { NoncedBox } from \"@idos-network/utils/cryptography\";\nimport invariant from \"tiny-invariant\";\n\nexport type CreateAccessGrantFromDAGParams = {\n dag_data_id: string;\n dag_owner_wallet_identifier: string;\n dag_grantee_wallet_identifier: string;\n dag_signature: string;\n dag_locked_until: number;\n dag_content_hash: string;\n};\n\nexport class GrantService {\n readonly #kwilClient: KwilActionClient;\n readonly #encryptionSecretKey: Uint8Array;\n\n constructor(kwilClient: KwilActionClient, encryptionSecretKey: Uint8Array) {\n this.#kwilClient = kwilClient;\n this.#encryptionSecretKey = encryptionSecretKey;\n }\n\n async createAccessGrantFromDAG(\n params: CreateAccessGrantFromDAGParams,\n getCredentialIdByContentHash: (contentHash: string) => Promise<string | null>,\n getCredentialShared: (id: string) => Promise<idOSCredential | null>,\n ): Promise<CreateAccessGrantFromDAGParams | null> {\n const credentialId = await getCredentialIdByContentHash(params.dag_content_hash);\n\n invariant(credentialId, \"Missing `idOSCredential` id\");\n\n const credential = await getCredentialShared(credentialId);\n\n invariant(credential, \"`idOSCredential` with id `{credentialId}` not found\");\n\n const plaintextContent = await NoncedBox.nonceFromBase64SecretKey(\n base64Encode(this.#encryptionSecretKey),\n ).decrypt(credential.content, credential.encryptor_public_key);\n\n // Get the content hash from the plaintext content\n const contentHash = hexEncodeSha256Hash(utf8Encode(plaintextContent));\n\n // Check if the content hash matches the content hash in the credential\n if (contentHash !== params.dag_content_hash) {\n throw new Error(\"Hash mismatch between `DAG` and `idOSCredential` content\");\n }\n\n const result = await _createAgByDagForCopy(this.#kwilClient, params);\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 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) => res.has_profile);\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 /// Useful to understand if a user id already exists.\n async getUser(params: GetUserAsInserterInput): Promise<idOSUser> {\n return getUserAsInserter(this.#kwilClient, this.#ensureEntityId(params));\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 CredentialFields,\n CredentialSubject,\n CredentialSubjectFaceId,\n idOSCredential,\n} from \"@idos-network/credentials/types\";\nimport type {\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 buildCredential,\n buildFaceIdCredential,\n type Credential,\n type FaceIdCredential,\n} from \"@idos-network/credentials/builder\";\nimport { deriveLevel } from \"@idos-network/credentials/utils\";\nimport { createNodeKwilClient, createServerKwilSigner } from \"@idos-network/kwil-infra\";\n\nimport {\n CredentialService,\n type DelegatedWriteGrantBaseParams,\n type DelegatedWriteGrantParams,\n} from \"./services/credential.service\";\nimport { type CreateAccessGrantFromDAGParams, GrantService } from \"./services/grant.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 signingKeyPair: SignKeyPair;\n encryptionSecretKey: Uint8Array;\n};\n\nexport class idOSIssuer {\n readonly #credentialService: CredentialService;\n readonly #grantService: GrantService;\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 credentialService = new CredentialService(\n kwilClient,\n params.signingKeyPair,\n params.encryptionSecretKey,\n );\n\n const grantService = new GrantService(kwilClient, params.encryptionSecretKey);\n const userService = new UserService(kwilClient);\n\n return new idOSIssuer(credentialService, grantService, userService);\n }\n\n private constructor(\n credentialService: CredentialService,\n grantService: GrantService,\n userService: UserService,\n ) {\n this.#credentialService = credentialService;\n this.#grantService = grantService;\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 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: DelegatedWriteGrantBaseParams,\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<idOSCredential | null> {\n return this.#credentialService.getCredentialShared(id);\n }\n\n async createAccessGrantFromDAG(\n params: CreateAccessGrantFromDAGParams,\n ): Promise<CreateAccessGrantFromDAGParams | null> {\n return this.#grantService.createAccessGrantFromDAG(\n params,\n (contentHash: string) => this.getCredentialIdByContentHash(contentHash),\n (id: string) => this.getCredentialShared(id),\n );\n }\n\n async buildCredential(\n fields: CredentialFields,\n subject: CredentialSubject,\n issuer: AvailableIssuerType,\n validate = true,\n ): Promise<Credential> {\n return buildCredential(fields, subject, issuer, validate);\n }\n\n deriveCredentialLevel(subject: CredentialSubject): string {\n return deriveLevel(subject);\n }\n\n async buildFaceIdCredential(\n fields: CredentialFields,\n subject: CredentialSubjectFaceId,\n issuer: AvailableIssuerType,\n validate = true,\n ): Promise<FaceIdCredential> {\n return buildFaceIdCredential(fields, subject, issuer, validate);\n }\n}\n\nexport type {\n idOSCredential,\n idOSGrant,\n idOSUser,\n idOSUserAttribute,\n idOSDelegatedWriteGrant,\n idOSWallet,\n CredentialFields,\n CredentialSubject,\n AvailableIssuerType,\n Credential,\n CredentialSubjectFaceId,\n FaceIdCredential,\n};\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;AAAA,IAAI,eAAe,QAAQ,IAAI,aAAa;AAC5C,IAAI,SAAS;AACb,SAAS,UAAU,WAAW,SAAS;CACnC,IAAI,WACA;CAEJ,IAAI,cACA,MAAM,IAAI,MAAM,OAAO;CAE3B,IAAI,WAAW,OAAO,YAAY,aAAa,SAAS,GAAG;CAC3D,IAAI,QAAQ,WAAW,GAAG,OAAO,QAAQ,KAAK,CAAC,OAAO,SAAS,GAAG;CAClE,MAAM,IAAI,MAAM,MAAM;;;;ACgD1B,IAAa,oBAAb,MAA+B;CAC7B;CACA;CACA;CAEA,YACE,YACA,gBACA,qBACA;EACA,KAAKA,cAAc;EACnB,KAAKC,kBAAkB;EACvB,KAAKC,uBAAuB;;CAG9B,+BAA+B,EAC7B,QACA,aACA,kBACA,gCAG4C;EAC5C,MAAM,mBAAmB,KAAK,IAAI,SAAS;EAC3C,MAAM,UAAU,eACd,kBACA,8BACA,iBAAiB,UAClB;EAED,MAAM,yBAAyB,aAC7B,KAAK,KAAK,SAAS,WAAW,YAAY,EAAE,KAAKD,gBAAgB,UAAU,CAC5E;EAED,OAAO;GACL,SAAS;GACT,SAAS,aAAa,QAAQ;GAC9B,cAAc;GACd;GAEA,mBAAmB,aACjB,KAAK,KAA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D,OAAO,KAAKA,aAAa,WAAW,YAAY;;CAGlD,MAAM,kBAAkB,QAAmD;EACzE,OAAO,KAAKA,aAAa,kBAAkB,OAAO;;CAGpD,MAAM,uBAAuB,QAAoD;EAC/E,OAAO,KAAKA,aAAa,uBAAuB,OAAO;;CAGzD,MAAM,WACJ,MACA,QACiC;EACjC,OAAO,KAAKA,aAAa,WAAW,MAAM,OAAO;;CAGnD,MAAM,QAAQ,IAA+B;EAC3C,OAAO,KAAKA,aAAa,QAAQ,EAAE,IAAI,CAAC;;CAG1C,MAAM,kCAAkC,QAAkD;EACxF,OAAO,KAAKF,mBAAmB,kCAAkC,OAAO;;CAG1E,MAAM,sCACJ,kBACA,qBACA,6BAIC;EACD,OAAO,KAAKA,mBAAmB,sCAC7B,kBACA,qBACA,4BACD;;CAGH,MAAM,uBACJ,eACA,aAC8C;EAC9C,OAAO,KAAKA,mBAAmB,uBAAuB,eAAe,YAAY;;CAGnF,MAAM,6BAA6B,aAA6C;EAC9E,OAAO,KAAKA,mBAAmB,6BAA6B,YAAY;;CAG1E,MAAM,oBAAoB,IAA4C;EACpE,OAAO,KAAKA,mBAAmB,oBAAoB,GAAG;;CAGxD,MAAM,yBACJ,QACgD;EAChD,OAAO,KAAKC,cAAc,yBACxB,SACC,gBAAwB,KAAK,6BAA6B,YAAY,GACtE,OAAe,KAAK,oBAAoB,GAAG,CAC7C;;CAGH,MAAM,gBACJ,QACA,SACA,QACA,WAAW,MACU;EACrB,OAAO,gBAAgB,QAAQ,SAAS,QAAQ,SAAS;;CAG3D,sBAAsB,SAAoC;EACxD,OAAO,YAAY,QAAQ;;CAG7B,MAAM,sBACJ,QACA,SACA,QACA,WAAW,MACgB;EAC3B,OAAO,sBAAsB,QAAQ,SAAS,QAAQ,SAAS"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idos-network/issuer",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "idOS Issuer JavaScript SDK for server environments",
5
5
  "homepage": "https://idos.network",
6
6
  "license": "MIT",
@@ -26,13 +26,13 @@
26
26
  "dependencies": {
27
27
  "@idos-network/kwil-js": "0.1.3",
28
28
  "tweetnacl": "^1.0.3",
29
- "@idos-network/credentials": "1.1.0",
30
- "@idos-network/kwil-infra": "1.1.0",
31
- "@idos-network/utils": "1.1.0"
29
+ "@idos-network/kwil-infra": "1.2.0",
30
+ "@idos-network/credentials": "1.2.0",
31
+ "@idos-network/utils": "1.2.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "tiny-invariant": "^1.3.3",
35
- "tsdown": "^0.21.0"
35
+ "tsdown": "^0.22.0"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "typescript": "^5.8.3"