mirror of
https://github.com/anikeen-com/id.git
synced 2026-03-17 15:46:17 +00:00
Compare commits
6 Commits
1.0.0-rc.3
...
1.0.0-rc.6
| Author | SHA1 | Date | |
|---|---|---|---|
| 30ac4ae4f9 | |||
| e1a6af11a3 | |||
| bb5df7f115 | |||
| 297404b05d | |||
| 5ab57dcdfe | |||
| 0f14fa1b4c |
14
oauth-public.staging.key
Normal file
14
oauth-public.staging.key
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
-----BEGIN PUBLIC KEY-----
|
||||||
|
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAi4Ta8r01zKaGSnGi1EiD
|
||||||
|
uMFWRXBlK4y/ZIfWBpElmS2ygv4mGeP3hT4Flm696Z2UMy56KC+c7CC/PQCiutLk
|
||||||
|
5NUphyX/t+0QS5Dqpw6FB33fLTNNY7GqSmGIUE4os8XYZRSyDQRgtOgq3R3vJkoV
|
||||||
|
7zoavTJmSCQlG5Qf0T//iMmzQ+b+6VZm1CJSz5nGx94u1DuXNyP5Epkk0wuHrtwy
|
||||||
|
kADR2lmydNodJzqpSD+8yQqnAhOZNtNF4qwQ3g13fRvHycBp3G2nlCfOn2g5PmYD
|
||||||
|
KYBKqvTq4PQH4E+K3pbbMz6zf/T6Dw7zTfksqHR4hqMgN6byRRxmwuBczIumcu9b
|
||||||
|
y7xbgoIGIVZXgJliALPFi+zTPTN7c8MedFs/xCBHCmzWYTCZfHgr8RPRewD19tCG
|
||||||
|
NSny5R0vlArpuZCTTgedPESDeGU4eNEddg4yXFzKlpE2nNuvzZ1Ohruc5ETOSU19
|
||||||
|
RTCBUBkjeL6ESZRd/yKGjbVx4dEYxZdIz4yBl+hZ2ZOIyG7L3zPrccAWrPpG56xr
|
||||||
|
E5IDBXxLFhaJ5LlyEAGQehB0ShEuCdkr88Xz7ba9PHpGqY83l4//ULrqPIZPAa4Z
|
||||||
|
E3AWHT1ZtXNPeA4SzZ9Y9Oij4M3chyHxqM0lL3kYP+dstZehTujStfElDIx2Ni10
|
||||||
|
73tILu4edYS0FxsL19m8gbsCAwEAAQ==
|
||||||
|
-----END PUBLIC KEY-----
|
||||||
@@ -46,16 +46,6 @@ class AnikeenId
|
|||||||
*/
|
*/
|
||||||
public static bool $unserializesCookies = false;
|
public static bool $unserializesCookies = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* The base URL for Anikeen ID API.
|
|
||||||
*/
|
|
||||||
private static string $baseUrl = 'https://id.anikeen.com/api/';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The staging base URL for Anikeen ID API.
|
|
||||||
*/
|
|
||||||
private static string $stagingBaseUrl = 'https://staging.id.anikeen.com/api/';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The key for the access token.
|
* The key for the access token.
|
||||||
*/
|
*/
|
||||||
@@ -96,6 +86,16 @@ class AnikeenId
|
|||||||
*/
|
*/
|
||||||
protected ?string $redirectUri = null;
|
protected ?string $redirectUri = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base URL for Anikeen ID.
|
||||||
|
*/
|
||||||
|
protected string $baseUrl = 'https://id.anikeen.com';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The staging base URL for Anikeen ID.
|
||||||
|
*/
|
||||||
|
protected string $stagingBaseUrl = 'https://staging.id.anikeen.com';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*/
|
*/
|
||||||
@@ -110,25 +110,25 @@ class AnikeenId
|
|||||||
if ($redirectUri = config('services.anikeen.redirect')) {
|
if ($redirectUri = config('services.anikeen.redirect')) {
|
||||||
$this->setRedirectUri($redirectUri);
|
$this->setRedirectUri($redirectUri);
|
||||||
}
|
}
|
||||||
if (config('services.anikeen.mode') === 'staging') {
|
if (self::getMode() === 'staging' && !config('services.anikeen.base_url')) {
|
||||||
self::setBaseUrl(self::$stagingBaseUrl);
|
self::setBaseUrl($this->stagingBaseUrl);
|
||||||
}
|
}
|
||||||
if ($baseUrl = config('services.anikeen.base_url')) {
|
if ($baseUrl = config('services.anikeen.base_url')) {
|
||||||
self::setBaseUrl($baseUrl);
|
self::setBaseUrl($baseUrl);
|
||||||
}
|
}
|
||||||
$this->client = new Client([
|
$this->client = new Client([
|
||||||
'base_uri' => self::$baseUrl,
|
'base_uri' => $this->baseUrl,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected function setBaseUrl(string $baseUrl): void
|
||||||
* @param string $baseUrl
|
|
||||||
*
|
|
||||||
* @internal only for internal and debug purposes.
|
|
||||||
*/
|
|
||||||
public static function setBaseUrl(string $baseUrl): void
|
|
||||||
{
|
{
|
||||||
self::$baseUrl = $baseUrl;
|
$this->baseUrl = $baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBaseUrl(): string
|
||||||
|
{
|
||||||
|
return rtrim($this->baseUrl, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function useAccessTokenField(string $accessTokenField): void
|
public static function useAccessTokenField(string $accessTokenField): void
|
||||||
@@ -141,6 +141,11 @@ class AnikeenId
|
|||||||
return self::$accessTokenField;
|
return self::$accessTokenField;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getMode(): string
|
||||||
|
{
|
||||||
|
return config('services.anikeen.mode') ?: 'production';
|
||||||
|
}
|
||||||
|
|
||||||
public static function useRefreshTokenField(string $refreshTokenField): void
|
public static function useRefreshTokenField(string $refreshTokenField): void
|
||||||
{
|
{
|
||||||
self::$refreshTokenField = $refreshTokenField;
|
self::$refreshTokenField = $refreshTokenField;
|
||||||
|
|||||||
@@ -6,11 +6,35 @@ class Scope
|
|||||||
{
|
{
|
||||||
const USER = 'user';
|
const USER = 'user';
|
||||||
const USER_READ = 'user:read';
|
const USER_READ = 'user:read';
|
||||||
const ORDERS = 'orders';
|
|
||||||
const ORDERS_READ = 'orders:read';
|
const ADDRESSES = 'addresses';
|
||||||
const PRODUCTS = 'products';
|
const ADDRESSES_READ = 'addresses:read';
|
||||||
const PRODUCTS_READ = 'products:read';
|
|
||||||
const BILLING = 'billing';
|
const BILLING = 'billing';
|
||||||
const BILLING_READ = 'billing:read';
|
const BILLING_READ = 'billing:read';
|
||||||
|
const BILLING_CLIENT = 'billing:client';
|
||||||
|
|
||||||
|
const INVOICES = 'invoices';
|
||||||
|
const INVOICES_READ = 'invoices:read';
|
||||||
|
const INVOICES_CLIENT = 'invoices:client';
|
||||||
|
|
||||||
|
const ORDERS = 'orders';
|
||||||
|
const ORDERS_READ = 'orders:read';
|
||||||
|
const ORDERS_CLIENT = 'orders:client';
|
||||||
|
|
||||||
|
const PAYMENT_METHODS = 'payment-methods';
|
||||||
|
const PAYMENT_METHODS_READ = 'payment-methods:read';
|
||||||
|
|
||||||
|
const SUBSCRIPTIONS = 'subscriptions';
|
||||||
|
const SUBSCRIPTIONS_READ = 'subscriptions:read';
|
||||||
|
const SUBSCRIPTIONS_CLIENT = 'subscriptions:client';
|
||||||
|
|
||||||
|
const TRANSACTIONS = 'transactions';
|
||||||
|
const TRANSACTIONS_READ = 'transactions:read';
|
||||||
|
const TRANSACTIONS_CLIENT = 'transactions:client';
|
||||||
|
|
||||||
|
const SSH_KEYS = 'ssh-keys';
|
||||||
|
const SSH_KEYS_READ = 'ssh-keys:read';
|
||||||
|
|
||||||
const ADMIN = 'admin';
|
const ADMIN = 'admin';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Anikeen\Id\Helpers;
|
namespace Anikeen\Id\Helpers;
|
||||||
|
|
||||||
|
use Anikeen\Id\AnikeenId;
|
||||||
use Firebase\JWT\JWT;
|
use Firebase\JWT\JWT;
|
||||||
use Firebase\JWT\Key;
|
use Firebase\JWT\Key;
|
||||||
use Illuminate\Auth\AuthenticationException;
|
use Illuminate\Auth\AuthenticationException;
|
||||||
@@ -30,6 +31,8 @@ class JwtParser
|
|||||||
|
|
||||||
private function getOauthPublicKey(): bool|string
|
private function getOauthPublicKey(): bool|string
|
||||||
{
|
{
|
||||||
return file_get_contents(dirname(__DIR__, 3) . '/oauth-public.key');
|
return AnikeenId::getMode() === 'staging'
|
||||||
|
? file_get_contents(dirname(__DIR__, 3) . '/oauth-public.staging.key')
|
||||||
|
: file_get_contents(dirname(__DIR__, 3) . '/oauth-public.key');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ use Throwable;
|
|||||||
* @property Response $response
|
* @property Response $response
|
||||||
* @property null|Throwable $exception
|
* @property null|Throwable $exception
|
||||||
*/
|
*/
|
||||||
abstract class BaseCollection implements JsonSerializable
|
#[\AllowDynamicProperties]
|
||||||
|
abstract class BaseCollection implements JsonSerializable
|
||||||
{
|
{
|
||||||
private Closure $callable;
|
private Closure $callable;
|
||||||
public ?Result $result = null;
|
public ?Result $result = null;
|
||||||
@@ -87,4 +88,4 @@ abstract class BaseCollection implements JsonSerializable
|
|||||||
{
|
{
|
||||||
return isset($this->result->{$name});
|
return isset($this->result->{$name});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ use Anikeen\Id\Exceptions\ResourceException;
|
|||||||
use Anikeen\Id\Result;
|
use Anikeen\Id\Result;
|
||||||
use JsonSerializable;
|
use JsonSerializable;
|
||||||
|
|
||||||
abstract class BaseResource implements JsonSerializable
|
#[\AllowDynamicProperties]
|
||||||
|
abstract class BaseResource implements JsonSerializable
|
||||||
{
|
{
|
||||||
public Result $result;
|
public Result $result;
|
||||||
|
|
||||||
@@ -53,4 +54,4 @@ abstract class BaseResource implements JsonSerializable
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,35 +10,6 @@ class Transactions extends BaseCollection
|
|||||||
{
|
{
|
||||||
use HasBillable;
|
use HasBillable;
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new transaction for the current user.
|
|
||||||
*
|
|
||||||
* @param array{
|
|
||||||
* group: null|string,
|
|
||||||
* invoice_id: null|string,
|
|
||||||
* payment_provider: null|string,
|
|
||||||
* payment_intent: null|string,
|
|
||||||
* status: string,
|
|
||||||
* type: string,
|
|
||||||
* amount: float,
|
|
||||||
* created_at: string
|
|
||||||
* } $attributes The attributes for the transaction.
|
|
||||||
* - group: The group (optional)
|
|
||||||
* - invoice_id: The invoice id (optional)
|
|
||||||
* - payment_provider: The payment provider (optional, e.g. "kofi", "stripe")
|
|
||||||
* - payment_intent: The payment intent (optional)
|
|
||||||
* - status: The status (e.g. "expired", "failed", "pending", "refunded", "succeeded")
|
|
||||||
* - type: The type (e.g. "deposit", "withdrawal")
|
|
||||||
* - amount: The amount
|
|
||||||
* - created_at: The created at datetime string (e.g. "Y-M-D H:i:s")
|
|
||||||
* @throws Throwable
|
|
||||||
*/
|
|
||||||
public function create(array $attributes = []): Transaction
|
|
||||||
{
|
|
||||||
return (new Transaction($this->billable->request('POST', 'v1/transactions', $attributes)))
|
|
||||||
->setBillable($this->billable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Anikeen\Id\Socialite;
|
namespace Anikeen\Id\Socialite;
|
||||||
|
|
||||||
|
use Anikeen\Id\AnikeenId;
|
||||||
use Anikeen\Id\Enums\Scope;
|
use Anikeen\Id\Enums\Scope;
|
||||||
use GuzzleHttp\Exception\GuzzleException;
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -32,11 +33,7 @@ class Provider extends AbstractProvider implements ProviderInterface
|
|||||||
*/
|
*/
|
||||||
protected function getBaseUrl(): string
|
protected function getBaseUrl(): string
|
||||||
{
|
{
|
||||||
$mode = config('services.anikeen.mode') ?? 'production';
|
return app(AnikeenId::class)->getBaseUrl();
|
||||||
|
|
||||||
return $mode === 'staging'
|
|
||||||
? 'https://staging.id.anikeen.com'
|
|
||||||
: 'https://id.anikeen.com';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,4 +95,12 @@ class Provider extends AbstractProvider implements ProviderInterface
|
|||||||
'grant_type' => 'authorization_code',
|
'grant_type' => 'authorization_code',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the user logout url for the provider.
|
||||||
|
*/
|
||||||
|
public function getLogoutUrl(string $redirect = null): string
|
||||||
|
{
|
||||||
|
return app(AnikeenId::class)->getBaseUrl() . '/logout?redirect=' . urlencode($redirect ?: '/');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user