Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Samples cleanup #261

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api-csharp/samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ to launch verifications.

## Setup

At this repository's root run `npm ci`. This sample depends on the `ui-web` sample. It serves static files generated by that application. So before you run this, make sure to run `npm run build` inside the
[`ui-web/samples`](../../ui-web/samples/) folder.
This sample depends on the `ui-web` sample. It serves static files generated by that application. So before you run this, make sure to run `npm install` and `npm run build` inside the
[`ui-web/samples`](../../../ui-web/samples/) folder.

### Running the project

Expand Down
4 changes: 2 additions & 2 deletions api-go/samples/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ to launch verifications.

## Setup

At this repository's root run `npm ci`. This sample depends on the `ui-web` sample. It serves static files generated by that application. So before you run this, make sure to run `npm run build` inside the
[`ui-web/samples`](../../ui-web/samples/) folder.
This sample depends on the `ui-web` sample. It serves static files generated by that application. So before you run this, make sure to run `npm install` and `npm run build` inside the
[`ui-web/samples`](../../../ui-web/samples/) folder.

### Running the project

Expand Down
4 changes: 2 additions & 2 deletions api-java/samples/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ to launch verifications.

## Setup

At this repository's root run `npm ci`. This sample depends on the `ui-web` sample. It serves static files generated by that application. So before you run this, make sure to run `npm run build` inside the
[`ui-web/samples`](../../ui-web/samples/) folder.
This sample depends on the `ui-web` sample. It serves static files generated by that application. So before you run this, make sure to run `npm install` and `npm run build` inside the
[`ui-web/samples`](../../../ui-web/samples/) folder.

### Running the project

Expand Down
4 changes: 1 addition & 3 deletions api-php/samples/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ to launch verifications.

## Setup

At this repository's root run `npm ci`. This sample depends on the `ui-web` sample. It serves static files generated by that application. So before you run this, make sure to run the [`build-sdk.ps1`](../build-sdk.ps1) inside the `api-php` folder. (You will need to have powershell installed.)

Alternatively, you can run `npm run build` inside the [`ui-web/samples`](../../ui-web/samples/) folder, and then copy the contents of the generated `dist` directory into `api-php/samples/public`.
This sample depends on the `ui-web` sample. It serves static files generated by that application. So before you run this, make sure to run `npm install` and `npm run build` inside the [`ui-web/samples`](../../../ui-web/samples/) folder, and then copy the contents of the generated `dist` directory into `api-php/samples/server/public`.

### Running the project

Expand Down
4 changes: 2 additions & 2 deletions api-python/samples/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ to launch verifications.

## Setup

At this repository's root run `npm ci`. This sample depends on the `ui-web` sample. It serves static files generated by that application. So before you run this, make sure to run `npm run build` inside the
[`ui-web/samples`](../../ui-web/samples/) folder.
This sample depends on the `ui-web` sample. It serves static files generated by that application. So before you run this, make sure to run `npm install` and `npm run build` inside the
[`ui-web/samples`](../../../ui-web/samples/) folder.

### Running the project

Expand Down
4 changes: 2 additions & 2 deletions api-ruby/samples/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ to launch verifications.

## Setup

At this repository's root run `npm ci`. This sample depends on the `ui-web` sample. It serves static files generated by that application. So before you run this, make sure to run `npm run build` inside the
[`ui-web/samples`](../../ui-web/samples/) folder.
This sample depends on the `ui-web` sample. It serves static files generated by that application. So before you run this, make sure to run `npm install` and `npm run build` inside the
[`ui-web/samples`](../../../ui-web/samples/) folder.

### Running the project

Expand Down
5 changes: 0 additions & 5 deletions api-typescript/samples/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ to launch verifications.

## Setup

At this repository's root run `npm ci`. This sample depends on the `ui-web` sample. It serves static files generated by that application. So before you run this, make sure to run `npm run build` inside the
[`ui-web/samples`](../../ui-web/samples/) folder.

### Running the project

Run `npm ci` to install the necessary dependencies.

Create a new `.env` file to set your Trinsic Access Token. You can use [`example.env`](./example.env) as a reference. If you need more information where to find this token, visit our [Getting Started](https://docs.trinsic.id/docs/getting-started-with-trinsic-connect) guide.
Expand Down
2 changes: 1 addition & 1 deletion api-typescript/samples/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "index.js",
"scripts": {
"prestart": "cd ../../ui-web/samples && npm run build && cd ../../api-typescript/samples",
"prestart": "cd ../../../ui-web/samples && npm ci && npm run build && cd ../../api-typescript/samples",
"start": "ts-node-dev --respawn --transpile-only --env-file=.env -- src/index.ts",
"build": "tsc"
},
Expand Down
20 changes: 14 additions & 6 deletions ui-web/samples/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,26 @@ function getProviders() {
})
.then((response) => response.json())
.then((r) => {
for (let i = 0; i < r.providers.length; i++) {
document.getElementById("listOptions").innerHTML +=
`<li><button class="launch-button" style="padding: 10px; background-color: transparent;" onclick="launchPopupMethod('${r.providers[i].id}').then(r => exchangeResult(r))"> <img src="${r.providers[i].logoUrl}" /> <div class="launch-name"> Launch ${r.providers[i].name}</div> <div class="chevron"></div></button></li>`;
const providers = r.providers.filter(
(provider) => provider.id !== "document-scan"
);

for (let i = 0; i < providers.length; i++) {
document.getElementById(
"listOptions"
).innerHTML += `<li><button class="launch-button" style="padding: 10px; background-color: transparent;" onclick="launchPopupMethod('${providers[i].id}').then(r => exchangeResult(r))"> <img src="${providers[i].logoUrl}" /> <div class="launch-name"> Launch ${providers[i].name}</div> <div class="chevron"></div></button></li>`;
}
});
}

async function launchPopupMethod(provider) {
return launchPopup(
async () => `launch/${provider}?redirectUrl=${window.location.origin}/redirect`
async () =>
`launch/${provider}?redirectUrl=${window.location.origin}/redirect`
);
}

createUrl();
getProviders();
if (window.location.pathname !== "/redirect") {
createUrl();
getProviders();
}
11 changes: 9 additions & 2 deletions ui-web/samples/redirect.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Trinsic redirect</title>
</head>
<body>
<script type="module" src="./main.js"></script>
<script type="module">
const params = new URLSearchParams(window.location.search);
const data = {
success: params.get("success") === "true" ? true : false,
resultsAccessKey: params.get("resultsAccessKey"),
sessionId: params.get("sessionId"),
};

console.debug("Sending message to opener", data, window.opener);

window.opener?.postMessage(data, "*");
if (window.opener) {
window.opener?.postMessage(data, "*");
} else {
exchangeResult(data);
}
</script>
<noscript>
<p>This page requires JavaScript to work properly.</p>
</noscript>
<div>Completing the flow</div>
<pre id="results"></pre>
</body>
</html>