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

    Class Token

    Contains an access token and its optional expiration time.

    Keep the Token.token value secret. Token.toString and the SDK logging helpers mask signatures and long payloads in recognized formats. A short v0 payload can remain visible. The Token.token getter and Token.toJSON always return the original value.

    import { Token } from '@nebius/js-sdk/runtime/token';

    const token = new Token(process.env.NEBIUS_TOKEN ?? '');
    if (token.isEmpty() || token.isExpired()) {
    throw new Error('A valid access token is required');
    }
    console.log({ expiresAt: token.expiration });

    Indexable

    • [key: symbol]: (() => string) | (() => object)

      Contains an access token and its optional expiration time.

      Keep the Token.token value secret. Token.toString and the SDK logging helpers mask signatures and long payloads in recognized formats. A short v0 payload can remain visible. The Token.token getter and Token.toJSON always return the original value.

      • () => string
          • (): string
          • Contains an access token and its optional expiration time.

            Keep the Token.token value secret. Token.toString and the SDK logging helpers mask signatures and long payloads in recognized formats. A short v0 payload can remain visible. The Token.token getter and Token.toJSON always return the original value.

            Returns string

      • () => object
          • (): object
          • Returns a safer log value. A short v0 payload can remain visible.

            Returns object

    Index
    • Creates a token.

      An omitted expiration means that the SDK cannot determine when the token expires. It does not make the token valid forever.

      Parameters

      • token: string
      • Optionalexpiration: Date

      Returns Token

    $type: "nebius.iam.AccessToken" = 'nebius.iam.AccessToken'

    Contains the fully qualified runtime type name.

    • get expiration(): Date | undefined

      Returns the token expiration time.

      Returns Date | undefined

    • get token(): string

      Returns the original token value. Treat the result as a secret.

      Returns string

    • Returns a safer log value. A short v0 payload can remain visible.

      Returns object

    • Returns whether two tokens contain the same value.

      Parameters

      • other: unknown

      Returns boolean

    • Reports whether the known expiration time has passed.

      Returns false when the token has no expiration time.

      Returns boolean

    • Converts the token to its cache representation.

      The returned object contains the unmasked token. Store it only in a protected location.

      Returns { expires_at: number | null; token: string }

      • expires_at: number | null

        Contains the expires at.

      • token: string

        Contains the token.

    • Returns a diagnostic string. A short v0 payload can remain visible.

      Returns string

    • Restores a token from the representation returned by Token.toJSON.

      Parameters

      • data: { expires_at?: number | null; token?: string }
        • Optionalexpires_at?: number | null

          Contains the expires at.

        • Optionaltoken?: string

          Contains the token.

      Returns Token