piece-signal-cli-rest-api 0.2.0 → 0.2.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/package.json +26 -4
- package/src/index.d.ts +8 -0
- package/src/index.js +90 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/add-admins-to-group.d.ts +12 -0
- package/src/lib/actions/add-admins-to-group.js +45 -0
- package/src/lib/actions/add-admins-to-group.js.map +1 -0
- package/src/lib/actions/add-device.d.ts +11 -0
- package/src/lib/actions/add-device.js +40 -0
- package/src/lib/actions/add-device.js.map +1 -0
- package/src/lib/actions/add-members-to-group.d.ts +12 -0
- package/src/lib/actions/add-members-to-group.js +45 -0
- package/src/lib/actions/add-members-to-group.js.map +1 -0
- package/src/lib/actions/block-group.d.ts +11 -0
- package/src/lib/actions/block-group.js +37 -0
- package/src/lib/actions/block-group.js.map +1 -0
- package/src/lib/actions/create-group.d.ts +18 -0
- package/src/lib/actions/create-group.js +117 -0
- package/src/lib/actions/create-group.js.map +1 -0
- package/src/lib/actions/delete-group.d.ts +11 -0
- package/src/lib/actions/delete-group.js +37 -0
- package/src/lib/actions/delete-group.js.map +1 -0
- package/src/lib/actions/get-contact.d.ts +11 -0
- package/src/lib/actions/get-contact.js +37 -0
- package/src/lib/actions/get-contact.js.map +1 -0
- package/src/lib/actions/get-group.d.ts +11 -0
- package/src/lib/actions/get-group.js +37 -0
- package/src/lib/actions/get-group.js.map +1 -0
- package/src/lib/actions/get-qr-code-link.d.ts +11 -0
- package/src/lib/actions/get-qr-code-link.js +60 -0
- package/src/lib/actions/get-qr-code-link.js.map +1 -0
- package/src/lib/actions/join-group.d.ts +11 -0
- package/src/lib/actions/join-group.js +37 -0
- package/src/lib/actions/join-group.js.map +1 -0
- package/src/lib/actions/list-accounts.d.ts +8 -0
- package/src/lib/actions/list-accounts.js +23 -0
- package/src/lib/actions/list-accounts.js.map +1 -0
- package/src/lib/actions/list-attachments.d.ts +8 -0
- package/src/lib/actions/list-attachments.js +23 -0
- package/src/lib/actions/list-attachments.js.map +1 -0
- package/src/lib/actions/list-contacts.d.ts +10 -0
- package/src/lib/actions/list-contacts.js +32 -0
- package/src/lib/actions/list-contacts.js.map +1 -0
- package/src/lib/actions/list-devices.d.ts +10 -0
- package/src/lib/actions/list-devices.js +32 -0
- package/src/lib/actions/list-devices.js.map +1 -0
- package/src/lib/actions/list-groups.d.ts +10 -0
- package/src/lib/actions/list-groups.js +32 -0
- package/src/lib/actions/list-groups.js.map +1 -0
- package/src/lib/actions/list-identities.d.ts +10 -0
- package/src/lib/actions/list-identities.js +32 -0
- package/src/lib/actions/list-identities.js.map +1 -0
- package/src/lib/actions/quit-group.d.ts +11 -0
- package/src/lib/actions/quit-group.js +37 -0
- package/src/lib/actions/quit-group.js.map +1 -0
- package/src/lib/actions/receive-messages.d.ts +15 -0
- package/src/lib/actions/receive-messages.js +100 -0
- package/src/lib/actions/receive-messages.js.map +1 -0
- package/src/lib/actions/remote-delete-message.d.ts +12 -0
- package/src/lib/actions/remote-delete-message.js +46 -0
- package/src/lib/actions/remote-delete-message.js.map +1 -0
- package/src/lib/actions/remove-admins-from-group.d.ts +12 -0
- package/src/lib/actions/remove-admins-from-group.js +45 -0
- package/src/lib/actions/remove-admins-from-group.js.map +1 -0
- package/src/lib/actions/remove-device.d.ts +11 -0
- package/src/lib/actions/remove-device.js +37 -0
- package/src/lib/actions/remove-device.js.map +1 -0
- package/src/lib/actions/remove-members-from-group.d.ts +12 -0
- package/src/lib/actions/remove-members-from-group.js +45 -0
- package/src/lib/actions/remove-members-from-group.js.map +1 -0
- package/src/lib/actions/remove-reaction.d.ts +13 -0
- package/src/lib/actions/remove-reaction.js +52 -0
- package/src/lib/actions/remove-reaction.js.map +1 -0
- package/src/lib/actions/request-approval-message.d.ts +15 -0
- package/src/lib/actions/request-approval-message.js +184 -0
- package/src/lib/actions/request-approval-message.js.map +1 -0
- package/src/lib/actions/resume-approval-flow.d.ts +11 -0
- package/src/lib/actions/resume-approval-flow.js +181 -0
- package/src/lib/actions/resume-approval-flow.js.map +1 -0
- package/src/lib/actions/search-numbers.d.ts +11 -0
- package/src/lib/actions/search-numbers.js +42 -0
- package/src/lib/actions/search-numbers.js.map +1 -0
- package/src/lib/actions/send-message.d.ts +27 -0
- package/src/lib/actions/send-message.js +176 -0
- package/src/lib/actions/send-message.js.map +1 -0
- package/src/lib/actions/send-reaction.d.ts +14 -0
- package/src/lib/actions/send-reaction.js +58 -0
- package/src/lib/actions/send-reaction.js.map +1 -0
- package/src/lib/actions/send-receipt.d.ts +13 -0
- package/src/lib/actions/send-receipt.js +58 -0
- package/src/lib/actions/send-receipt.js.map +1 -0
- package/src/lib/actions/start-typing.d.ts +11 -0
- package/src/lib/actions/start-typing.js +40 -0
- package/src/lib/actions/start-typing.js.map +1 -0
- package/src/lib/actions/stop-typing.d.ts +11 -0
- package/src/lib/actions/stop-typing.js +40 -0
- package/src/lib/actions/stop-typing.js.map +1 -0
- package/src/lib/actions/sync-contacts.d.ts +10 -0
- package/src/lib/actions/sync-contacts.js +32 -0
- package/src/lib/actions/sync-contacts.js.map +1 -0
- package/src/lib/actions/update-account-settings.d.ts +12 -0
- package/src/lib/actions/update-account-settings.js +49 -0
- package/src/lib/actions/update-account-settings.js.map +1 -0
- package/src/lib/actions/update-contact.d.ts +13 -0
- package/src/lib/actions/update-contact.js +56 -0
- package/src/lib/actions/update-contact.js.map +1 -0
- package/src/lib/actions/update-group.d.ts +19 -0
- package/src/lib/actions/update-group.js +125 -0
- package/src/lib/actions/update-group.js.map +1 -0
- package/src/lib/actions/update-profile.d.ts +13 -0
- package/src/lib/actions/update-profile.js +56 -0
- package/src/lib/actions/update-profile.js.map +1 -0
- package/src/lib/common/api-client.d.ts +24 -0
- package/src/lib/common/api-client.js +103 -0
- package/src/lib/common/api-client.js.map +1 -0
- package/src/lib/common/auth.d.ts +8 -0
- package/src/lib/common/auth.js +68 -0
- package/src/lib/common/auth.js.map +1 -0
- package/src/lib/common/message-utils.d.ts +81 -0
- package/src/lib/common/message-utils.js +327 -0
- package/src/lib/common/message-utils.js.map +1 -0
- package/src/lib/common/types.d.ts +65 -0
- package/src/lib/common/types.js +3 -0
- package/src/lib/common/types.js.map +1 -0
- package/src/lib/common/utils.d.ts +23 -0
- package/src/lib/common/utils.js +105 -0
- package/src/lib/common/utils.js.map +1 -0
- package/src/lib/triggers/new-group-member.d.ts +50 -0
- package/src/lib/triggers/new-group-member.js +155 -0
- package/src/lib/triggers/new-group-member.js.map +1 -0
- package/src/lib/triggers/new-message-received.d.ts +58 -0
- package/src/lib/triggers/new-message-received.js +469 -0
- package/src/lib/triggers/new-message-received.js.map +1 -0
- package/project.json +0 -58
- package/src/index.ts +0 -87
- package/src/lib/actions/add-admins-to-group.ts +0 -50
- package/src/lib/actions/add-device.ts +0 -45
- package/src/lib/actions/add-members-to-group.ts +0 -50
- package/src/lib/actions/block-group.ts +0 -36
- package/src/lib/actions/create-group.ts +0 -139
- package/src/lib/actions/delete-group.ts +0 -36
- package/src/lib/actions/get-contact.ts +0 -42
- package/src/lib/actions/get-group.ts +0 -37
- package/src/lib/actions/get-qr-code-link.ts +0 -62
- package/src/lib/actions/join-group.ts +0 -36
- package/src/lib/actions/list-accounts.ts +0 -20
- package/src/lib/actions/list-attachments.ts +0 -20
- package/src/lib/actions/list-contacts.ts +0 -37
- package/src/lib/actions/list-devices.ts +0 -38
- package/src/lib/actions/list-groups.ts +0 -32
- package/src/lib/actions/list-identities.ts +0 -32
- package/src/lib/actions/quit-group.ts +0 -36
- package/src/lib/actions/receive-messages.ts +0 -108
- package/src/lib/actions/remote-delete-message.ts +0 -56
- package/src/lib/actions/remove-admins-from-group.ts +0 -50
- package/src/lib/actions/remove-device.ts +0 -36
- package/src/lib/actions/remove-members-from-group.ts +0 -50
- package/src/lib/actions/remove-reaction.ts +0 -59
- package/src/lib/actions/request-approval-message.ts +0 -215
- package/src/lib/actions/search-numbers.ts +0 -47
- package/src/lib/actions/send-message.ts +0 -189
- package/src/lib/actions/send-reaction.ts +0 -66
- package/src/lib/actions/send-receipt.ts +0 -65
- package/src/lib/actions/start-typing.ts +0 -45
- package/src/lib/actions/stop-typing.ts +0 -45
- package/src/lib/actions/sync-contacts.ts +0 -31
- package/src/lib/actions/update-account-settings.ts +0 -57
- package/src/lib/actions/update-contact.ts +0 -65
- package/src/lib/actions/update-group.ts +0 -145
- package/src/lib/actions/update-profile.ts +0 -65
- package/src/lib/common/api-client.ts +0 -150
- package/src/lib/common/auth.ts +0 -66
- package/src/lib/common/message-utils.ts +0 -449
- package/src/lib/common/types.ts +0 -73
- package/src/lib/common/utils.ts +0 -106
- package/src/lib/triggers/new-group-member.ts +0 -176
- package/src/lib/triggers/new-message-received.ts +0 -618
- package/tsconfig.json +0 -19
- package/tsconfig.lib.json +0 -11
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { createAction, Property } from '@activepieces/pieces-framework';
|
|
2
|
-
import { signalCliRestApiAuth } from '../common/auth';
|
|
3
|
-
import { SignalCliApiClient } from '../common/api-client';
|
|
4
|
-
import { formatPhoneNumber } from '../common/utils';
|
|
5
|
-
|
|
6
|
-
interface UpdateGroupRequest {
|
|
7
|
-
base64_avatar?: string;
|
|
8
|
-
description?: string;
|
|
9
|
-
name?: string;
|
|
10
|
-
expiration_time?: number;
|
|
11
|
-
group_link?: 'disabled' | 'enabled' | 'enabled-with-approval';
|
|
12
|
-
permissions?: {
|
|
13
|
-
add_members: 'every-member' | 'only-admins';
|
|
14
|
-
edit_group: 'every-member' | 'only-admins';
|
|
15
|
-
send_messages: 'every-member' | 'only-admins';
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const updateGroup = createAction({
|
|
20
|
-
auth: signalCliRestApiAuth,
|
|
21
|
-
name: 'updateGroup',
|
|
22
|
-
displayName: 'Update Group',
|
|
23
|
-
description: 'Update a Signal group',
|
|
24
|
-
props: {
|
|
25
|
-
number: Property.ShortText({
|
|
26
|
-
displayName: 'Phone Number',
|
|
27
|
-
description: 'Registered phone number in international format',
|
|
28
|
-
required: true,
|
|
29
|
-
}),
|
|
30
|
-
groupid: Property.ShortText({
|
|
31
|
-
displayName: 'Group ID',
|
|
32
|
-
description: 'Group ID (base64 encoded)',
|
|
33
|
-
required: true,
|
|
34
|
-
}),
|
|
35
|
-
name: Property.ShortText({
|
|
36
|
-
displayName: 'Group Name',
|
|
37
|
-
description: 'New name of the group',
|
|
38
|
-
required: false,
|
|
39
|
-
}),
|
|
40
|
-
description: Property.LongText({
|
|
41
|
-
displayName: 'Description',
|
|
42
|
-
description: 'New group description',
|
|
43
|
-
required: false,
|
|
44
|
-
}),
|
|
45
|
-
base64_avatar: Property.LongText({
|
|
46
|
-
displayName: 'Avatar (Base64)',
|
|
47
|
-
description: 'Base64-encoded avatar image',
|
|
48
|
-
required: false,
|
|
49
|
-
}),
|
|
50
|
-
add_members_permission: Property.StaticDropdown({
|
|
51
|
-
displayName: 'Add Members Permission',
|
|
52
|
-
description: 'Who can add members',
|
|
53
|
-
required: false,
|
|
54
|
-
options: {
|
|
55
|
-
options: [
|
|
56
|
-
{ label: 'Every Member', value: 'every-member' },
|
|
57
|
-
{ label: 'Only Admins', value: 'only-admins' },
|
|
58
|
-
],
|
|
59
|
-
},
|
|
60
|
-
}),
|
|
61
|
-
edit_group_permission: Property.StaticDropdown({
|
|
62
|
-
displayName: 'Edit Group Permission',
|
|
63
|
-
description: 'Who can edit the group',
|
|
64
|
-
required: false,
|
|
65
|
-
options: {
|
|
66
|
-
options: [
|
|
67
|
-
{ label: 'Every Member', value: 'every-member' },
|
|
68
|
-
{ label: 'Only Admins', value: 'only-admins' },
|
|
69
|
-
],
|
|
70
|
-
},
|
|
71
|
-
}),
|
|
72
|
-
send_messages_permission: Property.StaticDropdown({
|
|
73
|
-
displayName: 'Send Messages Permission',
|
|
74
|
-
description: 'Who can send messages',
|
|
75
|
-
required: false,
|
|
76
|
-
options: {
|
|
77
|
-
options: [
|
|
78
|
-
{ label: 'Every Member', value: 'every-member' },
|
|
79
|
-
{ label: 'Only Admins', value: 'only-admins' },
|
|
80
|
-
],
|
|
81
|
-
},
|
|
82
|
-
}),
|
|
83
|
-
group_link: Property.StaticDropdown({
|
|
84
|
-
displayName: 'Group Link',
|
|
85
|
-
description: 'Group link state',
|
|
86
|
-
required: false,
|
|
87
|
-
options: {
|
|
88
|
-
options: [
|
|
89
|
-
{ label: 'Disabled', value: 'disabled' },
|
|
90
|
-
{ label: 'Enabled', value: 'enabled' },
|
|
91
|
-
{ label: 'Enabled with Approval', value: 'enabled-with-approval' },
|
|
92
|
-
],
|
|
93
|
-
},
|
|
94
|
-
}),
|
|
95
|
-
expiration_time: Property.Number({
|
|
96
|
-
displayName: 'Expiration Time',
|
|
97
|
-
description: 'Message expiration time in seconds',
|
|
98
|
-
required: false,
|
|
99
|
-
}),
|
|
100
|
-
},
|
|
101
|
-
async run(context) {
|
|
102
|
-
const { number, groupid, name, description, base64_avatar, add_members_permission, edit_group_permission, send_messages_permission, group_link, expiration_time } = context.propsValue;
|
|
103
|
-
// Auth props are passed directly to API client
|
|
104
|
-
|
|
105
|
-
const apiClient = new SignalCliApiClient(context.auth.props);
|
|
106
|
-
const formattedNumber = formatPhoneNumber(number);
|
|
107
|
-
|
|
108
|
-
const requestBody: UpdateGroupRequest = {};
|
|
109
|
-
|
|
110
|
-
if (name) {
|
|
111
|
-
requestBody.name = name;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (description) {
|
|
115
|
-
requestBody.description = description;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (base64_avatar) {
|
|
119
|
-
requestBody.base64_avatar = base64_avatar;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (add_members_permission || edit_group_permission || send_messages_permission) {
|
|
123
|
-
requestBody.permissions = {
|
|
124
|
-
add_members: (add_members_permission as 'every-member' | 'only-admins') || 'every-member',
|
|
125
|
-
edit_group: (edit_group_permission as 'every-member' | 'only-admins') || 'every-member',
|
|
126
|
-
send_messages: (send_messages_permission as 'every-member' | 'only-admins') || 'every-member',
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (group_link) {
|
|
131
|
-
requestBody.group_link = group_link as 'disabled' | 'enabled' | 'enabled-with-approval';
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (expiration_time) {
|
|
135
|
-
requestBody.expiration_time = expiration_time;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
await apiClient.put(
|
|
139
|
-
`/v1/groups/${encodeURIComponent(formattedNumber)}/${encodeURIComponent(groupid)}`,
|
|
140
|
-
requestBody
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
return { success: true };
|
|
144
|
-
},
|
|
145
|
-
});
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { createAction, Property } from '@activepieces/pieces-framework';
|
|
2
|
-
import { signalCliRestApiAuth } from '../common/auth';
|
|
3
|
-
import { SignalCliApiClient } from '../common/api-client';
|
|
4
|
-
import { formatPhoneNumber, normalizeBase64Attachment } from '../common/utils';
|
|
5
|
-
|
|
6
|
-
interface UpdateProfileRequest {
|
|
7
|
-
name: string;
|
|
8
|
-
base64_avatar?: string;
|
|
9
|
-
about?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const updateProfile = createAction({
|
|
13
|
-
auth: signalCliRestApiAuth,
|
|
14
|
-
name: 'updateProfile',
|
|
15
|
-
displayName: 'Update Profile',
|
|
16
|
-
description: 'Update your Signal profile (name, avatar, about)',
|
|
17
|
-
props: {
|
|
18
|
-
number: Property.ShortText({
|
|
19
|
-
displayName: 'Phone Number',
|
|
20
|
-
description: 'Registered phone number in international format',
|
|
21
|
-
required: true,
|
|
22
|
-
}),
|
|
23
|
-
name: Property.ShortText({
|
|
24
|
-
displayName: 'Name',
|
|
25
|
-
description: 'Profile name',
|
|
26
|
-
required: true,
|
|
27
|
-
}),
|
|
28
|
-
base64_avatar: Property.LongText({
|
|
29
|
-
displayName: 'Avatar (Base64)',
|
|
30
|
-
description: 'Base64-encoded avatar image',
|
|
31
|
-
required: false,
|
|
32
|
-
}),
|
|
33
|
-
about: Property.LongText({
|
|
34
|
-
displayName: 'About',
|
|
35
|
-
description: 'About text',
|
|
36
|
-
required: false,
|
|
37
|
-
}),
|
|
38
|
-
},
|
|
39
|
-
async run(context) {
|
|
40
|
-
const { number, name, base64_avatar, about } = context.propsValue;
|
|
41
|
-
// Auth props are passed directly to API client
|
|
42
|
-
|
|
43
|
-
const apiClient = new SignalCliApiClient(context.auth.props);
|
|
44
|
-
const formattedNumber = formatPhoneNumber(number);
|
|
45
|
-
|
|
46
|
-
const requestBody: UpdateProfileRequest = {
|
|
47
|
-
name,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
if (base64_avatar) {
|
|
51
|
-
requestBody.base64_avatar = normalizeBase64Attachment(base64_avatar);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (about) {
|
|
55
|
-
requestBody.about = about;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
await apiClient.put(
|
|
59
|
-
`/v1/profiles/${encodeURIComponent(formattedNumber)}`,
|
|
60
|
-
requestBody
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
return { success: true };
|
|
64
|
-
},
|
|
65
|
-
});
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { httpClient, HttpMethod, HttpRequest } from '@activepieces/pieces-common';
|
|
2
|
-
import { ErrorResponse } from './types';
|
|
3
|
-
|
|
4
|
-
export class SignalCliApiError extends Error {
|
|
5
|
-
constructor(
|
|
6
|
-
message: string,
|
|
7
|
-
public statusCode?: number,
|
|
8
|
-
public challengeTokens?: string[],
|
|
9
|
-
public account?: string
|
|
10
|
-
) {
|
|
11
|
-
super(message);
|
|
12
|
-
this.name = 'SignalCliApiError';
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface SignalCliAuthProps {
|
|
17
|
-
baseUrl: string;
|
|
18
|
-
useBasicAuth?: boolean;
|
|
19
|
-
basicAuthUsername?: string;
|
|
20
|
-
basicAuthPassword?: string;
|
|
21
|
-
defaultNumber?: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class SignalCliApiClient {
|
|
25
|
-
private baseUrl: string;
|
|
26
|
-
private basicAuthHeader?: string;
|
|
27
|
-
|
|
28
|
-
constructor(auth: SignalCliAuthProps) {
|
|
29
|
-
// Remove trailing slash
|
|
30
|
-
this.baseUrl = auth.baseUrl.replace(/\/$/, '');
|
|
31
|
-
|
|
32
|
-
// Setup Basic Auth if enabled
|
|
33
|
-
if (auth.useBasicAuth && auth.basicAuthUsername && auth.basicAuthPassword) {
|
|
34
|
-
const credentials = Buffer.from(
|
|
35
|
-
`${auth.basicAuthUsername}:${auth.basicAuthPassword}`
|
|
36
|
-
).toString('base64');
|
|
37
|
-
this.basicAuthHeader = `Basic ${credentials}`;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async sendRequest<T>(request: HttpRequest): Promise<T> {
|
|
42
|
-
try {
|
|
43
|
-
const headers = {
|
|
44
|
-
...request.headers,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// Add Basic Auth header if configured
|
|
48
|
-
if (this.basicAuthHeader) {
|
|
49
|
-
headers['Authorization'] = this.basicAuthHeader;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const response = await httpClient.sendRequest<T | ErrorResponse>({
|
|
53
|
-
...request,
|
|
54
|
-
url: `${this.baseUrl}${request.url}`,
|
|
55
|
-
headers,
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// Check for error response
|
|
59
|
-
if (response.status === 429) {
|
|
60
|
-
// Rate limit error
|
|
61
|
-
const error = response.body as ErrorResponse;
|
|
62
|
-
throw new SignalCliApiError(
|
|
63
|
-
error.error || 'Rate limit exceeded',
|
|
64
|
-
429,
|
|
65
|
-
error.challenge_tokens,
|
|
66
|
-
error.account
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (response.status >= 400) {
|
|
71
|
-
const error = response.body as ErrorResponse;
|
|
72
|
-
throw new SignalCliApiError(
|
|
73
|
-
error.error || `HTTP ${response.status}`,
|
|
74
|
-
response.status
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if ('error' in (response.body || {})) {
|
|
79
|
-
const error = response.body as ErrorResponse;
|
|
80
|
-
throw new SignalCliApiError(error.error || 'Unknown error occurred');
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return response.body as T;
|
|
84
|
-
} catch (error) {
|
|
85
|
-
if (error instanceof SignalCliApiError) {
|
|
86
|
-
throw error;
|
|
87
|
-
}
|
|
88
|
-
if (error instanceof Error) {
|
|
89
|
-
throw new SignalCliApiError(error.message);
|
|
90
|
-
}
|
|
91
|
-
throw new SignalCliApiError('Unknown error occurred');
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
async get<T>(url: string, headers?: Record<string, string>): Promise<T> {
|
|
96
|
-
return this.sendRequest<T>({
|
|
97
|
-
method: HttpMethod.GET,
|
|
98
|
-
url,
|
|
99
|
-
headers,
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async post<T>(
|
|
104
|
-
url: string,
|
|
105
|
-
body?: unknown,
|
|
106
|
-
headers?: Record<string, string>
|
|
107
|
-
): Promise<T> {
|
|
108
|
-
return this.sendRequest<T>({
|
|
109
|
-
method: HttpMethod.POST,
|
|
110
|
-
url,
|
|
111
|
-
body,
|
|
112
|
-
headers: {
|
|
113
|
-
'Content-Type': 'application/json',
|
|
114
|
-
...headers,
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
async put<T>(
|
|
120
|
-
url: string,
|
|
121
|
-
body?: unknown,
|
|
122
|
-
headers?: Record<string, string>
|
|
123
|
-
): Promise<T> {
|
|
124
|
-
return this.sendRequest<T>({
|
|
125
|
-
method: HttpMethod.PUT,
|
|
126
|
-
url,
|
|
127
|
-
body,
|
|
128
|
-
headers: {
|
|
129
|
-
'Content-Type': 'application/json',
|
|
130
|
-
...headers,
|
|
131
|
-
},
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
async delete<T>(
|
|
136
|
-
url: string,
|
|
137
|
-
body?: unknown,
|
|
138
|
-
headers?: Record<string, string>
|
|
139
|
-
): Promise<T> {
|
|
140
|
-
return this.sendRequest<T>({
|
|
141
|
-
method: HttpMethod.DELETE,
|
|
142
|
-
url,
|
|
143
|
-
body,
|
|
144
|
-
headers: {
|
|
145
|
-
'Content-Type': 'application/json',
|
|
146
|
-
...headers,
|
|
147
|
-
},
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
}
|
package/src/lib/common/auth.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { PieceAuth, Property } from '@activepieces/pieces-framework';
|
|
2
|
-
|
|
3
|
-
const markdown = `
|
|
4
|
-
To use the Signal CLI REST API, you need to provide the base URL of your signal-cli-rest-api instance.
|
|
5
|
-
|
|
6
|
-
1. Make sure you have signal-cli-rest-api running (e.g., via Docker)
|
|
7
|
-
2. The default URL is usually http://localhost:8080
|
|
8
|
-
3. If your API is behind a reverse proxy or on a different host, adjust the URL accordingly
|
|
9
|
-
4. If your API is behind a reverse proxy with HTTP Basic Auth, provide the credentials below
|
|
10
|
-
`;
|
|
11
|
-
|
|
12
|
-
export const signalCliRestApiAuth = PieceAuth.CustomAuth({
|
|
13
|
-
required: true,
|
|
14
|
-
description: markdown,
|
|
15
|
-
props: {
|
|
16
|
-
baseUrl: Property.ShortText({
|
|
17
|
-
displayName: 'API Base URL',
|
|
18
|
-
description: 'Base URL of your signal-cli-rest-api instance (e.g., http://localhost:8080)',
|
|
19
|
-
required: true,
|
|
20
|
-
defaultValue: 'http://localhost:8080',
|
|
21
|
-
}),
|
|
22
|
-
useBasicAuth: Property.Checkbox({
|
|
23
|
-
displayName: 'Use HTTP Basic Auth',
|
|
24
|
-
description: 'Enable if your API is behind a reverse proxy with HTTP Basic Auth',
|
|
25
|
-
required: false,
|
|
26
|
-
defaultValue: false,
|
|
27
|
-
}),
|
|
28
|
-
basicAuthUsername: Property.ShortText({
|
|
29
|
-
displayName: 'Basic Auth Username',
|
|
30
|
-
description: 'Username for HTTP Basic Auth (required if Basic Auth is enabled)',
|
|
31
|
-
required: false,
|
|
32
|
-
}),
|
|
33
|
-
basicAuthPassword: PieceAuth.SecretText({
|
|
34
|
-
displayName: 'Basic Auth Password',
|
|
35
|
-
description: 'Password for HTTP Basic Auth (required if Basic Auth is enabled)',
|
|
36
|
-
required: false,
|
|
37
|
-
}),
|
|
38
|
-
defaultNumber: Property.ShortText({
|
|
39
|
-
displayName: 'Default Phone Number (Optional)',
|
|
40
|
-
description: 'Default Signal phone number for this connection (can be overridden in actions)',
|
|
41
|
-
required: false,
|
|
42
|
-
}),
|
|
43
|
-
mode: Property.StaticDropdown({
|
|
44
|
-
displayName: 'Execution Mode',
|
|
45
|
-
description: 'The execution mode of your signal-cli-rest-api instance. json-rpc requires WebSocket, normal/native use HTTP GET.',
|
|
46
|
-
required: true,
|
|
47
|
-
defaultValue: 'normal',
|
|
48
|
-
options: {
|
|
49
|
-
options: [
|
|
50
|
-
{
|
|
51
|
-
label: 'Normal (HTTP GET)',
|
|
52
|
-
value: 'normal',
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
label: 'Native (HTTP GET)',
|
|
56
|
-
value: 'native',
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
label: 'JSON-RPC (WebSocket)',
|
|
60
|
-
value: 'json-rpc',
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
},
|
|
64
|
-
}),
|
|
65
|
-
},
|
|
66
|
-
});
|