twilio 5.3.7 → 5.4.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/README.md +7 -0
- package/lib/auth_strategy/AuthStrategy.d.ts +7 -0
- package/lib/auth_strategy/AuthStrategy.js +11 -0
- package/lib/auth_strategy/BasicAuthStrategy.d.ts +8 -0
- package/lib/auth_strategy/BasicAuthStrategy.js +21 -0
- package/lib/auth_strategy/NoAuthStrategy.d.ts +6 -0
- package/lib/auth_strategy/NoAuthStrategy.js +18 -0
- package/lib/auth_strategy/TokenAuthStrategy.d.ts +16 -0
- package/lib/auth_strategy/TokenAuthStrategy.js +60 -0
- package/lib/base/BaseTwilio.d.ts +11 -2
- package/lib/base/BaseTwilio.js +44 -16
- package/lib/base/Page.js +3 -0
- package/lib/base/RequestClient.d.ts +6 -0
- package/lib/base/RequestClient.js +5 -1
- package/lib/credential_provider/ClientCredentialProvider.d.ts +22 -0
- package/lib/credential_provider/ClientCredentialProvider.js +50 -0
- package/lib/credential_provider/CredentialProvider.d.ts +7 -0
- package/lib/credential_provider/CredentialProvider.js +11 -0
- package/lib/credential_provider/NoAuthCredentialProvider.d.ts +9 -0
- package/lib/credential_provider/NoAuthCredentialProvider.js +19 -0
- package/lib/credential_provider/OrgsCredentialProvider.d.ts +22 -0
- package/lib/credential_provider/OrgsCredentialProvider.js +50 -0
- package/lib/http/bearer_token/ApiTokenManager.d.ts +8 -0
- package/lib/http/bearer_token/ApiTokenManager.js +33 -0
- package/lib/http/bearer_token/OrgsTokenManager.d.ts +8 -0
- package/lib/http/bearer_token/OrgsTokenManager.js +33 -0
- package/lib/http/bearer_token/TokenManager.d.ts +3 -0
- package/lib/http/bearer_token/TokenManager.js +5 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +6 -0
- package/lib/rest/PreviewIam.d.ts +18 -0
- package/lib/rest/PreviewIam.js +29 -0
- package/lib/rest/PreviewIamBase.d.ts +13 -0
- package/lib/rest/PreviewIamBase.js +31 -0
- package/lib/rest/Twilio.d.ts +5 -0
- package/lib/rest/Twilio.js +6 -0
- package/lib/rest/accounts/v1/authTokenPromotion.js +3 -0
- package/lib/rest/accounts/v1/bulkConsents.js +1 -0
- package/lib/rest/accounts/v1/bulkContacts.js +1 -0
- package/lib/rest/accounts/v1/credential/aws.js +8 -0
- package/lib/rest/accounts/v1/credential/publicKey.js +8 -0
- package/lib/rest/accounts/v1/safelist.js +2 -0
- package/lib/rest/accounts/v1/secondaryAuthToken.js +5 -0
- package/lib/rest/api/v2010/account/address/dependentPhoneNumber.js +1 -0
- package/lib/rest/api/v2010/account/address.js +8 -0
- package/lib/rest/api/v2010/account/application.js +8 -0
- package/lib/rest/api/v2010/account/authorizedConnectApp.js +4 -0
- package/lib/rest/api/v2010/account/availablePhoneNumberCountry/local.js +1 -0
- package/lib/rest/api/v2010/account/availablePhoneNumberCountry/machineToMachine.js +1 -0
- package/lib/rest/api/v2010/account/availablePhoneNumberCountry/mobile.js +1 -0
- package/lib/rest/api/v2010/account/availablePhoneNumberCountry/national.js +1 -0
- package/lib/rest/api/v2010/account/availablePhoneNumberCountry/sharedCost.js +1 -0
- package/lib/rest/api/v2010/account/availablePhoneNumberCountry/tollFree.js +1 -0
- package/lib/rest/api/v2010/account/availablePhoneNumberCountry/voip.js +1 -0
- package/lib/rest/api/v2010/account/availablePhoneNumberCountry.js +4 -0
- package/lib/rest/api/v2010/account/balance.js +3 -0
- package/lib/rest/api/v2010/account/call/event.js +1 -0
- package/lib/rest/api/v2010/account/call/notification.js +4 -0
- package/lib/rest/api/v2010/account/call/payment.js +2 -0
- package/lib/rest/api/v2010/account/call/recording.js +8 -0
- package/lib/rest/api/v2010/account/call/siprec.js +2 -0
- package/lib/rest/api/v2010/account/call/stream.js +2 -0
- package/lib/rest/api/v2010/account/call/transcription.d.ts +1 -1
- package/lib/rest/api/v2010/account/call/transcription.js +2 -0
- package/lib/rest/api/v2010/account/call/userDefinedMessage.js +1 -0
- package/lib/rest/api/v2010/account/call/userDefinedMessageSubscription.js +3 -0
- package/lib/rest/api/v2010/account/call.js +8 -0
- package/lib/rest/api/v2010/account/conference/participant.js +8 -0
- package/lib/rest/api/v2010/account/conference/recording.js +7 -0
- package/lib/rest/api/v2010/account/conference.js +5 -0
- package/lib/rest/api/v2010/account/connectApp.js +7 -0
- package/lib/rest/api/v2010/account/incomingPhoneNumber/assignedAddOn/assignedAddOnExtension.js +4 -0
- package/lib/rest/api/v2010/account/incomingPhoneNumber/assignedAddOn.js +7 -0
- package/lib/rest/api/v2010/account/incomingPhoneNumber/local.js +2 -0
- package/lib/rest/api/v2010/account/incomingPhoneNumber/mobile.js +2 -0
- package/lib/rest/api/v2010/account/incomingPhoneNumber/tollFree.js +2 -0
- package/lib/rest/api/v2010/account/incomingPhoneNumber.js +8 -0
- package/lib/rest/api/v2010/account/key.js +7 -0
- package/lib/rest/api/v2010/account/message/feedback.js +1 -0
- package/lib/rest/api/v2010/account/message/media.js +6 -0
- package/lib/rest/api/v2010/account/message.js +8 -0
- package/lib/rest/api/v2010/account/newKey.js +1 -0
- package/lib/rest/api/v2010/account/newSigningKey.js +1 -0
- package/lib/rest/api/v2010/account/notification.js +4 -0
- package/lib/rest/api/v2010/account/outgoingCallerId.js +7 -0
- package/lib/rest/api/v2010/account/queue/member.js +5 -0
- package/lib/rest/api/v2010/account/queue.js +8 -0
- package/lib/rest/api/v2010/account/recording/addOnResult/payload/data.js +3 -0
- package/lib/rest/api/v2010/account/recording/addOnResult/payload.js +6 -0
- package/lib/rest/api/v2010/account/recording/addOnResult.js +6 -0
- package/lib/rest/api/v2010/account/recording/transcription.js +6 -0
- package/lib/rest/api/v2010/account/recording.js +4 -0
- package/lib/rest/api/v2010/account/shortCode.js +5 -0
- package/lib/rest/api/v2010/account/signingKey.js +7 -0
- package/lib/rest/api/v2010/account/sip/credentialList/credential.js +8 -0
- package/lib/rest/api/v2010/account/sip/credentialList.js +8 -0
- package/lib/rest/api/v2010/account/sip/domain/authTypes/authTypeCalls/authCallsCredentialListMapping.js +7 -0
- package/lib/rest/api/v2010/account/sip/domain/authTypes/authTypeCalls/authCallsIpAccessControlListMapping.js +7 -0
- package/lib/rest/api/v2010/account/sip/domain/authTypes/authTypeRegistrations/authRegistrationsCredentialListMapping.js +7 -0
- package/lib/rest/api/v2010/account/sip/domain/credentialListMapping.js +7 -0
- package/lib/rest/api/v2010/account/sip/domain/ipAccessControlListMapping.js +7 -0
- package/lib/rest/api/v2010/account/sip/domain.js +8 -0
- package/lib/rest/api/v2010/account/sip/ipAccessControlList/ipAddress.js +8 -0
- package/lib/rest/api/v2010/account/sip/ipAccessControlList.js +8 -0
- package/lib/rest/api/v2010/account/token.js +1 -0
- package/lib/rest/api/v2010/account/transcription.js +6 -0
- package/lib/rest/api/v2010/account/usage/record/allTime.js +1 -0
- package/lib/rest/api/v2010/account/usage/record/daily.js +1 -0
- package/lib/rest/api/v2010/account/usage/record/lastMonth.js +1 -0
- package/lib/rest/api/v2010/account/usage/record/monthly.js +1 -0
- package/lib/rest/api/v2010/account/usage/record/thisMonth.js +1 -0
- package/lib/rest/api/v2010/account/usage/record/today.js +1 -0
- package/lib/rest/api/v2010/account/usage/record/yearly.js +1 -0
- package/lib/rest/api/v2010/account/usage/record/yesterday.js +1 -0
- package/lib/rest/api/v2010/account/usage/record.js +1 -0
- package/lib/rest/api/v2010/account/usage/trigger.js +8 -0
- package/lib/rest/api/v2010/account/validationRequest.js +1 -0
- package/lib/rest/api/v2010/account.js +6 -0
- package/lib/rest/assistants/v1/assistant/assistantsKnowledge.d.ts +6 -0
- package/lib/rest/assistants/v1/assistant/assistantsKnowledge.js +7 -0
- package/lib/rest/assistants/v1/assistant/assistantsTool.js +5 -0
- package/lib/rest/assistants/v1/assistant/feedback.d.ts +4 -3
- package/lib/rest/assistants/v1/assistant/feedback.js +6 -2
- package/lib/rest/assistants/v1/assistant/message.d.ts +3 -2
- package/lib/rest/assistants/v1/assistant/message.js +5 -2
- package/lib/rest/assistants/v1/assistant.d.ts +33 -26
- package/lib/rest/assistants/v1/assistant.js +16 -4
- package/lib/rest/assistants/v1/knowledge/chunk.js +1 -0
- package/lib/rest/assistants/v1/knowledge/knowledgeStatus.js +3 -0
- package/lib/rest/assistants/v1/knowledge.d.ts +25 -8
- package/lib/rest/assistants/v1/knowledge.js +18 -4
- package/lib/rest/assistants/v1/policy.js +1 -0
- package/lib/rest/assistants/v1/session/message.js +1 -0
- package/lib/rest/assistants/v1/session.js +4 -0
- package/lib/rest/assistants/v1/tool.d.ts +15 -12
- package/lib/rest/assistants/v1/tool.js +16 -4
- package/lib/rest/bulkexports/v1/export/day.js +4 -0
- package/lib/rest/bulkexports/v1/export/exportCustomJob.js +2 -0
- package/lib/rest/bulkexports/v1/export/job.js +5 -0
- package/lib/rest/bulkexports/v1/export.js +3 -0
- package/lib/rest/bulkexports/v1/exportConfiguration.js +4 -0
- package/lib/rest/chat/v1/credential.js +8 -0
- package/lib/rest/chat/v1/service/channel/invite.js +7 -0
- package/lib/rest/chat/v1/service/channel/member.js +8 -0
- package/lib/rest/chat/v1/service/channel/message.js +8 -0
- package/lib/rest/chat/v1/service/channel.js +8 -0
- package/lib/rest/chat/v1/service/role.js +8 -0
- package/lib/rest/chat/v1/service/user/userChannel.js +1 -0
- package/lib/rest/chat/v1/service/user.js +8 -0
- package/lib/rest/chat/v1/service.js +8 -0
- package/lib/rest/chat/v2/credential.js +8 -0
- package/lib/rest/chat/v2/service/binding.js +6 -0
- package/lib/rest/chat/v2/service/channel/invite.js +7 -0
- package/lib/rest/chat/v2/service/channel/member.js +6 -0
- package/lib/rest/chat/v2/service/channel/message.js +6 -0
- package/lib/rest/chat/v2/service/channel/webhook.js +8 -0
- package/lib/rest/chat/v2/service/channel.js +6 -0
- package/lib/rest/chat/v2/service/role.js +8 -0
- package/lib/rest/chat/v2/service/user/userBinding.js +6 -0
- package/lib/rest/chat/v2/service/user/userChannel.js +5 -0
- package/lib/rest/chat/v2/service/user.js +8 -0
- package/lib/rest/chat/v2/service.js +8 -0
- package/lib/rest/chat/v3/channel.js +1 -0
- package/lib/rest/content/v1/content/approvalCreate.d.ts +2 -1
- package/lib/rest/content/v1/content/approvalCreate.js +5 -2
- package/lib/rest/content/v1/content/approvalFetch.js +3 -0
- package/lib/rest/content/v1/content.d.ts +25 -30
- package/lib/rest/content/v1/content.js +12 -6
- package/lib/rest/content/v1/contentAndApprovals.js +1 -0
- package/lib/rest/content/v1/legacyContent.js +1 -0
- package/lib/rest/content/v2/content.js +1 -0
- package/lib/rest/content/v2/contentAndApprovals.js +1 -0
- package/lib/rest/conversations/v1/addressConfiguration.d.ts +1 -1
- package/lib/rest/conversations/v1/addressConfiguration.js +8 -0
- package/lib/rest/conversations/v1/configuration/webhook.js +4 -0
- package/lib/rest/conversations/v1/configuration.js +4 -0
- package/lib/rest/conversations/v1/conversation/message/deliveryReceipt.js +4 -0
- package/lib/rest/conversations/v1/conversation/message.js +6 -0
- package/lib/rest/conversations/v1/conversation/participant.js +6 -0
- package/lib/rest/conversations/v1/conversation/webhook.js +8 -0
- package/lib/rest/conversations/v1/conversation.js +6 -0
- package/lib/rest/conversations/v1/conversationWithParticipants.js +1 -0
- package/lib/rest/conversations/v1/credential.js +8 -0
- package/lib/rest/conversations/v1/participantConversation.js +1 -0
- package/lib/rest/conversations/v1/role.js +8 -0
- package/lib/rest/conversations/v1/service/binding.js +6 -0
- package/lib/rest/conversations/v1/service/configuration/notification.js +4 -0
- package/lib/rest/conversations/v1/service/configuration/webhook.js +4 -0
- package/lib/rest/conversations/v1/service/configuration.js +4 -0
- package/lib/rest/conversations/v1/service/conversation/message/deliveryReceipt.js +4 -0
- package/lib/rest/conversations/v1/service/conversation/message.js +6 -0
- package/lib/rest/conversations/v1/service/conversation/participant.js +6 -0
- package/lib/rest/conversations/v1/service/conversation/webhook.js +8 -0
- package/lib/rest/conversations/v1/service/conversation.js +6 -0
- package/lib/rest/conversations/v1/service/conversationWithParticipants.js +1 -0
- package/lib/rest/conversations/v1/service/participantConversation.js +1 -0
- package/lib/rest/conversations/v1/service/role.js +8 -0
- package/lib/rest/conversations/v1/service/user/userConversation.js +7 -0
- package/lib/rest/conversations/v1/service/user.js +6 -0
- package/lib/rest/conversations/v1/service.js +7 -0
- package/lib/rest/conversations/v1/user/userConversation.js +7 -0
- package/lib/rest/conversations/v1/user.js +6 -0
- package/lib/rest/events/v1/eventType.js +4 -0
- package/lib/rest/events/v1/schema/schemaVersion.js +4 -0
- package/lib/rest/events/v1/schema.js +3 -0
- package/lib/rest/events/v1/sink/sinkTest.js +3 -0
- package/lib/rest/events/v1/sink/sinkValidate.js +1 -0
- package/lib/rest/events/v1/sink.js +8 -0
- package/lib/rest/events/v1/subscription/subscribedEvent.js +8 -0
- package/lib/rest/events/v1/subscription.js +8 -0
- package/lib/rest/flexApi/v1/assessments.js +3 -0
- package/lib/rest/flexApi/v1/channel.js +7 -0
- package/lib/rest/flexApi/v1/configuration.d.ts +5 -3
- package/lib/rest/flexApi/v1/configuration.js +6 -2
- package/lib/rest/flexApi/v1/flexFlow.js +8 -0
- package/lib/rest/flexApi/v1/insightsAssessmentsComment.js +2 -0
- package/lib/rest/flexApi/v1/insightsConversations.js +1 -0
- package/lib/rest/flexApi/v1/insightsQuestionnaires.js +4 -0
- package/lib/rest/flexApi/v1/insightsQuestionnairesCategory.js +3 -0
- package/lib/rest/flexApi/v1/insightsQuestionnairesQuestion.js +3 -0
- package/lib/rest/flexApi/v1/insightsSegments.js +1 -0
- package/lib/rest/flexApi/v1/insightsSession.js +1 -0
- package/lib/rest/flexApi/v1/insightsSettingsAnswerSets.js +1 -0
- package/lib/rest/flexApi/v1/insightsSettingsComment.js +1 -0
- package/lib/rest/flexApi/v1/insightsUserRoles.js +1 -0
- package/lib/rest/flexApi/v1/interaction/interactionChannel/interactionChannelInvite.js +2 -0
- package/lib/rest/flexApi/v1/interaction/interactionChannel/interactionChannelParticipant.js +3 -0
- package/lib/rest/flexApi/v1/interaction/interactionChannel.js +5 -0
- package/lib/rest/flexApi/v1/interaction.js +4 -0
- package/lib/rest/flexApi/v1/plugin/pluginVersions.js +3 -0
- package/lib/rest/flexApi/v1/plugin.js +4 -0
- package/lib/rest/flexApi/v1/pluginArchive.js +1 -0
- package/lib/rest/flexApi/v1/pluginConfiguration/configuredPlugin.js +2 -0
- package/lib/rest/flexApi/v1/pluginConfiguration.js +3 -0
- package/lib/rest/flexApi/v1/pluginConfigurationArchive.js +1 -0
- package/lib/rest/flexApi/v1/pluginRelease.js +3 -0
- package/lib/rest/flexApi/v1/pluginVersionArchive.js +1 -0
- package/lib/rest/flexApi/v1/provisioningStatus.js +3 -0
- package/lib/rest/flexApi/v1/webChannel.js +8 -0
- package/lib/rest/flexApi/v2/flexUser.js +4 -0
- package/lib/rest/flexApi/v2/webChannels.js +1 -0
- package/lib/rest/frontlineApi/v1/user.js +4 -0
- package/lib/rest/iam/V1.d.ts +5 -5
- package/lib/rest/iam/V1.js +5 -5
- package/lib/rest/iam/v1/apiKey.js +6 -0
- package/lib/rest/iam/v1/getApiKeys.js +1 -0
- package/lib/rest/iam/v1/{key.d.ts → newApiKey.d.ts} +14 -14
- package/lib/rest/iam/v1/{key.js → newApiKey.js} +7 -6
- package/lib/rest/insights/v1/call/annotation.js +4 -0
- package/lib/rest/insights/v1/call/callSummary.d.ts +1 -1
- package/lib/rest/insights/v1/call/callSummary.js +1 -0
- package/lib/rest/insights/v1/call/event.js +1 -0
- package/lib/rest/insights/v1/call/metric.js +1 -0
- package/lib/rest/insights/v1/call.js +3 -0
- package/lib/rest/insights/v1/callSummaries.d.ts +1 -1
- package/lib/rest/insights/v1/callSummaries.js +1 -0
- package/lib/rest/insights/v1/conference/conferenceParticipant.js +2 -0
- package/lib/rest/insights/v1/conference.js +4 -0
- package/lib/rest/insights/v1/room/participant.js +4 -0
- package/lib/rest/insights/v1/room.js +4 -0
- package/lib/rest/insights/v1/setting.js +2 -0
- package/lib/rest/intelligence/v2/customOperator.js +8 -0
- package/lib/rest/intelligence/v2/operator.js +4 -0
- package/lib/rest/intelligence/v2/operatorAttachment.js +5 -0
- package/lib/rest/intelligence/v2/operatorAttachments.js +3 -0
- package/lib/rest/intelligence/v2/operatorType.js +4 -0
- package/lib/rest/intelligence/v2/prebuiltOperator.js +4 -0
- package/lib/rest/intelligence/v2/service.js +8 -0
- package/lib/rest/intelligence/v2/transcript/media.js +1 -0
- package/lib/rest/intelligence/v2/transcript/operatorResult.js +2 -0
- package/lib/rest/intelligence/v2/transcript/sentence.js +1 -0
- package/lib/rest/intelligence/v2/transcript.js +7 -0
- package/lib/rest/ipMessaging/v1/credential.js +8 -0
- package/lib/rest/ipMessaging/v1/service/channel/invite.js +7 -0
- package/lib/rest/ipMessaging/v1/service/channel/member.js +8 -0
- package/lib/rest/ipMessaging/v1/service/channel/message.js +8 -0
- package/lib/rest/ipMessaging/v1/service/channel.js +8 -0
- package/lib/rest/ipMessaging/v1/service/role.js +8 -0
- package/lib/rest/ipMessaging/v1/service/user/userChannel.js +1 -0
- package/lib/rest/ipMessaging/v1/service/user.js +8 -0
- package/lib/rest/ipMessaging/v1/service.js +8 -0
- package/lib/rest/ipMessaging/v2/credential.js +8 -0
- package/lib/rest/ipMessaging/v2/service/binding.js +6 -0
- package/lib/rest/ipMessaging/v2/service/channel/invite.js +7 -0
- package/lib/rest/ipMessaging/v2/service/channel/member.js +6 -0
- package/lib/rest/ipMessaging/v2/service/channel/message.js +6 -0
- package/lib/rest/ipMessaging/v2/service/channel/webhook.js +8 -0
- package/lib/rest/ipMessaging/v2/service/channel.js +6 -0
- package/lib/rest/ipMessaging/v2/service/role.js +8 -0
- package/lib/rest/ipMessaging/v2/service/user/userBinding.js +6 -0
- package/lib/rest/ipMessaging/v2/service/user/userChannel.js +7 -0
- package/lib/rest/ipMessaging/v2/service/user.js +8 -0
- package/lib/rest/ipMessaging/v2/service.js +8 -0
- package/lib/rest/lookups/v1/phoneNumber.js +1 -0
- package/lib/rest/lookups/v2/phoneNumber.js +1 -0
- package/lib/rest/marketplace/v1/availableAddOn/availableAddOnExtension.js +4 -0
- package/lib/rest/marketplace/v1/availableAddOn.js +4 -0
- package/lib/rest/marketplace/v1/installedAddOn/installedAddOnExtension.js +5 -0
- package/lib/rest/marketplace/v1/installedAddOn/installedAddOnUsage.d.ts +4 -3
- package/lib/rest/marketplace/v1/installedAddOn/installedAddOnUsage.js +5 -2
- package/lib/rest/marketplace/v1/installedAddOn.js +8 -0
- package/lib/rest/marketplace/v1/moduleDataManagement.js +4 -0
- package/lib/rest/marketplace/v1/referralConversion.d.ts +3 -2
- package/lib/rest/marketplace/v1/referralConversion.js +5 -2
- package/lib/rest/messaging/v1/brandRegistration/brandRegistrationOtp.js +3 -0
- package/lib/rest/messaging/v1/brandRegistration/brandVetting.js +5 -0
- package/lib/rest/messaging/v1/brandRegistration.js +8 -0
- package/lib/rest/messaging/v1/deactivations.js +1 -0
- package/lib/rest/messaging/v1/domainCerts.js +6 -0
- package/lib/rest/messaging/v1/domainConfig.js +4 -0
- package/lib/rest/messaging/v1/domainConfigMessagingService.js +3 -0
- package/lib/rest/messaging/v1/externalCampaign.js +1 -0
- package/lib/rest/messaging/v1/linkshorteningMessagingService.js +5 -0
- package/lib/rest/messaging/v1/linkshorteningMessagingServiceDomainAssociation.js +3 -0
- package/lib/rest/messaging/v1/requestManagedCert.js +3 -0
- package/lib/rest/messaging/v1/service/alphaSender.js +7 -0
- package/lib/rest/messaging/v1/service/channelSender.js +7 -0
- package/lib/rest/messaging/v1/service/phoneNumber.js +7 -0
- package/lib/rest/messaging/v1/service/shortCode.js +7 -0
- package/lib/rest/messaging/v1/service/usAppToPerson.js +8 -0
- package/lib/rest/messaging/v1/service/usAppToPersonUsecase.js +1 -0
- package/lib/rest/messaging/v1/service.js +8 -0
- package/lib/rest/messaging/v1/tollfreeVerification.js +8 -0
- package/lib/rest/messaging/v1/usecase.js +3 -0
- package/lib/rest/microvisor/v1/accountConfig.js +8 -0
- package/lib/rest/microvisor/v1/accountSecret.js +8 -0
- package/lib/rest/microvisor/v1/app/appManifest.js +3 -0
- package/lib/rest/microvisor/v1/app.js +6 -0
- package/lib/rest/microvisor/v1/device/deviceConfig.js +8 -0
- package/lib/rest/microvisor/v1/device/deviceSecret.js +8 -0
- package/lib/rest/microvisor/v1/device.js +5 -0
- package/lib/rest/monitor/v1/alert.js +4 -0
- package/lib/rest/monitor/v1/event.js +4 -0
- package/lib/rest/notify/v1/credential.js +8 -0
- package/lib/rest/notify/v1/service/binding.js +7 -0
- package/lib/rest/notify/v1/service/notification.js +1 -0
- package/lib/rest/notify/v1/service.js +8 -0
- package/lib/rest/numbers/v1/bulkEligibility.d.ts +2 -1
- package/lib/rest/numbers/v1/bulkEligibility.js +8 -2
- package/lib/rest/numbers/v1/eligibility.d.ts +2 -1
- package/lib/rest/numbers/v1/eligibility.js +5 -2
- package/lib/rest/numbers/v1/portingPortIn.d.ts +2 -1
- package/lib/rest/numbers/v1/portingPortIn.js +10 -2
- package/lib/rest/numbers/v1/portingPortInPhoneNumber.js +5 -0
- package/lib/rest/numbers/v1/portingPortability.js +1 -0
- package/lib/rest/numbers/v1/portingWebhookConfiguration.d.ts +2 -1
- package/lib/rest/numbers/v1/portingWebhookConfiguration.js +5 -2
- package/lib/rest/numbers/v1/portingWebhookConfigurationDelete.js +2 -0
- package/lib/rest/numbers/v1/portingWebhookConfigurationFetch.js +3 -0
- package/lib/rest/numbers/v1/signingRequestConfiguration.d.ts +2 -1
- package/lib/rest/numbers/v1/signingRequestConfiguration.js +6 -2
- package/lib/rest/numbers/v2/authorizationDocument/dependentHostedNumberOrder.js +1 -0
- package/lib/rest/numbers/v2/authorizationDocument.js +7 -0
- package/lib/rest/numbers/v2/bulkHostedNumberOrder.d.ts +2 -1
- package/lib/rest/numbers/v2/bulkHostedNumberOrder.js +6 -2
- package/lib/rest/numbers/v2/bundleClone.js +1 -0
- package/lib/rest/numbers/v2/hostedNumberOrder.js +8 -0
- package/lib/rest/numbers/v2/regulatoryCompliance/bundle/bundleCopy.js +2 -0
- package/lib/rest/numbers/v2/regulatoryCompliance/bundle/evaluation.js +7 -0
- package/lib/rest/numbers/v2/regulatoryCompliance/bundle/itemAssignment.js +7 -0
- package/lib/rest/numbers/v2/regulatoryCompliance/bundle/replaceItems.js +1 -0
- package/lib/rest/numbers/v2/regulatoryCompliance/bundle.js +8 -0
- package/lib/rest/numbers/v2/regulatoryCompliance/endUser.js +8 -0
- package/lib/rest/numbers/v2/regulatoryCompliance/endUserType.js +4 -0
- package/lib/rest/numbers/v2/regulatoryCompliance/regulation.js +2 -0
- package/lib/rest/numbers/v2/regulatoryCompliance/supportingDocument.js +8 -0
- package/lib/rest/numbers/v2/regulatoryCompliance/supportingDocumentType.js +4 -0
- package/lib/rest/oauth/v1/authorize.js +1 -0
- package/lib/rest/oauth/v1/token.js +1 -0
- package/lib/rest/preview/hosted_numbers/authorizationDocument/dependentHostedNumberOrder.js +1 -0
- package/lib/rest/preview/hosted_numbers/authorizationDocument.js +6 -0
- package/lib/rest/preview/hosted_numbers/hostedNumberOrder.js +8 -0
- package/lib/rest/preview/marketplace/availableAddOn/availableAddOnExtension.js +4 -0
- package/lib/rest/preview/marketplace/availableAddOn.js +4 -0
- package/lib/rest/preview/marketplace/installedAddOn/installedAddOnExtension.js +5 -0
- package/lib/rest/preview/marketplace/installedAddOn.js +8 -0
- package/lib/rest/preview/sync/service/document/documentPermission.js +7 -0
- package/lib/rest/preview/sync/service/document.js +8 -0
- package/lib/rest/preview/sync/service/syncList/syncListItem.js +6 -0
- package/lib/rest/preview/sync/service/syncList/syncListPermission.js +7 -0
- package/lib/rest/preview/sync/service/syncList.js +7 -0
- package/lib/rest/preview/sync/service/syncMap/syncMapItem.js +6 -0
- package/lib/rest/preview/sync/service/syncMap/syncMapPermission.js +7 -0
- package/lib/rest/preview/sync/service/syncMap.js +7 -0
- package/lib/rest/preview/sync/service.js +8 -0
- package/lib/rest/preview/wireless/command.js +5 -0
- package/lib/rest/preview/wireless/ratePlan.js +8 -0
- package/lib/rest/preview/wireless/sim/usage.js +1 -0
- package/lib/rest/preview/wireless/sim.js +5 -0
- package/lib/rest/previewIam/V1.d.ts +20 -0
- package/lib/rest/previewIam/V1.js +42 -0
- package/lib/rest/previewIam/Versionless.d.ts +15 -0
- package/lib/rest/previewIam/Versionless.js +36 -0
- package/lib/rest/previewIam/v1/authorize.d.ts +69 -0
- package/lib/rest/previewIam/v1/authorize.js +84 -0
- package/lib/rest/previewIam/v1/token.d.ts +88 -0
- package/lib/rest/previewIam/v1/token.js +99 -0
- package/lib/rest/previewIam/versionless/organization/account.d.ts +216 -0
- package/lib/rest/previewIam/versionless/organization/account.js +195 -0
- package/lib/rest/previewIam/versionless/organization/roleAssignment.d.ts +274 -0
- package/lib/rest/previewIam/versionless/organization/roleAssignment.js +221 -0
- package/lib/rest/previewIam/versionless/organization/user.d.ts +448 -0
- package/lib/rest/previewIam/versionless/organization/user.js +299 -0
- package/lib/rest/previewIam/versionless/organization.d.ts +53 -0
- package/lib/rest/previewIam/versionless/organization.js +80 -0
- package/lib/rest/pricing/v1/messaging/country.d.ts +6 -6
- package/lib/rest/pricing/v1/messaging/country.js +4 -0
- package/lib/rest/pricing/v1/phoneNumber/country.d.ts +3 -3
- package/lib/rest/pricing/v1/phoneNumber/country.js +4 -0
- package/lib/rest/pricing/v1/voice/country.d.ts +6 -6
- package/lib/rest/pricing/v1/voice/country.js +4 -0
- package/lib/rest/pricing/v1/voice/number.d.ts +5 -5
- package/lib/rest/pricing/v1/voice/number.js +3 -0
- package/lib/rest/pricing/v2/country.d.ts +8 -8
- package/lib/rest/pricing/v2/country.js +4 -0
- package/lib/rest/pricing/v2/number.d.ts +8 -8
- package/lib/rest/pricing/v2/number.js +1 -0
- package/lib/rest/pricing/v2/voice/country.d.ts +8 -8
- package/lib/rest/pricing/v2/voice/country.js +4 -0
- package/lib/rest/pricing/v2/voice/number.d.ts +6 -6
- package/lib/rest/pricing/v2/voice/number.js +1 -0
- package/lib/rest/proxy/v1/service/phoneNumber.js +8 -0
- package/lib/rest/proxy/v1/service/session/interaction.js +6 -0
- package/lib/rest/proxy/v1/service/session/participant/messageInteraction.js +5 -0
- package/lib/rest/proxy/v1/service/session/participant.js +7 -0
- package/lib/rest/proxy/v1/service/session.js +8 -0
- package/lib/rest/proxy/v1/service/shortCode.js +8 -0
- package/lib/rest/proxy/v1/service.js +8 -0
- package/lib/rest/routes/v2/phoneNumber.js +4 -0
- package/lib/rest/routes/v2/sipDomain.js +4 -0
- package/lib/rest/routes/v2/trunk.js +4 -0
- package/lib/rest/serverless/v1/service/asset/assetVersion.js +4 -0
- package/lib/rest/serverless/v1/service/asset.js +8 -0
- package/lib/rest/serverless/v1/service/build/buildStatus.js +3 -0
- package/lib/rest/serverless/v1/service/build.js +7 -0
- package/lib/rest/serverless/v1/service/environment/deployment.js +5 -0
- package/lib/rest/serverless/v1/service/environment/log.js +4 -0
- package/lib/rest/serverless/v1/service/environment/variable.js +8 -0
- package/lib/rest/serverless/v1/service/environment.js +7 -0
- package/lib/rest/serverless/v1/service/function/functionVersion/functionVersionContent.js +3 -0
- package/lib/rest/serverless/v1/service/function/functionVersion.js +4 -0
- package/lib/rest/serverless/v1/service/function.js +8 -0
- package/lib/rest/serverless/v1/service.js +8 -0
- package/lib/rest/studio/v1/flow/engagement/engagementContext.js +3 -0
- package/lib/rest/studio/v1/flow/engagement/step/stepContext.js +3 -0
- package/lib/rest/studio/v1/flow/engagement/step.js +4 -0
- package/lib/rest/studio/v1/flow/engagement.js +7 -0
- package/lib/rest/studio/v1/flow/execution/executionContext.js +3 -0
- package/lib/rest/studio/v1/flow/execution/executionStep/executionStepContext.js +3 -0
- package/lib/rest/studio/v1/flow/execution/executionStep.js +4 -0
- package/lib/rest/studio/v1/flow/execution.js +8 -0
- package/lib/rest/studio/v1/flow.js +6 -0
- package/lib/rest/studio/v2/flow/execution/executionContext.js +3 -0
- package/lib/rest/studio/v2/flow/execution/executionStep/executionStepContext.js +3 -0
- package/lib/rest/studio/v2/flow/execution/executionStep.js +4 -0
- package/lib/rest/studio/v2/flow/execution.js +8 -0
- package/lib/rest/studio/v2/flow/flowRevision.js +4 -0
- package/lib/rest/studio/v2/flow/flowTestUser.js +4 -0
- package/lib/rest/studio/v2/flow.js +8 -0
- package/lib/rest/studio/v2/flowValidate.js +1 -0
- package/lib/rest/supersim/v1/esimProfile.js +5 -0
- package/lib/rest/supersim/v1/fleet.js +6 -0
- package/lib/rest/supersim/v1/ipCommand.js +5 -0
- package/lib/rest/supersim/v1/network.js +4 -0
- package/lib/rest/supersim/v1/networkAccessProfile/networkAccessProfileNetwork.js +7 -0
- package/lib/rest/supersim/v1/networkAccessProfile.js +6 -0
- package/lib/rest/supersim/v1/settingsUpdate.js +1 -0
- package/lib/rest/supersim/v1/sim/billingPeriod.js +1 -0
- package/lib/rest/supersim/v1/sim/simIpAddress.js +1 -0
- package/lib/rest/supersim/v1/sim.js +6 -0
- package/lib/rest/supersim/v1/smsCommand.js +5 -0
- package/lib/rest/supersim/v1/usageRecord.js +1 -0
- package/lib/rest/sync/v1/service/document/documentPermission.js +7 -0
- package/lib/rest/sync/v1/service/document.js +8 -0
- package/lib/rest/sync/v1/service/syncList/syncListItem.js +6 -0
- package/lib/rest/sync/v1/service/syncList/syncListPermission.js +7 -0
- package/lib/rest/sync/v1/service/syncList.js +8 -0
- package/lib/rest/sync/v1/service/syncMap/syncMapItem.js +6 -0
- package/lib/rest/sync/v1/service/syncMap/syncMapPermission.js +7 -0
- package/lib/rest/sync/v1/service/syncMap.js +8 -0
- package/lib/rest/sync/v1/service/syncStream/streamMessage.js +1 -0
- package/lib/rest/sync/v1/service/syncStream.js +8 -0
- package/lib/rest/sync/v1/service.js +8 -0
- package/lib/rest/taskrouter/v1/workspace/activity.js +8 -0
- package/lib/rest/taskrouter/v1/workspace/event.js +4 -0
- package/lib/rest/taskrouter/v1/workspace/task/reservation.js +5 -0
- package/lib/rest/taskrouter/v1/workspace/task.js +6 -0
- package/lib/rest/taskrouter/v1/workspace/taskChannel.js +8 -0
- package/lib/rest/taskrouter/v1/workspace/taskQueue/taskQueueBulkRealTimeStatistics.d.ts +2 -1
- package/lib/rest/taskrouter/v1/workspace/taskQueue/taskQueueBulkRealTimeStatistics.js +5 -2
- package/lib/rest/taskrouter/v1/workspace/taskQueue/taskQueueCumulativeStatistics.js +1 -0
- package/lib/rest/taskrouter/v1/workspace/taskQueue/taskQueueRealTimeStatistics.js +1 -0
- package/lib/rest/taskrouter/v1/workspace/taskQueue/taskQueueStatistics.js +1 -0
- package/lib/rest/taskrouter/v1/workspace/taskQueue/taskQueuesStatistics.js +1 -0
- package/lib/rest/taskrouter/v1/workspace/taskQueue.js +8 -0
- package/lib/rest/taskrouter/v1/workspace/worker/reservation.js +5 -0
- package/lib/rest/taskrouter/v1/workspace/worker/workerChannel.js +5 -0
- package/lib/rest/taskrouter/v1/workspace/worker/workerStatistics.js +1 -0
- package/lib/rest/taskrouter/v1/workspace/worker/workersCumulativeStatistics.js +1 -0
- package/lib/rest/taskrouter/v1/workspace/worker/workersRealTimeStatistics.js +1 -0
- package/lib/rest/taskrouter/v1/workspace/worker/workersStatistics.js +1 -0
- package/lib/rest/taskrouter/v1/workspace/worker.js +6 -0
- package/lib/rest/taskrouter/v1/workspace/workflow/workflowCumulativeStatistics.js +1 -0
- package/lib/rest/taskrouter/v1/workspace/workflow/workflowRealTimeStatistics.js +1 -0
- package/lib/rest/taskrouter/v1/workspace/workflow/workflowStatistics.js +1 -0
- package/lib/rest/taskrouter/v1/workspace/workflow.js +8 -0
- package/lib/rest/taskrouter/v1/workspace/workspaceCumulativeStatistics.js +1 -0
- package/lib/rest/taskrouter/v1/workspace/workspaceRealTimeStatistics.js +1 -0
- package/lib/rest/taskrouter/v1/workspace/workspaceStatistics.js +1 -0
- package/lib/rest/taskrouter/v1/workspace.js +8 -0
- package/lib/rest/trunking/v1/trunk/credentialList.js +7 -0
- package/lib/rest/trunking/v1/trunk/ipAccessControlList.js +7 -0
- package/lib/rest/trunking/v1/trunk/originationUrl.js +8 -0
- package/lib/rest/trunking/v1/trunk/phoneNumber.js +7 -0
- package/lib/rest/trunking/v1/trunk/recording.js +4 -0
- package/lib/rest/trunking/v1/trunk.js +8 -0
- package/lib/rest/trusthub/v1/complianceInquiries.js +2 -0
- package/lib/rest/trusthub/v1/complianceRegistrationInquiries.js +2 -0
- package/lib/rest/trusthub/v1/complianceTollfreeInquiries.js +1 -0
- package/lib/rest/trusthub/v1/customerProfiles/customerProfilesChannelEndpointAssignment.js +7 -0
- package/lib/rest/trusthub/v1/customerProfiles/customerProfilesEntityAssignments.js +7 -0
- package/lib/rest/trusthub/v1/customerProfiles/customerProfilesEvaluations.js +5 -0
- package/lib/rest/trusthub/v1/customerProfiles.js +8 -0
- package/lib/rest/trusthub/v1/endUser.js +8 -0
- package/lib/rest/trusthub/v1/endUserType.js +4 -0
- package/lib/rest/trusthub/v1/policies.js +4 -0
- package/lib/rest/trusthub/v1/supportingDocument.js +8 -0
- package/lib/rest/trusthub/v1/supportingDocumentType.js +4 -0
- package/lib/rest/trusthub/v1/trustProducts/trustProductsChannelEndpointAssignment.js +7 -0
- package/lib/rest/trusthub/v1/trustProducts/trustProductsEntityAssignments.js +7 -0
- package/lib/rest/trusthub/v1/trustProducts/trustProductsEvaluations.js +5 -0
- package/lib/rest/trusthub/v1/trustProducts.js +8 -0
- package/lib/rest/verify/v2/form.js +3 -0
- package/lib/rest/verify/v2/safelist.js +6 -0
- package/lib/rest/verify/v2/service/accessToken.js +4 -0
- package/lib/rest/verify/v2/service/entity/challenge/notification.js +1 -0
- package/lib/rest/verify/v2/service/entity/challenge.js +6 -0
- package/lib/rest/verify/v2/service/entity/factor.js +7 -0
- package/lib/rest/verify/v2/service/entity/newFactor.js +1 -0
- package/lib/rest/verify/v2/service/entity.js +7 -0
- package/lib/rest/verify/v2/service/messagingConfiguration.js +8 -0
- package/lib/rest/verify/v2/service/rateLimit/bucket.js +8 -0
- package/lib/rest/verify/v2/service/rateLimit.js +8 -0
- package/lib/rest/verify/v2/service/verification.js +5 -0
- package/lib/rest/verify/v2/service/verificationCheck.js +1 -0
- package/lib/rest/verify/v2/service/webhook.js +8 -0
- package/lib/rest/verify/v2/service.js +8 -0
- package/lib/rest/verify/v2/template.js +1 -0
- package/lib/rest/verify/v2/verificationAttempt.js +4 -0
- package/lib/rest/verify/v2/verificationAttemptsSummary.js +1 -0
- package/lib/rest/video/v1/composition.js +7 -0
- package/lib/rest/video/v1/compositionHook.js +8 -0
- package/lib/rest/video/v1/compositionSettings.js +4 -0
- package/lib/rest/video/v1/recording.js +6 -0
- package/lib/rest/video/v1/recordingSettings.js +4 -0
- package/lib/rest/video/v1/room/participant/anonymize.js +3 -0
- package/lib/rest/video/v1/room/participant/publishedTrack.js +4 -0
- package/lib/rest/video/v1/room/participant/subscribeRules.js +4 -0
- package/lib/rest/video/v1/room/participant/subscribedTrack.js +4 -0
- package/lib/rest/video/v1/room/participant.js +5 -0
- package/lib/rest/video/v1/room/recordingRules.js +4 -0
- package/lib/rest/video/v1/room/roomRecording.js +6 -0
- package/lib/rest/video/v1/room.js +6 -0
- package/lib/rest/voice/v1/archivedCall.js +2 -0
- package/lib/rest/voice/v1/byocTrunk.js +8 -0
- package/lib/rest/voice/v1/connectionPolicy/connectionPolicyTarget.js +8 -0
- package/lib/rest/voice/v1/connectionPolicy.js +8 -0
- package/lib/rest/voice/v1/dialingPermissions/bulkCountryUpdate.js +1 -0
- package/lib/rest/voice/v1/dialingPermissions/country/highriskSpecialPrefix.js +1 -0
- package/lib/rest/voice/v1/dialingPermissions/country.js +4 -0
- package/lib/rest/voice/v1/dialingPermissions/settings.js +4 -0
- package/lib/rest/voice/v1/ipRecord.js +8 -0
- package/lib/rest/voice/v1/sourceIpMapping.js +8 -0
- package/lib/rest/wireless/v1/command.js +7 -0
- package/lib/rest/wireless/v1/ratePlan.js +8 -0
- package/lib/rest/wireless/v1/sim/dataSession.js +1 -0
- package/lib/rest/wireless/v1/sim/usageRecord.js +1 -0
- package/lib/rest/wireless/v1/sim.js +7 -0
- package/lib/rest/wireless/v1/usageRecord.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -58,6 +58,13 @@ After a brief delay, you will receive the text message on your phone.
|
|
|
58
58
|
> **Warning**
|
|
59
59
|
> It's okay to hardcode your credentials when testing locally, but you should use environment variables to keep them secret before committing any code or deploying to production. Check out [How to Set Environment Variables](https://www.twilio.com/blog/2017/01/how-to-set-environment-variables.html) for more information.
|
|
60
60
|
|
|
61
|
+
## OAuth Feature for Twilio APIs
|
|
62
|
+
We are introducing Client Credentials Flow-based OAuth 2.0 authentication. This feature is currently in beta and its implementation is subject to change.
|
|
63
|
+
|
|
64
|
+
API examples [here](https://github.com/twilio/twilio-node/blob/main/examples/public_oauth.js)
|
|
65
|
+
|
|
66
|
+
Organisation API examples [here](https://github.com/twilio/twilio-node/blob/main/examples/orgs_api.js)
|
|
67
|
+
|
|
61
68
|
## Usage
|
|
62
69
|
|
|
63
70
|
Check out these [code examples](examples) in JavaScript and TypeScript to get up and running quickly.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import AuthStrategy from "./AuthStrategy";
|
|
2
|
+
export default class BasicAuthStrategy extends AuthStrategy {
|
|
3
|
+
private username;
|
|
4
|
+
private password;
|
|
5
|
+
constructor(username: string, password: string);
|
|
6
|
+
getAuthString(): Promise<string>;
|
|
7
|
+
requiresAuthentication(): boolean;
|
|
8
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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 AuthStrategy_1 = __importDefault(require("./AuthStrategy"));
|
|
7
|
+
class BasicAuthStrategy extends AuthStrategy_1.default {
|
|
8
|
+
constructor(username, password) {
|
|
9
|
+
super("basic");
|
|
10
|
+
this.username = username;
|
|
11
|
+
this.password = password;
|
|
12
|
+
}
|
|
13
|
+
getAuthString() {
|
|
14
|
+
const auth = Buffer.from(this.username + ":" + this.password).toString("base64");
|
|
15
|
+
return Promise.resolve(`Basic ${auth}`);
|
|
16
|
+
}
|
|
17
|
+
requiresAuthentication() {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.default = BasicAuthStrategy;
|
|
@@ -0,0 +1,18 @@
|
|
|
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 AuthStrategy_1 = __importDefault(require("./AuthStrategy"));
|
|
7
|
+
class NoAuthStrategy extends AuthStrategy_1.default {
|
|
8
|
+
constructor() {
|
|
9
|
+
super("noauth");
|
|
10
|
+
}
|
|
11
|
+
getAuthString() {
|
|
12
|
+
return Promise.resolve("");
|
|
13
|
+
}
|
|
14
|
+
requiresAuthentication() {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.default = NoAuthStrategy;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import AuthStrategy from "./AuthStrategy";
|
|
2
|
+
import TokenManager from "../http/bearer_token/TokenManager";
|
|
3
|
+
export default class TokenAuthStrategy extends AuthStrategy {
|
|
4
|
+
private token;
|
|
5
|
+
private tokenManager;
|
|
6
|
+
constructor(tokenManager: TokenManager);
|
|
7
|
+
getAuthString(): Promise<string>;
|
|
8
|
+
requiresAuthentication(): boolean;
|
|
9
|
+
fetchToken(): Promise<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Function to check if the token is expired with a buffer of 30 seconds.
|
|
12
|
+
* @param token - The JWT token as a string.
|
|
13
|
+
* @returns Boolean indicating if the token is expired.
|
|
14
|
+
*/
|
|
15
|
+
isTokenExpired(token: string): boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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 AuthStrategy_1 = __importDefault(require("./AuthStrategy"));
|
|
7
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
|
+
class TokenAuthStrategy extends AuthStrategy_1.default {
|
|
9
|
+
constructor(tokenManager) {
|
|
10
|
+
super("token");
|
|
11
|
+
this.token = "";
|
|
12
|
+
this.tokenManager = tokenManager;
|
|
13
|
+
}
|
|
14
|
+
async getAuthString() {
|
|
15
|
+
return this.fetchToken()
|
|
16
|
+
.then((token) => {
|
|
17
|
+
this.token = token;
|
|
18
|
+
return `Bearer ${this.token}`;
|
|
19
|
+
})
|
|
20
|
+
.catch((error) => {
|
|
21
|
+
throw new Error(`Failed to fetch access token: ${error.message}`);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
requiresAuthentication() {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
async fetchToken() {
|
|
28
|
+
if (this.token == null ||
|
|
29
|
+
this.token.length === 0 ||
|
|
30
|
+
this.isTokenExpired(this.token)) {
|
|
31
|
+
return this.tokenManager.fetchToken();
|
|
32
|
+
}
|
|
33
|
+
return Promise.resolve(this.token);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Function to check if the token is expired with a buffer of 30 seconds.
|
|
37
|
+
* @param token - The JWT token as a string.
|
|
38
|
+
* @returns Boolean indicating if the token is expired.
|
|
39
|
+
*/
|
|
40
|
+
isTokenExpired(token) {
|
|
41
|
+
try {
|
|
42
|
+
// Decode the token without verifying the signature, as we only want to read the expiration for this check
|
|
43
|
+
const decoded = jsonwebtoken_1.default.decode(token);
|
|
44
|
+
if (!decoded || !decoded.exp) {
|
|
45
|
+
// If the token doesn't have an expiration, consider it expired
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
const expiresAt = decoded.exp * 1000;
|
|
49
|
+
const bufferMilliseconds = 30 * 1000;
|
|
50
|
+
const bufferExpiresAt = expiresAt - bufferMilliseconds;
|
|
51
|
+
// Return true if the current time is after the expiration time with buffer
|
|
52
|
+
return Date.now() > bufferExpiresAt;
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
// If there's an error decoding the token, consider it expired
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.default = TokenAuthStrategy;
|
package/lib/base/BaseTwilio.d.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
import RequestClient from "./RequestClient";
|
|
5
5
|
import { HttpMethod } from "../interfaces";
|
|
6
6
|
import { Headers } from "../http/request";
|
|
7
|
+
import AuthStrategy from "../auth_strategy/AuthStrategy";
|
|
8
|
+
import CredentialProvider from "../credential_provider/CredentialProvider";
|
|
7
9
|
declare namespace Twilio {
|
|
8
10
|
interface ClientOpts {
|
|
9
11
|
httpClient?: RequestClient;
|
|
@@ -34,6 +36,7 @@ declare namespace Twilio {
|
|
|
34
36
|
uri?: string;
|
|
35
37
|
username?: string;
|
|
36
38
|
password?: string;
|
|
39
|
+
authStrategy?: AuthStrategy;
|
|
37
40
|
headers?: Headers;
|
|
38
41
|
params?: object;
|
|
39
42
|
data?: object;
|
|
@@ -45,9 +48,10 @@ declare namespace Twilio {
|
|
|
45
48
|
* Parent class for Twilio Client that implements request & validation logic
|
|
46
49
|
*/
|
|
47
50
|
class Client {
|
|
48
|
-
username
|
|
49
|
-
password
|
|
51
|
+
username?: string;
|
|
52
|
+
password?: string;
|
|
50
53
|
accountSid: string;
|
|
54
|
+
credentialProvider?: CredentialProvider;
|
|
51
55
|
opts?: ClientOpts;
|
|
52
56
|
env?: NodeJS.ProcessEnv;
|
|
53
57
|
edge?: string;
|
|
@@ -83,6 +87,11 @@ declare namespace Twilio {
|
|
|
83
87
|
* @returns A new instance of BaseTwilio
|
|
84
88
|
*/
|
|
85
89
|
constructor(username?: string, password?: string, opts?: ClientOpts);
|
|
90
|
+
setOpts(opts?: ClientOpts): void;
|
|
91
|
+
setAccountSid(accountSid?: string): void;
|
|
92
|
+
setCredentialProvider(credentialProvider: CredentialProvider): void;
|
|
93
|
+
invalidateBasicAuth(): void;
|
|
94
|
+
invalidateOAuth(): void;
|
|
86
95
|
get httpClient(): RequestClient;
|
|
87
96
|
/**
|
|
88
97
|
* Makes a request to the Twilio API using the configured http client.
|
package/lib/base/BaseTwilio.js
CHANGED
|
@@ -32,23 +32,22 @@ var Twilio;
|
|
|
32
32
|
*/
|
|
33
33
|
/* jshint ignore:end */
|
|
34
34
|
constructor(username, password, opts) {
|
|
35
|
-
this.opts
|
|
36
|
-
this.env = this.opts.env || {};
|
|
35
|
+
this.setOpts(opts);
|
|
37
36
|
this.username =
|
|
38
37
|
username ??
|
|
39
|
-
this.env
|
|
40
|
-
process.env.TWILIO_ACCOUNT_SID
|
|
41
|
-
(() => {
|
|
42
|
-
throw new Error("username is required");
|
|
43
|
-
})();
|
|
38
|
+
this.env?.TWILIO_ACCOUNT_SID ??
|
|
39
|
+
process.env.TWILIO_ACCOUNT_SID;
|
|
44
40
|
this.password =
|
|
45
41
|
password ??
|
|
46
|
-
this.env
|
|
47
|
-
process.env.TWILIO_AUTH_TOKEN
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
this.env?.TWILIO_AUTH_TOKEN ??
|
|
43
|
+
process.env.TWILIO_AUTH_TOKEN;
|
|
44
|
+
this.accountSid = "";
|
|
45
|
+
this.setAccountSid(this.opts?.accountSid || this.username);
|
|
46
|
+
this.invalidateOAuth();
|
|
47
|
+
}
|
|
48
|
+
setOpts(opts) {
|
|
49
|
+
this.opts = opts || {};
|
|
50
|
+
this.env = this.opts.env || {};
|
|
52
51
|
this.edge =
|
|
53
52
|
this.opts.edge ?? this.env.TWILIO_EDGE ?? process.env.TWILIO_EDGE;
|
|
54
53
|
this.region =
|
|
@@ -73,13 +72,28 @@ var Twilio;
|
|
|
73
72
|
if (this.opts.lazyLoading === false) {
|
|
74
73
|
this._httpClient = this.httpClient;
|
|
75
74
|
}
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
}
|
|
76
|
+
setAccountSid(accountSid) {
|
|
77
|
+
this.accountSid = accountSid || "";
|
|
78
|
+
if (this.accountSid && !this.accountSid?.startsWith("AC")) {
|
|
79
|
+
const apiKeyMsg = this.accountSid?.startsWith("SK")
|
|
78
80
|
? ". The given SID indicates an API Key which requires the accountSid to be passed as an additional option"
|
|
79
81
|
: "";
|
|
80
82
|
throw new Error("accountSid must start with AC" + apiKeyMsg);
|
|
81
83
|
}
|
|
82
84
|
}
|
|
85
|
+
setCredentialProvider(credentialProvider) {
|
|
86
|
+
this.credentialProvider = credentialProvider;
|
|
87
|
+
this.accountSid = "";
|
|
88
|
+
this.invalidateBasicAuth();
|
|
89
|
+
}
|
|
90
|
+
invalidateBasicAuth() {
|
|
91
|
+
this.username = undefined;
|
|
92
|
+
this.password = undefined;
|
|
93
|
+
}
|
|
94
|
+
invalidateOAuth() {
|
|
95
|
+
this.credentialProvider = undefined;
|
|
96
|
+
}
|
|
83
97
|
get httpClient() {
|
|
84
98
|
if (!this._httpClient) {
|
|
85
99
|
this._httpClient = new RequestClient_1.default({
|
|
@@ -116,6 +130,19 @@ var Twilio;
|
|
|
116
130
|
}
|
|
117
131
|
const username = opts.username || this.username;
|
|
118
132
|
const password = opts.password || this.password;
|
|
133
|
+
const authStrategy = opts.authStrategy || this.credentialProvider?.toAuthStrategy();
|
|
134
|
+
if (!authStrategy) {
|
|
135
|
+
if (!username) {
|
|
136
|
+
(() => {
|
|
137
|
+
throw new Error("username is required");
|
|
138
|
+
})();
|
|
139
|
+
}
|
|
140
|
+
if (!password) {
|
|
141
|
+
(() => {
|
|
142
|
+
throw new Error("password is required");
|
|
143
|
+
})();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
119
146
|
const headers = opts.headers || {};
|
|
120
147
|
const pkgVersion = moduleInfo.version;
|
|
121
148
|
const osName = os.platform();
|
|
@@ -130,7 +157,7 @@ var Twilio;
|
|
|
130
157
|
!headers["Content-Type"]) {
|
|
131
158
|
headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
132
159
|
}
|
|
133
|
-
if (!headers["Accept"]) {
|
|
160
|
+
if (opts.method !== "delete" && !headers["Accept"]) {
|
|
134
161
|
headers["Accept"] = "application/json";
|
|
135
162
|
}
|
|
136
163
|
var uri = new url.URL(opts.uri);
|
|
@@ -140,6 +167,7 @@ var Twilio;
|
|
|
140
167
|
uri: uri.href,
|
|
141
168
|
username: username,
|
|
142
169
|
password: password,
|
|
170
|
+
authStrategy: authStrategy,
|
|
143
171
|
headers: headers,
|
|
144
172
|
params: opts.params,
|
|
145
173
|
data: opts.data,
|
package/lib/base/Page.js
CHANGED
|
@@ -153,6 +153,9 @@ class Page {
|
|
|
153
153
|
if (keys.length === 1) {
|
|
154
154
|
return payload[keys[0]];
|
|
155
155
|
}
|
|
156
|
+
for (const key of keys)
|
|
157
|
+
if (Array.isArray(payload[key]))
|
|
158
|
+
return payload[key];
|
|
156
159
|
throw new Error("Page Records cannot be deserialized");
|
|
157
160
|
}
|
|
158
161
|
forOwn(obj, iteratee) {
|
|
@@ -4,6 +4,7 @@ import { HttpMethod } from "../interfaces";
|
|
|
4
4
|
import { AxiosInstance } from "axios";
|
|
5
5
|
import Response from "../http/response";
|
|
6
6
|
import Request, { Headers } from "../http/request";
|
|
7
|
+
import AuthStrategy from "../auth_strategy/AuthStrategy";
|
|
7
8
|
declare class RequestClient {
|
|
8
9
|
defaultTimeout: number;
|
|
9
10
|
axios: AxiosInstance;
|
|
@@ -35,6 +36,7 @@ declare class RequestClient {
|
|
|
35
36
|
* @param opts.uri - The request uri
|
|
36
37
|
* @param opts.username - The username used for auth
|
|
37
38
|
* @param opts.password - The password used for auth
|
|
39
|
+
* @param opts.authStrategy - The authStrategy for API call
|
|
38
40
|
* @param opts.headers - The request headers
|
|
39
41
|
* @param opts.params - The request params
|
|
40
42
|
* @param opts.data - The request data
|
|
@@ -65,6 +67,10 @@ declare namespace RequestClient {
|
|
|
65
67
|
* The password used for auth
|
|
66
68
|
*/
|
|
67
69
|
password?: string;
|
|
70
|
+
/**
|
|
71
|
+
* The AuthStrategy for API Call
|
|
72
|
+
*/
|
|
73
|
+
authStrategy?: AuthStrategy;
|
|
68
74
|
/**
|
|
69
75
|
* The request headers
|
|
70
76
|
*/
|
|
@@ -126,6 +126,7 @@ class RequestClient {
|
|
|
126
126
|
* @param opts.uri - The request uri
|
|
127
127
|
* @param opts.username - The username used for auth
|
|
128
128
|
* @param opts.password - The password used for auth
|
|
129
|
+
* @param opts.authStrategy - The authStrategy for API call
|
|
129
130
|
* @param opts.headers - The request headers
|
|
130
131
|
* @param opts.params - The request params
|
|
131
132
|
* @param opts.data - The request data
|
|
@@ -134,7 +135,7 @@ class RequestClient {
|
|
|
134
135
|
* @param opts.forever - Set to true to use the forever-agent
|
|
135
136
|
* @param opts.logLevel - Show debug logs
|
|
136
137
|
*/
|
|
137
|
-
request(opts) {
|
|
138
|
+
async request(opts) {
|
|
138
139
|
if (!opts.method) {
|
|
139
140
|
throw new Error("http method is required");
|
|
140
141
|
}
|
|
@@ -149,6 +150,9 @@ class RequestClient {
|
|
|
149
150
|
auth = Buffer.from(opts.username + ":" + opts.password).toString("base64");
|
|
150
151
|
headers.Authorization = "Basic " + auth;
|
|
151
152
|
}
|
|
153
|
+
else if (opts.authStrategy) {
|
|
154
|
+
headers.Authorization = await opts.authStrategy.getAuthString();
|
|
155
|
+
}
|
|
152
156
|
const options = {
|
|
153
157
|
timeout: opts.timeout || this.defaultTimeout,
|
|
154
158
|
maxRedirects: opts.allowRedirects ? 10 : 0,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import CredentialProvider from "./CredentialProvider";
|
|
2
|
+
import TokenManager from "../http/bearer_token/TokenManager";
|
|
3
|
+
import AuthStrategy from "../auth_strategy/AuthStrategy";
|
|
4
|
+
declare class ClientCredentialProvider extends CredentialProvider {
|
|
5
|
+
grantType: string;
|
|
6
|
+
clientId: string;
|
|
7
|
+
clientSecret: string;
|
|
8
|
+
tokenManager: TokenManager | null;
|
|
9
|
+
constructor();
|
|
10
|
+
toAuthStrategy(): AuthStrategy;
|
|
11
|
+
}
|
|
12
|
+
declare namespace ClientCredentialProvider {
|
|
13
|
+
class ClientCredentialProviderBuilder {
|
|
14
|
+
private readonly instance;
|
|
15
|
+
constructor();
|
|
16
|
+
setClientId(clientId: string): ClientCredentialProviderBuilder;
|
|
17
|
+
setClientSecret(clientSecret: string): ClientCredentialProviderBuilder;
|
|
18
|
+
setTokenManager(tokenManager: TokenManager): ClientCredentialProviderBuilder;
|
|
19
|
+
build(): ClientCredentialProvider;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export = ClientCredentialProvider;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const CredentialProvider_1 = __importDefault(require("./CredentialProvider"));
|
|
6
|
+
const ApiTokenManager_1 = __importDefault(require("../http/bearer_token/ApiTokenManager"));
|
|
7
|
+
const TokenAuthStrategy_1 = __importDefault(require("../auth_strategy/TokenAuthStrategy"));
|
|
8
|
+
class ClientCredentialProvider extends CredentialProvider_1.default {
|
|
9
|
+
constructor() {
|
|
10
|
+
super("client-credentials");
|
|
11
|
+
this.grantType = "client_credentials";
|
|
12
|
+
this.clientId = "";
|
|
13
|
+
this.clientSecret = "";
|
|
14
|
+
this.tokenManager = null;
|
|
15
|
+
}
|
|
16
|
+
toAuthStrategy() {
|
|
17
|
+
if (this.tokenManager == null) {
|
|
18
|
+
this.tokenManager = new ApiTokenManager_1.default({
|
|
19
|
+
grantType: this.grantType,
|
|
20
|
+
clientId: this.clientId,
|
|
21
|
+
clientSecret: this.clientSecret,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return new TokenAuthStrategy_1.default(this.tokenManager);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
(function (ClientCredentialProvider) {
|
|
28
|
+
class ClientCredentialProviderBuilder {
|
|
29
|
+
constructor() {
|
|
30
|
+
this.instance = new ClientCredentialProvider();
|
|
31
|
+
}
|
|
32
|
+
setClientId(clientId) {
|
|
33
|
+
this.instance.clientId = clientId;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
setClientSecret(clientSecret) {
|
|
37
|
+
this.instance.clientSecret = clientSecret;
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
setTokenManager(tokenManager) {
|
|
41
|
+
this.instance.tokenManager = tokenManager;
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
build() {
|
|
45
|
+
return this.instance;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
ClientCredentialProvider.ClientCredentialProviderBuilder = ClientCredentialProviderBuilder;
|
|
49
|
+
})(ClientCredentialProvider || (ClientCredentialProvider = {}));
|
|
50
|
+
module.exports = ClientCredentialProvider;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import CredentialProvider from "./CredentialProvider";
|
|
2
|
+
import AuthStrategy from "../auth_strategy/AuthStrategy";
|
|
3
|
+
declare namespace NoAuthCredentialProvider {
|
|
4
|
+
class NoAuthCredentialProvider extends CredentialProvider {
|
|
5
|
+
constructor();
|
|
6
|
+
toAuthStrategy(): AuthStrategy;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export = NoAuthCredentialProvider;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const CredentialProvider_1 = __importDefault(require("./CredentialProvider"));
|
|
6
|
+
const NoAuthStrategy_1 = __importDefault(require("../auth_strategy/NoAuthStrategy"));
|
|
7
|
+
var NoAuthCredentialProvider;
|
|
8
|
+
(function (NoAuthCredentialProvider_1) {
|
|
9
|
+
class NoAuthCredentialProvider extends CredentialProvider_1.default {
|
|
10
|
+
constructor() {
|
|
11
|
+
super("noauth");
|
|
12
|
+
}
|
|
13
|
+
toAuthStrategy() {
|
|
14
|
+
return new NoAuthStrategy_1.default();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
NoAuthCredentialProvider_1.NoAuthCredentialProvider = NoAuthCredentialProvider;
|
|
18
|
+
})(NoAuthCredentialProvider || (NoAuthCredentialProvider = {}));
|
|
19
|
+
module.exports = NoAuthCredentialProvider;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import CredentialProvider from "./CredentialProvider";
|
|
2
|
+
import TokenManager from "../http/bearer_token/TokenManager";
|
|
3
|
+
import AuthStrategy from "../auth_strategy/AuthStrategy";
|
|
4
|
+
declare class OrgsCredentialProvider extends CredentialProvider {
|
|
5
|
+
grantType: string;
|
|
6
|
+
clientId: string;
|
|
7
|
+
clientSecret: string;
|
|
8
|
+
tokenManager: TokenManager | null;
|
|
9
|
+
constructor();
|
|
10
|
+
toAuthStrategy(): AuthStrategy;
|
|
11
|
+
}
|
|
12
|
+
declare namespace OrgsCredentialProvider {
|
|
13
|
+
class OrgsCredentialProviderBuilder {
|
|
14
|
+
private readonly instance;
|
|
15
|
+
constructor();
|
|
16
|
+
setClientId(clientId: string): OrgsCredentialProviderBuilder;
|
|
17
|
+
setClientSecret(clientSecret: string): OrgsCredentialProviderBuilder;
|
|
18
|
+
setTokenManager(tokenManager: TokenManager): OrgsCredentialProviderBuilder;
|
|
19
|
+
build(): OrgsCredentialProvider;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export = OrgsCredentialProvider;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const CredentialProvider_1 = __importDefault(require("./CredentialProvider"));
|
|
6
|
+
const OrgsTokenManager_1 = __importDefault(require("../http/bearer_token/OrgsTokenManager"));
|
|
7
|
+
const TokenAuthStrategy_1 = __importDefault(require("../auth_strategy/TokenAuthStrategy"));
|
|
8
|
+
class OrgsCredentialProvider extends CredentialProvider_1.default {
|
|
9
|
+
constructor() {
|
|
10
|
+
super("client-credentials");
|
|
11
|
+
this.grantType = "client_credentials";
|
|
12
|
+
this.clientId = "";
|
|
13
|
+
this.clientSecret = "";
|
|
14
|
+
this.tokenManager = null;
|
|
15
|
+
}
|
|
16
|
+
toAuthStrategy() {
|
|
17
|
+
if (this.tokenManager == null) {
|
|
18
|
+
this.tokenManager = new OrgsTokenManager_1.default({
|
|
19
|
+
grantType: this.grantType,
|
|
20
|
+
clientId: this.clientId,
|
|
21
|
+
clientSecret: this.clientSecret,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return new TokenAuthStrategy_1.default(this.tokenManager);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
(function (OrgsCredentialProvider) {
|
|
28
|
+
class OrgsCredentialProviderBuilder {
|
|
29
|
+
constructor() {
|
|
30
|
+
this.instance = new OrgsCredentialProvider();
|
|
31
|
+
}
|
|
32
|
+
setClientId(clientId) {
|
|
33
|
+
this.instance.clientId = clientId;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
setClientSecret(clientSecret) {
|
|
37
|
+
this.instance.clientSecret = clientSecret;
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
setTokenManager(tokenManager) {
|
|
41
|
+
this.instance.tokenManager = tokenManager;
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
build() {
|
|
45
|
+
return this.instance;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
OrgsCredentialProvider.OrgsCredentialProviderBuilder = OrgsCredentialProviderBuilder;
|
|
49
|
+
})(OrgsCredentialProvider || (OrgsCredentialProvider = {}));
|
|
50
|
+
module.exports = OrgsCredentialProvider;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import TokenManager from "./TokenManager";
|
|
2
|
+
import { TokenListInstanceCreateOptions } from "../../rest/previewIam/v1/token";
|
|
3
|
+
export default class ApiTokenManager implements TokenManager {
|
|
4
|
+
private params;
|
|
5
|
+
constructor(params: TokenListInstanceCreateOptions);
|
|
6
|
+
getParams(): TokenListInstanceCreateOptions;
|
|
7
|
+
fetchToken(): Promise<string>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 token_1 = require("../../rest/previewIam/v1/token");
|
|
7
|
+
const PreviewIamBase_1 = __importDefault(require("../../rest/PreviewIamBase"));
|
|
8
|
+
const V1_1 = __importDefault(require("../../rest/previewIam/V1"));
|
|
9
|
+
const NoAuthCredentialProvider_1 = __importDefault(require("../../credential_provider/NoAuthCredentialProvider"));
|
|
10
|
+
const BaseTwilio_1 = require("../../base/BaseTwilio");
|
|
11
|
+
class ApiTokenManager {
|
|
12
|
+
constructor(params) {
|
|
13
|
+
this.params = params;
|
|
14
|
+
}
|
|
15
|
+
getParams() {
|
|
16
|
+
return this.params;
|
|
17
|
+
}
|
|
18
|
+
async fetchToken() {
|
|
19
|
+
const noAuthCredentialProvider = new NoAuthCredentialProvider_1.default.NoAuthCredentialProvider();
|
|
20
|
+
const client = new BaseTwilio_1.Client();
|
|
21
|
+
client.setCredentialProvider(noAuthCredentialProvider);
|
|
22
|
+
const tokenListInstance = (0, token_1.TokenListInstance)(new V1_1.default(new PreviewIamBase_1.default(client)));
|
|
23
|
+
return tokenListInstance
|
|
24
|
+
.create(this.params)
|
|
25
|
+
.then((token) => {
|
|
26
|
+
return token.accessToken;
|
|
27
|
+
})
|
|
28
|
+
.catch((error) => {
|
|
29
|
+
throw new Error(`Error Status Code: ${error.status}\nFailed to fetch access token: ${error.message}`);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.default = ApiTokenManager;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import TokenManager from "./TokenManager";
|
|
2
|
+
import { TokenListInstanceCreateOptions } from "../../rest/previewIam/v1/token";
|
|
3
|
+
export default class OrgsTokenManager implements TokenManager {
|
|
4
|
+
private readonly params;
|
|
5
|
+
constructor(params: TokenListInstanceCreateOptions);
|
|
6
|
+
getParams(): TokenListInstanceCreateOptions;
|
|
7
|
+
fetchToken(): Promise<string>;
|
|
8
|
+
}
|