mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-09-01 21:00:58 +00:00
* feat(modules): expose host data boundaries * feat(modules): add frontend extension surfaces * refactor(ai): remove assistant from core * chore(ai): prepare the module extraction * fix(modules): load extension styles after the host bundle * chore(modules): lock SDK 3.3.0
58 lines
2.0 KiB
PHP
58 lines
2.0 KiB
PHP
<?php
|
|
|
|
const OFFICIAL_MARKETPLACE_KEY_ID = 'official-modules-2026-01';
|
|
const OFFICIAL_MARKETPLACE_PUBLIC_KEY = 'sIDGuOAaMVzPv9I/GPbWp9ci5aUI5HcM5rZ0tKxW6dc=';
|
|
|
|
test('marketplace configuration advertises module API 1.2 by default', function () {
|
|
expect(marketplaceConfigFor(null)['module_api_version'])->toBe('1.2.0');
|
|
});
|
|
|
|
test('marketplace configuration includes the official signing key by default', function () {
|
|
expect(marketplacePublicKeysConfigFor(null))
|
|
->toBe([OFFICIAL_MARKETPLACE_KEY_ID => OFFICIAL_MARKETPLACE_PUBLIC_KEY]);
|
|
});
|
|
|
|
test('marketplace public-key configuration adds and rotates trusted keys', function () {
|
|
$keys = marketplacePublicKeysConfigFor(json_encode([
|
|
'rotated-modules-2027-01' => 'additional-public-key',
|
|
OFFICIAL_MARKETPLACE_KEY_ID => 'replacement-public-key',
|
|
], JSON_THROW_ON_ERROR));
|
|
|
|
expect($keys)->toBe([
|
|
OFFICIAL_MARKETPLACE_KEY_ID => 'replacement-public-key',
|
|
'rotated-modules-2027-01' => 'additional-public-key',
|
|
]);
|
|
});
|
|
|
|
function marketplacePublicKeysConfigFor(?string $override): array
|
|
{
|
|
return marketplaceConfigFor($override)['public_keys'];
|
|
}
|
|
|
|
function marketplaceConfigFor(?string $override): array
|
|
{
|
|
$previous = getenv('MARKETPLACE_PUBLIC_KEYS');
|
|
|
|
if ($override === null) {
|
|
putenv('MARKETPLACE_PUBLIC_KEYS');
|
|
unset($_ENV['MARKETPLACE_PUBLIC_KEYS'], $_SERVER['MARKETPLACE_PUBLIC_KEYS']);
|
|
} else {
|
|
putenv("MARKETPLACE_PUBLIC_KEYS={$override}");
|
|
$_ENV['MARKETPLACE_PUBLIC_KEYS'] = $override;
|
|
$_SERVER['MARKETPLACE_PUBLIC_KEYS'] = $override;
|
|
}
|
|
|
|
$configuration = require config_path('invoiceshelf.php');
|
|
|
|
if ($previous === false) {
|
|
putenv('MARKETPLACE_PUBLIC_KEYS');
|
|
unset($_ENV['MARKETPLACE_PUBLIC_KEYS'], $_SERVER['MARKETPLACE_PUBLIC_KEYS']);
|
|
} else {
|
|
putenv("MARKETPLACE_PUBLIC_KEYS={$previous}");
|
|
$_ENV['MARKETPLACE_PUBLIC_KEYS'] = $previous;
|
|
$_SERVER['MARKETPLACE_PUBLIC_KEYS'] = $previous;
|
|
}
|
|
|
|
return $configuration['marketplace'];
|
|
}
|