@sinch/verification 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -12
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -36,19 +36,24 @@ The `Verification` API uses the Application Signed Request to authenticate again
|
|
|
36
36
|
If you are using this SDK as part of the Sinch SDK (`@sinch/sdk-core`) you can access it as the `verification` property of the client that you would have instantiated.
|
|
37
37
|
|
|
38
38
|
```typescript
|
|
39
|
-
import {
|
|
39
|
+
import {
|
|
40
40
|
InitiateVerificationResponse,
|
|
41
41
|
StartVerificationRequestData,
|
|
42
42
|
SinchClient,
|
|
43
|
-
ApplicationCredentials,
|
|
43
|
+
ApplicationCredentials,
|
|
44
|
+
VerificationService,
|
|
44
45
|
} from '@sinch/sdk-core';
|
|
45
46
|
|
|
46
47
|
const credentials: ApplicationCredentials = {
|
|
47
48
|
applicationKey: 'APPLICATION_ID',
|
|
48
49
|
applicationSecret: 'APPLICATION_SECRET',
|
|
49
50
|
};
|
|
51
|
+
|
|
52
|
+
// Access the 'verification' service registered on the Sinch Client
|
|
50
53
|
const sinch = new SinchClient(credentials);
|
|
54
|
+
const verificationService: VerificationService = sinch.verification;
|
|
51
55
|
|
|
56
|
+
// Build the request data
|
|
52
57
|
const requestData: StartVerificationRequestData = {
|
|
53
58
|
initiateVerificationRequestBody: {
|
|
54
59
|
identity: {
|
|
@@ -59,9 +64,9 @@ const requestData: StartVerificationRequestData = {
|
|
|
59
64
|
},
|
|
60
65
|
};
|
|
61
66
|
|
|
62
|
-
//
|
|
63
|
-
const verificationInitResponse: InitiateVerificationResponse
|
|
64
|
-
|
|
67
|
+
// Use the 'verification' service registered on the Sinch client
|
|
68
|
+
const verificationInitResponse: InitiateVerificationResponse
|
|
69
|
+
= await verificationService.verifications.start(requestData);
|
|
65
70
|
```
|
|
66
71
|
|
|
67
72
|
### Standalone
|
|
@@ -75,7 +80,7 @@ import {
|
|
|
75
80
|
import {
|
|
76
81
|
InitiateVerificationResponse,
|
|
77
82
|
StartVerificationRequestData,
|
|
78
|
-
|
|
83
|
+
VerificationService,
|
|
79
84
|
} from '@sinch/verification';
|
|
80
85
|
|
|
81
86
|
const credentials: ApplicationCredentials = {
|
|
@@ -83,9 +88,10 @@ const credentials: ApplicationCredentials = {
|
|
|
83
88
|
applicationSecret: 'APPLICATION_SECRET',
|
|
84
89
|
};
|
|
85
90
|
|
|
86
|
-
// Declare the 'verification'
|
|
87
|
-
const
|
|
91
|
+
// Declare the 'verification' service in a standalone way
|
|
92
|
+
const verificationService = new VerificationService(credentials);
|
|
88
93
|
|
|
94
|
+
// Build the request data
|
|
89
95
|
const requestData: StartVerificationRequestData = {
|
|
90
96
|
initiateVerificationRequestBody: {
|
|
91
97
|
identity: {
|
|
@@ -96,9 +102,9 @@ const requestData: StartVerificationRequestData = {
|
|
|
96
102
|
},
|
|
97
103
|
};
|
|
98
104
|
|
|
99
|
-
// Use the standalone declaration of the 'verification'
|
|
105
|
+
// Use the standalone declaration of the 'verification' service
|
|
100
106
|
const verificationInitResponse: InitiateVerificationResponse
|
|
101
|
-
= await
|
|
107
|
+
= await verificationService.verifications.start(requestData);
|
|
102
108
|
```
|
|
103
109
|
|
|
104
110
|
## Promises
|
|
@@ -109,14 +115,14 @@ All the methods that interact with the Sinch APIs use Promises. You can use `awa
|
|
|
109
115
|
// Method 1: Wait for the Promise to complete (you need to be in an 'async' method)
|
|
110
116
|
let verificationInitResponse: InitiateVerificationResponse;
|
|
111
117
|
try {
|
|
112
|
-
verificationInitResponse = await
|
|
118
|
+
verificationInitResponse = await verificationService.verifications.start(requestData);
|
|
113
119
|
console.log(`Verification ID = ${verificationInitResponse.id}`);
|
|
114
120
|
} catch (error: any) {
|
|
115
121
|
console.error(`ERROR ${error.statusCode}: Impossible to start the verification for the number ${requestData.initiateVerificationRequestBody.identity.endpoint}`);
|
|
116
122
|
}
|
|
117
123
|
|
|
118
124
|
// Method 2: Resolve the promise
|
|
119
|
-
|
|
125
|
+
verificationService.verifications.start(requestData)
|
|
120
126
|
.then(response => console.log(`Verification ID = ${response.id}`))
|
|
121
127
|
.catch(error => console.error(`ERROR ${error.statusCode}: Impossible to start the verification for the number ${requestData.initiateVerificationRequestBody.identity.endpoint}`));
|
|
122
128
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sinch/verification",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Sinch Verification API",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"repository": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"compile": "tsc -p tsconfig.build.json && tsc -p tsconfig.tests.json && rimraf dist/tests tsconfig.build.tsbuildinfo"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@sinch/sdk-client": "^0.0.
|
|
31
|
+
"@sinch/sdk-client": "^0.0.4"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {},
|
|
34
34
|
"publishConfig": {
|