@optimizely/edge-delivery
Advanced tools
| /// <reference types="@cloudflare/workers-types" /> | ||
| /// <reference types="@cloudflare/workers-types/2023-07-01" /> | ||
| export declare class ScriptTagInjector implements HTMLRewriterElementContentHandlers { | ||
| tagPosition?: string; | ||
| scriptContent?: string; | ||
| scriptUrl?: string; | ||
| scriptNonce?: string; | ||
| constructor(scriptContentOrUrl: string, tagPosition?: string, scriptNonce?: string); | ||
| element(element: Element): void; | ||
| } |
| /** | ||
| * Optimizely Webhook Handler | ||
| * Handles incoming webhook requests from Optimizely and updates KV storage | ||
| */ | ||
| /// <reference types="@cloudflare/workers-types" /> | ||
| /// <reference types="@cloudflare/workers-types/2023-07-01" /> | ||
| import { Logger } from './edge-decider/logger'; | ||
| import { Options } from './models'; | ||
| /** | ||
| * This function is used to check if the request is a webhook request. | ||
| * @param request | ||
| * @returns {boolean} | ||
| */ | ||
| export declare const isWebhookRequest: (request: Request) => boolean; | ||
| /** | ||
| * Internal webhook handler called from applyExperiments | ||
| * Processes webhook POST requests from Optimizely, verifies the signature, | ||
| * and updates the KV namespace with the latest manifest data. | ||
| * | ||
| * @param request - The incoming Request object | ||
| * @param options - Configuration options including KV namespace and webhook secret | ||
| * @returns Response indicating success or failure | ||
| */ | ||
| export declare function handleWebhook(request: Request, options: Options, logger: Logger): Promise<Response>; |
@@ -11,3 +11,3 @@ /** | ||
| import { ExclusionGroup, ExperienceConfig, Experiment } from '../../../models'; | ||
| import type { Experiment as SdkExperiment, Group as SdkGroup } from '@optimizely/optimizely-sdk/lib/shared_types'; | ||
| import type { Experiment as SdkExperiment, Group as SdkGroup } from '@optimizely/optimizely-sdk/dist/shared_types'; | ||
| /** | ||
@@ -14,0 +14,0 @@ * Coerce experiments into Full Stack datafile-like format that |
| import { ExperienceConfig } from '../../models'; | ||
| import V4 from './datafile_versions/v4'; | ||
| /** | ||
@@ -8,32 +9,6 @@ * Wrapper that returns a datafile in Full Stack format. | ||
| */ | ||
| export declare const convertWebManifestToDatafile: (data: ExperienceConfig) => { | ||
| accountId: string; | ||
| anonymizeIP: boolean; | ||
| botFiltering: boolean; | ||
| projectId: string; | ||
| revision: string; | ||
| version: string; | ||
| typedAudiences: import("../../models").Audience[]; | ||
| experiments: import("@optimizely/optimizely-sdk/lib/shared_types").Experiment[]; | ||
| groups: import("@optimizely/optimizely-sdk/lib/shared_types").Group[]; | ||
| events: never[]; | ||
| attributes: never[]; | ||
| audiences: never[]; | ||
| export declare const convertWebManifestToDatafile: (data: ExperienceConfig) => ReturnType<typeof V4.convertToDatafile>; | ||
| declare const exportedModule: { | ||
| readonly convertWebManifestToDatafile: (data: ExperienceConfig) => ReturnType<typeof V4.convertToDatafile>; | ||
| }; | ||
| declare const _default: { | ||
| convertWebManifestToDatafile: (data: ExperienceConfig) => { | ||
| accountId: string; | ||
| anonymizeIP: boolean; | ||
| botFiltering: boolean; | ||
| projectId: string; | ||
| revision: string; | ||
| version: string; | ||
| typedAudiences: import("../../models").Audience[]; | ||
| experiments: import("@optimizely/optimizely-sdk/lib/shared_types").Experiment[]; | ||
| groups: import("@optimizely/optimizely-sdk/lib/shared_types").Group[]; | ||
| events: never[]; | ||
| attributes: never[]; | ||
| audiences: never[]; | ||
| }; | ||
| }; | ||
| export default _default; | ||
| export default exportedModule; |
@@ -15,2 +15,2 @@ /** | ||
| */ | ||
| export declare function hasMatch(value: string, match: string, visitorValue: null | string | number | undefined): boolean; | ||
| export declare function hasMatch(value: string | null | undefined, match: string, visitorValue: null | string | number | undefined): boolean; |
@@ -1,44 +0,45 @@ | ||
| import { Condition, ProfileAttributes } from '../../../models'; | ||
| import { Condition } from '../../../models'; | ||
| import type { OptimizelyUserContext } from '@optimizely/optimizely-sdk/universal'; | ||
| export declare const allConditionsMatcherList: Record<string, any>; | ||
| export declare function getMatcherFieldsNeeds(matchersNeeded: string[]): string[]; | ||
| export declare function getConditionEvaluators(): { | ||
| export declare const CONDITION_EVALUATORS: { | ||
| browser_version: { | ||
| evaluate: (cond: Condition, attributes: ProfileAttributes) => boolean; | ||
| evaluate: (cond: Condition, userContext: OptimizelyUserContext) => boolean; | ||
| }; | ||
| campaign: { | ||
| evaluate: (cond: Condition, attributes: ProfileAttributes) => boolean; | ||
| evaluate: (cond: Condition, userContext: OptimizelyUserContext) => boolean; | ||
| }; | ||
| cookies: { | ||
| evaluate: (cond: Condition, attributes: ProfileAttributes) => boolean; | ||
| evaluate: (cond: Condition, userContext: OptimizelyUserContext) => boolean; | ||
| }; | ||
| device: { | ||
| evaluate: (cond: Condition, attributes: ProfileAttributes) => boolean; | ||
| evaluate: (cond: Condition, userContext: OptimizelyUserContext) => boolean; | ||
| }; | ||
| first_session: { | ||
| evaluate: (_: Condition, attributes: ProfileAttributes) => boolean; | ||
| evaluate: (_: Condition, userContext: OptimizelyUserContext) => boolean; | ||
| }; | ||
| ip: { | ||
| evaluate: (cond: Condition, attributes: ProfileAttributes) => boolean | undefined; | ||
| evaluate: (cond: Condition, userContext: OptimizelyUserContext) => boolean | undefined; | ||
| }; | ||
| language: { | ||
| evaluate: (cond: Condition, attributes: ProfileAttributes) => boolean; | ||
| evaluate: (cond: Condition, userContext: OptimizelyUserContext) => boolean; | ||
| }; | ||
| location: { | ||
| evaluate: (cond: Condition, attributes: ProfileAttributes) => boolean | undefined; | ||
| evaluate: (cond: Condition, userContext: OptimizelyUserContext) => boolean | undefined; | ||
| }; | ||
| platform: { | ||
| evaluate: (cond: Condition, attributes: ProfileAttributes) => boolean; | ||
| evaluate: (cond: Condition, userContext: OptimizelyUserContext) => boolean; | ||
| }; | ||
| query: { | ||
| evaluate: (cond: Condition, attributes: ProfileAttributes) => boolean; | ||
| evaluate: (cond: Condition, userContext: OptimizelyUserContext) => boolean; | ||
| }; | ||
| referrer: { | ||
| evaluate: (cond: Condition, attributes: ProfileAttributes) => boolean; | ||
| evaluate: (cond: Condition, userContext: OptimizelyUserContext) => boolean; | ||
| }; | ||
| source_type: { | ||
| evaluate: (cond: Condition, attributes: ProfileAttributes) => boolean; | ||
| evaluate: (cond: Condition, userContext: OptimizelyUserContext) => boolean; | ||
| }; | ||
| time_and_day: { | ||
| evaluate: (cond: Condition, attributes: ProfileAttributes) => boolean; | ||
| evaluate: (cond: Condition, userContext: OptimizelyUserContext) => boolean; | ||
| }; | ||
| }; |
| /** | ||
| * Module to build the data structures to eventually send to Honeycomb. | ||
| */ | ||
| import { ConsoleLogHandler, LogLevel } from '@optimizely/js-sdk-logging'; | ||
| import { LogLevel, LogHandler } from '@optimizely/optimizely-sdk/universal'; | ||
| import { Decision } from '../../models'; | ||
| export declare const LogLevelToLower: Record<LogLevel, string>; | ||
| export declare const NameToLogLevelMap: Record<string, LogLevel>; | ||
| declare class ConsoleLogHandler implements LogHandler { | ||
| private prefix; | ||
| private logLevel; | ||
| constructor(prefix?: string); | ||
| setLogLevel(level: LogLevel): void; | ||
| log(level: LogLevel, message: string): void; | ||
| private getTime; | ||
| private consoleLog; | ||
| } | ||
| export declare const globalLogHandler: ConsoleLogHandler; | ||
| type LogState = { | ||
| export declare const opaqueLogger: import("@optimizely/optimizely-sdk/universal").OpaqueLogger; | ||
| export type LogState = { | ||
| decisions: Decision[]; | ||
@@ -27,6 +39,7 @@ logs: { | ||
| export declare class Logger { | ||
| browserLogLevel: number; | ||
| browserLogLevel: LogLevel; | ||
| logState: LogState; | ||
| constructor(); | ||
| setLogLevel(level: string | number): void; | ||
| setBrowserLogLevel(level: string | number): void; | ||
| setWorkerLogLevel(level: string | number): void; | ||
| getLogState(): LogState; | ||
@@ -40,2 +53,3 @@ getLifeCycleLogs(): string[]; | ||
| logError(error: Error): void; | ||
| __logAtLevel(level: LogLevel, message: string, ...rest: any[]): void; | ||
| debug(message: string, ...rest: any[]): void; | ||
@@ -45,21 +59,10 @@ info(message: string, ...rest: any[]): void; | ||
| error(message: string, ...rest: any[]): void; | ||
| getLogs(): { | ||
| level: LogLevel; | ||
| message: string; | ||
| rest: any[]; | ||
| }[]; | ||
| getLogs(): LogState['logs']; | ||
| } | ||
| export declare function getLogger(cfEvent: Object): Logger; | ||
| export declare function getGlobalLogHandler(): { | ||
| debug: (...args: any[]) => void; | ||
| info: (...args: any[]) => void; | ||
| warning: (...args: any[]) => void; | ||
| error: (...args: any[]) => void; | ||
| }; | ||
| declare const _default: { | ||
| Logger: typeof Logger; | ||
| getLogger: typeof getLogger; | ||
| getGlobalLogHandler: typeof getGlobalLogHandler; | ||
| globalLogHandler: ConsoleLogHandler; | ||
| }; | ||
| export default _default; |
+6
-3
| /// <reference types="@cloudflare/workers-types" /> | ||
| /// <reference types="@cloudflare/workers-types/2023-07-01" /> | ||
| import { Experimentation } from '@optimizely/client-experimentation'; | ||
| import type { Experiment as SdkExperiment } from '@optimizely/optimizely-sdk/lib/shared_types'; | ||
| import type { Experimentation } from '@optimizely/client-experimentation'; | ||
| import type { Experiment as SdkExperiment } from '@optimizely/optimizely-sdk/dist/shared_types'; | ||
| export declare class ExperienceConfig { | ||
@@ -241,2 +241,4 @@ accountId: string; | ||
| kvNamespace?: KVNamespace; | ||
| webhookSecret?: string; | ||
| fixCSPForOptimizely?: boolean; | ||
| control?: Response; | ||
@@ -250,3 +252,4 @@ rewriter?: HTMLRewriter; | ||
| DATA?: any; | ||
| constructor({ accountId, snippetId, isProd, isSnippetless, nonce, position, cacheTTLs, deployId, fallback, existingSnippet, control, rewriter, environment, dev_host, dev_protocol, dev_port, dev_pathname, DATA, }: Options); | ||
| logLevel?: 'debug' | 'info' | 'warning' | 'warn' | 'error'; | ||
| constructor({ accountId, snippetId, isProd, isSnippetless, nonce, position, cacheTTLs, deployId, fallback, existingSnippet, kvNamespace, webhookSecret, control, rewriter, environment, dev_host, dev_protocol, dev_port, dev_pathname, DATA, logLevel, }: Options); | ||
| } | ||
@@ -253,0 +256,0 @@ export type VisitorProfile = { |
+7
-1
@@ -8,3 +8,3 @@ /// <reference types="@cloudflare/workers-types" /> | ||
| queue: ExperienceQueue; | ||
| generatedDefines: Object; | ||
| generatedDefines: Record<string, any>; | ||
| results: ExperienceResults; | ||
@@ -33,5 +33,11 @@ deployId: string; | ||
| applyBrowserJs(rewriter: HTMLRewriter, cacheTTL: number, position: string, nonce: string): Promise<HTMLRewriter>; | ||
| insertJquery(rewriter: HTMLRewriter, element: string, nonce: string, tagPosition: 'prepend' | 'append' | 'after'): void; | ||
| computeBrowserJS(cacheTTL?: number): Promise<string>; | ||
| removeSnippetChange(existingSnippetParam: string): Change; | ||
| updateInputsWithOriginCookies(originSetCookieHeaders: string[]): void; | ||
| /** | ||
| * Add the required Content-Security-Policy directives to support Optimizely | ||
| * @param originalPolicy The original Content-Security-Policy header value | ||
| */ | ||
| addOptimizelyCSPRequirements(originalPolicy: string | null): void; | ||
| } |
+11
-6
| { | ||
| "name": "@optimizely/edge-delivery", | ||
| "license": "Apache-2.0", | ||
| "version": "1.0.5", | ||
| "version": "1.0.6", | ||
| "description": "Optimizely's Edge Delivery, a library for executing Web Experiments utilizing Cloudflare's HTMLRewriter technology.", | ||
@@ -14,3 +14,3 @@ "main": "dist/index.js", | ||
| "lint:fix": "prettier ./src --write", | ||
| "test": "cypress run", | ||
| "test": "jest --coverage", | ||
| "build": "tsc && node ./scripts/bundle.js", | ||
@@ -31,2 +31,3 @@ "clean": "rm -rf node_modules; rm -rf dist", | ||
| "dependencies": { | ||
| "content-security-policy-parser": "^0.6.0", | ||
| "cookie": "^1.0.2", | ||
@@ -37,14 +38,18 @@ "is-in-subnet": "^3.0.1", | ||
| "parse-domain": "^7.0.0", | ||
| "ua-parser-js": "0.7.33", | ||
| "ua-parser-js": "^1.0.41", | ||
| "uuid": "^3.3.3" | ||
| }, | ||
| "devDependencies": { | ||
| "@babel/preset-env": "^7.28.6", | ||
| "@babel/preset-typescript": "^7.28.5", | ||
| "@cloudflare/workers-types": "^4.20240605.0", | ||
| "@optimizely/client-experimentation": "^0.0.10", | ||
| "@optimizely/edge-delivery-browser-modules": "0.237.0", | ||
| "@optimizely/optimizely-sdk": "https://registry.npmjs.org/@optimizely/optimizely-sdk/-/optimizely-sdk-4.9.1.tgz", | ||
| "@optimizely/edge-delivery-browser-modules": "0.239.0-1-gb7b6b3c50", | ||
| "@optimizely/optimizely-sdk": "https://registry.npmjs.org/@optimizely/optimizely-sdk/-/optimizely-sdk-6.3.1.tgz", | ||
| "@types/cookie": "^1.0.0", | ||
| "@types/jest": "^30.0.0", | ||
| "@types/ua-parser-js": "^0.7.39", | ||
| "cypress": "^14.5.4", | ||
| "cypress": "^15.9.0", | ||
| "esbuild": "0.24.2", | ||
| "jest": "^30.2.0", | ||
| "prettier": "^3.7.4", | ||
@@ -51,0 +56,0 @@ "typescript": "5.2.2" |
+1
-0
@@ -55,2 +55,3 @@ <h1 align="center">Optimizely Edge Delivery SDK</h1> | ||
| - `options.DATA` - the JSON configuration file to retrieve to execute your experiments. | ||
| - `options.logLevel` - Set internal worker log level. it could be: 'debug' | 'info' | 'warning' | 'error' default to 'error'. | ||
@@ -57,0 +58,0 @@ #### Basic configuration options |
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
81
2.53%90
1.12%812041
-40.02%8
14.29%14
40%4588
-31.32%2
100%111
3600%24
1100%+ Added
+ Added
- Removed
Updated