Skip to content

Commit

Permalink
feat: js signaling client
Browse files Browse the repository at this point in the history
  • Loading branch information
PhearZero committed Apr 18, 2024
1 parent 68e6cab commit af6b7e7
Show file tree
Hide file tree
Showing 47 changed files with 1,757 additions and 3,059 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
swagger-codegen-cli.jar

.data
.idea

Expand Down
12 changes: 12 additions & 0 deletions client-gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@


CODEGEN=swagger-codegen-cli.jar
if [ -f $CODEGEN ]; then
echo "Codegen already exists"
else
echo "Downloading codegen"
wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.52/swagger-codegen-cli-3.0.52.jar -O swagger-codegen-cli.jar
fi

java -jar swagger-codegen-cli.jar generate -i http://localhost:3000/api-json -l typescript-fetch -o clients/liquid-auth-client-js/src/client
java -jar swagger-codegen-cli.jar generate -i http://localhost:3000/api-json -l kotlin-client -o clients/liquid-auth-client-kotlin
59 changes: 59 additions & 0 deletions clients/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Overview

Client JSON-RPC interfaces are generated from OpenAPI 3.0 specifications.
All clients should mirror the same interfaces and include the same parameters (as much as possible).

```typescript
interface SignalClient {
readonly url: string; // Origin of the service
type: "offer" | "answer" // Type of client
peerClient: RTCPeerConnection | PeerClient // Native WebRTC Wrapper/Interface
socket: Socket // The socket to the service

readonly authenticated: boolean; // State of authentication
readonly requestId?: string; // The current request being signaled

/**
* Generate a Request ID
*/
generateRequestId(): any;

/**
* Top level Friendly interface for signaling
* @param args
*/
peer(requestId: any, type: 'offer' | 'answer', config?: RTCConfiguration): Promise<void>;

/**
* Link a Request ID to this client
* @param args
*/
link(...args: any[]): Promise<LinkMessage>;

/**
* Wait for a desciption signal
* @param args
*/
signal(...args: any[]): Promise<string>;

/**
* Terminate the signaling session
*/
close(): void


/**
* Listen to Interface events
* @param args
*/
on(...args: any[]): void;

/**
* Emit an event to the interface
* @param channel
* @param callback
*/
emit(channel: string, callback: (...args: any[])=>void)

}
```
4 changes: 3 additions & 1 deletion clients/liquid-auth-client-js/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
"sourceType": "module"
},
"plugins": [
"@typescript-eslint/eslint-plugin"
"@typescript-eslint/eslint-plugin",
"eslint-plugin-tsdoc"
],
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"rules": {
"@typescript-eslint/no-explicit-any": "warn"
}
}
1 change: 1 addition & 0 deletions clients/liquid-auth-client-js/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
lib
docs

# Logs
logs
Expand Down
18 changes: 16 additions & 2 deletions clients/liquid-auth-client-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,23 @@
"./connect": {
"default": "./lib/connect.js",
"types": "./lib/connect.d.ts"
},
"./signal": {
"default": "./lib/signal.js",
"types": "./lib/signal.d.ts"
},
"./errors": {
"default": "./lib/errors.js",
"types": "./lib/errors.d.ts"
}
},
"scripts": {
"dev": "tsc --watch",
"build": "tsc",
"test": "tsc && node --test ./tests/connect.spec.js",
"test:cov": "tsc && c8 node --test ./tests/connect.spec.js"
"build:docs": "typedoc --plugin typedoc-plugin-markdown --out docs src",
"lint": "eslint --fix src",
"test": "tsc && node --test ./tests/*.spec.js",
"test:cov": "tsc && c8 node --test ./tests/*.spec.js"
},
"author": "",
"license": "MIT",
Expand All @@ -39,10 +49,14 @@
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-tsdoc": "^0.2.17",
"typedoc": "^0.25.13",
"typedoc-plugin-markdown": "^4.0.0-next.55",
"typescript": "^5.4.5"
},
"dependencies": {
"@liquid/core": "^1.0.0",
"eventemitter3": "^5.0.1",
"qr-code-styling": "^1.6.0-rc.1",
"tweetnacl": "^1.0.3"
}
Expand Down
1 change: 1 addition & 0 deletions clients/liquid-auth-client-js/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit af6b7e7

Please sign in to comment.