@optimizely/edge-delivery
Advanced tools
| /// <reference types="@cloudflare/workers-types" /> | ||
| /// <reference types="@cloudflare/workers-types/2023-07-01" /> | ||
| import { Geolocation } from '../lib/location'; | ||
| export declare function getLocation(request: Request): Geolocation | null; | ||
| export declare function normalizeCityName(cityName: string): string; |
| export declare const CloudflareRuntime: "cloudflare"; | ||
| export declare const AkamaiRuntime: "akamai"; | ||
| export declare const UnknownRuntime: "unknown"; | ||
| export type Runtime = typeof CloudflareRuntime | typeof AkamaiRuntime | typeof UnknownRuntime; |
| /** | ||
| * Get the SHA-256 of a given string | ||
| * | ||
| * @param text Text to hash | ||
| * @returns Promise<string> | ||
| */ | ||
| export declare function digestTextSha256(text: string): Promise<string>; | ||
| /** | ||
| * | ||
| * @param key | ||
| * @returns The cache string of a given key or undefined if not found | ||
| */ | ||
| export declare function getCachedString(key: string): Promise<string | undefined>; | ||
| /** | ||
| * Save a string on cache with the given key and ttl | ||
| * | ||
| * @param key To identify the saved string | ||
| * @param content Content string to save | ||
| * @param ttl Number of seconds to keep on cache | ||
| */ | ||
| export declare function saveCachedString(key: string, content: string, ttl?: number): Promise<void>; | ||
| /** | ||
| * Get the script nonce from the Content-Security-Policy header | ||
| * @param cspHeader The Content-Security-Policy header value | ||
| * @returns The nonce string or null if not found | ||
| */ | ||
| export declare function getScriptNonceFromHeader(cspHeader: string | null): string | undefined; |
| export { digestTextSha256, getCachedString, saveCachedString, getScriptNonceFromHeader, } from './cache'; | ||
| export { detectRuntime, isSelectorSupported } from './selector'; |
| /// <reference types="@cloudflare/workers-types" /> | ||
| /// <reference types="@cloudflare/workers-types/2023-07-01" /> | ||
| import { Runtime } from '../types'; | ||
| /** | ||
| * This function is used to determine the runtime (Akamai or Cloudflare) | ||
| * @returns {'cloudflare' | 'akamai' | 'unknown'} The detected runtime environment | ||
| * */ | ||
| export declare function detectRuntime(request: Request): Runtime; | ||
| /** | ||
| * This function checks if the selector is supported based on the runtime. | ||
| * HTMLRewriter has limited CSS selector support that varies by runtime: | ||
| * - Cloudflare: Does not support sibling combinators (~, +), pseudo-elements, and selected pseudo-classes | ||
| * - Akamai: Does not support sibling combinators (~, +) or any pseudo-classes/pseudo-elements | ||
| * | ||
| * Results are cached for performance. | ||
| * | ||
| * @param selector CSS selector string used in the transform | ||
| * @param runtime The runtime environment ('cloudflare' or 'akamai') | ||
| * @returns true if the selector is supported on the specified runtime, false otherwise | ||
| */ | ||
| export declare function isSelectorSupported(selector: string, runtime: Runtime): boolean; |
@@ -6,3 +6,3 @@ export declare const LOCATION_ORACLE_URL = "https://cdn.optimizely.com/geo4.json"; | ||
| * The IP address whose location was resolved. | ||
| * @property {EdgeScapeGeolocation} location | ||
| * @property {Geolocation} location | ||
| * Geolocation data for `ip`. | ||
@@ -12,3 +12,3 @@ */ | ||
| ip: string; | ||
| location: EdgeScapeGeolocation; | ||
| location: Geolocation; | ||
| }; | ||
@@ -18,3 +18,3 @@ /** | ||
| * See https://developer.akamai.com/edgescape | ||
| * @typedef {Object} EdgeScapeGeolocation | ||
| * @typedef {Object} Geolocation | ||
| * | ||
@@ -31,3 +31,3 @@ * @property {String} continent | ||
| */ | ||
| export type EdgeScapeGeolocation = { | ||
| export type Geolocation = { | ||
| continent: string; | ||
@@ -37,2 +37,3 @@ country: string; | ||
| city: string; | ||
| dma: string; | ||
| }; | ||
@@ -42,3 +43,3 @@ /** | ||
| * The IP address to resolve to a geolocation. | ||
| * @returns {Promise.<EdgeScapeGeolocation>} | ||
| * @returns {Promise.<Geolocation>} | ||
| * Rejects in the event of a cache miss followed by a failed subrequest to | ||
@@ -51,3 +52,3 @@ * resolve geolocation. Fulfills otherwise, with either a cached value or a | ||
| */ | ||
| export declare function getByIp(ip: string): Promise<EdgeScapeGeolocation>; | ||
| export declare function getByIp(ip: string): Promise<Geolocation>; | ||
| declare const _default: { | ||
@@ -54,0 +55,0 @@ getByIp: typeof getByIp; |
+2
-1
@@ -5,2 +5,3 @@ /// <reference types="@cloudflare/workers-types" /> | ||
| import type { Experiment as SdkExperiment } from '@optimizely/optimizely-sdk/dist/shared_types'; | ||
| import { Geolocation } from './edge-decider/lib/location'; | ||
| export declare class ExperienceConfig { | ||
@@ -187,3 +188,3 @@ accountId: string; | ||
| visitorIp?: string; | ||
| location?: Object; | ||
| location?: Geolocation | null; | ||
| referrer?: string | null; | ||
@@ -190,0 +191,0 @@ time?: TimeContext; |
+1
-1
@@ -31,3 +31,3 @@ /// <reference types="@cloudflare/workers-types" /> | ||
| getChangesFromVariation(exp: Experience, variationIds: Set<string>, viewsIds: string[]): Change[]; | ||
| applyTransforms(rewriter: HTMLRewriter, existingSnippet?: string): HTMLRewriter; | ||
| applyTransforms(rewriter: HTMLRewriter, targetRequest: Request, existingSnippet?: string): HTMLRewriter; | ||
| shouldDeferBrowserJs(): boolean; | ||
@@ -34,0 +34,0 @@ applyBrowserJs(rewriter: HTMLRewriter, cacheTTL?: number, position?: string, nonce?: string, isProd?: boolean, useEdgeDeliverySnippet?: boolean): Promise<HTMLRewriter>; |
+2
-2
| { | ||
| "name": "@optimizely/edge-delivery", | ||
| "license": "Apache-2.0", | ||
| "version": "1.0.10", | ||
| "version": "1.0.11", | ||
| "description": "Optimizely's Edge Delivery, a library for executing Web Experiments utilizing Cloudflare's HTMLRewriter technology.", | ||
@@ -44,3 +44,3 @@ "main": "dist/index.js", | ||
| "@optimizely/client-experimentation": "^0.0.10", | ||
| "@optimizely/edge-delivery-browser-modules": "0.239.0-1-gb7b6b3c50", | ||
| "@optimizely/edge-delivery-browser-modules": "0.246.0-1-g799ffd505", | ||
| "@optimizely/optimizely-sdk": "https://registry.npmjs.org/@optimizely/optimizely-sdk/-/optimizely-sdk-6.3.1.tgz", | ||
@@ -47,0 +47,0 @@ "@types/cookie": "^1.0.0", |
Sorry, the diff of this file is too big to display
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
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
828226
1.58%86
6.17%4712
2.15%106
2.91%