{"version":3,"file":"sticky-bucket-service.mjs","names":["toString","getStickyBucketAttributeKey","StickyBucketService","constructor","opts","prefix","getAllAssignments","attributes","docs","Promise","all","Object","entries","map","_ref","attributeName","attributeValue","getAssignments","forEach","doc","key","getKey","concat","StickyBucketServiceSync","getAssignmentsSync","saveAssignments","saveAssignmentsSync","getAllAssignmentsSync","_ref2","LocalStorageStickyBucketService","localStorage","globalThis","e","raw","getItem","data","JSON","parse","assignments","setItem","stringify","ExpressCookieStickyBucketService","_ref3","req","res","cookieAttributes","maxAge","cookies","str","cookie","encodeURIComponent","BrowserCookieStickyBucketService","_ref4","jsCookie","expires","get","_this$cookieAttribute","domain","hostOnlyAttributes","_objectWithoutProperties","_excluded","set","remove","RedisStickyBucketService","_ref5","redis","keys","_ref6","mget","then","values","_attributeName","_attributeValue"],"sources":["../../src/sticky-bucket-service.ts"],"sourcesContent":["import {\n  LocalStorageCompat,\n  StickyAssignmentsDocument,\n  StickyAttributeKey,\n} from \"./types/growthbook\";\nimport { toString } from \"./util\";\nimport { getStickyBucketAttributeKey } from \"./core\";\n\nexport interface CookieAttributes {\n  expires?: number | Date | undefined;\n  path?: string | undefined;\n  domain?: string | undefined;\n  secure?: boolean | undefined;\n  sameSite?: \"strict\" | \"Strict\" | \"lax\" | \"Lax\" | \"none\" | \"None\" | undefined;\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  [property: string]: any;\n}\nexport interface JsCookiesCompat<T = string> {\n  set(\n    name: string,\n    value: string | T,\n    options?: CookieAttributes,\n  ): string | undefined;\n  get(name: string): string | T | undefined;\n  get(): { [key: string]: string };\n  remove(name: string, options?: CookieAttributes): void;\n}\n\nexport interface IORedisCompat {\n  mget(...keys: string[]): Promise<string[]>;\n  set(key: string, value: string): Promise<string>;\n}\n\nexport interface RequestCompat {\n  cookies: Record<string, string>;\n  [key: string]: unknown;\n}\nexport interface ResponseCompat {\n  cookie(\n    name: string,\n    value: string,\n    options?: CookieAttributes,\n  ): ResponseCompat;\n  [key: string]: unknown;\n}\n\n/**\n * Responsible for reading and writing documents which describe sticky bucket assignments.\n */\nexport abstract class StickyBucketService {\n  protected prefix: string;\n\n  constructor(opts?: { prefix?: string }) {\n    opts = opts || {};\n    this.prefix = opts.prefix || \"\";\n  }\n\n  abstract getAssignments(\n    attributeName: string,\n    attributeValue: string,\n  ): Promise<StickyAssignmentsDocument | null>;\n\n  abstract saveAssignments(doc: StickyAssignmentsDocument): Promise<unknown>;\n\n  /**\n   * The SDK calls getAllAssignments to populate sticky buckets. This in turn will\n   * typically loop through individual getAssignments calls. However, some StickyBucketService\n   * instances (i.e. Redis) will instead perform a multi-query inside getAllAssignments instead.\n   */\n  async getAllAssignments(\n    attributes: Record<string, string>,\n  ): Promise<Record<StickyAttributeKey, StickyAssignmentsDocument>> {\n    const docs: Record<string, StickyAssignmentsDocument> = {};\n    (\n      await Promise.all(\n        Object.entries(attributes).map(([attributeName, attributeValue]) =>\n          this.getAssignments(attributeName, attributeValue),\n        ),\n      )\n    ).forEach((doc) => {\n      if (doc) {\n        const key = getStickyBucketAttributeKey(\n          doc.attributeName,\n          doc.attributeValue,\n        );\n        docs[key] = doc;\n      }\n    });\n    return docs;\n  }\n\n  getKey(attributeName: string, attributeValue: string): string {\n    return `${this.prefix}${attributeName}||${attributeValue}`;\n  }\n}\n\nexport abstract class StickyBucketServiceSync extends StickyBucketService {\n  abstract getAssignmentsSync(\n    attributeName: string,\n    attributeValue: string,\n  ): StickyAssignmentsDocument | null;\n\n  abstract saveAssignmentsSync(doc: StickyAssignmentsDocument): void;\n\n  async getAssignments(attributeName: string, attributeValue: string) {\n    return this.getAssignmentsSync(attributeName, attributeValue);\n  }\n\n  async saveAssignments(doc: StickyAssignmentsDocument) {\n    this.saveAssignmentsSync(doc);\n  }\n\n  getAllAssignmentsSync(\n    attributes: Record<string, string>,\n  ): Record<StickyAttributeKey, StickyAssignmentsDocument> {\n    const docs: Record<string, StickyAssignmentsDocument> = {};\n    Object.entries(attributes)\n      .map(([attributeName, attributeValue]) =>\n        this.getAssignmentsSync(attributeName, attributeValue),\n      )\n      .forEach((doc) => {\n        if (doc) {\n          const key = getStickyBucketAttributeKey(\n            doc.attributeName,\n            doc.attributeValue,\n          );\n          docs[key] = doc;\n        }\n      });\n    return docs;\n  }\n}\n\nexport class LocalStorageStickyBucketService extends StickyBucketService {\n  private localStorage: LocalStorageCompat | undefined;\n  constructor(opts?: { prefix?: string; localStorage?: LocalStorageCompat }) {\n    opts = opts || {};\n    super();\n    this.prefix = opts.prefix || \"gbStickyBuckets__\";\n    try {\n      this.localStorage = opts.localStorage || globalThis.localStorage;\n    } catch (e) {\n      // Ignore localStorage errors\n    }\n  }\n  async getAssignments(attributeName: string, attributeValue: string) {\n    const key = this.getKey(attributeName, attributeValue);\n    let doc: StickyAssignmentsDocument | null = null;\n    if (!this.localStorage) return doc;\n    try {\n      const raw = (await this.localStorage.getItem(key)) || \"{}\";\n      const data = JSON.parse(raw);\n      if (data.attributeName && data.attributeValue && data.assignments) {\n        doc = data;\n      }\n    } catch (e) {\n      // Ignore localStorage errors\n    }\n    return doc;\n  }\n  async saveAssignments(doc: StickyAssignmentsDocument) {\n    const key = this.getKey(doc.attributeName, doc.attributeValue);\n    if (!this.localStorage) return;\n    try {\n      await this.localStorage.setItem(key, JSON.stringify(doc));\n    } catch (e) {\n      // Ignore localStorage errors\n    }\n  }\n}\n\nexport class ExpressCookieStickyBucketService extends StickyBucketServiceSync {\n  /**\n   * Intended to be used with cookieParser() middleware from npm: 'cookie-parser'.\n   * Assumes:\n   *  - reading a cookie is automatically decoded via decodeURIComponent() or similar\n   *  - writing a cookie name & value must be manually encoded via encodeURIComponent() or similar\n   *  - all cookie bodies are JSON encoded strings and are manually encoded/decoded\n   */\n  private req: RequestCompat;\n  private res: ResponseCompat;\n  private cookieAttributes: CookieAttributes;\n  constructor({\n    prefix = \"gbStickyBuckets__\",\n    req,\n    res,\n    cookieAttributes = { maxAge: 180 * 24 * 3600 * 1000 }, // 180 days\n  }: {\n    prefix?: string;\n    req: RequestCompat;\n    res: ResponseCompat;\n    cookieAttributes?: CookieAttributes;\n  }) {\n    super();\n    this.prefix = prefix;\n    this.req = req;\n    this.res = res;\n    this.cookieAttributes = cookieAttributes;\n  }\n  getAssignmentsSync(attributeName: string, attributeValue: string) {\n    const key = this.getKey(attributeName, attributeValue);\n    let doc: StickyAssignmentsDocument | null = null;\n    if (!this.req) return doc;\n    try {\n      const raw = this.req.cookies[key] || \"{}\";\n      const data = JSON.parse(raw);\n      if (data.attributeName && data.attributeValue && data.assignments) {\n        doc = data;\n      }\n    } catch (e) {\n      // Ignore cookie errors\n    }\n    return doc;\n  }\n  saveAssignmentsSync(doc: StickyAssignmentsDocument) {\n    const key = this.getKey(doc.attributeName, doc.attributeValue);\n    if (!this.res) return;\n    const str = JSON.stringify(doc);\n    this.res.cookie(\n      encodeURIComponent(key),\n      encodeURIComponent(str),\n      this.cookieAttributes,\n    );\n  }\n}\n\nexport class BrowserCookieStickyBucketService extends StickyBucketServiceSync {\n  /**\n   * Intended to be used with npm: 'js-cookie'.\n   * Assumes:\n   *  - reading a cookie is automatically decoded via decodeURIComponent() or similar\n   *  - writing a cookie name & value is automatically encoded via encodeURIComponent() or similar\n   *  - all cookie bodies are JSON encoded strings and are manually encoded/decoded\n   */\n  private jsCookie: JsCookiesCompat;\n  private cookieAttributes: CookieAttributes;\n  constructor({\n    prefix = \"gbStickyBuckets__\",\n    jsCookie,\n    cookieAttributes = { expires: 180 }, // 180 days\n  }: {\n    prefix?: string;\n    jsCookie: JsCookiesCompat;\n    cookieAttributes?: CookieAttributes;\n  }) {\n    super();\n    this.prefix = prefix;\n    this.jsCookie = jsCookie;\n    this.cookieAttributes = cookieAttributes;\n  }\n  getAssignmentsSync(attributeName: string, attributeValue: string) {\n    const key = this.getKey(attributeName, attributeValue);\n    let doc: StickyAssignmentsDocument | null = null;\n    if (!this.jsCookie) return doc;\n    try {\n      const raw = this.jsCookie.get(key);\n      const data = JSON.parse(raw || \"{}\");\n      if (data.attributeName && data.attributeValue && data.assignments) {\n        doc = data;\n      }\n    } catch (e) {\n      // Ignore cookie errors\n    }\n    return doc;\n  }\n  async saveAssignmentsSync(doc: StickyAssignmentsDocument) {\n    const key = this.getKey(doc.attributeName, doc.attributeValue);\n    if (!this.jsCookie) return;\n    const str = JSON.stringify(doc);\n    const { domain, ...hostOnlyAttributes } = this.cookieAttributes;\n    if (!domain) {\n      this.jsCookie.set(key, str, this.cookieAttributes);\n      return;\n    }\n    // Remove any legacy host-only cookie first - it would shadow the\n    // domain-scoped one on reads\n    this.jsCookie.remove(key, hostOnlyAttributes);\n    this.jsCookie.set(key, str, this.cookieAttributes);\n    // Browsers silently reject a cookie whose domain doesn't cover this host\n    // (e.g. a typo) - fall back to host-only so assignments still persist\n    if (this.jsCookie.get(key) !== str) {\n      this.jsCookie.set(key, str, hostOnlyAttributes);\n    }\n  }\n}\n\nexport class RedisStickyBucketService extends StickyBucketService {\n  /** Intended to be used with npm: 'ioredis'. **/\n  private redis: IORedisCompat | undefined;\n  constructor({ redis }: { redis: IORedisCompat }) {\n    super();\n    this.redis = redis;\n  }\n  async getAllAssignments(\n    attributes: Record<string, string>,\n  ): Promise<Record<StickyAttributeKey, StickyAssignmentsDocument>> {\n    const docs: Record<StickyAttributeKey, StickyAssignmentsDocument> = {};\n    const keys = Object.entries(attributes).map(\n      ([attributeName, attributeValue]) =>\n        getStickyBucketAttributeKey(attributeName, attributeValue),\n    );\n    if (!this.redis) return docs;\n    await this.redis.mget(...keys).then((values) => {\n      values.forEach((raw) => {\n        try {\n          const data = JSON.parse(raw || \"{}\");\n          if (\n            data.attributeName &&\n            \"attributeValue\" in data &&\n            data.assignments\n          ) {\n            const key = getStickyBucketAttributeKey(\n              data.attributeName,\n              toString(data.attributeValue),\n            );\n            docs[key] = data;\n          }\n        } catch (e) {\n          // ignore redis doc parse errors\n        }\n      });\n    });\n    return docs;\n  }\n  async getAssignments(_attributeName: string, _attributeValue: string) {\n    // not implemented\n    return null;\n  }\n  async saveAssignments(doc: StickyAssignmentsDocument) {\n    const key = this.getKey(doc.attributeName, doc.attributeValue);\n    if (!this.redis) return;\n    await this.redis.set(key, JSON.stringify(doc));\n  }\n}\n"],"mappings":";;;AAKA,SAASA,QAAQ,QAAQ,YAAQ;AACjC,SAASC,2BAA2B,QAAQ,YAAQ;AAwCpD;AACA;AACA;AACA,OAAO,MAAeC,mBAAmB,CAAC;EAGxCC,WAAWA,CAACC,IAA0B,EAAE;IACtCA,IAAI,GAAGA,IAAI,IAAI,CAAC,CAAC;IACjB,IAAI,CAACC,MAAM,GAAGD,IAAI,CAACC,MAAM,IAAI,EAAE;EACjC;EASA;AACF;AACA;AACA;AACA;EACE,MAAMC,iBAAiBA,CACrBC,UAAkC,EAC8B;IAChE,MAAMC,IAA+C,GAAG,CAAC,CAAC;IAC1D,CACE,MAAMC,OAAO,CAACC,GAAG,CACfC,MAAM,CAACC,OAAO,CAACL,UAAU,CAAC,CAACM,GAAG,CAACC,IAAA;MAAA,IAAC,CAACC,aAAa,EAAEC,cAAc,CAAC,GAAAF,IAAA;MAAA,OAC7D,IAAI,CAACG,cAAc,CAACF,aAAa,EAAEC,cAAc,CAAC;IAAA,CACpD,CACF,CAAC,EACDE,OAAO,CAAEC,GAAG,IAAK;MACjB,IAAIA,GAAG,EAAE;QACP,MAAMC,GAAG,GAAGnB,2BAA2B,CACrCkB,GAAG,CAACJ,aAAa,EACjBI,GAAG,CAACH,cACN,CAAC;QACDR,IAAI,CAACY,GAAG,CAAC,GAAGD,GAAG;MACjB;IACF,CAAC,CAAC;IACF,OAAOX,IAAI;EACb;EAEAa,MAAMA,CAACN,aAAqB,EAAEC,cAAsB,EAAU;IAC5D,UAAAM,MAAA,CAAU,IAAI,CAACjB,MAAM,EAAAiB,MAAA,CAAGP,aAAa,QAAAO,MAAA,CAAKN,cAAc;EAC1D;AACF;AAEA,OAAO,MAAeO,uBAAuB,SAASrB,mBAAmB,CAAC;EAQxE,MAAMe,cAAcA,CAACF,a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