@azure-tools/communication-recipient-verification 1.0.0-alpha.20250122.7 → 1.0.0-alpha.20250131.1
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 +65 -65
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -35,10 +35,9 @@ Once you have a key, you can authenticate the `RecipientVerificationClient` with
|
|
|
35
35
|
|
|
36
36
|
### Using a connection string
|
|
37
37
|
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} = require("@azure-tools/communication-recipient-verification");
|
|
38
|
+
```ts snippet:ReadmeSampleCreateClient_ConnectionString
|
|
39
|
+
import { RecipientVerificationClient } from "@azure-tools/communication-recipient-verification";
|
|
40
|
+
|
|
42
41
|
const connectionString = "endpoint=<endpoint>;accessKey=<accessKey>";
|
|
43
42
|
const client = new RecipientVerificationClient(connectionString);
|
|
44
43
|
```
|
|
@@ -47,11 +46,10 @@ const client = new RecipientVerificationClient(connectionString);
|
|
|
47
46
|
|
|
48
47
|
If you use a key to initialize the client you will also need to provide the appropriate endpoint. You can get this endpoint from your Communication Services resource in [Azure Portal][azure_portal]. Once you have a key and endpoint, you can authenticate with the following code:
|
|
49
48
|
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
} = require("@azure-tools/communication-recipient-verification");
|
|
49
|
+
```ts snippet:ReadmeSampleCreateClient_KeyCredential
|
|
50
|
+
import { AzureKeyCredential } from "@azure/core-auth";
|
|
51
|
+
import { RecipientVerificationClient } from "@azure-tools/communication-recipient-verification";
|
|
52
|
+
|
|
55
53
|
const credential = new AzureKeyCredential("<key-from-resource>");
|
|
56
54
|
const client = new RecipientVerificationClient("<endpoint-from-resource>", credential);
|
|
57
55
|
```
|
|
@@ -66,11 +64,9 @@ npm install @azure/identity
|
|
|
66
64
|
|
|
67
65
|
The [`@azure/identity`][azure_identity] package provides a variety of credential types that your application can use to do this. The [README for `@azure/identity`][azure_identity_readme] provides more details and samples to get you started.
|
|
68
66
|
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
RecipientVerificationClient,
|
|
73
|
-
} = require("@azure-tools/communication-recipient-verification");
|
|
67
|
+
```ts snippet:ReadmeSampleCreateClient_DefaultAzureCredential
|
|
68
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
69
|
+
import { RecipientVerificationClient } from "@azure-tools/communication-recipient-verification";
|
|
74
70
|
|
|
75
71
|
const credential = new DefaultAzureCredential();
|
|
76
72
|
const client = new RecipientVerificationClient("<endpoint-from-resource>", credential);
|
|
@@ -87,90 +83,94 @@ The following sections provide code snippets that cover some of the common tasks
|
|
|
87
83
|
|
|
88
84
|
### Request phone number verification code
|
|
89
85
|
|
|
90
|
-
```
|
|
86
|
+
```ts snippet:ReadmeSampleRequestVerification
|
|
87
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
91
88
|
import { RecipientVerificationClient } from "@azure-tools/communication-recipient-verification";
|
|
92
|
-
const connectionString = "endpoint=<endpoint>;accessKey=<accessKey>";
|
|
93
|
-
const client = new RecipientVerificationClient(connectionString);
|
|
94
89
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const VerificationRequest = {
|
|
98
|
-
identity: "+11234567890",
|
|
99
|
-
channel: "sms",
|
|
100
|
-
};
|
|
90
|
+
const credential = new DefaultAzureCredential();
|
|
91
|
+
const client = new RecipientVerificationClient("<endpoint-from-resource>", credential);
|
|
101
92
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
93
|
+
// body of the request
|
|
94
|
+
const VerificationRequest = {
|
|
95
|
+
identity: "+11234567890",
|
|
96
|
+
channel: "sms",
|
|
97
|
+
};
|
|
106
98
|
|
|
107
|
-
|
|
99
|
+
// get the verification status
|
|
100
|
+
const status = await client.requestVerification(VerificationRequest);
|
|
101
|
+
console.log(status);
|
|
108
102
|
```
|
|
109
103
|
|
|
110
104
|
### Verify phone number
|
|
111
105
|
|
|
112
|
-
```
|
|
106
|
+
```ts snippet:ReadmeSampleVerifyIdentity
|
|
107
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
113
108
|
import { RecipientVerificationClient } from "@azure-tools/communication-recipient-verification";
|
|
114
|
-
const connectionString = "endpoint=<endpoint>;accessKey=<accessKey>";
|
|
115
|
-
const client = new RecipientVerificationClient(connectionString);
|
|
116
109
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const verificationId = "7e5dd7e1-5203-41ab-960e-65c1eb804fc6";
|
|
110
|
+
const credential = new DefaultAzureCredential();
|
|
111
|
+
const client = new RecipientVerificationClient("<endpoint-from-resource>", credential);
|
|
120
112
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
verificationCode: "1234567",
|
|
124
|
-
};
|
|
113
|
+
// id that is used to reference users phone number
|
|
114
|
+
const verificationId = "7e5dd7e1-5203-41ab-960e-65c1eb804fc6";
|
|
125
115
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
116
|
+
// body of the request
|
|
117
|
+
const VerificationRequest = {
|
|
118
|
+
verificationCode: "1234567",
|
|
119
|
+
};
|
|
130
120
|
|
|
131
|
-
|
|
121
|
+
// verifying your phone number
|
|
122
|
+
const status = await client.verifyIdentity(verificationId, VerificationRequest);
|
|
123
|
+
console.log(status);
|
|
132
124
|
```
|
|
133
125
|
|
|
134
126
|
### Remove verified number
|
|
135
127
|
|
|
136
|
-
```
|
|
128
|
+
```ts snippet:ReadmeSampleDeleteVerification
|
|
129
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
137
130
|
import { RecipientVerificationClient } from "@azure-tools/communication-recipient-verification";
|
|
138
|
-
const connectionString = "endpoint=<endpoint>;accessKey=<accessKey>";
|
|
139
|
-
const client = new RecipientVerificationClient(connectionString);
|
|
140
131
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const verificationId = "4d313ff0-3aeb-477e-8c15-7c9a893e8999";
|
|
132
|
+
const credential = new DefaultAzureCredential();
|
|
133
|
+
const client = new RecipientVerificationClient("<endpoint-from-resource>", credential);
|
|
144
134
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
135
|
+
// id that is used to reference users phone number
|
|
136
|
+
const verificationId = "4d313ff0-3aeb-477e-8c15-7c9a893e8999";
|
|
148
137
|
|
|
149
|
-
|
|
138
|
+
// delete verification for a resource
|
|
139
|
+
await client.deleteVerification(verificationId);
|
|
150
140
|
```
|
|
151
141
|
|
|
152
142
|
### Get verified numbers
|
|
153
143
|
|
|
154
|
-
```
|
|
144
|
+
```ts snippet:ReadmeSampleGetVerifications
|
|
145
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
155
146
|
import { RecipientVerificationClient } from "@azure-tools/communication-recipient-verification";
|
|
156
|
-
const connectionString = "endpoint=<endpoint>;accessKey=<accessKey>";
|
|
157
|
-
const client = new RecipientVerificationClient(connectionString);
|
|
158
147
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
148
|
+
const credential = new DefaultAzureCredential();
|
|
149
|
+
const client = new RecipientVerificationClient("<endpoint-from-resource>", credential);
|
|
150
|
+
|
|
151
|
+
// get all verifications for a resource
|
|
152
|
+
const verifications = await client.getVerifications();
|
|
162
153
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
154
|
+
// print all verifications
|
|
155
|
+
for await (const verification of verifications) {
|
|
156
|
+
console.log(verification);
|
|
167
157
|
}
|
|
168
|
-
|
|
169
|
-
main();
|
|
170
158
|
```
|
|
171
159
|
|
|
172
160
|
## Troubleshooting
|
|
173
161
|
|
|
162
|
+
### Logging
|
|
163
|
+
|
|
164
|
+
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
|
|
165
|
+
|
|
166
|
+
```ts snippet:SetLogLevel
|
|
167
|
+
import { setLogLevel } from "@azure/logger";
|
|
168
|
+
|
|
169
|
+
setLogLevel("info");
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger).
|
|
173
|
+
|
|
174
174
|
## Next steps
|
|
175
175
|
|
|
176
176
|
Please take a look at the samples directory for detailed examples on how to use this library.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure-tools/communication-recipient-verification",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.20250131.1",
|
|
4
4
|
"description": "Test",
|
|
5
5
|
"sdk-type": "client",
|
|
6
6
|
"main": "./dist/commonjs/index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
|
|
33
33
|
"unit-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser",
|
|
34
34
|
"unit-test:node": "dev-tool run test:vitest",
|
|
35
|
-
"update-snippets": "
|
|
35
|
+
"update-snippets": "dev-tool run update-snippets"
|
|
36
36
|
},
|
|
37
37
|
"files": [
|
|
38
38
|
"dist/",
|
|
@@ -57,17 +57,17 @@
|
|
|
57
57
|
"sideEffects": false,
|
|
58
58
|
"prettier": "@azure/eslint-plugin-azure-sdk/prettier.json",
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@azure/abort-controller": "^2.
|
|
61
|
-
"@azure/communication-common": "^2.
|
|
62
|
-
"@azure/core-auth": "^1.
|
|
60
|
+
"@azure/abort-controller": "^2.1.2",
|
|
61
|
+
"@azure/communication-common": "^2.3.1",
|
|
62
|
+
"@azure/core-auth": "^1.9.0",
|
|
63
63
|
"@azure/core-client": "^1.3.2",
|
|
64
|
-
"@azure/core-lro": "^2.2
|
|
65
|
-
"@azure/core-paging": "^1.
|
|
66
|
-
"@azure/core-rest-pipeline": "^1.
|
|
67
|
-
"@azure/core-tracing": "^1.
|
|
68
|
-
"@azure/logger": "^1.
|
|
69
|
-
"events": "^3.
|
|
70
|
-
"tslib": "^2.
|
|
64
|
+
"@azure/core-lro": "^2.7.2",
|
|
65
|
+
"@azure/core-paging": "^1.6.2",
|
|
66
|
+
"@azure/core-rest-pipeline": "^1.18.2",
|
|
67
|
+
"@azure/core-tracing": "^1.2.0",
|
|
68
|
+
"@azure/logger": "^1.1.4",
|
|
69
|
+
"events": "^3.3.0",
|
|
70
|
+
"tslib": "^2.8.1"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@azure-tools/test-recorder": ">=4.1.0-alpha <4.1.0-alphb",
|
|
@@ -77,13 +77,13 @@
|
|
|
77
77
|
"@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
|
|
78
78
|
"@azure/identity": "^4.0.1",
|
|
79
79
|
"@types/node": "^18.0.0",
|
|
80
|
-
"@vitest/browser": "^
|
|
81
|
-
"@vitest/coverage-istanbul": "^
|
|
80
|
+
"@vitest/browser": "^3.0.3",
|
|
81
|
+
"@vitest/coverage-istanbul": "^3.0.3",
|
|
82
82
|
"dotenv": "^16.0.0",
|
|
83
83
|
"eslint": "^9.9.0",
|
|
84
84
|
"playwright": "^1.48.2",
|
|
85
85
|
"typescript": "~5.7.2",
|
|
86
|
-
"vitest": "^
|
|
86
|
+
"vitest": "^3.0.3"
|
|
87
87
|
},
|
|
88
88
|
"//metadata": {
|
|
89
89
|
"constantPaths": [
|