@kumbify/sdk 1.1.0 → 1.1.2

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 CHANGED
@@ -30,11 +30,15 @@ import { KMailClient, KSMSClient } from "@kumbify/sdk";
30
30
 
31
31
  ### Email — KMailClient
32
32
 
33
- #### 📍 Create an Email Client
33
+ #### Create an Email Client
34
34
 
35
35
  ```ts
36
36
  const mailClient = new KMailClient({
37
37
  apiKey: "YOUR_EMAIL_API_KEY",
38
+ api: {
39
+ lang: "en",
40
+ version: "v1",
41
+ },
38
42
  });
39
43
  ```
40
44
 
@@ -55,13 +59,13 @@ console.log("Email Response: ", sendMail);
55
59
 
56
60
  **Parameters explained:**
57
61
 
58
- | Property | Type | Description |
59
- | -------------- | -------- | --------------------------------- |
60
- | `body.html` | string | HTML email content |
61
- | `body.text` | string | Plain text email content |
62
- | `from` | string | Sender email address |
63
- | `subject` | string | Email subject |
64
- | `to` | string[] | List of recipient email addresses |
62
+ | Property | Type | Description |
63
+ | ----------- | -------- | --------------------------------- |
64
+ | `body.html` | string | HTML email content |
65
+ | `body.text` | string | Plain text email content |
66
+ | `from` | string | Sender email address |
67
+ | `subject` | string | Email subject |
68
+ | `to` | string[] | List of recipient email addresses |
65
69
 
66
70
  ---
67
71
 
@@ -75,14 +79,13 @@ const sendMail = await mailClient.sendTemplateMail({
75
79
  data: {
76
80
  customer: {
77
81
  name: "Ricardo Castle",
78
- email: "doe@gmail.com"
79
- }
82
+ email: "doe@gmail.com",
83
+ },
80
84
  },
81
85
  },
82
86
  });
83
87
 
84
88
  console.log("Email Response: ", sendMail);
85
-
86
89
  ```
87
90
 
88
91
  **Parameters explained:**
@@ -98,11 +101,15 @@ console.log("Email Response: ", sendMail);
98
101
 
99
102
  ### SMS — KSMSClient
100
103
 
101
- #### 📍 Create an SMS Client
104
+ #### Create an SMS Client
102
105
 
103
106
  ```ts
104
107
  const smsClient = new KSMSClient({
105
108
  apiKey: "YOUR_SMS_API_KEY",
109
+ api: {
110
+ lang: "en",
111
+ version: "v1",
112
+ },
106
113
  });
107
114
  ```
108
115
 
@@ -119,11 +126,12 @@ console.log("SMS sent successfully!");
119
126
 
120
127
  **Parameters explained:**
121
128
 
122
- | Property | Type | Description |
123
- | --------- | ------ | ------------------------------------ |
124
- | `message` | string | SMS content |
125
- | `from` | string | Sender identifier (visible to users) |
126
- | `to` | string[] | List of recipient phone numbers |
129
+ | Property | Type | Description |
130
+ | --------- | -------- | ------------------------------------ |
131
+ | `message` | string | SMS content |
132
+ | `from` | string | Sender identifier (visible to users) |
133
+ | `to` | string[] | List of recipient phone numbers |
134
+
127
135
  ---
128
136
 
129
137
  ### Example Usage All Together
@@ -155,6 +163,45 @@ await smsClient.sendSMS({
155
163
 
156
164
  ---
157
165
 
166
+ ### OAuth2Client
167
+
168
+ #### Create an OAuth2 Client
169
+
170
+ ```ts
171
+ const oauthClient = new OAuth2Client({
172
+ clientId: process.env.KUMBIFY_CLIENT_ID,
173
+ clientSecret: process.env.KUMBIFY_CLIENT_SECRET,
174
+ redirectUri: {
175
+ account: "",
176
+ service: "",
177
+ },
178
+ scopes: {
179
+ account: ["profile", "subscription.read"],
180
+ services: ["gmail.send.email"],
181
+ },
182
+ api: {
183
+ lang: "pt",
184
+ version: "v1",
185
+ },
186
+ });
187
+
188
+ // Generate OAuth Account URL
189
+ const oauthAccountUrl = oauthClient.generateOAuthAccountUrl({});
190
+
191
+ // Generate OAuth Service URL
192
+ const oauthServiceUrl = oauthClient.generateOAuthServiceUrl({});
193
+ ```
194
+
195
+ | Property | Type | Description |
196
+ | -------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
197
+ | `clientId` | string | SMS content |
198
+ | `clientSecret` | string | Sender identifier (visible to users) |
199
+ | `redirectUri` | object | URL redirect type, choose the one that meets your needs. **Service** if using the client to obtain service permissions. **Account** if using it for sign-in |
200
+ | `scopes` | object | Scope type: choose the one that meets your needs. **Service**: if using the client to obtain service permissions, such as sending emails. **Account**: if using it for user account permissions, such as profile access |
201
+ | `api` | object | API Definitions |
202
+
203
+ ---
204
+
158
205
  ### Tips & Best Practices
159
206
 
160
207
  - Store your API keys in environment variables (never hardcode them).
@@ -0,0 +1,7 @@
1
+ export declare function fetchRequest({ ...data }: {
2
+ url: string;
3
+ method: "post" | "get" | "put" | "delete";
4
+ body?: Record<string, any>;
5
+ params?: Record<string, any>;
6
+ headers?: Record<string, any>;
7
+ }): Promise<any>;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fetchRequest = fetchRequest;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ async function fetchRequest({ ...data }) {
9
+ let resp;
10
+ const axiosAPI = axios_1.default.create({});
11
+ switch (data.method) {
12
+ case "delete":
13
+ resp = await axiosAPI.delete(data.url, {
14
+ data: data.body,
15
+ headers: data.headers,
16
+ params: data.params,
17
+ });
18
+ break;
19
+ case "get":
20
+ resp = await axiosAPI.get(data.url, {
21
+ headers: data.headers,
22
+ params: data.params,
23
+ });
24
+ break;
25
+ case "post":
26
+ resp = await axiosAPI.post(data.url, data.body, {
27
+ headers: data.headers,
28
+ params: data.params,
29
+ });
30
+ break;
31
+ case "put":
32
+ resp = await axiosAPI.put(data.url, data.body, {
33
+ headers: data.headers,
34
+ params: data.params,
35
+ });
36
+ break;
37
+ default:
38
+ resp = await axiosAPI.get(data.url, {
39
+ headers: data.headers,
40
+ params: data.params,
41
+ });
42
+ break;
43
+ }
44
+ return resp.data;
45
+ }
46
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/api/api.ts"],"names":[],"mappings":";;;;;AAEA,oCAoDC;AAtDD,kDAA0B;AAEnB,KAAK,UAAU,YAAY,CAAC,EAC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,CAAC;AACnB,CAAC"}
@@ -0,0 +1,8 @@
1
+ declare class APIError {
2
+ CatchError({ error, section, }: {
3
+ error: any;
4
+ section: "mail" | "sms" | "oauth";
5
+ }): void;
6
+ }
7
+ declare const _default: APIError;
8
+ export default _default;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const axios_1 = __importDefault(require("axios"));
7
+ class APIError {
8
+ CatchError({ error, section, }) {
9
+ let errorSection = "";
10
+ switch (section) {
11
+ case "mail":
12
+ errorSection = "Mail Service: Failed =>";
13
+ break;
14
+ case "oauth":
15
+ errorSection = "OAuthService: Failed =>";
16
+ break;
17
+ case "sms":
18
+ errorSection = "SMS Service: Failed =>";
19
+ break;
20
+ }
21
+ if (axios_1.default.isAxiosError(error)) {
22
+ const status = error.response?.status;
23
+ const data = error.response?.data;
24
+ throw new Error(`${errorSection} (status: ${status}): ${JSON.stringify(data)}`);
25
+ }
26
+ throw new Error(`${errorSection} ${String(error)}`);
27
+ }
28
+ }
29
+ exports.default = new APIError();
30
+ //# sourceMappingURL=APIError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"APIError.js","sourceRoot":"","sources":["../../src/errors/APIError.ts"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAE1B,MAAM,QAAQ;IACZ,UAAU,CAAC,EACT,KAAK,EACL,OAAO,GAIR;QACC,IAAI,YAAY,GAAG,EAAE,CAAC;QAEtB,QAAQ,OAAO,EAAE,CAAC;YAChB,KAAK,MAAM;gBACT,YAAY,GAAG,yBAAyB,CAAC;gBACzC,MAAM;YAER,KAAK,OAAO;gBACV,YAAY,GAAG,yBAAyB,CAAC;gBACzC,MAAM;YAER,KAAK,KAAK;gBACR,YAAY,GAAG,wBAAwB,CAAC;gBACxC,MAAM;QACV,CAAC;QAED,IAAI,eAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC;YACtC,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC;YAClC,MAAM,IAAI,KAAK,CACb,GAAG,YAAY,aAAa,MAAM,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAC/D,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,GAAG,YAAY,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACtD,CAAC;CACF;AAED,kBAAe,IAAI,QAAQ,EAAE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./kmail/KMailClient";
2
2
  export * from "./ksms/KSMSClient";
3
+ export * from "./oauth/OAuth2Client";
package/dist/index.js CHANGED
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./kmail/KMailClient"), exports);
18
18
  __exportStar(require("./ksms/KSMSClient"), exports);
19
+ __exportStar(require("./oauth/OAuth2Client"), exports);
19
20
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,oDAAkC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,oDAAkC;AAClC,uDAAqC"}
@@ -1,8 +1,10 @@
1
- import { IKMailResponseMail, IKMailSendMailSimpleMessage, IKMailSendMailTemplateMessage } from "../utils/types";
1
+ import { IAPIConfig, IKMailResponseMail, IKMailSendMailSimpleMessage, IKMailSendMailTemplateMessage } from "../utils/types";
2
2
  export declare class KMailClient {
3
3
  private apiKey;
4
- constructor({ apiKey }: {
4
+ private api;
5
+ constructor({ apiKey, api }: {
5
6
  apiKey: string;
7
+ api?: IAPIConfig;
6
8
  });
7
9
  sendSimpleMail({ ...data }: IKMailSendMailSimpleMessage): Promise<IKMailResponseMail>;
8
10
  sendTemplateMail({ ...data }: IKMailSendMailTemplateMessage): Promise<IKMailResponseMail>;
@@ -5,49 +5,58 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.KMailClient = void 0;
7
7
  const helpers_1 = require("../utils/helpers");
8
- const axios_1 = __importDefault(require("axios"));
8
+ const api_1 = require("../api/api");
9
+ const APIError_1 = __importDefault(require("../errors/APIError"));
9
10
  class KMailClient {
10
11
  apiKey;
11
- constructor({ apiKey }) {
12
+ api = { lang: "pt", version: "v1" };
13
+ constructor({ apiKey, api }) {
12
14
  this.apiKey = apiKey;
15
+ this.api = api;
13
16
  }
14
17
  async sendSimpleMail({ ...data }) {
15
18
  try {
16
- const response = await axios_1.default.post(helpers_1.APP_CONFIG.KMAIL_URL + "/send", {
17
- from_address: data.from,
18
- to_address: data.to,
19
- subject: data.subject,
20
- body_html: data.body.html,
21
- body_text: data.body.text,
22
- }, { headers: { "kumbi-api-key": "Bearer " + this.apiKey } });
23
- return response.data;
19
+ const response = await (0, api_1.fetchRequest)({
20
+ url: helpers_1.APP_CONFIG.KMAIL_URL + "/send",
21
+ method: "post",
22
+ body: {
23
+ from_address: data.from,
24
+ to_address: data.to,
25
+ subject: data.subject,
26
+ body_html: data.body.html,
27
+ body_text: data.body.text,
28
+ },
29
+ headers: {
30
+ "kumbi-api-key": "Bearer " + this.apiKey,
31
+ "accept-language": this.api.lang,
32
+ },
33
+ });
34
+ return response;
24
35
  }
25
36
  catch (error) {
26
- if (axios_1.default.isAxiosError(error)) {
27
- const status = error.response?.status;
28
- const data = error.response?.data;
29
- throw new Error(`Mail failed (status: ${status}): ${JSON.stringify(data)}`);
30
- }
31
- throw new Error(`Mail failed: ${String(error)}`);
37
+ APIError_1.default.CatchError({ error, section: "mail" });
32
38
  }
33
39
  }
34
40
  async sendTemplateMail({ ...data }) {
35
41
  try {
36
- const response = await axios_1.default.post(helpers_1.APP_CONFIG.KMAIL_URL + "/send", {
37
- from_address: data.from,
38
- to_address: data.to,
39
- template_name: data.template.name,
40
- template_data: data.template.data,
41
- }, { headers: { "kumbi-api-key": "Bearer " + this.apiKey } });
42
- return response.data;
42
+ const response = await (0, api_1.fetchRequest)({
43
+ url: helpers_1.APP_CONFIG.KMAIL_URL + "/send",
44
+ method: "post",
45
+ body: {
46
+ from_address: data.from,
47
+ to_address: data.to,
48
+ template_name: data.template.name,
49
+ template_data: data.template.data,
50
+ },
51
+ headers: {
52
+ "kumbi-api-key": "Bearer " + this.apiKey,
53
+ "accept-language": this.api.lang,
54
+ },
55
+ });
56
+ return response;
43
57
  }
44
58
  catch (error) {
45
- if (axios_1.default.isAxiosError(error)) {
46
- const status = error.response?.status;
47
- const data = error.response?.data;
48
- throw new Error(`Mail failed (status: ${status}): ${JSON.stringify(data)}`);
49
- }
50
- throw new Error(`Mail failed: ${String(error)}`);
59
+ APIError_1.default.CatchError({ error, section: "mail" });
51
60
  }
52
61
  }
53
62
  }
@@ -1 +1 @@
1
- {"version":3,"file":"KMailClient.js","sourceRoot":"","sources":["../../src/kmail/KMailClient.ts"],"names":[],"mappings":";;;;;;AAKA,8CAA8C;AAE9C,kDAA0B;AAE1B,MAAa,WAAW;IACd,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,EAAsB;QACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,EAAE,GAAG,IAAI,EAA+B;QAC3D,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAC/B,oBAAU,CAAC,SAAS,GAAG,OAAO,EAC9B;gBACE,YAAY,EAAE,IAAI,CAAC,I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../utils/types";
2
2
  export declare class KSMSClient {
3
3
  private apiKey;
4
- constructor({ apiKey }: {
4
+ private api;
5
+ constructor({ apiKey, api }: {
5
6
  apiKey: string;
7
+ api?: IAPIConfig;
6
8
  });
7
- sendSMS({ ...data }: IKSMSSendMessage): Promise<any>;
9
+ sendSMS({ ...data }: IKSMSSendMessage): Promise<IKSMSResponseMessage>;
8
10
  }
@@ -5,28 +5,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.KSMSClient = void 0;
7
7
  const helpers_1 = require("../utils/helpers");
8
- const axios_1 = __importDefault(require("axios"));
8
+ const api_1 = require("../api/api");
9
+ const APIError_1 = __importDefault(require("../errors/APIError"));
9
10
  class KSMSClient {
10
11
  apiKey;
11
- constructor({ apiKey }) {
12
+ api = { lang: "pt", version: "v1" };
13
+ constructor({ apiKey, api }) {
12
14
  this.apiKey = apiKey;
15
+ this.api = api;
13
16
  }
14
17
  async sendSMS({ ...data }) {
15
18
  try {
16
- const response = await axios_1.default.post(helpers_1.APP_CONFIG.KSMS_URL + "/send", {
17
- body: data.message,
18
- to: data.to,
19
- from: data.from,
20
- }, { headers: { "kumbi-api-key": "Bearer " + this.apiKey } });
21
- return response.data;
19
+ const response = await (0, api_1.fetchRequest)({
20
+ url: helpers_1.APP_CONFIG.KSMS_URL + "/send",
21
+ method: "post",
22
+ body: {
23
+ body: data.message,
24
+ to: data.to,
25
+ from: data.from,
26
+ },
27
+ headers: {
28
+ "kumbi-api-key": "Bearer " + this.apiKey,
29
+ "accept-language": this.api.lang,
30
+ },
31
+ });
32
+ return response;
22
33
  }
23
34
  catch (error) {
24
- if (axios_1.default.isAxiosError(error)) {
25
- const status = error.response?.status;
26
- const data = error.response?.data;
27
- throw new Error(`SMS failed (status: ${status}): ${JSON.stringify(data)}`);
28
- }
29
- throw new Error(`SMS failed: ${String(error)}`);
35
+ APIError_1.default.CatchError({ error, section: "sms" });
30
36
  }
31
37
  }
32
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"KSMSClient.js","sourceRoot":"","sources":["../../src/ksms/KSMSClient.ts"],"names":[],"mappings":";;;;;;AAAA,8CAA8C;AAE9C,kDAA0B;AAE1B,MAAa,UAAU;IACb,MAAM,CAAC;IAEf,YAAY,EAAE,MAAM,EAAsB;QACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,EAAoB;QACzC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAC/B,oBAAU,CAAC,QAAQ,GAAG,OAAO,EAC7B;gBACE,IAAI,EAAE,IAAI,CAAC,OAAO;gBAClB,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,EACD,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAC1D,CAAC;YAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,eAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC9B,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC;gBACtC,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC;gBAClC,MAAM,IAAI,KAAK,CACb,uBAAuB,MAAM,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAC1D,CAAC;YACJ,CAAC;YAED,MAAM,IAAI,KAAK,CAAC,eAAe,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;CACF;AAhCD,gCAgCC"}
1
+ {"version":3,"file":"KSMSClient.js","sourceRoot":"","sources":["../../src/ksms/KSMSClient.ts"],"names":[],"mappings":";;;;;;AAAA,8CAA8C;AAM9C,oCAA0C;AAE1C,kEAA0C;AAE1C,MAAa,UAAU;IACb,MAAM,CAAC;IACP,GAAG,GAAe,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAExD,YAAY,EAAE,MAAM,EAAE,GAAG,EAAwC;QAC/D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,EAAoB;QACzC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAyB,MAAM,IAAA,kBAAY,EAAC;gBACxD,GAAG,EAAE,oBAAU,CAAC,QAAQ,GAAG,OAAO;gBAClC,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE;oBACJ,IAAI,EAAE,IAAI,CAAC,OAAO;oBAClB,EAAE,EAAE,IAAI,CAAC,EAAE;oBACX,IAAI,EAAE,IAAI,CAAC,IAAI;iBAChB;gBACD,OAAO,EAAE;oBACP,eAAe,EAAE,SAAS,GAAG,IAAI,CAAC,MAAM;oBACxC,iBAAiB,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI;iBACjC;aACF,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,kBAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;CACF;AA9BD,gCA8BC"}
@@ -0,0 +1,49 @@
1
+ import { IAPIConfig, IOAuthUserInfoResponse, IOAuthUserTokenReponse } from "../utils/types";
2
+ interface IOAuthClientTokenParams {
3
+ type: "services" | "account";
4
+ code: string;
5
+ grant_type: "authorization_code" | "refresh_token";
6
+ refresh_token?: string;
7
+ redirect?: IOAuthRedirect;
8
+ expires_in: "1h" | "1d" | "7d" | "never";
9
+ }
10
+ interface IOAuthRedirect {
11
+ account?: string;
12
+ service?: string;
13
+ }
14
+ interface IOAuthScopes {
15
+ account?: OAuthAccountScopes[];
16
+ services?: OAuthServiceScopes[];
17
+ }
18
+ interface IOAuthClientProps {
19
+ clientId: string;
20
+ clientSecret: string;
21
+ scopes: IOAuthScopes;
22
+ redirectUri: IOAuthRedirect;
23
+ api?: IAPIConfig;
24
+ }
25
+ type OAuthServiceScopes = "gmail.send.email";
26
+ type OAuthAccountScopes = "profile" | "subscription.read";
27
+ export declare class OAuth2Client {
28
+ private clientId;
29
+ private clientSecret;
30
+ private redirectUri;
31
+ private scopes;
32
+ private api;
33
+ constructor({ clientId, clientSecret, redirectUri, scopes, api, }: IOAuthClientProps);
34
+ generateOAuthAccountUrl({ state }: {
35
+ state?: string;
36
+ }): {
37
+ url: string;
38
+ };
39
+ generateOAuthServiceUrl({ state }: {
40
+ state?: string;
41
+ }): {
42
+ url: string;
43
+ };
44
+ generateToken({ ...data }: IOAuthClientTokenParams): Promise<IOAuthUserTokenReponse>;
45
+ userInfo({ accessToken }: {
46
+ accessToken: string;
47
+ }): Promise<IOAuthUserInfoResponse>;
48
+ }
49
+ export {};
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.OAuth2Client = void 0;
7
+ const helpers_1 = require("../utils/helpers");
8
+ const api_1 = require("../api/api");
9
+ const APIError_1 = __importDefault(require("../errors/APIError"));
10
+ class OAuth2Client {
11
+ clientId;
12
+ clientSecret;
13
+ redirectUri;
14
+ scopes;
15
+ api = { lang: "pt", version: "v1" };
16
+ constructor({ clientId, clientSecret, redirectUri, scopes, api, }) {
17
+ this.clientId = clientId;
18
+ this.clientSecret = clientSecret;
19
+ this.redirectUri = redirectUri;
20
+ this.scopes = scopes;
21
+ this.api = api;
22
+ }
23
+ generateOAuthAccountUrl({ state }) {
24
+ const url = `${helpers_1.APP_CONFIG.OAUTH.ACCOUNT}?client_id=${this.clientId}&scopes=${this.scopes.account.join(",")}${state ? `&state=${state}` : ""}&redirect=${this.redirectUri.account}`;
25
+ return { url };
26
+ }
27
+ generateOAuthServiceUrl({ state }) {
28
+ const url = `${helpers_1.APP_CONFIG.OAUTH.ACCOUNT}?client_id=${this.clientId}&scopes=${this.scopes.services.join(",")}${state ? `&state=${state}` : ""}&redirect=${this.redirectUri.service}`;
29
+ return { url };
30
+ }
31
+ async generateToken({ ...data }) {
32
+ try {
33
+ const redirectUri = data.redirect
34
+ ? data.type == "account"
35
+ ? data.redirect.account
36
+ : data.redirect.service
37
+ : "";
38
+ const response = await (0, api_1.fetchRequest)({
39
+ url: helpers_1.APP_CONFIG.OAUTH.API_BASE_URL + "/u/tokens/generate",
40
+ method: "post",
41
+ body: {
42
+ code: data.code,
43
+ grant_type: data.grant_type,
44
+ refresh_token: data.refresh_token,
45
+ client_id: this.clientId,
46
+ redirect_uri: redirectUri,
47
+ expires_in: data.expires_in,
48
+ },
49
+ headers: {
50
+ "kumbi-app-key": `Bearer ${this.clientSecret}`,
51
+ "accept-language": this.api.lang,
52
+ },
53
+ });
54
+ return response;
55
+ }
56
+ catch (error) {
57
+ APIError_1.default.CatchError({ error, section: "oauth" });
58
+ }
59
+ }
60
+ async userInfo({ accessToken }) {
61
+ try {
62
+ const response = await (0, api_1.fetchRequest)({
63
+ url: helpers_1.APP_CONFIG.OAUTH.API_BASE_URL + "/u/me",
64
+ method: "post",
65
+ body: {
66
+ token: accessToken,
67
+ },
68
+ headers: {
69
+ "kumbi-app-key": `Bearer ${this.clientSecret}`,
70
+ "accept-language": this.api.lang,
71
+ },
72
+ });
73
+ return response;
74
+ }
75
+ catch (error) {
76
+ APIError_1.default.CatchError({ error, section: "oauth" });
77
+ }
78
+ }
79
+ }
80
+ exports.OAuth2Client = OAuth2Client;
81
+ //# sourceMappingURL=OAuth2Client.js.map
@@ -0,0 +1 @@
1
+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KAAK,CAAC,YAAY,GAAG,OAAO;gBAC5C,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE;oBACJ,KAAK,EAAE,WAAW;iBACnB;gBACD,OAAO,EAAE;oBACP,eAAe,EAAE,UAAU,IAAI,CAAC,YAAY,EAAE;oBAC9C,iBAAiB,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI;iBACjC;aACF,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,kBAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;CACF;AA3FD,oCA2FC"}
@@ -1,4 +1,9 @@
1
1
  export declare const APP_CONFIG: {
2
2
  KSMS_URL: string;
3
3
  KMAIL_URL: string;
4
+ OAUTH: {
5
+ API_BASE_URL: string;
6
+ SERVICE: string;
7
+ ACCOUNT: string;
8
+ };
4
9
  };
@@ -4,5 +4,10 @@ exports.APP_CONFIG = void 0;
4
4
  exports.APP_CONFIG = {
5
5
  KSMS_URL: "https://oi.kumbify.com/api/sms",
6
6
  KMAIL_URL: "https://oi.kumbify.com/api/email",
7
+ OAUTH: {
8
+ API_BASE_URL: "https://8n8.kumbify.com/api/",
9
+ SERVICE: "https://kumbify.com/pt/oauth/services",
10
+ ACCOUNT: "https://kumbify.com/pt/oauth",
11
+ },
7
12
  };
8
13
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG;IACxB,QAAQ,EAAE,gCAAgC;IAC1C,SAAS,EAAE,kCAAkC;CAC9C,CAAC"}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG;IACxB,QAAQ,EAAE,gCAAgC;IAC1C,SAAS,EAAE,kCAAkC;IAC7C,KAAK,EAAE;QACL,YAAY,EAAE,8BAA8B;QAC5C,OAAO,EAAE,uCAAuC;QAChD,OAAO,EAAE,8BAA8B;KACxC;CACF,CAAC"}
@@ -1,3 +1,13 @@
1
+ /**
2
+ * Global Types
3
+ */
4
+ export interface IAPIConfig {
5
+ lang: "pt" | "en";
6
+ version: "v1";
7
+ }
8
+ /**
9
+ * KMAIL Types
10
+ */
1
11
  export type IKMailSendMailSimpleMessage = {
2
12
  from: string;
3
13
  to: string[];
@@ -19,6 +29,9 @@ export type IKMailResponseMail = {
19
29
  success: boolean;
20
30
  messageId: string;
21
31
  };
32
+ /**
33
+ * KSMS Types
34
+ */
22
35
  export type IKSMSSendMessage = {
23
36
  message: string;
24
37
  to: string[];
@@ -28,3 +41,18 @@ export type IKSMSResponseMessage = {
28
41
  success: boolean;
29
42
  messageId: string;
30
43
  };
44
+ /**
45
+ * OAuth Types
46
+ */
47
+ export type IOAuthUserTokenReponse = {
48
+ success: boolean;
49
+ access_token: string;
50
+ refresh_token: string;
51
+ };
52
+ export type IOAuthUserInfoResponse = {
53
+ first_name: string;
54
+ last_name: string;
55
+ photo: string;
56
+ email: string;
57
+ kumbi_code: string;
58
+ };
@@ -1,3 +1,6 @@
1
1
  "use strict";
2
+ /**
3
+ * Global Types
4
+ */
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kumbify/sdk",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Oficial Kumbify SDK to integrate our services in your applications",
5
5
  "homepage": "https://github.com/kumbify-oficial/kumbi-sdk#readme",
6
6
  "bugs": {
@@ -24,7 +24,7 @@
24
24
  "scripts": {
25
25
  "changeset": "changeset",
26
26
  "version-pack": "changeset version",
27
- "publish-pack": "changeset publish"
27
+ "publish-pack": "tsc && changeset publish"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@changesets/cli": "^2.29.8",