ballerina/internal module

Records Summary

Record Description
CompressionError Represent all compression related errors.
JWTIssuerConfig Represents JWT issuer configurations.
JWTValidatorConfig Represents JWT validator configurations.
JwtHeader Represents a JWT header.
JwtPayload Represents a JWT payload.

Objects Summary

Object Description
Path

Reference to the file location.

Functions Summary

Return Type Function and Description
error?<> compress(internal:Path dirPath, internal:Path destDir)

Compresses a directory.

byte[] | error<> compressToByteArray(internal:Path dirPath)

Compresses a directory into a byte array.

error?<> decompress(internal:Path dirPath, internal:Path destDir)

Decompresses a compressed file.

error?<> decompressFromByteArray(byte[] content, internal:Path destDir)

Decompresses a byte array into a directory.

string | error<> execBallerinaDoc(string[] moduleList, string? sourceRoot, string? outputPath, string? templatesPath, string[]? exclude, boolean includeNatives, map<string>? envVars, string? config, boolean verbose)

Executes a ballerina doc command

string | error<> issue(internal:JwtHeader header, internal:JwtPayload payload, internal:JWTIssuerConfig config)

Issue a JWT token.

json | error<> parseJson(string s)

Parse JSON string to generate JSON object.

JwtPayload | error<> validate(string jwtToken, internal:JWTValidatorConfig config)

Validity given JWT token.

Global Variables

Name Data Type Description
COMPRESSION_ERROR_CODE string

Constant for the compression error code

INTERNAL_ERROR_CODE string

Constant for the internal error code

public type CompressionError record

Represent all compression related errors.

Field Name Data Type Default Value Description
message string

The error message

public type JWTIssuerConfig record

Represents JWT issuer configurations.

Field Name Data Type Default Value Description
keyAlias string

Key alias used for signing

keyPassword string

Key password used for signing

keyStoreFilePath string

Key store file path

keyStorePassword string

Key store password

public type JWTValidatorConfig record

Represents JWT validator configurations.

Field Name Data Type Default Value Description
issuer string

Expected issuer

audience string

Expected audience

clockSkew int 0

Clock skew in seconds

certificateAlias string

Certificate alias used for validation

trustStoreFilePath string

Trust store file path

trustStorePassword string

Trust store password

public type JwtHeader record

Represents a JWT header.

Field Name Data Type Default Value Description
alg string

Signing algorithm

typ string

Media type of the JWT

cty string

Content type, convey structural information about the JWT

kid string

Key ID, hint indicating which key was used to secure the JWS

public type JwtPayload record

Represents a JWT payload.

Field Name Data Type Default Value Description
iss string

Issuer, identifies the principal that issued the JWT

sub string

Subject, identifies the principal that is the subject of the JWT

aud string[] []

Audience, identifies the recipients that the JWT is intended for

jti string

JWT ID, unique identifier for the JWT

exp int 0

Expiration time, identifies the expiration time on or after which the JWT must not be accepted

nbf int

Not before, identifies the time before which the JWT must not be accepted

iat int

Issued at, identifies the time at which the JWT was issued

customClaims map

Map of custom claims

public function compress(internal:Path dirPath, internal:Path destDir) returns (error?<>)

Compresses a directory.

Parameter Name Data Type Default Value Description
dirPath internal:Path

Path of the directory to be compressed

destDir internal:Path

Path of the directory to place the compressed file

Return Type Description
error?<>

An error if an error occurs during the compression process

public function compressToByteArray(internal:Path dirPath) returns (byte[] | error<>)

Compresses a directory into a byte array.

Parameter Name Data Type Default Value Description
dirPath internal:Path

Path of the directory to be compressed

Return Type Description
byte[] | error<>

Compressed byte array of the file. An error if an error occurs during the compression process.

public function decompress(internal:Path dirPath, internal:Path destDir) returns (error?<>)

Decompresses a compressed file.

Parameter Name Data Type Default Value Description
dirPath internal:Path

Path of the compressed file

destDir internal:Path

Path of the directory to decompress the file

Return Type Description
error?<>

An error if an error occurs during the decompression process

public function decompressFromByteArray(byte[] content, internal:Path destDir) returns (error?<>)

Decompresses a byte array into a directory.

Parameter Name Data Type Default Value Description
content byte[]

Byte array of the compressed file

destDir internal:Path

Path of the directory to decompress the file

Return Type Description
error?<>

An error if an error occurs during the decompression process

public function execBallerinaDoc(string[] moduleList, string? sourceRoot, string? outputPath, string? templatesPath, string[]? exclude, boolean includeNatives, map<string>? envVars, string? config, boolean verbose) returns (string | error<>)

Executes a ballerina doc command

Parameter Name Data Type Default Value Description
moduleList string[]

List of modules

sourceRoot string? null

Root folder of the modules

outputPath string? null

Path to write api-docs

templatesPath string? null

Location of the templates

exclude string[]? null

Modules to exclude

includeNatives boolean false

Generate docs for natives

envVars map? null

Environment variables to pass

config string? null

Path to configuration file

verbose boolean false

Verbose mode

Return Type Description
string | error<>

Data piped from the standard output and error output of the process

public function issue(internal:JwtHeader header, internal:JwtPayload payload, internal:JWTIssuerConfig config) returns (string | error<>)

Issue a JWT token.

Parameter Name Data Type Default Value Description
header internal:JwtHeader

JwtHeader object

payload internal:JwtPayload

JwtPayload object

config internal:JWTIssuerConfig

JWTIssuerConfig object

Return Type Description
string | error<>

JWT token string or an error if token validation fails

public function parseJson(string s) returns (json | error<>)

Parse JSON string to generate JSON object.

Parameter Name Data Type Default Value Description
s string

JSON string

Return Type Description
json | error<>

JSON object.

public function validate(string jwtToken, internal:JWTValidatorConfig config) returns (JwtPayload | error<>)

Validity given JWT token.

Parameter Name Data Type Default Value Description
jwtToken string

JWT token that need to validate

config internal:JWTValidatorConfig

JWTValidatorConfig object

Return Type Description
JwtPayload | error<>

If JWT token is valied return the JWT payload. An error if token validation fails.

public type Path object

Reference to the file location.

  • <Path> __init(string root)

    Parameter Name Data Type Default Value Description
    root string
  • <Path> getPathValue() returns (string)

    Retreives the absolute path from the provided location.

    Return Type Description
    string

    Returns the absolute path as a string

  • <Path> getName() returns (string)

    Retreives the name of the file from the provided location.

    Return Type Description
    string

    Returns the name of the file

  • <Path> getExtension() returns (string)

    Retreives the extension of the file from the provided location.

    Return Type Description
    string

    Returns the extension of the file. Empty string if no extension.

  • <Path> exists() returns (boolean)

    Check for existance of the file.

    Return Type Description
    boolean

    True if the file exists, else false

  • <Path> list() returns (Path[] | error<>)

    Returns the files of folders in the directory.

    Return Type Description
    Path[] | error<>

    True if the given file path is a directory. It is false otherwise

  • <Path> isDirectory() returns (boolean)

    Check if given file is a directory

    Return Type Description
    boolean

    True if directory, else false

  • <Path> delete() returns (error?<>)

    Deletes a file/directory.

    Return Type Description
    error?<>

    Error if the directory/file could not be deleted

  • <Path> createDirectory() returns (error?<>)

    Creates a directory.

    Return Type Description
    error?<>

    Error if the directory could not be created

  • <Path> createFile() returns (error?<>)

    Creates a file.

    Return Type Description
    error?<>

    Error if the file could not be created

  • <Path> getModifiedTime() returns (time:Time | error<>)

    Retrieves the last modified time of the file of directory.

    Return Type Description
    time:Time | error<>

    Last modified time or an error if the path cannot be resolved

  • <Path> copyTo(internal:Path target) returns (error?<>)

    Copy file or directory to another path.

    Parameter Name Data Type Default Value Description
    target internal:Path

    The location to copy file or directory

    Return Type Description
    error?<>

    Error if the file could not be copied

  • <Path> moveTo(internal:Path target) returns (error?<>)

    Move file or directory to another path.

    Parameter Name Data Type Default Value Description
    target internal:Path

    The location to move file or directory

    Return Type Description
    error?<>

    Error if the file could not be moved

  • <Path> getParentDirectory() returns (Path | error<>)

    Get the enclosing parent directory.

    Return Type Description
    Path | error<>

    Path of parent folder or error occurred while getting parent directory

  • <Path> resolve(string[] paths) returns (Path)

    Resolve given path.

    Parameter Name Data Type Default Value Description
    paths string[]

    Paths to be resolved within the current path

    Return Type Description
    Path

    Resolved path