Skip to content

Commit

Permalink
fix(widget): set public API as default endpoint for the widget
Browse files Browse the repository at this point in the history
  • Loading branch information
psanders committed Nov 25, 2023
1 parent 2b9986d commit 9fe22f0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ SMTP_SENDER=Goodtok <info@example.com>
# SIP signaling config
DOCKER_HOST_ADDRESS=/* The public IP address of your Docker host */
SIP_DOMAIN=sip.goodtok.io
SIP_SIGNALING_SERVER=ws://sip.goodtok.io:5062
SIP_SIGNALING_SERVER=ws://localhost:5062

# Database and encryption config
POSTGRES_USER=postgres
Expand All @@ -100,7 +100,7 @@ In the website where you want to integrate Goodtok, you will need to add the fol
```html
<!-- Goodtok video client -->
<script
type="text/javascript"
type="module"
src="https://unpkg.com/@goodtok/widget?key=eyJndGlkIjoiZy00ZjkwZDEzYTQyIiwic2VydmVyIjoiaHR0cHM6Ly9hcGkuZ29vZHRvay5pby92MSJ9&token=OPTIONAL_CUSTOMER_TOKEN"
>
</script>
Expand All @@ -111,10 +111,10 @@ The key is a base64 encoded value containing the account `gtid` and `server` of

```bash
# The gtid corresponds to the workspace id in the Goodtok dashboard
echo -n '{"gtid":"g-4f90d13a42","server":"https://api.example.com/v1"}' | base64
echo -n '{"gtid":"g-7b7c46fb05","server":"http://localhost:6789/v1"}' | base64
```

If no server is specified, the client will use the default server at `api.goodtok.io`.
If no server is specified, the client will default to `https://api.goodtok.io/v1`.

The video widget will request an anonymous token from the server if none is provided. The server will generate a token only if the owner of the `gtid` has enabled anonymous access. The server will return an error if the owner has not allowed anonymous access.

Expand Down
2 changes: 1 addition & 1 deletion mods/widget/src/components/notification/Notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const NOTIFICATION_MESSAGES = {
[NotificationType.UNKNOWN_ERROR]: {
title: "Unexpected Error!",
description:
"Oops! Something unexpected happened and we couldn't process your request. Please try again later or contact support."
"Oops! Something unexpected happened and we couldn't process your request. Please try again later."
},
[NotificationType.PERMISSIONS_ERROR]: {
title: "Permissions Needed!",
Expand Down
2 changes: 1 addition & 1 deletion mods/widget/src/utils/getKeyFromSearchParam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function getKeyFromSearchParam(
searchParams: URLSearchParams,
key: string
) {
const searchParamsValue = searchParams.get("key");
const searchParamsValue = searchParams?.get("key");
if (!searchParamsValue) {
return null;
}
Expand Down
6 changes: 4 additions & 2 deletions mods/widget/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { getScriptParams } from "./getScriptParams";
* @return {string} token
*/
export function getCustomerToken(document: Document): string {
return getScriptParams(document).get("token");
return getScriptParams(document)?.get("token");
}

/**
Expand All @@ -37,7 +37,9 @@ export function getCustomerToken(document: Document): string {
*/
export function getAPIServer(document: Document): string {
const searchParams = getScriptParams(document);
return getKeyFromSearchParam(searchParams, "server");
return (
getKeyFromSearchParam(searchParams, "server") || "https://api.goodtok.io/v1"
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion site/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ <h2 class="h2 title">Questions? We’ve got answers<span class="accent-color">..
<!-- Goodtok video client -->
<script
type="module"
src="https://unpkg.com/@goodtok/widget@latest?key=eyJndGlkIjoiZy0xYjJjYjhmOGI2Iiwic2VydmVyIjoiaHR0cHM6Ly9hcGkuZ29vZHRvay5pby92MSJ9"
src="https://unpkg.com/@goodtok/widget@latest?key=eyJndGlkIjoiZy03YjdjNDZmYjA1In0="
>
</script>
<!-- Goodtok video client end -->
Expand Down

0 comments on commit 9fe22f0

Please sign in to comment.