Skip to content

Commit 43f59cf

Browse files
committed
Initial commit
0 parents  commit 43f59cf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+4405
-0
lines changed

.gitignore

+175
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
2+
3+
# Logs
4+
5+
logs
6+
_.log
7+
npm-debug.log_
8+
yarn-debug.log*
9+
yarn-error.log*
10+
lerna-debug.log*
11+
.pnpm-debug.log*
12+
13+
# Caches
14+
15+
.cache
16+
17+
# Diagnostic reports (https://nodejs.org/api/report.html)
18+
19+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
20+
21+
# Runtime data
22+
23+
pids
24+
_.pid
25+
_.seed
26+
*.pid.lock
27+
28+
# Directory for instrumented libs generated by jscoverage/JSCover
29+
30+
lib-cov
31+
32+
# Coverage directory used by tools like istanbul
33+
34+
coverage
35+
*.lcov
36+
37+
# nyc test coverage
38+
39+
.nyc_output
40+
41+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
42+
43+
.grunt
44+
45+
# Bower dependency directory (https://bower.io/)
46+
47+
bower_components
48+
49+
# node-waf configuration
50+
51+
.lock-wscript
52+
53+
# Compiled binary addons (https://nodejs.org/api/addons.html)
54+
55+
build/Release
56+
57+
# Dependency directories
58+
59+
node_modules/
60+
jspm_packages/
61+
62+
# Snowpack dependency directory (https://snowpack.dev/)
63+
64+
web_modules/
65+
66+
# TypeScript cache
67+
68+
*.tsbuildinfo
69+
70+
# Optional npm cache directory
71+
72+
.npm
73+
74+
# Optional eslint cache
75+
76+
.eslintcache
77+
78+
# Optional stylelint cache
79+
80+
.stylelintcache
81+
82+
# Microbundle cache
83+
84+
.rpt2_cache/
85+
.rts2_cache_cjs/
86+
.rts2_cache_es/
87+
.rts2_cache_umd/
88+
89+
# Optional REPL history
90+
91+
.node_repl_history
92+
93+
# Output of 'npm pack'
94+
95+
*.tgz
96+
97+
# Yarn Integrity file
98+
99+
.yarn-integrity
100+
101+
# dotenv environment variable files
102+
103+
.env
104+
.env.development.local
105+
.env.test.local
106+
.env.production.local
107+
.env.local
108+
109+
# parcel-bundler cache (https://parceljs.org/)
110+
111+
.parcel-cache
112+
113+
# Next.js build output
114+
115+
.next
116+
out
117+
118+
# Nuxt.js build / generate output
119+
120+
.nuxt
121+
dist
122+
123+
# Gatsby files
124+
125+
# Comment in the public line in if your project uses Gatsby and not Next.js
126+
127+
# https://nextjs.org/blog/next-9-1#public-directory-support
128+
129+
# public
130+
131+
# vuepress build output
132+
133+
.vuepress/dist
134+
135+
# vuepress v2.x temp and cache directory
136+
137+
.temp
138+
139+
# Docusaurus cache and generated files
140+
141+
.docusaurus
142+
143+
# Serverless directories
144+
145+
.serverless/
146+
147+
# FuseBox cache
148+
149+
.fusebox/
150+
151+
# DynamoDB Local files
152+
153+
.dynamodb/
154+
155+
# TernJS port file
156+
157+
.tern-port
158+
159+
# Stores VSCode versions used for testing VSCode extensions
160+
161+
.vscode-test
162+
163+
# yarn v2
164+
165+
.yarn/cache
166+
.yarn/unplugged
167+
.yarn/build-state.yml
168+
.yarn/install-state.gz
169+
.pnp.*
170+
171+
# IntelliJ based IDEs
172+
.idea
173+
174+
# Finder (MacOS) folder config
175+
.DS_Store

bun.lockb

1.99 KB
Binary file not shown.

package.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "@session.js/bun-network",
3+
"version": "1.0.0",
4+
"module": "src/index.ts",
5+
"main": "dist/index.js",
6+
"types": "dist/index.d.ts",
7+
"author": "Viktor Shchelochkov <[email protected]> (https://hloth.dev)",
8+
"repository": {
9+
"type": "git",
10+
"url": "git+https://github.com/sessionjs/bun-network.git"
11+
},
12+
"bugs": {
13+
"url": "https://github.com/sessionjs/bun-network/issues"
14+
},
15+
"homepage": "https://github.com/sessionjs/bun-network#readme",
16+
"description": "Bun.sh network connector for @session.js/client",
17+
"type": "module",
18+
"files": [
19+
"dist/index.js",
20+
"dist/index.d.ts"
21+
],
22+
"scripts": {
23+
"build": "tsc --project tsconfig.build.json && cp src/signal-bindings/compiled.js dist/signal-bindings/compiled.js && cp src/signal-bindings/compiled.d.ts dist/signal-bindings/compiled.d.ts",
24+
"protobuf": "pbjs --target static-module --wrap es6 --out src/signal-bindings/compiled.js src/signal-bindings/signalservice.proto && pbts --out src/signal-bindings/compiled.d.ts src/signal-bindings/compiled.js --force-long"
25+
},
26+
"peerDependencies": {
27+
"typescript": "^5.0.0"
28+
},
29+
"dependencies": {
30+
"lodash": "^4.17.21"
31+
},
32+
"devDependencies": {
33+
"@types/lodash": "^4.17.7"
34+
}
35+
}

src/disappearing-message.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export type DisappearingMessageType = (typeof DisappearingMessageMode)[number];
2+
export declare const DisappearingMessageMode: readonly ["unknown", "deleteAfterRead", "deleteAfterSend"];

src/disappearing-message.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// NOTE this must match Content.ExpirationType in the protobuf
2+
export type DisappearingMessageType = (typeof DisappearingMessageMode)[number];
3+
export const DisappearingMessageMode = ['unknown', 'deleteAfterRead', 'deleteAfterSend'] as const

src/enums.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export type PickEnum<T, K extends T> = {
2+
[P in keyof K]: P extends K ? P : never;
3+
};

src/enums.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export type PickEnum<T, K extends T> = {
2+
[P in keyof K]: P extends K ? P : never;
3+
};

src/envelope.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { SignalService } from './signal-bindings';
2+
export interface EnvelopePlus extends Omit<SignalService.Envelope, 'toJSON'> {
3+
senderIdentity: string;
4+
receivedAt: number;
5+
id: string;
6+
}

src/envelope.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { SignalService } from './signal-bindings'
2+
3+
export interface EnvelopePlus extends Omit<SignalService.Envelope, 'toJSON'> {
4+
senderIdentity: string;
5+
receivedAt: number;
6+
id: string;
7+
}

src/index.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { SnodeNamespaces } from './namespaces';
2+
export type { Network } from './network';
3+
export type { Storage } from './storage';

src/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { SnodeNamespaces } from './namespaces'
2+
export type { Network } from './network'
3+
export type { Storage } from './storage'

src/namespaces.d.ts

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import type { PickEnum } from './enums';
2+
export declare enum SnodeNamespaces {
3+
/**
4+
* This is the namespace anyone can deposit a message for us
5+
*/
6+
UserMessages = 0,
7+
/**
8+
* This is the namespace used to sync our profile
9+
*/
10+
UserProfile = 2,
11+
/**
12+
* This is the namespace used to sync our contacts
13+
*/
14+
UserContacts = 3,
15+
/**
16+
* This is the namespace used to sync our volatile info (currently read status only)
17+
*/
18+
ConvoInfoVolatile = 4,
19+
/**
20+
* This is the namespace used to sync our user groups and communities
21+
*/
22+
UserGroups = 5,
23+
/** **THIS IS LEGACY AND SHOULD BE USED unless you know how to deal with legacy closed groups**. Use UserGroups instead.
24+
* The messages sent to a closed group are sent and polled from this namespace
25+
*/
26+
ClosedGroupMessage = -10
27+
}
28+
/**
29+
* Returns true if that namespace is associated with the config of a user (not his messages, only configs)
30+
*/
31+
declare function isUserConfigNamespace(namespace: SnodeNamespaces): boolean;
32+
export type SnodeNamespacesGroup = PickEnum<SnodeNamespaces, SnodeNamespaces.ClosedGroupMessage>;
33+
export type SnodeNamespacesUser = PickEnum<SnodeNamespaces, SnodeNamespaces.UserContacts | SnodeNamespaces.UserProfile | SnodeNamespaces.UserMessages>;
34+
declare function maxSizeMap(namespaces: Array<SnodeNamespaces>): {
35+
namespace: SnodeNamespaces;
36+
maxSize: number;
37+
}[];
38+
export declare const SnodeNamespace: {
39+
isUserConfigNamespace: typeof isUserConfigNamespace;
40+
maxSizeMap: typeof maxSizeMap;
41+
};
42+
export {};

0 commit comments

Comments
 (0)