Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  allow-from-store-read.ts

  Sprache: JAVA
 

import { normalizeOptionalString } from "../shared/string-coerce.js";
import {
  clearAllowFromFileReadCacheForNamespace,
  dedupePreserveOrder,
  readAllowFromFileSyncWithExists,
  readAllowFromFileWithExists,
  resolveAllowFromAccountId,
  resolveAllowFromFilePath,
  shouldIncludeLegacyAllowFromEntries,
  type AllowFromStore,
} from "./allow-from-store-file.js";
import type { PairingChannel } from "./pairing-store.types.js";

const ALLOW_FROM_STORE_READ_CACHE_NAMESPACE = "allow-from-store-read";

function normalizeRawAllowFromList(store: AllowFromStore): string[] {
  const list = Array.isArray(store.allowFrom) ? store.allowFrom : [];
  return dedupePreserveOrder(
    list.map((entry) => normalizeOptionalString(entry) ?? "").filter(Boolean),
  );
}

async function readAllowFromEntriesForPathWithExists(
  filePath: string,
): Promise<{ entries: string[]; exists: boolean }> {
  return await readAllowFromFileWithExists({
    cacheNamespace: ALLOW_FROM_STORE_READ_CACHE_NAMESPACE,
    filePath,
    normalizeStore: normalizeRawAllowFromList,
  });
}

function readAllowFromEntriesForPathSyncWithExists(filePath: string): {
  entries: string[];
  exists: boolean;
} {
  return readAllowFromFileSyncWithExists({
    cacheNamespace: ALLOW_FROM_STORE_READ_CACHE_NAMESPACE,
    filePath,
    normalizeStore: normalizeRawAllowFromList,
  });
}

export function resolveChannelAllowFromPath(
  channel: PairingChannel,
  env: NodeJS.ProcessEnv = process.env,
  accountId?: string,
): string {
  return resolveAllowFromFilePath(channel, env, accountId);
}

export async function readLegacyChannelAllowFromStoreEntries(
  channel: PairingChannel,
  env: NodeJS.ProcessEnv = process.env,
): Promise<string[]> {
  const filePath = resolveAllowFromFilePath(channel, env);
  return (await readAllowFromEntriesForPathWithExists(filePath)).entries;
}

export async function readChannelAllowFromStoreEntries(
  channel: PairingChannel,
  env: NodeJS.ProcessEnv = process.env,
  accountId?: string,
): Promise<string[]> {
  const resolvedAccountId = resolveAllowFromAccountId(accountId);
  if (!shouldIncludeLegacyAllowFromEntries(resolvedAccountId)) {
    return (
      await readAllowFromEntriesForPathWithExists(
        resolveAllowFromFilePath(channel, env, resolvedAccountId),
      )
    ).entries;
  }
  const scopedEntries = (
    await readAllowFromEntriesForPathWithExists(
      resolveAllowFromFilePath(channel, env, resolvedAccountId),
    )
  ).entries;
  const legacyEntries = (
    await readAllowFromEntriesForPathWithExists(resolveAllowFromFilePath(channel, env))
  ).entries;
  return dedupePreserveOrder([...scopedEntries, ...legacyEntries]);
}

export function readLegacyChannelAllowFromStoreEntriesSync(
  channel: PairingChannel,
  env: NodeJS.ProcessEnv = process.env,
): string[] {
  return readAllowFromEntriesForPathSyncWithExists(resolveAllowFromFilePath(channel, env)).entries;
}

export function readChannelAllowFromStoreEntriesSync(
  channel: PairingChannel,
  env: NodeJS.ProcessEnv = process.env,
  accountId?: string,
): string[] {
  const resolvedAccountId = resolveAllowFromAccountId(accountId);
  if (!shouldIncludeLegacyAllowFromEntries(resolvedAccountId)) {
    return readAllowFromEntriesForPathSyncWithExists(
      resolveAllowFromFilePath(channel, env, resolvedAccountId),
    ).entries;
  }
  const scopedEntries = readAllowFromEntriesForPathSyncWithExists(
    resolveAllowFromFilePath(channel, env, resolvedAccountId),
  ).entries;
  const legacyEntries = readAllowFromEntriesForPathSyncWithExists(
    resolveAllowFromFilePath(channel, env),
  ).entries;
  return dedupePreserveOrder([...scopedEntries, ...legacyEntries]);
}

export function clearAllowFromStoreReadCacheForTest(): void {
  clearAllowFromFileReadCacheForNamespace(ALLOW_FROM_STORE_READ_CACHE_NAMESPACE);
}

Messung V0.5 in Prozent
C=98 H=96 G=96

¤ Dauer der Verarbeitung: 0.12 Sekunden  (vorverarbeitet am  2026-06-10) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik