@xmtp/browser-sdk 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +118 -0
- package/dist/index.d.ts +791 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/workers/client.js +2 -0
- package/dist/workers/client.js.map +1 -0
- package/dist/workers/utils.js +2 -0
- package/dist/workers/utils.js.map +1 -0
- package/package.json +101 -0
- package/src/Client.ts +181 -0
- package/src/ClientWorkerClass.ts +71 -0
- package/src/Conversation.ts +285 -0
- package/src/Conversations.ts +50 -0
- package/src/DecodedMessage.ts +71 -0
- package/src/Utils.ts +28 -0
- package/src/UtilsWorkerClass.ts +71 -0
- package/src/WorkerClient.ts +124 -0
- package/src/WorkerConversation.ts +169 -0
- package/src/WorkerConversations.ts +60 -0
- package/src/constants.ts +5 -0
- package/src/index.ts +9 -0
- package/src/types/clientEvents.ts +426 -0
- package/src/types/index.ts +4 -0
- package/src/types/options.ts +59 -0
- package/src/types/utils.ts +46 -0
- package/src/types/utilsEvents.ts +53 -0
- package/src/utils/conversions.ts +352 -0
- package/src/utils/createClient.ts +30 -0
- package/src/utils/date.ts +3 -0
- package/src/workers/client.ts +689 -0
- package/src/workers/utils.ts +72 -0
- package/tsconfig.json +11 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 XMTP (xmtp.org)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# XMTP client SDK for browsers
|
|
2
|
+
|
|
3
|
+
This package provides the XMTP client SDK for browsers.
|
|
4
|
+
|
|
5
|
+
To keep up with the latest SDK developments, see the [Issues tab](https://github.com/xmtp/xmtp-js/issues) in this repo.
|
|
6
|
+
|
|
7
|
+
To learn more about XMTP and get answers to frequently asked questions, see the [XMTP documentation](https://xmtp.org/docs).
|
|
8
|
+
|
|
9
|
+
> [!CAUTION]
|
|
10
|
+
> This SDK is currently in alpha. The API is subject to change and it is not yet recommended for production use.
|
|
11
|
+
|
|
12
|
+
## Requirements
|
|
13
|
+
|
|
14
|
+
### Response headers
|
|
15
|
+
|
|
16
|
+
Server response headers must be set to the following values:
|
|
17
|
+
|
|
18
|
+
- `Cross-Origin-Embedder-Policy: require-corp`
|
|
19
|
+
- `Cross-Origin-Opener-Policy: same-origin`
|
|
20
|
+
|
|
21
|
+
### Bundlers
|
|
22
|
+
|
|
23
|
+
This SDK uses a WebAssembly (WASM) module and bundlers must be configured properly to handle it.
|
|
24
|
+
|
|
25
|
+
#### Vite
|
|
26
|
+
|
|
27
|
+
Add the following to `vite.config.ts`:
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { defineConfig } from "vite";
|
|
31
|
+
|
|
32
|
+
// https://vitejs.dev/config/
|
|
33
|
+
export default defineConfig({
|
|
34
|
+
optimizeDeps: {
|
|
35
|
+
exclude: ["@xmtp/wasm-bindings"],
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
#### Next.js
|
|
41
|
+
|
|
42
|
+
Add the following to `next.config.mjs`:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
const nextConfig = {
|
|
46
|
+
serverComponentsExternalPackages: ["@xmtp/wasm-bindings"],
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default nextConfig;
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Install
|
|
53
|
+
|
|
54
|
+
**NPM**
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm install @xmtp/browser-sdk
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**PNPM**
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pnpm install @xmtp/browser-sdk
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Yarn**
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
yarn add @xmtp/browser-sdk
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Reference docs
|
|
73
|
+
|
|
74
|
+
Access the XMTP client browser SDK [reference documentation](TBD).
|
|
75
|
+
|
|
76
|
+
## Usage
|
|
77
|
+
|
|
78
|
+
Check out our [official documentation](https://xmtp.org/docs/build/get-started/overview) to get started developing with XMTP.
|
|
79
|
+
|
|
80
|
+
## XMTP network environments
|
|
81
|
+
|
|
82
|
+
XMTP provides `production`, `dev`, and `local` network environments to support the development phases of your project. To learn more about these environments, see our [official documentation](https://xmtp.org/docs/build/authentication#environments).
|
|
83
|
+
|
|
84
|
+
> **Important**
|
|
85
|
+
> When you [create a client](https://xmtp.org/docs/build/authentication#create-a-client), it connects to the XMTP `dev` environment by default. To learn how to use the `env` parameter to set your client's network environment, see [Configure the client](https://xmtp.org/docs/build/authentication#configure-the-client).
|
|
86
|
+
|
|
87
|
+
## Breaking revisions
|
|
88
|
+
|
|
89
|
+
Because this SDK is in active development, you should expect breaking revisions that might require you to adopt the latest SDK release to enable your app to continue working as expected.
|
|
90
|
+
|
|
91
|
+
XMTP communicates about breaking revisions in the [XMTP Discord community](https://discord.gg/xmtp), providing as much advance notice as possible. Additionally, breaking revisions in a release are described on the [Releases page](https://github.com/xmtp/xmtp-js/releases).
|
|
92
|
+
|
|
93
|
+
## Deprecation
|
|
94
|
+
|
|
95
|
+
Older versions of the SDK will eventually be deprecated, which means:
|
|
96
|
+
|
|
97
|
+
1. The network will not support and eventually actively reject connections from clients using deprecated versions.
|
|
98
|
+
2. Bugs will not be fixed in deprecated versions.
|
|
99
|
+
|
|
100
|
+
The following table provides the deprecation schedule.
|
|
101
|
+
|
|
102
|
+
| Announced | Effective | Minimum Version | Rationale |
|
|
103
|
+
| -------------------------------------------------------------- | --------- | --------------- | --------- |
|
|
104
|
+
| There are no deprecations scheduled for this SDK at this time. | | | |
|
|
105
|
+
|
|
106
|
+
Bug reports, feature requests, and PRs are welcome in accordance with these [contribution guidelines](https://github.com/xmtp/xmtp-js/blob/main/CONTRIBUTING.md).
|
|
107
|
+
|
|
108
|
+
## Developing
|
|
109
|
+
|
|
110
|
+
Run `yarn dev` to build the SDK and watch for changes, which will trigger a rebuild.
|
|
111
|
+
|
|
112
|
+
### Useful commands
|
|
113
|
+
|
|
114
|
+
- `yarn build`: Builds the SDK
|
|
115
|
+
- `yarn clean`: Removes `node_modules`, `dist`, and `.turbo` folders
|
|
116
|
+
- `yarn dev`: Builds the SDK and watches for changes, which will trigger a rebuild
|
|
117
|
+
- `yarn test`: Runs all tests
|
|
118
|
+
- `yarn typecheck`: Runs `tsc`
|