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

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