Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions .changeset/wet-moons-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cypherock/sdk-app-manager': patch
---

Fixes device auth issue in multivariant firmware
6 changes: 6 additions & 0 deletions packages/app-manager/src/operations/authDevice/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const verifyChallengeSignature = async (params: {
challenge: Uint8Array;
serial: Uint8Array;
firmwareVersion: string;
firmwareVariant: string;
email?: string;
cysyncVersion?: string;
}) => {
Expand All @@ -70,6 +71,7 @@ const verifyChallengeSignature = async (params: {
challenge,
serial,
firmwareVersion,
firmwareVariant,
email,
cysyncVersion,
} = params;
Expand All @@ -87,6 +89,7 @@ const verifyChallengeSignature = async (params: {
serial,
isTestApp: (await helper.sdk.getDeviceState()) === DeviceState.INITIAL,
firmwareVersion,
firmwareVariant,
email,
cysyncVersion,
},
Expand All @@ -112,8 +115,10 @@ export const authDevice = async (
const info = await getDeviceInfo(sdk);

assertOrThrowInvalidResult(info.firmwareVersion);
assertOrThrowInvalidResult(info.firmwareVariantInfo.variantStr);

const firmwareVersion = `${info.firmwareVersion.major}.${info.firmwareVersion.minor}.${info.firmwareVersion.patch}`;
const firmwareVariant = info.firmwareVariantInfo.variantStr;

const { onStatus, forceStatusUpdate } = createStatusListener({
enums: AuthDeviceStatus,
Expand All @@ -134,6 +139,7 @@ export const authDevice = async (
serial,
challenge,
firmwareVersion,
firmwareVariant,
email,
cysyncVersion,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ const fixtures = {
151, 114, 241, 236, 231, 201, 150, 28, 204,
]),
firmwareVersion: '1.0.0',
firmwareVariant: 'MULTI_COIN',
isTestApp: false,
},
result: true,
Expand All @@ -171,6 +172,7 @@ const fixtures = {
postfix1: undefined,
postfix2: undefined,
firmwareVersion: '1.0.0',
firmwareVariant: 'MULTI_COIN',
isTestApp: false,
},
],
Expand Down Expand Up @@ -206,6 +208,7 @@ const fixtures = {
]),
postfix2: new Uint8Array([12, 28, 106, 169, 138, 41]),
firmwareVersion: '2.4.0',
firmwareVariant: 'MULTI_COIN',
isTestApp: true,
},
result: true,
Expand All @@ -222,6 +225,7 @@ const fixtures = {
postfix1: '80de0982b3a21ae2128c7491',
postfix2: '0c1c6aa98a29',
firmwareVersion: '2.4.0',
firmwareVariant: 'MULTI_COIN',
isTestApp: true,
},
],
Expand Down Expand Up @@ -257,6 +261,7 @@ const fixtures = {
]),
postfix2: new Uint8Array([12, 28, 106, 169, 138, 41]),
firmwareVersion: '1.0.0',
firmwareVariant: 'MULTI_COIN',
isTestApp: false,
},
result: false,
Expand All @@ -273,6 +278,7 @@ const fixtures = {
postfix1: '80de0982b3a21ae2128c7491',
postfix2: '0c1c6aa98a29',
firmwareVersion: '1.0.0',
firmwareVariant: 'MULTI_COIN',
isTestApp: false,
},
],
Expand Down
2 changes: 2 additions & 0 deletions packages/app-manager/src/services/authVerification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const verifyChallengeSignature = async (params: {

challenge: Uint8Array;
firmwareVersion: string;
firmwareVariant: string;
isTestApp?: boolean;
email?: string;
cysyncVersion?: string;
Expand All @@ -53,6 +54,7 @@ export const verifyChallengeSignature = async (params: {

challenge: uint8ArrayToHex(params.challenge),
firmwareVersion: params.firmwareVersion,
firmwareVariant: params.firmwareVariant,
isTestApp: params.isTestApp,
email: params.email,
cysyncVersion: params.cysyncVersion,
Expand Down
7 changes: 6 additions & 1 deletion packages/app-manager/src/services/cardAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ export const verifyCardChallengeSignature = async (params: {
cysyncVersion?: string;
onlyFailure?: boolean;
sessionId?: string;
}) => verifyChallengeSignature({ ...params, firmwareVersion: '0.0.0' });
}) =>
verifyChallengeSignature({
...params,
firmwareVersion: '0.0.0',
firmwareVariant: 'MULTI_COIN',
});
1 change: 1 addition & 0 deletions packages/app-manager/src/services/deviceAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const verifyDeviceChallengeSignature = async (params: {

challenge: Uint8Array;
firmwareVersion: string;
firmwareVariant: string;
isTestApp: boolean;
email?: string;
cysyncVersion?: string;
Expand Down
17 changes: 17 additions & 0 deletions packages/app-manager/tests/04.authDevice/__fixtures__/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import {
deviceAppErrorTypeDetails,
} from '@cypherock/sdk-interfaces';
import { IAuthDeviceTestCase } from './types';
import {
FirmwareVariant,
firmwareVariantToJSON,
} from '../../../src/proto/generated/common';

const withUserRejection: IAuthDeviceTestCase = {
name: 'When user rejects the device auth',
Expand All @@ -29,6 +33,10 @@ const withUserRejection: IAuthDeviceTestCase = {
minor: 0,
patch: 0,
},
firmwareVariantInfo: {
variantId: FirmwareVariant.MULTI_COIN,
variantStr: firmwareVariantToJSON(FirmwareVariant.MULTI_COIN),
},
},
},
};
Expand Down Expand Up @@ -75,6 +83,10 @@ const withSerialSignatureFailure: IAuthDeviceTestCase = {
minor: 0,
patch: 0,
},
firmwareVariantInfo: {
variantId: FirmwareVariant.MULTI_COIN,
variantStr: firmwareVariantToJSON(FirmwareVariant.MULTI_COIN),
},
},
verifySerialSignatureCalls: [
[
Expand Down Expand Up @@ -158,6 +170,10 @@ const withChallengeSignatureFailure: IAuthDeviceTestCase = {
minor: 0,
patch: 0,
},
firmwareVariantInfo: {
variantId: FirmwareVariant.MULTI_COIN,
variantStr: firmwareVariantToJSON(FirmwareVariant.MULTI_COIN),
},
},
challenge: new Uint8Array([
63, 205, 246, 233, 246, 124, 84, 56, 185, 168, 7, 161, 59, 122, 91, 176,
Expand Down Expand Up @@ -200,6 +216,7 @@ const withChallengeSignatureFailure: IAuthDeviceTestCase = {
]),
isTestApp: false,
firmwareVersion: '1.0.0',
firmwareVariant: 'MULTI_COIN',
},
],
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { DeviceAppError } from '@cypherock/sdk-interfaces';
import { IAuthDeviceTestCase } from './types';
import {
FirmwareVariant,
firmwareVariantToJSON,
} from '../../../src/proto/generated/common';

const withInvaidSerialSigData: IAuthDeviceTestCase = {
name: 'Invalid data in serialSig step',
Expand Down Expand Up @@ -48,6 +52,10 @@ const withInvaidSerialSigData: IAuthDeviceTestCase = {
minor: 0,
patch: 0,
},
firmwareVariantInfo: {
variantId: FirmwareVariant.MULTI_COIN,
variantStr: firmwareVariantToJSON(FirmwareVariant.MULTI_COIN),
},
},
challenge: new Uint8Array([
250, 253, 111, 43, 36, 92, 54, 97, 161, 102, 155, 13, 159, 32, 200, 231,
Expand Down Expand Up @@ -102,6 +110,10 @@ const withInvaidSerialSigData2: IAuthDeviceTestCase = {
minor: 0,
patch: 0,
},
firmwareVariantInfo: {
variantId: FirmwareVariant.MULTI_COIN,
variantStr: firmwareVariantToJSON(FirmwareVariant.MULTI_COIN),
},
},
challenge: new Uint8Array([
250, 253, 111, 43, 36, 92, 54, 97, 161, 102, 155, 13, 159, 32, 200, 231,
Expand Down Expand Up @@ -160,6 +172,10 @@ const withInvalidChallengeSigData: IAuthDeviceTestCase = {
minor: 0,
patch: 0,
},
firmwareVariantInfo: {
variantId: FirmwareVariant.MULTI_COIN,
variantStr: firmwareVariantToJSON(FirmwareVariant.MULTI_COIN),
},
},
challenge: new Uint8Array([
250, 253, 111, 43, 36, 92, 54, 97, 161, 102, 155, 13, 159, 32, 200, 231,
Expand Down Expand Up @@ -215,6 +231,10 @@ const withInvalidChallengeSigData2: IAuthDeviceTestCase = {
minor: 0,
patch: 0,
},
firmwareVariantInfo: {
variantId: FirmwareVariant.MULTI_COIN,
variantStr: firmwareVariantToJSON(FirmwareVariant.MULTI_COIN),
},
},
challenge: new Uint8Array([
250, 253, 111, 43, 36, 92, 54, 97, 161, 102, 155, 13, 159, 32, 200, 231,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IGetDeviceInfoResultResponse } from '../../../src';
import { GetDeviceInfoResult } from '../../../src';

export interface IAuthDeviceTestCase {
queries: {
Expand All @@ -16,7 +16,7 @@ export interface IAuthDeviceTestCase {
eventCalls?: number[][];
verifySerialSignatureCalls?: any[][];
verifyChallengeSignatureCalls?: any[][];
deviceInfo: Partial<IGetDeviceInfoResultResponse>;
deviceInfo: Partial<GetDeviceInfoResult>;
};
errorInstance?: any;
errorMessage?: any;
Expand Down
19 changes: 19 additions & 0 deletions packages/app-manager/tests/04.authDevice/__fixtures__/valid.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import {
FirmwareVariant,
firmwareVariantToJSON,
} from '../../../src/proto/generated/common';
import { IAuthDeviceTestCase } from './types';

const withValidData: IAuthDeviceTestCase = {
Expand Down Expand Up @@ -100,6 +104,7 @@ const withValidData: IAuthDeviceTestCase = {
]),
isTestApp: false,
firmwareVersion: '1.0.0',
firmwareVariant: 'MULTI_COIN',
},
],
],
Expand All @@ -110,6 +115,10 @@ const withValidData: IAuthDeviceTestCase = {
minor: 0,
patch: 0,
},
firmwareVariantInfo: {
variantId: FirmwareVariant.MULTI_COIN,
variantStr: firmwareVariantToJSON(FirmwareVariant.MULTI_COIN),
},
},
},
};
Expand Down Expand Up @@ -171,6 +180,10 @@ const withPartiallySkippedStatus: IAuthDeviceTestCase = {
minor: 0,
patch: 0,
},
firmwareVariantInfo: {
variantId: FirmwareVariant.MULTI_COIN,
variantStr: firmwareVariantToJSON(FirmwareVariant.MULTI_COIN),
},
},
challenge: new Uint8Array([
143, 38, 255, 171, 87, 190, 161, 60, 70, 86, 74, 222, 253, 255, 156, 88,
Expand Down Expand Up @@ -213,6 +226,7 @@ const withPartiallySkippedStatus: IAuthDeviceTestCase = {
]),
isTestApp: false,
firmwareVersion: '1.0.0',
firmwareVariant: 'MULTI_COIN',
},
],
],
Expand Down Expand Up @@ -274,6 +288,10 @@ const withSkippedStatuses: IAuthDeviceTestCase = {
minor: 0,
patch: 0,
},
firmwareVariantInfo: {
variantId: FirmwareVariant.MULTI_COIN,
variantStr: firmwareVariantToJSON(FirmwareVariant.MULTI_COIN),
},
},
challenge: new Uint8Array([
63, 205, 246, 233, 246, 124, 84, 56, 185, 168, 7, 161, 59, 122, 91, 176,
Expand Down Expand Up @@ -316,6 +334,7 @@ const withSkippedStatuses: IAuthDeviceTestCase = {
]),
isTestApp: false,
firmwareVersion: '1.0.0',
firmwareVariant: 'MULTI_COIN',
},
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ const withChallengeSignatureFailure: IAuthCardTestCase = {
141, 85, 215, 54, 106,
]),
firmwareVersion: '0.0.0',
firmwareVariant: 'MULTI_COIN',
},
],
],
Expand Down
6 changes: 6 additions & 0 deletions packages/app-manager/tests/05.authCard/__fixtures__/valid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ const withValidData: IAuthCardTestCase = {
107, 113, 214, 188,
]),
firmwareVersion: '0.0.0',
firmwareVariant: 'MULTI_COIN',
},
],
],
Expand Down Expand Up @@ -202,6 +203,7 @@ const withPartiallySkippedStatus: IAuthCardTestCase = {
102, 156, 189, 63,
]),
firmwareVersion: '0.0.0',
firmwareVariant: 'MULTI_COIN',
},
],
],
Expand Down Expand Up @@ -298,6 +300,7 @@ const withSkippedStatuses: IAuthCardTestCase = {
141, 85, 215, 54, 106,
]),
firmwareVersion: '0.0.0',
firmwareVariant: 'MULTI_COIN',
},
],
],
Expand Down Expand Up @@ -405,6 +408,7 @@ const withCardIndex1: IAuthCardTestCase = {
107, 113, 214, 188,
]),
firmwareVersion: '0.0.0',
firmwareVariant: 'MULTI_COIN',
},
],
],
Expand Down Expand Up @@ -512,6 +516,7 @@ const withCardIndex2: IAuthCardTestCase = {
107, 113, 214, 188,
]),
firmwareVersion: '0.0.0',
firmwareVariant: 'MULTI_COIN',
},
],
],
Expand Down Expand Up @@ -619,6 +624,7 @@ const withCardIndex4: IAuthCardTestCase = {
107, 113, 214, 188,
]),
firmwareVersion: '0.0.0',
firmwareVariant: 'MULTI_COIN',
},
],
],
Expand Down
Loading