@ionite/redis-core 0.0.24-beta.20261024.47 → 0.0.24-beta.20261024.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -457,7 +457,7 @@ declare class RedisSessionStore<TExtended = object> implements SessionStore<TExt
457
457
  delete(sid: string): Promise<void>;
458
458
  deleteByIdpSid(idpSid: string): Promise<void>;
459
459
  }
460
- import { BaseTenant, Ionite, ListOptions as ListOptions6, ListResult as ListResult6, SetTenantIntegrationOptions, StagedRequestRecord, TenantIntegration, TenantIonCache, TenantStore } from "@ionite/core";
460
+ import { BaseTenant, Ionite, ListOptions as ListOptions6, ListResult as ListResult6, SetTenantIntegrationOptions, TenantIntegration, TenantIonCache, TenantStore } from "@ionite/core";
461
461
  type RedisTenantStoreOptions = RedisStoreOptions & {
462
462
  /**
463
463
  * App-owned cache of per-tenant `Ionite` instances (see `TenantIonCache`). Required to
@@ -478,8 +478,6 @@ declare class RedisTenantStore<TTenant extends BaseTenant = BaseTenant> implemen
478
478
  getIon(id: string): Promise<Ionite | undefined>;
479
479
  setIntegration(tenantId: string, integration: TenantIntegration | undefined, options?: SetTenantIntegrationOptions): Promise<TTenant | undefined>;
480
480
  getByIntegrationHandleHash(handleHash: string): Promise<TTenant | undefined>;
481
- setStagedRequest(requestUriHash: string, record: StagedRequestRecord): Promise<void>;
482
- getStagedRequest(requestUriHash: string): Promise<StagedRequestRecord | undefined>;
483
481
  getByRequestTokenHash(requestTokenHash: string): Promise<TTenant | undefined>;
484
482
  replaceActionRequest(expectedRequestTokenHash: string, tenant: TTenant): Promise<TTenant | undefined>;
485
483
  getByIoniteId(ioniteId: string): Promise<TTenant | undefined>;
package/dist/index.js CHANGED
@@ -43,11 +43,11 @@ for i=1,W do
43
43
  redis.call('SREM',k,unpack(members))
44
44
  end
45
45
  end
46
- return 'ok'`;class w{constructor(){this.claims=[];this.writes=[]}claimUnique(e,t){return this.claims.push({key:e,owner:t}),this}set(e,t){return this.writes.push({op:"set",key:e,value:t}),this}setex(e,t,s){return this.writes.push({op:"setex",key:e,ttl:Math.max(1,Math.floor(t)),value:s}),this}del(e){return this.writes.push({op:"del",key:e}),this}sadd(e,...t){if(t.length>0)this.writes.push({op:"sadd",key:e,members:t});return this}srem(e,...t){if(t.length>0)this.writes.push({op:"srem",key:e,members:t});return this}async exec(e){if(A(e))return this.execLua(e);return this.execSequential(e)}async execLua(e){if(this.claims.length>0||this.writes.length<=z)return ne(e,this.claims,this.writes);for(let t=0;t<this.writes.length;t+=z)await ne(e,[],this.writes.slice(t,t+z));return"ok"}async execSequential(e){for(let t of this.claims){let s=await e.get(t.key);if(s!=null&&s!==t.owner)return"conflict"}for(let t of this.writes)switch(t.op){case"set":await e.set(t.key,t.value);break;case"setex":await e.setex(t.key,t.ttl,t.value);break;case"del":await e.del(t.key);break;case"sadd":await e.sadd(t.key,...t.members);break;case"srem":await e.srem(t.key,...t.members);break}return"ok"}}async function ne(e,t,s){let r=[],i=[String(t.length)];for(let n of t)r.push(n.key),i.push(n.owner);i.push(String(s.length));for(let n of s)switch(n.op){case"set":i.push("set"),r.push(n.key),i.push(n.value);break;case"setex":i.push("setex"),r.push(n.key),i.push(String(n.ttl),n.value);break;case"del":i.push("del"),r.push(n.key);break;case"sadd":i.push("sadd"),r.push(n.key),i.push(String(n.members.length),...n.members);break;case"srem":i.push("srem"),r.push(n.key),i.push(String(n.members.length),...n.members);break}return String(await e.runScript($e,r,i))==="conflict"?"conflict":"ok"}import{list as ze,matchesListFilter as We}from"@ionite/core";var ae=100,oe=1000;function C(e){let t=e?.limit,s=t==null||!Number.isFinite(t)||t<=0?ae:Math.min(Math.floor(t),oe);return{...e,limit:s}}function R(e,t,s=(r,i)=>r[i]){let r=Math.max(0,t?.start??0),i=t?.limit,a=t?.filter?e.filter((l)=>We({requestable:s(l,"requestable"),userName:s(l,"userName"),clientId:s(l,"clientId"),externalId:s(l,"externalId"),updatedAt:s(l,"updatedAt")},t.filter)):e,n=a.length,o=i!=null?r+i:void 0,d=a.slice(r,o);return ze(n,d,r,i)}import{defaultLogger as Je}from"@ionite/core";function f(e,t){let s=t.log??Je,r={"ion.operation":"redis.revive","ion.outcome":"corrupt",store:t.store,...t.key?{key:t.key}:{}},i;try{i=JSON.parse(e)}catch{s.warn("Redis store: discarded corrupt JSON payload (failed to parse)",r);return}if(i===null||typeof i!=="object"||Array.isArray(i)){s.warn("Redis store: discarded JSON payload that is not a record object",r);return}return i}import{createHash as Fe}from"node:crypto";import{defaultLogger as Xe}from"@ionite/core";var Ze=4096,de=new Set,ce=new Set;function le(e,t){e.delete(t),e.add(t);while(e.size>Ze){let s=e.values().next().value;if(s===void 0)break;e.delete(s)}}function x(e,t){let s=e.keyPrefix;if(typeof s!=="string"||s.length===0)throw Error('Redis store keyPrefix is required and must be a non-empty string. Pass an explicit per-tenant prefix (e.g. "ion:t:<tenantId>:") so tenant keyspaces never collide.');if(t){let r=`${t}\x00${s}`;if(de.has(r)&&!ce.has(r))m(e).warn(`Redis ${t} constructed twice with the same keyPrefix "${s}". Each tenant MUST use a distinct keyPrefix (e.g. "ion:t:<tenantId>:") so tenant keyspaces never collide; sharing a prefix across tenants lets them read/write each other's data.`),le(ce,r);le(de,r)}return s}function m(e){return e.logger??Xe}function S(e,...t){return e+t.join(":")}var Qe=/^[A-Za-z0-9_.@|-]{1,64}$/;function g(e){if(Qe.test(e))return`=${e}`;return`#${Fe("sha256").update(e,"utf8").digest("base64url").slice(0,22)}`}var tt="access:ids",st="access:subject:",it="access:target:";function rt(e){return JSON.stringify({...e,createdAt:e.createdAt.toISOString(),updatedAt:e.updatedAt.toISOString()})}function W(e,t){let s=f(e,{store:"access",log:t});if(s===void 0)return;return{...s,createdAt:new Date(s.createdAt),updatedAt:new Date(s.updatedAt)}}function ge(e){return{id:e.id,subject:e.subject,subjectType:e.subjectType,targetType:e.targetType,target:e.target,resources:e.resources,applyToApplication:e.applyToApplication,provenance:e.provenance,status:e.status,metadata:e.metadata}}function he(e){let t=J(e.subject),s=J(e.target);if(!t)throw Error("Access change subject must resolve to a non-empty id.");if(!e.targetType)throw Error("Access change targetType is required.");if(!s)throw Error("Access change target must resolve to a non-empty id.");return{id:e.id??et(e),subjectId:t,targetId:s}}class ye{constructor(e){this.redis=e.redis,this.prefix=x(e,"access-assignment-store"),this.log=m(e)}key(...e){return S(this.prefix,...e)}idsSetKey(){return this.key(tt)}accessStorageKey(e){return this.key("access",g(e))}subjectIndexKey(e,t){return this.key(`${st}${t}:${g(e)}`)}targetIndexKey(e,t){return this.key(it+e,g(t))}async grant(e){ue(e.subjectType,"Access change subjectType");let t=he(e),s=this.accessStorageKey(t.id),r=await this.redis.get(s),i=r?W(r,this.log):void 0,a=new Date,n={...e,id:t.id,status:e.status??"active",subjectId:t.subjectId,targetId:t.targetId,createdAt:i?.createdAt??a,updatedAt:a},o=new w;o.set(s,rt(n)),o.sadd(this.idsSetKey(),t.id),o.sadd(this.subjectIndexKey(t.subjectId,e.subjectType),t.id),o.sadd(this.targetIndexKey(e.targetType,t.targetId),t.id),await o.exec(this.redis)}async revoke(e){let t=he(e);if(await this.redis.get(this.accessStorageKey(t.id))==null)return;let r=new w;r.del(this.accessStorageKey(t.id)),r.srem(this.idsSetKey(),t.id),r.srem(this.subjectIndexKey(t.subjectId,e.subjectType),t.id),r.srem(this.targetIndexKey(e.targetType,t.targetId),t.id),await r.exec(this.redis)}async get(e){let t=await this.redis.get(this.accessStorageKey(e));if(t==null)return;let s=W(t,this.log);return s?ge(s):void 0}async list(e){return this.listInMemory(C(e))}async listByTarget(e,t,s){let r=await this.redis.smembers(this.targetIndexKey(e,t.trim()));return this.listFromIds(r,s)}async listBySubject(e,t,s){ue(t);let r=J(e);if(!r)return pe(0,[],s?.start??0,s?.limit);let i=await this.redis.smembers(this.subjectIndexKey(r,t));return this.listFromIds(i,s)}async listInMemory(e){let t=await this.redis.smembers(this.idsSetKey());return this.listFromIds(t,e)}async listFromIds(e,t){if(e.length===0)return pe(0,[],t?.start??0,t?.limit);let r=[...e].sort().map((o)=>this.accessStorageKey(o)),a=(await this.redis.mget(r)).filter((o)=>o!=null).map((o)=>W(o,this.log)).filter((o)=>o!=null).filter((o)=>(o.status??"active")==="active"),n=R(a,t);return{...n,items:n.items.map(ge)}}}import{assertValidSubjectTypeScoping as fe,deepEqualPlain as nt,readyCatalogEntry as me}from"@ionite/core";class Se{constructor(e){this.listeners=new Set;let t=e.redis,s=x(e,"access-catalog-store"),r=m(e),i=(a)=>{for(let n of this.listeners)n(a)};this.groups=new B(t,s,"group",i,r),this.roles=new B(t,s,"role",i,r),this.permissions=new B(t,s,"permission",i,r)}afterChange(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}}class we{constructor(e){this.listeners=new Set;this.redis=e.redis,this.prefix=x(e,"resource-store"),this.log=m(e)}key(...e){return S(this.prefix,"authz","resource",...e)}entityKey(e){return this.key(g(e))}idsSetKey(){return this.key("ids")}async get(e){let t=await this.redis.get(this.entityKey(e));if(t==null)return;let s=f(t,{store:"authz:resource",key:e,log:this.log});return s===void 0?void 0:s}async list(e){let t=await this.redis.smembers(this.idsSetKey());if(t.length===0)return R([],e);let r=(await this.redis.mget(t.map((i)=>this.entityKey(i)))).filter((i)=>i!=null).map((i)=>f(i,{store:"authz:resource",log:this.log})).filter((i)=>i!==void 0).map((i)=>i);return R(r,e)}async children(e){return(await this.list()).items.filter((s)=>(typeof s.parent==="string"?s.parent:s.parent?.id)===e)}changed(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}async set(e){await new w().set(this.entityKey(e.id),JSON.stringify(e)).sadd(this.idsSetKey(),e.id).exec(this.redis),this.emitChange({id:e.id})}async delete(e){await new w().del(this.entityKey(e)).srem(this.idsSetKey(),e).exec(this.redis),this.emitChange({id:e,deleted:!0})}emitChange(e){for(let t of this.listeners)t(e)}}class B{constructor(e,t,s,r,i){this.redis=e;this.prefix=t;this.kind=s;this.emit=r;this.log=i}key(...e){return S(this.prefix,"authz",this.kind,...e)}idsSetKey(){return this.key("ids")}entityKey(e){return this.key(g(e))}async get(e){let t=await this.redis.get(this.entityKey(e));if(t==null)return;let s=f(t,{store:`authz:${this.kind}`,key:e,log:this.log});return s===void 0?void 0:s}set(e){fe(e);let t,s=!0,r=(async()=>{t=await this.get(e.id),s=!t||!nt(t,e);let i=new w;i.set(this.entityKey(e.id),JSON.stringify(e)),i.sadd(this.idsSetKey(),e.id),await i.exec(this.redis)})();return r.then(()=>{if(!s)return;this.emit({op:"set",kind:this.kind,entity:e,previous:t})},(i)=>{this.log?.warn("authz catalog store: background persist failed",{"ion.operation":`authz.catalog.${this.kind}.set`,"ion.outcome":"error",id:e.id,error:i instanceof Error?i.message:String(i)})}),me(e,r)}insertIfAbsent(e){fe(e);let t={...e},s=!1,r=(async()=>{if(!A(this.redis))throw Error("RedisAccessCatalogStore.insertIfAbsent requires a Redis adapter with runScript support.");let i=JSON.stringify(e),a=await this.redis.runScript(`local cur=redis.call('GET',KEYS[1])
46
+ return 'ok'`;class S{constructor(){this.claims=[];this.writes=[]}claimUnique(e,t){return this.claims.push({key:e,owner:t}),this}set(e,t){return this.writes.push({op:"set",key:e,value:t}),this}setex(e,t,s){return this.writes.push({op:"setex",key:e,ttl:Math.max(1,Math.floor(t)),value:s}),this}del(e){return this.writes.push({op:"del",key:e}),this}sadd(e,...t){if(t.length>0)this.writes.push({op:"sadd",key:e,members:t});return this}srem(e,...t){if(t.length>0)this.writes.push({op:"srem",key:e,members:t});return this}async exec(e){if(A(e))return this.execLua(e);return this.execSequential(e)}async execLua(e){if(this.claims.length>0||this.writes.length<=z)return ne(e,this.claims,this.writes);for(let t=0;t<this.writes.length;t+=z)await ne(e,[],this.writes.slice(t,t+z));return"ok"}async execSequential(e){for(let t of this.claims){let s=await e.get(t.key);if(s!=null&&s!==t.owner)return"conflict"}for(let t of this.writes)switch(t.op){case"set":await e.set(t.key,t.value);break;case"setex":await e.setex(t.key,t.ttl,t.value);break;case"del":await e.del(t.key);break;case"sadd":await e.sadd(t.key,...t.members);break;case"srem":await e.srem(t.key,...t.members);break}return"ok"}}async function ne(e,t,s){let r=[],i=[String(t.length)];for(let n of t)r.push(n.key),i.push(n.owner);i.push(String(s.length));for(let n of s)switch(n.op){case"set":i.push("set"),r.push(n.key),i.push(n.value);break;case"setex":i.push("setex"),r.push(n.key),i.push(String(n.ttl),n.value);break;case"del":i.push("del"),r.push(n.key);break;case"sadd":i.push("sadd"),r.push(n.key),i.push(String(n.members.length),...n.members);break;case"srem":i.push("srem"),r.push(n.key),i.push(String(n.members.length),...n.members);break}return String(await e.runScript($e,r,i))==="conflict"?"conflict":"ok"}import{list as ze,matchesListFilter as We}from"@ionite/core";var ae=100,oe=1000;function C(e){let t=e?.limit,s=t==null||!Number.isFinite(t)||t<=0?ae:Math.min(Math.floor(t),oe);return{...e,limit:s}}function R(e,t,s=(r,i)=>r[i]){let r=Math.max(0,t?.start??0),i=t?.limit,a=t?.filter?e.filter((l)=>We({requestable:s(l,"requestable"),userName:s(l,"userName"),clientId:s(l,"clientId"),externalId:s(l,"externalId"),updatedAt:s(l,"updatedAt")},t.filter)):e,n=a.length,o=i!=null?r+i:void 0,d=a.slice(r,o);return ze(n,d,r,i)}import{defaultLogger as Je}from"@ionite/core";function w(e,t){let s=t.log??Je,r={"ion.operation":"redis.revive","ion.outcome":"corrupt",store:t.store,...t.key?{key:t.key}:{}},i;try{i=JSON.parse(e)}catch{s.warn("Redis store: discarded corrupt JSON payload (failed to parse)",r);return}if(i===null||typeof i!=="object"||Array.isArray(i)){s.warn("Redis store: discarded JSON payload that is not a record object",r);return}return i}import{createHash as Fe}from"node:crypto";import{defaultLogger as Xe}from"@ionite/core";var Ze=4096,de=new Set,ce=new Set;function le(e,t){e.delete(t),e.add(t);while(e.size>Ze){let s=e.values().next().value;if(s===void 0)break;e.delete(s)}}function x(e,t){let s=e.keyPrefix;if(typeof s!=="string"||s.length===0)throw Error('Redis store keyPrefix is required and must be a non-empty string. Pass an explicit per-tenant prefix (e.g. "ion:t:<tenantId>:") so tenant keyspaces never collide.');if(t){let r=`${t}\x00${s}`;if(de.has(r)&&!ce.has(r))f(e).warn(`Redis ${t} constructed twice with the same keyPrefix "${s}". Each tenant MUST use a distinct keyPrefix (e.g. "ion:t:<tenantId>:") so tenant keyspaces never collide; sharing a prefix across tenants lets them read/write each other's data.`),le(ce,r);le(de,r)}return s}function f(e){return e.logger??Xe}function m(e,...t){return e+t.join(":")}var Qe=/^[A-Za-z0-9_.@|-]{1,64}$/;function g(e){if(Qe.test(e))return`=${e}`;return`#${Fe("sha256").update(e,"utf8").digest("base64url").slice(0,22)}`}var tt="access:ids",st="access:subject:",it="access:target:";function rt(e){return JSON.stringify({...e,createdAt:e.createdAt.toISOString(),updatedAt:e.updatedAt.toISOString()})}function W(e,t){let s=w(e,{store:"access",log:t});if(s===void 0)return;return{...s,createdAt:new Date(s.createdAt),updatedAt:new Date(s.updatedAt)}}function ge(e){return{id:e.id,subject:e.subject,subjectType:e.subjectType,targetType:e.targetType,target:e.target,resources:e.resources,applyToApplication:e.applyToApplication,provenance:e.provenance,status:e.status,metadata:e.metadata}}function he(e){let t=J(e.subject),s=J(e.target);if(!t)throw Error("Access change subject must resolve to a non-empty id.");if(!e.targetType)throw Error("Access change targetType is required.");if(!s)throw Error("Access change target must resolve to a non-empty id.");return{id:e.id??et(e),subjectId:t,targetId:s}}class ye{constructor(e){this.redis=e.redis,this.prefix=x(e,"access-assignment-store"),this.log=f(e)}key(...e){return m(this.prefix,...e)}idsSetKey(){return this.key(tt)}accessStorageKey(e){return this.key("access",g(e))}subjectIndexKey(e,t){return this.key(`${st}${t}:${g(e)}`)}targetIndexKey(e,t){return this.key(it+e,g(t))}async grant(e){ue(e.subjectType,"Access change subjectType");let t=he(e),s=this.accessStorageKey(t.id),r=await this.redis.get(s),i=r?W(r,this.log):void 0,a=new Date,n={...e,id:t.id,status:e.status??"active",subjectId:t.subjectId,targetId:t.targetId,createdAt:i?.createdAt??a,updatedAt:a},o=new S;o.set(s,rt(n)),o.sadd(this.idsSetKey(),t.id),o.sadd(this.subjectIndexKey(t.subjectId,e.subjectType),t.id),o.sadd(this.targetIndexKey(e.targetType,t.targetId),t.id),await o.exec(this.redis)}async revoke(e){let t=he(e);if(await this.redis.get(this.accessStorageKey(t.id))==null)return;let r=new S;r.del(this.accessStorageKey(t.id)),r.srem(this.idsSetKey(),t.id),r.srem(this.subjectIndexKey(t.subjectId,e.subjectType),t.id),r.srem(this.targetIndexKey(e.targetType,t.targetId),t.id),await r.exec(this.redis)}async get(e){let t=await this.redis.get(this.accessStorageKey(e));if(t==null)return;let s=W(t,this.log);return s?ge(s):void 0}async list(e){return this.listInMemory(C(e))}async listByTarget(e,t,s){let r=await this.redis.smembers(this.targetIndexKey(e,t.trim()));return this.listFromIds(r,s)}async listBySubject(e,t,s){ue(t);let r=J(e);if(!r)return pe(0,[],s?.start??0,s?.limit);let i=await this.redis.smembers(this.subjectIndexKey(r,t));return this.listFromIds(i,s)}async listInMemory(e){let t=await this.redis.smembers(this.idsSetKey());return this.listFromIds(t,e)}async listFromIds(e,t){if(e.length===0)return pe(0,[],t?.start??0,t?.limit);let r=[...e].sort().map((o)=>this.accessStorageKey(o)),a=(await this.redis.mget(r)).filter((o)=>o!=null).map((o)=>W(o,this.log)).filter((o)=>o!=null).filter((o)=>(o.status??"active")==="active"),n=R(a,t);return{...n,items:n.items.map(ge)}}}import{assertValidSubjectTypeScoping as fe,deepEqualPlain as nt,readyCatalogEntry as me}from"@ionite/core";class Se{constructor(e){this.listeners=new Set;let t=e.redis,s=x(e,"access-catalog-store"),r=f(e),i=(a)=>{for(let n of this.listeners)n(a)};this.groups=new B(t,s,"group",i,r),this.roles=new B(t,s,"role",i,r),this.permissions=new B(t,s,"permission",i,r)}afterChange(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}}class we{constructor(e){this.listeners=new Set;this.redis=e.redis,this.prefix=x(e,"resource-store"),this.log=f(e)}key(...e){return m(this.prefix,"authz","resource",...e)}entityKey(e){return this.key(g(e))}idsSetKey(){return this.key("ids")}async get(e){let t=await this.redis.get(this.entityKey(e));if(t==null)return;let s=w(t,{store:"authz:resource",key:e,log:this.log});return s===void 0?void 0:s}async list(e){let t=await this.redis.smembers(this.idsSetKey());if(t.length===0)return R([],e);let r=(await this.redis.mget(t.map((i)=>this.entityKey(i)))).filter((i)=>i!=null).map((i)=>w(i,{store:"authz:resource",log:this.log})).filter((i)=>i!==void 0).map((i)=>i);return R(r,e)}async children(e){return(await this.list()).items.filter((s)=>(typeof s.parent==="string"?s.parent:s.parent?.id)===e)}changed(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}async set(e){await new S().set(this.entityKey(e.id),JSON.stringify(e)).sadd(this.idsSetKey(),e.id).exec(this.redis),this.emitChange({id:e.id})}async delete(e){await new S().del(this.entityKey(e)).srem(this.idsSetKey(),e).exec(this.redis),this.emitChange({id:e,deleted:!0})}emitChange(e){for(let t of this.listeners)t(e)}}class B{constructor(e,t,s,r,i){this.redis=e;this.prefix=t;this.kind=s;this.emit=r;this.log=i}key(...e){return m(this.prefix,"authz",this.kind,...e)}idsSetKey(){return this.key("ids")}entityKey(e){return this.key(g(e))}async get(e){let t=await this.redis.get(this.entityKey(e));if(t==null)return;let s=w(t,{store:`authz:${this.kind}`,key:e,log:this.log});return s===void 0?void 0:s}set(e){fe(e);let t,s=!0,r=(async()=>{t=await this.get(e.id),s=!t||!nt(t,e);let i=new S;i.set(this.entityKey(e.id),JSON.stringify(e)),i.sadd(this.idsSetKey(),e.id),await i.exec(this.redis)})();return r.then(()=>{if(!s)return;this.emit({op:"set",kind:this.kind,entity:e,previous:t})},(i)=>{this.log?.warn("authz catalog store: background persist failed",{"ion.operation":`authz.catalog.${this.kind}.set`,"ion.outcome":"error",id:e.id,error:i instanceof Error?i.message:String(i)})}),me(e,r)}insertIfAbsent(e){fe(e);let t={...e},s=!1,r=(async()=>{if(!A(this.redis))throw Error("RedisAccessCatalogStore.insertIfAbsent requires a Redis adapter with runScript support.");let i=JSON.stringify(e),a=await this.redis.runScript(`local cur=redis.call('GET',KEYS[1])
47
47
  if cur then return {0,cur} end
48
48
  redis.call('SET',KEYS[1],ARGV[1])
49
49
  redis.call('SADD',KEYS[2],ARGV[2])
50
- return {1,ARGV[1]}`,[this.entityKey(e.id),this.idsSetKey()],[i,e.id]);if(!Array.isArray(a)||a.length<2)throw Error("RedisAccessCatalogStore.insertIfAbsent received an invalid Redis response.");s=String(a[0])==="1";let n=String(a[1]),o=f(n,{store:`authz:${this.kind}`,key:e.id,log:this.log});if(!o)throw Error("RedisAccessCatalogStore.insertIfAbsent could not parse the winning row.");let d=t;for(let l of Object.keys(d))delete d[l];Object.assign(d,o)})();return r.then(()=>{if(!s)return;this.emit({op:"set",kind:this.kind,entity:t,previous:void 0})},(i)=>{this.log?.warn("authz catalog store: atomic insert-if-absent failed",{"ion.operation":`authz.catalog.${this.kind}.insert_if_absent`,"ion.outcome":"error",id:e.id,error:i instanceof Error?i.message:String(i)})}),me(t,r)}async delete(e){let t=await this.get(e),s=new w;if(s.del(this.entityKey(e)),s.srem(this.idsSetKey(),e),await s.exec(this.redis),!t)return;this.emit({op:"delete",kind:this.kind,entity:t})}async list(e){let t=await this.redis.smembers(this.idsSetKey());if(t.length===0)return R([],e);let r=(await this.redis.mget(t.map((i)=>this.entityKey(i)))).filter((i)=>i!=null).map((i)=>f(i,{store:`authz:${this.kind}`,log:this.log})).filter((i)=>i!==void 0).map((i)=>i);return R(r,e)}}import{accessRefId as K,assertRequiredSubjectType as O}from"@ionite/core";var H="__app__",xe=100;function at(e){if(!Array.isArray(e))return[];return e.map((t)=>t==null?"":String(t)).filter((t)=>t.length>0)}var ot=`local rootId=ARGV[1]
50
+ return {1,ARGV[1]}`,[this.entityKey(e.id),this.idsSetKey()],[i,e.id]);if(!Array.isArray(a)||a.length<2)throw Error("RedisAccessCatalogStore.insertIfAbsent received an invalid Redis response.");s=String(a[0])==="1";let n=String(a[1]),o=w(n,{store:`authz:${this.kind}`,key:e.id,log:this.log});if(!o)throw Error("RedisAccessCatalogStore.insertIfAbsent could not parse the winning row.");let d=t;for(let l of Object.keys(d))delete d[l];Object.assign(d,o)})();return r.then(()=>{if(!s)return;this.emit({op:"set",kind:this.kind,entity:t,previous:void 0})},(i)=>{this.log?.warn("authz catalog store: atomic insert-if-absent failed",{"ion.operation":`authz.catalog.${this.kind}.insert_if_absent`,"ion.outcome":"error",id:e.id,error:i instanceof Error?i.message:String(i)})}),me(t,r)}async delete(e){let t=await this.get(e),s=new S;if(s.del(this.entityKey(e)),s.srem(this.idsSetKey(),e),await s.exec(this.redis),!t)return;this.emit({op:"delete",kind:this.kind,entity:t})}async list(e){let t=await this.redis.smembers(this.idsSetKey());if(t.length===0)return R([],e);let r=(await this.redis.mget(t.map((i)=>this.entityKey(i)))).filter((i)=>i!=null).map((i)=>w(i,{store:`authz:${this.kind}`,log:this.log})).filter((i)=>i!==void 0).map((i)=>i);return R(r,e)}}import{accessRefId as K,assertRequiredSubjectType as D}from"@ionite/core";var H="__app__",xe=100;function at(e){if(!Array.isArray(e))return[];return e.map((t)=>t==null?"":String(t)).filter((t)=>t.length>0)}var ot=`local rootId=ARGV[1]
51
51
  local A=tonumber(ARGV[2])
52
52
  local R=tonumber(ARGV[3])
53
53
  local rootKey=KEYS[1]
@@ -173,7 +173,7 @@ if D==0 then
173
173
  else
174
174
  redis.call('SADD',KEYS[2],subjectMember)
175
175
  end
176
- return 'ok'`;function D(e,t){return`${t}:${e}`}function N(e){return e&&e.length>0?e:H}function F(e){return JSON.stringify([e.subject,e.targetType,e.target,e.rToken])}function j(e){let t;try{t=JSON.parse(e)}catch{t=[]}let[s,r,i,a]=Array.isArray(t)?t:[];return{subject:s??"",targetType:r??"permission",target:i??"",rToken:a??H}}class ke{constructor(e){this.redis=e.redis,this.prefix=x(e,"access-index"),this.log=m(e)}key(...e){return S(this.prefix,...e)}subjectKeyPart(e){let t=e.indexOf(":");if(t<=0)return g(e);return`${e.slice(0,t)}:${g(e.slice(t+1))}`}hasKey(e,t,s,r){return this.key("idx:has",this.subjectKeyPart(e),t,g(s),g(r))}anyKey(e,t,s){return this.key("idx:any",this.subjectKeyPart(e),t,g(s))}edgeRootsKey(e,t,s,r){return this.key("idx:er",this.subjectKeyPart(e),t,g(s),g(r))}tripleKey(e,t,s){return this.key("idx:tr",this.subjectKeyPart(e),t,g(s))}rootKey(e){return this.key("idx:root",g(e))}subjectKey(e){return this.key("idx:subj",this.subjectKeyPart(e))}subjectsKey(){return this.key("idx:subjects")}disabledKey(e){return this.key("idx:disabled",this.subjectKeyPart(e))}async has(e,t,s,r,i){O(i);let a=K(e),n=K(s);if(!a||!n)return{allow:!1};let o=D(a,i);if(r===void 0){let[p,E]=await this.redis.mget([this.disabledKey(o),this.anyKey(o,t,n)]);if(p!=null)return{allow:!1,metadata:{reason:"subject_disabled"}};return E!=null?this.allow(a,i,t,n,void 0):{allow:!1}}let d=K(r),l=await this.redis.mget([this.disabledKey(o),this.hasKey(o,t,n,N(d)),this.hasKey(o,t,n,H)]);if(l[0]!=null)return{allow:!1,metadata:{reason:"subject_disabled"}};if(l[1]!=null)return this.allow(a,i,t,n,d);if(l[2]!=null)return this.allow(a,i,t,n,void 0);return{allow:!1}}async hasGroup(e,t,s,r){return this.has(e,"group",t,s,r)}async hasRole(e,t,s,r){return this.has(e,"role",t,s,r)}async hasPermission(e,t,s,r){return this.has(e,"permission",t,s,r)}async hasAny(e,t,s){if(t.length===0)return{allow:!1};this.warnLargeCheck("redis.access_index.has_any",t.length);let r=await this.evaluateTargets(e,t,s);for(let i of r)if(i.allow)return i;return{allow:!1}}async hasAll(e,t,s){if(t.length===0){let a=K(e);if(a){if(await this.redis.get(this.disabledKey(D(a,s)))!=null)return{allow:!1,metadata:{reason:"subject_disabled"}}}return{allow:!0}}this.warnLargeCheck("redis.access_index.has_all",t.length);let r=await this.evaluateTargets(e,t,s),i=[];for(let a of r){if(!a.allow)return{allow:!1,matched:i};if(a.matched)i.push(...a.matched)}return{allow:!0,matched:i}}async evaluateTargets(e,t,s){let r=K(e);if(!r)return t.map(()=>({allow:!1}));let i=D(r,s),a=[this.disabledKey(i)],n=t.map((d)=>{let l=K(d.target);if(!l)return{kind:"invalid"};if(d.resource===void 0){let T=a.push(this.anyKey(i,d.targetType,l))-1;return{kind:"any",targetType:d.targetType,targetId:l,idx:T}}let p=K(d.resource),E=a.push(this.hasKey(i,d.targetType,l,N(p)))-1,y=a.push(this.hasKey(i,d.targetType,l,H))-1;return{kind:"resource",targetType:d.targetType,targetId:l,resourceId:p,idxResource:E,idxApp:y}}),o=await this.redis.mget(a);if(o[0]!=null)return t.map(()=>({allow:!1,metadata:{reason:"subject_disabled"}}));return n.map((d)=>{if(d.kind==="invalid")return{allow:!1};if(d.kind==="any")return o[d.idx]!=null?this.allow(r,s,d.targetType,d.targetId,void 0):{allow:!1};if(o[d.idxResource]!=null)return this.allow(r,s,d.targetType,d.targetId,d.resourceId);if(o[d.idxApp]!=null)return this.allow(r,s,d.targetType,d.targetId,void 0);return{allow:!1}})}edgeKeys(e){return[this.edgeRootsKey(e.subject,e.targetType,e.target,e.rToken),this.hasKey(e.subject,e.targetType,e.target,e.rToken),this.tripleKey(e.subject,e.targetType,e.target),this.anyKey(e.subject,e.targetType,e.target),this.subjectKey(e.subject)]}async materialize(e,t){let s=new Map;for(let n of t){let o=K(n.subject),d=K(n.target);if(!o||!d)continue;O(n.subjectType,"Effective edge subjectType");let l=D(o,n.subjectType),p=N(n.resource),E={subject:l,targetType:n.targetType,target:d,rToken:p};s.set(F(E),E)}let r=new Set(await this.redis.smembers(this.rootKey(e))),i=[];for(let[n,o]of s)if(!r.has(n))i.push({encoded:n,d:o});let a=[];for(let n of r)if(!s.has(n))a.push({encoded:n,d:j(n)});if(i.length===0&&a.length===0)return;if(A(this.redis)){let n=[this.rootKey(e),this.subjectsKey()],o=[e,String(i.length),String(a.length)];for(let{encoded:d,d:l}of i)n.push(...this.edgeKeys(l)),o.push(d,l.rToken,l.subject);for(let{encoded:d,d:l}of a)n.push(...this.edgeKeys(l)),o.push(d,l.rToken);await this.redis.runScript(ot,n,o);return}for(let{encoded:n,d:o}of i)await this.redis.sadd(this.edgeRootsKey(o.subject,o.targetType,o.target,o.rToken),e),await this.redis.set(this.hasKey(o.subject,o.targetType,o.target,o.rToken),"1"),await this.redis.sadd(this.tripleKey(o.subject,o.targetType,o.target),o.rToken),await this.redis.set(this.anyKey(o.subject,o.targetType,o.target),"1"),await this.redis.sadd(this.rootKey(e),n),await this.redis.sadd(this.subjectKey(o.subject),n),await this.redis.sadd(this.subjectsKey(),o.subject);for(let{encoded:n,d:o}of a)await this.dropRootFromEdge(e,o.subject,o.targetType,o.target,o.rToken),await this.redis.srem(this.rootKey(e),n)}async replaceSubject(e,t,s){if(!A(this.redis))throw Error("RedisAccessIndex.replaceSubject requires an adapter with atomic runScript support.");let r=K(e);if(!r)return;let i=D(r,t),a=[];for(let y of s){let T=K(y.subject);O(y.subjectType,"Effective edge subjectType");let v=y.subjectType;if(T!==r||v!==t)throw Error(`AccessIndex.replaceSubject received an edge for ${v}:${T}; expected ${i}.`);let b=K(y.target);if(!b)continue;let I={subject:i,targetType:y.targetType,target:b,rToken:N(y.resource)};a.push({rootId:y.rootId,encoded:F(I),d:I})}let o=(await this.redis.smembers(this.subjectKey(i))).map(j),d=await Promise.all(o.map((y)=>this.redis.smembers(this.edgeRootsKey(y.subject,y.targetType,y.target,y.rToken)))),l=[...new Set(d.flat())],p=[this.subjectKey(i),this.subjectsKey()];for(let y of o){let[T,v,b,I]=this.edgeKeys(y);p.push(T,v,b,I)}for(let y of l)p.push(this.rootKey(y));for(let y of a){let[T,v,b,I]=this.edgeKeys(y.d);p.push(this.rootKey(y.rootId),T,v,b,I)}let E=[i,String(o.length),String(l.length),String(a.length)];for(let y of a)E.push(y.rootId,y.encoded,y.d.rToken);await this.redis.runScript(ut,p,E)}async removeByRoot(e){let t=this.rootKey(e),s=await this.redis.smembers(t);if(s.length===0){await this.redis.del(t);return}if(A(this.redis)){let r=[t],i=[e,String(s.length)];for(let a of s){let n=j(a);r.push(...this.edgeKeys(n)),i.push(a,n.rToken)}await this.redis.runScript(dt,r,i);return}for(let r of s){let{subject:i,targetType:a,target:n,rToken:o}=j(r);await this.dropRootFromEdge(e,i,a,n,o)}await this.redis.del(t)}async listSubjects(){let e=await this.redis.smembers(this.subjectsKey()),t=[];for(let s of e){let r=s.indexOf(":");if(r<=0)throw Error(`AccessIndex subject key "${s}" is missing a subjectType prefix.`);let i=s.slice(0,r);O(i,"AccessIndex subject key subjectType"),t.push({subjectType:i,subject:s.slice(r+1)})}return t}async setSubjectDisabled(e,t,s){let r=K(e);if(!r)return;let i=this.disabledKey(D(r,t));if(s)await this.redis.set(i,"1");else await this.redis.del(i)}async isSubjectDisabled(e,t){O(t);let s=K(e);if(!s)return!1;return await this.redis.get(this.disabledKey(D(s,t)))!=null}async clear(e,t){if(e===void 0){let i=await this.redis.smembers(this.subjectsKey());for(let a of i)await this.clearSubject(a);await this.redis.del(this.subjectsKey());return}O(t);let s=K(e);if(!s)return;let r=D(s,t);await this.clearSubject(r),await this.redis.srem(this.subjectsKey(),r)}async clearSubject(e){let t=this.subjectKey(e),s=await this.redis.smembers(t);if(s.length===0){await this.redis.del(t);return}if(A(this.redis)){let r=[t];for(let a of s){let{targetType:n,target:o,rToken:d}=j(a);r.push(this.edgeRootsKey(e,n,o,d),this.hasKey(e,n,o,d),this.tripleKey(e,n,o),this.anyKey(e,n,o))}let i=at(await this.redis.runScript(ct,r,[String(s.length)]));if(i.length>0)await this.redis.runScript(lt,i.map((a)=>this.rootKey(a)),[]);return}for(let r of s){let{targetType:i,target:a,rToken:n}=j(r),o=this.edgeRootsKey(e,i,a,n),d=await this.redis.smembers(o);for(let p of d)await this.redis.srem(this.rootKey(p),r);if(await this.redis.del(o),await this.redis.del(this.hasKey(e,i,a,n)),await this.redis.srem(this.tripleKey(e,i,a),n),(await this.redis.smembers(this.tripleKey(e,i,a))).length===0)await this.redis.del(this.tripleKey(e,i,a)),await this.redis.del(this.anyKey(e,i,a))}await this.redis.del(t)}async dropRootFromEdge(e,t,s,r,i){let a=this.edgeRootsKey(t,s,r,i);if(await this.redis.srem(a,e),(await this.redis.smembers(a)).length>0)return;await this.redis.del(a),await this.redis.del(this.hasKey(t,s,r,i));let o=F({subject:t,targetType:s,target:r,rToken:i});if(await this.redis.srem(this.subjectKey(t),o),await this.redis.srem(this.tripleKey(t,s,r),i),(await this.redis.smembers(this.tripleKey(t,s,r))).length===0)await this.redis.del(this.tripleKey(t,s,r)),await this.redis.del(this.anyKey(t,s,r))}allow(e,t,s,r,i){return{allow:!0,matched:[{subject:e,subjectType:t,targetType:s,target:r,resources:i?[i]:void 0}]}}warnLargeCheck(e,t){if(t<=xe)return;this.log.warn("Redis access index check received a large bounded target set; issuing per-target reads.",{"ion.operation":e,"ion.outcome":"degraded",count:t,threshold:xe})}}var pt=512;async function gt(e,t,s=512){if(e.length===0)return[];let r=s>0?s:512,i=[];for(let a=0;a<e.length;a+=r){let n=await t(e.slice(a,a+r));for(let o of n)i.push(o??null)}return i}import{list as ht,StoreConflictError as yt}from"@ionite/core";var ft="customer:ids",mt="customer:name:",St="customer:external:";function wt(e){let t=e.createdAt??new Date,s=e.updatedAt??t,r={...e,createdAt:t.toISOString(),updatedAt:s.toISOString()};if(r.ciam&&typeof r.ciam==="object"&&r.ciam!==null){let i=r.ciam;if(i.expires instanceof Date)i.expires=i.expires.toISOString()}return JSON.stringify(r)}function X(e,t){let s=f(e,{store:"customer",log:t});if(s===void 0)return;if(s.ciam&&typeof s.ciam==="object"&&s.ciam!==null){let r=s.ciam;if(typeof r.expires==="string")r.expires=new Date(r.expires)}return{...s,createdAt:typeof s.createdAt==="string"?new Date(s.createdAt):void 0,updatedAt:typeof s.updatedAt==="string"?new Date(s.updatedAt):void 0}}class Te{constructor(e){this.redis=e.redis,this.prefix=x(e,"customer-store"),this.log=m(e)}key(...e){return S(this.prefix,...e)}entityKey(e){return this.key("customer",g(e))}idsSetKey(){return this.key(ft)}nameIndexKey(e){return this.key(mt+g(e))}externalIdIndexKey(e){return this.key(St+g(e))}async get(e){let t=await this.redis.get(this.entityKey(e));if(t==null)return;return X(t,this.log)}async lookup(e){if(e.id){let t=await this.get(e.id);if(t)return t}if(e.userName){let t=await this.redis.get(this.nameIndexKey(e.userName.toLowerCase()));if(t!=null)return this.get(t)}if(e.externalId)return this.getByExternalId(e.externalId);return}async getByExternalId(e){let t=await this.redis.get(this.externalIdIndexKey(e));if(t==null)return;return this.get(t)}async upsert(e){let t=e.id?.trim()||crypto.randomUUID(),s={...e,id:t},r=this.entityKey(t),i=await this.redis.get(r),a=i!=null?X(i,this.log)??null:null,n=s.userName?.toLowerCase(),o=a?.userName?.toLowerCase(),d=s.externalId,l=a?.externalId,p=new w;if(n)p.claimUnique(this.nameIndexKey(n),t);if(d)p.claimUnique(this.externalIdIndexKey(d),t);if(o&&o!==n)p.del(this.nameIndexKey(o));if(l&&l!==d)p.del(this.externalIdIndexKey(l));if(p.set(r,wt(s)),n)p.set(this.nameIndexKey(n),t);if(d)p.set(this.externalIdIndexKey(d),t);if(p.sadd(this.idsSetKey(),t),await p.exec(this.redis)==="conflict")throw new yt(`userName "${s.userName}" is already in use`,"unique_violation","userName");return s}async delete(e){let t=await this.get(e);if(t==null)return 0;let s=new w;if(s.del(this.entityKey(e)),t.userName)s.del(this.nameIndexKey(t.userName.toLowerCase()));if(t.externalId)s.del(this.externalIdIndexKey(t.externalId));return s.srem(this.idsSetKey(),e),await s.exec(this.redis),1}async list(e){let t=C(e),s=(await this.redis.smembers(this.idsSetKey())).sort();if(s.length===0)return ht(0,[],t.start??0,t.limit);let r=s.map((n)=>this.entityKey(n)),a=(await this.redis.mget(r)).filter((n)=>n!=null).map((n)=>X(n,this.log)).filter((n)=>n!=null);return R(a,t)}}import{StoreConflictError as xt}from"@ionite/core";var kt="delegate:ids";function Re(e){let t=e.createdAt??new Date,s=e.updatedAt??t;return JSON.stringify({...e,createdAt:t.toISOString(),updatedAt:s.toISOString(),expiresAt:e.expiresAt?.toISOString(),previousTokenHashExpiresAt:e.previousTokenHashExpiresAt?.toISOString(),lastUsedAt:e.lastUsedAt?.toISOString()})}function Z(e,t){let s=f(e,{store:"delegate",log:t});if(s===void 0)return;let r=(i)=>typeof i==="string"?new Date(i):void 0;return{...s,createdAt:r(s.createdAt),updatedAt:r(s.updatedAt),expiresAt:r(s.expiresAt),previousTokenHashExpiresAt:r(s.previousTokenHashExpiresAt),lastUsedAt:r(s.lastUsedAt)}}class Ae{constructor(e){this.redis=e.redis,this.prefix=x(e,"delegate-store"),this.log=m(e)}key(...e){return S(this.prefix,...e)}entityKey(e){return this.key("delegate",g(e))}tokenHashKey(e){return this.key("delegate:token",g(e))}externalIdKey(e){return this.key("delegate:external",g(e))}idsSetKey(){return this.key(kt)}async get(e){let t=await this.redis.get(this.entityKey(e));return t==null?void 0:Z(t,this.log)}async lookup(e){return await this.get(e.id)??(e.externalId?this.getByExternalId(e.externalId):void 0)}async getByTokenHash(e){let t=await this.redis.get(this.tokenHashKey(e));if(!t)return;let s=await this.get(t);if(!s)return;if(s.tokenHash===e)return s;if(s.previousTokenHash===e&&s.previousTokenHashExpiresAt&&s.previousTokenHashExpiresAt.getTime()>Date.now())return s;return}async getByExternalId(e){let t=await this.redis.get(this.externalIdKey(e));return t?this.get(t):void 0}async listByOwner(e,t,s){let r=await this.all();return R(r.filter((i)=>i.owner.id===e&&i.owner.type===t),C(s))}async upsert(e){let t=e.id?.trim()||crypto.randomUUID(),s=await this.get(t),r=new Date,i={...e,id:t,createdAt:s?.createdAt??e.createdAt??r,updatedAt:r},a=new w;if(a.claimUnique(this.tokenHashKey(i.tokenHash),t),i.previousTokenHash)a.claimUnique(this.tokenHashKey(i.previousTokenHash),t);if(i.externalId)a.claimUnique(this.externalIdKey(i.externalId),t);if(s?.tokenHash&&s.tokenHash!==i.tokenHash)a.del(this.tokenHashKey(s.tokenHash));if(s?.previousTokenHash&&s.previousTokenHash!==i.previousTokenHash)a.del(this.tokenHashKey(s.previousTokenHash));if(s?.externalId&&s.externalId!==i.externalId)a.del(this.externalIdKey(s.externalId));if(a.set(this.entityKey(t),Re(i)),a.set(this.tokenHashKey(i.tokenHash),t),i.previousTokenHash)a.set(this.tokenHashKey(i.previousTokenHash),t);if(i.externalId)a.set(this.externalIdKey(i.externalId),t);if(a.sadd(this.idsSetKey(),t),await a.exec(this.redis)==="conflict")throw new xt("Delegate token hash or externalId is already in use","unique_violation");return i}async delete(e){let t=await this.get(e);if(!t)return 0;let s=new w;if(s.del(this.entityKey(e)),s.del(this.tokenHashKey(t.tokenHash)),t.previousTokenHash)s.del(this.tokenHashKey(t.previousTokenHash));if(t.externalId)s.del(this.externalIdKey(t.externalId));return s.srem(this.idsSetKey(),e),await s.exec(this.redis),1}async list(e){return R(await this.all(),C(e))}async touch(e,t){let s=this.entityKey(e);for(let r=0;r<3;r+=1){let i=await this.redis.get(s);if(i==null)return;let a=Z(i,this.log);if(!a)return;let n=Re({...a,lastUsedAt:t}),o=await G(this.redis,s,i,n);if(o==="ok"||o==="missing")return;if(o==="unsupported"){await this.redis.set(s,n);return}}this.log.warn("Delegate usage timestamp update lost a concurrent race",{"ion.operation":"delegate.touch","ion.outcome":"skipped",delegateId:e})}async all(){let e=(await this.redis.smembers(this.idsSetKey())).sort();if(e.length===0)return[];return(await this.redis.mget(e.map((s)=>this.entityKey(s)))).filter((s)=>s!=null).map((s)=>Z(s,this.log)).filter((s)=>s!==void 0)}}import{createHash as Tt}from"node:crypto";function Ee(e){return Tt("sha1").update(e,"utf8").digest("hex")}function Rt(e){return(e instanceof Error?e.message:String(e)).includes("NOSCRIPT")}function At(e){let t=new Map;return async(s,r,i)=>{let a=t.get(s);if(!a)a=Ee(s),t.set(s,a);try{return await e.evalsha(a,r,i)}catch(n){if(Rt(n))return e.eval(s,r,i);throw n}}}function be(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Et(e){let t=be(e.clientOptions)?{...e.clientOptions}:be(e)?{...e}:{};return delete t.redisUrl,delete t.clientOptions,{redisUrl:(typeof e.redisUrl==="string"?e.redisUrl.trim():"")||void 0,clientOptions:t}}import{defaultLogger as bt}from"@ionite/core";function ve(e,t){return`${e}:${encodeURIComponent(t)}`}function vt(e,t){if(typeof e!=="object"||e===null||Array.isArray(e))return!1;let s=e,r=s.headers;return s.kind==="delivery"&&typeof s.key==="string"&&typeof s.rawBody==="string"&&typeof r==="object"&&r!==null&&r.requestId===t&&typeof r.keyId==="string"&&typeof r.signature==="string"}function It(e,t={}){if(!e.getdel)throw Error("Redis adapter must implement getdel() for LFV callback coordination");let s=e.getdel.bind(e),r=t.channelPrefix?.trim()||"ionite:lfv:otp",i=t.logger??bt;return{async put(a,n,o){if(n.kind!=="delivery"||n.headers.requestId!==a)throw Error("LFV callback mailbox only accepts matching delivery envelopes");let d=Math.max(1,Math.ceil(o/1000));await e.setex(ve(r,a),d,JSON.stringify(n))},async take(a){let n=await s(ve(r,a));if(n==null)return;let o;try{o=JSON.parse(n)}catch(d){i.warn("Invalid JSON received from LFV Redis callback mailbox",{"ion.operation":"lfv.callback.redis.take","ion.outcome":"rejected",requestId:a,error:d instanceof Error?d.message:String(d)});return}if(!vt(o,a)){i.warn("Invalid envelope received from LFV Redis callback mailbox",{"ion.operation":"lfv.callback.redis.take","ion.outcome":"rejected",requestId:a});return}return o}}}import{StoreConflictError as Kt}from"@ionite/core";function Pt(e){return JSON.stringify({token:e.token,customer:e.customer,createdAt:e.createdAt.toISOString(),expiresAt:e.expiresAt.toISOString()})}function Ie(e,t){let s=f(e,{store:"magic-link",log:t});if(s===void 0)return;return{...s,createdAt:new Date(s.createdAt),expiresAt:new Date(s.expiresAt)}}class Ke{constructor(e){this.redis=e.redis,this.prefix=x(e,"magic-link-store"),this.log=m(e)}key(e){return S(this.prefix,"magic",g(e))}async create(e,t,s){let r=this.key(e),i={token:e,customer:t,createdAt:new Date,expiresAt:s},a=Math.max(1,Math.floor((s.getTime()-Date.now())/1000));if(await _(this.redis,r,Pt(i),{ttlSeconds:a})==="conflict")throw new Kt(`Magic link with token ${e} already exists`,"already_exists","token")}async get(e){let t=await this.redis.get(this.key(e));if(t==null)return null;return Ie(t,this.log)??null}async getAndDelete(e){let t=this.key(e),s;if(typeof this.redis.getdel==="function")s=await this.redis.getdel(t);else if(s=await this.redis.get(t),s!=null)await this.redis.del(t);if(s==null)return null;let r=Ie(s,this.log);if(r==null)return null;if(Date.now()>r.expiresAt.getTime())return null;return r}async delete(e){await this.redis.del(this.key(e))}}import{defaultLogger as Lt}from"@ionite/core";function Ct(e,t){if(typeof t!=="number"||t<=0)return e;return new Promise((s,r)=>{let i=setTimeout(()=>{r(Error(`Reactive Redis adapter did not become ready within ${t}ms`))},t);e.then(()=>{clearTimeout(i),s()},(a)=>{clearTimeout(i),r(a)})})}function Dt(){let e,t;return{promise:new Promise((r,i)=>{e=r,t=i}),resolve:e,reject:t}}function Pe(e){return typeof e==="function"}function Ot(e){let t=e.logger??Lt,s=e.sourceName?.trim()||"redis",r=e.path.trim(),i,a,n=!1,o,d,l,p=!1,E=!1,y=!1,T=new Map,v=Promise.resolve(),b=Dt();b.promise.catch(()=>{});let I={async get(c){return P((u)=>u.get(c))},async set(c,u){await P((h)=>h.set(c,u))},async setex(c,u,h){await P((k)=>k.setex(c,u,h))},async expire(c,u){await P((h)=>h.expire(c,u))},async del(c){await P((u)=>u.del(c))},async sadd(c,...u){await P((h)=>h.sadd(c,...u))},async srem(c,...u){await P((h)=>h.srem(c,...u))},async smembers(c){return P((u)=>u.smembers(c))},async mget(c){return P((u)=>u.mget(c))},async publish(c,u){await P(async(h)=>{if(!h.publish)throw Error("Active Redis adapter does not support publish (Pub/Sub)");await h.publish(c,u)})},async subscribeChannel(c,u){let h=T.get(c);if(!h){let L=new Set;h={listeners:L,dispatch:(Me)=>{for(let Ye of Array.from(L))try{Ye(Me)}catch(Y){t.warn("Redis channel listener threw",{"ion.operation":"redis.adapter.subscribe","ion.outcome":"failure",sourceName:s,path:r,channel:c,error:Y instanceof Error?Y.message:String(Y)})}}},T.set(c,h)}let k=h;k.listeners.add(u);try{await He(c,k)}catch(L){if(k.listeners.delete(u),k.listeners.size===0)T.delete(c);throw L}return async()=>{if(k.listeners.delete(u),k.listeners.size===0){T.delete(c);let L=k.unsubscribe;k.unsubscribe=void 0,await L?.()}}},ready(c){return Ct(b.promise,c)},isReady(){return i!==void 0},async close(){if(p=!0,re(),!n)n=!0,b.reject(Error(`Reactive Redis adapter for source "${s}" at path "${r}" was closed before becoming ready.`));await v.catch(()=>{}),await U(i),i=void 0;for(let c of T.values())c.unsubscribe=void 0;T.clear(),M()}};function se(c){v=v.then(c).catch((u)=>{if(!n)n=!0,b.reject(u);t.warn("Reactive Redis adapter update failed",{"ion.operation":"redis.adapter.update","ion.outcome":"degraded",sourceName:s,path:r,error:u instanceof Error?u.message:String(u)})})}async function ie(){if(p)throw Error(`Reactive Redis adapter for source "${s}" at path "${r}" is closed.`);let c=i?.adapter;if(c)return c;if(await v.catch(()=>{}),p)throw Error(`Reactive Redis adapter for source "${s}" at path "${r}" is closed.`);let u=i?.adapter;if(u)return u;if(await b.promise,p)throw Error(`Reactive Redis adapter for source "${s}" at path "${r}" is closed.`);let h=i?.adapter;if(!h)throw Error(`Reactive Redis adapter for source "${s}" at path "${r}" did not become ready.`);return h}async function P(c){let u=await ie();return c(u)}function re(){a?.(),a=void 0}async function He(c,u){if(u.unsubscribe)return;if(!u.attaching)u.attaching=(async()=>{let h=await ie();if(!h.subscribeChannel)throw Error("Active Redis adapter does not support subscribeChannel (Pub/Sub)");if(u.listeners.size===0)return;u.unsubscribe=await h.subscribeChannel(c,u.dispatch)})().finally(()=>{u.attaching=void 0});await u.attaching}async function Ve(c){for(let[u,h]of T){if(h.attaching)await h.attaching.catch(()=>{});if(h.unsubscribe=void 0,!c.subscribeChannel){t.warn("Active Redis adapter does not support subscribeChannel; channel subscriptions dropped.",{"ion.operation":"redis.adapter.capabilities","ion.outcome":"degraded",sourceName:s,path:r,capability:"subscribeChannel"});return}try{h.unsubscribe=await c.subscribeChannel(u,h.dispatch)}catch(k){t.warn("Failed to re-subscribe Redis channel after client rotation",{"ion.operation":"redis.adapter.subscribe","ion.outcome":"failure",sourceName:s,path:r,channel:u,error:k instanceof Error?k.message:String(k)})}}}async function qe(c){re(),a=await c.subscribe(r,(u)=>{se(async()=>{if(p)return;await Ue(u)})},e.subscription??e.secretOptions)}async function Ue(c){if(p)return;let u=`${s}:${r}:${c.metadata.version}`;if(i!==void 0&&d===u&&o===c.metadata.version)return;let h=e.endpointOf?.(c);if(i!==void 0&&h!=null&&h!==""&&l!=null&&l!==""&&h!==l)throw Error(`Reactive Redis adapter for source "${s}" at path "${r}" rejected a rotation that changed the endpoint (${l} -> ${h}); only credentials may rotate under an active adapter.`);let k=await e.createClient(c);if(p){await U(k);return}let L=i;if(i=k,d=u,o=c.metadata.version,h!=null&&h!=="")l=h;if(M(),L!==void 0)await Ve(k.adapter);if(!n)n=!0,b.resolve();await U(L)}async function U(c){if(!c?.dispose)return;await c.dispose()}function M(){let c=i?.adapter;if(c?.runScript&&Pe(c.runScript))I.runScript=async(u,h,k)=>P(async(L)=>{if(!L.runScript)throw Error("Active Redis adapter does not support runScript");return L.runScript(u,h,k)});else if(delete I.runScript,c!==void 0&&!E)E=!0,t.warn("Active Redis adapter does not support runScript (EVAL); stores fall back to non-isolated writes.",{"ion.operation":"redis.adapter.capabilities","ion.outcome":"degraded",sourceName:s,path:r,capability:"runScript"});if(c?.getdel&&Pe(c.getdel))I.getdel=async(u)=>P(async(h)=>{if(!h.getdel)return null;return h.getdel(u)});else if(delete I.getdel,c!==void 0&&!y)y=!0,t.warn("Active Redis adapter does not support getdel (GETDEL); single-use consume falls back to get+del.",{"ion.operation":"redis.adapter.capabilities","ion.outcome":"degraded",sourceName:s,path:r,capability:"getdel"})}return M(),se(async()=>{if(p)return;await qe(e.source)}),I}import{StoreConflictError as jt}from"@ionite/core";var _t=5;function Gt(e,t){let s;try{s=JSON.parse(e)}catch{return}if(s==null||typeof s!=="object"||Array.isArray(s))return;return JSON.stringify({...s,...t})}function Le(e){return JSON.stringify({...e,createdAt:e.createdAt.toISOString()})}function V(e,t){let s=f(e,{store:"session",log:t});if(s===void 0)return;return{...s,createdAt:new Date(s.createdAt)}}function Q(e){if(!e)return;let t=e instanceof Date?e.getTime():new Date(e).getTime();if(Number.isNaN(t))return;let s=Math.ceil((t-Date.now())/1000);return s>0?s:1}class Ce{constructor(e){this.capabilities={derivedEntitlements:!0};this.redis=e.redis,this.prefix=x(e,"session-store"),this.log=m(e)}key(e){return S(this.prefix,"session",g(e))}idpSidKey(e){return S(this.prefix,"session-idp-sid",g(e))}async addToIdpIndex(e){if(!e.idpSid)return;let t=this.idpSidKey(e.idpSid);await this.redis.sadd(t,e.sid);let s=Q(e.expiresAt);if(s===void 0)return;let r=await this.redis.ttl?.(t)??-1;await this.redis.expire(t,Math.max(s,r>0?r:0))}async removeFromIdpIndex(e){if(!e.idpSid)return;let t=this.idpSidKey(e.idpSid);if(await this.redis.srem(t,e.sid),(await this.redis.smembers(t)).length===0)await this.redis.del(t)}async create(e){let t=this.key(e.sid),s=Q(e.expiresAt);if(await _(this.redis,t,Le(e),{ttlSeconds:s})==="conflict")throw new jt(`Session with sid ${e.sid} already exists`,"already_exists","sid");await this.addToIdpIndex(e)}async get(e){let t=await this.redis.get(this.key(e));if(t==null)return null;return V(t,this.log)??null}async update(e,t){let s=this.key(e),r=await this.redis.get(s),i=r==null?void 0:V(r,this.log);if(!i)throw Error(`Session with sid ${e} not found`);let a={...i,...t},n=async()=>{if(i.idpSid!==a.idpSid)await this.removeFromIdpIndex(i);await this.addToIdpIndex(a)},o=JSON.parse(JSON.stringify(t)),d="expiresAt"in o?Q(o.expiresAt):void 0;if(A(this.redis))for(let T=0;T<_t;T++){let v=await this.redis.get(s);if(v==null)throw Error(`Session with sid ${e} not found`);let b=Gt(v,o);if(b===void 0)throw Error(`Session with sid ${e} not found`);let I=await G(this.redis,s,v,b,d);if(I==="ok"){await n();return}if(I==="missing")throw Error(`Session with sid ${e} not found`)}let l=await this.redis.get(s);if(l==null)throw Error(`Session with sid ${e} not found`);let p=V(l,this.log);if(p==null)throw Error(`Session with sid ${e} not found`);let E={...p,...t},y=Le(E);if(d!=null&&d>0)await this.redis.setex(s,Math.max(1,Math.floor(d)),y);else await this.redis.set(s,y);await n()}async delete(e){let t=await this.redis.get(this.key(e));if(await this.redis.del(this.key(e)),t!=null){let s=V(t,this.log);if(s)await this.removeFromIdpIndex(s)}}async deleteByIdpSid(e){let t=this.idpSidKey(e),s=await this.redis.smembers(t);for(let r of s)await this.delete(r);await this.redis.del(t)}}var Bt="tenant:ids",Nt=`
176
+ return 'ok'`;function O(e,t){return`${t}:${e}`}function N(e){return e&&e.length>0?e:H}function F(e){return JSON.stringify([e.subject,e.targetType,e.target,e.rToken])}function j(e){let t;try{t=JSON.parse(e)}catch{t=[]}let[s,r,i,a]=Array.isArray(t)?t:[];return{subject:s??"",targetType:r??"permission",target:i??"",rToken:a??H}}class ke{constructor(e){this.redis=e.redis,this.prefix=x(e,"access-index"),this.log=f(e)}key(...e){return m(this.prefix,...e)}subjectKeyPart(e){let t=e.indexOf(":");if(t<=0)return g(e);return`${e.slice(0,t)}:${g(e.slice(t+1))}`}hasKey(e,t,s,r){return this.key("idx:has",this.subjectKeyPart(e),t,g(s),g(r))}anyKey(e,t,s){return this.key("idx:any",this.subjectKeyPart(e),t,g(s))}edgeRootsKey(e,t,s,r){return this.key("idx:er",this.subjectKeyPart(e),t,g(s),g(r))}tripleKey(e,t,s){return this.key("idx:tr",this.subjectKeyPart(e),t,g(s))}rootKey(e){return this.key("idx:root",g(e))}subjectKey(e){return this.key("idx:subj",this.subjectKeyPart(e))}subjectsKey(){return this.key("idx:subjects")}disabledKey(e){return this.key("idx:disabled",this.subjectKeyPart(e))}async has(e,t,s,r,i){D(i);let a=K(e),n=K(s);if(!a||!n)return{allow:!1};let o=O(a,i);if(r===void 0){let[p,E]=await this.redis.mget([this.disabledKey(o),this.anyKey(o,t,n)]);if(p!=null)return{allow:!1,metadata:{reason:"subject_disabled"}};return E!=null?this.allow(a,i,t,n,void 0):{allow:!1}}let d=K(r),l=await this.redis.mget([this.disabledKey(o),this.hasKey(o,t,n,N(d)),this.hasKey(o,t,n,H)]);if(l[0]!=null)return{allow:!1,metadata:{reason:"subject_disabled"}};if(l[1]!=null)return this.allow(a,i,t,n,d);if(l[2]!=null)return this.allow(a,i,t,n,void 0);return{allow:!1}}async hasGroup(e,t,s,r){return this.has(e,"group",t,s,r)}async hasRole(e,t,s,r){return this.has(e,"role",t,s,r)}async hasPermission(e,t,s,r){return this.has(e,"permission",t,s,r)}async hasAny(e,t,s){if(t.length===0)return{allow:!1};this.warnLargeCheck("redis.access_index.has_any",t.length);let r=await this.evaluateTargets(e,t,s);for(let i of r)if(i.allow)return i;return{allow:!1}}async hasAll(e,t,s){if(t.length===0){let a=K(e);if(a){if(await this.redis.get(this.disabledKey(O(a,s)))!=null)return{allow:!1,metadata:{reason:"subject_disabled"}}}return{allow:!0}}this.warnLargeCheck("redis.access_index.has_all",t.length);let r=await this.evaluateTargets(e,t,s),i=[];for(let a of r){if(!a.allow)return{allow:!1,matched:i};if(a.matched)i.push(...a.matched)}return{allow:!0,matched:i}}async evaluateTargets(e,t,s){let r=K(e);if(!r)return t.map(()=>({allow:!1}));let i=O(r,s),a=[this.disabledKey(i)],n=t.map((d)=>{let l=K(d.target);if(!l)return{kind:"invalid"};if(d.resource===void 0){let T=a.push(this.anyKey(i,d.targetType,l))-1;return{kind:"any",targetType:d.targetType,targetId:l,idx:T}}let p=K(d.resource),E=a.push(this.hasKey(i,d.targetType,l,N(p)))-1,y=a.push(this.hasKey(i,d.targetType,l,H))-1;return{kind:"resource",targetType:d.targetType,targetId:l,resourceId:p,idxResource:E,idxApp:y}}),o=await this.redis.mget(a);if(o[0]!=null)return t.map(()=>({allow:!1,metadata:{reason:"subject_disabled"}}));return n.map((d)=>{if(d.kind==="invalid")return{allow:!1};if(d.kind==="any")return o[d.idx]!=null?this.allow(r,s,d.targetType,d.targetId,void 0):{allow:!1};if(o[d.idxResource]!=null)return this.allow(r,s,d.targetType,d.targetId,d.resourceId);if(o[d.idxApp]!=null)return this.allow(r,s,d.targetType,d.targetId,void 0);return{allow:!1}})}edgeKeys(e){return[this.edgeRootsKey(e.subject,e.targetType,e.target,e.rToken),this.hasKey(e.subject,e.targetType,e.target,e.rToken),this.tripleKey(e.subject,e.targetType,e.target),this.anyKey(e.subject,e.targetType,e.target),this.subjectKey(e.subject)]}async materialize(e,t){let s=new Map;for(let n of t){let o=K(n.subject),d=K(n.target);if(!o||!d)continue;D(n.subjectType,"Effective edge subjectType");let l=O(o,n.subjectType),p=N(n.resource),E={subject:l,targetType:n.targetType,target:d,rToken:p};s.set(F(E),E)}let r=new Set(await this.redis.smembers(this.rootKey(e))),i=[];for(let[n,o]of s)if(!r.has(n))i.push({encoded:n,d:o});let a=[];for(let n of r)if(!s.has(n))a.push({encoded:n,d:j(n)});if(i.length===0&&a.length===0)return;if(A(this.redis)){let n=[this.rootKey(e),this.subjectsKey()],o=[e,String(i.length),String(a.length)];for(let{encoded:d,d:l}of i)n.push(...this.edgeKeys(l)),o.push(d,l.rToken,l.subject);for(let{encoded:d,d:l}of a)n.push(...this.edgeKeys(l)),o.push(d,l.rToken);await this.redis.runScript(ot,n,o);return}for(let{encoded:n,d:o}of i)await this.redis.sadd(this.edgeRootsKey(o.subject,o.targetType,o.target,o.rToken),e),await this.redis.set(this.hasKey(o.subject,o.targetType,o.target,o.rToken),"1"),await this.redis.sadd(this.tripleKey(o.subject,o.targetType,o.target),o.rToken),await this.redis.set(this.anyKey(o.subject,o.targetType,o.target),"1"),await this.redis.sadd(this.rootKey(e),n),await this.redis.sadd(this.subjectKey(o.subject),n),await this.redis.sadd(this.subjectsKey(),o.subject);for(let{encoded:n,d:o}of a)await this.dropRootFromEdge(e,o.subject,o.targetType,o.target,o.rToken),await this.redis.srem(this.rootKey(e),n)}async replaceSubject(e,t,s){if(!A(this.redis))throw Error("RedisAccessIndex.replaceSubject requires an adapter with atomic runScript support.");let r=K(e);if(!r)return;let i=O(r,t),a=[];for(let y of s){let T=K(y.subject);D(y.subjectType,"Effective edge subjectType");let v=y.subjectType;if(T!==r||v!==t)throw Error(`AccessIndex.replaceSubject received an edge for ${v}:${T}; expected ${i}.`);let b=K(y.target);if(!b)continue;let I={subject:i,targetType:y.targetType,target:b,rToken:N(y.resource)};a.push({rootId:y.rootId,encoded:F(I),d:I})}let o=(await this.redis.smembers(this.subjectKey(i))).map(j),d=await Promise.all(o.map((y)=>this.redis.smembers(this.edgeRootsKey(y.subject,y.targetType,y.target,y.rToken)))),l=[...new Set(d.flat())],p=[this.subjectKey(i),this.subjectsKey()];for(let y of o){let[T,v,b,I]=this.edgeKeys(y);p.push(T,v,b,I)}for(let y of l)p.push(this.rootKey(y));for(let y of a){let[T,v,b,I]=this.edgeKeys(y.d);p.push(this.rootKey(y.rootId),T,v,b,I)}let E=[i,String(o.length),String(l.length),String(a.length)];for(let y of a)E.push(y.rootId,y.encoded,y.d.rToken);await this.redis.runScript(ut,p,E)}async removeByRoot(e){let t=this.rootKey(e),s=await this.redis.smembers(t);if(s.length===0){await this.redis.del(t);return}if(A(this.redis)){let r=[t],i=[e,String(s.length)];for(let a of s){let n=j(a);r.push(...this.edgeKeys(n)),i.push(a,n.rToken)}await this.redis.runScript(dt,r,i);return}for(let r of s){let{subject:i,targetType:a,target:n,rToken:o}=j(r);await this.dropRootFromEdge(e,i,a,n,o)}await this.redis.del(t)}async listSubjects(){let e=await this.redis.smembers(this.subjectsKey()),t=[];for(let s of e){let r=s.indexOf(":");if(r<=0)throw Error(`AccessIndex subject key "${s}" is missing a subjectType prefix.`);let i=s.slice(0,r);D(i,"AccessIndex subject key subjectType"),t.push({subjectType:i,subject:s.slice(r+1)})}return t}async setSubjectDisabled(e,t,s){let r=K(e);if(!r)return;let i=this.disabledKey(O(r,t));if(s)await this.redis.set(i,"1");else await this.redis.del(i)}async isSubjectDisabled(e,t){D(t);let s=K(e);if(!s)return!1;return await this.redis.get(this.disabledKey(O(s,t)))!=null}async clear(e,t){if(e===void 0){let i=await this.redis.smembers(this.subjectsKey());for(let a of i)await this.clearSubject(a);await this.redis.del(this.subjectsKey());return}D(t);let s=K(e);if(!s)return;let r=O(s,t);await this.clearSubject(r),await this.redis.srem(this.subjectsKey(),r)}async clearSubject(e){let t=this.subjectKey(e),s=await this.redis.smembers(t);if(s.length===0){await this.redis.del(t);return}if(A(this.redis)){let r=[t];for(let a of s){let{targetType:n,target:o,rToken:d}=j(a);r.push(this.edgeRootsKey(e,n,o,d),this.hasKey(e,n,o,d),this.tripleKey(e,n,o),this.anyKey(e,n,o))}let i=at(await this.redis.runScript(ct,r,[String(s.length)]));if(i.length>0)await this.redis.runScript(lt,i.map((a)=>this.rootKey(a)),[]);return}for(let r of s){let{targetType:i,target:a,rToken:n}=j(r),o=this.edgeRootsKey(e,i,a,n),d=await this.redis.smembers(o);for(let p of d)await this.redis.srem(this.rootKey(p),r);if(await this.redis.del(o),await this.redis.del(this.hasKey(e,i,a,n)),await this.redis.srem(this.tripleKey(e,i,a),n),(await this.redis.smembers(this.tripleKey(e,i,a))).length===0)await this.redis.del(this.tripleKey(e,i,a)),await this.redis.del(this.anyKey(e,i,a))}await this.redis.del(t)}async dropRootFromEdge(e,t,s,r,i){let a=this.edgeRootsKey(t,s,r,i);if(await this.redis.srem(a,e),(await this.redis.smembers(a)).length>0)return;await this.redis.del(a),await this.redis.del(this.hasKey(t,s,r,i));let o=F({subject:t,targetType:s,target:r,rToken:i});if(await this.redis.srem(this.subjectKey(t),o),await this.redis.srem(this.tripleKey(t,s,r),i),(await this.redis.smembers(this.tripleKey(t,s,r))).length===0)await this.redis.del(this.tripleKey(t,s,r)),await this.redis.del(this.anyKey(t,s,r))}allow(e,t,s,r,i){return{allow:!0,matched:[{subject:e,subjectType:t,targetType:s,target:r,resources:i?[i]:void 0}]}}warnLargeCheck(e,t){if(t<=xe)return;this.log.warn("Redis access index check received a large bounded target set; issuing per-target reads.",{"ion.operation":e,"ion.outcome":"degraded",count:t,threshold:xe})}}var pt=512;async function gt(e,t,s=512){if(e.length===0)return[];let r=s>0?s:512,i=[];for(let a=0;a<e.length;a+=r){let n=await t(e.slice(a,a+r));for(let o of n)i.push(o??null)}return i}import{list as ht,StoreConflictError as yt}from"@ionite/core";var ft="customer:ids",mt="customer:name:",St="customer:external:";function wt(e){let t=e.createdAt??new Date,s=e.updatedAt??t,r={...e,createdAt:t.toISOString(),updatedAt:s.toISOString()};if(r.ciam&&typeof r.ciam==="object"&&r.ciam!==null){let i=r.ciam;if(i.expires instanceof Date)i.expires=i.expires.toISOString()}return JSON.stringify(r)}function X(e,t){let s=w(e,{store:"customer",log:t});if(s===void 0)return;if(s.ciam&&typeof s.ciam==="object"&&s.ciam!==null){let r=s.ciam;if(typeof r.expires==="string")r.expires=new Date(r.expires)}return{...s,createdAt:typeof s.createdAt==="string"?new Date(s.createdAt):void 0,updatedAt:typeof s.updatedAt==="string"?new Date(s.updatedAt):void 0}}class Te{constructor(e){this.redis=e.redis,this.prefix=x(e,"customer-store"),this.log=f(e)}key(...e){return m(this.prefix,...e)}entityKey(e){return this.key("customer",g(e))}idsSetKey(){return this.key(ft)}nameIndexKey(e){return this.key(mt+g(e))}externalIdIndexKey(e){return this.key(St+g(e))}async get(e){let t=await this.redis.get(this.entityKey(e));if(t==null)return;return X(t,this.log)}async lookup(e){if(e.id){let t=await this.get(e.id);if(t)return t}if(e.userName){let t=await this.redis.get(this.nameIndexKey(e.userName.toLowerCase()));if(t!=null)return this.get(t)}if(e.externalId)return this.getByExternalId(e.externalId);return}async getByExternalId(e){let t=await this.redis.get(this.externalIdIndexKey(e));if(t==null)return;return this.get(t)}async upsert(e){let t=e.id?.trim()||crypto.randomUUID(),s={...e,id:t},r=this.entityKey(t),i=await this.redis.get(r),a=i!=null?X(i,this.log)??null:null,n=s.userName?.toLowerCase(),o=a?.userName?.toLowerCase(),d=s.externalId,l=a?.externalId,p=new S;if(n)p.claimUnique(this.nameIndexKey(n),t);if(d)p.claimUnique(this.externalIdIndexKey(d),t);if(o&&o!==n)p.del(this.nameIndexKey(o));if(l&&l!==d)p.del(this.externalIdIndexKey(l));if(p.set(r,wt(s)),n)p.set(this.nameIndexKey(n),t);if(d)p.set(this.externalIdIndexKey(d),t);if(p.sadd(this.idsSetKey(),t),await p.exec(this.redis)==="conflict")throw new yt(`userName "${s.userName}" is already in use`,"unique_violation","userName");return s}async delete(e){let t=await this.get(e);if(t==null)return 0;let s=new S;if(s.del(this.entityKey(e)),t.userName)s.del(this.nameIndexKey(t.userName.toLowerCase()));if(t.externalId)s.del(this.externalIdIndexKey(t.externalId));return s.srem(this.idsSetKey(),e),await s.exec(this.redis),1}async list(e){let t=C(e),s=(await this.redis.smembers(this.idsSetKey())).sort();if(s.length===0)return ht(0,[],t.start??0,t.limit);let r=s.map((n)=>this.entityKey(n)),a=(await this.redis.mget(r)).filter((n)=>n!=null).map((n)=>X(n,this.log)).filter((n)=>n!=null);return R(a,t)}}import{StoreConflictError as xt}from"@ionite/core";var kt="delegate:ids";function Re(e){let t=e.createdAt??new Date,s=e.updatedAt??t;return JSON.stringify({...e,createdAt:t.toISOString(),updatedAt:s.toISOString(),expiresAt:e.expiresAt?.toISOString(),previousTokenHashExpiresAt:e.previousTokenHashExpiresAt?.toISOString(),lastUsedAt:e.lastUsedAt?.toISOString()})}function Z(e,t){let s=w(e,{store:"delegate",log:t});if(s===void 0)return;let r=(i)=>typeof i==="string"?new Date(i):void 0;return{...s,createdAt:r(s.createdAt),updatedAt:r(s.updatedAt),expiresAt:r(s.expiresAt),previousTokenHashExpiresAt:r(s.previousTokenHashExpiresAt),lastUsedAt:r(s.lastUsedAt)}}class Ae{constructor(e){this.redis=e.redis,this.prefix=x(e,"delegate-store"),this.log=f(e)}key(...e){return m(this.prefix,...e)}entityKey(e){return this.key("delegate",g(e))}tokenHashKey(e){return this.key("delegate:token",g(e))}externalIdKey(e){return this.key("delegate:external",g(e))}idsSetKey(){return this.key(kt)}async get(e){let t=await this.redis.get(this.entityKey(e));return t==null?void 0:Z(t,this.log)}async lookup(e){return await this.get(e.id)??(e.externalId?this.getByExternalId(e.externalId):void 0)}async getByTokenHash(e){let t=await this.redis.get(this.tokenHashKey(e));if(!t)return;let s=await this.get(t);if(!s)return;if(s.tokenHash===e)return s;if(s.previousTokenHash===e&&s.previousTokenHashExpiresAt&&s.previousTokenHashExpiresAt.getTime()>Date.now())return s;return}async getByExternalId(e){let t=await this.redis.get(this.externalIdKey(e));return t?this.get(t):void 0}async listByOwner(e,t,s){let r=await this.all();return R(r.filter((i)=>i.owner.id===e&&i.owner.type===t),C(s))}async upsert(e){let t=e.id?.trim()||crypto.randomUUID(),s=await this.get(t),r=new Date,i={...e,id:t,createdAt:s?.createdAt??e.createdAt??r,updatedAt:r},a=new S;if(a.claimUnique(this.tokenHashKey(i.tokenHash),t),i.previousTokenHash)a.claimUnique(this.tokenHashKey(i.previousTokenHash),t);if(i.externalId)a.claimUnique(this.externalIdKey(i.externalId),t);if(s?.tokenHash&&s.tokenHash!==i.tokenHash)a.del(this.tokenHashKey(s.tokenHash));if(s?.previousTokenHash&&s.previousTokenHash!==i.previousTokenHash)a.del(this.tokenHashKey(s.previousTokenHash));if(s?.externalId&&s.externalId!==i.externalId)a.del(this.externalIdKey(s.externalId));if(a.set(this.entityKey(t),Re(i)),a.set(this.tokenHashKey(i.tokenHash),t),i.previousTokenHash)a.set(this.tokenHashKey(i.previousTokenHash),t);if(i.externalId)a.set(this.externalIdKey(i.externalId),t);if(a.sadd(this.idsSetKey(),t),await a.exec(this.redis)==="conflict")throw new xt("Delegate token hash or externalId is already in use","unique_violation");return i}async delete(e){let t=await this.get(e);if(!t)return 0;let s=new S;if(s.del(this.entityKey(e)),s.del(this.tokenHashKey(t.tokenHash)),t.previousTokenHash)s.del(this.tokenHashKey(t.previousTokenHash));if(t.externalId)s.del(this.externalIdKey(t.externalId));return s.srem(this.idsSetKey(),e),await s.exec(this.redis),1}async list(e){return R(await this.all(),C(e))}async touch(e,t){let s=this.entityKey(e);for(let r=0;r<3;r+=1){let i=await this.redis.get(s);if(i==null)return;let a=Z(i,this.log);if(!a)return;let n=Re({...a,lastUsedAt:t}),o=await G(this.redis,s,i,n);if(o==="ok"||o==="missing")return;if(o==="unsupported"){await this.redis.set(s,n);return}}this.log.warn("Delegate usage timestamp update lost a concurrent race",{"ion.operation":"delegate.touch","ion.outcome":"skipped",delegateId:e})}async all(){let e=(await this.redis.smembers(this.idsSetKey())).sort();if(e.length===0)return[];return(await this.redis.mget(e.map((s)=>this.entityKey(s)))).filter((s)=>s!=null).map((s)=>Z(s,this.log)).filter((s)=>s!==void 0)}}import{createHash as Tt}from"node:crypto";function Ee(e){return Tt("sha1").update(e,"utf8").digest("hex")}function Rt(e){return(e instanceof Error?e.message:String(e)).includes("NOSCRIPT")}function At(e){let t=new Map;return async(s,r,i)=>{let a=t.get(s);if(!a)a=Ee(s),t.set(s,a);try{return await e.evalsha(a,r,i)}catch(n){if(Rt(n))return e.eval(s,r,i);throw n}}}function be(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Et(e){let t=be(e.clientOptions)?{...e.clientOptions}:be(e)?{...e}:{};return delete t.redisUrl,delete t.clientOptions,{redisUrl:(typeof e.redisUrl==="string"?e.redisUrl.trim():"")||void 0,clientOptions:t}}import{defaultLogger as bt}from"@ionite/core";function ve(e,t){return`${e}:${encodeURIComponent(t)}`}function vt(e,t){if(typeof e!=="object"||e===null||Array.isArray(e))return!1;let s=e,r=s.headers;return s.kind==="delivery"&&typeof s.key==="string"&&typeof s.rawBody==="string"&&typeof r==="object"&&r!==null&&r.requestId===t&&typeof r.keyId==="string"&&typeof r.signature==="string"}function It(e,t={}){if(!e.getdel)throw Error("Redis adapter must implement getdel() for LFV callback coordination");let s=e.getdel.bind(e),r=t.channelPrefix?.trim()||"ionite:lfv:otp",i=t.logger??bt;return{async put(a,n,o){if(n.kind!=="delivery"||n.headers.requestId!==a)throw Error("LFV callback mailbox only accepts matching delivery envelopes");let d=Math.max(1,Math.ceil(o/1000));await e.setex(ve(r,a),d,JSON.stringify(n))},async take(a){let n=await s(ve(r,a));if(n==null)return;let o;try{o=JSON.parse(n)}catch(d){i.warn("Invalid JSON received from LFV Redis callback mailbox",{"ion.operation":"lfv.callback.redis.take","ion.outcome":"rejected",requestId:a,error:d instanceof Error?d.message:String(d)});return}if(!vt(o,a)){i.warn("Invalid envelope received from LFV Redis callback mailbox",{"ion.operation":"lfv.callback.redis.take","ion.outcome":"rejected",requestId:a});return}return o}}}import{StoreConflictError as Kt}from"@ionite/core";function Pt(e){return JSON.stringify({token:e.token,customer:e.customer,createdAt:e.createdAt.toISOString(),expiresAt:e.expiresAt.toISOString()})}function Ie(e,t){let s=w(e,{store:"magic-link",log:t});if(s===void 0)return;return{...s,createdAt:new Date(s.createdAt),expiresAt:new Date(s.expiresAt)}}class Ke{constructor(e){this.redis=e.redis,this.prefix=x(e,"magic-link-store"),this.log=f(e)}key(e){return m(this.prefix,"magic",g(e))}async create(e,t,s){let r=this.key(e),i={token:e,customer:t,createdAt:new Date,expiresAt:s},a=Math.max(1,Math.floor((s.getTime()-Date.now())/1000));if(await _(this.redis,r,Pt(i),{ttlSeconds:a})==="conflict")throw new Kt(`Magic link with token ${e} already exists`,"already_exists","token")}async get(e){let t=await this.redis.get(this.key(e));if(t==null)return null;return Ie(t,this.log)??null}async getAndDelete(e){let t=this.key(e),s;if(typeof this.redis.getdel==="function")s=await this.redis.getdel(t);else if(s=await this.redis.get(t),s!=null)await this.redis.del(t);if(s==null)return null;let r=Ie(s,this.log);if(r==null)return null;if(Date.now()>r.expiresAt.getTime())return null;return r}async delete(e){await this.redis.del(this.key(e))}}import{defaultLogger as Lt}from"@ionite/core";function Ct(e,t){if(typeof t!=="number"||t<=0)return e;return new Promise((s,r)=>{let i=setTimeout(()=>{r(Error(`Reactive Redis adapter did not become ready within ${t}ms`))},t);e.then(()=>{clearTimeout(i),s()},(a)=>{clearTimeout(i),r(a)})})}function Ot(){let e,t;return{promise:new Promise((r,i)=>{e=r,t=i}),resolve:e,reject:t}}function Pe(e){return typeof e==="function"}function Dt(e){let t=e.logger??Lt,s=e.sourceName?.trim()||"redis",r=e.path.trim(),i,a,n=!1,o,d,l,p=!1,E=!1,y=!1,T=new Map,v=Promise.resolve(),b=Ot();b.promise.catch(()=>{});let I={async get(c){return P((u)=>u.get(c))},async set(c,u){await P((h)=>h.set(c,u))},async setex(c,u,h){await P((k)=>k.setex(c,u,h))},async expire(c,u){await P((h)=>h.expire(c,u))},async del(c){await P((u)=>u.del(c))},async sadd(c,...u){await P((h)=>h.sadd(c,...u))},async srem(c,...u){await P((h)=>h.srem(c,...u))},async smembers(c){return P((u)=>u.smembers(c))},async mget(c){return P((u)=>u.mget(c))},async publish(c,u){await P(async(h)=>{if(!h.publish)throw Error("Active Redis adapter does not support publish (Pub/Sub)");await h.publish(c,u)})},async subscribeChannel(c,u){let h=T.get(c);if(!h){let L=new Set;h={listeners:L,dispatch:(Ye)=>{for(let qe of Array.from(L))try{qe(Ye)}catch(q){t.warn("Redis channel listener threw",{"ion.operation":"redis.adapter.subscribe","ion.outcome":"failure",sourceName:s,path:r,channel:c,error:q instanceof Error?q.message:String(q)})}}},T.set(c,h)}let k=h;k.listeners.add(u);try{await He(c,k)}catch(L){if(k.listeners.delete(u),k.listeners.size===0)T.delete(c);throw L}return async()=>{if(k.listeners.delete(u),k.listeners.size===0){T.delete(c);let L=k.unsubscribe;k.unsubscribe=void 0,await L?.()}}},ready(c){return Ct(b.promise,c)},isReady(){return i!==void 0},async close(){if(p=!0,re(),!n)n=!0,b.reject(Error(`Reactive Redis adapter for source "${s}" at path "${r}" was closed before becoming ready.`));await v.catch(()=>{}),await M(i),i=void 0;for(let c of T.values())c.unsubscribe=void 0;T.clear(),Y()}};function se(c){v=v.then(c).catch((u)=>{if(!n)n=!0,b.reject(u);t.warn("Reactive Redis adapter update failed",{"ion.operation":"redis.adapter.update","ion.outcome":"degraded",sourceName:s,path:r,error:u instanceof Error?u.message:String(u)})})}async function ie(){if(p)throw Error(`Reactive Redis adapter for source "${s}" at path "${r}" is closed.`);let c=i?.adapter;if(c)return c;if(await v.catch(()=>{}),p)throw Error(`Reactive Redis adapter for source "${s}" at path "${r}" is closed.`);let u=i?.adapter;if(u)return u;if(await b.promise,p)throw Error(`Reactive Redis adapter for source "${s}" at path "${r}" is closed.`);let h=i?.adapter;if(!h)throw Error(`Reactive Redis adapter for source "${s}" at path "${r}" did not become ready.`);return h}async function P(c){let u=await ie();return c(u)}function re(){a?.(),a=void 0}async function He(c,u){if(u.unsubscribe)return;if(!u.attaching)u.attaching=(async()=>{let h=await ie();if(!h.subscribeChannel)throw Error("Active Redis adapter does not support subscribeChannel (Pub/Sub)");if(u.listeners.size===0)return;u.unsubscribe=await h.subscribeChannel(c,u.dispatch)})().finally(()=>{u.attaching=void 0});await u.attaching}async function Ve(c){for(let[u,h]of T){if(h.attaching)await h.attaching.catch(()=>{});if(h.unsubscribe=void 0,!c.subscribeChannel){t.warn("Active Redis adapter does not support subscribeChannel; channel subscriptions dropped.",{"ion.operation":"redis.adapter.capabilities","ion.outcome":"degraded",sourceName:s,path:r,capability:"subscribeChannel"});return}try{h.unsubscribe=await c.subscribeChannel(u,h.dispatch)}catch(k){t.warn("Failed to re-subscribe Redis channel after client rotation",{"ion.operation":"redis.adapter.subscribe","ion.outcome":"failure",sourceName:s,path:r,channel:u,error:k instanceof Error?k.message:String(k)})}}}async function Ue(c){re(),a=await c.subscribe(r,(u)=>{se(async()=>{if(p)return;await Me(u)})},e.subscription??e.secretOptions)}async function Me(c){if(p)return;let u=`${s}:${r}:${c.metadata.version}`;if(i!==void 0&&d===u&&o===c.metadata.version)return;let h=e.endpointOf?.(c);if(i!==void 0&&h!=null&&h!==""&&l!=null&&l!==""&&h!==l)throw Error(`Reactive Redis adapter for source "${s}" at path "${r}" rejected a rotation that changed the endpoint (${l} -> ${h}); only credentials may rotate under an active adapter.`);let k=await e.createClient(c);if(p){await M(k);return}let L=i;if(i=k,d=u,o=c.metadata.version,h!=null&&h!=="")l=h;if(Y(),L!==void 0)await Ve(k.adapter);if(!n)n=!0,b.resolve();await M(L)}async function M(c){if(!c?.dispose)return;await c.dispose()}function Y(){let c=i?.adapter;if(c?.runScript&&Pe(c.runScript))I.runScript=async(u,h,k)=>P(async(L)=>{if(!L.runScript)throw Error("Active Redis adapter does not support runScript");return L.runScript(u,h,k)});else if(delete I.runScript,c!==void 0&&!E)E=!0,t.warn("Active Redis adapter does not support runScript (EVAL); stores fall back to non-isolated writes.",{"ion.operation":"redis.adapter.capabilities","ion.outcome":"degraded",sourceName:s,path:r,capability:"runScript"});if(c?.getdel&&Pe(c.getdel))I.getdel=async(u)=>P(async(h)=>{if(!h.getdel)return null;return h.getdel(u)});else if(delete I.getdel,c!==void 0&&!y)y=!0,t.warn("Active Redis adapter does not support getdel (GETDEL); single-use consume falls back to get+del.",{"ion.operation":"redis.adapter.capabilities","ion.outcome":"degraded",sourceName:s,path:r,capability:"getdel"})}return Y(),se(async()=>{if(p)return;await Ue(e.source)}),I}import{StoreConflictError as jt}from"@ionite/core";var _t=5;function Gt(e,t){let s;try{s=JSON.parse(e)}catch{return}if(s==null||typeof s!=="object"||Array.isArray(s))return;return JSON.stringify({...s,...t})}function Le(e){return JSON.stringify({...e,createdAt:e.createdAt.toISOString()})}function V(e,t){let s=w(e,{store:"session",log:t});if(s===void 0)return;return{...s,createdAt:new Date(s.createdAt)}}function Q(e){if(!e)return;let t=e instanceof Date?e.getTime():new Date(e).getTime();if(Number.isNaN(t))return;let s=Math.ceil((t-Date.now())/1000);return s>0?s:1}class Ce{constructor(e){this.capabilities={derivedEntitlements:!0};this.redis=e.redis,this.prefix=x(e,"session-store"),this.log=f(e)}key(e){return m(this.prefix,"session",g(e))}idpSidKey(e){return m(this.prefix,"session-idp-sid",g(e))}async addToIdpIndex(e){if(!e.idpSid)return;let t=this.idpSidKey(e.idpSid);await this.redis.sadd(t,e.sid);let s=Q(e.expiresAt);if(s===void 0)return;let r=await this.redis.ttl?.(t)??-1;await this.redis.expire(t,Math.max(s,r>0?r:0))}async removeFromIdpIndex(e){if(!e.idpSid)return;let t=this.idpSidKey(e.idpSid);if(await this.redis.srem(t,e.sid),(await this.redis.smembers(t)).length===0)await this.redis.del(t)}async create(e){let t=this.key(e.sid),s=Q(e.expiresAt);if(await _(this.redis,t,Le(e),{ttlSeconds:s})==="conflict")throw new jt(`Session with sid ${e.sid} already exists`,"already_exists","sid");await this.addToIdpIndex(e)}async get(e){let t=await this.redis.get(this.key(e));if(t==null)return null;return V(t,this.log)??null}async update(e,t){let s=this.key(e),r=await this.redis.get(s),i=r==null?void 0:V(r,this.log);if(!i)throw Error(`Session with sid ${e} not found`);let a={...i,...t},n=async()=>{if(i.idpSid!==a.idpSid)await this.removeFromIdpIndex(i);await this.addToIdpIndex(a)},o=JSON.parse(JSON.stringify(t)),d="expiresAt"in o?Q(o.expiresAt):void 0;if(A(this.redis))for(let T=0;T<_t;T++){let v=await this.redis.get(s);if(v==null)throw Error(`Session with sid ${e} not found`);let b=Gt(v,o);if(b===void 0)throw Error(`Session with sid ${e} not found`);let I=await G(this.redis,s,v,b,d);if(I==="ok"){await n();return}if(I==="missing")throw Error(`Session with sid ${e} not found`)}let l=await this.redis.get(s);if(l==null)throw Error(`Session with sid ${e} not found`);let p=V(l,this.log);if(p==null)throw Error(`Session with sid ${e} not found`);let E={...p,...t},y=Le(E);if(d!=null&&d>0)await this.redis.setex(s,Math.max(1,Math.floor(d)),y);else await this.redis.set(s,y);await n()}async delete(e){let t=await this.redis.get(this.key(e));if(await this.redis.del(this.key(e)),t!=null){let s=V(t,this.log);if(s)await this.removeFromIdpIndex(s)}}async deleteByIdpSid(e){let t=this.idpSidKey(e),s=await this.redis.smembers(t);for(let r of s)await this.delete(r);await this.redis.del(t)}}var Bt="tenant:ids",Nt=`
177
177
  local raw = redis.call('GET', KEYS[1])
178
178
  local previous = nil
179
179
  if raw then previous = cjson.decode(raw) end
@@ -257,4 +257,4 @@ redis.call('SET', KEYS[1], updated)
257
257
  if ARGV[4] ~= '' then redis.call('SET', KEYS[2], ARGV[6]) end
258
258
  if ARGV[8] ~= '' then redis.call('SET', KEYS[3], ARGV[6]) end
259
259
  return updated
260
- `;function De(e){return JSON.stringify({...e,createdAt:e.createdAt.toISOString(),updatedAt:e.updatedAt.toISOString()})}function q(e,t){let s=f(e,{store:"tenant",log:t});if(s===void 0)return;return{...s,createdAt:new Date(s.createdAt),updatedAt:new Date(s.updatedAt)}}class Oe{constructor(e){this.redis=e.redis,this.prefix=x(e,"tenant-store"),this.log=m(e)}key(...e){return S(this.prefix,...e)}entityKey(e){return this.key("tenant",g(e))}idsSetKey(){return this.key(Bt)}integrationHandleKey(e){return`${this.key("tenant:integration")}:${e}`}requestTokenKey(e){return`${this.key("tenant:request")}:${e}`}stagedRequestKey(e){return`${this.key("tenant:staged")}:${e}`}ioniteIdKey(e){return`${this.key("tenant:ionite")}:${g(e)}`}async get(e){let t=await this.redis.get(this.entityKey(e));if(t==null)return;return q(t,this.log)}async upsert(e){if(!A(this.redis))throw Error("RedisTenantStore.upsert requires adapter.runScript for atomic secondary indexes");let t=e.ioniteId??"";return await this.redis.runScript(Nt,[this.entityKey(e.id),t?this.ioniteIdKey(t):this.key("tenant:ionite:none"),this.idsSetKey(),e.requestTokenHash?this.requestTokenKey(e.requestTokenHash):this.key("tenant:request:none")],[t,e.id,De(e),e.requestTokenHash??"",`${this.key("tenant:request")}:`]),e}async list(e){let t=await this.redis.smembers(this.idsSetKey());if(t.length===0)return R([],e);let s=t.map((a)=>this.entityKey(a)),i=(await this.redis.mget(s)).map((a)=>a!=null?q(a,this.log):void 0).filter((a)=>a!=null);return R(i,e)}async delete(e){let t=await this.get(e),s=new w().srem(this.idsSetKey(),e).del(this.entityKey(e));if(t?.integration)s.del(this.integrationHandleKey(t.integration.handleHash));if(t?.requestTokenHash)s.del(this.requestTokenKey(t.requestTokenHash));if(t?.ioniteId)s.del(this.ioniteIdKey(t.ioniteId));return await s.exec(this.redis),t?1:0}async setIntegration(e,t,s){if(!A(this.redis))throw Error("RedisTenantStore.setIntegration requires adapter.runScript for atomic compare-and-set");let r=t?.handleHash??"",i=t?.ioniteId??"",a=await this.redis.runScript(Vt,[this.entityKey(e),r?this.integrationHandleKey(r):this.key("tenant:integration:none"),i?this.ioniteIdKey(i):this.key("tenant:ionite:none")],[s?.expectedHandleHash===null?"-":s?.expectedHandleHash??"",s?.expectedVersion?.toString()??"",t?JSON.stringify(t):"",r,`${this.key("tenant:integration")}:`,e,new Date().toISOString(),i]);return typeof a==="string"?q(a,this.log):void 0}async getByIntegrationHandleHash(e){let t=await this.redis.get(this.integrationHandleKey(e));return t?this.get(t):void 0}async setStagedRequest(e,t){let s=Math.ceil((Date.parse(t.expiresAt)-Date.now())/1000);if(s<=0)return;await this.redis.setex(this.stagedRequestKey(e),s,JSON.stringify(t))}async getStagedRequest(e){let t=await this.redis.get(this.stagedRequestKey(e)),s=t==null?void 0:f(t,{store:"tenant",log:this.log});if(typeof s?.handle!=="string"||typeof s.expiresAt!=="string")return;if(Date.parse(s.expiresAt)<=Date.now())return;return{handle:s.handle,expiresAt:s.expiresAt}}async getByRequestTokenHash(e){let t=await this.redis.get(this.requestTokenKey(e));return t?this.get(t):void 0}async replaceActionRequest(e,t){if(!A(this.redis))throw Error("RedisTenantStore.replaceActionRequest requires adapter.runScript for atomic compare-and-set");let s=await this.redis.runScript(Ht,[this.requestTokenKey(e),this.entityKey(t.id),t.requestTokenHash?this.requestTokenKey(t.requestTokenHash):this.key("tenant:request:none")],[t.id,e,De(t),t.ioniteId??"",t.requestTokenHash??""]);return typeof s==="string"?q(s,this.log):void 0}async getByIoniteId(e){let t=await this.redis.get(this.ioniteIdKey(e));return t?this.get(t):void 0}}class je{constructor(e){this.ionCache=e.ionCache,this.store=new Oe(e)}async get(e){return this.store.get(e)}async upsert(e){let t=await this.store.upsert(e);return this.ionCache?.delete(e.id),t}async list(e){return this.store.list(e)}async delete(e){let t=await this.store.delete(e);return this.ionCache?.delete(e),t}async getIon(e){if(!this.ionCache)throw Error(`${this.constructor.name}.getIon() requires an app-owned ionCache. Pass { ionCache } (an lru-cache instance whose fetchMethod builds the tenant Ionite and whose dispose `+"closes it) — the SDK does not cache tenant runtimes. See the multi-tenant docs.");return this.ionCache.fetch(e)}async setIntegration(e,t,s){return this.store.setIntegration(e,t,s)}async getByIntegrationHandleHash(e){return this.store.getByIntegrationHandleHash(e)}async setStagedRequest(e,t){return this.store.setStagedRequest(e,t)}async getStagedRequest(e){return this.store.getStagedRequest(e)}async getByRequestTokenHash(e){return this.store.getByRequestTokenHash(e)}async replaceActionRequest(e,t){let s=await this.store.replaceActionRequest(e,t);if(s)this.ionCache?.delete(s.id);return s}async getByIoniteId(e){return this.store.getByIoniteId(e)}}import{list as qt,StoreConflictError as _e}from"@ionite/core";var Ut="user:ids",Mt="user:name:",Yt="user:external-id:";function $t(e){let t=e.createdAt??new Date,s=e.updatedAt??t,r={...e,createdAt:t.toISOString(),updatedAt:s.toISOString()};if(r.sso&&typeof r.sso==="object"&&r.sso!==null){let i=r.sso;if(i.expires instanceof Date)i.expires=i.expires.toISOString()}return JSON.stringify(r)}function ee(e,t){let s=f(e,{store:"user",log:t});if(s===void 0)return;if(s.sso&&typeof s.sso==="object"&&s.sso!==null){let r=s.sso;if(typeof r.expires==="string")r.expires=new Date(r.expires)}return{...s,createdAt:typeof s.createdAt==="string"?new Date(s.createdAt):void 0,updatedAt:typeof s.updatedAt==="string"?new Date(s.updatedAt):void 0}}class Ge{constructor(e){this.redis=e.redis,this.prefix=x(e,"user-store"),this.log=m(e)}key(...e){return S(this.prefix,...e)}entityKey(e){return this.key("user",g(e))}idsSetKey(){return this.key(Ut)}nameIndexKey(e){return this.key(Mt+g(e))}externalIdIndexKey(e){return this.key(Yt+g(e))}async get(e){let t=await this.redis.get(this.entityKey(e));if(t==null)return;return ee(t,this.log)}async getByExternalId(e){let t=await this.redis.get(this.externalIdIndexKey(e));return t?this.get(t):void 0}async getByUserName(e){let t=await this.redis.get(this.nameIndexKey(e.toLowerCase()));return t?this.get(t):void 0}async lookup(e){return this.get(e.id??"")}async upsert(e){let t=e.id?.trim()||crypto.randomUUID(),s={...e,id:t},r=this.entityKey(t),i=await this.redis.get(r),a=i!=null?ee(i,this.log)??null:null,n=s.userName?.toLowerCase(),o=a?.userName?.toLowerCase(),d=s.externalId,l=a?.externalId,p=new w;if(n)p.claimUnique(this.nameIndexKey(n),t);if(d)p.claimUnique(this.externalIdIndexKey(d),t);if(o&&o!==n)p.del(this.nameIndexKey(o));if(l&&l!==d)p.del(this.externalIdIndexKey(l));if(p.set(r,$t(s)),n)p.set(this.nameIndexKey(n),t);if(d)p.set(this.externalIdIndexKey(d),t);if(p.sadd(this.idsSetKey(),t),await p.exec(this.redis)==="conflict"){if(d){let E=await this.redis.get(this.externalIdIndexKey(d));if(E&&E!==t)throw new _e(`externalId "${d}" is already in use`,"unique_violation","externalId")}throw new _e(`userName "${s.userName}" is already in use`,"unique_violation","userName")}return s}async delete(e){let t=await this.get(e);if(t==null)return 0;let s=new w;if(s.del(this.entityKey(e)),t.userName)s.del(this.nameIndexKey(t.userName.toLowerCase()));if(t.externalId)s.del(this.externalIdIndexKey(t.externalId));return s.srem(this.idsSetKey(),e),await s.exec(this.redis),1}async list(e){let t=C(e),s=(await this.redis.smembers(this.idsSetKey())).sort();if(s.length===0)return qt(0,[],t.start??0,t.limit);let r=s.map((n)=>this.entityKey(n)),a=(await this.redis.mget(r)).filter((n)=>n!=null).map((n)=>ee(n,this.log)).filter((n)=>n!=null);return R(a,t)}}import{list as zt,StoreConflictError as Wt}from"@ionite/core";var Jt="workload-identity:ids",Ft="workload-identity:client:",Xt="workload-identity:external:";function Zt(e){let t=e.createdAt??new Date,s=e.updatedAt??t;return JSON.stringify({...e,createdAt:t.toISOString(),updatedAt:s.toISOString()})}function te(e,t){let s=f(e,{store:"workload-identity",log:t});if(s===void 0)return;return{...s,createdAt:typeof s.createdAt==="string"?new Date(s.createdAt):void 0,updatedAt:typeof s.updatedAt==="string"?new Date(s.updatedAt):void 0}}class Be{constructor(e){this.redis=e.redis,this.prefix=x(e,"workload-identity-store"),this.log=m(e)}key(...e){return S(this.prefix,...e)}entityKey(e){return this.key("workload-identity",g(e))}idsSetKey(){return this.key(Jt)}clientIndexKey(e){return this.key(Ft+g(e))}externalIdIndexKey(e){return this.key(Xt+g(e))}async get(e){let t=await this.redis.get(this.entityKey(e));if(t==null)return;return te(t,this.log)}async lookup(e){if(e.id){let t=await this.get(e.id);if(t)return t}if(e.clientId){let t=await this.redis.get(this.clientIndexKey(e.clientId));if(t!=null)return this.get(t)}if(e.externalId)return this.getByExternalId(e.externalId);return}async getByExternalId(e){let t=await this.redis.get(this.externalIdIndexKey(e));if(t==null)return;return this.get(t)}async upsert(e){let t=e.id?.trim()||crypto.randomUUID(),s=this.entityKey(t),r=await this.redis.get(s),i=null;if(r!=null)i=te(r,this.log)??null;let a=new Date,n={...e,id:t,createdAt:i?.createdAt??e.createdAt??a,updatedAt:a},o=new w;if(n.clientId)o.claimUnique(this.clientIndexKey(n.clientId),t);if(n.externalId)o.claimUnique(this.externalIdIndexKey(n.externalId),t);if(i?.clientId&&i.clientId!==n.clientId)o.del(this.clientIndexKey(i.clientId));if(i?.externalId&&i.externalId!==n.externalId)o.del(this.externalIdIndexKey(i.externalId));if(o.set(s,Zt(n)),n.clientId)o.set(this.clientIndexKey(n.clientId),t);if(n.externalId)o.set(this.externalIdIndexKey(n.externalId),t);if(o.sadd(this.idsSetKey(),t),await o.exec(this.redis)==="conflict")throw new Wt(`clientId "${n.clientId}" is already in use`,"unique_violation","clientId");return n}async delete(e){let t=await this.get(e);if(t==null)return 0;let s=new w;if(s.del(this.entityKey(e)),t.clientId)s.del(this.clientIndexKey(t.clientId));if(t.externalId)s.del(this.externalIdIndexKey(t.externalId));return s.srem(this.idsSetKey(),e),await s.exec(this.redis),1}async list(e){let t=C(e),s=(await this.redis.smembers(this.idsSetKey())).sort();if(s.length===0)return zt(0,[],t.start??0,t.limit);let r=s.map((n)=>this.entityKey(n)),a=(await this.redis.mget(r)).filter((n)=>n!=null).map((n)=>te(n,this.log)).filter((n)=>n!=null);return R(a,t)}}function Qt(e){return JSON.stringify({...e,expires_at:e.expires_at.toISOString(),created_at:e.created_at.toISOString()})}function es(e,t){let s=f(e,{store:"workload-token",log:t});if(s===void 0)return;return{...s,expires_at:new Date(s.expires_at),created_at:new Date(s.created_at)}}class Ne{constructor(e){this.redis=e.redis,this.prefix=x(e,"workload-token-store"),this.log=m(e)}key(e){return S(this.prefix,"workload","token",g(e))}async set(e){let t=this.key(e.workload_id),s=Math.max(1,Math.floor((e.expires_at.getTime()-Date.now())/1000));await this.redis.setex(t,s,Qt(e))}async get(e){let t=await this.redis.get(this.key(e));if(t==null)return null;let s=es(t,this.log);if(s==null)return null;if(Date.now()>s.expires_at.getTime())return await this.redis.del(this.key(e)),null;return s}async delete(e){await this.redis.del(this.key(e))}async isValid(e){return await this.get(e)!==null}async cleanup(){}}export{ae as DEFAULT_LIST_LIMIT,pt as DEFAULT_MGET_CHUNK_SIZE,oe as MAX_LIST_LIMIT,ye as RedisAccessAssignmentStore,Se as RedisAccessCatalogStore,ke as RedisAccessIndex,Te as RedisCustomerStore,Ae as RedisDelegateStore,Ke as RedisMagicLinkStore,we as RedisResourceStore,Ce as RedisSessionStore,je as RedisTenantStore,w as RedisTxn,Ge as RedisUserStore,Be as RedisWorkloadIdentityStore,Ne as RedisWorkloadTokenStore,G as atomicCompareAndSet,_ as atomicCreate,gt as chunkedMget,At as createEvalshaRunner,Ot as createReactiveRedis,It as createRedisLfvTransport,g as encodeKeyId,x as getKeyPrefix,m as getLogger,S as prefixedKey,Ee as scriptSha1,Et as splitIonRedisSecret,A as supportsRunScript};
260
+ `;function Oe(e){return JSON.stringify({...e,createdAt:e.createdAt.toISOString(),updatedAt:e.updatedAt.toISOString()})}function U(e,t){let s=w(e,{store:"tenant",log:t});if(s===void 0)return;return{...s,createdAt:new Date(s.createdAt),updatedAt:new Date(s.updatedAt)}}class De{constructor(e){this.redis=e.redis,this.prefix=x(e,"tenant-store"),this.log=f(e)}key(...e){return m(this.prefix,...e)}entityKey(e){return this.key("tenant",g(e))}idsSetKey(){return this.key(Bt)}integrationHandleKey(e){return`${this.key("tenant:integration")}:${e}`}requestTokenKey(e){return`${this.key("tenant:request")}:${e}`}ioniteIdKey(e){return`${this.key("tenant:ionite")}:${g(e)}`}async get(e){let t=await this.redis.get(this.entityKey(e));if(t==null)return;return U(t,this.log)}async upsert(e){if(!A(this.redis))throw Error("RedisTenantStore.upsert requires adapter.runScript for atomic secondary indexes");let t=e.ioniteId??"";return await this.redis.runScript(Nt,[this.entityKey(e.id),t?this.ioniteIdKey(t):this.key("tenant:ionite:none"),this.idsSetKey(),e.requestTokenHash?this.requestTokenKey(e.requestTokenHash):this.key("tenant:request:none")],[t,e.id,Oe(e),e.requestTokenHash??"",`${this.key("tenant:request")}:`]),e}async list(e){let t=await this.redis.smembers(this.idsSetKey());if(t.length===0)return R([],e);let s=t.map((a)=>this.entityKey(a)),i=(await this.redis.mget(s)).map((a)=>a!=null?U(a,this.log):void 0).filter((a)=>a!=null);return R(i,e)}async delete(e){let t=await this.get(e),s=new S().srem(this.idsSetKey(),e).del(this.entityKey(e));if(t?.integration)s.del(this.integrationHandleKey(t.integration.handleHash));if(t?.requestTokenHash)s.del(this.requestTokenKey(t.requestTokenHash));if(t?.ioniteId)s.del(this.ioniteIdKey(t.ioniteId));return await s.exec(this.redis),t?1:0}async setIntegration(e,t,s){if(!A(this.redis))throw Error("RedisTenantStore.setIntegration requires adapter.runScript for atomic compare-and-set");let r=t?.handleHash??"",i=t?.ioniteId??"",a=await this.redis.runScript(Vt,[this.entityKey(e),r?this.integrationHandleKey(r):this.key("tenant:integration:none"),i?this.ioniteIdKey(i):this.key("tenant:ionite:none")],[s?.expectedHandleHash===null?"-":s?.expectedHandleHash??"",s?.expectedVersion?.toString()??"",t?JSON.stringify(t):"",r,`${this.key("tenant:integration")}:`,e,new Date().toISOString(),i]);return typeof a==="string"?U(a,this.log):void 0}async getByIntegrationHandleHash(e){let t=await this.redis.get(this.integrationHandleKey(e));return t?this.get(t):void 0}async getByRequestTokenHash(e){let t=await this.redis.get(this.requestTokenKey(e));return t?this.get(t):void 0}async replaceActionRequest(e,t){if(!A(this.redis))throw Error("RedisTenantStore.replaceActionRequest requires adapter.runScript for atomic compare-and-set");let s=await this.redis.runScript(Ht,[this.requestTokenKey(e),this.entityKey(t.id),t.requestTokenHash?this.requestTokenKey(t.requestTokenHash):this.key("tenant:request:none")],[t.id,e,Oe(t),t.ioniteId??"",t.requestTokenHash??""]);return typeof s==="string"?U(s,this.log):void 0}async getByIoniteId(e){let t=await this.redis.get(this.ioniteIdKey(e));return t?this.get(t):void 0}}class je{constructor(e){this.ionCache=e.ionCache,this.store=new De(e)}async get(e){return this.store.get(e)}async upsert(e){let t=await this.store.upsert(e);return this.ionCache?.delete(e.id),t}async list(e){return this.store.list(e)}async delete(e){let t=await this.store.delete(e);return this.ionCache?.delete(e),t}async getIon(e){if(!this.ionCache)throw Error(`${this.constructor.name}.getIon() requires an app-owned ionCache. Pass { ionCache } (an lru-cache instance whose fetchMethod builds the tenant Ionite and whose dispose `+"closes it) — the SDK does not cache tenant runtimes. See the multi-tenant docs.");return this.ionCache.fetch(e)}async setIntegration(e,t,s){return this.store.setIntegration(e,t,s)}async getByIntegrationHandleHash(e){return this.store.getByIntegrationHandleHash(e)}async getByRequestTokenHash(e){return this.store.getByRequestTokenHash(e)}async replaceActionRequest(e,t){let s=await this.store.replaceActionRequest(e,t);if(s)this.ionCache?.delete(s.id);return s}async getByIoniteId(e){return this.store.getByIoniteId(e)}}import{list as Ut,StoreConflictError as _e}from"@ionite/core";var Mt="user:ids",Yt="user:name:",qt="user:external-id:";function $t(e){let t=e.createdAt??new Date,s=e.updatedAt??t,r={...e,createdAt:t.toISOString(),updatedAt:s.toISOString()};if(r.sso&&typeof r.sso==="object"&&r.sso!==null){let i=r.sso;if(i.expires instanceof Date)i.expires=i.expires.toISOString()}return JSON.stringify(r)}function ee(e,t){let s=w(e,{store:"user",log:t});if(s===void 0)return;if(s.sso&&typeof s.sso==="object"&&s.sso!==null){let r=s.sso;if(typeof r.expires==="string")r.expires=new Date(r.expires)}return{...s,createdAt:typeof s.createdAt==="string"?new Date(s.createdAt):void 0,updatedAt:typeof s.updatedAt==="string"?new Date(s.updatedAt):void 0}}class Ge{constructor(e){this.redis=e.redis,this.prefix=x(e,"user-store"),this.log=f(e)}key(...e){return m(this.prefix,...e)}entityKey(e){return this.key("user",g(e))}idsSetKey(){return this.key(Mt)}nameIndexKey(e){return this.key(Yt+g(e))}externalIdIndexKey(e){return this.key(qt+g(e))}async get(e){let t=await this.redis.get(this.entityKey(e));if(t==null)return;return ee(t,this.log)}async getByExternalId(e){let t=await this.redis.get(this.externalIdIndexKey(e));return t?this.get(t):void 0}async getByUserName(e){let t=await this.redis.get(this.nameIndexKey(e.toLowerCase()));return t?this.get(t):void 0}async lookup(e){return this.get(e.id??"")}async upsert(e){let t=e.id?.trim()||crypto.randomUUID(),s={...e,id:t},r=this.entityKey(t),i=await this.redis.get(r),a=i!=null?ee(i,this.log)??null:null,n=s.userName?.toLowerCase(),o=a?.userName?.toLowerCase(),d=s.externalId,l=a?.externalId,p=new S;if(n)p.claimUnique(this.nameIndexKey(n),t);if(d)p.claimUnique(this.externalIdIndexKey(d),t);if(o&&o!==n)p.del(this.nameIndexKey(o));if(l&&l!==d)p.del(this.externalIdIndexKey(l));if(p.set(r,$t(s)),n)p.set(this.nameIndexKey(n),t);if(d)p.set(this.externalIdIndexKey(d),t);if(p.sadd(this.idsSetKey(),t),await p.exec(this.redis)==="conflict"){if(d){let E=await this.redis.get(this.externalIdIndexKey(d));if(E&&E!==t)throw new _e(`externalId "${d}" is already in use`,"unique_violation","externalId")}throw new _e(`userName "${s.userName}" is already in use`,"unique_violation","userName")}return s}async delete(e){let t=await this.get(e);if(t==null)return 0;let s=new S;if(s.del(this.entityKey(e)),t.userName)s.del(this.nameIndexKey(t.userName.toLowerCase()));if(t.externalId)s.del(this.externalIdIndexKey(t.externalId));return s.srem(this.idsSetKey(),e),await s.exec(this.redis),1}async list(e){let t=C(e),s=(await this.redis.smembers(this.idsSetKey())).sort();if(s.length===0)return Ut(0,[],t.start??0,t.limit);let r=s.map((n)=>this.entityKey(n)),a=(await this.redis.mget(r)).filter((n)=>n!=null).map((n)=>ee(n,this.log)).filter((n)=>n!=null);return R(a,t)}}import{list as zt,StoreConflictError as Wt}from"@ionite/core";var Jt="workload-identity:ids",Ft="workload-identity:client:",Xt="workload-identity:external:";function Zt(e){let t=e.createdAt??new Date,s=e.updatedAt??t;return JSON.stringify({...e,createdAt:t.toISOString(),updatedAt:s.toISOString()})}function te(e,t){let s=w(e,{store:"workload-identity",log:t});if(s===void 0)return;return{...s,createdAt:typeof s.createdAt==="string"?new Date(s.createdAt):void 0,updatedAt:typeof s.updatedAt==="string"?new Date(s.updatedAt):void 0}}class Be{constructor(e){this.redis=e.redis,this.prefix=x(e,"workload-identity-store"),this.log=f(e)}key(...e){return m(this.prefix,...e)}entityKey(e){return this.key("workload-identity",g(e))}idsSetKey(){return this.key(Jt)}clientIndexKey(e){return this.key(Ft+g(e))}externalIdIndexKey(e){return this.key(Xt+g(e))}async get(e){let t=await this.redis.get(this.entityKey(e));if(t==null)return;return te(t,this.log)}async lookup(e){if(e.id){let t=await this.get(e.id);if(t)return t}if(e.clientId){let t=await this.redis.get(this.clientIndexKey(e.clientId));if(t!=null)return this.get(t)}if(e.externalId)return this.getByExternalId(e.externalId);return}async getByExternalId(e){let t=await this.redis.get(this.externalIdIndexKey(e));if(t==null)return;return this.get(t)}async upsert(e){let t=e.id?.trim()||crypto.randomUUID(),s=this.entityKey(t),r=await this.redis.get(s),i=null;if(r!=null)i=te(r,this.log)??null;let a=new Date,n={...e,id:t,createdAt:i?.createdAt??e.createdAt??a,updatedAt:a},o=new S;if(n.clientId)o.claimUnique(this.clientIndexKey(n.clientId),t);if(n.externalId)o.claimUnique(this.externalIdIndexKey(n.externalId),t);if(i?.clientId&&i.clientId!==n.clientId)o.del(this.clientIndexKey(i.clientId));if(i?.externalId&&i.externalId!==n.externalId)o.del(this.externalIdIndexKey(i.externalId));if(o.set(s,Zt(n)),n.clientId)o.set(this.clientIndexKey(n.clientId),t);if(n.externalId)o.set(this.externalIdIndexKey(n.externalId),t);if(o.sadd(this.idsSetKey(),t),await o.exec(this.redis)==="conflict")throw new Wt(`clientId "${n.clientId}" is already in use`,"unique_violation","clientId");return n}async delete(e){let t=await this.get(e);if(t==null)return 0;let s=new S;if(s.del(this.entityKey(e)),t.clientId)s.del(this.clientIndexKey(t.clientId));if(t.externalId)s.del(this.externalIdIndexKey(t.externalId));return s.srem(this.idsSetKey(),e),await s.exec(this.redis),1}async list(e){let t=C(e),s=(await this.redis.smembers(this.idsSetKey())).sort();if(s.length===0)return zt(0,[],t.start??0,t.limit);let r=s.map((n)=>this.entityKey(n)),a=(await this.redis.mget(r)).filter((n)=>n!=null).map((n)=>te(n,this.log)).filter((n)=>n!=null);return R(a,t)}}function Qt(e){return JSON.stringify({...e,expires_at:e.expires_at.toISOString(),created_at:e.created_at.toISOString()})}function es(e,t){let s=w(e,{store:"workload-token",log:t});if(s===void 0)return;return{...s,expires_at:new Date(s.expires_at),created_at:new Date(s.created_at)}}class Ne{constructor(e){this.redis=e.redis,this.prefix=x(e,"workload-token-store"),this.log=f(e)}key(e){return m(this.prefix,"workload","token",g(e))}async set(e){let t=this.key(e.workload_id),s=Math.max(1,Math.floor((e.expires_at.getTime()-Date.now())/1000));await this.redis.setex(t,s,Qt(e))}async get(e){let t=await this.redis.get(this.key(e));if(t==null)return null;let s=es(t,this.log);if(s==null)return null;if(Date.now()>s.expires_at.getTime())return await this.redis.del(this.key(e)),null;return s}async delete(e){await this.redis.del(this.key(e))}async isValid(e){return await this.get(e)!==null}async cleanup(){}}export{ae as DEFAULT_LIST_LIMIT,pt as DEFAULT_MGET_CHUNK_SIZE,oe as MAX_LIST_LIMIT,ye as RedisAccessAssignmentStore,Se as RedisAccessCatalogStore,ke as RedisAccessIndex,Te as RedisCustomerStore,Ae as RedisDelegateStore,Ke as RedisMagicLinkStore,we as RedisResourceStore,Ce as RedisSessionStore,je as RedisTenantStore,S as RedisTxn,Ge as RedisUserStore,Be as RedisWorkloadIdentityStore,Ne as RedisWorkloadTokenStore,G as atomicCompareAndSet,_ as atomicCreate,gt as chunkedMget,At as createEvalshaRunner,Dt as createReactiveRedis,It as createRedisLfvTransport,g as encodeKeyId,x as getKeyPrefix,f as getLogger,m as prefixedKey,Ee as scriptSha1,Et as splitIonRedisSecret,A as supportsRunScript};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ionite/redis-core",
3
- "version": "0.0.24-beta.20261024.47",
3
+ "version": "0.0.24-beta.20261024.49",
4
4
  "description": "Redis adapter interface and store implementations for ionite. Use with @ionite/redis (node-redis), @ionite/ioredis, or a custom RedisAdapter.",
5
5
  "private": false,
6
6
  "author": "ionite",
@@ -24,7 +24,7 @@
24
24
  "./package.json": "./package.json"
25
25
  },
26
26
  "dependencies": {
27
- "@ionite/core": "0.0.24-beta.20261024.47"
27
+ "@ionite/core": "0.0.24-beta.20261024.49"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/node": "^26.1.0"