Skip to content

Commit

Permalink
fix: merged main to alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammeds1992 committed May 29, 2023
2 parents 8cdb999 + 3fff974 commit 067bc5d
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 126 deletions.
128 changes: 63 additions & 65 deletions packages/restapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,77 +7,77 @@ This package gives access to Push Protocol (Push Nodes) APIs. Visit [Developer D
- [How to use in your app?](#how-to-use-in-your-app)
- [Installation](#installation)
- [Import SDK](#import-sdk)
- [**About generating the "signer" object for different platforms**](#about-generating-the-signer-object-for-different-platforms)
- [About generating the "signer" object for different platforms](#about-generating-the-signer-object-for-different-platforms)
- [When using in SERVER-SIDE code:](#when-using-in-server-side-code)
- [When using in FRONT-END code:](#when-using-in-front-end-code)
- [**About blockchain agnostic address format**](#about-blockchain-agnostic-address-format)
- [About blockchain agnostic address format](#about-blockchain-agnostic-address-format)
- [Chat blockchain agnostic address format](#chat-blockchain-agnostic-address-format)
- [**About Push contract addresses**](#about-push-contract-addresses)
- [About Push contract addresses](#about-push-contract-addresses)
- [Push core contract address](#push-core-contract-address)
- [Push communicator contract address](#push-communicator-contract-address)
- [SDK Features](#sdk-features)
- [For Notification](#for-notification)
- [**Fetching user notifications**](#fetching-user-notifications)
- [**Fetching user spam notifications**](#fetching-user-spam-notifications)
- [**Fetching user subscriptions**](#fetching-user-subscriptions)
- [**Fetching channel details**](#fetching-channel-details)
- [**Searching for channel(s)**](#searching-for-channels)
- [**Opt in to a channel**](#opt-in-to-a-channel)
- [**Opt out to a channel**](#opt-out-to-a-channel)
- [**Sending notification**](#sending-notification)
- [**Direct payload for single recipient(target)**](#direct-payload-for-single-recipienttarget)
- [**Direct payload for group of recipients(subset)**](#direct-payload-for-group-of-recipientssubset)
- [**Direct payload for all recipients(broadcast)**](#direct-payload-for-all-recipientsbroadcast)
- [**IPFS payload for single recipient(target)**](#ipfs-payload-for-single-recipienttarget)
- [**IPFS payload for group of recipients(subset)**](#ipfs-payload-for-group-of-recipientssubset)
- [**IPFS payload for all recipients(broadcast)**](#ipfs-payload-for-all-recipientsbroadcast)
- [**Minimal payload for single recipient(target)**](#minimal-payload-for-single-recipienttarget)
- [**Minimal payload for a group of recipient(subset)**](#minimal-payload-for-a-group-of-recipientsubset)
- [**Minimal payload for all recipients(broadcast)**](#minimal-payload-for-all-recipientsbroadcast)
- [**Graph payload for single recipient(target)**](#graph-payload-for-single-recipienttarget)
- [**Graph payload for group of recipients(subset)**](#graph-payload-for-group-of-recipientssubset)
- [**Graph payload for all recipients(broadcast)**](#graph-payload-for-all-recipientsbroadcast)
- [Fetching user notifications](#fetching-user-notifications)
- [Fetching user spam notifications](#fetching-user-spam-notifications)
- [Fetching user subscriptions](#fetching-user-subscriptions)
- [Fetching channel details](#fetching-channel-details)
- [Searching for channel(s)](#searching-for-channels)
- [Opt in to a channel](#opt-in-to-a-channel)
- [Opt out to a channel](#opt-out-to-a-channel)
- [Sending notification](#sending-notification)
- [Direct payload for single recipient(target)](#direct-payload-for-single-recipienttarget)
- [Direct payload for group of recipients(subset)](#direct-payload-for-group-of-recipientssubset)
- [Direct payload for all recipients(broadcast)](#direct-payload-for-all-recipientsbroadcast)
- [IPFS payload for single recipient(target)](#ipfs-payload-for-single-recipienttarget)
- [IPFS payload for group of recipients(subset)](#ipfs-payload-for-group-of-recipientssubset)
- [IPFS payload for all recipients(broadcast)](#ipfs-payload-for-all-recipientsbroadcast)
- [Minimal payload for single recipient(target)](#minimal-payload-for-single-recipienttarget)
- [Minimal payload for a group of recipient(subset)](#minimal-payload-for-a-group-of-recipientsubset)
- [Minimal payload for all recipients(broadcast)](#minimal-payload-for-all-recipientsbroadcast)
- [Graph payload for single recipient(target)](#graph-payload-for-single-recipienttarget)
- [Graph payload for group of recipients(subset)](#graph-payload-for-group-of-recipientssubset)
- [Graph payload for all recipients(broadcast)](#graph-payload-for-all-recipientsbroadcast)
- [Notification Helper Utils](#notification-helper-utils)
- [**Parsing notifications**](#parsing-notifications)
- [Parsing notifications](#parsing-notifications)
- [Advanced Notifications (WIP)](#advanced-notifications-wip)
- [DEPRECATED](#deprecated)
- [**Get a channel's subscriber list of addresses**](#get-a-channels-subscriber-list-of-addresses)
- [Get a channel's subscriber list of addresses](#get-a-channels-subscriber-list-of-addresses)
- [For Chat](#for-chat)
- [**Create user for chat**](#create-user-for-chat)
- [**Get user data for chat**](#get-user-data-for-chat)
- [**Decrypting encrypted pgp private key from user data**](#decrypting-encrypted-pgp-private-key-from-user-data)
- [**Fetching list of user chats**](#fetching-list-of-user-chats)
- [**Fetching list of user chat requests**](#fetching-list-of-user-chat-requests)
- [**Fetching conversation hash between two users**](#fetching-conversation-hash-between-two-users)
- [**Fetching latest chat between two users**](#fetching-latest-chat-between-two-users)
- [**Fetching chat history between two users**](#fetching-chat-history-between-two-users)
- [**To send a message**](#to-send-a-message)
- [**To approve a chat request**](#to-approve-a-chat-request)
- [**To create a group**](#to-create-a-group)
- [**To update group details**](#to-update-group-details)
- [**To get group details by group name**](#to-get-group-details-by-group-name)
- [**To get group details by chatId**](#to-get-group-details-by-chatid)
- [**Chat Helper Utils**](#chat-helper-utils)
- [**Decrypting messages**](#decrypting-messages)
- [Create user for chat](#create-user-for-chat)
- [Get user data for chat](#get-user-data-for-chat)
- [Decrypting encrypted pgp private key from user data](#decrypting-encrypted-pgp-private-key-from-user-data)
- [Fetching list of user chats](#fetching-list-of-user-chats)
- [Fetching list of user chat requests](#fetching-list-of-user-chat-requests)
- [Fetching conversation hash between two users](#fetching-conversation-hash-between-two-users)
- [Fetching latest chat between two users](#fetching-latest-chat-between-two-users)
- [Fetching chat history between two users](#fetching-chat-history-between-two-users)
- [To send a message](#to-send-a-message)
- [To approve a chat request](#to-approve-a-chat-request)
- [To create a group](#to-create-a-group)
- [To update group details](#to-update-group-details)
- [To get group details by group name](#to-get-group-details-by-group-name)
- [To get group details by chatId](#to-get-group-details-by-chatid)
- [Chat Helper Utils](#chat-helper-utils)
- [Decrypting messages](#decrypting-messages)
- [For Video](#for-video)
- [**Instance Variables**](#instance-variables)
- [**peerInstance**](#peerinstance)
- [**signer**](#signer)
- [**chainId**](#chainid)
- [**pgpPrivateKey**](#pgpprivatekey)
- [**env**](#env)
- [**data**](#data)
- [**setData**](#setdata)
- [**Methods**](#methods)
- [**constructor**](#constructor)
- [**create**](#create)
- [**request**](#request)
- [**acceptRequest**](#acceptrequest)
- [**connect**](#connect)
- [**disconnect**](#disconnect)
- [**enableVideo**](#enablevideo)
- [**enableAudio**](#enableaudio)
- [**isInitiator**](#isinitiator)
- [Instance Variables](#instance-variables)
- [peerInstance](#peerinstance)
- [signer](#signer)
- [chainId](#chainid)
- [pgpPrivateKey](#pgpprivatekey)
- [env](#env)
- [data](#data)
- [setData](#setdata)
- [Methods](#methods)
- [constructor](#constructor)
- [create](#create)
- [request](#request)
- [acceptRequest](#acceptrequest)
- [connect](#connect)
- [disconnect](#disconnect)
- [enableVideo](#enablevideo)
- [enableAudio](#enableaudio)
- [isInitiator](#isinitiator)

# How to use in your app?
## Installation
Expand Down Expand Up @@ -3828,6 +3828,7 @@ Allowed Options (params with * are mandatory)
- This method is used to enable/disable the video (from ```data.local.stream```) for a push video call.
- Can be triggered on the initiator as well as receivers end.
- **Note -** If video was not enabled during ```create()``` then it will always remain off.
```typescript
export type EnableVideoInputOptions = {
state: boolean;
Expand All @@ -3847,6 +3848,7 @@ Allowed Options (params with * are mandatory)
- This method is used to enable/disable the audio (from ```data.local.stream```) for a push video call.
- Can be triggered on the initiator as well as receivers end.
- **Note -** If audio was not enabled during ```create()``` then it will always remain off.
```typescript
export type EnableAudioInputOptions = {
state: boolean;
Expand All @@ -3865,11 +3867,7 @@ Allowed Options (params with * are mandatory)
#### **isInitiator**
- This method is used to tell if the current peer is the initator of the push video call or not.
- Can be triggered on the initiator as well as receivers end.
```typescript
isInitiator(): boolean
```
Allowed Options (params with * are mandatory)
| Param | Type | Default | Remarks |
|----------|---------|---------|--------------------------------------------|
| - | - | - | - |
```
9 changes: 4 additions & 5 deletions packages/restapi/src/lib/chat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ export * from './chats';
export * from './chat';
export * from './requests';
export * from './send';
export * from "./conversationHash";
export * from './conversationHash';
export * from './approveRequest';
export * from './updateUser';
export * from './historicalMessages';
export * from './latestMessage';
export { decryptWithWalletRPCMethod } from "../helpers/crypto";
export { decryptPGPKey } from "../helpers/crypto";
export { decryptConversation } from "./helpers";
export { decryptWithWalletRPCMethod } from '../helpers/crypto';
export { decryptPGPKey } from '../helpers/crypto';
export { decryptConversation } from './helpers';
export * from './helpers/payloadHelper';
export * from './createGroup';
export * from './updateGroup';
Expand Down
40 changes: 0 additions & 40 deletions packages/restapi/src/lib/chat/updateUser.ts

This file was deleted.

9 changes: 9 additions & 0 deletions packages/socket/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [0.5.1](https://github.com/ethereum-push-notification-service/push-sdk/compare/socket-0.5.0...socket-0.5.1) (2023-05-22)


### Bug Fixes

* fixed nft socket ([#413](https://github.com/ethereum-push-notification-service/push-sdk/issues/413)) ([0d8c3ab](https://github.com/ethereum-push-notification-service/push-sdk/commit/0d8c3ab628ec29903bcc051254e5c54e94a2325e))



# [0.5.0](https://github.com/ethereum-push-notification-service/push-sdk/compare/socket-0.4.1...socket-0.5.0) (2023-04-27)


Expand Down
2 changes: 1 addition & 1 deletion packages/socket/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pushprotocol/socket",
"version": "0.5.0",
"version": "0.5.1",
"type": "commonjs",
"publishConfig": {
"registry": "https://registry.npmjs.org/"
Expand Down
45 changes: 30 additions & 15 deletions packages/socket/src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { ethers } from 'ethers';
import * as Constants from './constants';
import { ENV } from './constants';


export interface AddressValidatorsType {
[key: string]: ({ address } : { address: string }) => boolean;
[key: string]: ({ address }: { address: string }) => boolean;
}

export function isValidETHAddress(address: string) {
Expand All @@ -14,23 +13,39 @@ export function isValidETHAddress(address: string) {

const AddressValidators: AddressValidatorsType = {
// Ethereum
'eip155': ({ address } : { address: string }) => {
eip155: ({ address }: { address: string }) => {
return isValidETHAddress(address);
}
},
// Add other chains here
};

export const isValidCAIP10NFTAddress = (wallet: string): boolean => {
try {
const walletComponent = wallet.split(':');
return (
(walletComponent.length === 5 || walletComponent.length === 6) &&
walletComponent[0].toLowerCase() === 'nft' &&
!isNaN(Number(walletComponent[4])) &&
Number(walletComponent[4]) > 0 &&
!isNaN(Number(walletComponent[2])) &&
Number(walletComponent[2]) > 0 &&
ethers.utils.isAddress(walletComponent[3]) &&
walletComponent[1] === 'eip155'
);
} catch (err) {
return false;
}
};

export function validateCAIP(addressInCAIP: string) {
const [
blockchain,
networkId,
address
] = addressInCAIP.split(':');
const [blockchain, networkId, address] = addressInCAIP.split(':');

if (!blockchain) return false;
if (!networkId) return false;
if (!address) return false;

if (isValidCAIP10NFTAddress(addressInCAIP)) return true;

const validatorFn = AddressValidators[blockchain];

return validatorFn({ address });
Expand All @@ -47,13 +62,13 @@ export function getFallbackETHCAIPAddress(env: ENV, address: string) {
}

/**
* This helper
* This helper
* checks if a VALID CAIP
* return the CAIP
* else
* check if valid ETH
* return a CAIP representation of that address (EIP155 + env)
* else
* else
* throw error!
*/
export function getCAIPAddress(env: ENV, address: string, msg?: string) {
Expand All @@ -68,9 +83,9 @@ export function getCAIPAddress(env: ENV, address: string, msg?: string) {
}
}

export const walletToPCAIP10 = (account:string): string => {
export const walletToPCAIP10 = (account: string): string => {
if (account.includes('eip155:')) {
return account
return account;
}
return 'eip155:' + account
}
return 'eip155:' + account;
};

0 comments on commit 067bc5d

Please sign in to comment.