-module(gose). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/gose.gleam"). -export([error_message/1]). -export_type([gose_error/0]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. ?MODULEDOC( " A Gleam library for JOSE (JSON Object Signing and Encryption) and\n" " COSE (CBOR Object Signing and Encryption).\n" "\n" " Core:\n" " - `gose/algorithm`: algorithm identifiers\n" " - `gose/key`: key management\n" " - `gose/cbor`: CBOR encoding for COSE\n" "\n" " JOSE:\n" " - `gose/jose/jws`: JSON Web Signature ([RFC 7515](https://www.rfc-editor.org/rfc/rfc7515.html))\n" " - `gose/jose/jws_multi`: JWS JSON Serialization for multi-signer workflows\n" " - `gose/jose/jwe`: JSON Web Encryption ([RFC 7516](https://www.rfc-editor.org/rfc/rfc7516.html))\n" " - `gose/jose/jwe_multi`: JWE JSON Serialization for multi-recipient workflows\n" " - `gose/jose/jwk`: JSON Web Key serialization ([RFC 7517](https://www.rfc-editor.org/rfc/rfc7517.html))\n" " - `gose/jose/key_set`: JWK Set ([RFC 7517 Section 5](https://www.rfc-editor.org/rfc/rfc7517.html#section-5))\n" " - `gose/jose/encrypted_key`: encrypted JWK export/import\n" " - `gose/jose/jwt`: JSON Web Token ([RFC 7519](https://www.rfc-editor.org/rfc/rfc7519.html))\n" " - `gose/jose/encrypted_jwt`: encrypted JWT (JWE-based)\n" "\n" " COSE:\n" " - `gose/cose`: header parameters ([RFC 9052 Section 3.1](https://www.rfc-editor.org/rfc/rfc9052.html#section-3.1))\n" " - `gose/cose/sign1`: COSE_Sign1 ([RFC 9052](https://www.rfc-editor.org/rfc/rfc9052.html))\n" " - `gose/cose/sign`: COSE_Sign multi-signer ([RFC 9052](https://www.rfc-editor.org/rfc/rfc9052.html))\n" " - `gose/cose/encrypt0`: COSE_Encrypt0 ([RFC 9052](https://www.rfc-editor.org/rfc/rfc9052.html))\n" " - `gose/cose/encrypt`: COSE_Encrypt multi-recipient ([RFC 9052](https://www.rfc-editor.org/rfc/rfc9052.html))\n" " - `gose/cose/mac0`: COSE_Mac0 ([RFC 9052](https://www.rfc-editor.org/rfc/rfc9052.html))\n" " - `gose/cose/key`: COSE Key serialization ([RFC 9052](https://www.rfc-editor.org/rfc/rfc9052.html))\n" " - `gose/cose/algorithm`: COSE algorithm ID mapping ([RFC 9053](https://www.rfc-editor.org/rfc/rfc9053.html))\n" " - `gose/cose/cwt`: CBOR Web Token ([RFC 8392](https://www.rfc-editor.org/rfc/rfc8392.html))\n" " - `gose/cose/encrypted_cwt`: encrypted CWT (Encrypt0-wrapped Sign1)\n" ). -type gose_error() :: {parse_error, binary()} | {crypto_error, binary()} | {invalid_state, binary()} | verification_failed. -file("src/gose.gleam", 53). ?DOC(" Extract the message string from a GoseError, regardless of variant.\n"). -spec error_message(gose_error()) -> binary(). error_message(Error) -> case Error of {parse_error, Msg} -> Msg; {crypto_error, Msg@1} -> Msg@1; {invalid_state, Msg@2} -> Msg@2; verification_failed -> <<"verification failed"/utf8>> end.