@@ -54,7 +54,7 @@ async function restClient() {
5454 it ( 'should set user agent based on OS information' , ( ) => {
5555 const telesign = new RestClient ( requestWrapper , customerId , apiKey ) ;
5656
57- expect ( telesign . userAgent ) . toContain ( 'TeleSignSDK/ECMAScript-Node v ' ) ;
57+ expect ( telesign . userAgent ) . toContain ( 'TeleSignSDK/ECMAScript-Node' ) ;
5858 } ) ;
5959
6060 it ( 'should change the attribute restEndpoint' , ( ) => {
@@ -89,7 +89,8 @@ async function restClient() {
8989 it ( 'should set userAgent to the expected value' , ( ) => {
9090 const rc = new RestClient ( requestWrapper , customerId , apiKey ) ;
9191
92- expect ( rc . userAgent ) . toContain ( 'TeleSignSDK/ECMAScript-Node v ' ) ;
92+ expect ( rc . userAgent ) . toContain ( 'TeleSignSDK/ECMAScript-Node' ) ;
93+ expect ( rc . userAgent ) . toContain ( 'OriginatingSDK/node_telesign' ) ;
9394 } ) ;
9495
9596 it ( 'should return default userAgent on error' , ( ) => {
@@ -375,7 +376,9 @@ async function restClient() {
375376 const expectedResponse = { message : 'Successful response' }
376377 var optionsSent = null
377378 const requestWrapper = new FetchRequestWrapperMock ( response , null , expectedResponse , ( options ) => optionsSent = options ) ;
379+
378380 const telesign = new RestClient ( requestWrapper , 'customerId' , 'apiKey' ) ;
381+
379382 const resource = '/test' ;
380383 const params = { key1 : 'value1' , key2 : 'value2' }
381384 const nonce = 'A1592C6F-E384-4CDB-BC42-C3AB970369E9' ;
@@ -388,7 +391,10 @@ async function restClient() {
388391 expect ( optionsSent . headers ) . toHaveProperty ( 'Authorization' , 'TSA customerId:y7PFf4BjQViy9TfeUTQutsQzKm/6T7NrklwOfaOTRKc=' ) ;
389392 expect ( optionsSent . headers ) . toHaveProperty ( 'Content-Type' , '' ) ;
390393 expect ( optionsSent . headers ) . toHaveProperty ( 'Date' , 'Wed, 14 Dec 2016 18:20:12 GMT' ) ;
391- expect ( optionsSent . headers ) . toHaveProperty ( 'User-Agent' , function ( value ) { expect ( value ) . toContain ( 'TeleSignSDK/ECMAScript-Node v 3.0.0' ) } ) ;
394+ expect ( optionsSent . headers ) . toHaveProperty ( 'User-Agent' , function ( value ) {
395+ expect ( value ) . toContain ( 'TeleSignSDK/ECMAScript-Node' )
396+ expect ( value ) . toContain ( 'OriginatingSDK/node_telesign' )
397+ } ) ;
392398 expect ( optionsSent . headers ) . toHaveProperty ( 'x-ts-auth-method' , 'HMAC-SHA256' ) ;
393399 expect ( optionsSent . headers ) . toHaveProperty ( 'x-ts-auth-method' , 'HMAC-SHA256' )
394400 expect ( optionsSent . headers ) . toHaveProperty ( 'x-ts-nonce' , 'A1592C6F-E384-4CDB-BC42-C3AB970369E9' )
@@ -483,7 +489,10 @@ async function restClient() {
483489 expect ( optionsSent . headers ) . toHaveProperty ( 'Authorization' , 'TSA customerId:aQk5d8nanixOKIzrQfzIWjEqvVDxEuMOCoSoiH7Cnsc=' ) ;
484490 expect ( optionsSent . headers ) . toHaveProperty ( 'Content-Type' , 'application/x-www-form-urlencoded' ) ;
485491 expect ( optionsSent . headers ) . toHaveProperty ( 'Date' , 'Wed, 15 Dec 2016 18:20:12 GMT' ) ;
486- expect ( optionsSent . headers ) . toHaveProperty ( 'User-Agent' , function ( value ) { expect ( value ) . toContain ( 'TeleSignSDK/ECMAScript-Node v 3.0.0' ) } ) ;
492+ expect ( optionsSent . headers ) . toHaveProperty ( 'User-Agent' , function ( value ) {
493+ expect ( value ) . toContain ( 'TeleSignSDK/ECMAScript-Node' )
494+ expect ( value ) . toContain ( 'OriginatingSDK/node_telesign' )
495+ } ) ;
487496 expect ( optionsSent . headers ) . toHaveProperty ( 'x-ts-auth-method' , 'HMAC-SHA256' )
488497 expect ( optionsSent . headers ) . toHaveProperty ( 'x-ts-nonce' , 'FD7E3E50-6F1A-4BAF-9A5C-2F11B9A5B654' )
489498 expect ( optionsSent ) . toHaveProperty ( 'method' , 'POST' ) ;
@@ -517,7 +526,10 @@ async function restClient() {
517526 expect ( optionsSent . headers ) . toHaveProperty ( 'Authorization' , 'TSA customerId:5/gV/TLGSxrKPCUsuAwBpu5ZFm/xNAQpPuMe+Jvtt1k=' ) ;
518527 expect ( optionsSent . headers ) . toHaveProperty ( 'Content-Type' , 'application/x-www-form-urlencoded' ) ;
519528 expect ( optionsSent . headers ) . toHaveProperty ( 'Date' , 'Wed, 15 Dec 2016 18:20:12 GMT' ) ;
520- expect ( optionsSent . headers ) . toHaveProperty ( 'User-Agent' , function ( value ) { expect ( value ) . toContain ( 'TeleSignSDK/ECMAScript-Node v 3.0.0' ) } ) ;
529+ expect ( optionsSent . headers ) . toHaveProperty ( 'User-Agent' , function ( value ) {
530+ expect ( value ) . toContain ( 'TeleSignSDK/ECMAScript-Node' )
531+ expect ( value ) . toContain ( 'OriginatingSDK/node_telesign' )
532+ } ) ;
521533 expect ( optionsSent . headers ) . toHaveProperty ( 'x-ts-auth-method' , 'HMAC-SHA256' )
522534 expect ( optionsSent . headers ) . toHaveProperty ( 'x-ts-nonce' , 'FD7E3E50-6F1A-4BAF-9A5C-2F11B9A5B654' )
523535 expect ( optionsSent ) . toHaveProperty ( 'method' , 'PUT' ) ;
@@ -540,6 +552,9 @@ async function restClient() {
540552 'https://rest-api.telesign.com' ,
541553 15000 ,
542554 null ,
555+ 'node_telesign' ,
556+ null ,
557+ null ,
543558 contentType
544559 ) ;
545560 const jsonParams = { key : 'value' } ;
@@ -570,6 +585,9 @@ async function restClient() {
570585 'https://rest-api.telesign.com' ,
571586 15000 ,
572587 null ,
588+ 'node_telesign' ,
589+ null ,
590+ null ,
573591 'application/json'
574592 ) ;
575593 const params = null
@@ -607,7 +625,29 @@ async function restClient() {
607625
608626 expect ( telesign . phoneid . restEndpoint ) . toBe ( "https://rest-api.telesign.com" ) ;
609627 expect ( telesign . phoneid . timeout ) . toBe ( 15000 ) ;
610- expect ( telesign . phoneid . userAgent ) . toContain ( 'TeleSignSDK/ECMAScript-Node v' ) ;
628+ expect ( telesign . phoneid . userAgent ) . toContain ( 'TeleSignSDK/ECMAScript-Node' ) ;
629+ expect ( telesign . phoneid . userAgent ) . toContain ( 'OriginatingSDK/node_telesign' ) ;
630+ } ) ;
631+
632+ test ( 'Use Telesign from FS' , async ( ) => {
633+ const telesign = new TeleSignSDK (
634+ customerId ,
635+ apiKey ,
636+ restEndpoint ,
637+ 15000 ,
638+ null ,
639+ 'node_telesign_enterprise' ,
640+ '1.0.0' ,
641+ '2.0.0'
642+ ) ;
643+
644+ expect ( telesign . rest . restEndpoint ) . toBe ( "https://rest-api.telesign.com" ) ;
645+ expect ( telesign . rest . contentType ) . toBe ( "application/x-www-form-urlencoded" ) ;
646+ expect ( telesign . rest . timeout ) . toBe ( 15000 ) ;
647+ expect ( telesign . rest . userAgent ) . toContain ( 'TeleSignSDK/ECMAScript-Node' ) ;
648+ expect ( telesign . rest . userAgent ) . toContain ( 'OriginatingSDK/node_telesign_enterprise' ) ;
649+ expect ( telesign . rest . userAgent ) . toContain ( 'SDKVersion/1.0.0' ) ;
650+ expect ( telesign . rest . userAgent ) . toContain ( 'DependencySDKVersion/2.0.0' ) ;
611651 } ) ;
612652
613653 // AppVerify test ------------------------
0 commit comments