-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
labeler Update Labeler.php Update LabelerServer.php Update HttpServer.php Update HttpServer.php Update AbstractLabeler.php Update AtpClient.php Update HasShortHand.php Update HasShortHand.php wip Update AtBytesObject.php wip wip Update LabelerServer.php wip Update LabelerServer.php Create HttpServer.php Update ArtisanLabeler.php Update LabelDefinition.php wip Update HasShortHand.php Update HasShortHand.php Update AtpClient.php wip Update UnsignedLabel.php Update UnsignedLabel.php wip Update LabelerServer.php Update LabelerServer.php Update LabelerServer.php Update LabelerServer.php Update LabelerServer.php Update DidDocument.php Update LabelerServer.php Update LabelerServer.php Update LabelerServer.php Update SignedLabel.php Update SignedLabel.php wip Update AbstractLabeler.php wip wip wip labeler labeler Update LabelerServer.php wip wip Create LabelerTest.php Update Encoder.php Update LabelerServer.php Update LabelerServer.php Update LabelerServer.php Update LabelerServer.php Update Labeler.php Update Labeler.php Update LabelerServer.php Create AtBytes.php Update BytesWrapper.php Update LabelerServer.php Update LabelerController.php Update LabelerServer.php Update Labeler.php Update Labeler.php Update LabelerServer.php Update BytesWrapper.php Update LabelerServer.php Update EmitEventResponse.php Update LabelerServer.php Update LabelerServer.php Update Labeler.php Update HasShortHand.php Update LabelerServer.php Update HasShortHand.php Update LabelerServer.php Update Labeler.php Update LabelerServer.php Update LabelerServer.php Update LabelerServer.php Update LabelerServer.php Update LabelerServer.php Update HasShortHand.php Update HasShortHand.php Update EmitEventResponse.php Update HasShortHand.php Update HasShortHand.php Update HasShortHand.php Update LabelerServer.php Update LabelerServer.php LabelerServer Update HasShortHand.php Update AbstractLabeler.php Update console.php Update SignedLabel.php Update Labeler.php
- Loading branch information
Showing
33 changed files
with
929 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Revolution\Bluesky\Casts; | ||
|
||
use Illuminate\Contracts\Database\Eloquent\CastsAttributes; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Revolution\Bluesky\Core\CBOR\AtBytes; | ||
|
||
class AtBytesObject implements CastsAttributes | ||
{ | ||
/** | ||
* Cast the given value. | ||
* | ||
* @param array<string, mixed> $attributes | ||
*/ | ||
public function get(Model $model, string $key, mixed $value, array $attributes): AtBytes | ||
{ | ||
return new AtBytes($value); | ||
} | ||
|
||
/** | ||
* Prepare the given value for storage. | ||
* | ||
* @param array<string, mixed> $attributes | ||
*/ | ||
public function set(Model $model, string $key, mixed $value, array $attributes): string | ||
{ | ||
return $value instanceof AtBytes ? $value->toBytes() : $value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Revolution\Bluesky\Console\Labeler; | ||
|
||
use Illuminate\Console\Command; | ||
use Revolution\Bluesky\Labeler\Server\LabelerServer; | ||
use Workerman\Worker; | ||
|
||
/** | ||
* ``` | ||
* php artisan bluesky:labeler:server start | ||
* ``` | ||
*/ | ||
class LabelerServeCommand extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'bluesky:labeler:server {cmd} {--H|host=127.0.0.1} {--P|port=7000} {--d|daemon=}'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Labeler WebSocket server'; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return int | ||
*/ | ||
public function handle(LabelerServer $server): int | ||
{ | ||
if (! class_exists(Worker::class)) { | ||
$this->error('Please install workerman/workerman'); | ||
|
||
return 1; | ||
} | ||
|
||
$host = (string) $this->option('host'); | ||
$port = (int) $this->option('port'); | ||
|
||
$server->start($host, $port); | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Revolution\Bluesky\Core\CBOR; | ||
|
||
use Illuminate\Contracts\Support\Arrayable; | ||
use Illuminate\Contracts\Support\Jsonable; | ||
|
||
/** | ||
* @link https://github.com/mary-ext/atcute/blob/trunk/packages/utilities/cbor/lib/bytes.ts | ||
*/ | ||
final readonly class AtBytes implements Arrayable, Jsonable | ||
{ | ||
public function __construct(protected string $bytes) | ||
{ | ||
} | ||
|
||
/** | ||
* ``` | ||
* $bytes = AtBytes::fromArray(['$bytes' => 'base64'])->toBytes(); | ||
* ``` | ||
*/ | ||
public static function fromArray(array $array): self | ||
{ | ||
return new self(base64_decode($array['$bytes'])); | ||
} | ||
|
||
public function toBytes(): string | ||
{ | ||
return $this->bytes; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return ['$bytes' => $this->encode()]; | ||
} | ||
|
||
public function toJson($options = 0): string | ||
{ | ||
return json_encode($this->toArray(), $options); | ||
} | ||
|
||
protected function encode(): string | ||
{ | ||
return base64_encode($this->bytes); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.