Net::OneTimeSecret - Perl interface to OneTimeSecret.com API
use Net::OneTimeSecret; $api = Net::OneTimeSecret->new( <your customer id>, <your API key> ); $response = $api->shareSecret( "Attack at dawn" ); $secretKey = $response->{secret_key}; $retrievedMessage = $api->retrieveSecret( $secretKey ); print $retrievedMessage->{value}; Attack at dawn $retrieveAgain = $api->retrieveSecret( $secretKey ); print $retrieveAgain->{value}; # value is empty
0.03
Very thin wrapper
You have full access to arguments and returned values for all the REST API calls.
Transparent
You call it with Perl data, and get back Perl data. No messing with encoding or decoding of JSON.
Unicode
Unicode, errrm, seems to work OK.
See https://onetimesecret.com if you don't know how it works or what it's for.
To use, you create an api object by instantiating a Net::OneTimeSecret using your customer id (which is the email address with which you signed up for your API account) and your api key (which you need to generate at https://onetimesecret.com).
my $response = $api->status();
If $response->{status} is equal to "nominal" then the system is up.
my $response = $api->shareSecret( <secret>, [options] );
where options can be
This will send recipient an email notifying them that there is a secret for them to collect
A passphrase that the recipient will need to know in order to retrieve the secret
How long the secret will last
It will return a hash like this:
{ "custid": <this is you>, "value": <secret>, "metadata_key": <metadata key>, "secret_key": <secret key>, "ttl": <seconds>, "updated": <utc>, "created": <utc> }
my $response = $api->retrieveSecret( <secret>, [ passphrase => <passphrase> ] );
There is only one possible option:
This generates a secret (useful for creating passwords, ids, etc) that can be viewed only once.
my $response = $api->generateSecret( [options] );
my $response = $api->retrieveMetadata( <metadata_key> );
{ "custid": <this is you>, "metadata_key": <metadata key>, "secret_key": <secret key>, "ttl": <seconds>, "updated": <utc>, "created": <utc> }
Error handling
Right now you're on your own to test for errors and trap explosions.
Bulletproofing
There are lots of cases that could have slipped through the cracks, so it will need some cleaning up and bulletproofing to harden it a bit.
Please report bugs relevant to OneTimeSecret to <info[at]kyledawkins.com>.
OneTimeSecret
The github repository is at https://quile@github.com/quile/onetime-perl.git
Some other stuff.
Kyle Dawkins, <info[at]kyledawkins.com>
Copyright 2011 by Kyle Dawkins
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Net::OneTimeSecret, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::OneTimeSecret
CPAN shell
perl -MCPAN -e shell install Net::OneTimeSecret
For more information on module installation, please visit the detailed CPAN module installation guide.