allow vendord
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s

This commit is contained in:
2026-03-30 14:54:57 +07:00
parent 66aed7c4e8
commit b5e3a778ce
21316 changed files with 2777892 additions and 13 deletions

View File

@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace Kreait\Firebase\Contract;
use Kreait\Firebase\AppCheck\AppCheckToken;
use Kreait\Firebase\AppCheck\AppCheckTokenOptions;
use Kreait\Firebase\AppCheck\VerifyAppCheckTokenResponse;
use Kreait\Firebase\Exception;
use Kreait\Firebase\Exception\AppCheck\FailedToVerifyAppCheckToken;
use Kreait\Firebase\Exception\AppCheck\InvalidAppCheckToken;
use Kreait\Firebase\Exception\AppCheck\InvalidAppCheckTokenOptions;
/**
* @phpstan-import-type AppCheckTokenOptionsShape from AppCheckTokenOptions
*/
interface AppCheck
{
/**
* @param non-empty-string $appId
* @param AppCheckTokenOptions|AppCheckTokenOptionsShape|null $options
*
* @throws InvalidAppCheckTokenOptions
* @throws Exception\AppCheckException
* @throws Exception\FirebaseException
*/
public function createToken(string $appId, $options = null): AppCheckToken;
/**
* @param non-empty-string $appCheckToken
*
* @throws InvalidAppCheckToken
* @throws FailedToVerifyAppCheckToken
* @throws Exception\AppCheckException
* @throws Exception\FirebaseException
*/
public function verifyToken(string $appCheckToken): VerifyAppCheckTokenResponse;
}

View File

@@ -0,0 +1,463 @@
<?php
declare(strict_types=1);
namespace Kreait\Firebase\Contract;
use DateInterval;
use InvalidArgumentException;
use Kreait\Firebase\Auth\ActionCodeSettings;
use Kreait\Firebase\Auth\CreateActionLink\FailedToCreateActionLink;
use Kreait\Firebase\Auth\CreateSessionCookie\FailedToCreateSessionCookie;
use Kreait\Firebase\Auth\DeleteUsersResult;
use Kreait\Firebase\Auth\SendActionLink\FailedToSendActionLink;
use Kreait\Firebase\Auth\SignIn\FailedToSignIn;
use Kreait\Firebase\Auth\SignInResult;
use Kreait\Firebase\Auth\UserQuery;
use Kreait\Firebase\Auth\UserRecord;
use Kreait\Firebase\Exception;
use Kreait\Firebase\Exception\Auth\ExpiredOobCode;
use Kreait\Firebase\Exception\Auth\FailedToVerifySessionCookie;
use Kreait\Firebase\Exception\Auth\FailedToVerifyToken;
use Kreait\Firebase\Exception\Auth\InvalidOobCode;
use Kreait\Firebase\Exception\Auth\OperationNotAllowed;
use Kreait\Firebase\Exception\Auth\RevokedIdToken;
use Kreait\Firebase\Exception\Auth\RevokedSessionCookie;
use Kreait\Firebase\Exception\Auth\UserDisabled;
use Kreait\Firebase\Exception\Auth\UserNotFound;
use Kreait\Firebase\Request\CreateUser;
use Kreait\Firebase\Request\UpdateUser;
use Lcobucci\JWT\Token;
use Lcobucci\JWT\UnencryptedToken;
use Psr\Http\Message\UriInterface;
use Stringable;
use Traversable;
/**
* @phpstan-import-type UserQueryShape from UserQuery
*/
interface Auth
{
/**
* @param Stringable|non-empty-string $uid
*
* @throws UserNotFound
* @throws Exception\AuthException
* @throws Exception\FirebaseException
*/
public function getUser(Stringable|string $uid): UserRecord;
/**
* @param non-empty-list<Stringable|non-empty-string> $uids
*
* @throws Exception\AuthException
* @throws Exception\FirebaseException
*
* @return array<non-empty-string, UserRecord|null>
*/
public function getUsers(array $uids): array;
/**
* @param UserQuery|UserQueryShape $query
*
* @throws Exception\FirebaseException
* @throws Exception\AuthException
*
* @return array<non-empty-string, UserRecord>
*/
public function queryUsers(UserQuery|array $query): array;
/**
* @param positive-int $maxResults
* @param positive-int $batchSize
*
* @throws Exception\FirebaseException
* @throws Exception\AuthException
*
* @return Traversable<UserRecord>
*/
public function listUsers(int $maxResults = 1000, int $batchSize = 1000): Traversable;
/**
* Creates a new user with the provided properties.
*
* @param array<non-empty-string, mixed>|CreateUser $properties
*
* @throws Exception\AuthException
* @throws Exception\FirebaseException
*/
public function createUser(array|CreateUser $properties): UserRecord;
/**
* Updates the given user with the given properties.
*
* @param non-empty-array<non-empty-string, mixed>|UpdateUser $properties
*
* @throws Exception\AuthException
* @throws Exception\FirebaseException
*/
public function updateUser(Stringable|string $uid, array|UpdateUser $properties): UserRecord;
/**
* @param Stringable|non-empty-string $email
* @param Stringable|non-empty-string $password
*
* @throws Exception\AuthException
* @throws Exception\FirebaseException
*/
public function createUserWithEmailAndPassword(Stringable|string $email, Stringable|string $password): UserRecord;
/**
* @param Stringable|non-empty-string $email
*
* @throws UserNotFound
* @throws Exception\AuthException
* @throws Exception\FirebaseException
*/
public function getUserByEmail(Stringable|string $email): UserRecord;
/**
* @param Stringable|non-empty-string $phoneNumber
*
* @throws Exception\AuthException
* @throws Exception\FirebaseException
*/
public function getUserByPhoneNumber(Stringable|string $phoneNumber): UserRecord;
/**
* @throws Exception\AuthException
* @throws Exception\FirebaseException
*/
public function createAnonymousUser(): UserRecord;
/**
* @param Stringable|non-empty-string $uid
* @param Stringable|non-empty-string $newPassword
*
* @throws Exception\AuthException
* @throws Exception\FirebaseException
*/
public function changeUserPassword(Stringable|string $uid, Stringable|string $newPassword): UserRecord;
/**
* @param Stringable|non-empty-string $uid
* @param Stringable|non-empty-string $newEmail
*
* @throws Exception\AuthException
* @throws Exception\FirebaseException
*/
public function changeUserEmail(Stringable|string $uid, Stringable|string $newEmail): UserRecord;
/**
* @param Stringable|non-empty-string $uid
*
* @throws Exception\AuthException
* @throws Exception\FirebaseException
*/
public function enableUser(Stringable|string $uid): UserRecord;
/**
* @param Stringable|non-empty-string $uid
*
* @throws Exception\AuthException
* @throws Exception\FirebaseException
*/
public function disableUser(Stringable|string $uid): UserRecord;
/**
* @param Stringable|non-empty-string $uid
*
* @throws UserNotFound
* @throws Exception\AuthException
* @throws Exception\FirebaseException
*/
public function deleteUser(Stringable|string $uid): void;
/**
* @param iterable<Stringable|non-empty-string> $uids
* @param bool $forceDeleteEnabledUsers Whether to force deleting accounts that are not in disabled state. If false, only disabled accounts will be deleted, and accounts that are not disabled will be added to the errors.
*
* @throws Exception\AuthException
*/
public function deleteUsers(iterable $uids, bool $forceDeleteEnabledUsers = false): DeleteUsersResult;
/**
* @param non-empty-string $type
* @param Stringable|non-empty-string $email
* @param ActionCodeSettings|array<non-empty-string, mixed>|null $actionCodeSettings
* @param non-empty-string|null $locale
*
* @throws FailedToCreateActionLink
*/
public function getEmailActionLink(string $type, Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): string;
/**
* @param non-empty-string $type
* @param Stringable|non-empty-string $email
* @param ActionCodeSettings|array<non-empty-string, mixed>|null $actionCodeSettings
* @param non-empty-string|null $locale
*
* @throws UserNotFound
* @throws FailedToSendActionLink
*/
public function sendEmailActionLink(string $type, Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): void;
/**
* @param Stringable|non-empty-string $email
* @param ActionCodeSettings|array<non-empty-string, mixed>|null $actionCodeSettings
* @param non-empty-string|null $locale
*
* @throws FailedToCreateActionLink
*/
public function getEmailVerificationLink(Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): string;
/**
* @param Stringable|non-empty-string $email
* @param ActionCodeSettings|array<non-empty-string, mixed>|null $actionCodeSettings
* @param non-empty-string|null $locale
*
* @throws FailedToSendActionLink
*/
public function sendEmailVerificationLink(Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): void;
/**
* @param Stringable|non-empty-string $email
* @param ActionCodeSettings|array<non-empty-string, mixed>|null $actionCodeSettings
* @param non-empty-string|null $locale
*
* @throws FailedToCreateActionLink
*/
public function getPasswordResetLink(Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): string;
/**
* @param Stringable|non-empty-string $email
* @param ActionCodeSettings|array<non-empty-string, mixed>|null $actionCodeSettings
* @param non-empty-string|null $locale
*
* @throws FailedToSendActionLink
*/
public function sendPasswordResetLink(Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): void;
/**
* @param Stringable|non-empty-string $email
* @param ActionCodeSettings|array<non-empty-string, mixed>|null $actionCodeSettings
* @param non-empty-string|null $locale
*
* @throws FailedToCreateActionLink
*/
public function getSignInWithEmailLink(Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): string;
/**
* @param Stringable|non-empty-string $email
* @param ActionCodeSettings|array<non-empty-string, mixed>|null $actionCodeSettings
* @param non-empty-string|null $locale
*
* @throws FailedToSendActionLink
*/
public function sendSignInWithEmailLink(Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): void;
/**
* Sets additional developer claims on an existing user identified by the provided UID.
*
* @see https://firebase.google.com/docs/auth/admin/custom-claims
*
* @param Stringable|non-empty-string $uid
* @param array<non-empty-string, mixed>|null $claims
*
* @throws Exception\AuthException
* @throws Exception\FirebaseException
*/
public function setCustomUserClaims(Stringable|string $uid, ?array $claims): void;
/**
* @param array<non-empty-string, mixed> $claims
* @param int<0, 3600>|DateInterval|non-empty-string $ttl
*
* @throws Exception\AuthException
* @throws Exception\FirebaseException
*/
public function createCustomToken(Stringable|string $uid, array $claims = [], int|DateInterval|string $ttl = 3600): UnencryptedToken;
/**
* @param non-empty-string $tokenString
*/
public function parseToken(string $tokenString): UnencryptedToken;
/**
* Creates a new Firebase session cookie with the given lifetime.
*
* The session cookie JWT will have the same payload claims as the provided ID token.
*
* @param Token|non-empty-string $idToken The Firebase ID token to exchange for a session cookie
* @param DateInterval|positive-int $ttl
*
* @throws InvalidArgumentException if the token or TTL is invalid
* @throws FailedToCreateSessionCookie
*/
public function createSessionCookie(Token|string $idToken, DateInterval|int $ttl): string;
/**
* Verifies a JWT auth token.
*
* Returns a token with the token's claims or rejects it if the token could not be verified.
*
* If checkRevoked is set to true, verifies if the session corresponding to the ID token was revoked.
* If the corresponding user's session was invalidated, a RevokedIdToken exception is thrown.
* If not specified the check is not applied.
*
* NOTE: Allowing time inconsistencies might impose a security risk. Do this only when you are not able
* to fix your environment's time to be consistent with Google's servers.
*
* @param Token|non-empty-string $idToken the JWT to verify
* @param bool $checkIfRevoked whether to check if the ID token is revoked
* @param positive-int|null $leewayInSeconds number of seconds to allow a token to be expired, in case that there
* is a clock skew between the signing and the verifying server
*
* @throws FailedToVerifyToken if the token could not be verified
* @throws RevokedIdToken if the token has been revoked
*/
public function verifyIdToken(Token|string $idToken, bool $checkIfRevoked = false, ?int $leewayInSeconds = null): UnencryptedToken;
/**
* Verifies a JWT session cookie.
*
* Returns a token with the cookie's claims or rejects it if the session cookie could not be verified.
*
* If checkRevoked is set to true, verifies if the session corresponding to the ID token was revoked.
* If the corresponding user's session was invalidated, a RevokedSessionCookie exception is thrown.
* If not specified the check is not applied.
*
* NOTE: Allowing time inconsistencies might impose a security risk. Do this only when you are not able
* to fix your environment's time to be consistent with Google's servers.
*
* @param non-empty-string $sessionCookie
* @param positive-int|null $leewayInSeconds
*
* @throws FailedToVerifySessionCookie
* @throws RevokedSessionCookie
*/
public function verifySessionCookie(string $sessionCookie, bool $checkIfRevoked = false, ?int $leewayInSeconds = null): UnencryptedToken;
/**
* Verifies the given password reset code and returns the associated user's email address.
*
* @see https://firebase.google.com/docs/reference/rest/auth#section-verify-password-reset-code
*
* @param non-empty-string $oobCode
*
* @throws ExpiredOobCode
* @throws InvalidOobCode
* @throws OperationNotAllowed
* @throws Exception\AuthException
* @throws Exception\FirebaseException
*/
public function verifyPasswordResetCode(string $oobCode): string;
/**
* Applies the password reset requested via the given OOB code and returns the associated user's email address.
*
* @see https://firebase.google.com/docs/reference/rest/auth#section-confirm-reset-password
*
* @param non-empty-string $oobCode the email action code sent to the user's email for resetting the password
* @param Stringable|non-empty-string $newPassword
* @param bool $invalidatePreviousSessions Invalidate sessions initialized with the previous credentials
*
* @throws ExpiredOobCode
* @throws InvalidOobCode
* @throws OperationNotAllowed
* @throws UserDisabled
* @throws Exception\AuthException
* @throws Exception\FirebaseException
*/
public function confirmPasswordReset(string $oobCode, Stringable|string $newPassword, bool $invalidatePreviousSessions = true): string;
/**
* Revokes all refresh tokens for the specified user identified by the uid provided.
* In addition to revoking all refresh tokens for a user, all ID tokens issued
* before revocation will also be revoked on the Auth backend. Any request with an
* ID token generated before revocation will be rejected with a token expired error.
*
* @param Stringable|string $uid the user whose tokens are to be revoked
*
* @throws Exception\AuthException
* @throws Exception\FirebaseException
*/
public function revokeRefreshTokens(Stringable|string $uid): void;
/**
* @param Stringable|non-empty-string $uid
* @param list<Stringable|non-empty-string>|Stringable|non-empty-string $provider
*
* @throws Exception\AuthException
* @throws Exception\FirebaseException
*/
public function unlinkProvider(Stringable|string $uid, array|Stringable|string $provider): UserRecord;
/**
* @param UserRecord|Stringable|non-empty-string $user
* @param array<non-empty-string, mixed>|null $claims
*
* @throws FailedToSignIn
*/
public function signInAsUser(UserRecord|Stringable|string $user, ?array $claims = null): SignInResult;
/**
* @param Token|non-empty-string $token
*
* @throws FailedToSignIn
*/
public function signInWithCustomToken(Token|string $token): SignInResult;
/**
* @param non-empty-string $refreshToken
*
* @throws FailedToSignIn
*/
public function signInWithRefreshToken(string $refreshToken): SignInResult;
/**
* @param Stringable|non-empty-string $email
* @param Stringable|non-empty-string $clearTextPassword
*
* @throws FailedToSignIn
*/
public function signInWithEmailAndPassword(Stringable|string $email, Stringable|string $clearTextPassword): SignInResult;
/**
* @param Stringable|non-empty-string $email
* @param non-empty-string $oobCode
*
* @throws FailedToSignIn
*/
public function signInWithEmailAndOobCode(Stringable|string $email, string $oobCode): SignInResult;
/**
* @throws FailedToSignIn
*/
public function signInAnonymously(): SignInResult;
/**
* @see https://cloud.google.com/identity-platform/docs/reference/rest/v1/accounts/signInWithIdp
*
* @param Stringable|non-empty-string $provider
* @param non-empty-string $accessToken
* @param UriInterface|non-empty-string|null $redirectUrl
* @param non-empty-string|null $oauthTokenSecret
* @param non-empty-string|null $linkingIdToken
* @param non-empty-string|null $rawNonce
*
* @throws FailedToSignIn
*/
public function signInWithIdpAccessToken(Stringable|string $provider, string $accessToken, $redirectUrl = null, ?string $oauthTokenSecret = null, ?string $linkingIdToken = null, ?string $rawNonce = null): SignInResult;
/**
* @param Stringable|non-empty-string $provider
* @param Token|non-empty-string $idToken
* @param UriInterface|non-empty-string|null $redirectUrl
* @param non-empty-string|null $linkingIdToken
* @param non-empty-string|null $rawNonce
*
* @throws FailedToSignIn
*/
public function signInWithIdpIdToken(Stringable|string $provider, Token|string $idToken, $redirectUrl = null, ?string $linkingIdToken = null, ?string $rawNonce = null): SignInResult;
}

View File

@@ -0,0 +1,63 @@
<?php
declare(strict_types=1);
namespace Kreait\Firebase\Contract;
use Kreait\Firebase\Database\Reference;
use Kreait\Firebase\Database\RuleSet;
use Kreait\Firebase\Database\Transaction;
use Kreait\Firebase\Exception\DatabaseException;
use Kreait\Firebase\Exception\InvalidArgumentException;
use Kreait\Firebase\Exception\OutOfRangeException;
use Psr\Http\Message\UriInterface;
/**
* The Firebase Realtime Database.
*
* @see https://firebase.google.com/docs/reference/rest/database
*/
interface Database
{
public const SERVER_TIMESTAMP = ['.sv' => 'timestamp'];
/**
* Returns a Reference to the root or the specified path.
*
* @throws InvalidArgumentException
*/
public function getReference(?string $path = null): Reference;
/**
* Returns a reference to the root or the path specified in url.
*
* @param string|UriInterface $uri
*
* @throws InvalidArgumentException If the URL is invalid
* @throws OutOfRangeException If the URL is not in the same domain as the current database
*/
public function getReferenceFromUrl($uri): Reference;
/**
* Retrieve Firebase Database Rules.
*
* @see https://firebase.google.com/docs/database/rest/app-management#retrieving-firebase-realtime-database-rules
*
* @throws DatabaseException
*/
public function getRuleSet(): RuleSet;
/**
* Update Firebase Database Rules.
*
* @see https://firebase.google.com/docs/database/rest/app-management#updating-firebase-realtime-database-rules
*
* @throws DatabaseException
*/
public function updateRules(RuleSet $ruleSet): void;
/**
* @param callable(Transaction $transaction):mixed $callable
*/
public function runTransaction(callable $callable): mixed;
}

View File

@@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
namespace Kreait\Firebase\Contract;
use InvalidArgumentException;
use Kreait\Firebase\DynamicLink;
use Kreait\Firebase\DynamicLink\CreateDynamicLink;
use Kreait\Firebase\DynamicLink\CreateDynamicLink\FailedToCreateDynamicLink;
use Kreait\Firebase\DynamicLink\DynamicLinkStatistics;
use Kreait\Firebase\DynamicLink\GetStatisticsForDynamicLink;
use Kreait\Firebase\DynamicLink\ShortenLongDynamicLink;
use Kreait\Firebase\DynamicLink\ShortenLongDynamicLink\FailedToShortenLongDynamicLink;
use Stringable;
/**
* @deprecated 7.14.0 Firebase Dynamic Links is deprecated and should not be used in new projects. The service will
* shut down on August 25, 2025. The component will remain in the SDK until then, but as the
* Firebase service is deprecated, this component is also deprecated
*
* @see https://firebase.google.com/support/dynamic-links-faq Dynamic Links Deprecation FAQ
*
* @see https://firebase.google.com/docs/dynamic-links/rest Create Dynamic Links with the REST API
*
* @phpstan-import-type CreateDynamicLinkShape from CreateDynamicLink
* @phpstan-import-type ShortenLongDynamicLinkShape from ShortenLongDynamicLink
*/
interface DynamicLinks
{
/**
* @param Stringable|non-empty-string|CreateDynamicLink|CreateDynamicLinkShape $url
*
* @throws InvalidArgumentException
* @throws FailedToCreateDynamicLink
*/
public function createUnguessableLink(Stringable|string|CreateDynamicLink|array $url): DynamicLink;
/**
* @param Stringable|non-empty-string|CreateDynamicLink|CreateDynamicLinkShape $url
*
* @throws InvalidArgumentException
* @throws FailedToCreateDynamicLink
*/
public function createShortLink(Stringable|string|CreateDynamicLink|array $url): DynamicLink;
/**
* @param Stringable|non-empty-string|CreateDynamicLink|CreateDynamicLinkShape $actionOrParametersOrUrl
*
* @throws InvalidArgumentException
* @throws FailedToCreateDynamicLink
*/
public function createDynamicLink(Stringable|string|CreateDynamicLink|array $actionOrParametersOrUrl, ?string $suffixType = null): DynamicLink;
/**
* @param Stringable|non-empty-string|ShortenLongDynamicLink|ShortenLongDynamicLinkShape $longDynamicLinkOrAction
*
* @throws InvalidArgumentException
* @throws FailedToShortenLongDynamicLink
*/
public function shortenLongDynamicLink(Stringable|string|ShortenLongDynamicLink|array $longDynamicLinkOrAction, ?string $suffixType = null): DynamicLink;
/**
* @throws InvalidArgumentException
* @throws GetStatisticsForDynamicLink\FailedToGetStatisticsForDynamicLink
*/
public function getStatistics(Stringable|string|GetStatisticsForDynamicLink $dynamicLinkOrAction, ?int $durationInDays = null): DynamicLinkStatistics;
}

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace Kreait\Firebase\Contract;
use Google\Cloud\Firestore\FirestoreClient;
interface Firestore
{
public function database(): FirestoreClient;
}

View File

@@ -0,0 +1,134 @@
<?php
declare(strict_types=1);
namespace Kreait\Firebase\Contract;
use Kreait\Firebase\Exception\FirebaseException;
use Kreait\Firebase\Exception\InvalidArgumentException;
use Kreait\Firebase\Exception\Messaging\InvalidArgument;
use Kreait\Firebase\Exception\Messaging\InvalidMessage;
use Kreait\Firebase\Exception\MessagingException;
use Kreait\Firebase\Messaging\AppInstance;
use Kreait\Firebase\Messaging\Message;
use Kreait\Firebase\Messaging\Messages;
use Kreait\Firebase\Messaging\MulticastSendReport;
use Kreait\Firebase\Messaging\RegistrationToken;
use Kreait\Firebase\Messaging\RegistrationTokens;
use Kreait\Firebase\Messaging\Topic;
/**
* @phpstan-import-type MessageInputShape from Message
*/
interface Messaging
{
/**
* @deprecated 7.5.0
*/
public const BATCH_MESSAGE_LIMIT = 500;
/**
* @param Message|MessageInputShape $message
*
* @throws MessagingException
* @throws FirebaseException
* @throws InvalidArgumentException
*
* @return array<array-key, mixed>
*/
public function send(Message|array $message, bool $validateOnly = false): array;
/**
* @param Message|MessageInputShape $message
* @param RegistrationTokens|RegistrationToken|list<RegistrationToken|string>|non-empty-string $registrationTokens
*
* @throws InvalidArgumentException if the message is invalid or the list of registration tokens is empty
* @throws MessagingException if the API request failed
* @throws FirebaseException if something very unexpected happened (never :))
*/
public function sendMulticast(Message|array $message, RegistrationTokens|RegistrationToken|array|string $registrationTokens, bool $validateOnly = false): MulticastSendReport;
/**
* @param list<Message|MessageInputShape>|Messages $messages
*
* @throws InvalidArgumentException if the message is invalid
* @throws MessagingException if the API request failed
* @throws FirebaseException if something very unexpected happened (never :))
*/
public function sendAll(array|Messages $messages, bool $validateOnly = false): MulticastSendReport;
/**
* @param Message|MessageInputShape $message
*
* @throws InvalidMessage
* @throws MessagingException
* @throws FirebaseException
* @throws InvalidArgumentException
*
* @return array<non-empty-string, mixed>
*/
public function validate(Message|array $message): array;
/**
* @param RegistrationTokens|RegistrationToken|list<RegistrationToken|non-empty-string>|non-empty-string $registrationTokenOrTokens
*
* @throws MessagingException
* @throws FirebaseException
*
* @return array{
* valid: list<non-empty-string>,
* unknown: list<non-empty-string>,
* invalid: list<non-empty-string>
* }
*/
public function validateRegistrationTokens(RegistrationTokens|RegistrationToken|array|string $registrationTokenOrTokens): array;
/**
* @param Topic|non-empty-string $topic
* @param RegistrationTokens|RegistrationToken|list<RegistrationToken|non-empty-string>|non-empty-string $registrationTokenOrTokens
*
* @return array<string, array<string, string>>
*/
public function subscribeToTopic(string|Topic $topic, RegistrationTokens|RegistrationToken|array|string $registrationTokenOrTokens): array;
/**
* @param iterable<non-empty-string|Topic> $topics
* @param RegistrationTokens|RegistrationToken|list<RegistrationToken|non-empty-string>|non-empty-string $registrationTokenOrTokens
*
* @return array<string, array<string, string>>
*/
public function subscribeToTopics(iterable $topics, RegistrationTokens|RegistrationToken|array|string $registrationTokenOrTokens): array;
/**
* @param Topic|non-empty-string $topic
* @param RegistrationTokens|RegistrationToken|list<RegistrationToken|non-empty-string>|non-empty-string $registrationTokenOrTokens
*
* @return array<string, array<string, string>>
*/
public function unsubscribeFromTopic(string|Topic $topic, RegistrationTokens|RegistrationToken|array|string $registrationTokenOrTokens): array;
/**
* @param array<non-empty-string|Topic> $topics
* @param RegistrationTokens|RegistrationToken|list<RegistrationToken|non-empty-string>|non-empty-string $registrationTokenOrTokens
*
* @return array<string, array<string, string>>
*/
public function unsubscribeFromTopics(array $topics, RegistrationTokens|RegistrationToken|array|string $registrationTokenOrTokens): array;
/**
* @param RegistrationTokens|RegistrationToken|list<RegistrationToken|non-empty-string>|non-empty-string $registrationTokenOrTokens
*
* @return array<string, array<string, string>>
*/
public function unsubscribeFromAllTopics(RegistrationTokens|RegistrationToken|array|string $registrationTokenOrTokens): array;
/**
* @see https://developers.google.com/instance-id/reference/server#results
*
* @param RegistrationToken|non-empty-string $registrationToken
*
* @throws InvalidArgument if the registration token is invalid
* @throws MessagingException
*/
public function getAppInstance(RegistrationToken|string $registrationToken): AppInstance;
}

View File

@@ -0,0 +1,81 @@
<?php
declare(strict_types=1);
namespace Kreait\Firebase\Contract;
use Kreait\Firebase\Exception\RemoteConfig\ValidationFailed;
use Kreait\Firebase\Exception\RemoteConfig\VersionNotFound;
use Kreait\Firebase\Exception\RemoteConfigException;
use Kreait\Firebase\RemoteConfig\FindVersions;
use Kreait\Firebase\RemoteConfig\Template;
use Kreait\Firebase\RemoteConfig\Version;
use Kreait\Firebase\RemoteConfig\VersionNumber;
use Traversable;
/**
* The Firebase Remote Config.
*
* @see https://firebase.google.com/docs/remote-config/use-config-rest
* @see https://firebase.google.com/docs/reference/remote-config/rest
*
* @phpstan-import-type RemoteConfigTemplateShape from Template
* @phpstan-import-type FindVersionsShape from FindVersions
*/
interface RemoteConfig
{
/**
* @param Version|VersionNumber|positive-int|non-empty-string $versionNumber
*
* @throws RemoteConfigException if something went wrong
*/
public function get(Version|VersionNumber|int|string|null $versionNumber = null): Template;
/**
* Validates the given template without publishing it.
*
* @param Template|RemoteConfigTemplateShape $template
*
* @throws ValidationFailed if the validation failed
* @throws RemoteConfigException
*/
public function validate($template): void;
/**
* @param Template|RemoteConfigTemplateShape $template
*
* @throws RemoteConfigException
*
* @return non-empty-string The etag value of the published template that can be compared to in later calls
*/
public function publish($template): string;
/**
* Returns a version with the given number.
*
* @param VersionNumber|positive-int|non-empty-string $versionNumber
*
* @throws VersionNotFound
* @throws RemoteConfigException if something went wrong
*/
public function getVersion(VersionNumber|int|string $versionNumber): Version;
/**
* Returns a version with the given number.
*
* @param VersionNumber|positive-int|non-empty-string $versionNumber
*
* @throws VersionNotFound
* @throws RemoteConfigException if something went wrong
*/
public function rollbackToVersion(VersionNumber|int|string $versionNumber): Template;
/**
* @param FindVersions|FindVersionsShape|null $query
*
* @throws RemoteConfigException if something went wrong
*
* @return Traversable<Version>
*/
public function listVersions($query = null): Traversable;
}

View File

@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace Kreait\Firebase\Contract;
use Google\Cloud\Storage\Bucket;
use Google\Cloud\Storage\StorageClient;
interface Storage
{
public function getStorageClient(): StorageClient;
public function getBucket(?string $name = null): Bucket;
}

View File

@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace Kreait\Firebase\Contract\Transitional;
use Kreait\Firebase\Auth\UserRecord;
use Kreait\Firebase\Exception;
use Kreait\Firebase\Exception\Auth\UserNotFound;
use Stringable;
/**
* @TODO: This interface is intended to be integrated into the Auth interface on the next major release.
*/
interface FederatedUserFetcher
{
/**
* @param Stringable|non-empty-string $providerId
* @param Stringable|non-empty-string $providerUid
*
* @throws UserNotFound
* @throws Exception\AuthException
* @throws Exception\FirebaseException
*/
public function getUserByProviderUid(Stringable|string $providerId, Stringable|string $providerUid): UserRecord;
}