1# Copyright 2021 Google LLC 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14"""Jwt package.""" 15 16import datetime 17from typing import Dict, List, Mapping, Optional, Union, cast 18 19from tink.jwt import _jwk_set_converter 20from tink.jwt import _jwt_error 21from tink.jwt import _jwt_hmac_key_manager 22from tink.jwt import _jwt_key_templates 23from tink.jwt import _jwt_mac 24from tink.jwt import _jwt_mac_wrapper 25from tink.jwt import _jwt_public_key_sign 26from tink.jwt import _jwt_public_key_verify 27from tink.jwt import _jwt_signature_key_manager 28from tink.jwt import _jwt_signature_wrappers 29from tink.jwt import _jwt_validator 30from tink.jwt import _raw_jwt 31from tink.jwt import _verified_jwt 32 33JwtInvalidError = _jwt_error.JwtInvalidError 34RawJwt = _raw_jwt.RawJwt 35VerifiedJwt = _verified_jwt.VerifiedJwt 36JwtValidator = _jwt_validator.JwtValidator 37Claim = _raw_jwt.Claim 38JwtMac = _jwt_mac.JwtMac 39JwtPublicKeySign = _jwt_public_key_sign.JwtPublicKeySign 40JwtPublicKeyVerify = _jwt_public_key_verify.JwtPublicKeyVerify 41 42new_raw_jwt = _raw_jwt.new_raw_jwt 43new_validator = _jwt_validator.new_validator 44 45jwk_set_from_public_keyset_handle = _jwk_set_converter.from_public_keyset_handle 46jwk_set_to_public_keyset_handle = _jwk_set_converter.to_public_keyset_handle 47 48jwt_hs256_template = _jwt_key_templates.jwt_hs256_template 49raw_jwt_hs256_template = _jwt_key_templates.raw_jwt_hs256_template 50jwt_hs384_template = _jwt_key_templates.jwt_hs384_template 51raw_jwt_hs384_template = _jwt_key_templates.raw_jwt_hs384_template 52jwt_hs512_template = _jwt_key_templates.jwt_hs512_template 53raw_jwt_hs512_template = _jwt_key_templates.raw_jwt_hs512_template 54jwt_es256_template = _jwt_key_templates.jwt_es256_template 55raw_jwt_es256_template = _jwt_key_templates.raw_jwt_es256_template 56jwt_es384_template = _jwt_key_templates.jwt_es384_template 57raw_jwt_es384_template = _jwt_key_templates.raw_jwt_es384_template 58jwt_es512_template = _jwt_key_templates.jwt_es512_template 59raw_jwt_es512_template = _jwt_key_templates.raw_jwt_es512_template 60jwt_rs256_2048_f4_template = _jwt_key_templates.jwt_rs256_2048_f4_template 61raw_jwt_rs256_2048_f4_template = _jwt_key_templates.raw_jwt_rs256_2048_f4_template 62jwt_rs256_3072_f4_template = _jwt_key_templates.jwt_rs256_3072_f4_template 63raw_jwt_rs256_3072_f4_template = _jwt_key_templates.raw_jwt_rs256_3072_f4_template 64jwt_rs384_3072_f4_template = _jwt_key_templates.jwt_rs384_3072_f4_template 65raw_jwt_rs384_3072_f4_template = _jwt_key_templates.raw_jwt_rs384_3072_f4_template 66jwt_rs512_4096_f4_template = _jwt_key_templates.jwt_rs512_4096_f4_template 67raw_jwt_rs512_4096_f4_template = _jwt_key_templates.raw_jwt_rs512_4096_f4_template 68jwt_ps256_2048_f4_template = _jwt_key_templates.jwt_ps256_2048_f4_template 69raw_jwt_ps256_2048_f4_template = _jwt_key_templates.raw_jwt_ps256_2048_f4_template 70jwt_ps256_3072_f4_template = _jwt_key_templates.jwt_ps256_3072_f4_template 71raw_jwt_ps256_3072_f4_template = _jwt_key_templates.raw_jwt_ps256_3072_f4_template 72jwt_ps384_3072_f4_template = _jwt_key_templates.jwt_ps384_3072_f4_template 73raw_jwt_ps384_3072_f4_template = _jwt_key_templates.raw_jwt_ps384_3072_f4_template 74jwt_ps512_4096_f4_template = _jwt_key_templates.jwt_ps512_4096_f4_template 75raw_jwt_ps512_4096_f4_template = _jwt_key_templates.raw_jwt_ps512_4096_f4_template 76 77 78def register_jwt_mac() -> None: 79 _jwt_hmac_key_manager.register() 80 _jwt_mac_wrapper.register() 81 82 83def register_jwt_signature() -> None: 84 _jwt_signature_key_manager.register() 85 _jwt_signature_wrappers.register() 86 87 88# Deprecated. Use jwk_set_from_public_keyset_handle instead. 89jwk_set_from_keyset_handle = _jwk_set_converter.from_keyset_handle 90# Deprecated. Use jwk_set_to_public_keyset_handle instead. 91jwk_set_to_keyset_handle = _jwk_set_converter.to_keyset_handle 92