Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/3.0.0 pre #213

Merged
merged 5 commits into from
Jul 14, 2023
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
60 changes: 30 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion src/id-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ import { mapServerUri, sdkVersionInfo, validatePartnerParams } from './helpers';
import { IdInfo, PartnerParams } from './shared';
import { JOB_TYPE } from './constants';

const validateIdInfo = (idInfo: IdInfo) => {
/**
* Validates the provided id info
* @param {IdInfo} idInfo Contains info needed for the verification job
* @returns {void}
* @throws {Error} - If the id info is invalid.
*/
const validateIdInfo = (idInfo: IdInfo): void => {
if (typeof idInfo !== 'object') {
throw new Error('ID Info needs to be an object');
}
Expand Down Expand Up @@ -60,6 +66,15 @@ export class IDApi {
this.url = mapServerUri(sid_server);
}

/**
* Submit a job to Smile.
* @param {PartnerParams} partner_params - the user_id, job_id, and job_type of the job to submit.
* Can additionally include optional parameters that Smile will return in the
* job status.
* @param {IdInfo} id_info - ID information required to create a job.
* @returns {Promise<object>} A promise that resolves to the job status.
* @throws {Error} If any of the required parameters are missing or if the request fails.
*/
async submit_job(
partner_params: PartnerParams,
id_info: IdInfo,
Expand Down
4 changes: 2 additions & 2 deletions src/signature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const generate_signature = (
partnerID: string,
apiKey: string,
timestamp: string | number,
) => {
): string => {
const isoTimestamp =
typeof timestamp === 'number'
? new Date(timestamp).toISOString()
Expand Down Expand Up @@ -63,7 +63,7 @@ export default class Signature {
};
}

confirm_signature(timestamp: string | number, signature: string) {
confirm_signature(timestamp: string | number, signature: string): boolean {
return (
generate_signature(this.partnerID, this.apiKey, timestamp) === signature
);
Expand Down
2 changes: 1 addition & 1 deletion src/web-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ const hasSelfieImage = ({
}: {
image_type_id: number;
image: string;
}) => [0, 2].includes(image_type_id);
}): boolean => [0, 2].includes(image_type_id);

/**
* Checks to ensure required images for job type 1 are present.
Expand Down