diff options
author | Calvin Morrison <calvin@pobox.com> | 2025-09-03 21:15:36 -0400 |
---|---|---|
committer | Calvin Morrison <calvin@pobox.com> | 2025-09-03 21:15:36 -0400 |
commit | 49fa5aa2a127bdf8924d02bf77e5086b39c7a447 (patch) | |
tree | 61d86a7705dacc9fddccc29fa79d075d83ab8059 /server/_build/default/lib/base64url |
Diffstat (limited to 'server/_build/default/lib/base64url')
-rw-r--r-- | server/_build/default/lib/base64url/LICENSE.txt | 18 | ||||
-rw-r--r-- | server/_build/default/lib/base64url/README.md | 58 | ||||
-rw-r--r-- | server/_build/default/lib/base64url/ebin/base64url.app | 11 | ||||
-rw-r--r-- | server/_build/default/lib/base64url/ebin/base64url.beam | bin | 0 -> 3664 bytes | |||
-rw-r--r-- | server/_build/default/lib/base64url/hex_metadata.config | 12 | ||||
-rw-r--r-- | server/_build/default/lib/base64url/rebar.config | 11 | ||||
-rw-r--r-- | server/_build/default/lib/base64url/src/base64url.app.src | 14 | ||||
-rw-r--r-- | server/_build/default/lib/base64url/src/base64url.erl | 98 |
8 files changed, 222 insertions, 0 deletions
diff --git a/server/_build/default/lib/base64url/LICENSE.txt b/server/_build/default/lib/base64url/LICENSE.txt new file mode 100644 index 0000000..c3f0a46 --- /dev/null +++ b/server/_build/default/lib/base64url/LICENSE.txt @@ -0,0 +1,18 @@ +Copyright (c) 2013 Vladimir Dronnikov <dronnikov@gmail.com> + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/server/_build/default/lib/base64url/README.md b/server/_build/default/lib/base64url/README.md new file mode 100644 index 0000000..165a5dd --- /dev/null +++ b/server/_build/default/lib/base64url/README.md @@ -0,0 +1,58 @@ +Base64Url +============== + +[](https://hex.pm/packages/base64url) + +Standalone [URL safe](http://tools.ietf.org/html/rfc4648) base64-compatible codec. + +Usage +-------------- + +URL-Safe base64 encoding: +```erlang +base64url:encode(<<255,127,254,252>>). +<<"_3_-_A">> +base64url:decode(<<"_3_-_A">>). +<<255,127,254,252>> +``` + +Vanilla base64 encoding: +```erlang +base64:encode(<<255,127,254,252>>). +<<"/3/+/A==">> +``` + +Some systems in the wild use base64 URL encoding, but keep the padding for MIME compatibility (base64 Content-Transfer-Encoding). To interact with such systems, use: +```erlang +base64url:encode_mime(<<255,127,254,252>>). +<<"_3_-_A==">> +base64url:decode(<<"_3_-_A==">>). +<<255,127,254,252>> +``` + +Thanks +-------------- + +To authors of [this](https://github.com/basho/riak_control/blob/master/src/base64url.erl) and [this](https://github.com/mochi/mochiweb/blob/master/src/mochiweb_base64url.erl). + +[License](base64url/blob/master/LICENSE.txt) +------- + +Copyright (c) 2013 Vladimir Dronnikov <dronnikov@gmail.com> + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/server/_build/default/lib/base64url/ebin/base64url.app b/server/_build/default/lib/base64url/ebin/base64url.app new file mode 100644 index 0000000..2990bf7 --- /dev/null +++ b/server/_build/default/lib/base64url/ebin/base64url.app @@ -0,0 +1,11 @@ +{application,base64url, + [{description,"URL safe base64-compatible codec"}, + {vsn,"0.0.1"}, + {id,"git"}, + {registered,[]}, + {applications,[kernel,stdlib]}, + {env,[]}, + {contributors,["Vladimir Dronnikov"]}, + {licenses,["MIT"]}, + {links,[{"Github","https://github.com/dvv/base64url"}]}, + {modules,[base64url]}]}. diff --git a/server/_build/default/lib/base64url/ebin/base64url.beam b/server/_build/default/lib/base64url/ebin/base64url.beam Binary files differnew file mode 100644 index 0000000..b14b81b --- /dev/null +++ b/server/_build/default/lib/base64url/ebin/base64url.beam diff --git a/server/_build/default/lib/base64url/hex_metadata.config b/server/_build/default/lib/base64url/hex_metadata.config new file mode 100644 index 0000000..6eafd23 --- /dev/null +++ b/server/_build/default/lib/base64url/hex_metadata.config @@ -0,0 +1,12 @@ +{<<"name">>,<<"base64url">>}. +{<<"version">>,<<"0.0.1">>}. +{<<"app">>,<<"base64url">>}. +{<<"contributors">>,[<<"Vladimir Dronnikov">>]}. +{<<"precompiled">>,false}. +{<<"description">>,<<"URL safe base64-compatible codec">>}. +{<<"files">>, + [<<"src/base64url.app.src">>,<<"src/base64url.erl">>,<<"rebar.config">>, + <<"README.md">>,<<"LICENSE.txt">>]}. +{<<"licenses">>,[<<"MIT">>]}. +{<<"links">>,[{<<"Github">>,<<"https://github.com/dvv/base64url">>}]}. +{<<"build_tools">>,[<<"rebar">>]}. diff --git a/server/_build/default/lib/base64url/rebar.config b/server/_build/default/lib/base64url/rebar.config new file mode 100644 index 0000000..b3028a1 --- /dev/null +++ b/server/_build/default/lib/base64url/rebar.config @@ -0,0 +1,11 @@ +{lib_dirs, ["deps"]}. + +{erl_opts, [ + debug_info, + warn_format, + warn_export_vars, + warn_obsolete_guard, + warn_bif_clash +]}. + +{cover_enabled, true}. diff --git a/server/_build/default/lib/base64url/src/base64url.app.src b/server/_build/default/lib/base64url/src/base64url.app.src new file mode 100644 index 0000000..b914370 --- /dev/null +++ b/server/_build/default/lib/base64url/src/base64url.app.src @@ -0,0 +1,14 @@ +{application, base64url, [ + {description, "URL safe base64-compatible codec"}, + {vsn, "0.0.1"}, + {id, "git"}, + {registered, []}, + {applications, [ + kernel, + stdlib + ]}, + {env, []}, + {contributors, ["Vladimir Dronnikov"]}, + {licenses, ["MIT"]}, + {links, [{"Github", "https://github.com/dvv/base64url"}]} +]}. diff --git a/server/_build/default/lib/base64url/src/base64url.erl b/server/_build/default/lib/base64url/src/base64url.erl new file mode 100644 index 0000000..fa38269 --- /dev/null +++ b/server/_build/default/lib/base64url/src/base64url.erl @@ -0,0 +1,98 @@ +%% +%% @doc URL safe base64-compatible codec. +%% +%% Based heavily on the code extracted from: +%% https://github.com/basho/riak_control/blob/master/src/base64url.erl and +%% https://github.com/mochi/mochiweb/blob/master/src/mochiweb_base64url.erl. +%% + +-module(base64url). +-author('Vladimir Dronnikov <dronnikov@gmail.com>'). + +-export([ + decode/1, + encode/1, + encode_mime/1 + ]). + +-spec encode( + binary() | iolist() + ) -> binary(). + +encode(Bin) when is_binary(Bin) -> + << << (urlencode_digit(D)) >> || <<D>> <= base64:encode(Bin), D =/= $= >>; +encode(L) when is_list(L) -> + encode(iolist_to_binary(L)). + +-spec encode_mime( + binary() | iolist() + ) -> binary(). +encode_mime(Bin) when is_binary(Bin) -> + << << (urlencode_digit(D)) >> || <<D>> <= base64:encode(Bin) >>; +encode_mime(L) when is_list(L) -> + encode_mime(iolist_to_binary(L)). + +-spec decode( + binary() | iolist() + ) -> binary(). + +decode(Bin) when is_binary(Bin) -> + Bin2 = case byte_size(Bin) rem 4 of + % 1 -> << Bin/binary, "===" >>; + 2 -> << Bin/binary, "==" >>; + 3 -> << Bin/binary, "=" >>; + _ -> Bin + end, + base64:decode(<< << (urldecode_digit(D)) >> || <<D>> <= Bin2 >>); +decode(L) when is_list(L) -> + decode(iolist_to_binary(L)). + +urlencode_digit($/) -> $_; +urlencode_digit($+) -> $-; +urlencode_digit(D) -> D. + +urldecode_digit($_) -> $/; +urldecode_digit($-) -> $+; +urldecode_digit(D) -> D. + +-ifdef(TEST). +-include_lib("eunit/include/eunit.hrl"). + +aim_test() -> + % vanilla base64 produce URL unsafe output + ?assertNotEqual( + binary:match(base64:encode([255,127,254,252]), [<<"=">>, <<"/">>, <<"+">>]), + nomatch), + % this codec produce URL safe output + ?assertEqual( + binary:match(encode([255,127,254,252]), [<<"=">>, <<"/">>, <<"+">>]), + nomatch), + % the mime codec produces URL unsafe output, but only because of padding + ?assertEqual( + binary:match(encode_mime([255,127,254,252]), [<<"/">>, <<"+">>]), + nomatch), + ?assertNotEqual( + binary:match(encode_mime([255,127,254,252]), [<<"=">>]), + nomatch). + +codec_test() -> + % codec is lossless with or without padding + ?assertEqual(decode(encode(<<"foo">>)), <<"foo">>), + ?assertEqual(decode(encode(<<"foo1">>)), <<"foo1">>), + ?assertEqual(decode(encode(<<"foo12">>)), <<"foo12">>), + ?assertEqual(decode(encode(<<"foo123">>)), <<"foo123">>), + ?assertEqual(decode(encode_mime(<<"foo">>)), <<"foo">>), + ?assertEqual(decode(encode_mime(<<"foo1">>)), <<"foo1">>), + ?assertEqual(decode(encode_mime(<<"foo12">>)), <<"foo12">>), + ?assertEqual(decode(encode_mime(<<"foo123">>)), <<"foo123">>). + +iolist_test() -> + % codec supports iolists + ?assertEqual(decode(encode("foo")), <<"foo">>), + ?assertEqual(decode(encode(["fo", "o1"])), <<"foo1">>), + ?assertEqual(decode(encode([255,127,254,252])), <<255,127,254,252>>), + ?assertEqual(decode(encode_mime("foo")), <<"foo">>), + ?assertEqual(decode(encode_mime(["fo", "o1"])), <<"foo1">>), + ?assertEqual(decode(encode_mime([255,127,254,252])), <<255,127,254,252>>). + +-endif. |