From 845ce36f8eda24beaad24131ecd82cf3870866ed Mon Sep 17 00:00:00 2001 From: Mohammed S Date: Tue, 18 Apr 2023 22:27:17 +0530 Subject: [PATCH 1/3] Deployment (#321) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ci(restapi): 🎉 cut release to restapi-v1.0.0 * fix(component): dummy * ci(restapi): 🎉 cut release to restapi-v1.0.0 * fix(component): dummy * ci(restapi): 🎉 cut release to restapi-v1.0.1 * ci(restapi): 🎉 cut release to restapi-v1.0.1 * fix(component): dummy * ci(restapi): 🎉 cut release to restapi-v1.0.2 * fix(component): dummy * ci(restapi): 🎉 cut release to restapi-v1.0.2 * fix(component): dummy * ci(restapi): 🎉 cut release to restapi-v1.0.3 * fix: success progressHook * ci(restapi): 🎉 cut release to restapi-v1.0.4 * ci(restapi): 🎉 cut release to restapi-v1.1.0 * ci(restapi): 🎉 cut release to restapi-v1.2.0 * ci(restapi): 🎉 cut release to restapi-v1.2.0 * ci(restapi): 🎉 cut release to restapi-v1.0.0 * fix(component): dummy * fix(component): dummy * fix(component): dummy * ci(restapi): 🎉 cut release to restapi-v1.0.2 * fix(component): dummy * ci(restapi): 🎉 cut release to restapi-v1.0.3 * ci(restapi): 🎉 cut release to restapi-v1.0.4 * ci(restapi): 🎉 cut release to restapi-v1.2.1 * fix: local for local development (#295) Co-Authored-By: aman035 * fix: version update * ci(restapi): 🎉 cut release to restapi-v1.2.2 * ci(restapi): 🎉 cut release to restapi-v1.2.3 --------- Co-authored-by: aman035 --- packages/restapi/CHANGELOG.md | 33 +++++++++++++++++++++++++++++++++ packages/restapi/package.json | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/packages/restapi/CHANGELOG.md b/packages/restapi/CHANGELOG.md index 2d055f231..8d2fee118 100644 --- a/packages/restapi/CHANGELOG.md +++ b/packages/restapi/CHANGELOG.md @@ -2,6 +2,39 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [1.2.3](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-1.2.2...restapi-1.2.3) (2023-04-18) + + +### Bug Fixes + +* git merge ([87a31a1](https://github.com/ethereum-push-notification-service/push-sdk/commit/87a31a142b80e3305d5986e9f6b5734d9345b7d0)) + + + +## [1.2.2](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-1.2.1...restapi-1.2.2) (2023-04-07) + + +### Bug Fixes + +* local for local development ([#295](https://github.com/ethereum-push-notification-service/push-sdk/issues/295)) ([639b4d2](https://github.com/ethereum-push-notification-service/push-sdk/commit/639b4d2de728ef289da5889b51fd45e003156699)) +* main merge ([0be9604](https://github.com/ethereum-push-notification-service/push-sdk/commit/0be9604eacf003db0cc4244f41d5e9c533f7613a)) +* remove hardcoded values ([#299](https://github.com/ethereum-push-notification-service/push-sdk/issues/299)) ([02a4e20](https://github.com/ethereum-push-notification-service/push-sdk/commit/02a4e2077a2ee4fb010d619d04acffc1881a2c0c)) +* signerType ([#303](https://github.com/ethereum-push-notification-service/push-sdk/issues/303)) ([20eb15a](https://github.com/ethereum-push-notification-service/push-sdk/commit/20eb15af4bc3286e5836845e299326352af0ce34)) +* version update ([d5433a9](https://github.com/ethereum-push-notification-service/push-sdk/commit/d5433a93de34e69953ca88e602d264b234708727)) +* version update ([#302](https://github.com/ethereum-push-notification-service/push-sdk/issues/302)) ([82bd4f7](https://github.com/ethereum-push-notification-service/push-sdk/commit/82bd4f7882f8782f8d19a1daf97e5366ce26c5de)) + + + +## [1.2.1](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-1.2.0...restapi-1.2.1) (2023-04-07) + + +### Bug Fixes + +* added types for chat fn ([#298](https://github.com/ethereum-push-notification-service/push-sdk/issues/298)) ([1c944b2](https://github.com/ethereum-push-notification-service/push-sdk/commit/1c944b237909e393f6ae72c76138411076c62b13)) + + + + # [1.2.0](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-1.1.0...restapi-1.2.0) (2023-04-06) diff --git a/packages/restapi/package.json b/packages/restapi/package.json index 8aab7cb33..fc16dae18 100644 --- a/packages/restapi/package.json +++ b/packages/restapi/package.json @@ -1,6 +1,6 @@ { "name": "@pushprotocol/restapi", - "version": "1.2.1", + "version": "1.2.3", "type": "commonjs", "publishConfig": { "registry": "https://registry.npmjs.org/" From 385b3ddf2e2aa22b687a5094ba5cfec0e13da63b Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Wed, 19 Apr 2023 17:13:56 +0530 Subject: [PATCH 2/3] fix: chamged signerType from ethers.wallet (#315) --- .../restapi/src/lib/chat/helpers/crypto.ts | 217 +++++++++--------- packages/restapi/src/lib/types/index.ts | 5 +- packages/uiweb/src/lib/types/index.ts | 5 +- 3 files changed, 118 insertions(+), 109 deletions(-) diff --git a/packages/restapi/src/lib/chat/helpers/crypto.ts b/packages/restapi/src/lib/chat/helpers/crypto.ts index b7f9c020a..8eba063e5 100644 --- a/packages/restapi/src/lib/chat/helpers/crypto.ts +++ b/packages/restapi/src/lib/chat/helpers/crypto.ts @@ -10,13 +10,19 @@ import { walletType, } from '../../types'; import { get } from '../../user'; -import { decryptPGPKey, decryptWithWalletRPCMethod, isValidETHAddress, walletToPCAIP10, decryptAndVerifySignature } from '../../helpers'; +import { + decryptPGPKey, + decryptWithWalletRPCMethod, + isValidETHAddress, + walletToPCAIP10, + decryptAndVerifySignature, +} from '../../helpers'; import { get as getUser } from '../../user'; import { createUserService } from './service'; -import Constants, {ENV} from '../../constants'; +import Constants, { ENV } from '../../constants'; import { getDomainInformation, getTypeInformation } from './signature'; -const SIG_TYPE_V2 = "eip712v2"; +const SIG_TYPE_V2 = 'eip712v2'; interface IEncryptedRequest { message: string; @@ -31,7 +37,7 @@ export const encryptAndSign = async ({ privateKeyArmored, }: { plainText: string; - keys: Array + keys: Array; privateKeyArmored: string; }): Promise<{ cipherText: string; @@ -59,7 +65,6 @@ export const encryptAndSign = async ({ }; }; - export const signMessageWithPGP = async ({ message, privateKeyArmored, @@ -77,7 +82,7 @@ export const signMessageWithPGP = async ({ return { signature, - sigType: 'pgp' + sigType: 'pgp', }; }; @@ -89,36 +94,36 @@ export const decryptFeeds = async ({ }: { feeds: IFeeds[]; connectedUser: IUser; - pgpPrivateKey?:string; + pgpPrivateKey?: string; env: ENV; }): Promise => { - let otherPeer: IUser; - let signatureValidationPubliKey: string; // To do signature verification it depends on who has sent the message - for (const feed of feeds) { - let gotOtherPeer = false; - if (feed.msg.encType !== 'PlainText') { - if (!pgpPrivateKey) { - throw Error('Decrypted private key is necessary'); - } - if (feed.msg.fromCAIP10 !== connectedUser.wallets.split(',')[0]) { - if (!gotOtherPeer) { - otherPeer = await getUser({ account: feed.msg.fromCAIP10, env }); - gotOtherPeer = true; - } - signatureValidationPubliKey = otherPeer!.publicKey!; - } else { - signatureValidationPubliKey = connectedUser.publicKey!; + let otherPeer: IUser; + let signatureValidationPubliKey: string; // To do signature verification it depends on who has sent the message + for (const feed of feeds) { + let gotOtherPeer = false; + if (feed.msg.encType !== 'PlainText') { + if (!pgpPrivateKey) { + throw Error('Decrypted private key is necessary'); + } + if (feed.msg.fromCAIP10 !== connectedUser.wallets.split(',')[0]) { + if (!gotOtherPeer) { + otherPeer = await getUser({ account: feed.msg.fromCAIP10, env }); + gotOtherPeer = true; } - feed.msg.messageContent = await decryptAndVerifySignature({ - cipherText: feed.msg.messageContent, - encryptedSecretKey: feed.msg.encryptedSecret, - publicKeyArmored: signatureValidationPubliKey, - signatureArmored: feed.msg.signature, - privateKeyArmored: pgpPrivateKey, - message: feed.msg - }); + signatureValidationPubliKey = otherPeer!.publicKey!; + } else { + signatureValidationPubliKey = connectedUser.publicKey!; } + feed.msg.messageContent = await decryptAndVerifySignature({ + cipherText: feed.msg.messageContent, + encryptedSecretKey: feed.msg.encryptedSecret, + publicKeyArmored: signatureValidationPubliKey, + signatureArmored: feed.msg.signature, + privateKeyArmored: pgpPrivateKey, + message: feed.msg, + }); } + } return feeds; }; @@ -162,7 +167,7 @@ export const decryptMessages = async ({ privateKeyArmored: connectedUser.privateKey, publicKeyArmored: signatureValidationPubliKey, signatureArmored: savedMsg.signature, - message: savedMsg + message: savedMsg, }); } } @@ -175,9 +180,8 @@ export const getEncryptedRequest = async ( message: string, isGroup: boolean, env: ENV, - group: GroupDTO | null, + group: GroupDTO | null ): Promise => { - if (!isGroup) { const receiverCreatedUser: IUser = await get({ account: receiverAddress, @@ -198,13 +202,10 @@ export const getEncryptedRequest = async ( }); // If the user is being created here, that means that user don't have a PGP keys. So this intent will be in plaintext - const { - signature - } = await signMessageWithPGP({ - message: message, - privateKeyArmored: senderCreatedUser.privateKey!, - }); - + const { signature } = await signMessageWithPGP({ + message: message, + privateKeyArmored: senderCreatedUser.privateKey!, + }); return { message: message, @@ -220,10 +221,7 @@ export const getEncryptedRequest = async ( '-----BEGIN PGP PUBLIC KEY BLOCK-----' ) ) { - - const { - signature - } = await signMessageWithPGP({ + const { signature } = await signMessageWithPGP({ message: message, privateKeyArmored: senderCreatedUser.privateKey!, }); @@ -235,49 +233,13 @@ export const getEncryptedRequest = async ( signature: signature, }; } else { - const { - cipherText, - encryptedSecret, - signature, - } = await encryptAndSign({ - plainText: message, - keys: [receiverCreatedUser.publicKey, senderCreatedUser.publicKey], - privateKeyArmored: senderCreatedUser.privateKey!, - }); - return { - message: cipherText, - encryptionType: 'pgp', - aesEncryptedSecret: encryptedSecret, - signature: signature, - }; - } - } - } else if(group) { - if(group.isPublic) { - const { - signature - } = await signMessageWithPGP({ - message: message, - privateKeyArmored: senderCreatedUser.privateKey!, - }); - return { - message: message, - encryptionType: 'PlainText', - aesEncryptedSecret: '', - signature: signature, + const { cipherText, encryptedSecret, signature } = await encryptAndSign( + { + plainText: message, + keys: [receiverCreatedUser.publicKey, senderCreatedUser.publicKey], + privateKeyArmored: senderCreatedUser.privateKey!, } - } - else { - const publicKeys: string[] = group.members.map(member => member.publicKey); - const { - cipherText, - encryptedSecret, - signature, - } = await encryptAndSign({ - plainText: message, - keys: publicKeys, - privateKeyArmored: senderCreatedUser.privateKey!, - }); + ); return { message: cipherText, encryptionType: 'pgp', @@ -285,26 +247,62 @@ export const getEncryptedRequest = async ( signature: signature, }; } + } + } else if (group) { + if (group.isPublic) { + const { signature } = await signMessageWithPGP({ + message: message, + privateKeyArmored: senderCreatedUser.privateKey!, + }); + return { + message: message, + encryptionType: 'PlainText', + aesEncryptedSecret: '', + signature: signature, + }; + } else { + const publicKeys: string[] = group.members.map( + (member) => member.publicKey + ); + const { cipherText, encryptedSecret, signature } = await encryptAndSign({ + plainText: message, + keys: publicKeys, + privateKeyArmored: senderCreatedUser.privateKey!, + }); + return { + message: cipherText, + encryptionType: 'pgp', + aesEncryptedSecret: encryptedSecret, + signature: signature, + }; + } } }; -export const getEip191Signature = async (wallet: walletType, message: string) => { - if(!wallet?.signer) { - console.warn("This method is deprecated. Provide signer in the function"); +export const getEip191Signature = async ( + wallet: walletType, + message: string +) => { + if (!wallet?.signer) { + console.warn('This method is deprecated. Provide signer in the function'); // sending random signature for making it backward compatible - return { signature: "xyz", sigType: "a" }; + return { signature: 'xyz', sigType: 'a' }; } const _signer = wallet?.signer; // sign a message using EIP191 const signedMessage = await _signer?.signMessage(message); - return {verificationProof: `eip191:${signedMessage}`}; -} + return { verificationProof: `eip191:${signedMessage}` }; +}; -export const getEip712Signature = async (wallet: walletType, hash: string, isDomainEmpty: boolean) => { - if(!wallet?.signer) { - console.warn("This method is deprecated. Provide signer in the function"); +export const getEip712Signature = async ( + wallet: walletType, + hash: string, + isDomainEmpty: boolean +) => { + if (!wallet?.signer) { + console.warn('This method is deprecated. Provide signer in the function'); // sending random signature for making it backward compatible - return { signature: "xyz", sigType: "a" }; + return { signature: 'xyz', sigType: 'a' }; } const typeInformation = getTypeInformation(); @@ -312,29 +310,34 @@ export const getEip712Signature = async (wallet: walletType, hash: string, isDom let chainId: number; try { chainId = await _signer.getChainId(); - } - catch(err) { + } catch (err) { chainId = 1; } const domain = getDomainInformation(chainId); // sign a message using EIP712 - const signedMessage = await _signer?._signTypedData( + const signedMessage = await _signer?._signTypedData!( isDomainEmpty ? {} : domain, typeInformation, - { data: hash }, + { data: hash } ); - const verificationProof = isDomainEmpty ? `${SIG_TYPE_V2}:${signedMessage}` : `${SIG_TYPE_V2}:${chainId}:${signedMessage}` + const verificationProof = isDomainEmpty + ? `${SIG_TYPE_V2}:${signedMessage}` + : `${SIG_TYPE_V2}:${chainId}:${signedMessage}`; return { verificationProof }; -} +}; -export async function getDecryptedPrivateKey(wallet: walletType, user: any, address: string): Promise { +export async function getDecryptedPrivateKey( + wallet: walletType, + user: any, + address: string +): Promise { let decryptedPrivateKey; if (wallet.signer) { decryptedPrivateKey = await decryptPGPKey({ signer: wallet.signer, - encryptedPGPPrivateKey: user.encryptedPrivateKey - }) + encryptedPGPPrivateKey: user.encryptedPrivateKey, + }); } else { decryptedPrivateKey = await decryptWithWalletRPCMethod( user.encryptedPrivateKey, @@ -342,4 +345,4 @@ export async function getDecryptedPrivateKey(wallet: walletType, user: any, addr ); } return decryptedPrivateKey; -} \ No newline at end of file +} diff --git a/packages/restapi/src/lib/types/index.ts b/packages/restapi/src/lib/types/index.ts index 91b9fb73c..05e45b450 100644 --- a/packages/restapi/src/lib/types/index.ts +++ b/packages/restapi/src/lib/types/index.ts @@ -259,7 +259,10 @@ export interface UserInfo { isAdmin: boolean; } -export type SignerType = ethers.Wallet; +export type SignerType = ethers.Signer & { + _signTypedData?: (domain: any, types: any, value: any) => Promise; + privateKey?: string; +}; export type EnvOptionsType = { env?: ENV; diff --git a/packages/uiweb/src/lib/types/index.ts b/packages/uiweb/src/lib/types/index.ts index 78aec13dd..1a2cd2c90 100644 --- a/packages/uiweb/src/lib/types/index.ts +++ b/packages/uiweb/src/lib/types/index.ts @@ -36,4 +36,7 @@ export interface ITheme { moduleColor?: string; } -export type SignerType = ethers.Wallet; +export type SignerType = ethers.Signer & { + _signTypedData?: (domain: any, types: any, value: any) => Promise; + privateKey?: string; +}; From 069783e2cbe77723e335affb2f2668c785aeace6 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Wed, 19 Apr 2023 17:14:13 +0530 Subject: [PATCH 3/3] fix: fix videoCall Notif (#310) --- .../restapi/src/lib/payloads/constants.ts | 34 +++--- packages/restapi/src/lib/payloads/helpers.ts | 115 ++++++++++-------- .../src/lib/payloads/sendNotifications.ts | 7 +- 3 files changed, 86 insertions(+), 70 deletions(-) diff --git a/packages/restapi/src/lib/payloads/constants.ts b/packages/restapi/src/lib/payloads/constants.ts index 8d19e0612..03561b1bc 100644 --- a/packages/restapi/src/lib/payloads/constants.ts +++ b/packages/restapi/src/lib/payloads/constants.ts @@ -1,16 +1,16 @@ export interface ChainIdToSourceType { - [key: number]: string + [key: number]: string; } export const CHAIN_ID_TO_SOURCE: ChainIdToSourceType = { - 1: "ETH_MAINNET", - 5: "ETH_TEST_GOERLI", - 137: "POLYGON_MAINNET", - 80001: "POLYGON_TEST_MUMBAI", - 56: "BSC_MAINNET", - 97: "BSC_TESTNET", - 10: "OPTIMISM_MAINNET", - 420: "OPTIMISM_TESTNET" + 1: 'ETH_MAINNET', + 5: 'ETH_TEST_GOERLI', + 137: 'POLYGON_MAINNET', + 80001: 'POLYGON_TEST_MUMBAI', + 56: 'BSC_MAINNET', + 97: 'BSC_TESTNET', + 10: 'OPTIMISM_MAINNET', + 420: 'OPTIMISM_TESTNET', }; export const SOURCE_TYPES = { @@ -22,19 +22,19 @@ export const SOURCE_TYPES = { BSC_TESTNET: 'BSC_TESTNET', OPTIMISM_MAINNET: 'OPTIMISM_MAINNET', OPTIMISM_TESTNET: 'OPTIMISM_TESTNET', - THE_GRAPH: 'THE_GRAPH' + THE_GRAPH: 'THE_GRAPH', + PUSH_VIDEO: 'PUSH_VIDEO', }; -export enum IDENTITY_TYPE { +export enum IDENTITY_TYPE { MINIMAL = 0, IPFS = 1, DIRECT_PAYLOAD = 2, - SUBGRAPH = 3 -}; + SUBGRAPH = 3, +} -export enum NOTIFICATION_TYPE { +export enum NOTIFICATION_TYPE { BROADCAST = 1, TARGETTED = 3, - SUBSET = 4 -}; - + SUBSET = 4, +} diff --git a/packages/restapi/src/lib/payloads/helpers.ts b/packages/restapi/src/lib/payloads/helpers.ts index 08df179fd..ffc7495f7 100644 --- a/packages/restapi/src/lib/payloads/helpers.ts +++ b/packages/restapi/src/lib/payloads/helpers.ts @@ -1,6 +1,7 @@ import { v4 as uuidv4 } from 'uuid'; import { ENV } from '../constants'; -import { generateHash, getCAIPAddress } from '../helpers'; +import { getCAIPAddress } from '../helpers'; +import * as CryptoJS from 'crypto-js'; import { ISendNotificationInputOptions, @@ -195,68 +196,73 @@ export async function getVerificationProof({ pgpPrivateKey?: string; env?: ENV; }) { - // console.log('payload ---> \n\n', payload); - - const type = { - Data: [{ name: 'data', type: 'string' }], - }; - const domain = { - name: 'EPNS COMM V1', - chainId: chainId, - verifyingContract: verifyingContract, - }; - let message = null; - let signature = null; + let verificationProof = null; - if (identityType === IDENTITY_TYPE.MINIMAL) { - message = { - data: `${identityType}+${notificationType}+${payload.notification.title}+${payload.notification.body}`, - }; - signature = await signer._signTypedData(domain, type, message); - return `eip712v2:${signature}::uid::${uuid}`; - } else if (identityType === IDENTITY_TYPE.IPFS) { - message = { - data: `1+${ipfsHash}`, - }; - signature = await signer._signTypedData(domain, type, message); - return `eip712v2:${signature}::uid::${uuid}`; - } else if (identityType === IDENTITY_TYPE.DIRECT_PAYLOAD) { - const payloadJSON = JSON.stringify(payload); - message = { - data: `2+${payloadJSON}`, - }; + switch (identityType) { + case IDENTITY_TYPE.MINIMAL: { + message = { + data: `${identityType}+${notificationType}+${payload.notification.title}+${payload.notification.body}`, + }; + break; + } + case IDENTITY_TYPE.IPFS: { + message = { + data: `1+${ipfsHash}`, + }; + break; + } + case IDENTITY_TYPE.DIRECT_PAYLOAD: { + const payloadJSON = JSON.stringify(payload); + message = { + data: `2+${payloadJSON}`, + }; + break; + } + case IDENTITY_TYPE.SUBGRAPH: { + message = { + data: `3+graph:${graph?.id}+${graph?.counter}`, + }; + break; + } + default: { + throw new Error('Invalid IdentityType'); + } + } - if (senderType === 1) { - // chat notification - // generate the pgpv2 verification proof + switch (senderType) { + case 0: { + const type = { + Data: [{ name: 'data', type: 'string' }], + }; + const domain = { + name: 'EPNS COMM V1', + chainId: chainId, + verifyingContract: verifyingContract, + }; + const signature = await signer._signTypedData(domain, type, message); + verificationProof = `eip712v2:${signature}::uid::${uuid}`; + break; + } + case 1: { const connectedUser = await getConnectedUser( wallet!, pgpPrivateKey!, env! ); - - const hash = generateHash(JSON.stringify(message)).toString(); - signature = await sign({ + const hash = CryptoJS.SHA256(JSON.stringify(message)).toString(); + const signature = await sign({ message: hash, signingKey: connectedUser.privateKey!, }); - return `pgpv2:${signature}:meta:${chatId}::uid::${uuid}`; + verificationProof = `pgpv2:${signature}:meta:${chatId}::uid::${uuid}`; + break; + } + default: { + throw new Error('Invalid SenderType'); } - - // channel notification - // generate eip712 verification proof - signature = await signer._signTypedData(domain, type, message); - return `eip712v2:${signature}::uid::${uuid}`; - } else if (identityType === IDENTITY_TYPE.SUBGRAPH) { - message = { - data: `3+graph:${graph?.id}+${graph?.counter}`, - }; - signature = await signer._signTypedData(domain, type, message); - return `eip712v2:${signature}::uid::${uuid}`; } - - return signature; + return verificationProof; } export function getPayloadIdentity({ @@ -286,7 +292,14 @@ export function getPayloadIdentity({ return null; } -export function getSource(chainId: number, identityType: IDENTITY_TYPE) { +export function getSource( + chainId: number, + identityType: IDENTITY_TYPE, + senderType: 0 | 1 +) { + if (senderType === 1) { + return SOURCE_TYPES.PUSH_VIDEO; + } if (identityType === IDENTITY_TYPE.SUBGRAPH) { return SOURCE_TYPES.THE_GRAPH; } diff --git a/packages/restapi/src/lib/payloads/sendNotifications.ts b/packages/restapi/src/lib/payloads/sendNotifications.ts index 863b71306..e8adfdda7 100644 --- a/packages/restapi/src/lib/payloads/sendNotifications.ts +++ b/packages/restapi/src/lib/payloads/sendNotifications.ts @@ -116,12 +116,15 @@ export async function sendNotification(options: ISendNotificationInputOptions) { ipfsHash, }); - const source = getSource(chainId, identityType); + const source = getSource(chainId, identityType, senderType); const apiPayload = { verificationProof, identity, - sender: _channelAddress, + sender: + senderType === 1 + ? `${channelCAIPDetails?.blockchain}:${channelCAIPDetails?.address}` + : _channelAddress, source, /** note this recipient key has a different expectation from the BE API, see the funciton for more */ recipient: getRecipientFieldForAPIPayload({