@sentry/junior-google 0.0.0-stage → 0.238.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 +201 -0
- package/README.md +107 -2
- package/dist/cli.d.ts +3 -0
- package/dist/config.d.ts +38 -0
- package/dist/credentials.d.ts +42 -0
- package/dist/db/schema.d.ts +98 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +1460 -0
- package/dist/oauth.d.ts +47 -0
- package/dist/setup-routes.d.ts +25 -0
- package/dist/store.d.ts +22 -0
- package/dist/tools/create-event.d.ts +142 -0
- package/dist/tools/find-meeting-times.d.ts +162 -0
- package/dist/tools/list-events.d.ts +151 -0
- package/dist/tools/shared.d.ts +85 -0
- package/dist/tools/update-event.d.ts +139 -0
- package/migrations/0000_google_accounts.sql +7 -0
- package/migrations/meta/0000_snapshot.json +62 -0
- package/migrations/meta/_journal.json +13 -0
- package/package.json +44 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,108 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @sentry/junior-google
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Proof of concept. Junior acts as its own Google Workspace account, for example
|
|
4
|
+
`junior@sentry.io`. Junior does not use the Google credentials of the people it
|
|
5
|
+
helps. Tracking issue: getsentry/junior#2063.
|
|
6
|
+
|
|
7
|
+
This version supports Calendar only. Drive and Gmail are out of scope.
|
|
8
|
+
|
|
9
|
+
## Surfaces
|
|
10
|
+
|
|
11
|
+
- `findMeetingTimes` finds times when every attendee is free. It reads
|
|
12
|
+
free/busy data only. It never reads event titles or details.
|
|
13
|
+
- `createCalendarEvent` creates an event on Junior's own calendar. It sends
|
|
14
|
+
invites and can add a Google Meet link. A retry of the same tool call returns
|
|
15
|
+
the same event. It does not create a second invite.
|
|
16
|
+
- `listCalendarEvents` reads the events on one colleague's calendar. It shows
|
|
17
|
+
only what the calendar's Google sharing settings let Junior's account see.
|
|
18
|
+
A calendar shared as free/busy only shows busy blocks without titles. It
|
|
19
|
+
never returns event descriptions.
|
|
20
|
+
- `updateCalendarEvent` changes the title, description, time, or attendees of
|
|
21
|
+
an event that Junior organizes. Google emails the attendees about the
|
|
22
|
+
change. Only people invited to the event can ask for a change.
|
|
23
|
+
- The **Google account** page on the dashboard Admin page shows whether the
|
|
24
|
+
account is connected. Its Connect button starts Google sign-in.
|
|
25
|
+
- `junior google connect` and `junior google status` are the operator CLI.
|
|
26
|
+
|
|
27
|
+
## Authentication
|
|
28
|
+
|
|
29
|
+
A Junior admin connects the account one time, out of band. Slack never shows
|
|
30
|
+
the sign-in link, the authorization code, or any token. Junior admins are
|
|
31
|
+
managed with `junior admin grant <email>`. This plugin has no admin list of its
|
|
32
|
+
own.
|
|
33
|
+
|
|
34
|
+
1. An admin opens **Admin → Google account** in the dashboard and selects
|
|
35
|
+
**Connect**, or runs `junior google connect`.
|
|
36
|
+
2. Google sign-in opens with PKCE and a single-use state value.
|
|
37
|
+
3. The admin signs in as the configured account, not as themselves.
|
|
38
|
+
4. Junior checks that the identity token names the configured account. It also
|
|
39
|
+
checks that Google granted every Calendar scope. If a check fails, Junior
|
|
40
|
+
revokes the grant and stores nothing.
|
|
41
|
+
5. Junior stores the refresh token in the `junior_google_accounts` table.
|
|
42
|
+
|
|
43
|
+
At runtime, the `issueCredential` hook exchanges the refresh token for a
|
|
44
|
+
one-hour access token. Junior applies that token only to `www.googleapis.com`
|
|
45
|
+
requests from this plugin's tools. The `grantForEgress` hook denies sandbox
|
|
46
|
+
commands and any request that does not match a declared operation. Thus the
|
|
47
|
+
model cannot use `curl` to read Junior's calendar and skip the tool rules.
|
|
48
|
+
|
|
49
|
+
If Google rejects the refresh token (`invalid_grant`), Junior deletes it. The
|
|
50
|
+
tools then report that an admin must connect the account again. If the stored
|
|
51
|
+
grant does not have every scope the current tools need, the tools also ask an
|
|
52
|
+
admin to reconnect.
|
|
53
|
+
|
|
54
|
+
## Rules in code
|
|
55
|
+
|
|
56
|
+
- Junior checks and invites only people in the allowed domains. By default,
|
|
57
|
+
the allowed domain is the domain of the account email.
|
|
58
|
+
- Junior adds the requester to the attendees when it knows their email.
|
|
59
|
+
- Junior changes only events that it organizes, and only for a requester who
|
|
60
|
+
is invited to the event.
|
|
61
|
+
- Calendar scopes are `calendar.events.freebusy`, `calendar.events.readonly`,
|
|
62
|
+
and `calendar.events.owned`. Junior also requests `openid email` to verify
|
|
63
|
+
the account during sign-in.
|
|
64
|
+
|
|
65
|
+
## Setup
|
|
66
|
+
|
|
67
|
+
The plugin uses the same Google OAuth client as dashboard sign-in. Each
|
|
68
|
+
sign-in requests only its own scopes, so dashboard sign-in still asks only for
|
|
69
|
+
identity.
|
|
70
|
+
|
|
71
|
+
1. In the Google Cloud project of the dashboard OAuth client, enable the
|
|
72
|
+
Google Calendar API.
|
|
73
|
+
2. On the OAuth consent screen, use user type **Internal** and add the
|
|
74
|
+
Calendar scopes above.
|
|
75
|
+
3. On the OAuth client, add these redirect URIs:
|
|
76
|
+
- `https://<junior host>/api/plugins/google/oauth/callback`
|
|
77
|
+
- `http://127.0.0.1:8765/oauth/callback`, for the CLI. Use another port with
|
|
78
|
+
`junior google connect --port`.
|
|
79
|
+
4. Give the Junior account a Workspace license.
|
|
80
|
+
5. Set these environment variables on the deployment:
|
|
81
|
+
|
|
82
|
+
| Variable | Purpose |
|
|
83
|
+
| ---------------------------------- | ----------------------------------------------- |
|
|
84
|
+
| `GOOGLE_CLIENT_ID` | OAuth client id, shared with dashboard sign-in |
|
|
85
|
+
| `GOOGLE_CLIENT_SECRET` | OAuth client secret |
|
|
86
|
+
| `GOOGLE_WORKSPACE_ACCOUNT_EMAIL` | The account Junior acts as |
|
|
87
|
+
| `GOOGLE_WORKSPACE_ALLOWED_DOMAINS` | Optional comma-separated domains to schedule in |
|
|
88
|
+
|
|
89
|
+
The plugin registers no tools and no sign-in routes until the first three
|
|
90
|
+
variables are set. The Admin page shows **Not configured** until then.
|
|
91
|
+
|
|
92
|
+
6. Run `junior upgrade` to create the table.
|
|
93
|
+
7. Run `junior admin grant <email>` for each person who may connect the account.
|
|
94
|
+
8. Connect the account on **Admin → Google account**, or run
|
|
95
|
+
`junior google connect` with the deployment database configured.
|
|
96
|
+
|
|
97
|
+
## Known gaps
|
|
98
|
+
|
|
99
|
+
- The refresh token is stored in plain text in Postgres. Encryption at rest is
|
|
100
|
+
tracked in getsentry/junior#2065.
|
|
101
|
+
- Free/busy and event details show only what the company's calendar sharing
|
|
102
|
+
default allows. Calendars that Junior cannot see appear in `unavailable`
|
|
103
|
+
for `findMeetingTimes`, and as `visible: false` for `listCalendarEvents`.
|
|
104
|
+
- Anyone who can talk to Junior can ask it to read a colleague's calendar.
|
|
105
|
+
Junior returns what its own account can see, so set the sharing default
|
|
106
|
+
with that in mind.
|
|
107
|
+
- No disconnect command. To revoke access, remove the app grant from the
|
|
108
|
+
Junior account in Google.
|
package/dist/cli.d.ts
ADDED
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deployment configuration for the Google plugin.
|
|
3
|
+
*
|
|
4
|
+
* Values come from host environment variables. They never reach the sandbox.
|
|
5
|
+
*/
|
|
6
|
+
/** Dashboard sign-in uses the same OAuth client. */
|
|
7
|
+
export declare const GOOGLE_CLIENT_ID_ENV = "GOOGLE_CLIENT_ID";
|
|
8
|
+
export declare const GOOGLE_CLIENT_SECRET_ENV = "GOOGLE_CLIENT_SECRET";
|
|
9
|
+
export declare const GOOGLE_ACCOUNT_EMAIL_ENV = "GOOGLE_WORKSPACE_ACCOUNT_EMAIL";
|
|
10
|
+
export declare const GOOGLE_ALLOWED_DOMAINS_ENV = "GOOGLE_WORKSPACE_ALLOWED_DOMAINS";
|
|
11
|
+
/**
|
|
12
|
+
* Scopes the Calendar tools need. Request nothing broader.
|
|
13
|
+
*
|
|
14
|
+
* - `calendar.events.freebusy`: availability for `findMeetingTimes`.
|
|
15
|
+
* - `calendar.events.readonly`: events that Junior's account can see on other
|
|
16
|
+
* people's calendars, for `listCalendarEvents`. Google sharing settings
|
|
17
|
+
* still decide how much detail each calendar shows.
|
|
18
|
+
* - `calendar.events.owned`: create and change events on Junior's own
|
|
19
|
+
* calendar.
|
|
20
|
+
*/
|
|
21
|
+
export declare const GOOGLE_CALENDAR_SCOPES: readonly ["https://www.googleapis.com/auth/calendar.events.freebusy", "https://www.googleapis.com/auth/calendar.events.owned", "https://www.googleapis.com/auth/calendar.events.readonly"];
|
|
22
|
+
/** Identity scopes used only to verify which account signed in. */
|
|
23
|
+
export declare const GOOGLE_IDENTITY_SCOPES: readonly ["openid", "email"];
|
|
24
|
+
export interface GoogleConfig {
|
|
25
|
+
/** The Workspace account Junior acts as, for example `junior@sentry.io`. */
|
|
26
|
+
accountEmail: string;
|
|
27
|
+
/** Domains Junior may check availability for and invite. */
|
|
28
|
+
allowedDomains: string[];
|
|
29
|
+
clientId: string;
|
|
30
|
+
clientSecret: string;
|
|
31
|
+
}
|
|
32
|
+
/** Return the email domain in lowercase, or undefined for a malformed email. */
|
|
33
|
+
export declare function emailDomain(email: string): string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Read the Google plugin configuration, or undefined when the deployment does
|
|
36
|
+
* not configure the plugin.
|
|
37
|
+
*/
|
|
38
|
+
export declare function readGoogleConfig(): GoogleConfig | undefined;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credential issuing and egress policy for Google APIs.
|
|
3
|
+
*
|
|
4
|
+
* Only this plugin's own tools may use Junior's Google account. The tools
|
|
5
|
+
* enforce disclosure and invite rules in code, so the sandbox and other
|
|
6
|
+
* callers get no Google credential at all.
|
|
7
|
+
*/
|
|
8
|
+
import { type EgressHookContext, type IssueCredentialHookContext, type PluginCredentialResult, type PluginGrant } from "@sentry/junior-plugin-api";
|
|
9
|
+
export declare const GOOGLE_API_DOMAIN = "www.googleapis.com";
|
|
10
|
+
/** Google API operations that plugin tools may perform. */
|
|
11
|
+
export declare const GOOGLE_OPERATIONS: {
|
|
12
|
+
readonly "google.calendar.event.create": {
|
|
13
|
+
readonly access: "write";
|
|
14
|
+
readonly method: "POST";
|
|
15
|
+
readonly path: RegExp;
|
|
16
|
+
};
|
|
17
|
+
readonly "google.calendar.event.get": {
|
|
18
|
+
readonly access: "read";
|
|
19
|
+
readonly method: "GET";
|
|
20
|
+
readonly path: RegExp;
|
|
21
|
+
};
|
|
22
|
+
readonly "google.calendar.event.update": {
|
|
23
|
+
readonly access: "write";
|
|
24
|
+
readonly method: "PATCH";
|
|
25
|
+
readonly path: RegExp;
|
|
26
|
+
};
|
|
27
|
+
readonly "google.calendar.events.list": {
|
|
28
|
+
readonly access: "read";
|
|
29
|
+
readonly method: "GET";
|
|
30
|
+
readonly path: RegExp;
|
|
31
|
+
};
|
|
32
|
+
readonly "google.calendar.freebusy.query": {
|
|
33
|
+
readonly access: "read";
|
|
34
|
+
readonly method: "POST";
|
|
35
|
+
readonly path: RegExp;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export type GoogleOperation = keyof typeof GOOGLE_OPERATIONS;
|
|
39
|
+
/** Select the grant for one Google request, or deny it. */
|
|
40
|
+
export declare function googleGrantForEgress(ctx: EgressHookContext): PluginGrant;
|
|
41
|
+
/** Mint a short-lived access token for Junior's Google account. */
|
|
42
|
+
export declare function issueGoogleCredential(ctx: IssueCredentialHookContext): Promise<PluginCredentialResult>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Google accounts that Junior acts as.
|
|
3
|
+
*
|
|
4
|
+
* One row per connected account email. The refresh token is a long-lived
|
|
5
|
+
* secret: never log it, return it from routes, or expose it to the sandbox.
|
|
6
|
+
*/
|
|
7
|
+
export declare const juniorGoogleAccounts: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
8
|
+
name: "junior_google_accounts";
|
|
9
|
+
schema: undefined;
|
|
10
|
+
columns: {
|
|
11
|
+
accountEmail: import("drizzle-orm/pg-core").PgColumn<{
|
|
12
|
+
name: "account_email";
|
|
13
|
+
tableName: "junior_google_accounts";
|
|
14
|
+
dataType: "string";
|
|
15
|
+
columnType: "PgText";
|
|
16
|
+
data: string;
|
|
17
|
+
driverParam: string;
|
|
18
|
+
notNull: true;
|
|
19
|
+
hasDefault: false;
|
|
20
|
+
isPrimaryKey: true;
|
|
21
|
+
isAutoincrement: false;
|
|
22
|
+
hasRuntimeDefault: false;
|
|
23
|
+
enumValues: [string, ...string[]];
|
|
24
|
+
baseColumn: never;
|
|
25
|
+
identity: undefined;
|
|
26
|
+
generated: undefined;
|
|
27
|
+
}, {}, {}>;
|
|
28
|
+
refreshToken: import("drizzle-orm/pg-core").PgColumn<{
|
|
29
|
+
name: "refresh_token";
|
|
30
|
+
tableName: "junior_google_accounts";
|
|
31
|
+
dataType: "string";
|
|
32
|
+
columnType: "PgText";
|
|
33
|
+
data: string;
|
|
34
|
+
driverParam: string;
|
|
35
|
+
notNull: true;
|
|
36
|
+
hasDefault: false;
|
|
37
|
+
isPrimaryKey: false;
|
|
38
|
+
isAutoincrement: false;
|
|
39
|
+
hasRuntimeDefault: false;
|
|
40
|
+
enumValues: [string, ...string[]];
|
|
41
|
+
baseColumn: never;
|
|
42
|
+
identity: undefined;
|
|
43
|
+
generated: undefined;
|
|
44
|
+
}, {}, {}>;
|
|
45
|
+
scope: import("drizzle-orm/pg-core").PgColumn<{
|
|
46
|
+
name: "scope";
|
|
47
|
+
tableName: "junior_google_accounts";
|
|
48
|
+
dataType: "string";
|
|
49
|
+
columnType: "PgText";
|
|
50
|
+
data: string;
|
|
51
|
+
driverParam: string;
|
|
52
|
+
notNull: true;
|
|
53
|
+
hasDefault: false;
|
|
54
|
+
isPrimaryKey: false;
|
|
55
|
+
isAutoincrement: false;
|
|
56
|
+
hasRuntimeDefault: false;
|
|
57
|
+
enumValues: [string, ...string[]];
|
|
58
|
+
baseColumn: never;
|
|
59
|
+
identity: undefined;
|
|
60
|
+
generated: undefined;
|
|
61
|
+
}, {}, {}>;
|
|
62
|
+
connectedBy: import("drizzle-orm/pg-core").PgColumn<{
|
|
63
|
+
name: "connected_by";
|
|
64
|
+
tableName: "junior_google_accounts";
|
|
65
|
+
dataType: "string";
|
|
66
|
+
columnType: "PgText";
|
|
67
|
+
data: string;
|
|
68
|
+
driverParam: string;
|
|
69
|
+
notNull: true;
|
|
70
|
+
hasDefault: false;
|
|
71
|
+
isPrimaryKey: false;
|
|
72
|
+
isAutoincrement: false;
|
|
73
|
+
hasRuntimeDefault: false;
|
|
74
|
+
enumValues: [string, ...string[]];
|
|
75
|
+
baseColumn: never;
|
|
76
|
+
identity: undefined;
|
|
77
|
+
generated: undefined;
|
|
78
|
+
}, {}, {}>;
|
|
79
|
+
connectedAtMs: import("drizzle-orm/pg-core").PgColumn<{
|
|
80
|
+
name: "connected_at_ms";
|
|
81
|
+
tableName: "junior_google_accounts";
|
|
82
|
+
dataType: "number";
|
|
83
|
+
columnType: "PgBigInt53";
|
|
84
|
+
data: number;
|
|
85
|
+
driverParam: string | number;
|
|
86
|
+
notNull: true;
|
|
87
|
+
hasDefault: false;
|
|
88
|
+
isPrimaryKey: false;
|
|
89
|
+
isAutoincrement: false;
|
|
90
|
+
hasRuntimeDefault: false;
|
|
91
|
+
enumValues: undefined;
|
|
92
|
+
baseColumn: never;
|
|
93
|
+
identity: undefined;
|
|
94
|
+
generated: undefined;
|
|
95
|
+
}, {}, {}>;
|
|
96
|
+
};
|
|
97
|
+
dialect: "pg";
|
|
98
|
+
}>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Google plugin runtime boundary.
|
|
3
|
+
*
|
|
4
|
+
* Junior acts as its own Google Workspace account. A Junior admin connects
|
|
5
|
+
* that account out of band, through the dashboard Admin page or the CLI. Calendar
|
|
6
|
+
* tools use host-owned egress, and the sandbox gets no Google credential.
|
|
7
|
+
*/
|
|
8
|
+
import { type PluginRegistration } from "@sentry/junior-plugin-api";
|
|
9
|
+
/** Register Junior's Google Workspace plugin. */
|
|
10
|
+
export declare function googlePlugin(): PluginRegistration;
|