@nuvlore/extension-access-okta-slack 0.1.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/LICENSE +202 -0
- package/README.md +52 -0
- package/package.json +64 -0
- package/src/slackApi.mjs +68 -0
- package/src/slackBotChat.mjs +129 -0
- package/src/slackBotRead.mjs +106 -0
- package/src/slackCanvasCreate.mjs +165 -0
- package/src/slackConfig.mjs +18 -0
- package/src/slackMessageSend.mjs +71 -0
- package/src/slackSearch.mjs +103 -0
- package/src/slackSessionRead.mjs +200 -0
- package/src/slackSyncExport.mjs +346 -0
- package/src/slackSyncPaths.mjs +47 -0
- package/src/slackSyncState.mjs +35 -0
- package/tools/okta_slack_okta_read.mjs +41 -0
- package/tools/okta_slack_okta_verify.mjs +26 -0
- package/tools/slack_okta_ai_capabilities.mjs +26 -0
- package/tools/slack_okta_bot_ask.mjs +42 -0
- package/tools/slack_okta_bot_history.mjs +32 -0
- package/tools/slack_okta_create_canvas.mjs +38 -0
- package/tools/slack_okta_search_all.mjs +33 -0
- package/tools/slack_okta_search_messages.mjs +34 -0
- package/tools/slack_okta_send_message.mjs +42 -0
- package/tools/slack_okta_sync_all.mjs +35 -0
- package/tools/slack_okta_sync_status.mjs +26 -0
- package/vendor/extension-sso/LICENSE +202 -0
- package/vendor/extension-sso/README.md +35 -0
- package/vendor/extension-sso/commands/okta-login.md +10 -0
- package/vendor/extension-sso/package.json +53 -0
- package/vendor/extension-sso/skills/workday-okta-auth/SKILL.md +20 -0
- package/vendor/extension-sso/src/autoAuth.mjs +25 -0
- package/vendor/extension-sso/src/browserLogin.mjs +1 -0
- package/vendor/extension-sso/src/chromeCookies.mjs +1 -0
- package/vendor/extension-sso/src/cookieJar.mjs +1 -0
- package/vendor/extension-sso/src/extensionAccess.mjs +173 -0
- package/vendor/extension-sso/src/htmlSessionExtract.mjs +1 -0
- package/vendor/extension-sso/src/oktaAppAccess.mjs +133 -0
- package/vendor/extension-sso/src/oktaAppCatalog.mjs +118 -0
- package/vendor/extension-sso/src/oktaAppRead.mjs +119 -0
- package/vendor/extension-sso/src/oktaConfig.mjs +12 -0
- package/vendor/extension-sso/src/oktaSession.mjs +32 -0
- package/vendor/extension-sso/src/serviceOperations.mjs +407 -0
- package/vendor/extension-sso/src/serviceReadSearch.mjs +395 -0
- package/vendor/extension-sso/src/serviceReads.mjs +109 -0
- package/vendor/extension-sso/src/serviceRegistry.mjs +497 -0
- package/vendor/extension-sso/src/sessionAuth.mjs +339 -0
- package/vendor/extension-sso/src/sessionManager.mjs +212 -0
- package/vendor/extension-sso/src/sessionValidate.mjs +74 -0
- package/vendor/extension-sso/src/ssoConfig.mjs +31 -0
- package/vendor/extension-sso/src/ssoHttpRead.mjs +292 -0
- package/vendor/extension-sso/tools/extension-access-tools.shared.mjs +16 -0
- package/vendor/extension-sso/tools/okta-app-tools.shared.mjs +5 -0
- package/vendor/extension-sso/tools/okta-tools.shared.mjs +18 -0
- package/vendor/extension-sso/tools/workday_extension_read.mjs +51 -0
- package/vendor/extension-sso/tools/workday_extension_read_access.mjs +65 -0
- package/vendor/extension-sso/tools/workday_list_extension_access.mjs +39 -0
- package/vendor/extension-sso/tools/workday_list_okta_apps.mjs +18 -0
- package/vendor/extension-sso/tools/workday_list_service_operations.mjs +41 -0
- package/vendor/extension-sso/tools/workday_list_service_read_search_capabilities.mjs +34 -0
- package/vendor/extension-sso/tools/workday_list_services.mjs +31 -0
- package/vendor/extension-sso/tools/workday_okta_app_probe_all.mjs +24 -0
- package/vendor/extension-sso/tools/workday_okta_app_read.mjs +30 -0
- package/vendor/extension-sso/tools/workday_okta_app_read_access.mjs +25 -0
- package/vendor/extension-sso/tools/workday_okta_auth_header.mjs +58 -0
- package/vendor/extension-sso/tools/workday_okta_login.mjs +65 -0
- package/vendor/extension-sso/tools/workday_okta_open_app.mjs +63 -0
- package/vendor/extension-sso/tools/workday_okta_open_service.mjs +63 -0
- package/vendor/extension-sso/tools/workday_okta_status.mjs +35 -0
- package/vendor/extension-sso/tools/workday_service_auth.mjs +65 -0
- package/vendor/extension-sso/tools/workday_service_operation_read.mjs +51 -0
- package/vendor/extension-sso/tools/workday_service_read.mjs +56 -0
- package/vendor/extension-sso/tools/workday_service_search.mjs +62 -0
- package/vendor/extension-sso/tools/workday_sso_cookie_header.mjs +59 -0
- package/vendor/extension-sso/vendor/extension-browser-sso/LICENSE +202 -0
- package/vendor/extension-sso/vendor/extension-browser-sso/README.md +16 -0
- package/vendor/extension-sso/vendor/extension-browser-sso/package.json +47 -0
- package/vendor/extension-sso/vendor/extension-browser-sso/src/autoAuth.mjs +47 -0
- package/vendor/extension-sso/vendor/extension-browser-sso/src/browserHttpRead.mjs +76 -0
- package/vendor/extension-sso/vendor/extension-browser-sso/src/browserLogin.mjs +24 -0
- package/vendor/extension-sso/vendor/extension-browser-sso/src/chromeCookies.mjs +192 -0
- package/vendor/extension-sso/vendor/extension-browser-sso/src/cookieJar.mjs +132 -0
- package/vendor/extension-sso/vendor/extension-browser-sso/src/extensions/toolkit/devops-data-paths.mjs +222 -0
- package/vendor/extension-sso/vendor/extension-browser-sso/src/extensions/toolkit/devops-diagnostics.mjs +440 -0
- package/vendor/extension-sso/vendor/extension-browser-sso/src/extensions/toolkit/enterprise-api-read.mjs +180 -0
- package/vendor/extension-sso/vendor/extension-browser-sso/src/extensions/toolkit/read-only-command-pack.mjs +1 -0
- package/vendor/extension-sso/vendor/extension-browser-sso/src/extensions/toolkit/read-only-plan.mjs +45 -0
- package/vendor/extension-sso/vendor/extension-browser-sso/src/extensions/toolkit/read-only-shell-policy.d.mts +26 -0
- package/vendor/extension-sso/vendor/extension-browser-sso/src/extensions/toolkit/read-only-shell-policy.mjs +170 -0
- package/vendor/extension-sso/vendor/extension-browser-sso/src/htmlSessionExtract.mjs +64 -0
- package/vendor/extension-sso/vendor/extension-read-only-toolkit/LICENSE +202 -0
- package/vendor/extension-sso/vendor/extension-read-only-toolkit/README.md +29 -0
- package/vendor/extension-sso/vendor/extension-read-only-toolkit/package.json +43 -0
- package/vendor/extension-sso/vendor/extension-read-only-toolkit/src/devops-data-paths.mjs +222 -0
- package/vendor/extension-sso/vendor/extension-read-only-toolkit/src/devops-diagnostics.mjs +440 -0
- package/vendor/extension-sso/vendor/extension-read-only-toolkit/src/enterprise-api-read.mjs +180 -0
- package/vendor/extension-sso/vendor/extension-read-only-toolkit/src/read-only-command-pack.mjs +1 -0
- package/vendor/extension-sso/vendor/extension-read-only-toolkit/src/read-only-plan.mjs +45 -0
- package/vendor/extension-sso/vendor/extension-read-only-toolkit/src/read-only-shell-policy.d.mts +26 -0
- package/vendor/extension-sso/vendor/extension-read-only-toolkit/src/read-only-shell-policy.mjs +170 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# @nuvlore/extension-access-okta-slack
|
|
2
|
+
|
|
3
|
+
Slack SSO access through Chrome/Okta browser-session cookies.
|
|
4
|
+
|
|
5
|
+
Default tools are read/search only:
|
|
6
|
+
|
|
7
|
+
- `slack_okta_search_messages`
|
|
8
|
+
- `slack_okta_search_all`
|
|
9
|
+
- `slack_okta_bot_history`
|
|
10
|
+
- `slack_okta_ai_capabilities`
|
|
11
|
+
- `slack_okta_sync_status`
|
|
12
|
+
|
|
13
|
+
Write tools are opt-in and must only be used when the user explicitly asks to send/post:
|
|
14
|
+
|
|
15
|
+
- `slack_okta_send_message`
|
|
16
|
+
- `slack_okta_create_canvas`
|
|
17
|
+
- `slack_okta_bot_ask`
|
|
18
|
+
|
|
19
|
+
## Browser Session Flow
|
|
20
|
+
|
|
21
|
+
1. Check `workday_okta_status`.
|
|
22
|
+
2. If Slack is not ready, run `workday_okta_open_app({ app: "Slack" })` or `workday_okta_login`.
|
|
23
|
+
3. The user completes Okta Verify/MFA in Chrome when prompted.
|
|
24
|
+
4. Use Slack read/search tools for investigation.
|
|
25
|
+
5. Use `slack_okta_send_message` only for an explicit send request. The tool reuses the Chrome Slack session token and cookies without printing them.
|
|
26
|
+
6. Use `slack_okta_create_canvas` only for an explicit canvas request. Slack Canvas API requires a Slack token with `canvases:write`; set `WORKDAY_SLACK_CANVAS_TOKEN` / `SLACK_CANVAS_TOKEN`, or store the token in macOS Keychain as `service=nuvlore`, `account=nuvlore.slack_canvas`. Chrome session tokens are attempted only to surface the Slack auth blocker and are not printed.
|
|
27
|
+
7. Use `slack_okta_bot_ask` only when the user explicitly requests a Slackbot-assisted lookup or the active skill requires Jira-grounded Slackbot context. It sends a DM to your Slackbot only. If it returns a `threadTs` but the answer list is initially empty, use `slack_okta_bot_history` to recover the later Slackbot reply; Slackbot DM replies are not always exposed through thread reads immediately.
|
|
28
|
+
|
|
29
|
+
Recommended Keychain storage:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
security add-generic-password -U -s nuvlore -a nuvlore.slack_canvas -w '<xoxb-or-user-token-with-canvases-write>'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
For channel sends, pass the Slack conversation id, not the channel name:
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"channelId": "C0497KFSDNJ",
|
|
40
|
+
"message": "Hi team, can someone help with `proteusaws00034`? Thanks."
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
For channel canvas creation, pass the channel id and Markdown content:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"channelId": "C0B66H7EM8W",
|
|
49
|
+
"title": "Test Canvas - _20260526_oncall",
|
|
50
|
+
"content": "# Purpose\nThis is a lightweight test canvas."
|
|
51
|
+
}
|
|
52
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nuvlore/extension-access-okta-slack",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Slack SSO access via browser session cookies, with read/search tools and explicitly authorized sends.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
"./slack-session-read": "./src/slackSessionRead.mjs",
|
|
9
|
+
"./slack-search": "./src/slackSearch.mjs",
|
|
10
|
+
"./slack-bot-read": "./src/slackBotRead.mjs",
|
|
11
|
+
"./slack-bot-chat": "./src/slackBotChat.mjs",
|
|
12
|
+
"./slack-message-send": "./src/slackMessageSend.mjs",
|
|
13
|
+
"./slack-canvas-create": "./src/slackCanvasCreate.mjs",
|
|
14
|
+
"./slack-sync": "./src/slackSyncExport.mjs"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"LICENSE",
|
|
18
|
+
"README.md",
|
|
19
|
+
"src",
|
|
20
|
+
"tools",
|
|
21
|
+
"vendor/extension-sso/LICENSE",
|
|
22
|
+
"vendor/extension-sso/README.md",
|
|
23
|
+
"vendor/extension-sso/package.json",
|
|
24
|
+
"vendor/extension-sso/commands",
|
|
25
|
+
"vendor/extension-sso/skills",
|
|
26
|
+
"vendor/extension-sso/src",
|
|
27
|
+
"vendor/extension-sso/tools",
|
|
28
|
+
"vendor/extension-sso/vendor/extension-browser-sso/LICENSE",
|
|
29
|
+
"vendor/extension-sso/vendor/extension-browser-sso/README.md",
|
|
30
|
+
"vendor/extension-sso/vendor/extension-browser-sso/package.json",
|
|
31
|
+
"vendor/extension-sso/vendor/extension-browser-sso/src",
|
|
32
|
+
"vendor/extension-sso/vendor/extension-read-only-toolkit/LICENSE",
|
|
33
|
+
"vendor/extension-sso/vendor/extension-read-only-toolkit/README.md",
|
|
34
|
+
"vendor/extension-sso/vendor/extension-read-only-toolkit/package.json",
|
|
35
|
+
"vendor/extension-sso/vendor/extension-read-only-toolkit/src"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"test": "npm run test:unit && npm run test:integration",
|
|
39
|
+
"test:unit": "vitest run test/*.test.ts && node --test test/unit/*.test.js",
|
|
40
|
+
"test:integration": "node --test test/integration/*.test.js"
|
|
41
|
+
},
|
|
42
|
+
"agentRuntimeDistribution": {
|
|
43
|
+
"visibility": "private",
|
|
44
|
+
"group": "sso-access-okta",
|
|
45
|
+
"serviceGrouping": "single-service",
|
|
46
|
+
"publicService": false,
|
|
47
|
+
"rationale": "SSO HTTP access for Slack. Default workflows are read/search; sends require explicit user authorization."
|
|
48
|
+
},
|
|
49
|
+
"agentRuntimeTools": {
|
|
50
|
+
"service": "access-okta-slack"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@nuvlore/extension-sso": "file:vendor/extension-sso",
|
|
54
|
+
"@nuvlore/extension-read-only-toolkit": "file:vendor/extension-sso/vendor/extension-read-only-toolkit",
|
|
55
|
+
"zod": "^4.1.12"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"vitest": "^3.1.3"
|
|
59
|
+
},
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"registry": "https://registry.npmjs.org/",
|
|
62
|
+
"access": "public"
|
|
63
|
+
}
|
|
64
|
+
}
|
package/src/slackApi.mjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { assertSlackReadOnlyMethod } from "./slackSessionRead.mjs";
|
|
2
|
+
|
|
3
|
+
export const SLACK_BOT_WRITE_METHODS = new Set(["chat.postMessage", "conversations.open"]);
|
|
4
|
+
|
|
5
|
+
export function assertSlackBotWriteMethod(method) {
|
|
6
|
+
const name = String(method || "").trim();
|
|
7
|
+
if (!SLACK_BOT_WRITE_METHODS.has(name)) {
|
|
8
|
+
throw new Error(`Slackbot write: method ${name} is not allowed. Only chat.postMessage to Slackbot DM.`);
|
|
9
|
+
}
|
|
10
|
+
return name;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function createSlackRawApiClient(session, options = {}) {
|
|
14
|
+
const fetchImpl = options.fetchImpl ?? globalThis.fetch;
|
|
15
|
+
const rateLimitMs = options.rateLimitMs ?? 350;
|
|
16
|
+
let lastCall = 0;
|
|
17
|
+
|
|
18
|
+
async function throttle() {
|
|
19
|
+
const wait = rateLimitMs - (Date.now() - lastCall);
|
|
20
|
+
if (wait > 0) await new Promise((resolve) => setTimeout(resolve, wait));
|
|
21
|
+
lastCall = Date.now();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return async function slackRawApi(method, params = {}, { write = false } = {}) {
|
|
25
|
+
if (write) assertSlackBotWriteMethod(method);
|
|
26
|
+
else assertSlackReadOnlyMethod(method);
|
|
27
|
+
await throttle();
|
|
28
|
+
const body = new URLSearchParams({ token: session.token, ...params });
|
|
29
|
+
const response = await fetchImpl(`${session.baseUrl}/api/${method}`, {
|
|
30
|
+
method: "POST",
|
|
31
|
+
headers: {
|
|
32
|
+
cookie: session.cookieHeader,
|
|
33
|
+
"content-type": "application/x-www-form-urlencoded"
|
|
34
|
+
},
|
|
35
|
+
body
|
|
36
|
+
});
|
|
37
|
+
const data = await response.json();
|
|
38
|
+
if (!data.ok) {
|
|
39
|
+
throw new Error(`Slack ${method} failed: ${data.error || "unknown_error"}`);
|
|
40
|
+
}
|
|
41
|
+
return data;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function isThinkingPlaceholder(text) {
|
|
46
|
+
const value = String(text || "").trim();
|
|
47
|
+
return !value || /^_?thinking\.{0,3}_?$/i.test(value) || /^thinking\.{0,3}$/i.test(value);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function isSlackbotMessage(message) {
|
|
51
|
+
if (!message) return false;
|
|
52
|
+
return (
|
|
53
|
+
message.user === "USLACKBOT" ||
|
|
54
|
+
message.bot_id === "BSLACKBOT" ||
|
|
55
|
+
message.subtype === "ai" ||
|
|
56
|
+
message.subtype === "bot_message"
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function compactSlackMessage(message) {
|
|
61
|
+
return {
|
|
62
|
+
ts: message.ts,
|
|
63
|
+
user: message.user,
|
|
64
|
+
botId: message.bot_id,
|
|
65
|
+
subtype: message.subtype,
|
|
66
|
+
text: message.text
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createSlackRawApiClient,
|
|
3
|
+
compactSlackMessage,
|
|
4
|
+
isSlackbotMessage,
|
|
5
|
+
isThinkingPlaceholder
|
|
6
|
+
} from "./slackApi.mjs";
|
|
7
|
+
import { SLACKBOT_USER_ID, findSlackbotImChannel } from "./slackBotRead.mjs";
|
|
8
|
+
import { loadSlackSession, slackUserBoot } from "./slackSessionRead.mjs";
|
|
9
|
+
|
|
10
|
+
const DEFAULT_WAIT_MS = 90_000;
|
|
11
|
+
const DEFAULT_POLL_MS = 2_000;
|
|
12
|
+
|
|
13
|
+
async function ensureSlackbotChannel(session, slackApi, boot) {
|
|
14
|
+
let im = findSlackbotImChannel(boot);
|
|
15
|
+
if (im) return im.id;
|
|
16
|
+
const opened = await slackApi(
|
|
17
|
+
"conversations.open",
|
|
18
|
+
{ users: SLACKBOT_USER_ID, return_im: "true" },
|
|
19
|
+
{ write: true }
|
|
20
|
+
);
|
|
21
|
+
return opened.channel?.id;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function postToSlackbot(slackApi, channelId, text, threadTs) {
|
|
25
|
+
const params = {
|
|
26
|
+
channel: channelId,
|
|
27
|
+
text: String(text).trim()
|
|
28
|
+
};
|
|
29
|
+
if (threadTs) params.thread_ts = String(threadTs);
|
|
30
|
+
return slackApi("chat.postMessage", params, { write: true });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function isFinalSlackbotReply(message) {
|
|
34
|
+
return isSlackbotMessage(message) && !isThinkingPlaceholder(message.text);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function waitForSlackbotReplies(slackApi, channelId, threadTs, options = {}) {
|
|
38
|
+
const deadline = Date.now() + (options.waitMs ?? DEFAULT_WAIT_MS);
|
|
39
|
+
const pollMs = options.pollMs ?? DEFAULT_POLL_MS;
|
|
40
|
+
let stableText = "";
|
|
41
|
+
let stablePolls = 0;
|
|
42
|
+
|
|
43
|
+
while (Date.now() < deadline) {
|
|
44
|
+
const page = await slackApi("conversations.replies", {
|
|
45
|
+
channel: channelId,
|
|
46
|
+
ts: threadTs,
|
|
47
|
+
limit: "50"
|
|
48
|
+
});
|
|
49
|
+
const messages = page.messages ?? [];
|
|
50
|
+
const botReplies = messages.filter((message, index) => index > 0 && isSlackbotMessage(message));
|
|
51
|
+
const latestBot = botReplies.at(-1);
|
|
52
|
+
|
|
53
|
+
if (latestBot && isFinalSlackbotReply(latestBot)) {
|
|
54
|
+
const text = String(latestBot.text || "");
|
|
55
|
+
if (text === stableText) {
|
|
56
|
+
stablePolls += 1;
|
|
57
|
+
} else {
|
|
58
|
+
stableText = text;
|
|
59
|
+
stablePolls = 0;
|
|
60
|
+
}
|
|
61
|
+
if (stablePolls >= 1) {
|
|
62
|
+
return {
|
|
63
|
+
threadTs,
|
|
64
|
+
messages: messages.map(compactSlackMessage),
|
|
65
|
+
botReplies: botReplies.map(compactSlackMessage)
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
await new Promise((resolve) => setTimeout(resolve, pollMs));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
throw new Error(
|
|
74
|
+
`Slackbot did not reply within ${options.waitMs ?? DEFAULT_WAIT_MS}ms for thread ${threadTs}.`
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Send a message to Slackbot and wait for its reply in the thread.
|
|
80
|
+
* Uses browser SSO session (xoxc). Replies use Slack AI (subtype: ai).
|
|
81
|
+
*/
|
|
82
|
+
export async function askSlackbot(question, options = {}) {
|
|
83
|
+
const text = String(question || "").trim();
|
|
84
|
+
if (!text) throw new Error("question is required.");
|
|
85
|
+
if (text.length > 4000) throw new Error("question exceeds 4000 characters.");
|
|
86
|
+
|
|
87
|
+
const session = await loadSlackSession(options);
|
|
88
|
+
const slackApi = createSlackRawApiClient(session, options);
|
|
89
|
+
const boot = await slackUserBoot(session, options);
|
|
90
|
+
const channelId = await ensureSlackbotChannel(session, slackApi, boot);
|
|
91
|
+
|
|
92
|
+
const posted = await postToSlackbot(slackApi, channelId, text, options.threadTs);
|
|
93
|
+
const threadTs = options.threadTs || posted.ts;
|
|
94
|
+
const waited = await waitForSlackbotReplies(slackApi, channelId, threadTs, options);
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
readOnly: false,
|
|
98
|
+
scope: "slackbot-dm-only",
|
|
99
|
+
channelId,
|
|
100
|
+
threadTs,
|
|
101
|
+
question: text,
|
|
102
|
+
posted: compactSlackMessage(posted.message ?? { ts: posted.ts, text, user: boot.self?.id }),
|
|
103
|
+
reply: waited.botReplies.at(-1) ?? null,
|
|
104
|
+
allBotReplies: waited.botReplies,
|
|
105
|
+
thread: waited.messages
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Follow up in an existing Slackbot thread. */
|
|
110
|
+
export async function followUpSlackbot(threadTs, message, options = {}) {
|
|
111
|
+
return askSlackbot(message, { ...options, threadTs });
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Full Slackbot interaction report: post + wait + optional thread history.
|
|
116
|
+
*/
|
|
117
|
+
export async function slackbotInteract(input, options = {}) {
|
|
118
|
+
const result = await askSlackbot(input.question ?? input.text, options);
|
|
119
|
+
if (options.includeThreadHistory) {
|
|
120
|
+
const slackApi = createSlackRawApiClient(await loadSlackSession(options), options);
|
|
121
|
+
const page = await slackApi("conversations.replies", {
|
|
122
|
+
channel: result.channelId,
|
|
123
|
+
ts: result.threadTs,
|
|
124
|
+
limit: "100"
|
|
125
|
+
});
|
|
126
|
+
result.fullThread = (page.messages ?? []).map(compactSlackMessage);
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createSlackApiClient,
|
|
3
|
+
fetchAllReplies,
|
|
4
|
+
loadSlackSession,
|
|
5
|
+
slackUserBoot
|
|
6
|
+
} from "./slackSessionRead.mjs";
|
|
7
|
+
|
|
8
|
+
export const SLACKBOT_USER_ID = "USLACKBOT";
|
|
9
|
+
|
|
10
|
+
export function findSlackbotImChannel(boot) {
|
|
11
|
+
const ims = Object.values(boot.ims ?? {});
|
|
12
|
+
return ims.find((im) => im.user === SLACKBOT_USER_ID) ?? null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function getSlackbotChannel(options = {}) {
|
|
16
|
+
const session = await loadSlackSession(options);
|
|
17
|
+
const boot = await slackUserBoot(session, options);
|
|
18
|
+
const im = findSlackbotImChannel(boot);
|
|
19
|
+
if (!im) {
|
|
20
|
+
throw new Error("Slackbot DM not found. Open a chat with @slackbot in Slack once.");
|
|
21
|
+
}
|
|
22
|
+
return { session, boot, channelId: im.id, channel: im };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function readSlackbotHistory(options = {}) {
|
|
26
|
+
const { session, channelId, channel } = await getSlackbotChannel(options);
|
|
27
|
+
const slackApi = createSlackApiClient(session, options);
|
|
28
|
+
const limit = String(options.limit ?? 50);
|
|
29
|
+
const page = await slackApi("conversations.history", { channel: channelId, limit });
|
|
30
|
+
const messages = (page.messages ?? []).map((message) => ({
|
|
31
|
+
ts: message.ts,
|
|
32
|
+
user: message.user,
|
|
33
|
+
botId: message.bot_id,
|
|
34
|
+
subtype: message.subtype,
|
|
35
|
+
text: message.text,
|
|
36
|
+
replyCount: message.reply_count ?? 0,
|
|
37
|
+
threadTs: message.thread_ts
|
|
38
|
+
}));
|
|
39
|
+
return {
|
|
40
|
+
readOnly: true,
|
|
41
|
+
channelId,
|
|
42
|
+
channel,
|
|
43
|
+
messages
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export async function readSlackbotThread(threadTs, options = {}) {
|
|
48
|
+
const { session, channelId } = await getSlackbotChannel(options);
|
|
49
|
+
const slackApi = createSlackApiClient(session, options);
|
|
50
|
+
const messages = await fetchAllReplies(slackApi, channelId, threadTs);
|
|
51
|
+
const [root, ...replies] = messages;
|
|
52
|
+
return {
|
|
53
|
+
readOnly: true,
|
|
54
|
+
channelId,
|
|
55
|
+
threadTs,
|
|
56
|
+
root: root
|
|
57
|
+
? {
|
|
58
|
+
ts: root.ts,
|
|
59
|
+
user: root.user,
|
|
60
|
+
text: root.text
|
|
61
|
+
}
|
|
62
|
+
: null,
|
|
63
|
+
replies: replies.map((message) => ({
|
|
64
|
+
ts: message.ts,
|
|
65
|
+
user: message.user,
|
|
66
|
+
botId: message.bot_id,
|
|
67
|
+
subtype: message.subtype,
|
|
68
|
+
text: message.text
|
|
69
|
+
}))
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Read Slackbot Q&A threads (user question + bot replies). Read-only — does not send new messages. */
|
|
74
|
+
export async function readSlackbotConversations(options = {}) {
|
|
75
|
+
const history = await readSlackbotHistory(options);
|
|
76
|
+
const { session, channelId } = await getSlackbotChannel(options);
|
|
77
|
+
const slackApi = createSlackApiClient(session, options);
|
|
78
|
+
const conversations = [];
|
|
79
|
+
|
|
80
|
+
for (const message of history.messages) {
|
|
81
|
+
if (message.user && message.replyCount > 0) {
|
|
82
|
+
const thread = await readSlackbotThread(message.ts, options);
|
|
83
|
+
conversations.push({
|
|
84
|
+
question: message.text,
|
|
85
|
+
askedAt: message.ts,
|
|
86
|
+
threadTs: message.ts,
|
|
87
|
+
answers: thread.replies
|
|
88
|
+
});
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (message.botId || message.subtype === "bot_message") {
|
|
92
|
+
conversations.push({
|
|
93
|
+
botMessage: message.text,
|
|
94
|
+
ts: message.ts,
|
|
95
|
+
botId: message.botId
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
readOnly: true,
|
|
102
|
+
channelId,
|
|
103
|
+
conversationCount: conversations.length,
|
|
104
|
+
conversations
|
|
105
|
+
};
|
|
106
|
+
}
|