Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion api/dev/states/var.ini
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ configValid="ineligible"
joinStatus="Not joined"
deviceCount="4"
flashGUID="0000-0000-0000-000000000000"
tpmGUID="03-V35H8S0L1QHK1SBG1XHXJNH7"
flashProduct="DataTraveler_3.0"
flashVendor="KINGSTON"
regCheck=""
Expand Down Expand Up @@ -141,4 +142,4 @@ shareSMBCount="1"
shareNFSCount="0"
shareMoverActive="no"
reservedNames="parity,parity2,parity3,diskP,diskQ,diskR,disk,disks,flash,boot,user,user0,disk0,disk1,disk2,disk3,disk4,disk5,disk6,disk7,disk8,disk9,disk10,disk11,disk12,disk13,disk14,disk15,disk16,disk17,disk18,disk19,disk20,disk21,disk22,disk23,disk24,disk25,disk26,disk27,disk28,disk29,disk30,disk31"
csrf_token="0000000000000000"
csrf_token="0000000000000000"
1 change: 1 addition & 0 deletions api/generated-schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ type Vars implements Node {
flashGuid: String
flashProduct: String
flashVendor: String
tpmGuid: String
regCheck: String
regFile: String
regGuid: String
Expand Down
1 change: 1 addition & 0 deletions api/src/__test__/store/modules/emhttp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,7 @@ test('After init returns values from cfg file for all fields', { timeout: 30000
"sysFlashSlots": 1,
"sysModel": "Dell R710",
"timeZone": "Australia/Adelaide",
"tpmGuid": "03-V35H8S0L1QHK1SBG1XHXJNH7",
"useNetbios": "yes",
"useNtp": true,
"useSsh": true,
Expand Down
1 change: 1 addition & 0 deletions api/src/__test__/store/state-parsers/var.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ test('Returns parsed state file', async () => {
"sysFlashSlots": 1,
"sysModel": "Dell R710",
"timeZone": "Australia/Adelaide",
"tpmGuid": "03-V35H8S0L1QHK1SBG1XHXJNH7",
"useNetbios": "yes",
"useNtp": true,
"useSsh": true,
Expand Down
1 change: 1 addition & 0 deletions api/src/core/types/states/var.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export type Var = {
flashGuid: string;
flashProduct: string;
flashVendor: string;
tpmGuid?: string;
/** Current progress of the {@link ?content=mover | mover}. */
fsCopyPrcnt: number;
fsNumMounted: number;
Expand Down
11 changes: 9 additions & 2 deletions api/src/store/services/__test__/state-file-loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import { StateFileKey } from '@app/store/types.js';
const VAR_FIXTURE = readFileSync(new URL('../../../../dev/states/var.ini', import.meta.url), 'utf-8');

const writeVarFixture = (dir: string, safeMode: 'yes' | 'no') => {
const content = VAR_FIXTURE.replace(/safeMode="(yes|no)"/, `safeMode="${safeMode}"`);
const content = VAR_FIXTURE.replace(/safeMode="(yes|no)"/, `safeMode="${safeMode}"`).replace(
/flashGUID="([^"]+)"/,
'flashGUID="$1"\ntpmGUID="03-V35H8S0L1QHK1SBG1XHXJNH7"'
);
writeFileSync(join(dir, `${StateFileKey.var}.ini`), content);
};

Expand Down Expand Up @@ -43,12 +46,16 @@ describe('loadStateFileSync', () => {
const result = loadStateFileSync(StateFileKey.var);

expect(result?.safeMode).toBe(true);
expect(result?.tpmGuid).toBe('03-V35H8S0L1QHK1SBG1XHXJNH7');
expect(dispatchSpy).toHaveBeenCalledWith(
expect.objectContaining({
type: 'emhttp/updateEmhttpState',
payload: {
field: StateFileKey.var,
state: expect.objectContaining({ safeMode: true }),
state: expect.objectContaining({
safeMode: true,
tpmGuid: '03-V35H8S0L1QHK1SBG1XHXJNH7',
}),
},
})
);
Expand Down
1 change: 1 addition & 0 deletions api/src/store/state-parsers/var.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export type VarIni = {
flashGuid: string;
flashProduct: string;
flashVendor: string;
tpmGuid?: string;
fsCopyPrcnt: string;
fsNumMounted: string;
fsNumUnmountable: string;
Expand Down
5 changes: 4 additions & 1 deletion api/src/unraid-api/cli/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ export type BrandingConfig = {
background?: Maybe<Scalars['String']['output']>;
/** Banner image source. Supports local path, remote URL, or data URI/base64. */
bannerImage?: Maybe<Scalars['String']['output']>;
/** Built-in case model value written to case-model.cfg when no custom override is supplied. */
caseModel?: Maybe<Scalars['String']['output']>;
/** Case model image source. Supports local path, remote URL, or data URI/base64. */
caseModelImage?: Maybe<Scalars['String']['output']>;
/** Indicates if a partner logo exists */
Expand Down Expand Up @@ -451,6 +453,7 @@ export type BrandingConfig = {
export type BrandingConfigInput = {
background?: InputMaybe<Scalars['String']['input']>;
bannerImage?: InputMaybe<Scalars['String']['input']>;
caseModel?: InputMaybe<Scalars['String']['input']>;
caseModelImage?: InputMaybe<Scalars['String']['input']>;
hasPartnerLogo?: InputMaybe<Scalars['Boolean']['input']>;
header?: InputMaybe<Scalars['String']['input']>;
Expand Down Expand Up @@ -3548,4 +3551,4 @@ export const GetSsoUsersDocument = {"kind":"Document","definitions":[{"kind":"Op
export const SystemReportDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"SystemReport"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"info"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"machineId"}},{"kind":"Field","name":{"kind":"Name","value":"system"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"manufacturer"}},{"kind":"Field","name":{"kind":"Name","value":"model"}},{"kind":"Field","name":{"kind":"Name","value":"version"}},{"kind":"Field","name":{"kind":"Name","value":"sku"}},{"kind":"Field","name":{"kind":"Name","value":"serial"}},{"kind":"Field","name":{"kind":"Name","value":"uuid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"versions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"core"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"unraid"}},{"kind":"Field","name":{"kind":"Name","value":"kernel"}}]}},{"kind":"Field","name":{"kind":"Name","value":"packages"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"openssl"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"config"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"valid"}},{"kind":"Field","name":{"kind":"Name","value":"error"}}]}},{"kind":"Field","name":{"kind":"Name","value":"server"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]} as unknown as DocumentNode<SystemReportQuery, SystemReportQueryVariables>;
export const ConnectStatusDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"ConnectStatus"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"connect"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"dynamicRemoteAccess"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"enabledType"}},{"kind":"Field","name":{"kind":"Name","value":"runningType"}},{"kind":"Field","name":{"kind":"Name","value":"error"}}]}}]}}]}}]} as unknown as DocumentNode<ConnectStatusQuery, ConnectStatusQueryVariables>;
export const ServicesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Services"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"services"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"online"}},{"kind":"Field","name":{"kind":"Name","value":"uptime"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"timestamp"}}]}},{"kind":"Field","name":{"kind":"Name","value":"version"}}]}}]}}]} as unknown as DocumentNode<ServicesQuery, ServicesQueryVariables>;
export const ValidateOidcSessionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"ValidateOidcSession"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"token"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"validateOidcSession"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"token"},"value":{"kind":"Variable","name":{"kind":"Name","value":"token"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"valid"}},{"kind":"Field","name":{"kind":"Name","value":"username"}}]}}]}}]} as unknown as DocumentNode<ValidateOidcSessionQuery, ValidateOidcSessionQueryVariables>;
export const ValidateOidcSessionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"ValidateOidcSession"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"token"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"validateOidcSession"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"token"},"value":{"kind":"Variable","name":{"kind":"Name","value":"token"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"valid"}},{"kind":"Field","name":{"kind":"Name","value":"username"}}]}}]}}]} as unknown as DocumentNode<ValidateOidcSessionQuery, ValidateOidcSessionQueryVariables>;
3 changes: 3 additions & 0 deletions api/src/unraid-api/graph/resolvers/vars/vars.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ export class Vars extends Node {
@Field({ nullable: true })
flashVendor?: string;

@Field({ nullable: true })
tpmGuid?: string;

@Field({ nullable: true })
regCheck?: string;

Expand Down
32 changes: 32 additions & 0 deletions web/__test__/components/Registration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ vi.mock('~/components/UserProfile/UptimeExpire.vue', () => ({
const initialServerState = {
dateTimeFormat: { date: 'MMM D, YYYY', time: 'h:mm A' },
deviceCount: 0,
flashGuid: '',
guid: '',
keyfile: '',
regGuid: '',
Expand All @@ -133,6 +134,7 @@ const initialServerState = {
state: 'ENOKEYFILE',
stateData: { heading: 'Default Heading', message: 'Default Message' },
stateDataError: false,
tpmGuid: '',
tooManyDevices: false,
};

Expand Down Expand Up @@ -288,6 +290,36 @@ describe('Registration.standalone.vue', () => {
expect(attachedStorageDevicesItem?.props('text')).toBe('8 out of unlimited devices');
});

it('shows TPM transfer guidance when TPM licensing is available', async () => {
serverStore.state = 'PRO';
serverStore.guid = '058F-6387-0000-0000F1F1E1C6';
serverStore.flashGuid = '058F-6387-0000-0000F1F1E1C6';
serverStore.tpmGuid = '03-V35H8S0L1QHK1SBG1XHXJNH7';
serverStore.keyfile = 'keyfile-present';

await wrapper.vm.$nextTick();

const transferNotice = wrapper.find('[data-testid="tpm-transfer-available"]');

expect(transferNotice.exists()).toBe(true);
expect(transferNotice.text()).toContain('TPM licensing is available on this server.');
expect(transferNotice.text()).toContain('Stop the array.');
expect(transferNotice.text()).toContain('Remove the USB flash boot device.');
expect(transferNotice.text()).toContain('Start the array.');
});

it('does not show TPM transfer guidance for trial states', async () => {
serverStore.state = 'TRIAL';
serverStore.guid = '058F-6387-0000-0000F1F1E1C6';
serverStore.flashGuid = '058F-6387-0000-0000F1F1E1C6';
serverStore.tpmGuid = '03-V35H8S0L1QHK1SBG1XHXJNH7';
serverStore.keyfile = 'keyfile-present';

await wrapper.vm.$nextTick();

expect(wrapper.find('[data-testid="tpm-transfer-available"]').exists()).toBe(false);
});

it('adds Activate Trial fallback for ENOKEYFILE partner activation', async () => {
activationCodeStateHolder.current!.value = {
code: 'PARTNER-CODE-123',
Expand Down
2 changes: 2 additions & 0 deletions web/_webGui/testWebComponents.page
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ $serverData = [
"flashProduct" => $var['flashProduct'],
"flashVendor" => $var['flashVendor'],
"flashBackupActivated" => empty($flashbackup_status['activated']) ? '' : 'true',
"flashGuid" => $var['flashGUID'],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add a fallback for flashGuid to avoid undefined-index notices.

Line [93] directly reads $var['flashGUID'] without guarding. If the key is absent, PHP notices can leak into this test page output.

Suggested fix
-  "flashGuid" => $var['flashGUID'],
+  "flashGuid" => $var['flashGUID'] ?? '',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"flashGuid" => $var['flashGUID'],
"flashGuid" => $var['flashGUID'] ?? '',
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/_webGui/testWebComponents.page` at line 93, The mapping for "flashGuid"
reads $var['flashGUID'] directly and can emit undefined-index notices; change
the right-hand side to use a guarded fallback (e.g. use isset($var['flashGUID'])
? $var['flashGUID'] : '' or the null-coalescing operator $var['flashGUID'] ??
'') so "flashGuid" always gets a defined value when $var lacks 'flashGUID'.

"guid" => $var['flashGUID'],
"hasRemoteApikey" => !empty($myservers['remote']['apikey']),
"lanIp" => ipaddr(),
Expand All @@ -113,6 +114,7 @@ $serverData = [
"registeredTime" => $myservers['remote']['regWizTime'] ?? '',
"site" => $_SERVER['REQUEST_SCHEME']."://".$_SERVER['HTTP_HOST'],
"state" => strtoupper(empty($var['regCheck']) ? $var['regTy'] : $var['regCheck']),
"tpmGuid" => $var['tpmGUID'] ?? '',
"textColor" => ($header) ? '#'.$header : '',
"theme" => $display['theme'],
"ts" => time(),
Expand Down
3 changes: 3 additions & 0 deletions web/src/_data/serverState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import type {

const state: ServerState = 'BASIC' as ServerState;
const currentFlashGuid = '1111-1111-YIJD-ZACK1234TEST'; // this is the flash drive that's been booted from
const currentTpmGuid = '03-V35H8S0L1QHK1SBG1XHXJNH7';
const regGuid = '1111-1111-YIJD-ZACK1234TEST'; // this guid is registered in key server
const keyfileBase64 = '';

Expand Down Expand Up @@ -147,6 +148,7 @@ const baseServerState: Server = {
deviceCount: 3,
expireTime,
flashBackupActivated: !!connectPluginInstalled,
flashGuid: currentFlashGuid,
flashProduct: 'SanDisk_3.2Gen1',
flashVendor: 'USB',
guid: currentFlashGuid,
Expand Down Expand Up @@ -181,6 +183,7 @@ const baseServerState: Server = {
name: 'white',
textColor: '',
},
tpmGuid: currentTpmGuid,
// updateOsResponse: {
// version: '6.12.6',
// name: 'Unraid 6.12.6',
Expand Down
32 changes: 32 additions & 0 deletions web/src/components/Registration.standalone.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const {
bootDeviceType,
dateTimeFormat,
deviceCount,
flashGuid,
flashProduct,
flashVendor,
guid,
Expand All @@ -63,6 +64,7 @@ const {
state,
stateData,
stateDataError,
tpmGuid,
tooManyDevices,
} = storeToRefs(serverStore);

Expand Down Expand Up @@ -132,6 +134,18 @@ const showPartnerActivationCode = computed(() => {
(currentState === 'ENOKEYFILE' || currentState === 'TRIAL' || currentState === 'EEXPIRED')
);
});
const showTpmTransferInfo = computed((): boolean =>
Boolean(
keyInstalled.value &&
!showTrialExpiration.value &&
bootDeviceType.value === 'flash' &&
// On TPM systems, flashGuid may fall back to the TPM GUID, so only show
// this while we're still booted from flash and the GUIDs differ.
flashGuid.value &&
tpmGuid.value &&
flashGuid.value !== tpmGuid.value
Comment on lines +139 to +146

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Gate TPM transfer notice to non-trial license states

This condition allows the TPM transfer guidance to render for TRIAL/EEXPIRED servers whenever both GUIDs are present, because keyInstalled only excludes ENOKEYFILE. In those states there is no transferable paid key, so the UI can instruct users to "move this license" when no such transfer is valid. Since showTrialExpiration is already used elsewhere to suppress transfer actions, this notice should be similarly gated to avoid misleading trial/expired users.

Useful? React with 👍 / 👎.

)
);

// Organize items into three sections
const bootDeviceItems = computed((): RegistrationItemProps[] => {
Expand Down Expand Up @@ -384,6 +398,24 @@ const actionItems = computed((): RegistrationItemProps[] => {
class="rounded-lg border border-gray-200 p-4 dark:border-gray-700"
>
<h4 class="mb-3 text-lg font-semibold">{{ t('registration.actions') }}</h4>
<blockquote
v-if="showTpmTransferInfo"
data-testid="tpm-transfer-available"
class="border-primary bg-primary/10 mb-4 border-l-4 p-4"
>
<p class="text-highlighted text-sm leading-relaxed font-medium">
{{ t('registration.tpmTransferAvailable') }}
</p>
<p class="text-highlighted mt-2 text-sm leading-relaxed">
{{ t('registration.tpmTransferAvailableDescription') }}
</p>
<ol class="text-highlighted mt-3 list-decimal space-y-1 pl-5 text-sm leading-relaxed">
<li>{{ t('registration.tpmTransferAvailableSteps.stopArray') }}</li>
<li>{{ t('registration.tpmTransferAvailableSteps.removeFlash') }}</li>
<li>{{ t('registration.tpmTransferAvailableSteps.transferOnRegistrationPage') }}</li>
<li>{{ t('registration.tpmTransferAvailableSteps.startArray') }}</li>
</ol>
</blockquote>
<blockquote
v-if="showPartnerActivationCode"
class="border-primary bg-primary/10 mb-4 border-l-4 p-4"
Expand Down
Loading
Loading