' JWT/OAuth2 constants and optional helper declarations.
#IF NOT %DEF(PBX_JWT_OAUTH2_PBI)
#DEFINE PBX_JWT_OAUTH2_PBI

CONST JWT_HEADER_ALG = "alg"
CONST JWT_HEADER_TYP = "typ"
CONST JWT_HEADER_KID = "kid"
CONST JWT_TYP_JWT = "JWT"
CONST JWT_ALG_NONE = "none"
CONST JWT_ALG_HS256 = "HS256"
CONST JWT_ALG_HS384 = "HS384"
CONST JWT_ALG_HS512 = "HS512"
CONST JWT_ALG_RS256 = "RS256"
CONST JWT_ALG_RS384 = "RS384"
CONST JWT_ALG_RS512 = "RS512"
CONST JWT_ALG_ES256 = "ES256"
CONST JWT_ALG_ES384 = "ES384"
CONST JWT_ALG_ES512 = "ES512"
CONST JWT_CLAIM_ISS = "iss"
CONST JWT_CLAIM_SUB = "sub"
CONST JWT_CLAIM_AUD = "aud"
CONST JWT_CLAIM_EXP = "exp"
CONST JWT_CLAIM_NBF = "nbf"
CONST JWT_CLAIM_IAT = "iat"
CONST JWT_CLAIM_JTI = "jti"
CONST JWT_CLAIM_SCOPE = "scope"
CONST OAUTH2_GRANT_AUTHORIZATION_CODE = "authorization_code"
CONST OAUTH2_GRANT_CLIENT_CREDENTIALS = "client_credentials"
CONST OAUTH2_GRANT_REFRESH_TOKEN = "refresh_token"
CONST OAUTH2_RESPONSE_TYPE_CODE = "code"
CONST OAUTH2_TOKEN_TYPE_BEARER = "Bearer"
CONST OAUTH2_HEADER_BEARER_PREFIX = "Bearer "
CONST OAUTH2_FIELD_ACCESS_TOKEN = "access_token"
CONST OAUTH2_FIELD_REFRESH_TOKEN = "refresh_token"
CONST OAUTH2_FIELD_TOKEN_TYPE = "token_type"
CONST OAUTH2_FIELD_EXPIRES_IN = "expires_in"
CONST OAUTH2_FIELD_SCOPE = "scope"

DECLARE FUNCTION PBXJwt_Parse LIB "pbxapi64.dll" ALIAS "PBXJwt_Parse" (BYVAL pToken AS QUAD, BYVAL cbToken AS QUAD, BYVAL phHeaderDoc AS QUAD, BYVAL phPayloadDoc AS QUAD) AS LONG
DECLARE FUNCTION PBXJwt_VerifyHmac LIB "pbxapi64.dll" ALIAS "PBXJwt_VerifyHmac" (BYVAL pToken AS QUAD, BYVAL cbToken AS QUAD, BYVAL pKey AS QUAD, BYVAL cbKey AS QUAD, BYVAL algId AS LONG) AS LONG
DECLARE FUNCTION PBXJwt_CreateHmac LIB "pbxapi64.dll" ALIAS "PBXJwt_CreateHmac" (BYVAL hHeaderDoc AS QUAD, BYVAL hPayloadDoc AS QUAD, BYVAL pKey AS QUAD, BYVAL cbKey AS QUAD, BYVAL algId AS LONG, BYVAL ppToken AS QUAD, BYVAL pcbToken AS QUAD) AS LONG

#ENDIF
