@sipgate/integration-bridge 0.1.0 → 0.1.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/LICENSE CHANGED
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright 2019 sipgate GmbH
189
+ Copyright 2022 sipgate GmbH
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # sipgate Integration Bridge Framework
2
2
 
3
- This is the sipgate Integration Bridge framework to integrate with external services.
3
+ This is the sipgate Integration Bridge framework to integrate sipgate apps with external services.
4
4
  It provides a unified way to connect apps to any provider of external data management, like contacts or calendar events.
5
5
 
6
6
  ## Bootstrapping a new bridge
7
7
 
8
- If you want to bootstrap a new sipgate Integration Bridge you can use this repository: [sipgate-integration-bridge-boilerplate](https://github.com/sipgate/sipgate-integration-bridge-boilerplate)
8
+ If you want to bootstrap a new sipgate Integration Bridge you can use this repository: [sipgate-integration-bridge-boilerplate](https://github.com/sipgate/integration-bridge-boilerplate)
9
9
 
10
10
  ## Installation
11
11
 
@@ -36,13 +36,13 @@ const adapter = {
36
36
  throw new ServerError(401, "Unauthorized");
37
37
  }
38
38
 
39
- if (response.ok) {
40
- const contacts = await response.json();
41
- // TODO: Convert contact to the structure above
42
- return contacts;
43
- } else {
39
+ if (!response.ok) {
44
40
  throw new ServerError(500, "Could not fetch contacts");
45
41
  }
42
+
43
+ const contacts = await response.json();
44
+ // TODO: Convert contact to the structure below
45
+ return contacts;
46
46
  },
47
47
  };
48
48
 
@@ -76,7 +76,7 @@ Contacts are accepted in this format:
76
76
  The sipgate Integration Bridge supports configuration through the following environment variables:
77
77
 
78
78
  - `OAUTH2_REDIRECT_URL`: URL for to redirect the user at the end of the OAuth2 flow
79
- - `OAUTH2_IDENTIFIER`: Name of the Integration to indentify credentials
79
+ - `OAUTH2_IDENTIFIER`: Name of the Integration to identify credentials
80
80
  - `REDIS_URL`: URL of a Redis instance to cache responses, otherwise memory cache will be used
81
81
  - `CACHE_DISABLED`: Disable caching
82
82
  - `CACHE_REFRESH_INTERVAL`: Time a contact in cache is not refreshed (in seconds), only used if redis or memory cache is active
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.convertPhoneNumberToE164 = void 0;
4
- const google_libphonenumber_1 = require("google-libphonenumber");
5
- const phoneUtil = google_libphonenumber_1.PhoneNumberUtil.getInstance();
4
+ const awesome_phonenumber_1 = require("awesome-phonenumber");
6
5
  function convertPhoneNumberToE164(phoneNumber, locale) {
7
6
  const region = locale.replace(/.+_/, "").toUpperCase();
8
7
  try {
9
- const parsedPhoneNumber = phoneUtil.parse(phoneNumber, region);
10
- return phoneUtil.format(parsedPhoneNumber, google_libphonenumber_1.PhoneNumberFormat.E164);
8
+ const parsedPhoneNumber = (0, awesome_phonenumber_1.parsePhoneNumber)(phoneNumber, region);
9
+ const e164 = parsedPhoneNumber.getNumber("e164");
10
+ return e164 !== null && e164 !== void 0 ? e164 : phoneNumber;
11
11
  }
12
12
  catch (_a) {
13
13
  return phoneNumber;
@@ -1 +1 @@
1
- {"version":3,"file":"phone-number-utils.js","sourceRoot":"","sources":["../../src/util/phone-number-utils.ts"],"names":[],"mappings":";;;AAAA,iEAA2E;AAE3E,MAAM,SAAS,GAAoB,uCAAe,CAAC,WAAW,EAAE,CAAC;AAEjE,SAAgB,wBAAwB,CACtC,WAAmB,EACnB,MAAc;IAEd,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAEvD,IAAI;QACF,MAAM,iBAAiB,GAA+B,SAAS,CAAC,KAAK,CACnE,WAAW,EACX,MAAM,CACP,CAAC;QACF,OAAO,SAAS,CAAC,MAAM,CAAC,iBAAiB,EAAE,yCAAiB,CAAC,IAAI,CAAC,CAAC;KACpE;IAAC,WAAM;QACN,OAAO,WAAW,CAAC;KACpB;AACH,CAAC;AAfD,4DAeC"}
1
+ {"version":3,"file":"phone-number-utils.js","sourceRoot":"","sources":["../../src/util/phone-number-utils.ts"],"names":[],"mappings":";;;AAAA,6DAAuD;AAEvD,SAAgB,wBAAwB,CACtC,WAAmB,EACnB,MAAc;IAEd,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAEvD,IAAI;QACF,MAAM,iBAAiB,GAAG,IAAA,sCAAgB,EAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAChE,MAAM,IAAI,GAAG,iBAAiB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACjD,OAAO,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,WAAW,CAAC;KAC5B;IAAC,WAAM;QACN,OAAO,WAAW,CAAC;KACpB;AACH,CAAC;AAbD,4DAaC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sipgate/integration-bridge",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "sipgate Integration Bridge Framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -60,8 +60,6 @@
60
60
  "@types/compression": "1.7.2",
61
61
  "@types/cors": "2.8.12",
62
62
  "@types/express": "4.17.13",
63
- "@types/get-port": "4.2.0",
64
- "@types/google-libphonenumber": "7.4.23",
65
63
  "@types/jest": "28.1.6",
66
64
  "@types/lru-cache": "7.10.9",
67
65
  "@types/node": "18.0.6",
@@ -77,12 +75,12 @@
77
75
  },
78
76
  "dependencies": {
79
77
  "ajv": "^8.11.0",
78
+ "awesome-phonenumber": "^3.2.0",
80
79
  "axios": "^0.27.2",
81
80
  "body-parser": "^1.20.0",
82
81
  "compression": "^1.7.4",
83
82
  "cors": "^2.8.5",
84
83
  "express": "^4.18.1",
85
- "google-libphonenumber": "^3.2.29",
86
84
  "lru-cache": "^7.13.1",
87
85
  "redis": "^4.2.0"
88
86
  }