@sinch/sdk-core 0.0.0

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 ADDED
@@ -0,0 +1,107 @@
1
+ # Sinch server SDK for Node.js
2
+
3
+ This package contains the Sinch Client SDK for Node.js. To use it, you will need a Sinch account. Please [sign up](https://dashboard.sinch.com/signup) or [log in](https://dashboard.sinch.com/login) if you already have one.
4
+
5
+ <span style="color:red; font-weight:bold">Warning:</span>
6
+ **This SDK is currently available for preview purposes only. It should not be used in production environments.**
7
+
8
+ ## Installation
9
+
10
+ ### With NPM
11
+
12
+ ```bash
13
+ npm install @sinch/sdk-core
14
+ ```
15
+
16
+ ### With Yarn
17
+
18
+ ```bash
19
+ yarn add @sinch/sdk-core
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ The `@sinch/sdk-core` package contains the entry point for a SDK user: the `SinchClient` class. It will use the information given in parameters to initialize the right plugins for the right APIs.
25
+
26
+ As there are different authentication schemes, the initialization method will depend on which one is used by the API.
27
+
28
+ ### OAuth2 Authentication
29
+
30
+ ```typescript
31
+ import { SinchClient } from '@sinch/sdk-core';
32
+
33
+ // The credentials can be found on the Account dashboard: https://dashboard.sinch.com/account/access-keys
34
+ const sinch = new SinchClient({
35
+ projectId: 'my-project-id',
36
+ keyId: 'my-key-id',
37
+ keySecret: 'my-key-secret',
38
+ });
39
+
40
+ const response = await sinch.numbers.availableRegions.list({
41
+ types: 'LOCAL',
42
+ });
43
+ ```
44
+ The initialization method above will work for the APIs that supports the authentication with OAuth2 (Numbers and SMS on US and EU regions).
45
+
46
+ ### API Token authentication
47
+
48
+ If you want to use the SMS API on the other regions (or US and EU too, it will work), you'll need other credentials in order to give to the Client the `servicePlanId` and the associated `apiToken`.
49
+
50
+ ```typescript
51
+ import { SinchSmsClient } from '@sinch/sdk-core';
52
+
53
+ // The credentials can be found on the Service APIs dashboard: https://dashboard.sinch.com/sms/api/services
54
+ const sinch = new SinchClient({
55
+ servicePlanId: 'my-service-plan-id',
56
+ apiToken: 'my-key-id',
57
+ region: 'my-region', // Optional, can be 'us', 'eu', 'br', 'au', 'ca'. Default is 'us'
58
+ });
59
+
60
+ const response = await sinch.sms.batches.get({
61
+ batch_id: '01HF28S9AABBBCCCCY92BJB569',
62
+ });
63
+ ```
64
+
65
+ ### Signed application authentication
66
+
67
+ Both `Verification` and `Voice` APIs are using this authentication method: the request is encoded using the `Application Secret` and identified with the `Application Key`.
68
+
69
+ ```typescript
70
+ import { SinchClient } from '@sinch/sdk-core';
71
+
72
+ // The credentials can be found on the Verification or Voice dashboard:
73
+ // https://dashboard.sinch.com/verification/apps or
74
+ // https://dashboard.sinch.com/voice/apps
75
+ const sinch = new SinchClient({
76
+ applicationId: 'my-application-key',
77
+ applicationSecret: 'my-application-secret',
78
+ });
79
+
80
+ const response = await sinch.verification.verificationStatus.getById({
81
+ id: '018bfc3e-1234-5678-1234-ebdb3fd6d30f',
82
+ });
83
+ ```
84
+
85
+ ## Examples
86
+ You can find an example of each request in the [../../examples/simple-examples](../../examples/simple-examples/) folder.
87
+
88
+ ## Contact
89
+ Developer Experience team: [devexp@sinch.com](mailto:devexp@sinch.com)
90
+
91
+ ## Supported APIs
92
+
93
+ Here is the list of the Sinch API and there level of support by the Node.js SDK:
94
+
95
+ | API Category | API Name | Status |
96
+ |------------------------|-------------------------------------|:------:|
97
+ | Messaging | SMS API | ✅ |
98
+ | | Conversation API | ❌ |
99
+ | | RCS API | ❌ |
100
+ | | MMS API | ❌ |
101
+ | | Provisioning API | ❌ |
102
+ | Voice and Video | Voice API | ❌ |
103
+ | | Elastic SIP Trunking | ❌ |
104
+ | Numbers & Connectivity | Numbers API | ✅ |
105
+ | | Brand and Campaign Registration API | ❌ |
106
+ | | Number Lookup API | ❌ |
107
+ | Verification | Verification API | ✅ |
@@ -0,0 +1,4 @@
1
+ export * from './sinch-client';
2
+ export * from '@sinch/numbers';
3
+ export * from '@sinch/sms';
4
+ export * from '@sinch/verification';
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./sinch-client"), exports);
18
+ __exportStar(require("@sinch/numbers"), exports);
19
+ __exportStar(require("@sinch/sms"), exports);
20
+ __exportStar(require("@sinch/verification"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,iDAA+B;AAC/B,6CAA2B;AAC3B,sDAAoC"}
@@ -0,0 +1,16 @@
1
+ import { Numbers } from '@sinch/numbers';
2
+ import { Sms } from '@sinch/sms';
3
+ import { Verification } from '@sinch/verification';
4
+ import { SinchClientParameters } from '@sinch/sdk-client';
5
+ /** Sinch Client to declare and initialize the supported APIs */
6
+ export declare class SinchClient {
7
+ readonly numbers: Numbers;
8
+ readonly sms: Sms;
9
+ readonly verification: Verification;
10
+ /**
11
+ * Initialize your API Client instance with the provided credentials.
12
+ *
13
+ * @param {SinchClientParameters} params - The object containing the Sinch credentials.
14
+ */
15
+ constructor(params: SinchClientParameters);
16
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SinchClient = void 0;
4
+ const numbers_1 = require("@sinch/numbers");
5
+ const sms_1 = require("@sinch/sms");
6
+ const verification_1 = require("@sinch/verification");
7
+ /** Sinch Client to declare and initialize the supported APIs */
8
+ class SinchClient {
9
+ /**
10
+ * Initialize your API Client instance with the provided credentials.
11
+ *
12
+ * @param {SinchClientParameters} params - The object containing the Sinch credentials.
13
+ */
14
+ constructor(params) {
15
+ // Initialize the "Numbers" API
16
+ this.numbers = new numbers_1.Numbers(params);
17
+ // Initialize the "SMS" API.
18
+ this.sms = new sms_1.Sms(params);
19
+ // Initialize the "Verification" API
20
+ this.verification = new verification_1.Verification(params);
21
+ }
22
+ }
23
+ exports.SinchClient = SinchClient;
24
+ //# sourceMappingURL=sinch-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sinch-client.js","sourceRoot":"","sources":["../src/sinch-client.ts"],"names":[],"mappings":";;;AAAA,4CAAyC;AACzC,oCAAiC;AACjC,sDAAmD;AAGnD,gEAAgE;AAChE,MAAa,WAAW;IAMtB;;;;OAIG;IACH,YAAY,MAA6B;QACvC,+BAA+B;QAC/B,IAAI,CAAC,OAAO,GAAG,IAAI,iBAAO,CAAC,MAAM,CAAC,CAAC;QAEnC,4BAA4B;QAC5B,IAAI,CAAC,GAAG,GAAG,IAAI,SAAG,CAAC,MAAM,CAAC,CAAC;QAE3B,oCAAoC;QACpC,IAAI,CAAC,YAAY,GAAG,IAAI,2BAAY,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;CACF;AArBD,kCAqBC"}
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@sinch/sdk-core",
3
+ "version": "0.0.0",
4
+ "description": "Node.js client for the Sinch API platform",
5
+ "homepage": "",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": ""
9
+ },
10
+ "license": "Apache-2.0",
11
+ "author": "Sinch",
12
+ "main": "dist/index.js",
13
+ "types": "dist/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "import": "./dist/index.js",
17
+ "require": "./dist/index.js"
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
21
+ "directories": {
22
+ "src": "dist",
23
+ "test": "tests"
24
+ },
25
+ "files": ["/dist"],
26
+ "scripts": {
27
+ "build": "yarn run clean && yarn run compile",
28
+ "clean": "rimraf dist tsconfig.tsbuildinfo",
29
+ "compile": "tsc --build --verbose"
30
+ },
31
+ "dependencies": {
32
+ "@sinch/numbers": "^0.0.0",
33
+ "@sinch/sms": "^0.0.0",
34
+ "@sinch/verification": "^0.0.0"
35
+ },
36
+ "devDependencies": {},
37
+ "publishConfig": {
38
+ "directory": "dist"
39
+ }
40
+ }