@things-factory/integration-msgraph 9.0.15 → 9.0.24

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.
@@ -8,6 +8,7 @@ export declare class MsGraphConnector implements Connector {
8
8
  type: string;
9
9
  name: string;
10
10
  label: string;
11
+ useDomainAttribute: boolean;
11
12
  }[];
12
13
  get taskPrefixes(): string[];
13
14
  get description(): string;
@@ -13,8 +13,8 @@ class MsGraphConnector {
13
13
  integration_base_1.ConnectionManager.logger.info('msgraph-connector connections are ready');
14
14
  }
15
15
  async connect(connection) {
16
- var { endpoint: uri = 'https://graph.microsoft.com/v1.0', params: { clientId, clientSecret, tenantId, authTenantId } } = connection;
17
- if (!clientId || !clientSecret || !tenantId || !authTenantId) {
16
+ var { endpoint: uri = 'https://graph.microsoft.com/v1.0', params: { clientId, clientSecret, tenantId } } = connection;
17
+ if (!clientId || !clientSecret || !tenantId) {
18
18
  throw new Error('Connection parameters should not be undefined');
19
19
  }
20
20
  const credential = new azure.ClientSecretCredential(tenantId, clientId, clientSecret);
@@ -39,22 +39,20 @@ class MsGraphConnector {
39
39
  {
40
40
  type: 'string',
41
41
  name: 'clientId',
42
- label: 'client-id'
42
+ label: 'client-id',
43
+ useDomainAttribute: true
43
44
  },
44
45
  {
45
46
  type: 'string',
46
47
  name: 'clientSecret',
47
- label: 'client-secret'
48
+ label: 'client-secret',
49
+ useDomainAttribute: true
48
50
  },
49
51
  {
50
52
  type: 'string',
51
53
  name: 'tenantId',
52
- label: 'tenant-id'
53
- },
54
- {
55
- type: 'string',
56
- name: 'authTenantId',
57
- label: 'auth-tenant-id'
54
+ label: 'tenant-id',
55
+ useDomainAttribute: true
58
56
  }
59
57
  ];
60
58
  }
@@ -1 +1 @@
1
- {"version":3,"file":"msgraph-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/msgraph-connector.ts"],"names":[],"mappings":";;;AAAA,mBAAmB;AACnB,gCAA6B;AAE7B,uEAA+E;AAE/E,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AU,CAAC,IAAI,IAAI,UAAU,CAAC,QAAQ,gBAAgB,CACvF,CAAA;IACH,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,UAAU;QACzB,MAAM,MAAM,GAAG,oCAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAA;QAClE,wCAAwC;QACxC,oCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;QAEtD,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,gCAAgC,UAAU,CAAC,IAAI,mBAAmB,CAAC,CAAA;IACnG,CAAC;IAED,IAAI,aAAa;QACf,2FAA2F;QAC3F,OAAO;YACL;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,WAAW;aACnB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,eAAe;aACvB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,WAAW;aACnB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,gBAAgB;aACxB;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,SAAS,CAAC,CAAA;IACpB,CAAC;IAED,IAAI,WAAW;QACb,OAAO,qBAAqB,CAAA;IAC9B,CAAC;CACF;AA1ED,4CA0EC;AAED,oCAAiB,CAAC,iBAAiB,CAAC,mBAAmB,EAAE,IAAI,gBAAgB,EAAE,CAAC,CAAA","sourcesContent":["/* fetch polyfil */\nimport 'cross-fetch/polyfill'\n\nimport { ConnectionManager, Connector } from '@things-factory/integration-base'\n\nconst azure = require('@azure/identity')\nconst graph = require('@microsoft/microsoft-graph-client')\nconst authProviders = require('@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials')\n\nexport class MsGraphConnector implements Connector {\n async ready(connectionConfigs) {\n await Promise.all(connectionConfigs.map(this.connect.bind(this)))\n\n ConnectionManager.logger.info('msgraph-connector connections are ready')\n }\n\n async connect(connection) {\n var {\n endpoint: uri = 'https://graph.microsoft.com/v1.0',\n params: { clientId, clientSecret, tenantId, authTenantId }\n } = connection\n\n if (!clientId || !clientSecret || !tenantId || !authTenantId) {\n throw new Error('Connection parameters should not be undefined')\n }\n\n const credential = new azure.ClientSecretCredential(tenantId, clientId, clientSecret)\n const authProvider = new authProviders.TokenCredentialAuthenticationProvider(credential, {\n scopes: ['https://graph.microsoft.com/.default']\n })\n\n const client = graph.Client.initWithMiddleware({\n authProvider: authProvider\n })\n\n ConnectionManager.addConnectionInstance(connection, client)\n\n ConnectionManager.logger.info(\n `msgraph-connector connection(${connection.name}:${connection.endpoint}) is connected`\n )\n }\n\n async disconnect(connection) {\n const client = ConnectionManager.getConnectionInstance(connection)\n // TODO implement how to stop connection\n ConnectionManager.removeConnectionInstance(connection)\n\n ConnectionManager.logger.info(`msgraph-connector connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n /* To get proper settings, refer https://developer.microsoft.com/en-us/graph/quick-start */\n return [\n {\n type: 'string',\n name: 'clientId',\n label: 'client-id'\n },\n {\n type: 'string',\n name: 'clientSecret',\n label: 'client-secret'\n },\n {\n type: 'string',\n name: 'tenantId',\n label: 'tenant-id'\n },\n {\n type: 'string',\n name: 'authTenantId',\n label: 'auth-tenant-id'\n }\n ]\n }\n\n get taskPrefixes() {\n return ['msgraph']\n }\n\n get description() {\n return 'Graph API Connector'\n }\n}\n\nConnectionManager.registerConnector('msgraph-connector', new MsGraphConnector())\n"]}
1
+ {"version":3,"file":"msgraph-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/msgraph-connector.ts"],"names":[],"mappings":";;;AAAA,mBAAmB;AACnB,gCAA6B;AAE7B,uEAA+E;AAE/E,MAAM,KAAK,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;AACxC,MAAM,KAAK,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAA;A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,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAA;QAClE,wCAAwC;QACxC,oCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;QAEtD,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,gCAAgC,UAAU,CAAC,IAAI,mBAAmB,CAAC,CAAA;IACnG,CAAC;IAED,IAAI,aAAa;QACf,2FAA2F;QAC3F,OAAO;YACL;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,WAAW;gBAClB,kBAAkB,EAAE,IAAI;aACzB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,eAAe;gBACtB,kBAAkB,EAAE,IAAI;aACzB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,WAAW;gBAClB,kBAAkB,EAAE,IAAI;aACzB;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,SAAS,CAAC,CAAA;IACpB,CAAC;IAED,IAAI,WAAW;QACb,OAAO,qBAAqB,CAAA;IAC9B,CAAC;CACF;AAxED,4CAwEC;AAED,oCAAiB,CAAC,iBAAiB,CAAC,mBAAmB,EAAE,IAAI,gBAAgB,EAAE,CAAC,CAAA","sourcesContent":["/* fetch polyfil */\nimport 'cross-fetch/polyfill'\n\nimport { ConnectionManager, Connector } from '@things-factory/integration-base'\n\nconst azure = require('@azure/identity')\nconst graph = require('@microsoft/microsoft-graph-client')\nconst authProviders = require('@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials')\n\nexport class MsGraphConnector implements Connector {\n async ready(connectionConfigs) {\n await Promise.all(connectionConfigs.map(this.connect.bind(this)))\n\n ConnectionManager.logger.info('msgraph-connector connections are ready')\n }\n\n async connect(connection) {\n var {\n endpoint: uri = 'https://graph.microsoft.com/v1.0',\n params: { clientId, clientSecret, tenantId }\n } = connection\n\n if (!clientId || !clientSecret || !tenantId) {\n throw new Error('Connection parameters should not be undefined')\n }\n\n const credential = new azure.ClientSecretCredential(tenantId, clientId, clientSecret)\n const authProvider = new authProviders.TokenCredentialAuthenticationProvider(credential, {\n scopes: ['https://graph.microsoft.com/.default']\n })\n\n const client = graph.Client.initWithMiddleware({\n authProvider: authProvider\n })\n\n ConnectionManager.addConnectionInstance(connection, client)\n\n ConnectionManager.logger.info(\n `msgraph-connector connection(${connection.name}:${connection.endpoint}) is connected`\n )\n }\n\n async disconnect(connection) {\n const client = ConnectionManager.getConnectionInstance(connection)\n // TODO implement how to stop connection\n ConnectionManager.removeConnectionInstance(connection)\n\n ConnectionManager.logger.info(`msgraph-connector connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n /* To get proper settings, refer https://developer.microsoft.com/en-us/graph/quick-start */\n return [\n {\n type: 'string',\n name: 'clientId',\n label: 'client-id',\n useDomainAttribute: true\n },\n {\n type: 'string',\n name: 'clientSecret',\n label: 'client-secret',\n useDomainAttribute: true\n },\n {\n type: 'string',\n name: 'tenantId',\n label: 'tenant-id',\n useDomainAttribute: true\n }\n ]\n }\n\n get taskPrefixes() {\n return ['msgraph']\n }\n\n get description() {\n return 'Graph API Connector'\n }\n}\n\nConnectionManager.registerConnector('msgraph-connector', new MsGraphConnector())\n"]}