rcs-js 2.0.0-rc.10 → 2.0.0-rc.12
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/dist/cjs/Client.d.ts +3 -0
- package/dist/cjs/Client.js +15 -10
- package/dist/cjs/api/resources/brands/client/Client.d.ts +2 -0
- package/dist/cjs/api/resources/brands/client/Client.js +6 -0
- package/dist/cjs/api/resources/campaigns/resources/dlc/client/Client.d.ts +6 -6
- package/dist/cjs/api/resources/campaigns/resources/dlc/client/Client.js +6 -6
- package/dist/cjs/api/resources/campaigns/resources/rcs/client/Client.d.ts +1 -0
- package/dist/cjs/api/resources/campaigns/resources/rcs/client/Client.js +3 -0
- package/dist/cjs/api/resources/campaigns/resources/rcs/client/requests/UpsertRcsCampaignParams.d.ts +2 -2
- package/dist/cjs/api/resources/index.d.ts +2 -0
- package/dist/cjs/api/resources/index.js +3 -1
- package/dist/cjs/api/resources/messages/client/Client.d.ts +3 -0
- package/dist/cjs/api/resources/messages/client/Client.js +9 -0
- package/dist/cjs/api/resources/messages/resources/mms/client/Client.d.ts +1 -0
- package/dist/cjs/api/resources/messages/resources/mms/client/Client.js +3 -0
- package/dist/cjs/api/resources/messages/resources/rcs/client/Client.d.ts +3 -2
- package/dist/cjs/api/resources/messages/resources/rcs/client/Client.js +4 -1
- package/dist/cjs/api/resources/messages/resources/sms/client/Client.d.ts +1 -0
- package/dist/cjs/api/resources/messages/resources/sms/client/Client.js +3 -0
- package/dist/cjs/api/resources/phoneNumbers/resources/campaign/client/Client.d.ts +2 -0
- package/dist/cjs/api/resources/phoneNumbers/resources/campaign/client/Client.js +6 -0
- package/dist/cjs/api/resources/phoneNumbers/resources/webhook/client/Client.d.ts +1 -0
- package/dist/cjs/api/resources/phoneNumbers/resources/webhook/client/Client.js +3 -0
- package/dist/cjs/api/resources/rcs/client/Client.d.ts +121 -0
- package/dist/cjs/api/resources/rcs/client/Client.js +320 -0
- package/dist/cjs/api/resources/rcs/client/index.d.ts +2 -0
- package/dist/cjs/api/resources/rcs/client/index.js +17 -0
- package/dist/cjs/api/resources/rcs/client/requests/RcsCapabilitiesQuery.d.ts +13 -0
- package/dist/cjs/api/resources/rcs/client/requests/RcsLinkRequest.d.ts +22 -0
- package/dist/cjs/api/resources/rcs/client/requests/RcsWhitelistRequest.d.ts +16 -0
- package/dist/cjs/api/resources/rcs/client/requests/index.d.ts +3 -0
- package/dist/cjs/api/resources/rcs/client/requests/index.js +2 -0
- package/dist/cjs/api/resources/rcs/index.d.ts +1 -0
- package/dist/cjs/api/resources/rcs/index.js +17 -0
- package/dist/cjs/api/resources/status/resources/get/client/Client.d.ts +2 -2
- package/dist/cjs/api/resources/status/resources/get/client/Client.js +2 -2
- package/dist/cjs/api/resources/tools/resources/file/client/Client.d.ts +21 -0
- package/dist/cjs/api/resources/tools/resources/file/client/Client.js +74 -0
- package/dist/cjs/api/resources/tools/resources/file/client/requests/RefreshFileParams.d.ts +21 -0
- package/dist/cjs/api/resources/tools/resources/file/client/requests/RefreshFileParams.js +5 -0
- package/dist/cjs/api/resources/tools/resources/file/client/requests/index.d.ts +1 -0
- package/dist/cjs/api/resources/tools/resources/url/client/Client.d.ts +1 -1
- package/dist/cjs/api/resources/tools/resources/url/client/Client.js +1 -1
- package/dist/cjs/api/types/AutofillDlcCampaignResponse.d.ts +11 -11
- package/dist/cjs/api/types/ButtonClicked.d.ts +11 -0
- package/dist/cjs/api/types/ButtonClicked.js +5 -0
- package/dist/cjs/api/types/ButtonClickedData.d.ts +56 -0
- package/dist/cjs/api/types/ButtonClickedData.js +16 -0
- package/dist/cjs/api/types/ConversationList.d.ts +4 -4
- package/dist/cjs/api/types/CreateUrlOptions.d.ts +1 -1
- package/dist/cjs/api/types/DlcCampaignStatus.d.ts +2 -2
- package/dist/cjs/api/types/DlcCampaignWithExtendedBrandAndStatus.d.ts +13 -10
- package/dist/cjs/api/types/ExtendedBrand.d.ts +7 -4
- package/dist/cjs/api/types/ExtendedRcsCampaign.d.ts +11 -10
- package/dist/cjs/api/types/MessageContent.d.ts +2 -2
- package/dist/cjs/api/types/MessageEvent.d.ts +56 -0
- package/dist/cjs/api/types/MessageEvent.js +13 -0
- package/dist/cjs/api/types/ProfileStatusEnum.d.ts +7 -4
- package/dist/cjs/api/types/RcsBase.d.ts +2 -0
- package/dist/cjs/api/types/RcsButtonCall.d.ts +2 -0
- package/dist/cjs/api/types/RcsButtonOpenUrl.d.ts +2 -0
- package/dist/cjs/api/types/RcsButtonRequestUserLocation.d.ts +2 -0
- package/dist/cjs/api/types/RcsButtonScheduleEvent.d.ts +2 -0
- package/dist/cjs/api/types/RcsButtonSendLocation.d.ts +2 -0
- package/dist/cjs/api/types/RcsButtonTrigger.d.ts +2 -2
- package/dist/cjs/api/types/RcsCampaign.d.ts +2 -2
- package/dist/cjs/api/types/RcsCapabilitiesResult.d.ts +8 -0
- package/dist/cjs/api/types/RcsCapabilitiesResult.js +5 -0
- package/dist/cjs/api/types/RcsCapability.d.ts +36 -0
- package/dist/cjs/api/types/RcsCapability.js +5 -0
- package/dist/cjs/api/types/RcsLinkResult.d.ts +13 -0
- package/dist/cjs/api/types/RcsLinkResult.js +5 -0
- package/dist/cjs/api/types/RcsValidateContent.d.ts +1 -0
- package/dist/cjs/api/types/RcsWhitelistResponse.d.ts +10 -0
- package/dist/cjs/api/types/RcsWhitelistResponse.js +5 -0
- package/dist/cjs/api/types/RefreshedFile.d.ts +9 -0
- package/dist/cjs/api/types/RefreshedFile.js +5 -0
- package/dist/cjs/api/types/{Rcs.d.ts → RichMessage.d.ts} +1 -1
- package/dist/cjs/api/types/RichMessage.js +5 -0
- package/dist/cjs/api/types/index.d.ts +9 -3
- package/dist/cjs/api/types/index.js +9 -3
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/wrapper/PinnacleClient.d.ts +9 -0
- package/dist/cjs/wrapper/PinnacleClient.js +17 -0
- package/dist/cjs/wrapper/messages/Client.d.ts +13 -0
- package/dist/cjs/wrapper/messages/Client.js +49 -0
- package/dist/cjs/wrapper/tools/Client.d.ts +6 -0
- package/dist/cjs/wrapper/tools/Client.js +12 -0
- package/dist/cjs/wrapper/tools/FileUploader.d.ts +15 -0
- package/dist/cjs/wrapper/tools/FileUploader.js +162 -0
- package/dist/esm/Client.d.mts +3 -0
- package/dist/esm/Client.mjs +7 -2
- package/dist/esm/api/resources/brands/client/Client.d.mts +2 -0
- package/dist/esm/api/resources/brands/client/Client.mjs +6 -0
- package/dist/esm/api/resources/campaigns/resources/dlc/client/Client.d.mts +6 -6
- package/dist/esm/api/resources/campaigns/resources/dlc/client/Client.mjs +6 -6
- package/dist/esm/api/resources/campaigns/resources/rcs/client/Client.d.mts +1 -0
- package/dist/esm/api/resources/campaigns/resources/rcs/client/Client.mjs +3 -0
- package/dist/esm/api/resources/campaigns/resources/rcs/client/requests/UpsertRcsCampaignParams.d.mts +2 -2
- package/dist/esm/api/resources/index.d.mts +2 -0
- package/dist/esm/api/resources/index.mjs +2 -0
- package/dist/esm/api/resources/messages/client/Client.d.mts +3 -0
- package/dist/esm/api/resources/messages/client/Client.mjs +9 -0
- package/dist/esm/api/resources/messages/resources/mms/client/Client.d.mts +1 -0
- package/dist/esm/api/resources/messages/resources/mms/client/Client.mjs +3 -0
- package/dist/esm/api/resources/messages/resources/rcs/client/Client.d.mts +3 -2
- package/dist/esm/api/resources/messages/resources/rcs/client/Client.mjs +4 -1
- package/dist/esm/api/resources/messages/resources/sms/client/Client.d.mts +1 -0
- package/dist/esm/api/resources/messages/resources/sms/client/Client.mjs +3 -0
- package/dist/esm/api/resources/phoneNumbers/resources/campaign/client/Client.d.mts +2 -0
- package/dist/esm/api/resources/phoneNumbers/resources/campaign/client/Client.mjs +6 -0
- package/dist/esm/api/resources/phoneNumbers/resources/webhook/client/Client.d.mts +1 -0
- package/dist/esm/api/resources/phoneNumbers/resources/webhook/client/Client.mjs +3 -0
- package/dist/esm/api/resources/rcs/client/Client.d.mts +121 -0
- package/dist/esm/api/resources/rcs/client/Client.mjs +283 -0
- package/dist/esm/api/resources/rcs/client/index.d.mts +2 -0
- package/dist/esm/api/resources/rcs/client/index.mjs +1 -0
- package/dist/esm/api/resources/rcs/client/requests/RcsCapabilitiesQuery.d.mts +13 -0
- package/dist/esm/api/resources/rcs/client/requests/RcsLinkRequest.d.mts +22 -0
- package/dist/esm/api/resources/rcs/client/requests/RcsWhitelistRequest.d.mts +16 -0
- package/dist/esm/api/resources/rcs/client/requests/index.d.mts +3 -0
- package/dist/esm/api/resources/rcs/client/requests/index.mjs +1 -0
- package/dist/esm/api/resources/rcs/index.d.mts +1 -0
- package/dist/esm/api/resources/rcs/index.mjs +1 -0
- package/dist/esm/api/resources/status/resources/get/client/Client.d.mts +2 -2
- package/dist/esm/api/resources/status/resources/get/client/Client.mjs +2 -2
- package/dist/esm/api/resources/tools/resources/file/client/Client.d.mts +21 -0
- package/dist/esm/api/resources/tools/resources/file/client/Client.mjs +74 -0
- package/dist/esm/api/resources/tools/resources/file/client/requests/RefreshFileParams.d.mts +21 -0
- package/dist/esm/api/resources/tools/resources/file/client/requests/RefreshFileParams.mjs +4 -0
- package/dist/esm/api/resources/tools/resources/file/client/requests/index.d.mts +1 -0
- package/dist/esm/api/resources/tools/resources/url/client/Client.d.mts +1 -1
- package/dist/esm/api/resources/tools/resources/url/client/Client.mjs +1 -1
- package/dist/esm/api/types/AutofillDlcCampaignResponse.d.mts +11 -11
- package/dist/esm/api/types/ButtonClicked.d.mts +11 -0
- package/dist/esm/api/types/ButtonClicked.mjs +4 -0
- package/dist/esm/api/types/ButtonClickedData.d.mts +56 -0
- package/dist/esm/api/types/ButtonClickedData.mjs +13 -0
- package/dist/esm/api/types/ConversationList.d.mts +4 -4
- package/dist/esm/api/types/CreateUrlOptions.d.mts +1 -1
- package/dist/esm/api/types/DlcCampaignStatus.d.mts +2 -2
- package/dist/esm/api/types/DlcCampaignWithExtendedBrandAndStatus.d.mts +13 -10
- package/dist/esm/api/types/ExtendedBrand.d.mts +7 -4
- package/dist/esm/api/types/ExtendedRcsCampaign.d.mts +11 -10
- package/dist/esm/api/types/MessageContent.d.mts +2 -2
- package/dist/esm/api/types/MessageEvent.d.mts +56 -0
- package/dist/esm/api/types/MessageEvent.mjs +10 -0
- package/dist/esm/api/types/ProfileStatusEnum.d.mts +7 -4
- package/dist/esm/api/types/RcsBase.d.mts +2 -0
- package/dist/esm/api/types/RcsButtonCall.d.mts +2 -0
- package/dist/esm/api/types/RcsButtonOpenUrl.d.mts +2 -0
- package/dist/esm/api/types/RcsButtonRequestUserLocation.d.mts +2 -0
- package/dist/esm/api/types/RcsButtonScheduleEvent.d.mts +2 -0
- package/dist/esm/api/types/RcsButtonSendLocation.d.mts +2 -0
- package/dist/esm/api/types/RcsButtonTrigger.d.mts +2 -2
- package/dist/esm/api/types/RcsCampaign.d.mts +2 -2
- package/dist/esm/api/types/RcsCapabilitiesResult.d.mts +8 -0
- package/dist/esm/api/types/RcsCapabilitiesResult.mjs +4 -0
- package/dist/esm/api/types/RcsCapability.d.mts +36 -0
- package/dist/esm/api/types/RcsCapability.mjs +4 -0
- package/dist/esm/api/types/RcsLinkResult.d.mts +13 -0
- package/dist/esm/api/types/RcsLinkResult.mjs +4 -0
- package/dist/esm/api/types/RcsValidateContent.d.mts +1 -0
- package/dist/esm/api/types/RcsWhitelistResponse.d.mts +10 -0
- package/dist/esm/api/types/RcsWhitelistResponse.mjs +4 -0
- package/dist/esm/api/types/RefreshedFile.d.mts +9 -0
- package/dist/esm/api/types/RefreshedFile.mjs +4 -0
- package/dist/esm/api/types/{Rcs.d.mts → RichMessage.d.mts} +1 -1
- package/dist/esm/api/types/RichMessage.mjs +4 -0
- package/dist/esm/api/types/index.d.mts +9 -3
- package/dist/esm/api/types/index.mjs +9 -3
- package/dist/esm/index.d.mts +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/dist/esm/wrapper/PinnacleClient.d.mts +9 -0
- package/dist/esm/wrapper/PinnacleClient.mjs +13 -0
- package/dist/esm/wrapper/messages/Client.d.mts +13 -0
- package/dist/esm/wrapper/messages/Client.mjs +45 -0
- package/dist/esm/wrapper/tools/Client.d.mts +6 -0
- package/dist/esm/wrapper/tools/Client.mjs +8 -0
- package/dist/esm/wrapper/tools/FileUploader.d.mts +15 -0
- package/dist/esm/wrapper/tools/FileUploader.mjs +125 -0
- package/package.json +7 -3
- package/reference.md +313 -10
- package/dist/cjs/api/types/ClickAction.d.ts +0 -28
- package/dist/cjs/api/types/InboundButton.d.ts +0 -11
- package/dist/esm/api/types/ClickAction.d.mts +0 -28
- package/dist/esm/api/types/InboundButton.d.mts +0 -11
- /package/dist/cjs/api/{types/ClickAction.js → resources/rcs/client/requests/RcsCapabilitiesQuery.js} +0 -0
- /package/dist/cjs/api/{types/InboundButton.js → resources/rcs/client/requests/RcsLinkRequest.js} +0 -0
- /package/dist/cjs/api/{types/Rcs.js → resources/rcs/client/requests/RcsWhitelistRequest.js} +0 -0
- /package/dist/esm/api/{types/ClickAction.mjs → resources/rcs/client/requests/RcsCapabilitiesQuery.mjs} +0 -0
- /package/dist/esm/api/{types/InboundButton.mjs → resources/rcs/client/requests/RcsLinkRequest.mjs} +0 -0
- /package/dist/esm/api/{types/Rcs.mjs → resources/rcs/client/requests/RcsWhitelistRequest.mjs} +0 -0
|
@@ -59,9 +59,9 @@ export * from "./RcsMediaDetailsContent.mjs";
|
|
|
59
59
|
export * from "./RcsMediaContent.mjs";
|
|
60
60
|
export * from "./RcsCardsContent.mjs";
|
|
61
61
|
export * from "./RcsContent.mjs";
|
|
62
|
-
export * from "./
|
|
62
|
+
export * from "./ButtonClickedData.mjs";
|
|
63
63
|
export * from "./LocationShareAction.mjs";
|
|
64
|
-
export * from "./
|
|
64
|
+
export * from "./ButtonClicked.mjs";
|
|
65
65
|
export * from "./MessageContent.mjs";
|
|
66
66
|
export * from "./MessageMethodEnum.mjs";
|
|
67
67
|
export * from "./MessageStatusEnum.mjs";
|
|
@@ -78,7 +78,7 @@ export * from "./RichTextMessage.mjs";
|
|
|
78
78
|
export * from "./RichMediaMessage.mjs";
|
|
79
79
|
export * from "./RcsCards.mjs";
|
|
80
80
|
export * from "./RichCardsMessage.mjs";
|
|
81
|
-
export * from "./
|
|
81
|
+
export * from "./RichMessage.mjs";
|
|
82
82
|
export * from "./SentRcsDetails.mjs";
|
|
83
83
|
export * from "./SmsValidationResult.mjs";
|
|
84
84
|
export * from "./MmsValidationResult.mjs";
|
|
@@ -102,6 +102,10 @@ export * from "./DetachedWebhookInfo.mjs";
|
|
|
102
102
|
export * from "./MessagingProfileEnum.mjs";
|
|
103
103
|
export * from "./AttachedPhoneNumberResult.mjs";
|
|
104
104
|
export * from "./DetachedPhoneNumberResult.mjs";
|
|
105
|
+
export * from "./RcsCapability.mjs";
|
|
106
|
+
export * from "./RcsCapabilitiesResult.mjs";
|
|
107
|
+
export * from "./RcsWhitelistResponse.mjs";
|
|
108
|
+
export * from "./RcsLinkResult.mjs";
|
|
105
109
|
export * from "./BrandStatus.mjs";
|
|
106
110
|
export * from "./TollFreeStatusEnum.mjs";
|
|
107
111
|
export * from "./TollFreeCampaignStatus.mjs";
|
|
@@ -115,6 +119,7 @@ export * from "./ShortenedUrl.mjs";
|
|
|
115
119
|
export * from "./LinkClickEvent.mjs";
|
|
116
120
|
export * from "./ShortenedUrlWithClickData.mjs";
|
|
117
121
|
export * from "./UploadResults.mjs";
|
|
122
|
+
export * from "./RefreshedFile.mjs";
|
|
118
123
|
export * from "./VcardAddress.mjs";
|
|
119
124
|
export * from "./VcardPhone.mjs";
|
|
120
125
|
export * from "./VcardEmail.mjs";
|
|
@@ -124,3 +129,4 @@ export * from "./VCardData.mjs";
|
|
|
124
129
|
export * from "./VcardResource.mjs";
|
|
125
130
|
export * from "./Webhooks.mjs";
|
|
126
131
|
export * from "./WebhookResult.mjs";
|
|
132
|
+
export * from "./MessageEvent.mjs";
|
package/dist/esm/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * as Pinnacle from "./api/index.mjs";
|
|
2
|
-
export { PinnacleClient } from "./
|
|
2
|
+
export { PinnacleClient } from "./wrapper/PinnacleClient.mjs";
|
|
3
3
|
export { PinnacleEnvironment } from "./environments.mjs";
|
|
4
4
|
export { PinnacleError, PinnacleTimeoutError } from "./errors/index.mjs";
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * as Pinnacle from "./api/index.mjs";
|
|
2
|
-
export { PinnacleClient } from "./
|
|
2
|
+
export { PinnacleClient } from "./wrapper/PinnacleClient.mjs";
|
|
3
3
|
export { PinnacleEnvironment } from "./environments.mjs";
|
|
4
4
|
export { PinnacleError, PinnacleTimeoutError } from "./errors/index.mjs";
|
package/dist/esm/version.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.0.0-rc.
|
|
1
|
+
export declare const SDK_VERSION = "2.0.0-rc.12";
|
package/dist/esm/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "2.0.0-rc.
|
|
1
|
+
export const SDK_VERSION = "2.0.0-rc.12";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PinnacleClient as FernClient } from "../Client";
|
|
2
|
+
import { EnhancedTools } from "./tools/Client.mjs";
|
|
3
|
+
import { EnhancedMessages } from "./messages/Client.mjs";
|
|
4
|
+
export declare class PinnacleClient extends FernClient {
|
|
5
|
+
protected _tools: EnhancedTools | undefined;
|
|
6
|
+
protected _messages: EnhancedMessages | undefined;
|
|
7
|
+
get tools(): EnhancedTools;
|
|
8
|
+
get messages(): EnhancedMessages;
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PinnacleClient as FernClient } from "../Client";
|
|
2
|
+
import { EnhancedTools } from "./tools/Client.mjs";
|
|
3
|
+
import { EnhancedMessages } from "./messages/Client.mjs";
|
|
4
|
+
export class PinnacleClient extends FernClient {
|
|
5
|
+
get tools() {
|
|
6
|
+
var _a;
|
|
7
|
+
return ((_a = this._tools) !== null && _a !== void 0 ? _a : (this._tools = new EnhancedTools(this._options)));
|
|
8
|
+
}
|
|
9
|
+
get messages() {
|
|
10
|
+
var _a;
|
|
11
|
+
return ((_a = this._messages) !== null && _a !== void 0 ? _a : (this._messages = new EnhancedMessages(this._options)));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Messages } from "../../api/resources/messages/client/Client.mjs";
|
|
2
|
+
import * as Pinnacle from "../../api/index.mjs";
|
|
3
|
+
interface ExpressLikeRequest {
|
|
4
|
+
headers: Record<string, string | string[] | undefined>;
|
|
5
|
+
body?: any;
|
|
6
|
+
get?: (name: string) => string | undefined;
|
|
7
|
+
protocol?: string;
|
|
8
|
+
originalUrl?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class EnhancedMessages extends Messages {
|
|
11
|
+
process(req: Request | ExpressLikeRequest, secret?: string): Promise<Pinnacle.MessageEvent>;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { Messages } from "../../api/resources/messages/client/Client.mjs";
|
|
11
|
+
import { UnauthorizedError } from "../../api/errors/index.mjs";
|
|
12
|
+
export class EnhancedMessages extends Messages {
|
|
13
|
+
process(req, secret) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
const signingSecret = secret || process.env.PINNACLE_SIGNING_SECRET;
|
|
17
|
+
let headerSecret;
|
|
18
|
+
let body;
|
|
19
|
+
if (req instanceof Request) {
|
|
20
|
+
headerSecret =
|
|
21
|
+
((_a = req.headers) === null || _a === void 0 ? void 0 : _a.get("PINNACLE-SIGNING-SECRET")) || ((_b = req.headers) === null || _b === void 0 ? void 0 : _b.get("pinnacle-signing-secret")) || undefined;
|
|
22
|
+
body = yield req.json();
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
const headers = req.headers;
|
|
26
|
+
headerSecret = headers["pinnacle-signing-secret"];
|
|
27
|
+
body = req.body;
|
|
28
|
+
}
|
|
29
|
+
if (!signingSecret) {
|
|
30
|
+
throw new UnauthorizedError({
|
|
31
|
+
error: "Make sure to set the PINNACLE-SIGNING-SECRET environment variable or pass the secret as an argument to the process method",
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (!headerSecret) {
|
|
35
|
+
throw new UnauthorizedError({
|
|
36
|
+
error: "Failed to get the PINNACLE-SIGNING-SECRET header from request",
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (headerSecret !== signingSecret) {
|
|
40
|
+
throw new UnauthorizedError({ error: "Invalid webhook signature" });
|
|
41
|
+
}
|
|
42
|
+
return body;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Tools } from '../../api/resources/tools/client/Client.mjs';
|
|
2
|
+
import { FileUploader } from './FileUploader.mjs';
|
|
3
|
+
export class EnhancedTools extends Tools {
|
|
4
|
+
get file() {
|
|
5
|
+
var _a;
|
|
6
|
+
return ((_a = this._fileUploader) !== null && _a !== void 0 ? _a : (this._fileUploader = new FileUploader(this._options)));
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { File_ } from "../../api/resources/tools/resources/file/client/Client.mjs";
|
|
2
|
+
import { UploadFileParams } from "../../api/resources/tools/resources/file/client/requests/index.mjs";
|
|
3
|
+
export declare class FileUploader extends File_ {
|
|
4
|
+
/**
|
|
5
|
+
* Upload a file from a file path (Node.js) or File object (browser)
|
|
6
|
+
* @param fileInput - File path string (Node.js) or File object (browser)
|
|
7
|
+
* @param options - Upload options
|
|
8
|
+
* @returns The download URL of the uploaded file
|
|
9
|
+
*/
|
|
10
|
+
uploadFromPath(fileInput: string | File, options?: {
|
|
11
|
+
name?: string;
|
|
12
|
+
options?: UploadFileParams.Options;
|
|
13
|
+
}): Promise<string>;
|
|
14
|
+
private getMimeType;
|
|
15
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import * as mime from "mime-types";
|
|
11
|
+
import { File_ } from "../../api/resources/tools/resources/file/client/Client.mjs";
|
|
12
|
+
import { BadRequestError, NotFoundError, InternalServerError } from "../../api/errors/index.mjs";
|
|
13
|
+
export class FileUploader extends File_ {
|
|
14
|
+
/**
|
|
15
|
+
* Upload a file from a file path (Node.js) or File object (browser)
|
|
16
|
+
* @param fileInput - File path string (Node.js) or File object (browser)
|
|
17
|
+
* @param options - Upload options
|
|
18
|
+
* @returns The download URL of the uploaded file
|
|
19
|
+
*/
|
|
20
|
+
uploadFromPath(fileInput, options) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
let size;
|
|
23
|
+
let fileName;
|
|
24
|
+
let contentType;
|
|
25
|
+
let blob;
|
|
26
|
+
if (typeof window === "undefined") {
|
|
27
|
+
if (typeof fileInput !== "string") {
|
|
28
|
+
throw new BadRequestError({ message: "In Node.js, fileInput must be a file path string" });
|
|
29
|
+
}
|
|
30
|
+
const fs = yield import("fs");
|
|
31
|
+
const path = yield import("path");
|
|
32
|
+
const filePath = fileInput;
|
|
33
|
+
let stats;
|
|
34
|
+
try {
|
|
35
|
+
stats = yield fs.promises.stat(filePath);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error.code === "ENOENT") {
|
|
39
|
+
throw new NotFoundError({ error: `File not found: ${filePath}` });
|
|
40
|
+
}
|
|
41
|
+
throw new InternalServerError({ error: `Failed to access file: ${error.message}` });
|
|
42
|
+
}
|
|
43
|
+
if (stats.isDirectory()) {
|
|
44
|
+
throw new BadRequestError({ message: `Path is a directory, not a file: ${filePath}` });
|
|
45
|
+
}
|
|
46
|
+
size = stats.size;
|
|
47
|
+
fileName = (options === null || options === void 0 ? void 0 : options.name) || path.default.basename(filePath);
|
|
48
|
+
contentType = this.getMimeType(filePath);
|
|
49
|
+
const fileBuffer = yield fs.promises.readFile(filePath);
|
|
50
|
+
const arrayBuffer = new Uint8Array(fileBuffer).buffer;
|
|
51
|
+
blob = new Blob([arrayBuffer], { type: contentType });
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
if (!(fileInput instanceof File)) {
|
|
55
|
+
throw new BadRequestError({ message: "In browser, fileInput must be a File object" });
|
|
56
|
+
}
|
|
57
|
+
const file = fileInput;
|
|
58
|
+
size = file.size;
|
|
59
|
+
fileName = (options === null || options === void 0 ? void 0 : options.name) || file.name;
|
|
60
|
+
contentType = file.type || this.getMimeType(file.name);
|
|
61
|
+
blob = file;
|
|
62
|
+
}
|
|
63
|
+
const uploadParams = {
|
|
64
|
+
contentType,
|
|
65
|
+
size,
|
|
66
|
+
name: fileName,
|
|
67
|
+
options: options === null || options === void 0 ? void 0 : options.options,
|
|
68
|
+
};
|
|
69
|
+
const uploadResult = yield this.upload(uploadParams);
|
|
70
|
+
if (uploadResult.uploadUrl) {
|
|
71
|
+
yield fetch(uploadResult.uploadUrl, {
|
|
72
|
+
method: "PUT",
|
|
73
|
+
body: blob,
|
|
74
|
+
headers: {
|
|
75
|
+
"Content-Type": contentType,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return uploadResult.downloadUrl;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
getMimeType(filePath) {
|
|
83
|
+
const mimeType = mime.lookup(filePath);
|
|
84
|
+
if (!mimeType) {
|
|
85
|
+
return "application/octet-stream";
|
|
86
|
+
}
|
|
87
|
+
const supportedTypes = new Set([
|
|
88
|
+
"audio/mpeg",
|
|
89
|
+
"audio/mp4",
|
|
90
|
+
"audio/ogg",
|
|
91
|
+
"audio/aac",
|
|
92
|
+
"audio/webm",
|
|
93
|
+
"audio/wav",
|
|
94
|
+
"audio/3gpp",
|
|
95
|
+
"audio/amr",
|
|
96
|
+
"video/mp4",
|
|
97
|
+
"video/mpeg",
|
|
98
|
+
"video/quicktime",
|
|
99
|
+
"video/webm",
|
|
100
|
+
"video/3gpp",
|
|
101
|
+
"video/H264",
|
|
102
|
+
"video/x-m4v",
|
|
103
|
+
"image/jpeg",
|
|
104
|
+
"image/png",
|
|
105
|
+
"image/gif",
|
|
106
|
+
"image/bmp",
|
|
107
|
+
"image/tiff",
|
|
108
|
+
"image/webp",
|
|
109
|
+
"application/pdf",
|
|
110
|
+
"text/csv",
|
|
111
|
+
"application/rtf",
|
|
112
|
+
"text/vcard",
|
|
113
|
+
"text/calendar",
|
|
114
|
+
]);
|
|
115
|
+
if (supportedTypes.has(mimeType)) {
|
|
116
|
+
return mimeType;
|
|
117
|
+
}
|
|
118
|
+
const baseType = mimeType.split("/")[0];
|
|
119
|
+
if (["audio", "video", "image"].includes(baseType)) {
|
|
120
|
+
console.warn(`MIME type ${mimeType} may not be fully supported. Proceeding anyway.`);
|
|
121
|
+
return mimeType;
|
|
122
|
+
}
|
|
123
|
+
return "application/octet-stream";
|
|
124
|
+
}
|
|
125
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rcs-js",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.12",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": "github:pinnacle-dev/rcs-js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -38,6 +38,9 @@
|
|
|
38
38
|
"test:browser": "jest --selectProjects browser",
|
|
39
39
|
"test:wire": "jest --selectProjects wire"
|
|
40
40
|
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"mime-types": "^3.0.1"
|
|
43
|
+
},
|
|
41
44
|
"devDependencies": {
|
|
42
45
|
"webpack": "^5.97.1",
|
|
43
46
|
"ts-loader": "^9.5.1",
|
|
@@ -49,7 +52,8 @@
|
|
|
49
52
|
"msw": "^2.8.4",
|
|
50
53
|
"@types/node": "^18.19.70",
|
|
51
54
|
"prettier": "^3.4.2",
|
|
52
|
-
"typescript": "~5.7.2"
|
|
55
|
+
"typescript": "~5.7.2",
|
|
56
|
+
"@types/mime-types": "^3.0.1"
|
|
53
57
|
},
|
|
54
58
|
"browser": {
|
|
55
59
|
"fs": false,
|
|
@@ -62,4 +66,4 @@
|
|
|
62
66
|
"node": ">=18.0.0"
|
|
63
67
|
},
|
|
64
68
|
"sideEffects": false
|
|
65
|
-
}
|
|
69
|
+
}
|