feat: add Signalwire integration
This commit is contained in:
65
packages/backend/src/apps/signalwire/auth/index.ts
Normal file
65
packages/backend/src/apps/signalwire/auth/index.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import verifyCredentials from './verify-credentials';
|
||||
import isStillVerified from './is-still-verified';
|
||||
|
||||
export default {
|
||||
fields: [
|
||||
{
|
||||
key: 'accountSid',
|
||||
label: 'Project ID',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description:
|
||||
'Log into your Signalwire account and find the Project ID',
|
||||
clickToCopy: false,
|
||||
},
|
||||
{
|
||||
key: 'authToken',
|
||||
label: 'API Token',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: 'API Token in the respective project',
|
||||
clickToCopy: false,
|
||||
},
|
||||
{
|
||||
key: 'spaceRegion',
|
||||
label: 'Signalwire Region',
|
||||
type: 'dropdown' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: '',
|
||||
placeholder: null,
|
||||
description: 'Most people should choose the default, "US"',
|
||||
clickToCopy: false,
|
||||
options: [
|
||||
{
|
||||
label: 'US',
|
||||
value: '',
|
||||
},
|
||||
{
|
||||
label: 'EU',
|
||||
value: 'eu-',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'spaceName',
|
||||
label: 'Space Name',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: 'Name of your Signalwire space that contains the project',
|
||||
clickToCopy: true,
|
||||
},
|
||||
],
|
||||
|
||||
verifyCredentials,
|
||||
isStillVerified,
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import verifyCredentials from './verify-credentials';
|
||||
|
||||
const isStillVerified = async ($: IGlobalVariable) => {
|
||||
await verifyCredentials($);
|
||||
return true;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
||||
@@ -0,0 +1,11 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
await $.http.get('https://' + $.auth.data.spaceName + '.' + $.auth.data.spaceRegion + 'signalwire.com' + '/api/laml/2010-04-01/Accounts');
|
||||
|
||||
await $.auth.set({
|
||||
screenName: $.auth.data.accountSid,
|
||||
});
|
||||
};
|
||||
|
||||
export default verifyCredentials;
|
||||
Reference in New Issue
Block a user