open-index/open-npm huggingface dataset:
npm package: @ion-gateway/isomorphic-eventsource
Description: This package provides `EventSource` applicable in different environments (browser & NodeJS).
Author: ionconnect
Latest version: 0.0.2

# @ion-gateway/isomorphic-eventsource

This package provides `EventSource` applicable in different environments (browser & NodeJS).

## Get started
`npm i @ion-gateway/isomorphic-eventsource`

## How to use
Just import the package and use global `EventSource` constructor:

```ts
import '@ion-gateway/isomorphic-eventsource';

const eventSourceInstance = new EventSource();
```

That will work in both browser and NodeJS.

## How does it work
This package exports an empty script if bundler creates browser-compatible build. 
When package is imported in NodeJS environment, it assigns an `EventSource` imported from the `eventsource` package to the `global` variable.

Note that this package doesn't provide an `EventSource` polyfill for browsers which doesn't support `EventSource` natively.
npm package: @ion-gateway/isomorphic-fetch
Description: This package provides `fetch` applicable in different environments (browser & NodeJS).
Author: ionconnect
Latest version: 0.0.3

# @ion-gateway/isomorphic-fetch

This package provides `fetch` applicable in different environments (browser & NodeJS).

## Get started
`npm i @ion-gateway/isomorphic-fetch`

## How to use
Just import the package and use global `fetch` function:

```ts
import '@ion-gateway/isomorphic-fetch';

const result = await fetch('https://example.com');
```

That will work in both browser and NodeJS.

## How does it work
This package exports an empty script if bundler creates browser-compatible build.
When package is imported in NodeJS environment, it assigns an `fetch` imported from the `node-fetch` package to the `global` variable.

Note that this package doesn't provide an `fetch` polyfill for browsers which doesn't support `fetch` natively.
npm package: @ion-gateway/protocol
Description: ℹ️ If you want to integrate TonConnect to your dApp, you should use [@ion-gateway/sdk](https://www.npmjs.com/package/@ion-gateway/sdk)
Author: ionconnect
Latest version: 2.2.7

# ION Gateway protocol models

ℹ️ If you want to integrate TonConnect to your dApp, you should use [@ion-gateway/sdk](https://www.npmjs.com/package/@ion-gateway/sdk)

[Latest API documentation](https://ion-gateway.github.io/sdk/modules/_ionconnect_protocol.html)

## Summary
Package contains protocol requests, responses and event models and encoding, decoding functions.

You can use it to integrate TonConnect to your wallet app (written with TypeScript).

## Get started

### Install package
`npm i @ion-gateway/protocol`

### Use protocol models in your app

```ts
import { AppRequest, RpcMethod, WalletResponse } from '@ion-gateway/protocol';

function myWalletAppRequestsHandler<T extends RpcMethod>(request: AppRequest<T>): Promise<WalletResponse<T>> {
    // handle request, ask the user for a confirmation and return WalletResponse
}

```

### Use protocol cryptography in your app

```ts
import { SessionCrypto, WalletMessage, Base64, hexToByteArray } from '@ion-gateway/protocol';

function encodeIncommingHTTPBridgeRequest(encryptedMessage: string, from: string): WalletMessage {
    const sessionCrypto = new SessionCrypto(yourStoredSessionReypair);

    const decryptedMessage =
        sessionCrypto.decrypt(
            Base64.decode(bridgeIncomingMessage.message).toUint8Array(),
            hexToByteArray(bridgeIncomingMessage.from)
        );
    
    return  JSON.parse(decryptedMessage);
}
```