Skip to content

Commit

Permalink
feat: adjust to remote access connect approach (#1)
Browse files Browse the repository at this point in the history
* adjust to remote access connect approach

* setup pipeline

* fix build and adjust readme

* fix: ensure user has remote access permissions

* fix: no need to attach token if using oauth

* feat: add hint regarding broken compatibility with electron agent
BREAKING CHANGE: The way of establishing the WebRTC connection has changed and is no longer compatible with the old implementation.
  • Loading branch information
reey committed Mar 31, 2023
1 parent c0506a7 commit b28f511
Show file tree
Hide file tree
Showing 37 changed files with 46,851 additions and 11,401 deletions.
3 changes: 3 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["@commitlint/config-angular"]
}
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
dist/
42 changes: 42 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"root": true,
"ignorePatterns": ["projects/**/*"],
"overrides": [
{
"files": ["*.ts"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates",
"plugin:prettier/recommended" // <--- here we inherit from the recommended setup from eslint-plugin-prettier for TS
],
"rules": {},
"parserOptions": {
"project": ["tsconfig.json"]
}
},
{
"files": ["*.spec.ts"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates",
"plugin:prettier/recommended" // <--- here we inherit from the recommended setup from eslint-plugin-prettier for TS
],
"rules": {},
"parserOptions": {
"project": ["tsconfig.spec.json"]
}
},
{
"files": ["*.html"],
"extends": [
"plugin:@angular-eslint/template/recommended",
"plugin:prettier/recommended" // <--- here we inherit from the recommended setup from eslint-plugin-prettier for HTML
],
"rules": {}
}
]
}
100 changes: 0 additions & 100 deletions .github/workflows/ci.yml

This file was deleted.

54 changes: 54 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Pull request
on:
pull_request:

permissions:
contents: read
pull-requests: write

jobs:
build:
timeout-minutes: 15
runs-on: ubuntu-22.04
name: Build
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'npm'

- name: Install dependencies
run: npm ci

- uses: sibiraj-s/action-eslint@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
eslint-args: '--quiet'
extensions: 'html,ts'
annotations: true

- name: Run unit tests
run: |
npm run test
- name: Add commit hash to version
run: |
npm version prepatch --no-git-tag-version --preid $(git rev-parse --short HEAD)
- name: Build
run: npm run build:ci

- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: build
if-no-files-found: error
retention-days: 5
path: |
dist/apps/sag-ps-iot-pkg-webrtc-webcam-plugin/**
85 changes: 85 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Release
on:
push:
branches:
- main
- next
- beta
- '*.x'
- '*.*.x'

permissions:
contents: write
issues: write
pull-requests: write

jobs:
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 8
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Linting
run: npm run lint

- name: Build
run: npm run build:ci

- name: Zip build
run: |
cd dist/apps/sag-ps-iot-pkg-webrtc-webcam-plugin
zip -r -q ../../build.zip *
cd ../../..
rm -r dist/apps
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: build
if-no-files-found: error
retention-days: 5
path: |
dist/build.zip
release:
name: Release
runs-on: ubuntu-latest
needs: [build]
timeout-minutes: 8
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 'lts/*'

- name: Install dependencies
run: npm ci

- name: Download build
uses: actions/download-artifact@v3
with:
name: build

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit ${1}
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lint:staged --quiet
3 changes: 3 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"*.(ts|html)": "eslint"
}
11 changes: 11 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"singleQuote": true,
"overrides": [
{
"files": "*.html",
"options": {
"parser": "angular"
}
}
]
}
51 changes: 51 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"branches": [
"+([0-9])?(.{+([0-9]),x}).x",
"main",
"next",
"next-major",
{ "name": "beta", "prerelease": true },
{ "name": "alpha", "prerelease": true }
],
"tagFormat": "v${version}",
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
[
"@semantic-release/npm",
{
"npmPublish": false
}
],
[
"@semantic-release/git",
{
"assets": [
"CHANGELOG.md",
"package.json",
"package-lock.json",
"npm-shrinkwrap.json"
],
"message": "ci(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "bash ./replaceVersion.sh ${nextRelease.version}"
}
],
[
"@semantic-release/github",
{
"assets": [
{
"path": "sag-ps-iot-pkg-webrtc-webcam-plugin-*.zip"
}
]
}
]
],
"preset": "angular"
}
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ The plugin uses by default some [STUN servers](https://de.wikipedia.org/wiki/Ses
Depending on the firewall setup beteen the two peers it might happen that a peer-to-peer connection can not be established.
In that case a third party [TURN server](https://en.wikipedia.org/wiki/Traversal_Using_Relays_around_NAT) is required, where the video traffic passes through. You can host such a server on your own with e.g. [Coturn](https://github.com/coturn/coturn).

Have a look at the [cumulocity-electron-agent](https://github.com/SoftwareAG/cumulocity-electron-agent) for a sample device agent implementation supporting this feature.
Have a look at this [thin-edge extension](https://github.com/thin-edge/thin-edge.io_examples/pull/54) for a sample Cumulocity agent, that supports this feature.

Please note that this plugin will store **possible sensitive information** in form of e.g. **external and internal IP addresses** in Cumulocity operations in order to establish the peer-to-peer connection. A possible future solution to this could be to establish a websocket connection between the device and browser via a microservice to exchange those details without storing them in Cumulocity.
The plugin uses Cumulocity's remote-access-connect feature in `PASSTHROUGH` mode to establish a WebSocket connection between the browser and an WebRTC server like e.g. [go2rtc](https://github.com/AlexxIT/go2rtc) running on the device. Ensure that this microservice together with it's `PASSTHROUGH` mode is available on your Cumulocity tenant.

With the current set of changes this plugin is no longer compatible with the [electron-agent](https://github.com/SoftwareAG/cumulocity-electron-agent).

---

Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// jest.config.js
module.exports = {
preset: 'jest-preset-angular',
setupFilesAfterEnv: ['<rootDir>/setup-jest.js'],
setupFilesAfterEnv: ['<rootDir>/src/setup-jest.js'],
transformIgnorePatterns: ['/!node_modules\\/lodash-es/']
};

0 comments on commit b28f511

Please sign in to comment.