adrenth/raindrop-sdk

此包已被废弃且不再维护。未建议替代包。

Hydro Raindrop SDK

1.2.0 2018-08-02 16:52 UTC

This package is auto-updated.

Last update: 2020-05-23 14:42:30 UTC


README

此包提供了一组便捷函数,旨在简化将Hydro的Raindrop身份验证集成到您的项目中的过程。更多信息和详细API文档可在Raindrop文档中找到。

Raindrop有两大版本

客户端Raindrop

客户端Raindrop是一个下一代的双因素认证解决方案。Hydro已开源了客户端Raindrop的代码

服务器端Raindrop

服务器端Raindrop是一个企业级的安全协议,用于保护API和其他共享资源。Hydro已开源了服务器端Raindrop的代码

安装说明

composer require adrenth/raindrop-sdk

使用示例

require __DIR__ . '/../vendor/autoload.php';

$clientId = '...';
$clientSecret = '...';
$applicationId = '...';

$settings = new \Adrenth\Raindrop\ApiSettings(
    $clientId,
    $clientSecret,
    new \Adrenth\Raindrop\Environment\SandboxEnvironment
);

// Create token storage for storing the API's access token.
$tokenStorage = new \Adrenth\Raindrop\TokenStorage\FileTokenStorage(__DIR__ . '/token.txt');

// Ideally create your own TokenStorage adapter. 
// The shipped FileTokenStorage is purely an example of how to create your own.

/*
 * Client-side calls
 */
$client = new \Adrenth\Raindrop\Client($settings, $tokenStorage, $applicationId);

// (Un)register a user by it's Hydro ID
$client->registerUser($hydroId);
$client->unregisterUser($hydroId);

// Generate 6 digit message
$message = $client->generateMessage();

// Verify signature
$client->verifySignature($hydroId, $message);

/*
 * Server-side calls
 */
$server = new \Adrenth\Raindrop\Server($settings, $tokenStorage);

$server->whitelist('0x..'); // Provide ETH address
$server->challenge('41579b51-c365-406e-86a8-3839fcad576f');
$server->authenticate('41579b51-c365-406e-86a8-3839fcad576f');