NAME
UID2::Client::XS - Unified ID 2.0 Client for Perl (binding to the UID2 C++ library)
SYNOPSIS
use UID2::Client::XS;
my $client = UID2::Client::XS->new({
    endpoint => '...',
    auth_key => '...',
    secret_key => '...',
});
my $result = $client->refresh();
die $result->{reason} unless $result->{is_success};
my $decrypted = $client->decrypt($uid2_token);
if ($result->{is_success}) {
    say $result->{uid};
}
DESCRIPTION
This module provides an interface to Unified ID 2.0 API.
CONSTRUCTOR METHODS
new
my $client = UID2::Client::XS->new(\%options);
Creates and returns a new UID2 client with a hashref of options.
Valid options are:
- endpoint
 - 
The UID2 Endpoint (required).
Please note that not to specify a trailing slash.
 - auth_key
 - 
A bearer token in the request's authorization header (required).
 - secret_key
 - 
A secret key for encrypting/decrypting the request/response body (required).
 - identity_scope
 - 
UID2 or EUID. Defaults to UID2.
 
new_euid
my $client = UID2::Client::XS->new_euid(\%options);
Calls new() with EUID identity_scope.
METHODS
refresh
my $result = $client->refresh();
Fetch the latest keys and returns a hashref containing the response. The hashref will have the following keys:
- is_success
 - 
Boolean indicating whether the operation succeeded.
 - reason
 - 
Returns reason for failure if is_success is false.
 
refresh_json
my $result = $client->refresh_json($json);
Updates keys with the JSON string and returns a hashref containing the response. The hashref will have same keys of refresh.
decrypt
my $result = $client->decrypt($token);
# or
my $result = $client->decrypt($token, $timestamp);
Decrypts an advertising token and returns a hashref containing the response. The hashref will have the following keys:
- is_success
 - 
Boolean indicating whether the operation succeeded.
 - status
 - 
Returns failed status if is_success is false.
See UID2::Client::XS::DecryptionStatus for more details.
 - uid
 - 
The UID2 string.
 - site_id
 - site_key_site_id
 - established
 
encrypt_data
my $result = $client->encrypt_data($data, \%request);
Encrypts arbitrary data with a hashref of requests.
Valid options are:
- advertising_token
 - 
Specify the UID2 Token.
 - site_id
 - initialization_vector
 - now
 
One of advertising_token or site_id must be passed.
Returns a hashref containing the response. The hashref will have the following keys:
- is_success
 - 
Boolean indicating whether the operation succeeded.
 - status
 - 
Returns failed status if is_success is false.
See UID2::Client::XS::EncryptionStatus for more details.
 - encrypted_data
 
decrypt_data
my $result = $client->decrypt_data($encrypted_data);
Decrypts data encrypted with encrypt_data(). Returns a hashref containing the response. The hashref will have the following keys:
- is_success
 - status
 - decrypted_data
 - encrypted_at
 
SEE ALSO
https://github.com/IABTechLab/uid2-client-cpp11
AUTHOR
Jiro Nishiguchi <jiro@cpan.org>