-- Deploy camper:encode_base64url to pg
-- requires: roles
-- requires: schema_camper

begin;

set search_path to camper, public;

create or replace function encode_base64url(data bytea) returns text as
$$
	select translate(encode(data, 'base64'), E'+/\n', '-_');
$$
	language sql
	immutable
;

revoke execute on function encode_base64url(bytea) from public;
grant execute on function encode_base64url(bytea) to guest;
grant execute on function encode_base64url(bytea) to employee;
grant execute on function encode_base64url(bytea) to admin;

commit;
