-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for custom authentication, connectors, and credentials AP…
…Is (#497) Adds support for custom authentication, the connectors API and the credentials API.
- Loading branch information
1 parent
e40bb18
commit 84bbf33
Showing
9 changed files
with
621 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
import { Provider } from './auth.js'; | ||
import { ListQueryParams } from './listQueryParams.js'; | ||
|
||
/** | ||
* Interface representing the Nylas connector response. | ||
*/ | ||
export interface Connector { | ||
/** | ||
* Custom name of the connector | ||
*/ | ||
name: string; | ||
/** | ||
* The provider type | ||
*/ | ||
provider: Provider; | ||
/** | ||
* Optional settings from provider | ||
*/ | ||
settings?: Record<string, unknown>; | ||
/** | ||
* Default scopes for the connector | ||
*/ | ||
scope?: string[]; | ||
} | ||
|
||
/** | ||
* Interface representing a Google connector creation request. | ||
*/ | ||
export interface GoogleCreateConnectorSettings { | ||
/** | ||
* The Google Client ID | ||
*/ | ||
clientId: string; | ||
/** | ||
* The Google Client Secret | ||
*/ | ||
clientSecret: string; | ||
/** | ||
* The Google Pub/Sub topic name | ||
*/ | ||
topicName?: string; | ||
} | ||
|
||
/** | ||
* Interface representing a Microsoft connector creation request. | ||
*/ | ||
export interface MicrosoftCreateConnectorSettings { | ||
/** | ||
* The Microsoft Client ID | ||
*/ | ||
clientId: string; | ||
/** | ||
* The Microsoft Client Secret | ||
*/ | ||
clientSecret: string; | ||
/** | ||
* The Microsoft tenant ID | ||
*/ | ||
tenant?: string; | ||
} | ||
|
||
/** | ||
* Interface representing the base Nylas connector creation request. | ||
*/ | ||
interface BaseCreateConnectionRequest { | ||
/** | ||
* Custom name of the connector | ||
*/ | ||
name: string; | ||
/** | ||
* The provider type | ||
*/ | ||
provider: Provider; | ||
} | ||
|
||
/** | ||
* Interface representing the base Nylas connector creation request. | ||
*/ | ||
export interface GoogleCreateConnectorRequest | ||
extends BaseCreateConnectionRequest { | ||
/** | ||
* The Google OAuth provider credentials and settings | ||
*/ | ||
settings: GoogleCreateConnectorSettings; | ||
/** | ||
* The Google OAuth scopes | ||
*/ | ||
scope?: string[]; | ||
} | ||
|
||
export interface MicrosoftCreateConnectorRequest | ||
extends BaseCreateConnectionRequest { | ||
/** | ||
* The Microsoft OAuth provider credentials and settings | ||
*/ | ||
settings: MicrosoftCreateConnectorSettings; | ||
/** | ||
* The Microsoft OAuth scopes | ||
*/ | ||
scope?: string[]; | ||
} | ||
|
||
/** | ||
* Interface representing the base Nylas connector creation request. | ||
*/ | ||
export type ImapCreateConnectorRequest = BaseCreateConnectionRequest; | ||
|
||
/** | ||
* Interface representing the base Nylas connector creation request. | ||
*/ | ||
export type VirtualCalendarsCreateConnectorRequest = BaseCreateConnectionRequest; | ||
|
||
/** | ||
* The type of the Nylas connector creation request. | ||
*/ | ||
export type CreateConnectorRequest = | ||
| GoogleCreateConnectorRequest | ||
| MicrosoftCreateConnectorRequest | ||
| ImapCreateConnectorRequest | ||
| VirtualCalendarsCreateConnectorRequest; | ||
|
||
/** | ||
* Interface representing the base Nylas connector creation request. | ||
*/ | ||
export interface UpdateConnectorRequest { | ||
/** | ||
* Custom name of the connector | ||
*/ | ||
name?: string; | ||
/** | ||
* The OAuth provider credentials and settings | ||
*/ | ||
settings?: Record<string, unknown>; | ||
/** | ||
* The OAuth scopes | ||
*/ | ||
scope?: string[]; | ||
} | ||
|
||
/** | ||
* Interface of the query parameters for listing connectors. | ||
*/ | ||
export type ListConnectorsQueryParams = ListQueryParams; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
/** | ||
* Interface representing a Nylas Credential object. | ||
*/ | ||
export interface Credential { | ||
/** | ||
* Globally unique object identifier | ||
*/ | ||
id: string; | ||
/** | ||
* Name of the credential | ||
*/ | ||
name: string; | ||
/** | ||
* The type of credential | ||
*/ | ||
credentialType?: CredentialType; | ||
/** | ||
* Hashed value of the credential that you created | ||
*/ | ||
hashedData?: string; | ||
/** | ||
* Timestamp of when the credential was created | ||
*/ | ||
createdAt?: number; | ||
/** | ||
* Timestamp of when the credential was updated | ||
*/ | ||
updatedAt?: number; | ||
} | ||
|
||
/** | ||
* Interface representing additional data needed to create a credential for Microsoft Admin Consent | ||
*/ | ||
export interface MicrosoftAdminConsentSettings { | ||
clientId: string; | ||
clientSecret: string; | ||
[key: string]: string; | ||
} | ||
|
||
/** | ||
* Interface representing additional data needed to create a credential for Google Service Account | ||
*/ | ||
export interface GoogleServiceAccountCredential { | ||
privateKeyId: string; | ||
privateKey: string; | ||
clientEmail: string; | ||
[key: string]: string; | ||
} | ||
|
||
/** | ||
* Interface representing additional data needed to create a credential for a Connector Override | ||
*/ | ||
export type ConnectorOverrideCredential = Record<string, unknown>; | ||
|
||
/** | ||
* Type representing the data needed to create a credential | ||
*/ | ||
export type CredentialData = | ||
| MicrosoftAdminConsentSettings | ||
| GoogleServiceAccountCredential | ||
| ConnectorOverrideCredential; | ||
|
||
/** | ||
* Interface representing a request to create a Microsoft Admin Consent credential | ||
*/ | ||
export interface CreateMicrosoftCredentialRequest { | ||
/** | ||
* Unique name of this credential | ||
*/ | ||
name: string; | ||
/** | ||
* Type of credential for the admin consent flow | ||
*/ | ||
credentialType: CredentialType.ADMINCONSENT; | ||
/** | ||
* Data that specifies some special data required for this credential | ||
*/ | ||
credentialData: MicrosoftAdminConsentSettings; | ||
} | ||
|
||
/** | ||
* Interface representing a request to create a Google Service Account credential | ||
*/ | ||
export interface CreateGoogleCredentialRequest { | ||
/** | ||
* Unique name of this credential | ||
*/ | ||
name: string; | ||
/** | ||
* Type of credential for the app permission flow | ||
*/ | ||
credentialType: CredentialType.SERVICEACCOUNT; | ||
/** | ||
* Data that specifies some special data required for this credential | ||
*/ | ||
credentialData: GoogleServiceAccountCredential; | ||
} | ||
|
||
/** | ||
* Interface representing a request to create a Connector Override credential | ||
*/ | ||
export interface CreateOverrideCredentialRequest { | ||
/** | ||
* Unique name of this credential | ||
*/ | ||
name: string; | ||
/** | ||
* Type of credential to force the override of a connector's client values | ||
*/ | ||
credentialType: CredentialType.CONNECTOR; | ||
/** | ||
* Data that specifies some special data required for this credential | ||
*/ | ||
credentialData: ConnectorOverrideCredential; | ||
} | ||
|
||
/** | ||
* Interface representing a request to create a credential | ||
*/ | ||
export type CreateCredentialRequest = | ||
| CreateMicrosoftCredentialRequest | ||
| CreateGoogleCredentialRequest | ||
| CreateOverrideCredentialRequest; | ||
|
||
/** | ||
* Interface representing a request to update a credential | ||
*/ | ||
export interface UpdateCredentialRequest { | ||
/** | ||
* Unique name of this credential | ||
*/ | ||
name?: string; | ||
/** | ||
* Data that specifies some special data required for this credential | ||
*/ | ||
credentialData?: CredentialData; | ||
} | ||
|
||
/** | ||
* Enum representing the type of credential | ||
*/ | ||
export enum CredentialType { | ||
ADMINCONSENT = 'adminconsent', | ||
SERVICEACCOUNT = 'serviceaccount', | ||
CONNECTOR = 'connector', | ||
} | ||
|
||
/** | ||
* Interface representing the query parameters for listing credentials. | ||
*/ | ||
export interface ListCredentialsQueryParams { | ||
/** | ||
* Limit the number of results | ||
*/ | ||
limit?: number; | ||
/** | ||
* Offset the results by this number | ||
*/ | ||
offset?: number; | ||
/** | ||
* Sort the results by field name | ||
*/ | ||
sortBy?: 'createdAt' | 'updatedAt'; | ||
/** | ||
* Order the results by ascending or descending | ||
*/ | ||
orderBy?: 'desc' | 'asc'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.