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
1 change: 1 addition & 0 deletions packages/sdk-client/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './api';
export * from './client';
export * from './domain';
export * from './model';
export * from './plugins';
export * from './utils';
1 change: 1 addition & 0 deletions packages/sdk-client/src/model/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type { WithAdditionalProperties } from './withAdditionalProperties';
3 changes: 3 additions & 0 deletions packages/sdk-client/src/model/withAdditionalProperties.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface WithAdditionalProperties {
[key: string]: any;
}
3 changes: 3 additions & 0 deletions packages/verification/src/models/v1/enums.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export type ActionEnum = 'allow' | 'deny';

/** Selects type of code which will be sent to customer */
export type CodeType = 'Numeric' | 'Alpha' | 'Alphanumeric' | string;

export type VerificationStatusEnum = 'PENDING'
| 'SUCCESSFUL'
| 'FAIL'
Expand Down
30 changes: 20 additions & 10 deletions packages/verification/src/models/v1/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ export const startVerificationHelper = {
* @param {string} phoneNumber - The phone number to which the verification call should be made.
* @param {string} [reference] - An optional reference identifier used to pass your own reference in the request for tracking purposes.
* @param {string} [locale] - An optional language-region identifier to use for the verification call.
* @param {Record<string, unknown>} [additionalOptions] - An optional object for any additional phone call options.
* @return {StartPhoneCallVerificationRequestData} The request data object for initiating the phone call verification.
*/
buildPhoneCallRequest: (
phoneNumber: string,
reference?: string,
locale?: string,
additionalOptions?: Record<string, unknown>,
): StartPhoneCallVerificationRequestData => {
return {
startVerificationWithPhoneCallRequestBody: {
Expand All @@ -65,13 +67,14 @@ export const startVerificationHelper = {
endpoint: phoneNumber,
},
reference,
...(locale !== undefined) ? {
...(locale !== undefined || additionalOptions !== undefined ? {
phoneCallOptions: {
speech: {
locale,
},
...(locale !== undefined ? {
speech: { locale },
} : {}),
...(additionalOptions ?? {}),
},
} : {},
} : {}),
},
};
},
Expand All @@ -96,13 +99,13 @@ export const startVerificationHelper = {
endpoint: phoneNumber,
},
reference,
...(locale !== undefined) ? {
...(locale !== undefined ? {
calloutOptions: {
speech: {
locale,
},
},
} : {},
} : {}),
},
};
},
Expand All @@ -112,12 +115,17 @@ export const startVerificationHelper = {
* @param {string} phoneNumber - The phone number to which the flash call verification should be made.
* @param {string} [reference] - An optional reference identifier used to pass your own reference in the request for tracking purposes.
* @param {number} [dialTimeout] - An optional timeout value in seconds for how long to wait for the flash call to be answered.
* @param {number} [interceptionTimeout] - An optional timeout value in seconds for the maximum time that a phone call verification will be active and can be completed. If the phone number hasn't been verified successfully during this time, then the verification request will fail. By default, the Sinch dashboard will automatically optimize dial time out during a phone call.
* @param {Record<string, unknown>} [additionalOptions] - An optional object for any additional flash call options.
* @return {StartFlashCallVerificationRequestData} The request data object for initiating the flash call verification.
* TODO V2: limit the number of parameters by introducing a FlashCallOptions object
*/
buildFlashCallRequest: (
phoneNumber: string,
reference?: string,
dialTimeout?: number,
interceptionTimeout?: number,
additionalOptions?: Record<string, unknown>,
): StartFlashCallVerificationRequestData => {
return {
startVerificationWithFlashCallRequestBody: {
Expand All @@ -126,11 +134,13 @@ export const startVerificationHelper = {
endpoint: phoneNumber,
},
reference,
...(dialTimeout !== undefined) ? {
...(dialTimeout !== undefined || interceptionTimeout !== undefined || additionalOptions !== undefined ? {
flashCallOptions: {
dialTimeout,
...(dialTimeout !== undefined ? { dialTimeout } : {}),
...(interceptionTimeout !== undefined ? { interceptionTimeout } : {}),
...(additionalOptions ?? {}),
},
} : {},
} : {}),
},
};
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ActionEnum } from '../../enums';
import { WithAdditionalProperties } from '@sinch/sdk-client';

export interface FlashCallRequestEventResponse {
/** Determines whether the verification can be executed. */
Expand All @@ -10,9 +11,11 @@ export interface FlashCallRequestEventResponse {
/** @deprecated Use FlashCallProperties instead */
export type FlashCallContent = FlashCallProperties;

export interface FlashCallProperties {
/** The phone number that will be displayed to the user when the flashcall is received on the user\'s phone. By default, the Sinch dashboard will randomly select the CLI that will be displayed during a flashcall from a pool of numbers. If you want to set your own CLI, you can specify it in the response to the Verification Request Event. */
export interface FlashCallProperties extends WithAdditionalProperties {
/** The phone number that will be displayed to the user when the flash call is received on the user's phone. By default, the Sinch dashboard will randomly select the CLI that will be displayed during a phone call from a pool of numbers. If you want to set your own CLI, you can specify it in the response to the Verification Request Event. */
cli?: string;
/** The maximum time that a flashcall verification will be active and can be completed. If the phone number hasn\'t been verified successfully during this time, then the verification request will fail. By default, the Sinch dashboard will automatically optimize dial time out during a flashcall. If you want to set your own dial time out for the flashcall, you can specify it in the response to the Verification Request Event. */
/** The amount of time that a phone will ring. */
dialTimeout?: number;
/** The maximum time that a phone call verification will be active and can be completed. If the phone number hasn't been verified successfully during this time, then the verification request will fail. By default, the Sinch dashboard will automatically optimize dial time out during a phone call. */
interceptionTimeout?: number;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ActionEnum } from '../../enums';
import { WithAdditionalProperties } from '@sinch/sdk-client';

/** @deprecated Use PhoneCallRequestEventResponse instead */
export type CalloutRequestEventResponse = PhoneCallRequestEventResponse;
Expand All @@ -13,7 +14,7 @@ export interface PhoneCallRequestEventResponse {
/** @deprecated Use PhoneCallProperties instead */
export type CalloutProperties = PhoneCallProperties;

export interface PhoneCallProperties {
export interface PhoneCallProperties extends WithAdditionalProperties {
/** The Phone Call PIN that should be entered by the user. Sinch servers automatically generate PIN codes for Phone Call verification. If you want to set your own code, you can specify it in the response to the Verification Request Event. */
code?: string;
/** @see SpeechProperties */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ActionEnum } from '../../enums';
import { ActionEnum, CodeType } from '../../enums';
import { WithAdditionalProperties } from '@sinch/sdk-client';

export interface SmsRequestEventResponse {
/** Determines whether the verification can be executed. */
Expand All @@ -7,11 +8,15 @@ export interface SmsRequestEventResponse {
sms?: SmsProperties;
}

export interface SmsProperties {
export interface SmsProperties extends WithAdditionalProperties {
/** The SMS OTP that should be used. By default, the Sinch dashboard will automatically generate OTP codes for SMS verification. If you want to set your own OTP, you can specify it in the response to the Verification Request Event. */
code?: string;
/** List of strings */
acceptLanguage?: string[];
/** Accepted values for the type of code to be generated are `Numeric`, `Alpha`, and `Alphanumeric`. Default is `Numeric`. */
codeType?: CodeType;
/** The expiration time for a verification process is represented in the format `HH:MM:SS`. */
expiry?: string;
}

/** @deprecated Use SmsRequestEventResponse instead */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SmsRequestEventResponse } from '../sms-request-event-response';
import { FlashCallRequestEventResponse } from '../flashcall-request-event-response';
import { CalloutRequestEventResponse } from '../phonecall-request-event-response';
import { PhoneCallRequestEventResponse } from '../phonecall-request-event-response';

export type VerificationRequestEventResponse = SmsRequestEventResponse
| FlashCallRequestEventResponse
| CalloutRequestEventResponse;
| PhoneCallRequestEventResponse;
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { LinksObject } from '../links-object';
import { WithAdditionalProperties } from '@sinch/sdk-client';

export interface StartFlashCallVerificationResponse {

Expand All @@ -12,14 +13,14 @@ export interface StartFlashCallVerificationResponse {
_links?: LinksObject[];
}

interface FlashCallContent {
interface FlashCallContent extends WithAdditionalProperties {

/** Filter that should be applied for incoming calls to intercept the Flashcall. */
/** Filter that should be applied for incoming calls to intercept the flash call. */
cliFilter: string;
/** Amount of seconds client should wait for the Flashcall. */
/** Amount of seconds client should wait for the flash call. */
interceptionTimeout: number;
/** The time in seconds allowed for reporting the code after which the verification will expire. */
reportTimeout?: number;
/** Used by the SDKs, this setting makes the handset deny the flashcall after the set time in seconds. */
/** Used by the mobile SDKs, this setting makes the handset deny the flash call after the set time in seconds. */
denyCallAfter?: number;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { LinksObject } from '../links-object';
import { WithAdditionalProperties } from '@sinch/sdk-client';
import { CodeType } from '../enums';

export interface StartSmsVerificationResponse {

Expand All @@ -12,10 +14,12 @@ export interface StartSmsVerificationResponse {
_links?: LinksObject[];
}

interface SmsContent {
interface SmsContent extends WithAdditionalProperties {

/** The expected template for the SMS response. */
template?: string;
/** The amount of time in seconds that the client should wait for the SMS. */
interceptionTimeout?: number;
/** Accepted values for the type of code to be generated are `Numeric`, `Alpha`, and `Alphanumeric`. Default is `Numeric`. */
codeType?: CodeType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export type {
StartDataVerification,
StartSeamlessVerification,
SmsOptions,
CodeType,
PhoneCallOptions,
CalloutOptions,
PhoneCallOptionsSpeech,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Identity } from '../identity';
import { WithAdditionalProperties } from '@sinch/sdk-client';
import { CodeType } from '../enums';

export interface StartVerificationWithSms extends StartVerificationBase {
/** @see SmsOptions */
Expand Down Expand Up @@ -43,7 +45,7 @@ export interface StartVerificationBase {
/**
* An optional object for SMS Verification, with default values assumed for all contained values if not provided.
*/
export interface SmsOptions {
export interface SmsOptions extends WithAdditionalProperties {
/** The expiration time for a verification process is represented in the format `HH:MM:SS`. */
expiry?: Date | string;
/** Accepted values for the type of code to be generated are `Numeric`, `Alpha`, and `Alphanumeric`. Default is `Numeric`. */
Expand All @@ -54,14 +56,14 @@ export interface SmsOptions {
locale?: string;
}

export type CodeType = 'Numeric' | 'Alpha' | 'Alphanumeric';

/**
* An optional object for Flash Call Verification, considered only when the verification request originates from your backend (not an SDK client) via an [Application signed request](https://developers.sinch.com/docs/voice/api-reference/authentication/signed-request).
* An optional configuration for Flash Call Verification, should be used only when the verification request originates from your backend (not an end user device) and request is signed via an [Application signed request](https://developers.sinch.com/docs/voice/api-reference/authentication/signed-request).
*/
export interface FlashCallOptions {
/** The dial timeout in seconds. */
export interface FlashCallOptions extends WithAdditionalProperties {
/** The amount of time that a phone will ring. */
dialTimeout?: number;
/** The maximum time that a phone call verification will be active and can be completed. If the phone number hasn't been verified successfully during this time, then the verification request will fail. By default, the Sinch dashboard will automatically optimize dial time out during a phone call. */
interceptionTimeout?: number;
}

/** @deprecated Use PhoneCallOptions instead */
Expand All @@ -70,7 +72,7 @@ export type CalloutOptions = PhoneCallOptions;
/**
* An optional object for Phone Call Verification, with default values assumed for all contained values if not provided.
*/
export interface PhoneCallOptions {
export interface PhoneCallOptions extends WithAdditionalProperties {
/** @see PhoneCallOptionsSpeech */
speech?: PhoneCallOptionsSpeech;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface SmsVerificationReportRequest {
interface SmsContent {
/** The code which was received by the user submitting the SMS verification. */
code: string;
/** The sender ID of the SMS. */
/** @deprecated The sender ID of the SMS. */
cli?: string;
}

Expand Down
Loading
Loading