Skip to content

Commit 66ae909

Browse files
Merge pull request #15 from fingerprintjs/rc
Release v0.2.0-rc.1
2 parents 6606640 + 5680cef commit 66ae909

21 files changed

+368
-158
lines changed

.github/workflows/mock-e2e-pr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
with:
5959
verbose: true
6060
env:
61-
CONFIG_STORE_NAME: "E2ETest"
61+
STORE_NAME_PREFIX: "E2ETest"
6262
- name: Deploy
6363
id: deploy
6464
env:
@@ -67,7 +67,7 @@ jobs:
6767
FASTLY_API_TOKEN: ${{secrets.FASTLY_API_TOKEN}}
6868
FPJS_BACKEND_URL: ${{secrets.MOCK_FPCDN}}
6969
FPCDN_URL: ${{secrets.MOCK_FPCDN}}
70-
CONFIG_STORE_NAME: "E2ETest"
70+
STORE_NAME_PREFIX: "E2ETest"
7171
run: pnpm run ci
7272
- name: Wait for 60s
7373
shell: bash

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
## [0.2.0-rc.2](https://github.com/fingerprintjs/fingerprint-pro-fastly-compute-proxy-integration/compare/v0.2.0-rc.1...v0.2.0-rc.2) (2024-11-08)
2+
3+
4+
### Features
5+
6+
* move proxy secret to secret store ([b943878](https://github.com/fingerprintjs/fingerprint-pro-fastly-compute-proxy-integration/commit/b94387882bd4d485733faa6cc712ee6e298d6e58))
7+
* show all configurations on status page ([e996354](https://github.com/fingerprintjs/fingerprint-pro-fastly-compute-proxy-integration/commit/e9963545ae6be1fa44e2fa41ef74306067e6a75e))
8+
9+
## [0.2.0-rc.1](https://github.com/fingerprintjs/fingerprint-pro-fastly-compute-proxy-integration/compare/v0.1.0...v0.2.0-rc.1) (2024-11-05)
10+
11+
12+
### Features
13+
14+
* add prefix to config store name ([3838318](https://github.com/fingerprintjs/fingerprint-pro-fastly-compute-proxy-integration/commit/38383186439c5b1f7362b7462ea1a578287a59e3))
15+
116
## [0.1.0](https://github.com/fingerprintjs/fingerprint-pro-fastly-compute-proxy-integration/compare/v0.0.0...v0.1.0) (2024-10-29)
217

318

README.md

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,29 @@ The Fastly Compute Proxy Integration is responsible for proxying identification
3030

3131
## Getting started
3232

33-
This is a quick overview of the installation setup. For detailed step-by-step instructions, see the [Fastly Compute proxy integration guide in our documentation](https://dev.fingerprint.com/docs/fastly-compute-edge-proxy-integration).
33+
This is a quick overview of the installation setup. For detailed step-by-step instructions, see the [Fastly Compute proxy integration guide in our documentation](https://dev.fingerprint.com/docs/fastly-compute-proxy-integration).
3434

3535
1. Go to the Fingerprint Dashboard > [**API Keys**](https://dashboard.fingerprint.com/api-keys) and click **Create Proxy Key** to create a proxy secret. You will use it later to authenticate your requests to Fingerprint APIs.
3636

37-
2. [Create a Config store](https://docs.fastly.com/en/guides/working-with-config-stores#creating-a-config-store) in your Fastly account named exactly `Fingerprint` and add the following values:
37+
2. [Create an empty Compute Service](https://docs.fastly.com/en/guides/working-with-compute-services#creating-a-new-compute-service) in your Fastly account.
3838

39-
| Key | Example Value | Description |
40-
|------------------------------|----------------------|---------------------------------------------------------------------------------------------|
41-
| PROXY_SECRET | 6XI9CLf3C9oHSB12TTaI | Fingerprint proxy secret generated in Step 1. |
42-
| OPEN_CLIENT_RESPONSE_ENABLED | false | Set to `true` if you have [Open client response](https://dev.fingerprint.com/docs/open-client-response) enabled for your Fingerprint application. Defaults to `false`. |
43-
| AGENT_SCRIPT_DOWNLOAD_PATH | z5kms2 | Random path segment for downloading the JavaScript agent. |
44-
| GET_RESULT_PATH | nocmjw | Random path segment for Fingerprint identification requests. |
39+
3. [Create a Config store](https://docs.fastly.com/en/guides/working-with-config-stores#creating-a-config-store) named `Fingerprint_Compute_Config_Store_<SERVICE_ID>`, where the suffix is your proxy integration's [Compute Service ID](https://docs.fastly.com/en/guides/about-services). Add the following values:
4540

46-
3. Go to [Releases](https://github.com/fingerprintjs/fingerprint-pro-fastly-compute-proxy-integration/releases) to download the latest `fingerprint-proxy-integration.tar.gz` package file.
47-
4. Upload package to your Fastly Compute Service's **Package**.
48-
5. Configure the Fingerprint [JavaScript Agent](https://dev.fingerprint.com/docs/install-the-javascript-agent#configuring-the-agent) on your website using the paths defined in Step 2.
41+
| Key | Example Value | Description |
42+
| ---------------------------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
43+
| AGENT_SCRIPT_DOWNLOAD_PATH | z5kms2 | Random path segment for downloading the JavaScript agent. |
44+
| GET_RESULT_PATH | nocmjw | Random path segment for Fingerprint identification requests. |
45+
| OPEN_CLIENT_RESPONSE_PLUGINS_ENABLED | false | Set to `true` if you have [Open client response](https://dev.fingerprint.com/docs/open-client-response) enabled for your Fingerprint application. Defaults to `false`. |
46+
47+
4. [Create a Secret store](https://docs.fastly.com/en/guides/working-with-secret-stores#creating-a-secret-store) named `Fingerprint_Compute_Secret_Store_<SERVICE_ID>`, where the suffix is your proxy integration's [Compute Service ID](https://docs.fastly.com/en/guides/about-services). Add your proxy secret:
48+
49+
| Key | Example Value | Description |
50+
| ------------ | -------------------- | --------------------------------------------- |
51+
| PROXY_SECRET | 6XI9CLf3C9oHSB12TTaI | Fingerprint proxy secret generated in Step 1. |
52+
53+
5. Go to [Releases](https://github.com/fingerprintjs/fingerprint-pro-fastly-compute-proxy-integration/releases) to download the latest `fingerprint-proxy-integration.tar.gz` package file.
54+
6. Upload package to your Fastly Compute Service's **Package**.
55+
7. Configure the Fingerprint [JavaScript Agent](https://dev.fingerprint.com/docs/install-the-javascript-agent#configuring-the-agent) on your website using the paths defined in Step 3.
4956
```javascript
5057
import * as FingerprintJS from '@fingerprintjs/fingerprintjs-pro'
5158

@@ -62,16 +69,27 @@ This is a quick overview of the installation setup. For detailed step-by-step in
6269
});
6370
```
6471

65-
See the [Fastly Compute proxy integration guide](https://dev.fingerprint.com/docs/fastly-compute-edge-proxy-integration#step-9-configure-the-fingerprint-client-agent-on-to-use-your-service) in our documentation for more details.
72+
See the [Fastly Compute proxy integration guide](https://dev.fingerprint.com/docs/fastly-compute-proxy-integration#step-4-configure-the-fingerprint-client-agent-to-use-your-service) in our documentation for more details.
73+
74+
### Using custom store names
6675

67-
### Using a custom config store name
76+
By default, the service package provided in releases assumes the following names for the Config store and Secret Store:
6877

69-
The worker package provided in Releases assumes the config store used by the integration is named exactly `Fingerprint`. If you need to use a different config store name, you can pass the name to the `CONFIG_STORE_NAME` environment variable and build a custom worker package:
78+
* `Fingerprint_Compute_Config_Store_<SERVICE_ID>`
79+
* `Fingerprint_Compute_Secret_Store_<SERVICE_ID>`
7080

71-
```shell
72-
CONFIG_STORE_NAME=MyCustomStoreName pnpm run build
81+
To use a custom name prefix for both stores, use the `STORE_NAME_PREFIX` environment variable to build a custom service package:
82+
83+
```shell=
84+
STORE_NAME_PREFIX=CustomName pnpm run build
7385
```
7486

87+
Your custom built package in `pkg/package.tar.gz` will use your custom prefix in store names like:
88+
89+
* `CustomName_Config_Store_<SERVICE_ID>`
90+
* `CustomName_Secret_Store_<SERVICE_ID>`
91+
92+
7593
## Feedback and support
7694

7795
Please reach out to our [Customer Success team](https://fingerprint.com/support/) if run into any issues with the integration.

__mocks__/fastly:env.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function env(key) {
2+
return `TEST_${key}`
3+
}

__mocks__/fastly:kv-store.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export class KVStore {
2+
async put(name, value) {
3+
return { name, value }
4+
}
5+
}

__mocks__/fastly:secret-store.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
const store = new Map()
2-
export class ConfigStore {
2+
export class SecretStore {
33
constructor(storeName) {
44
this.storeName = storeName
55
}
66

7-
get(key) {
8-
return store.get(key) || null
7+
async get(key) {
8+
return {
9+
plaintext: () => {
10+
return store.get(key) || null
11+
},
12+
}
913
}
1014

1115
set(key, value) {

build.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { build } from 'esbuild'
22

33
// Load environment variables from process.env
4-
const configStoreName = process.env.CONFIG_STORE_NAME || 'Fingerprint'
4+
const configStoreNamePrefix = process.env.STORE_NAME_PREFIX || 'Fingerprint_Compute'
55

66
build({
77
entryPoints: ['./src/index.ts'],
88
outdir: './build',
99
bundle: true,
1010
format: 'cjs',
1111
external: ['fastly:*'],
12-
define: { 'process.env.CONFIG_STORE_NAME': `"${configStoreName}"` },
12+
define: { 'process.env.STORE_NAME_PREFIX': `"${configStoreNamePrefix}"` },
1313
}).catch(() => process.exit(1))

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fingerprint-pro-fastly-compute-proxy-integration",
3-
"version": "0.1.0",
3+
"version": "0.2.0-rc.2",
44
"engines": {
55
"node": ">=20"
66
},
@@ -12,7 +12,6 @@
1212
"@fingerprintjs/commit-lint-dx-team": "^0.1.0",
1313
"@fingerprintjs/conventional-changelog-dx-team": "^0.1.0",
1414
"@fingerprintjs/eslint-config-dx-team": "^0.1.0",
15-
"@fingerprintjs/fingerprintjs-pro-server-api": "^5.0.0",
1615
"@fingerprintjs/prettier-config-dx-team": "^0.2.0",
1716
"@fingerprintjs/tsconfig-dx-team": "^0.0.2",
1817
"@jest/globals": "^29.7.0",
@@ -23,7 +22,7 @@
2322
"@types/pako": "^2.0.3",
2423
"babel-jest": "^29.7.0",
2524
"esbuild": "^0.24.0",
26-
"fastly": "7.3.0",
25+
"fastly": "^7.10.0",
2726
"fs": "0.0.1-security",
2827
"husky": "^9.1.5",
2928
"jest": "^29.7.0",
@@ -62,5 +61,8 @@
6261
"commitizen": {
6362
"path": "./node_modules/cz-conventional-changelog"
6463
}
64+
},
65+
"peerDependencies": {
66+
"@fingerprintjs/fingerprintjs-pro-server-api": "^5.2.0"
6567
}
6668
}

plugins/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// import { saveFingerprintResultToKVStore } from './saveToKVStore'
1+
import { saveFingerprintResultToKVStore } from './saveToKVStore'
22
import { Plugin } from '../src/utils/registerPlugin'
33

44
export default [
5-
// {
6-
// name: 'Save Fingerprint Result to KV Store',
7-
// callback: saveFingerprintResultToKVStore,
8-
// type: 'processOpenClientResponse',
9-
// },
5+
{
6+
name: 'Save Fingerprint Result to KV Store',
7+
callback: saveFingerprintResultToKVStore,
8+
type: 'processOpenClientResponse',
9+
},
1010
] satisfies Plugin[]

plugins/saveToKVStore.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,23 @@
22

33
import { KVStore } from 'fastly:kv-store'
44
import { ProcessOpenClientResponseContext } from '../src/utils/registerPlugin'
5+
import { getConfigStore } from '../src/utils/getStore'
6+
import { env } from 'fastly:env'
57
export async function saveFingerprintResultToKVStore(context: ProcessOpenClientResponseContext) {
8+
const configStore = getConfigStore()
9+
const isPluginEnabled = configStore?.get('SAVE_TO_KV_STORE_PLUGIN_ENABLED') === 'true'
10+
11+
if (!isPluginEnabled) {
12+
console.log("Plugin 'saveFingerprintResultToKVStore' is not enabled")
13+
return
14+
}
15+
616
const requestId = context.event?.products.identification?.data?.requestId
717
if (!requestId) {
18+
console.log('[saveFingerprintResultToKVStore] Plugin Error: request ID is undefined in the event response.')
819
return
920
}
10-
const store = new KVStore('FingerprintResults')
21+
const serviceId = env('FASTLY_SERVICE_ID')
22+
const store = new KVStore(`Fingerprint_Results_${serviceId}`)
1123
await store.put(requestId, JSON.stringify(context.event))
1224
}

0 commit comments

Comments
 (0)