@nebius/js-sdk - v0.2.54
    Preparing search index...

    Shares renewable access tokens through a file cache and refreshes them in the background.

    This class combines in-memory caching, a process-shared file cache, and one renewal loop. Concurrent callers share an in-flight renewal. The wrapped bearer must have a stable name because that name selects the cache entry.

    Call AsyncRenewableBearer.close at shutdown.

    Hierarchy (View Summary)

    Indexable

    • [key: symbol]: () => unknown

      Shares renewable access tokens through a file cache and refreshes them in the background.

      This class combines in-memory caching, a process-shared file cache, and one renewal loop. Concurrent callers share an in-flight renewal. The wrapped bearer must have a stable name because that name selects the cache entry.

      Call AsyncRenewableBearer.close at shutdown.

        • (): unknown
        • Returns a JSON-safe value for logs.

          Returns unknown

    Index
    • Creates a shared file-backed renewal layer.

      cacheFilePath selects the credentials file. fileCacheThrottleMs limits disk checks. Renewal failures use jittered exponential backoff. source must have a stable name for its cache entry.

      Parameters

      • source: Bearer
      • Optionalopts: {
            cacheFilePath?: string;
            fileCacheThrottleMs?: number;
            initialRetryTimeoutMs?: number;
            initialSafetyMarginMs?: number | null;
            jitterFraction?: number;
            lifetimeSafeFraction?: number;
            logger?: Logger;
            maxRetries?: number;
            maxRetryTimeoutMs?: number;
            metrics?: AuthMetricsInput;
            provider?: string;
            refreshRequestTimeoutMs?: number;
            retrySafetyMarginMs?: number;
            retryTimeoutExponent?: number;
            safetyMinRemainingMs?: number;
        }
        • OptionalcacheFilePath?: string

          Shared YAML cache path. Defaults to ~/.nebius/credentials.yaml.

        • OptionalfileCacheThrottleMs?: number

          Minimum interval between cache-file reads, in milliseconds. Defaults to five minutes.

        • OptionalinitialRetryTimeoutMs?: number

          Initial retry delay, in milliseconds. Defaults to one second.

        • OptionalinitialSafetyMarginMs?: number | null

          Required remaining lifetime for an initially cached token, in milliseconds.

          Defaults to two hours. null also selects this default. Valid cache hits keep the margin until a fetch enters the renewal path.

        • OptionaljitterFraction?: number

          Random retry-delay variation from 0 to 1.

          Defaults to 0.2. Values outside the range are clamped.

        • OptionallifetimeSafeFraction?: number

          Fraction of remaining lifetime to wait before renewal.

          Defaults to 0.9, which renews with about 10% left.

        • Optionallogger?: Logger

          Optional destination for diagnostic events.

        • OptionalmaxRetries?: number

          Maximum total authentication attempts for one receiver. Defaults to 2.

        • OptionalmaxRetryTimeoutMs?: number

          Maximum retry delay, in milliseconds. Defaults to 60 seconds.

        • Optionalmetrics?: AuthMetricsInput

          Optional authentication metrics destination.

        • Optionalprovider?: string

          Metrics provider label. Defaults to the wrapped source provider.

        • OptionalrefreshRequestTimeoutMs?: number

          Default budget passed to the source for a renewal, in milliseconds.

          Defaults to five seconds. It applies to foreground and background renewal when the caller does not supply a synchronous override. The source decides how it enforces the budget.

        • OptionalretrySafetyMarginMs?: number

          Accepted for compatibility but not used by this implementation.

        • OptionalretryTimeoutExponent?: number

          Multiplier for exponential retry delays. Defaults to 1.5.

        • OptionalsafetyMinRemainingMs?: number

          Minimum lifetime kept before renewal, in milliseconds. Defaults to 15 seconds.

      Returns AsyncRenewableBearer

    $type: "nebius.sdk.AsyncRenewableBearer" = 'nebius.sdk.AsyncRenewableBearer'

    Contains the fully qualified runtime type name.

    safetyMargin: number | null

    Extra lifetime required for the first cached token, in milliseconds.

    The constructor assigns the two-hour default when the option is null or undefined. A valid cache hit keeps this margin for later fetches. The value becomes null only when a fetch proceeds into the renewal path.

    • get metricProvider(): string

      Returns the provider name for authorization metrics.

      Returns string

    • get name(): string | undefined

      Returns the stable credential name used by file-backed token caches.

      Most bearers do not have a name. Wrappers can add one with NamedBearer.

      Returns string | undefined