Skip to content

Commit f7fd2c5

Browse files
authored
Merge pull request #47 from IABTechLab/sas-UID2-6012-more-sample-pages
secure signals client-server
2 parents 54c4fe7 + 8e703c2 commit f7fd2c5

File tree

21 files changed

+156
-180
lines changed

21 files changed

+156
-180
lines changed

docker-compose.yml

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,44 @@
11
services:
2-
prebid-client:
2+
# javascript sdk integrations
3+
javascript-sdk-client-side:
34
build:
45
context: .
5-
dockerfile: web-integrations/prebid-integrations/client-side/Dockerfile
6+
dockerfile: web-integrations/javascript-sdk/client-side/Dockerfile
67
ports:
78
- "3031:3031"
8-
container_name: prebid-client-side
9+
container_name: javascript-sdk-client-side
910
env_file:
1011
- .env
11-
12-
# Add more services here as needed
13-
javascript-sdk-client-side:
12+
13+
javascript-sdk-client-server:
1414
build:
1515
context: .
16-
dockerfile: web-integrations/javascript-sdk/client-side/Dockerfile
16+
dockerfile: web-integrations/javascript-sdk/client-server/Dockerfile
1717
ports:
1818
- "3032:3032"
19-
container_name: javascript-sdk-client-side
19+
container_name: javascript-sdk-client-server
2020
env_file:
2121
- .env
2222

23-
# google-secure-signals-client:
24-
# build:
25-
# context: .
26-
# dockerfile: web-integrations/google-secure-signals/client-side/Dockerfile
27-
# ports:
28-
# - "3033:3033"
29-
# container_name: google-secure-signals-client
23+
# secure signals integrations
24+
google-secure-signals-client-server:
25+
build:
26+
context: .
27+
dockerfile: web-integrations/google-secure-signals/client-server/Dockerfile
28+
ports:
29+
- "3041:3041"
30+
container_name: google-secure-signals-client-server
31+
env_file:
32+
- .env
3033

31-
javascript-sdk-client:
34+
# prebid integrations
35+
prebid-client:
3236
build:
3337
context: .
34-
dockerfile: web-integrations/javascript-sdk/client-server/Dockerfile
38+
dockerfile: web-integrations/prebid-integrations/client-side/Dockerfile
3539
ports:
3640
- "3051:3051"
37-
container_name: javascript-sdk-client-server
41+
container_name: prebid-client-side
3842
env_file:
3943
- .env
44+

publisher/server_only/package-lock.json

Lines changed: 27 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

publisher/server_only/version.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

web-integrations/google-secure-signals/client-server/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

web-integrations/google-secure-signals/client-server/.gitkeep

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
FROM node:20.11-alpine3.18
1+
FROM node:20.11.0-alpine3.18
2+
23
WORKDIR /usr/src/app
3-
COPY . .
4+
5+
# Copy package files first for better caching
6+
COPY web-integrations/google-secure-signals/client-server/package*.json ./
47
RUN npm install
58

6-
RUN apk add --no-cache gettext
7-
RUN mv public/ads.js public/ads.js.template
8-
CMD /bin/sh -c "envsubst < public/ads.js.template > public/ads.js && npm start"
9+
# Copy application files
10+
COPY web-integrations/google-secure-signals/client-server/server.js ./
11+
COPY web-integrations/google-secure-signals/client-server/public ./public/
12+
COPY web-integrations/google-secure-signals/client-server/views ./views/
913

10-
EXPOSE 3000
14+
EXPOSE 3041
15+
CMD ["npm", "start"]

web-integrations/google-secure-signals/client-server/README.md

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,53 @@ For an example application without using the UID2 SDK, see [Server-Side UID2 Int
66

77
> NOTE: Although the server side of the example application is implemented in JavaScript using node.js, it is not a requirement. You can use any technology of your choice and refer to the example application for an illustration of the functionality that needs to be implemented.
88
9-
## Build and Run the Example Application
9+
## Running with Docker
10+
11+
### Using Docker Compose (Recommended)
12+
13+
From the base directory:
14+
15+
```bash
16+
# Start the service
17+
docker-compose up -d google-secure-signals-client
18+
19+
# View logs
20+
docker-compose logs google-secure-signals-client
21+
22+
# Stop the service
23+
docker-compose down google-secure-signals-client
24+
```
25+
26+
### Using Docker directly
27+
28+
From the base directory:
29+
30+
```bash
31+
# Build the image
32+
docker build -f web-integrations/google-secure-signals/client-server/Dockerfile -t google-secure-signals-client .
33+
34+
# Run the container
35+
docker run -p 3052:3052 --env-file .env google-secure-signals-client
36+
```
1037

1138
### Using the VS Code Debugger
1239

1340
The easiest way to try the example is to do the following:
1441

1542
1. Open this repo in VS Code
16-
1. Create a `.env` file in this folder and populate `UID2_API_KEY` and `UID2_CLIENT_SECRET`:
43+
1. Create a `.env` file in the base directory and populate the required variables:
1744
```
1845
UID2_BASE_URL=http://localhost:8080
1946
UID2_API_KEY=<your-integ-API-key>
2047
UID2_CLIENT_SECRET=<your-integ-client-secret>
2148
AD_TAG_URL=https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/extrernal/adx-test-tag&tfcd=0&npa=0&sz=640x480&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=
2249
UID2_JS_SDK_URL=http://localhost:9091/uid2-sdk.js
50+
PORT=3052
2351
```
2452
1. Click the Run and Debug tab or hit `Crtl+Shift+D`
2553
1. Select `Launch Secure Signals (Chrome)` from the configuration dropdown
2654
1. Click `Start Debugging` or hit F5
2755

28-
### Running the Docker commands manually
29-
30-
The other way to try the example is to use the following Docker Build command. First, open this folder in your terminal, then run the following:
31-
32-
```
33-
docker build . -t uid2-secure-signals-standard
34-
docker run -it --rm -p 3000:3000 `
35-
-e UID2_BASE_URL="https://operator-integ.uidapi.com" `
36-
-e UID2_API_KEY="<your-integ-API-key>" `
37-
-e UID2_CLIENT_SECRET="<your-integ-client-secret>" `
38-
-e AD_TAG_URL="https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/extrernal/adx-test-tag&tfcd=0&npa=0&sz=640x480&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=" `
39-
-e UID2_JS_SDK_URL="<your-JS-SDK-URL>" `
40-
uid2-secure-signals-standard
41-
```
42-
4356
The following table lists the environment variables that you must specify to start the application.
4457

4558
| Parameter | Data Type | Description |
@@ -56,7 +69,7 @@ Output similar to the following indicates that the example application is up and
5669
> [email protected] start /usr/src/app
5770
> node server.js
5871
59-
Example app listening at http://localhost:3000
72+
Example app listening at http://localhost:3052
6073
```
6174

6275
If needed, to close the application, terminate the Docker container or use the `Ctrl+C` keyboard shortcut.
@@ -67,7 +80,7 @@ The following table outlines and annotates the steps you can take to test and ex
6780

6881
| Step | Description | Comments |
6982
| :--: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
70-
| 1 | In your browser, navigate to the application main page at `http://localhost:3000`. | The displayed main ([index](views/index.html)) page of the example application provides a login form for the user to complete the UID2 login process.</br>IMPORTANT: A real-life application must also display a form for the user to consent to targeted advertising. |
83+
| 1 | In your browser, navigate to the application main page at `http://localhost:3052`. | The displayed main ([index](views/index.html)) page of the example application provides a login form for the user to complete the UID2 login process.</br>IMPORTANT: A real-life application must also display a form for the user to consent to targeted advertising. |
7184
| 2 | In the text field at the bottom, enter the email address that you want to use for testing and click **Generate UID2**. Note: The button may be labeled different here as it is a testing environment; in a real production environment, labels may differ. | The click calls the Secure Signal [`clearAllCache()`](https://developers.google.com/publisher-tag/reference#googletag.secureSignals.SecureSignalProvidersArray_clearAllCache) function, to clear all cached signals from local storage, and then calls the `/login` endpoint ([server.js](server.js)). The login initiated on the server side then calls the [POST /token/generate](https://unifiedid.com/docs/endpoints/post-token-generate#decrypted-json-response-format) endpoint and processes the received response. |
7285
| | A confirmation message appears with the established UID2 identity information. | The displayed identity information is the `body` property of the [JSON response payload](https://unifiedid.com/docs/endpoints/post-token-generate#decrypted-json-response-format) from the `POST /token/generate` response. It has been passed to the `login` [view](views/login.html) for rendering client-side JavaScript. Next, the identity information is passed to the UID2 SDK [`init()`](https://unifiedid.com/docs/sdks/sdk-ref-javascript#initopts-object-void) function. If the identity is valid, the SDK stores it either in local storage or a first-party UID2 cookie (see [UID2 Storage Format](https://unifiedid.com/docs/sdks/sdk-ref-javascript#uid2-storage-format) for use on subsequent page loads. |
7386
| 3 | Click the **Back to the main page** link. | On the updated application main page, note the newly populated **UID2 Advertising Token** value and a video player. While the [page view](views/index.html) is loading, [GPT](https://developers.google.com/publisher-tag/reference#googletag) auto-loads the Secure Signal UID2 script which pushes the advertising token to GPT local storage, and the [IMA](https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side) makes an ad request which transmits the encoded signal in the request. The [page view](views/index.html) calls the [init()](https://unifiedid.com/docs/sdks/sdk-ref-javascript#initopts-object-void) function again, but this time without passing an explicit identity. Instead, the identity is loaded from the first-party cookie. |

0 commit comments

Comments
 (0)