Skip to content

Commit 8c6e154

Browse files
rename folder and reorganize readme
1 parent 1fbaa6f commit 8c6e154

File tree

9 files changed

+13
-13
lines changed

9 files changed

+13
-13
lines changed

web-integrations/javascript-sdk/server-side/README.md renamed to web-integrations/javascript-sdk/server-side-node/README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ For more information on the JavaScript SDK, refer to the [UID2 SDK for JavaScrip
88
99
This example can be configured for either UID2 or EUID — the behavior is determined by your environment variable configuration. You cannot use both simultaneously.
1010

11-
## Key Benefits
11+
## How This Implementation Works
1212

13-
This example demonstrates the advantages of using the JavaScript SDK on the server:
13+
Unlike the browser where the SDK runs natively in the DOM, this example uses **jsdom** to simulate a browser environment within Node.js:
1414

15-
- **Secure credential handling**: Public credentials (server public key and subscription ID) remain on the server and are not exposed to the browser
16-
- **Simplified implementation**: The SDK handles the full token lifecycle including encryption, decryption, and refresh logic automatically
17-
- **No manual cryptography**: Unlike traditional server-side integrations, there's no need to manually implement encryption/decryption processes
15+
1. **Creates a virtual DOM**: Uses jsdom to provide `window`, `document`, and `navigator` objects that the SDK expects
16+
2. **Polyfills browser APIs**: Adds Node.js equivalents for Web Crypto API (`crypto.subtle`) and text encoding APIs (`TextEncoder`/`TextDecoder`)
17+
3. **Loads the SDK**: Fetches and executes the browser-based SDK code within the simulated environment
18+
4. **Runs SDK methods**: Calls `setIdentityFromEmail` just like in a browser, with the same public credentials
19+
20+
This demonstrates that the client-side SDK can be compatible with server-side Node.js environments when given the proper browser-like context.
1821

1922
## Build and Run the Example Application
2023

@@ -91,13 +94,10 @@ The following table outlines and annotates the steps you may take to test and ex
9194
| 3 | Review the displayed identity information. | The server reads the user session and extracts the current identity ([server.js](server.js)). The `advertising_token` on the identity can be used for targeted advertising. Note that the identity contains several timestamps that determine when the advertising token becomes invalid (`identity_expires`) and when the server should attempt to refresh it (`refresh_from`). The `verifyIdentity` function ([server.js](server.js)) uses the SDK to refresh the token as needed.<br/>The user is automatically logged out in the following cases:<br/>- If the identity expires without being refreshed and refresh attempt fails.<br/>- If the refresh token expires.<br/>- If the refresh attempt indicates that the user has opted out. |
9295
| 4 | To exit the application, click **Log Out**. | This calls the `/logout` endpoint on the server ([server.js](server.js)), which clears the session and presents the user with the login form again.<br/> NOTE: The page displays the **Log Out** button as long as the user is logged in. |
9396

94-
## How This Implementation Works
95-
96-
Unlike the browser where the SDK runs natively in the DOM, this example uses **jsdom** to simulate a browser environment within Node.js:
97+
## Key Benefits
9798

98-
1. **Creates a virtual DOM**: Uses jsdom to provide `window`, `document`, and `navigator` objects that the SDK expects
99-
2. **Polyfills browser APIs**: Adds Node.js equivalents for Web Crypto API (`crypto.subtle`) and text encoding APIs (`TextEncoder`/`TextDecoder`)
100-
3. **Loads the SDK**: Fetches and executes the browser-based SDK code within the simulated environment
101-
4. **Runs SDK methods**: Calls `setIdentityFromEmail` just like in a browser, with the same public credentials
99+
This example demonstrates the advantages of using the JavaScript SDK on the server:
102100

103-
This demonstrates that the client-side SDK is can be compatible with server-side Node.js environments when given the proper browser-like context.
101+
- **Secure credential handling**: Public credentials (server public key and subscription ID) remain on the server and are not exposed to the browser
102+
- **Simplified implementation**: The SDK handles the full token lifecycle including encryption, decryption, and refresh logic automatically
103+
- **No manual cryptography**: Unlike traditional server-side integrations, there's no need to manually implement encryption/decryption processes

0 commit comments

Comments
 (0)