From 05251683c08c20e41ee36b8570bb8317ceff599d Mon Sep 17 00:00:00 2001 From: aman035 Date: Wed, 3 Jul 2024 20:59:06 +0530 Subject: [PATCH] fix: change d-node-notif to dnode --- packages/d-node-notif/project.json | 57 -- packages/d-node-notif/src/lib/alias/index.ts | 1 - .../d-node-notif/src/lib/chat/helpers/aes.ts | 21 - .../d-node-notif/src/lib/chat/helpers/pgp.ts | 176 ----- packages/d-node-notif/src/lib/helpers/api.ts | 19 - .../src/lib/utils/parseSubscribersAPI.ts | 24 - .../tests/lib/notification/tokenABI.ts | 709 ------------------ packages/{d-node-notif => dnode}/.babelrc | 0 .../{d-node-notif => dnode}/.eslintrc.json | 0 packages/{d-node-notif => dnode}/README.md | 4 +- packages/{d-node-notif => dnode}/package.json | 2 +- packages/dnode/project.json | 57 ++ packages/{d-node-notif => dnode}/src/index.ts | 0 .../src/lib/abis/comm.ts | 0 .../src/lib/abis/core.ts | 0 .../src/lib/abis/token.ts | 0 .../src/lib/abis/validator.ts | 0 .../src/lib/alias/getAliasInfo.ts | 0 packages/dnode/src/lib/alias/index.ts | 1 + .../src/lib/channels/_getSubscribers.ts | 0 .../src/lib/channels/getChannel.ts | 0 .../lib/channels/getChannelNotifications.ts | 0 .../src/lib/channels/getChannels.ts | 0 .../src/lib/channels/getDelegates.ts | 0 .../src/lib/channels/getSubscribers.ts | 0 .../src/lib/channels/index.ts | 1 - .../src/lib/channels/search.ts | 0 .../src/lib/channels/signature.helpers.ts | 30 +- .../src/lib/channels/subscribe.ts | 0 .../src/lib/channels/subscribeV2.ts | 0 .../src/lib/channels/unsubscribe.ts | 0 .../src/lib/channels/unsubscribeV2.ts | 0 packages/dnode/src/lib/chat/helpers/aes.ts | 34 + .../src/lib/chat/helpers/crypto.ts | 0 .../src/lib/chat/helpers/index.ts | 0 packages/dnode/src/lib/chat/helpers/pgp.ts | 247 ++++++ .../src/lib/chat/helpers/service.ts | 0 .../src/lib/chat/helpers/signature.ts | 0 .../src/lib/chat/helpers/user.ts | 0 .../src/lib/chat/helpers/wallet.ts | 0 .../{d-node-notif => dnode}/src/lib/config.ts | 0 .../src/lib/constants.ts | 0 .../src/lib/errors/httpStatus.ts | 4 +- .../src/lib/errors/validationError.ts | 2 +- .../src/lib/helpers/address.ts | 0 packages/dnode/src/lib/helpers/api.ts | 19 + .../src/lib/helpers/cache.ts | 0 .../src/lib/helpers/config.ts | 0 .../src/lib/helpers/crypto.ts | 0 .../src/lib/helpers/index.ts | 0 .../src/lib/helpers/signer.ts | 0 .../{d-node-notif => dnode}/src/lib/index.ts | 0 .../src/lib/payloads/constants.ts | 0 .../src/lib/payloads/helpers.ts | 0 .../src/lib/payloads/index.ts | 2 +- .../src/lib/payloads/sendNotifications.ts | 0 .../src/lib/progressHook.ts | 0 .../src/lib/pushAPI/PushAPI.ts | 0 .../src/lib/pushAPI/pushAPITypes.ts | 0 .../pushNotification/PushNotificationTypes.ts | 12 +- .../src/lib/pushNotification/alias.ts | 51 +- .../src/lib/pushNotification/channel.ts | 0 .../src/lib/pushNotification/delegate.ts | 0 .../src/lib/pushNotification/notification.ts | 0 .../pushNotification/pushNotificationBase.ts | 0 .../src/lib/pushValidator/pushValidator.ts | 0 .../lib/pushValidator/pushValidatorTypes.ts | 0 .../src/lib/pushstream/DataModifier.ts | 0 .../src/lib/pushstream/PushStream.ts | 0 .../src/lib/pushstream/pushStreamTypes.ts | 0 .../src/lib/pushstream/socketClient.ts | 0 .../src/lib/types/index.ts | 0 .../src/lib/user/auth.updateUser.ts | 0 .../src/lib/user/createUser.ts | 0 .../src/lib/user/createUserWithProfile.ts | 3 +- .../src/lib/user/decryptAuth.ts | 0 .../src/lib/user/getDelegations.ts | 0 .../src/lib/user/getFeeds.ts | 0 .../src/lib/user/getFeedsPerChannel.ts | 0 .../src/lib/user/getSubscriptions.ts | 0 .../src/lib/user/getUser.ts | 0 .../src/lib/user/getUsersBatch.ts | 0 .../src/lib/user/index.ts | 0 .../src/lib/user/profile.updateUser.ts | 0 .../src/lib/user/upgradeUser.ts | 0 .../src/lib/utils/axiosUtil.ts | 0 .../src/lib/utils/index.ts | 2 +- .../src/lib/utils/parseAPI.ts | 26 +- .../src/lib/utils/parseSettings.ts | 0 .../src/lib/utils/parseSubscribersAPI.ts | 33 + .../src/lib/utils/pasreSubscriptionAPI.ts | 20 +- .../src/lib/utils/populateIUser.ts | 0 .../{d-node-notif => dnode}/tests/.env.sample | 0 .../tests/lib/aliasChains/arbitrum.test.ts | 0 .../tests/lib/aliasChains/berachain.test.ts | 0 .../tests/lib/aliasChains/optimism.test.ts | 0 .../tests/lib/aliasChains/polygon.test.ts | 0 .../lib/aliasChains/polygonZkevm.test.ts | 0 .../tests/lib/initialize/initialize.test.ts | 0 .../tests/lib/notification/alias.test.ts | 0 .../tests/lib/notification/channel.test.ts | 0 .../tests/lib/notification/delegate.test.ts | 0 .../lib/notification/notification.test.ts | 0 .../dnode/tests/lib/notification/tokenABI.ts | 709 ++++++++++++++++++ .../lib/pushValidator/pushValidator.test.ts | 0 .../tests/lib/utils/parseSettings.test.ts | 0 .../lib/utils/parseSubscriptionAPI.test.ts | 2 +- .../tests/loaders/envVerifier.ts | 0 .../tests/process-env.d.ts | 4 +- .../{d-node-notif => dnode}/tests/root.ts | 23 +- .../{d-node-notif => dnode}/tsconfig.json | 0 .../{d-node-notif => dnode}/tsconfig.lib.json | 0 .../tsconfig.mocha.json | 14 +- tsconfig.base.json | 2 +- workspace.json | 2 +- 115 files changed, 1208 insertions(+), 1105 deletions(-) delete mode 100644 packages/d-node-notif/project.json delete mode 100644 packages/d-node-notif/src/lib/alias/index.ts delete mode 100644 packages/d-node-notif/src/lib/chat/helpers/aes.ts delete mode 100644 packages/d-node-notif/src/lib/chat/helpers/pgp.ts delete mode 100644 packages/d-node-notif/src/lib/helpers/api.ts delete mode 100644 packages/d-node-notif/src/lib/utils/parseSubscribersAPI.ts delete mode 100644 packages/d-node-notif/tests/lib/notification/tokenABI.ts rename packages/{d-node-notif => dnode}/.babelrc (100%) rename packages/{d-node-notif => dnode}/.eslintrc.json (100%) rename packages/{d-node-notif => dnode}/README.md (51%) rename packages/{d-node-notif => dnode}/package.json (97%) create mode 100644 packages/dnode/project.json rename packages/{d-node-notif => dnode}/src/index.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/abis/comm.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/abis/core.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/abis/token.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/abis/validator.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/alias/getAliasInfo.ts (100%) create mode 100644 packages/dnode/src/lib/alias/index.ts rename packages/{d-node-notif => dnode}/src/lib/channels/_getSubscribers.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/channels/getChannel.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/channels/getChannelNotifications.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/channels/getChannels.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/channels/getDelegates.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/channels/getSubscribers.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/channels/index.ts (99%) rename packages/{d-node-notif => dnode}/src/lib/channels/search.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/channels/signature.helpers.ts (80%) rename packages/{d-node-notif => dnode}/src/lib/channels/subscribe.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/channels/subscribeV2.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/channels/unsubscribe.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/channels/unsubscribeV2.ts (100%) create mode 100644 packages/dnode/src/lib/chat/helpers/aes.ts rename packages/{d-node-notif => dnode}/src/lib/chat/helpers/crypto.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/chat/helpers/index.ts (100%) create mode 100644 packages/dnode/src/lib/chat/helpers/pgp.ts rename packages/{d-node-notif => dnode}/src/lib/chat/helpers/service.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/chat/helpers/signature.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/chat/helpers/user.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/chat/helpers/wallet.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/config.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/constants.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/errors/httpStatus.ts (76%) rename packages/{d-node-notif => dnode}/src/lib/errors/validationError.ts (98%) rename packages/{d-node-notif => dnode}/src/lib/helpers/address.ts (100%) create mode 100644 packages/dnode/src/lib/helpers/api.ts rename packages/{d-node-notif => dnode}/src/lib/helpers/cache.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/helpers/config.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/helpers/crypto.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/helpers/index.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/helpers/signer.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/index.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/payloads/constants.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/payloads/helpers.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/payloads/index.ts (87%) rename packages/{d-node-notif => dnode}/src/lib/payloads/sendNotifications.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/progressHook.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/pushAPI/PushAPI.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/pushAPI/pushAPITypes.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/pushNotification/PushNotificationTypes.ts (99%) rename packages/{d-node-notif => dnode}/src/lib/pushNotification/alias.ts (75%) rename packages/{d-node-notif => dnode}/src/lib/pushNotification/channel.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/pushNotification/delegate.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/pushNotification/notification.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/pushNotification/pushNotificationBase.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/pushValidator/pushValidator.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/pushValidator/pushValidatorTypes.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/pushstream/DataModifier.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/pushstream/PushStream.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/pushstream/pushStreamTypes.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/pushstream/socketClient.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/types/index.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/user/auth.updateUser.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/user/createUser.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/user/createUserWithProfile.ts (97%) rename packages/{d-node-notif => dnode}/src/lib/user/decryptAuth.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/user/getDelegations.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/user/getFeeds.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/user/getFeedsPerChannel.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/user/getSubscriptions.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/user/getUser.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/user/getUsersBatch.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/user/index.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/user/profile.updateUser.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/user/upgradeUser.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/utils/axiosUtil.ts (100%) rename packages/{d-node-notif => dnode}/src/lib/utils/index.ts (58%) rename packages/{d-node-notif => dnode}/src/lib/utils/parseAPI.ts (69%) rename packages/{d-node-notif => dnode}/src/lib/utils/parseSettings.ts (100%) create mode 100644 packages/dnode/src/lib/utils/parseSubscribersAPI.ts rename packages/{d-node-notif => dnode}/src/lib/utils/pasreSubscriptionAPI.ts (52%) rename packages/{d-node-notif => dnode}/src/lib/utils/populateIUser.ts (100%) rename packages/{d-node-notif => dnode}/tests/.env.sample (100%) rename packages/{d-node-notif => dnode}/tests/lib/aliasChains/arbitrum.test.ts (100%) rename packages/{d-node-notif => dnode}/tests/lib/aliasChains/berachain.test.ts (100%) rename packages/{d-node-notif => dnode}/tests/lib/aliasChains/optimism.test.ts (100%) rename packages/{d-node-notif => dnode}/tests/lib/aliasChains/polygon.test.ts (100%) rename packages/{d-node-notif => dnode}/tests/lib/aliasChains/polygonZkevm.test.ts (100%) rename packages/{d-node-notif => dnode}/tests/lib/initialize/initialize.test.ts (100%) rename packages/{d-node-notif => dnode}/tests/lib/notification/alias.test.ts (100%) rename packages/{d-node-notif => dnode}/tests/lib/notification/channel.test.ts (100%) rename packages/{d-node-notif => dnode}/tests/lib/notification/delegate.test.ts (100%) rename packages/{d-node-notif => dnode}/tests/lib/notification/notification.test.ts (100%) create mode 100644 packages/dnode/tests/lib/notification/tokenABI.ts rename packages/{d-node-notif => dnode}/tests/lib/pushValidator/pushValidator.test.ts (100%) rename packages/{d-node-notif => dnode}/tests/lib/utils/parseSettings.test.ts (100%) rename packages/{d-node-notif => dnode}/tests/lib/utils/parseSubscriptionAPI.test.ts (97%) rename packages/{d-node-notif => dnode}/tests/loaders/envVerifier.ts (100%) rename packages/{d-node-notif => dnode}/tests/process-env.d.ts (66%) rename packages/{d-node-notif => dnode}/tests/root.ts (69%) rename packages/{d-node-notif => dnode}/tsconfig.json (100%) rename packages/{d-node-notif => dnode}/tsconfig.lib.json (100%) rename packages/{d-node-notif => dnode}/tsconfig.mocha.json (57%) diff --git a/packages/d-node-notif/project.json b/packages/d-node-notif/project.json deleted file mode 100644 index df0d02019..000000000 --- a/packages/d-node-notif/project.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "packages/d-node-notif/src", - "projectType": "library", - "targets": { - "build": { - "executor": "@nrwl/js:tsc", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/packages/d-node-notif", - "main": "packages/d-node-notif/src/index.ts", - "tsConfig": "packages/d-node-notif/tsconfig.lib.json", - "assets": ["packages/d-node-notif/*.md"] - } - }, - "lint": { - "executor": "@nrwl/linter:eslint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["packages/d-node-notif/**/*.ts"] - } - }, - "test": { - "executor": "@nrwl/workspace:run-commands", - "outputs": ["coverage/packages/d-node-notif"], - "options": { - "commands": ["cd packages/d-node-notif && yarn run test"], - "passWithNoTests": true - } - }, - "ci-version": { - "executor": "@jscutlery/semver:version", - "options": { - "preset": "angular", - "commitMessageFormat": "ci(${projectName}): 🎉 cut release to ${projectName}-v${version}", - "postTargets": ["d-node_notif:build", "d-node_notif:ci-publish"] - } - }, - "ci-version-beta": { - "executor": "@jscutlery/semver:version", - "options": { - "preset": "angular", - "commitMessageFormat": "ci(${projectName}): 🎉 cut beta release to ${projectName}-v${version}", - "postTargets": ["d-node_notif:build", "d-node_notif:ci-publish"], - "version": "prerelease", - "preid": "alpha" - } - }, - "ci-publish": { - "executor": "@nrwl/workspace:run-commands", - "options": { - "command": "node tools/scripts/publish.mjs d-node_notif" - } - } -}, - "tags": [] -} diff --git a/packages/d-node-notif/src/lib/alias/index.ts b/packages/d-node-notif/src/lib/alias/index.ts deleted file mode 100644 index c6e18c3d5..000000000 --- a/packages/d-node-notif/src/lib/alias/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./getAliasInfo"; \ No newline at end of file diff --git a/packages/d-node-notif/src/lib/chat/helpers/aes.ts b/packages/d-node-notif/src/lib/chat/helpers/aes.ts deleted file mode 100644 index dd90b9094..000000000 --- a/packages/d-node-notif/src/lib/chat/helpers/aes.ts +++ /dev/null @@ -1,21 +0,0 @@ -import * as CryptoJS from "crypto-js" - -export const aesEncrypt = ({ plainText, secretKey }: { plainText: string; secretKey: string }): string => { - return CryptoJS.AES.encrypt(plainText, secretKey).toString() -} - -export const aesDecrypt = ({ cipherText, secretKey }: { cipherText: string; secretKey: string }): string => { - const bytes = CryptoJS.AES.decrypt(cipherText, secretKey) - return bytes.toString(CryptoJS.enc.Utf8) -} - -export const generateRandomSecret = (length: number): string => { - let result = '' - const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' - const charactersLength = characters.length - for (let i = 0; i < length; i++) { - result += characters.charAt(Math.floor(Math.random() * charactersLength)) - } - - return result -} diff --git a/packages/d-node-notif/src/lib/chat/helpers/pgp.ts b/packages/d-node-notif/src/lib/chat/helpers/pgp.ts deleted file mode 100644 index 6240dc60d..000000000 --- a/packages/d-node-notif/src/lib/chat/helpers/pgp.ts +++ /dev/null @@ -1,176 +0,0 @@ -import * as openpgp from 'openpgp'; - -interface IPGPHelper{ - generateKeyPair(): Promise<{ privateKeyArmored: string; publicKeyArmored: string }>; - sign ({ message, signingKey }: { message: string; signingKey: string }): Promise; - pgpEncrypt ({ plainText, keys }: { plainText: string; keys: Array }): Promise; - pgpDecrypt({cipherText,toPrivateKeyArmored}: { cipherText: any, toPrivateKeyArmored: string}): Promise; - verifySignature({ messageContent, signatureArmored, publicKeyArmored, }: {messageContent: string;signatureArmored: string; publicKeyArmored: string;}): Promise -} - -const PGPHelper:IPGPHelper = { - async generateKeyPair(){ - const keys = await openpgp.generateKey({ - type: 'rsa', - rsaBits: 2048, - userIDs: [{ name: '', email: '' }] - }) - return { - privateKeyArmored: keys.privateKey, - publicKeyArmored: keys.publicKey - } - }, - - async sign ({ message, signingKey }): Promise { - const messageObject: openpgp.Message = await openpgp.createMessage({ text: message }) - const privateKey: openpgp.PrivateKey = await openpgp.readPrivateKey({ armoredKey: signingKey }) - return await openpgp.sign({ message: messageObject, signingKeys: privateKey, detached: true }) - }, - - async pgpEncrypt ({ plainText, keys }): Promise { - const pgpKeys: openpgp.Key[] = []; - - for(let i = 0; i < keys.length; i++) { - pgpKeys.push(await openpgp.readKey({ armoredKey: keys[i] })); - } - const message: openpgp.Message = await openpgp.createMessage({ text: plainText }); - const encrypted: string = await openpgp.encrypt({ - message: message, - encryptionKeys: pgpKeys, - }); - return encrypted; - }, - - async pgpDecrypt({ - cipherText, - toPrivateKeyArmored - }: { - cipherText: any - toPrivateKeyArmored: string - }): Promise{ - - const message = await openpgp.readMessage({ armoredMessage: cipherText }) - const privateKey: openpgp.PrivateKey = await openpgp.readPrivateKey({ armoredKey: toPrivateKeyArmored }) - - const { data: decrypted } = await openpgp.decrypt({ - message, - decryptionKeys: privateKey - }) - - return decrypted as string - }, - - async verifySignature({ - messageContent, - signatureArmored, - publicKeyArmored, - }: { - messageContent: string - signatureArmored: string - publicKeyArmored: string - }): Promise { - const message: openpgp.Message = await openpgp.createMessage({ text: messageContent }) - const signature: openpgp.Signature = await openpgp.readSignature({ - armoredSignature: signatureArmored - }) - const publicKey: openpgp.PublicKey = await openpgp.readKey({ armoredKey: publicKeyArmored }) - const verificationResult = await openpgp.verify({ - message, - signature, - verificationKeys: publicKey - }) - const { verified } = verificationResult.signatures[0] - try { - await verified - } catch (e) { - throw new Error('Signature could not be verified: ' + e) - } - } - -} - -export {IPGPHelper, PGPHelper} - -export const generateKeyPair = async (): Promise<{ privateKeyArmored: string; publicKeyArmored: string }> => { - const keys = await openpgp.generateKey({ - type: 'rsa', - rsaBits: 2048, - userIDs: [{ name: '', email: '' }] - }) - return { - privateKeyArmored: keys.privateKey, - publicKeyArmored: keys.publicKey - } -} - -export const pgpEncrypt = async ({ - plainText, - keys, -}: { - plainText: string - keys: Array -}): Promise => { - - const pgpKeys: openpgp.Key[] = []; - - for(let i = 0; i < keys.length; i++) { - pgpKeys.push(await openpgp.readKey({ armoredKey: keys[i] })) - } - const message: openpgp.Message = await openpgp.createMessage({ text: plainText }) - const encrypted: string = await openpgp.encrypt({ - message: message, - encryptionKeys: pgpKeys - }) - return encrypted -} - -export const sign = async ({ message, signingKey }: { message: string; signingKey: string }): Promise => { - const messageObject: openpgp.Message = await openpgp.createMessage({ text: message }) - const privateKey: openpgp.PrivateKey = await openpgp.readPrivateKey({ armoredKey: signingKey }) - return await openpgp.sign({ message: messageObject, signingKeys: privateKey, detached: true }) -} - -export const verifySignature = async ({ - messageContent, - signatureArmored, - publicKeyArmored, -}: { - messageContent: string - signatureArmored: string - publicKeyArmored: string -}): Promise => { - const message: openpgp.Message = await openpgp.createMessage({ text: messageContent }) - const signature: openpgp.Signature = await openpgp.readSignature({ - armoredSignature: signatureArmored - }) - const publicKey: openpgp.PublicKey = await openpgp.readKey({ armoredKey: publicKeyArmored }) - const verificationResult = await openpgp.verify({ - message, - signature, - verificationKeys: publicKey - }) - const { verified } = verificationResult.signatures[0] - try { - await verified - } catch (e) { - throw new Error('Signature could not be verified: ' + e) - } -} - -export const pgpDecrypt = async ({ - cipherText, - toPrivateKeyArmored -}: { - cipherText: any - toPrivateKeyArmored: string -}): Promise => { - const message = await openpgp.readMessage({ armoredMessage: cipherText }) - const privateKey: openpgp.PrivateKey = await openpgp.readPrivateKey({ armoredKey: toPrivateKeyArmored }) - - const { data: decrypted } = await openpgp.decrypt({ - message, - decryptionKeys: privateKey - }) - - return decrypted as string -} diff --git a/packages/d-node-notif/src/lib/helpers/api.ts b/packages/d-node-notif/src/lib/helpers/api.ts deleted file mode 100644 index 54cfc1db6..000000000 --- a/packages/d-node-notif/src/lib/helpers/api.ts +++ /dev/null @@ -1,19 +0,0 @@ -import Constants from '../constants'; - -export function getQueryParams(obj: any) { - return Object.keys(obj) - .map(key => { - return `${key}=${encodeURIComponent(obj[key])}`; - }) - .join('&'); -} - -export function getLimit(passedLimit?: number) { - if (!passedLimit) return Constants.PAGINATION.LIMIT; - - // if (passedLimit > Constants.PAGINATION.LIMIT_MAX) { - // return Constants.PAGINATION.LIMIT_MAX; - // } - - return passedLimit; -} \ No newline at end of file diff --git a/packages/d-node-notif/src/lib/utils/parseSubscribersAPI.ts b/packages/d-node-notif/src/lib/utils/parseSubscribersAPI.ts deleted file mode 100644 index 11d3331d9..000000000 --- a/packages/d-node-notif/src/lib/utils/parseSubscribersAPI.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { ApiSubscribersType, NotificationSettingType } from '../types'; -import { parseSettings } from './parseSettings'; -/** - * @description parse the response gotten from the API - * @param {ApiSubscribersType[]} response - * @returns {NotificationSettingType[]} - */ - -export type SubscriberResponse = { - itemcount: number; - subscribers: {subscriber: string, settings: NotificationSettingType[] | null}[] -} -export function parseSubscrbersApiResponse(response: ApiSubscribersType):SubscriberResponse { - const parsedSubscribers = response.subscribers.map((apisubscribers: {subscriber: string, settings: string| null}) => { - return { - subscriber: apisubscribers.subscriber, - settings: apisubscribers.settings? parseSettings(apisubscribers.settings): null - } - }); - return { - itemcount: response.itemcount, - subscribers: [...parsedSubscribers] - } -} \ No newline at end of file diff --git a/packages/d-node-notif/tests/lib/notification/tokenABI.ts b/packages/d-node-notif/tests/lib/notification/tokenABI.ts deleted file mode 100644 index 0f602271d..000000000 --- a/packages/d-node-notif/tests/lib/notification/tokenABI.ts +++ /dev/null @@ -1,709 +0,0 @@ -export const abi = [ - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "fromDelegate", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "toDelegate", - "type": "address" - } - ], - "name": "DelegateChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "delegate", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "previousBalance", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newBalance", - "type": "uint256" - } - ], - "name": "DelegateVotesChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "holder", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "weight", - "type": "uint256" - } - ], - "name": "HolderWeightChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "inputs": [], - "name": "DELEGATION_TYPEHASH", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "DOMAIN_TYPEHASH", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "PERMIT_TYPEHASH", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "rawAmount", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "born", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "rawAmount", - "type": "uint256" - } - ], - "name": "burn", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "name": "checkpoints", - "outputs": [ - { - "internalType": "uint32", - "name": "fromBlock", - "type": "uint32" - }, - { - "internalType": "uint96", - "name": "votes", - "type": "uint96" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "delegatee", - "type": "address" - } - ], - "name": "delegate", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "delegatee", - "type": "address" - }, - { - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "expiry", - "type": "uint256" - }, - { - "internalType": "uint8", - "name": "v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "s", - "type": "bytes32" - } - ], - "name": "delegateBySig", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "delegates", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "getCurrentVotes", - "outputs": [ - { - "internalType": "uint96", - "name": "", - "type": "uint96" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "uint256", - "name": "blockNumber", - "type": "uint256" - } - ], - "name": "getPriorVotes", - "outputs": [ - { - "internalType": "uint96", - "name": "", - "type": "uint96" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "holderDelegation", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "holderWeight", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "nonces", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "numCheckpoints", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "rawAmount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "deadline", - "type": "uint256" - }, - { - "internalType": "uint8", - "name": "v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "s", - "type": "bytes32" - } - ], - "name": "permit", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "holder", - "type": "address" - } - ], - "name": "resetHolderWeight", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "address", - "name": "delegate", - "type": "address" - } - ], - "name": "returnHolderDelegation", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "returnHolderRatio", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "delegate", - "type": "address" - }, - { - "internalType": "bool", - "name": "value", - "type": "bool" - } - ], - "name": "setHolderDelegation", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "dst", - "type": "address" - }, - { - "internalType": "uint256", - "name": "rawAmount", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "src", - "type": "address" - }, - { - "internalType": "address", - "name": "dst", - "type": "address" - }, - { - "internalType": "uint256", - "name": "rawAmount", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } - ] as const \ No newline at end of file diff --git a/packages/d-node-notif/.babelrc b/packages/dnode/.babelrc similarity index 100% rename from packages/d-node-notif/.babelrc rename to packages/dnode/.babelrc diff --git a/packages/d-node-notif/.eslintrc.json b/packages/dnode/.eslintrc.json similarity index 100% rename from packages/d-node-notif/.eslintrc.json rename to packages/dnode/.eslintrc.json diff --git a/packages/d-node-notif/README.md b/packages/dnode/README.md similarity index 51% rename from packages/d-node-notif/README.md rename to packages/dnode/README.md index 383d4fca0..5854b16b0 100644 --- a/packages/d-node-notif/README.md +++ b/packages/dnode/README.md @@ -1,7 +1,7 @@ -# d-node-notif +# dnode This library was generated with [Nx](https://nx.dev). ## Building -Run `nx build d-node-notif` to build the library. +Run `nx build dnode` to build the library. diff --git a/packages/d-node-notif/package.json b/packages/dnode/package.json similarity index 97% rename from packages/d-node-notif/package.json rename to packages/dnode/package.json index e494077fa..12ae3ee55 100644 --- a/packages/d-node-notif/package.json +++ b/packages/dnode/package.json @@ -1,5 +1,5 @@ { - "name": "@sdk/d-node-notif", + "name": "@sdk/dnode", "version": "0.0.1", "type": "commonjs", "publishConfig": { diff --git a/packages/dnode/project.json b/packages/dnode/project.json new file mode 100644 index 000000000..afdd2cb60 --- /dev/null +++ b/packages/dnode/project.json @@ -0,0 +1,57 @@ +{ + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/dnode/src", + "projectType": "library", + "targets": { + "build": { + "executor": "@nrwl/js:tsc", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/packages/dnode", + "main": "packages/dnode/src/index.ts", + "tsConfig": "packages/dnode/tsconfig.lib.json", + "assets": ["packages/dnode/*.md"] + } + }, + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["packages/dnode/**/*.ts"] + } + }, + "test": { + "executor": "@nrwl/workspace:run-commands", + "outputs": ["coverage/packages/dnode"], + "options": { + "commands": ["cd packages/dnode && yarn run test"], + "passWithNoTests": true + } + }, + "ci-version": { + "executor": "@jscutlery/semver:version", + "options": { + "preset": "angular", + "commitMessageFormat": "ci(${projectName}): 🎉 cut release to ${projectName}-v${version}", + "postTargets": ["d-node_notif:build", "d-node_notif:ci-publish"] + } + }, + "ci-version-beta": { + "executor": "@jscutlery/semver:version", + "options": { + "preset": "angular", + "commitMessageFormat": "ci(${projectName}): 🎉 cut beta release to ${projectName}-v${version}", + "postTargets": ["d-node_notif:build", "d-node_notif:ci-publish"], + "version": "prerelease", + "preid": "alpha" + } + }, + "ci-publish": { + "executor": "@nrwl/workspace:run-commands", + "options": { + "command": "node tools/scripts/publish.mjs d-node_notif" + } + } + }, + "tags": [] +} diff --git a/packages/d-node-notif/src/index.ts b/packages/dnode/src/index.ts similarity index 100% rename from packages/d-node-notif/src/index.ts rename to packages/dnode/src/index.ts diff --git a/packages/d-node-notif/src/lib/abis/comm.ts b/packages/dnode/src/lib/abis/comm.ts similarity index 100% rename from packages/d-node-notif/src/lib/abis/comm.ts rename to packages/dnode/src/lib/abis/comm.ts diff --git a/packages/d-node-notif/src/lib/abis/core.ts b/packages/dnode/src/lib/abis/core.ts similarity index 100% rename from packages/d-node-notif/src/lib/abis/core.ts rename to packages/dnode/src/lib/abis/core.ts diff --git a/packages/d-node-notif/src/lib/abis/token.ts b/packages/dnode/src/lib/abis/token.ts similarity index 100% rename from packages/d-node-notif/src/lib/abis/token.ts rename to packages/dnode/src/lib/abis/token.ts diff --git a/packages/d-node-notif/src/lib/abis/validator.ts b/packages/dnode/src/lib/abis/validator.ts similarity index 100% rename from packages/d-node-notif/src/lib/abis/validator.ts rename to packages/dnode/src/lib/abis/validator.ts diff --git a/packages/d-node-notif/src/lib/alias/getAliasInfo.ts b/packages/dnode/src/lib/alias/getAliasInfo.ts similarity index 100% rename from packages/d-node-notif/src/lib/alias/getAliasInfo.ts rename to packages/dnode/src/lib/alias/getAliasInfo.ts diff --git a/packages/dnode/src/lib/alias/index.ts b/packages/dnode/src/lib/alias/index.ts new file mode 100644 index 000000000..ae953d398 --- /dev/null +++ b/packages/dnode/src/lib/alias/index.ts @@ -0,0 +1 @@ +export * from './getAliasInfo'; diff --git a/packages/d-node-notif/src/lib/channels/_getSubscribers.ts b/packages/dnode/src/lib/channels/_getSubscribers.ts similarity index 100% rename from packages/d-node-notif/src/lib/channels/_getSubscribers.ts rename to packages/dnode/src/lib/channels/_getSubscribers.ts diff --git a/packages/d-node-notif/src/lib/channels/getChannel.ts b/packages/dnode/src/lib/channels/getChannel.ts similarity index 100% rename from packages/d-node-notif/src/lib/channels/getChannel.ts rename to packages/dnode/src/lib/channels/getChannel.ts diff --git a/packages/d-node-notif/src/lib/channels/getChannelNotifications.ts b/packages/dnode/src/lib/channels/getChannelNotifications.ts similarity index 100% rename from packages/d-node-notif/src/lib/channels/getChannelNotifications.ts rename to packages/dnode/src/lib/channels/getChannelNotifications.ts diff --git a/packages/d-node-notif/src/lib/channels/getChannels.ts b/packages/dnode/src/lib/channels/getChannels.ts similarity index 100% rename from packages/d-node-notif/src/lib/channels/getChannels.ts rename to packages/dnode/src/lib/channels/getChannels.ts diff --git a/packages/d-node-notif/src/lib/channels/getDelegates.ts b/packages/dnode/src/lib/channels/getDelegates.ts similarity index 100% rename from packages/d-node-notif/src/lib/channels/getDelegates.ts rename to packages/dnode/src/lib/channels/getDelegates.ts diff --git a/packages/d-node-notif/src/lib/channels/getSubscribers.ts b/packages/dnode/src/lib/channels/getSubscribers.ts similarity index 100% rename from packages/d-node-notif/src/lib/channels/getSubscribers.ts rename to packages/dnode/src/lib/channels/getSubscribers.ts diff --git a/packages/d-node-notif/src/lib/channels/index.ts b/packages/dnode/src/lib/channels/index.ts similarity index 99% rename from packages/d-node-notif/src/lib/channels/index.ts rename to packages/dnode/src/lib/channels/index.ts index 8728fc02a..74e5d3ea8 100644 --- a/packages/d-node-notif/src/lib/channels/index.ts +++ b/packages/dnode/src/lib/channels/index.ts @@ -9,4 +9,3 @@ export * from './subscribe'; export * from './subscribeV2'; export * from './unsubscribe'; export * from './unsubscribeV2'; - diff --git a/packages/d-node-notif/src/lib/channels/search.ts b/packages/dnode/src/lib/channels/search.ts similarity index 100% rename from packages/d-node-notif/src/lib/channels/search.ts rename to packages/dnode/src/lib/channels/search.ts diff --git a/packages/d-node-notif/src/lib/channels/signature.helpers.ts b/packages/dnode/src/lib/channels/signature.helpers.ts similarity index 80% rename from packages/d-node-notif/src/lib/channels/signature.helpers.ts rename to packages/dnode/src/lib/channels/signature.helpers.ts index fadb4e480..5cd6ad59d 100644 --- a/packages/d-node-notif/src/lib/channels/signature.helpers.ts +++ b/packages/dnode/src/lib/channels/signature.helpers.ts @@ -35,18 +35,26 @@ export const getSubscriptionMessageV2 = ( const actionTypeKey = action === 'Unsubscribe' ? 'unsubscriber' : 'subscriber'; if (action == 'Subscribe') { - return JSON.stringify({ - channel, - [actionTypeKey]: userAddress, - action: action, - userSetting: userSetting?? '', - }, null, 4); + return JSON.stringify( + { + channel, + [actionTypeKey]: userAddress, + action: action, + userSetting: userSetting ?? '', + }, + null, + 4 + ); } else { - return JSON.stringify({ - channel, - [actionTypeKey]: userAddress, - action: action, - }, null, 4); + return JSON.stringify( + { + channel, + [actionTypeKey]: userAddress, + action: action, + }, + null, + 4 + ); } }; diff --git a/packages/d-node-notif/src/lib/channels/subscribe.ts b/packages/dnode/src/lib/channels/subscribe.ts similarity index 100% rename from packages/d-node-notif/src/lib/channels/subscribe.ts rename to packages/dnode/src/lib/channels/subscribe.ts diff --git a/packages/d-node-notif/src/lib/channels/subscribeV2.ts b/packages/dnode/src/lib/channels/subscribeV2.ts similarity index 100% rename from packages/d-node-notif/src/lib/channels/subscribeV2.ts rename to packages/dnode/src/lib/channels/subscribeV2.ts diff --git a/packages/d-node-notif/src/lib/channels/unsubscribe.ts b/packages/dnode/src/lib/channels/unsubscribe.ts similarity index 100% rename from packages/d-node-notif/src/lib/channels/unsubscribe.ts rename to packages/dnode/src/lib/channels/unsubscribe.ts diff --git a/packages/d-node-notif/src/lib/channels/unsubscribeV2.ts b/packages/dnode/src/lib/channels/unsubscribeV2.ts similarity index 100% rename from packages/d-node-notif/src/lib/channels/unsubscribeV2.ts rename to packages/dnode/src/lib/channels/unsubscribeV2.ts diff --git a/packages/dnode/src/lib/chat/helpers/aes.ts b/packages/dnode/src/lib/chat/helpers/aes.ts new file mode 100644 index 000000000..98b3ca3b9 --- /dev/null +++ b/packages/dnode/src/lib/chat/helpers/aes.ts @@ -0,0 +1,34 @@ +import * as CryptoJS from 'crypto-js'; + +export const aesEncrypt = ({ + plainText, + secretKey, +}: { + plainText: string; + secretKey: string; +}): string => { + return CryptoJS.AES.encrypt(plainText, secretKey).toString(); +}; + +export const aesDecrypt = ({ + cipherText, + secretKey, +}: { + cipherText: string; + secretKey: string; +}): string => { + const bytes = CryptoJS.AES.decrypt(cipherText, secretKey); + return bytes.toString(CryptoJS.enc.Utf8); +}; + +export const generateRandomSecret = (length: number): string => { + let result = ''; + const characters = + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + const charactersLength = characters.length; + for (let i = 0; i < length; i++) { + result += characters.charAt(Math.floor(Math.random() * charactersLength)); + } + + return result; +}; diff --git a/packages/d-node-notif/src/lib/chat/helpers/crypto.ts b/packages/dnode/src/lib/chat/helpers/crypto.ts similarity index 100% rename from packages/d-node-notif/src/lib/chat/helpers/crypto.ts rename to packages/dnode/src/lib/chat/helpers/crypto.ts diff --git a/packages/d-node-notif/src/lib/chat/helpers/index.ts b/packages/dnode/src/lib/chat/helpers/index.ts similarity index 100% rename from packages/d-node-notif/src/lib/chat/helpers/index.ts rename to packages/dnode/src/lib/chat/helpers/index.ts diff --git a/packages/dnode/src/lib/chat/helpers/pgp.ts b/packages/dnode/src/lib/chat/helpers/pgp.ts new file mode 100644 index 000000000..85d9992ac --- /dev/null +++ b/packages/dnode/src/lib/chat/helpers/pgp.ts @@ -0,0 +1,247 @@ +import * as openpgp from 'openpgp'; + +interface IPGPHelper { + generateKeyPair(): Promise<{ + privateKeyArmored: string; + publicKeyArmored: string; + }>; + sign({ + message, + signingKey, + }: { + message: string; + signingKey: string; + }): Promise; + pgpEncrypt({ + plainText, + keys, + }: { + plainText: string; + keys: Array; + }): Promise; + pgpDecrypt({ + cipherText, + toPrivateKeyArmored, + }: { + cipherText: any; + toPrivateKeyArmored: string; + }): Promise; + verifySignature({ + messageContent, + signatureArmored, + publicKeyArmored, + }: { + messageContent: string; + signatureArmored: string; + publicKeyArmored: string; + }): Promise; +} + +const PGPHelper: IPGPHelper = { + async generateKeyPair() { + const keys = await openpgp.generateKey({ + type: 'rsa', + rsaBits: 2048, + userIDs: [{ name: '', email: '' }], + }); + return { + privateKeyArmored: keys.privateKey, + publicKeyArmored: keys.publicKey, + }; + }, + + async sign({ message, signingKey }): Promise { + const messageObject: openpgp.Message = await openpgp.createMessage({ + text: message, + }); + const privateKey: openpgp.PrivateKey = await openpgp.readPrivateKey({ + armoredKey: signingKey, + }); + return ( + await openpgp.sign({ + message: messageObject, + signingKeys: privateKey, + detached: true, + }) + ); + }, + + async pgpEncrypt({ plainText, keys }): Promise { + const pgpKeys: openpgp.Key[] = []; + + for (let i = 0; i < keys.length; i++) { + pgpKeys.push(await openpgp.readKey({ armoredKey: keys[i] })); + } + const message: openpgp.Message = await openpgp.createMessage({ + text: plainText, + }); + const encrypted: string = await openpgp.encrypt({ + message: message, + encryptionKeys: pgpKeys, + }); + return encrypted; + }, + + async pgpDecrypt({ + cipherText, + toPrivateKeyArmored, + }: { + cipherText: any; + toPrivateKeyArmored: string; + }): Promise { + const message = await openpgp.readMessage({ armoredMessage: cipherText }); + const privateKey: openpgp.PrivateKey = await openpgp.readPrivateKey({ + armoredKey: toPrivateKeyArmored, + }); + + const { data: decrypted } = await openpgp.decrypt({ + message, + decryptionKeys: privateKey, + }); + + return decrypted as string; + }, + + async verifySignature({ + messageContent, + signatureArmored, + publicKeyArmored, + }: { + messageContent: string; + signatureArmored: string; + publicKeyArmored: string; + }): Promise { + const message: openpgp.Message = await openpgp.createMessage({ + text: messageContent, + }); + const signature: openpgp.Signature = await openpgp.readSignature({ + armoredSignature: signatureArmored, + }); + const publicKey: openpgp.PublicKey = await openpgp.readKey({ + armoredKey: publicKeyArmored, + }); + const verificationResult = await openpgp.verify({ + message, + signature, + verificationKeys: publicKey, + }); + const { verified } = verificationResult.signatures[0]; + try { + await verified; + } catch (e) { + throw new Error('Signature could not be verified: ' + e); + } + }, +}; + +export { IPGPHelper, PGPHelper }; + +export const generateKeyPair = async (): Promise<{ + privateKeyArmored: string; + publicKeyArmored: string; +}> => { + const keys = await openpgp.generateKey({ + type: 'rsa', + rsaBits: 2048, + userIDs: [{ name: '', email: '' }], + }); + return { + privateKeyArmored: keys.privateKey, + publicKeyArmored: keys.publicKey, + }; +}; + +export const pgpEncrypt = async ({ + plainText, + keys, +}: { + plainText: string; + keys: Array; +}): Promise => { + const pgpKeys: openpgp.Key[] = []; + + for (let i = 0; i < keys.length; i++) { + pgpKeys.push(await openpgp.readKey({ armoredKey: keys[i] })); + } + const message: openpgp.Message = await openpgp.createMessage({ + text: plainText, + }); + const encrypted: string = await openpgp.encrypt({ + message: message, + encryptionKeys: pgpKeys, + }); + return encrypted; +}; + +export const sign = async ({ + message, + signingKey, +}: { + message: string; + signingKey: string; +}): Promise => { + const messageObject: openpgp.Message = await openpgp.createMessage({ + text: message, + }); + const privateKey: openpgp.PrivateKey = await openpgp.readPrivateKey({ + armoredKey: signingKey, + }); + return ( + await openpgp.sign({ + message: messageObject, + signingKeys: privateKey, + detached: true, + }) + ); +}; + +export const verifySignature = async ({ + messageContent, + signatureArmored, + publicKeyArmored, +}: { + messageContent: string; + signatureArmored: string; + publicKeyArmored: string; +}): Promise => { + const message: openpgp.Message = await openpgp.createMessage({ + text: messageContent, + }); + const signature: openpgp.Signature = await openpgp.readSignature({ + armoredSignature: signatureArmored, + }); + const publicKey: openpgp.PublicKey = await openpgp.readKey({ + armoredKey: publicKeyArmored, + }); + const verificationResult = await openpgp.verify({ + message, + signature, + verificationKeys: publicKey, + }); + const { verified } = verificationResult.signatures[0]; + try { + await verified; + } catch (e) { + throw new Error('Signature could not be verified: ' + e); + } +}; + +export const pgpDecrypt = async ({ + cipherText, + toPrivateKeyArmored, +}: { + cipherText: any; + toPrivateKeyArmored: string; +}): Promise => { + const message = await openpgp.readMessage({ armoredMessage: cipherText }); + const privateKey: openpgp.PrivateKey = await openpgp.readPrivateKey({ + armoredKey: toPrivateKeyArmored, + }); + + const { data: decrypted } = await openpgp.decrypt({ + message, + decryptionKeys: privateKey, + }); + + return decrypted as string; +}; diff --git a/packages/d-node-notif/src/lib/chat/helpers/service.ts b/packages/dnode/src/lib/chat/helpers/service.ts similarity index 100% rename from packages/d-node-notif/src/lib/chat/helpers/service.ts rename to packages/dnode/src/lib/chat/helpers/service.ts diff --git a/packages/d-node-notif/src/lib/chat/helpers/signature.ts b/packages/dnode/src/lib/chat/helpers/signature.ts similarity index 100% rename from packages/d-node-notif/src/lib/chat/helpers/signature.ts rename to packages/dnode/src/lib/chat/helpers/signature.ts diff --git a/packages/d-node-notif/src/lib/chat/helpers/user.ts b/packages/dnode/src/lib/chat/helpers/user.ts similarity index 100% rename from packages/d-node-notif/src/lib/chat/helpers/user.ts rename to packages/dnode/src/lib/chat/helpers/user.ts diff --git a/packages/d-node-notif/src/lib/chat/helpers/wallet.ts b/packages/dnode/src/lib/chat/helpers/wallet.ts similarity index 100% rename from packages/d-node-notif/src/lib/chat/helpers/wallet.ts rename to packages/dnode/src/lib/chat/helpers/wallet.ts diff --git a/packages/d-node-notif/src/lib/config.ts b/packages/dnode/src/lib/config.ts similarity index 100% rename from packages/d-node-notif/src/lib/config.ts rename to packages/dnode/src/lib/config.ts diff --git a/packages/d-node-notif/src/lib/constants.ts b/packages/dnode/src/lib/constants.ts similarity index 100% rename from packages/d-node-notif/src/lib/constants.ts rename to packages/dnode/src/lib/constants.ts diff --git a/packages/d-node-notif/src/lib/errors/httpStatus.ts b/packages/dnode/src/lib/errors/httpStatus.ts similarity index 76% rename from packages/d-node-notif/src/lib/errors/httpStatus.ts rename to packages/dnode/src/lib/errors/httpStatus.ts index 767542bd9..62fcc6739 100644 --- a/packages/d-node-notif/src/lib/errors/httpStatus.ts +++ b/packages/dnode/src/lib/errors/httpStatus.ts @@ -2,5 +2,5 @@ export enum HttpStatus { BadRequest = 400, NotFound = 404, Forbidden = 403, - InternalError=500 -} \ No newline at end of file + InternalError = 500, +} diff --git a/packages/d-node-notif/src/lib/errors/validationError.ts b/packages/dnode/src/lib/errors/validationError.ts similarity index 98% rename from packages/d-node-notif/src/lib/errors/validationError.ts rename to packages/dnode/src/lib/errors/validationError.ts index 631707d30..2e3ffcd13 100644 --- a/packages/d-node-notif/src/lib/errors/validationError.ts +++ b/packages/dnode/src/lib/errors/validationError.ts @@ -1,4 +1,4 @@ -import { HttpStatus } from "./httpStatus"; +import { HttpStatus } from './httpStatus'; export class ValidationError extends Error { status: HttpStatus; diff --git a/packages/d-node-notif/src/lib/helpers/address.ts b/packages/dnode/src/lib/helpers/address.ts similarity index 100% rename from packages/d-node-notif/src/lib/helpers/address.ts rename to packages/dnode/src/lib/helpers/address.ts diff --git a/packages/dnode/src/lib/helpers/api.ts b/packages/dnode/src/lib/helpers/api.ts new file mode 100644 index 000000000..e465f54b5 --- /dev/null +++ b/packages/dnode/src/lib/helpers/api.ts @@ -0,0 +1,19 @@ +import Constants from '../constants'; + +export function getQueryParams(obj: any) { + return Object.keys(obj) + .map((key) => { + return `${key}=${encodeURIComponent(obj[key])}`; + }) + .join('&'); +} + +export function getLimit(passedLimit?: number) { + if (!passedLimit) return Constants.PAGINATION.LIMIT; + + // if (passedLimit > Constants.PAGINATION.LIMIT_MAX) { + // return Constants.PAGINATION.LIMIT_MAX; + // } + + return passedLimit; +} diff --git a/packages/d-node-notif/src/lib/helpers/cache.ts b/packages/dnode/src/lib/helpers/cache.ts similarity index 100% rename from packages/d-node-notif/src/lib/helpers/cache.ts rename to packages/dnode/src/lib/helpers/cache.ts diff --git a/packages/d-node-notif/src/lib/helpers/config.ts b/packages/dnode/src/lib/helpers/config.ts similarity index 100% rename from packages/d-node-notif/src/lib/helpers/config.ts rename to packages/dnode/src/lib/helpers/config.ts diff --git a/packages/d-node-notif/src/lib/helpers/crypto.ts b/packages/dnode/src/lib/helpers/crypto.ts similarity index 100% rename from packages/d-node-notif/src/lib/helpers/crypto.ts rename to packages/dnode/src/lib/helpers/crypto.ts diff --git a/packages/d-node-notif/src/lib/helpers/index.ts b/packages/dnode/src/lib/helpers/index.ts similarity index 100% rename from packages/d-node-notif/src/lib/helpers/index.ts rename to packages/dnode/src/lib/helpers/index.ts diff --git a/packages/d-node-notif/src/lib/helpers/signer.ts b/packages/dnode/src/lib/helpers/signer.ts similarity index 100% rename from packages/d-node-notif/src/lib/helpers/signer.ts rename to packages/dnode/src/lib/helpers/signer.ts diff --git a/packages/d-node-notif/src/lib/index.ts b/packages/dnode/src/lib/index.ts similarity index 100% rename from packages/d-node-notif/src/lib/index.ts rename to packages/dnode/src/lib/index.ts diff --git a/packages/d-node-notif/src/lib/payloads/constants.ts b/packages/dnode/src/lib/payloads/constants.ts similarity index 100% rename from packages/d-node-notif/src/lib/payloads/constants.ts rename to packages/dnode/src/lib/payloads/constants.ts diff --git a/packages/d-node-notif/src/lib/payloads/helpers.ts b/packages/dnode/src/lib/payloads/helpers.ts similarity index 100% rename from packages/d-node-notif/src/lib/payloads/helpers.ts rename to packages/dnode/src/lib/payloads/helpers.ts diff --git a/packages/d-node-notif/src/lib/payloads/index.ts b/packages/dnode/src/lib/payloads/index.ts similarity index 87% rename from packages/d-node-notif/src/lib/payloads/index.ts rename to packages/dnode/src/lib/payloads/index.ts index 22436ff9a..a9984ab12 100644 --- a/packages/d-node-notif/src/lib/payloads/index.ts +++ b/packages/dnode/src/lib/payloads/index.ts @@ -5,5 +5,5 @@ export { ADDITIONAL_META_TYPE, SPACE_REQUEST_TYPE, SPACE_ACCEPT_REQUEST_TYPE, - SPACE_DISCONNECT_TYPE + SPACE_DISCONNECT_TYPE, } from './constants'; diff --git a/packages/d-node-notif/src/lib/payloads/sendNotifications.ts b/packages/dnode/src/lib/payloads/sendNotifications.ts similarity index 100% rename from packages/d-node-notif/src/lib/payloads/sendNotifications.ts rename to packages/dnode/src/lib/payloads/sendNotifications.ts diff --git a/packages/d-node-notif/src/lib/progressHook.ts b/packages/dnode/src/lib/progressHook.ts similarity index 100% rename from packages/d-node-notif/src/lib/progressHook.ts rename to packages/dnode/src/lib/progressHook.ts diff --git a/packages/d-node-notif/src/lib/pushAPI/PushAPI.ts b/packages/dnode/src/lib/pushAPI/PushAPI.ts similarity index 100% rename from packages/d-node-notif/src/lib/pushAPI/PushAPI.ts rename to packages/dnode/src/lib/pushAPI/PushAPI.ts diff --git a/packages/d-node-notif/src/lib/pushAPI/pushAPITypes.ts b/packages/dnode/src/lib/pushAPI/pushAPITypes.ts similarity index 100% rename from packages/d-node-notif/src/lib/pushAPI/pushAPITypes.ts rename to packages/dnode/src/lib/pushAPI/pushAPITypes.ts diff --git a/packages/d-node-notif/src/lib/pushNotification/PushNotificationTypes.ts b/packages/dnode/src/lib/pushNotification/PushNotificationTypes.ts similarity index 99% rename from packages/d-node-notif/src/lib/pushNotification/PushNotificationTypes.ts rename to packages/dnode/src/lib/pushNotification/PushNotificationTypes.ts index dc3c6c20f..0e599ae5f 100644 --- a/packages/d-node-notif/src/lib/pushNotification/PushNotificationTypes.ts +++ b/packages/dnode/src/lib/pushNotification/PushNotificationTypes.ts @@ -34,7 +34,7 @@ export type AliasOptions = Omit; export type AliasInfoOptions = { raw?: boolean; version?: number; -} +}; export enum FeedType { INBOX = 'INBOX', @@ -132,8 +132,6 @@ export type ChannelOptions = { raw: boolean; }; - - export enum ChannelListType { ALL = 'all', VERIFIED = 'verified', @@ -144,8 +142,6 @@ export enum ChannelListSortType { SUBSCRIBER = 'subscribers', } - - export type ChannelListOptions = { page?: number; limit?: number; @@ -153,11 +149,7 @@ export type ChannelListOptions = { order?: ChannelListOrderType; }; - - - - export enum ChannelListOrderType { ASCENDING = 'asc', DESCENDING = 'desc', -}; \ No newline at end of file +} diff --git a/packages/d-node-notif/src/lib/pushNotification/alias.ts b/packages/dnode/src/lib/pushNotification/alias.ts similarity index 75% rename from packages/d-node-notif/src/lib/pushNotification/alias.ts rename to packages/dnode/src/lib/pushNotification/alias.ts index 11df7472c..b9a197054 100644 --- a/packages/d-node-notif/src/lib/pushNotification/alias.ts +++ b/packages/dnode/src/lib/pushNotification/alias.ts @@ -6,7 +6,6 @@ import CONFIG, * as config from '../config'; import * as PUSH_ALIAS from '../alias'; import { PushNotificationBaseClass } from './pushNotificationBase'; - export class Alias extends PushNotificationBaseClass { constructor(signer?: SignerType, env?: ENV, account?: string) { super(signer, env, account); @@ -31,7 +30,10 @@ export class Alias extends PushNotificationBaseClass { * @param {AliasInfoOptions} options - options related to alias * @returns the transaction hash if the transaction is successfull */ - initiate = async (alias: string, options?: AliasInfoOptions): Promise => { + initiate = async ( + alias: string, + options?: AliasInfoOptions + ): Promise => { try { this.checkSignerObjectExists(); const networkDetails = await this.getChainId(this.signer!); @@ -48,14 +50,14 @@ export class Alias extends PushNotificationBaseClass { ); const addAliasRes = await this.initiateAddAlias(commContract, alias); - let resp: { [key: string]: any } = { tx: addAliasRes } + let resp: { [key: string]: any } = { tx: addAliasRes }; if (options?.raw) { - resp = { - ...resp, - "raw": { - "initiateVerificationProof": addAliasRes - } - } + resp = { + ...resp, + raw: { + initiateVerificationProof: addAliasRes, + }, + }; } return resp; } catch (error) { @@ -64,11 +66,11 @@ export class Alias extends PushNotificationBaseClass { }; /** - * @description verifies an alias address of a channel - * @param {string} channelAddress - channelAddress to be verified - * @param {AliasInfoOptions} options - options related to alias - * @returns the transaction hash if the transaction is successfull - */ + * @description verifies an alias address of a channel + * @param {string} channelAddress - channelAddress to be verified + * @param {AliasInfoOptions} options - options related to alias + * @returns the transaction hash if the transaction is successfull + */ verify = async (channelAddress: string, options?: AliasInfoOptions) => { try { this.checkSignerObjectExists(); @@ -85,16 +87,19 @@ export class Alias extends PushNotificationBaseClass { config.ABIS.COMM, config.VIEM_CONFIG[this.env!][caip].NETWORK ); - const { verifyAliasRes, channelInfo } = await this.verifyAlias(commContract, channelAddress); - let resp: { [key: string]: any } = { tx: verifyAliasRes } + const { verifyAliasRes, channelInfo } = await this.verifyAlias( + commContract, + channelAddress + ); + let resp: { [key: string]: any } = { tx: verifyAliasRes }; if (options?.raw) { - resp = { - ...resp, - "raw": { - "initiateVerificationProof": channelInfo.initiate_verification_proof, - "verifyVerificationProof": verifyAliasRes - } - } + resp = { + ...resp, + raw: { + initiateVerificationProof: channelInfo.initiate_verification_proof, + verifyVerificationProof: verifyAliasRes, + }, + }; } return resp; } catch (error) { diff --git a/packages/d-node-notif/src/lib/pushNotification/channel.ts b/packages/dnode/src/lib/pushNotification/channel.ts similarity index 100% rename from packages/d-node-notif/src/lib/pushNotification/channel.ts rename to packages/dnode/src/lib/pushNotification/channel.ts diff --git a/packages/d-node-notif/src/lib/pushNotification/delegate.ts b/packages/dnode/src/lib/pushNotification/delegate.ts similarity index 100% rename from packages/d-node-notif/src/lib/pushNotification/delegate.ts rename to packages/dnode/src/lib/pushNotification/delegate.ts diff --git a/packages/d-node-notif/src/lib/pushNotification/notification.ts b/packages/dnode/src/lib/pushNotification/notification.ts similarity index 100% rename from packages/d-node-notif/src/lib/pushNotification/notification.ts rename to packages/dnode/src/lib/pushNotification/notification.ts diff --git a/packages/d-node-notif/src/lib/pushNotification/pushNotificationBase.ts b/packages/dnode/src/lib/pushNotification/pushNotificationBase.ts similarity index 100% rename from packages/d-node-notif/src/lib/pushNotification/pushNotificationBase.ts rename to packages/dnode/src/lib/pushNotification/pushNotificationBase.ts diff --git a/packages/d-node-notif/src/lib/pushValidator/pushValidator.ts b/packages/dnode/src/lib/pushValidator/pushValidator.ts similarity index 100% rename from packages/d-node-notif/src/lib/pushValidator/pushValidator.ts rename to packages/dnode/src/lib/pushValidator/pushValidator.ts diff --git a/packages/d-node-notif/src/lib/pushValidator/pushValidatorTypes.ts b/packages/dnode/src/lib/pushValidator/pushValidatorTypes.ts similarity index 100% rename from packages/d-node-notif/src/lib/pushValidator/pushValidatorTypes.ts rename to packages/dnode/src/lib/pushValidator/pushValidatorTypes.ts diff --git a/packages/d-node-notif/src/lib/pushstream/DataModifier.ts b/packages/dnode/src/lib/pushstream/DataModifier.ts similarity index 100% rename from packages/d-node-notif/src/lib/pushstream/DataModifier.ts rename to packages/dnode/src/lib/pushstream/DataModifier.ts diff --git a/packages/d-node-notif/src/lib/pushstream/PushStream.ts b/packages/dnode/src/lib/pushstream/PushStream.ts similarity index 100% rename from packages/d-node-notif/src/lib/pushstream/PushStream.ts rename to packages/dnode/src/lib/pushstream/PushStream.ts diff --git a/packages/d-node-notif/src/lib/pushstream/pushStreamTypes.ts b/packages/dnode/src/lib/pushstream/pushStreamTypes.ts similarity index 100% rename from packages/d-node-notif/src/lib/pushstream/pushStreamTypes.ts rename to packages/dnode/src/lib/pushstream/pushStreamTypes.ts diff --git a/packages/d-node-notif/src/lib/pushstream/socketClient.ts b/packages/dnode/src/lib/pushstream/socketClient.ts similarity index 100% rename from packages/d-node-notif/src/lib/pushstream/socketClient.ts rename to packages/dnode/src/lib/pushstream/socketClient.ts diff --git a/packages/d-node-notif/src/lib/types/index.ts b/packages/dnode/src/lib/types/index.ts similarity index 100% rename from packages/d-node-notif/src/lib/types/index.ts rename to packages/dnode/src/lib/types/index.ts diff --git a/packages/d-node-notif/src/lib/user/auth.updateUser.ts b/packages/dnode/src/lib/user/auth.updateUser.ts similarity index 100% rename from packages/d-node-notif/src/lib/user/auth.updateUser.ts rename to packages/dnode/src/lib/user/auth.updateUser.ts diff --git a/packages/d-node-notif/src/lib/user/createUser.ts b/packages/dnode/src/lib/user/createUser.ts similarity index 100% rename from packages/d-node-notif/src/lib/user/createUser.ts rename to packages/dnode/src/lib/user/createUser.ts diff --git a/packages/d-node-notif/src/lib/user/createUserWithProfile.ts b/packages/dnode/src/lib/user/createUserWithProfile.ts similarity index 97% rename from packages/d-node-notif/src/lib/user/createUserWithProfile.ts rename to packages/dnode/src/lib/user/createUserWithProfile.ts index 6b031976e..d9a99a342 100644 --- a/packages/d-node-notif/src/lib/user/createUserWithProfile.ts +++ b/packages/dnode/src/lib/user/createUserWithProfile.ts @@ -37,12 +37,11 @@ export const createUserWithProfile = async ( signer: userOptions.signer, }); - user = await profileUpdate({ account: user.did, env: userOptions.env, pgpPrivateKey: pk, - profile: userOptions.profile + profile: userOptions.profile, }); } return user; diff --git a/packages/d-node-notif/src/lib/user/decryptAuth.ts b/packages/dnode/src/lib/user/decryptAuth.ts similarity index 100% rename from packages/d-node-notif/src/lib/user/decryptAuth.ts rename to packages/dnode/src/lib/user/decryptAuth.ts diff --git a/packages/d-node-notif/src/lib/user/getDelegations.ts b/packages/dnode/src/lib/user/getDelegations.ts similarity index 100% rename from packages/d-node-notif/src/lib/user/getDelegations.ts rename to packages/dnode/src/lib/user/getDelegations.ts diff --git a/packages/d-node-notif/src/lib/user/getFeeds.ts b/packages/dnode/src/lib/user/getFeeds.ts similarity index 100% rename from packages/d-node-notif/src/lib/user/getFeeds.ts rename to packages/dnode/src/lib/user/getFeeds.ts diff --git a/packages/d-node-notif/src/lib/user/getFeedsPerChannel.ts b/packages/dnode/src/lib/user/getFeedsPerChannel.ts similarity index 100% rename from packages/d-node-notif/src/lib/user/getFeedsPerChannel.ts rename to packages/dnode/src/lib/user/getFeedsPerChannel.ts diff --git a/packages/d-node-notif/src/lib/user/getSubscriptions.ts b/packages/dnode/src/lib/user/getSubscriptions.ts similarity index 100% rename from packages/d-node-notif/src/lib/user/getSubscriptions.ts rename to packages/dnode/src/lib/user/getSubscriptions.ts diff --git a/packages/d-node-notif/src/lib/user/getUser.ts b/packages/dnode/src/lib/user/getUser.ts similarity index 100% rename from packages/d-node-notif/src/lib/user/getUser.ts rename to packages/dnode/src/lib/user/getUser.ts diff --git a/packages/d-node-notif/src/lib/user/getUsersBatch.ts b/packages/dnode/src/lib/user/getUsersBatch.ts similarity index 100% rename from packages/d-node-notif/src/lib/user/getUsersBatch.ts rename to packages/dnode/src/lib/user/getUsersBatch.ts diff --git a/packages/d-node-notif/src/lib/user/index.ts b/packages/dnode/src/lib/user/index.ts similarity index 100% rename from packages/d-node-notif/src/lib/user/index.ts rename to packages/dnode/src/lib/user/index.ts diff --git a/packages/d-node-notif/src/lib/user/profile.updateUser.ts b/packages/dnode/src/lib/user/profile.updateUser.ts similarity index 100% rename from packages/d-node-notif/src/lib/user/profile.updateUser.ts rename to packages/dnode/src/lib/user/profile.updateUser.ts diff --git a/packages/d-node-notif/src/lib/user/upgradeUser.ts b/packages/dnode/src/lib/user/upgradeUser.ts similarity index 100% rename from packages/d-node-notif/src/lib/user/upgradeUser.ts rename to packages/dnode/src/lib/user/upgradeUser.ts diff --git a/packages/d-node-notif/src/lib/utils/axiosUtil.ts b/packages/dnode/src/lib/utils/axiosUtil.ts similarity index 100% rename from packages/d-node-notif/src/lib/utils/axiosUtil.ts rename to packages/dnode/src/lib/utils/axiosUtil.ts diff --git a/packages/d-node-notif/src/lib/utils/index.ts b/packages/dnode/src/lib/utils/index.ts similarity index 58% rename from packages/d-node-notif/src/lib/utils/index.ts rename to packages/dnode/src/lib/utils/index.ts index 476b78a58..2abb73f55 100644 --- a/packages/d-node-notif/src/lib/utils/index.ts +++ b/packages/dnode/src/lib/utils/index.ts @@ -1,4 +1,4 @@ /** * Only externally used Helpers */ -export * from './parseAPI'; \ No newline at end of file +export * from './parseAPI'; diff --git a/packages/d-node-notif/src/lib/utils/parseAPI.ts b/packages/dnode/src/lib/utils/parseAPI.ts similarity index 69% rename from packages/d-node-notif/src/lib/utils/parseAPI.ts rename to packages/dnode/src/lib/utils/parseAPI.ts index cb4f5ac07..0f4d00d43 100644 --- a/packages/d-node-notif/src/lib/utils/parseAPI.ts +++ b/packages/dnode/src/lib/utils/parseAPI.ts @@ -5,20 +5,22 @@ import { ApiNotificationType, ParsedResponseType } from '../types'; * @param {ApiNotificationType[]} response * @returns {ParsedResponseType[]} */ -export function parseApiResponse(response: ApiNotificationType[]): ParsedResponseType[] { +export function parseApiResponse( + response: ApiNotificationType[] +): ParsedResponseType[] { return response.map((apiNotification: ApiNotificationType) => { const { payload: { data: { - acta: cta = "", - amsg: bigMessage = "", - asub = "", - icon = "", - url = "", - sid = "", - app = "", - aimg = "", - secret = "" + acta: cta = '', + amsg: bigMessage = '', + asub = '', + icon = '', + url = '', + sid = '', + app = '', + aimg = '', + secret = '', }, notification, }, @@ -36,7 +38,7 @@ export function parseApiResponse(response: ApiNotificationType[]): ParsedRespons image: aimg, blockchain: source, notification, - secret + secret, }; }); -} \ No newline at end of file +} diff --git a/packages/d-node-notif/src/lib/utils/parseSettings.ts b/packages/dnode/src/lib/utils/parseSettings.ts similarity index 100% rename from packages/d-node-notif/src/lib/utils/parseSettings.ts rename to packages/dnode/src/lib/utils/parseSettings.ts diff --git a/packages/dnode/src/lib/utils/parseSubscribersAPI.ts b/packages/dnode/src/lib/utils/parseSubscribersAPI.ts new file mode 100644 index 000000000..5bb30682c --- /dev/null +++ b/packages/dnode/src/lib/utils/parseSubscribersAPI.ts @@ -0,0 +1,33 @@ +import { ApiSubscribersType, NotificationSettingType } from '../types'; +import { parseSettings } from './parseSettings'; +/** + * @description parse the response gotten from the API + * @param {ApiSubscribersType[]} response + * @returns {NotificationSettingType[]} + */ + +export type SubscriberResponse = { + itemcount: number; + subscribers: { + subscriber: string; + settings: NotificationSettingType[] | null; + }[]; +}; +export function parseSubscrbersApiResponse( + response: ApiSubscribersType +): SubscriberResponse { + const parsedSubscribers = response.subscribers.map( + (apisubscribers: { subscriber: string; settings: string | null }) => { + return { + subscriber: apisubscribers.subscriber, + settings: apisubscribers.settings + ? parseSettings(apisubscribers.settings) + : null, + }; + } + ); + return { + itemcount: response.itemcount, + subscribers: [...parsedSubscribers], + }; +} diff --git a/packages/d-node-notif/src/lib/utils/pasreSubscriptionAPI.ts b/packages/dnode/src/lib/utils/pasreSubscriptionAPI.ts similarity index 52% rename from packages/d-node-notif/src/lib/utils/pasreSubscriptionAPI.ts rename to packages/dnode/src/lib/utils/pasreSubscriptionAPI.ts index 6216c5023..b4686094a 100644 --- a/packages/d-node-notif/src/lib/utils/pasreSubscriptionAPI.ts +++ b/packages/dnode/src/lib/utils/pasreSubscriptionAPI.ts @@ -7,14 +7,18 @@ import { parseSettings } from './parseSettings'; */ export type SubscriptionResponse = { - channel: string, - user_settings: NotificationSettingType[] | null -} -export function parseSubscriptionsApiResponse(response: ApiSubscriptionType[]):SubscriptionResponse[] { + channel: string; + user_settings: NotificationSettingType[] | null; +}; +export function parseSubscriptionsApiResponse( + response: ApiSubscriptionType[] +): SubscriptionResponse[] { return response.map((apisubscription: ApiSubscriptionType) => { return { - channel: apisubscription.channel, - user_settings: apisubscription.user_settings? parseSettings(apisubscription.user_settings): null - } + channel: apisubscription.channel, + user_settings: apisubscription.user_settings + ? parseSettings(apisubscription.user_settings) + : null, + }; }); -} \ No newline at end of file +} diff --git a/packages/d-node-notif/src/lib/utils/populateIUser.ts b/packages/dnode/src/lib/utils/populateIUser.ts similarity index 100% rename from packages/d-node-notif/src/lib/utils/populateIUser.ts rename to packages/dnode/src/lib/utils/populateIUser.ts diff --git a/packages/d-node-notif/tests/.env.sample b/packages/dnode/tests/.env.sample similarity index 100% rename from packages/d-node-notif/tests/.env.sample rename to packages/dnode/tests/.env.sample diff --git a/packages/d-node-notif/tests/lib/aliasChains/arbitrum.test.ts b/packages/dnode/tests/lib/aliasChains/arbitrum.test.ts similarity index 100% rename from packages/d-node-notif/tests/lib/aliasChains/arbitrum.test.ts rename to packages/dnode/tests/lib/aliasChains/arbitrum.test.ts diff --git a/packages/d-node-notif/tests/lib/aliasChains/berachain.test.ts b/packages/dnode/tests/lib/aliasChains/berachain.test.ts similarity index 100% rename from packages/d-node-notif/tests/lib/aliasChains/berachain.test.ts rename to packages/dnode/tests/lib/aliasChains/berachain.test.ts diff --git a/packages/d-node-notif/tests/lib/aliasChains/optimism.test.ts b/packages/dnode/tests/lib/aliasChains/optimism.test.ts similarity index 100% rename from packages/d-node-notif/tests/lib/aliasChains/optimism.test.ts rename to packages/dnode/tests/lib/aliasChains/optimism.test.ts diff --git a/packages/d-node-notif/tests/lib/aliasChains/polygon.test.ts b/packages/dnode/tests/lib/aliasChains/polygon.test.ts similarity index 100% rename from packages/d-node-notif/tests/lib/aliasChains/polygon.test.ts rename to packages/dnode/tests/lib/aliasChains/polygon.test.ts diff --git a/packages/d-node-notif/tests/lib/aliasChains/polygonZkevm.test.ts b/packages/dnode/tests/lib/aliasChains/polygonZkevm.test.ts similarity index 100% rename from packages/d-node-notif/tests/lib/aliasChains/polygonZkevm.test.ts rename to packages/dnode/tests/lib/aliasChains/polygonZkevm.test.ts diff --git a/packages/d-node-notif/tests/lib/initialize/initialize.test.ts b/packages/dnode/tests/lib/initialize/initialize.test.ts similarity index 100% rename from packages/d-node-notif/tests/lib/initialize/initialize.test.ts rename to packages/dnode/tests/lib/initialize/initialize.test.ts diff --git a/packages/d-node-notif/tests/lib/notification/alias.test.ts b/packages/dnode/tests/lib/notification/alias.test.ts similarity index 100% rename from packages/d-node-notif/tests/lib/notification/alias.test.ts rename to packages/dnode/tests/lib/notification/alias.test.ts diff --git a/packages/d-node-notif/tests/lib/notification/channel.test.ts b/packages/dnode/tests/lib/notification/channel.test.ts similarity index 100% rename from packages/d-node-notif/tests/lib/notification/channel.test.ts rename to packages/dnode/tests/lib/notification/channel.test.ts diff --git a/packages/d-node-notif/tests/lib/notification/delegate.test.ts b/packages/dnode/tests/lib/notification/delegate.test.ts similarity index 100% rename from packages/d-node-notif/tests/lib/notification/delegate.test.ts rename to packages/dnode/tests/lib/notification/delegate.test.ts diff --git a/packages/d-node-notif/tests/lib/notification/notification.test.ts b/packages/dnode/tests/lib/notification/notification.test.ts similarity index 100% rename from packages/d-node-notif/tests/lib/notification/notification.test.ts rename to packages/dnode/tests/lib/notification/notification.test.ts diff --git a/packages/dnode/tests/lib/notification/tokenABI.ts b/packages/dnode/tests/lib/notification/tokenABI.ts new file mode 100644 index 000000000..c46216138 --- /dev/null +++ b/packages/dnode/tests/lib/notification/tokenABI.ts @@ -0,0 +1,709 @@ +export const abi = [ + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'Approval', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'delegator', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'fromDelegate', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'toDelegate', + type: 'address', + }, + ], + name: 'DelegateChanged', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'delegate', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'previousBalance', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'newBalance', + type: 'uint256', + }, + ], + name: 'DelegateVotesChanged', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'holder', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'weight', + type: 'uint256', + }, + ], + name: 'HolderWeightChanged', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'Transfer', + type: 'event', + }, + { + inputs: [], + name: 'DELEGATION_TYPEHASH', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'DOMAIN_TYPEHASH', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'PERMIT_TYPEHASH', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + ], + name: 'allowance', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'rawAmount', + type: 'uint256', + }, + ], + name: 'approve', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + ], + name: 'balanceOf', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'born', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'rawAmount', + type: 'uint256', + }, + ], + name: 'burn', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + { + internalType: 'uint32', + name: '', + type: 'uint32', + }, + ], + name: 'checkpoints', + outputs: [ + { + internalType: 'uint32', + name: 'fromBlock', + type: 'uint32', + }, + { + internalType: 'uint96', + name: 'votes', + type: 'uint96', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'decimals', + outputs: [ + { + internalType: 'uint8', + name: '', + type: 'uint8', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'delegatee', + type: 'address', + }, + ], + name: 'delegate', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'delegatee', + type: 'address', + }, + { + internalType: 'uint256', + name: 'nonce', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'expiry', + type: 'uint256', + }, + { + internalType: 'uint8', + name: 'v', + type: 'uint8', + }, + { + internalType: 'bytes32', + name: 'r', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 's', + type: 'bytes32', + }, + ], + name: 'delegateBySig', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'delegates', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + ], + name: 'getCurrentVotes', + outputs: [ + { + internalType: 'uint96', + name: '', + type: 'uint96', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'uint256', + name: 'blockNumber', + type: 'uint256', + }, + ], + name: 'getPriorVotes', + outputs: [ + { + internalType: 'uint96', + name: '', + type: 'uint96', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'holderDelegation', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'holderWeight', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'name', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'nonces', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'numCheckpoints', + outputs: [ + { + internalType: 'uint32', + name: '', + type: 'uint32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'rawAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + { + internalType: 'uint8', + name: 'v', + type: 'uint8', + }, + { + internalType: 'bytes32', + name: 'r', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 's', + type: 'bytes32', + }, + ], + name: 'permit', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'holder', + type: 'address', + }, + ], + name: 'resetHolderWeight', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'address', + name: 'delegate', + type: 'address', + }, + ], + name: 'returnHolderDelegation', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'returnHolderRatio', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'delegate', + type: 'address', + }, + { + internalType: 'bool', + name: 'value', + type: 'bool', + }, + ], + name: 'setHolderDelegation', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'symbol', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalSupply', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'dst', + type: 'address', + }, + { + internalType: 'uint256', + name: 'rawAmount', + type: 'uint256', + }, + ], + name: 'transfer', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'src', + type: 'address', + }, + { + internalType: 'address', + name: 'dst', + type: 'address', + }, + { + internalType: 'uint256', + name: 'rawAmount', + type: 'uint256', + }, + ], + name: 'transferFrom', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const; diff --git a/packages/d-node-notif/tests/lib/pushValidator/pushValidator.test.ts b/packages/dnode/tests/lib/pushValidator/pushValidator.test.ts similarity index 100% rename from packages/d-node-notif/tests/lib/pushValidator/pushValidator.test.ts rename to packages/dnode/tests/lib/pushValidator/pushValidator.test.ts diff --git a/packages/d-node-notif/tests/lib/utils/parseSettings.test.ts b/packages/dnode/tests/lib/utils/parseSettings.test.ts similarity index 100% rename from packages/d-node-notif/tests/lib/utils/parseSettings.test.ts rename to packages/dnode/tests/lib/utils/parseSettings.test.ts diff --git a/packages/d-node-notif/tests/lib/utils/parseSubscriptionAPI.test.ts b/packages/dnode/tests/lib/utils/parseSubscriptionAPI.test.ts similarity index 97% rename from packages/d-node-notif/tests/lib/utils/parseSubscriptionAPI.test.ts rename to packages/dnode/tests/lib/utils/parseSubscriptionAPI.test.ts index 3dda1e8dd..85206e726 100644 --- a/packages/d-node-notif/tests/lib/utils/parseSubscriptionAPI.test.ts +++ b/packages/dnode/tests/lib/utils/parseSubscriptionAPI.test.ts @@ -20,6 +20,6 @@ const testData = [ describe('Test parseSubscriptionsApiResponse', () => { it('Should succesfully parse the subscriptions', () => { const res = parseSubscriptionsApiResponse(testData); - console.log(JSON.stringify(res)) + console.log(JSON.stringify(res)); }); }); diff --git a/packages/d-node-notif/tests/loaders/envVerifier.ts b/packages/dnode/tests/loaders/envVerifier.ts similarity index 100% rename from packages/d-node-notif/tests/loaders/envVerifier.ts rename to packages/dnode/tests/loaders/envVerifier.ts diff --git a/packages/d-node-notif/tests/process-env.d.ts b/packages/dnode/tests/process-env.d.ts similarity index 66% rename from packages/d-node-notif/tests/process-env.d.ts rename to packages/dnode/tests/process-env.d.ts index 01c738239..afbff16dd 100644 --- a/packages/d-node-notif/tests/process-env.d.ts +++ b/packages/dnode/tests/process-env.d.ts @@ -1,5 +1,5 @@ declare namespace NodeJS { interface ProcessEnv { - readonly ENV: string + readonly ENV: string; } -} \ No newline at end of file +} diff --git a/packages/d-node-notif/tests/root.ts b/packages/dnode/tests/root.ts similarity index 69% rename from packages/d-node-notif/tests/root.ts rename to packages/dnode/tests/root.ts index 3e36df7a9..699fe6a89 100644 --- a/packages/d-node-notif/tests/root.ts +++ b/packages/dnode/tests/root.ts @@ -3,27 +3,30 @@ import * as path from 'path'; export const mochaHooks = { // This file is needed to end the test suite. - beforeAll: [ - async function () { + beforeAll: [ + async function () { // Load .env file - const envFound = dotenv.config({ path: path.resolve(__dirname, './.env')}) + const envFound = dotenv.config({ + path: path.resolve(__dirname, './.env'), + }); // check if .env exists if (!envFound) { console.log(' .env NOT FOUND '); process.exit(1); } else { // Check environment setup first - console.log(' Verifying ENV ') - const EnvVerifierLoader = (await require('./loaders/envVerifier')).default - await EnvVerifierLoader() - console.log(' ENV Verified / Generated and Loaded! ') + console.log(' Verifying ENV '); + const EnvVerifierLoader = (await require('./loaders/envVerifier')) + .default; + await EnvVerifierLoader(); + console.log(' ENV Verified / Generated and Loaded! '); } - }, - ], + }, + ], afterAll(done: () => void) { done(); console.log(' ALL TEST CASES EXECUTED '); process.exit(0); }, -}; \ No newline at end of file +}; diff --git a/packages/d-node-notif/tsconfig.json b/packages/dnode/tsconfig.json similarity index 100% rename from packages/d-node-notif/tsconfig.json rename to packages/dnode/tsconfig.json diff --git a/packages/d-node-notif/tsconfig.lib.json b/packages/dnode/tsconfig.lib.json similarity index 100% rename from packages/d-node-notif/tsconfig.lib.json rename to packages/dnode/tsconfig.lib.json diff --git a/packages/d-node-notif/tsconfig.mocha.json b/packages/dnode/tsconfig.mocha.json similarity index 57% rename from packages/d-node-notif/tsconfig.mocha.json rename to packages/dnode/tsconfig.mocha.json index d8df67126..90f48352c 100644 --- a/packages/d-node-notif/tsconfig.mocha.json +++ b/packages/dnode/tsconfig.mocha.json @@ -2,14 +2,12 @@ "extends": "./tsconfig.json", "ts-node": { "transpileOnly": true, - "esm": true, + "esm": true }, - + "compilerOptions": { "module": "commonjs", - "esModuleInterop": false, - }, - "exclude": [ - "node_modules" - ] -} \ No newline at end of file + "esModuleInterop": false + }, + "exclude": ["node_modules"] +} diff --git a/tsconfig.base.json b/tsconfig.base.json index 99d89699b..efe4352ac 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -21,7 +21,7 @@ "@pushprotocol/socket": ["packages/socket/src/index.ts"], "@pushprotocol/uiembed": ["packages/uiembed/src/index.ts"], "@pushprotocol/uiweb": ["packages/uiweb/src/index.ts"], - "@sdk/d-node-notif": ["packages/d-node-notif/src/index.ts"] + "@sdk/dnode": ["packages/dnode/src/index.ts"] } }, "exclude": ["node_modules", "tmp"] diff --git a/workspace.json b/workspace.json index b7001c5f5..b8411fa67 100644 --- a/workspace.json +++ b/workspace.json @@ -2,7 +2,7 @@ "$schema": "./node_modules/nx/schemas/workspace-schema.json", "version": 2, "projects": { - "d-node-notif": "packages/d-node-notif", + "dnode": "packages/dnode", "examples-sdk-frontend-react": "packages/examples/sdk-frontend-react", "ledgerlive": "packages/ledgerlive", "react-native-sdk": "packages/reactnative",