Skip to content

Commit

Permalink
SDK-2470 add brand_id to IDV SDK config (#487)
Browse files Browse the repository at this point in the history
Update idv_service to expose a `withBrandId` in the SDK config builder. (#487)
  • Loading branch information
laurent-yoti committed Aug 9, 2024
1 parent 0b29021 commit cd9570c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
16 changes: 15 additions & 1 deletion src/idv_service/session/create/sdk.config.builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,19 @@ class SdkConfigBuilder {
);
}

/**
* Sets the brandID on the builder
*
* @param {string} brandId
*
* @returns {this}
*/
withBrandId(brandId) {
Validation.isString(brandId, 'brandId');
this.brandId = brandId;
return this;
}

/**
* Builds the {@link SdkConfig} using the values supplied to the builder
*
Expand All @@ -269,7 +282,8 @@ class SdkConfigBuilder {
this.privacyPolicyUrl,
this.biometricConsentFlow,
this.allowHandoff,
this.attemptsConfiguration
this.attemptsConfiguration,
this.brandId
);
}
}
Expand Down
10 changes: 9 additions & 1 deletion src/idv_service/session/create/sdk.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class SdkConfig {
* Allows user to handoff to mobile during session
* @param {object} attemptsConfiguration
* The attempts configuration
* @param {string} brandId
* The brandID for the client
*/
constructor(
allowedCaptureMethods,
Expand All @@ -41,7 +43,8 @@ class SdkConfig {
privacyPolicyUrl,
biometricConsentFlow,
allowHandoff,
attemptsConfiguration
attemptsConfiguration,
brandId
) {
Validation.isString(allowedCaptureMethods, 'allowedCaptureMethods', true);
/** @private */
Expand Down Expand Up @@ -92,6 +95,10 @@ class SdkConfig {
/** @private */
this.attemptsConfiguration = attemptsConfiguration;
}

Validation.isString(brandId, 'brandId', true);
/** @private */
this.brandId = brandId;
}

/**
Expand All @@ -111,6 +118,7 @@ class SdkConfig {
biometric_consent_flow: this.biometricConsentFlow,
allow_handoff: this.allowHandoff,
attempts_configuration: this.attemptsConfiguration,
brand_id: this.brandId,
};
}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/idv_service/session/create/sdk.config.builder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('SdkConfigBuilder', () => {
.withPrivacyPolicyUrl('some-privacy-policy-url')
.withBiometricConsentFlow('some-flow')
.withAllowHandoff(true)
.withBrandId('some-brand-identifier')
.build();

const expectedJson = JSON.stringify({
Expand All @@ -30,6 +31,7 @@ describe('SdkConfigBuilder', () => {
privacy_policy_url: 'some-privacy-policy-url',
biometric_consent_flow: 'some-flow',
allow_handoff: true,
brand_id: 'some-brand-identifier',
});

expect(JSON.stringify(sdkConfig)).toBe(expectedJson);
Expand Down
9 changes: 9 additions & 0 deletions types/src/idv_service/session/create/sdk.config.builder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ declare class SdkConfigBuilder {
* @returns {this}
*/
withIdDocumentTextExtractionGenericRetries(retries: number): this;
/**
* Sets the brandID on the builder
*
* @param {string} brandId
*
* @returns {this}
*/
withBrandId(brandId: string): this;
brandId: string;
/**
* Builds the {@link SdkConfig} using the values supplied to the builder
*
Expand Down
7 changes: 6 additions & 1 deletion types/src/idv_service/session/create/sdk.config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ declare class SdkConfig {
* Allows user to handoff to mobile during session
* @param {object} attemptsConfiguration
* The attempts configuration
* @param {string} brandId
* The brandID for the client
*/
constructor(allowedCaptureMethods: string, primaryColour: string, secondaryColour: string, fontColour: string, locale: string, presetIssuingCountry: string, successUrl: string, errorUrl: string, privacyPolicyUrl: string, biometricConsentFlow: string, allowHandoff: boolean, attemptsConfiguration: object);
constructor(allowedCaptureMethods: string, primaryColour: string, secondaryColour: string, fontColour: string, locale: string, presetIssuingCountry: string, successUrl: string, errorUrl: string, privacyPolicyUrl: string, biometricConsentFlow: string, allowHandoff: boolean, attemptsConfiguration: object, brandId: string);
/** @private */
private allowedCaptureMethods;
/** @private */
Expand All @@ -51,6 +53,8 @@ declare class SdkConfig {
private allowHandoff;
/** @private */
private attemptsConfiguration;
/** @private */
private brandId;
/**
* Returns serialized data for JSON.stringify()
*/
Expand All @@ -67,5 +71,6 @@ declare class SdkConfig {
biometric_consent_flow: string;
allow_handoff: boolean;
attempts_configuration: any;
brand_id: string;
};
}

0 comments on commit cd9570c

Please sign in to comment.