Bitbucket Data Center API Client
    Preparing search index...

    Class Security

    Handles authentication (Basic or Bearer) for Bitbucket Data Center REST API requests.

    const security = new Security(
    'https://bitbucket.example.com',
    'my-user',
    'my-token'
    );

    const headers = security.getHeaders();
    // { Authorization: 'Basic <base64>', 'Content-Type': 'application/json', Accept: 'application/json' }

    // HTTP access tokens recommend Bearer authentication instead:
    const bearerSecurity = new Security('https://bitbucket.example.com', '', 'my-token', 'bearer');
    // { Authorization: 'Bearer my-token', ... }
    Index

    Constructors

    • Creates a new Security instance with Basic or Bearer authentication credentials.

      Parameters

      • apiUrl: string

        The base URL of the Bitbucket Data Center instance (e.g., https://bitbucket.example.com). Must be a valid URL; throws if it cannot be parsed.

      • user: string

        The username to authenticate with. Ignored when authType is 'bearer'.

      • token: string

        The personal access token or password to authenticate with

      • authType: AuthType = 'basic'

        The authentication scheme to use. Defaults to 'basic'.

      Returns Security

      If apiUrl is not a valid URL

    Methods

    • Returns the base URL of the Bitbucket Data Center instance, without a trailing slash.

      Returns string

      The API base URL

    • Returns the value of the Authorization header for Basic Authentication.

      Returns string

      The Authorization header value in the format Basic <base64-encoded-credentials>

    • Returns the full set of HTTP headers required for authenticated API requests.

      Returns Record<string, string>

      An object containing Authorization, Content-Type, and Accept headers