@seamapi/http 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +212 -1
- package/dist/connect.cjs +691 -26
- package/dist/connect.cjs.map +1 -1
- package/dist/connect.d.cts +101 -11
- package/lib/seam/connect/auth.js +55 -4
- package/lib/seam/connect/auth.js.map +1 -1
- package/lib/seam/connect/options.d.ts +11 -1
- package/lib/seam/connect/options.js +51 -1
- package/lib/seam/connect/options.js.map +1 -1
- package/lib/seam/connect/routes/access-codes-unmanaged.d.ts +3 -1
- package/lib/seam/connect/routes/access-codes-unmanaged.js +15 -1
- package/lib/seam/connect/routes/access-codes-unmanaged.js.map +1 -1
- package/lib/seam/connect/routes/access-codes.d.ts +3 -1
- package/lib/seam/connect/routes/access-codes.js +15 -1
- package/lib/seam/connect/routes/access-codes.js.map +1 -1
- package/lib/seam/connect/routes/acs-access-groups.d.ts +3 -10
- package/lib/seam/connect/routes/acs-access-groups.js +15 -23
- package/lib/seam/connect/routes/acs-access-groups.js.map +1 -1
- package/lib/seam/connect/routes/acs-credentials.d.ts +9 -1
- package/lib/seam/connect/routes/acs-credentials.js +29 -1
- package/lib/seam/connect/routes/acs-credentials.js.map +1 -1
- package/lib/seam/connect/routes/acs-systems.d.ts +3 -1
- package/lib/seam/connect/routes/acs-systems.js +15 -1
- package/lib/seam/connect/routes/acs-systems.js.map +1 -1
- package/lib/seam/connect/routes/acs-users.d.ts +3 -1
- package/lib/seam/connect/routes/acs-users.js +15 -1
- package/lib/seam/connect/routes/acs-users.js.map +1 -1
- package/lib/seam/connect/routes/acs.d.ts +3 -1
- package/lib/seam/connect/routes/acs.js +15 -1
- package/lib/seam/connect/routes/acs.js.map +1 -1
- package/lib/seam/connect/routes/action-attempts.d.ts +3 -1
- package/lib/seam/connect/routes/action-attempts.js +15 -1
- package/lib/seam/connect/routes/action-attempts.js.map +1 -1
- package/lib/seam/connect/routes/client-sessions.d.ts +6 -1
- package/lib/seam/connect/routes/client-sessions.js +22 -1
- package/lib/seam/connect/routes/client-sessions.js.map +1 -1
- package/lib/seam/connect/routes/connect-webviews.d.ts +3 -1
- package/lib/seam/connect/routes/connect-webviews.js +15 -1
- package/lib/seam/connect/routes/connect-webviews.js.map +1 -1
- package/lib/seam/connect/routes/connected-accounts.d.ts +3 -1
- package/lib/seam/connect/routes/connected-accounts.js +15 -1
- package/lib/seam/connect/routes/connected-accounts.js.map +1 -1
- package/lib/seam/connect/routes/devices-unmanaged.d.ts +3 -1
- package/lib/seam/connect/routes/devices-unmanaged.js +15 -1
- package/lib/seam/connect/routes/devices-unmanaged.js.map +1 -1
- package/lib/seam/connect/routes/devices.d.ts +3 -1
- package/lib/seam/connect/routes/devices.js +15 -1
- package/lib/seam/connect/routes/devices.js.map +1 -1
- package/lib/seam/connect/routes/events.d.ts +3 -1
- package/lib/seam/connect/routes/events.js +15 -1
- package/lib/seam/connect/routes/events.js.map +1 -1
- package/lib/seam/connect/routes/index.d.ts +1 -0
- package/lib/seam/connect/routes/index.js +1 -0
- package/lib/seam/connect/routes/index.js.map +1 -1
- package/lib/seam/connect/routes/locks.d.ts +3 -1
- package/lib/seam/connect/routes/locks.js +15 -1
- package/lib/seam/connect/routes/locks.js.map +1 -1
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.d.ts +3 -1
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js +15 -1
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js.map +1 -1
- package/lib/seam/connect/routes/noise-sensors.d.ts +3 -1
- package/lib/seam/connect/routes/noise-sensors.js +15 -1
- package/lib/seam/connect/routes/noise-sensors.js.map +1 -1
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.d.ts +3 -1
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js +15 -1
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js.map +1 -1
- package/lib/seam/connect/routes/thermostats.d.ts +3 -1
- package/lib/seam/connect/routes/thermostats.js +15 -1
- package/lib/seam/connect/routes/thermostats.js.map +1 -1
- package/lib/seam/connect/routes/user-identities.d.ts +38 -0
- package/lib/seam/connect/routes/user-identities.js +121 -0
- package/lib/seam/connect/routes/user-identities.js.map +1 -0
- package/lib/seam/connect/routes/webhooks.d.ts +3 -1
- package/lib/seam/connect/routes/webhooks.js +15 -1
- package/lib/seam/connect/routes/webhooks.js.map +1 -1
- package/lib/seam/connect/routes/workspaces.d.ts +3 -1
- package/lib/seam/connect/routes/workspaces.js +15 -1
- package/lib/seam/connect/routes/workspaces.js.map +1 -1
- package/lib/seam/connect/seam-http.d.ts +5 -2
- package/lib/seam/connect/seam-http.js +19 -2
- package/lib/seam/connect/seam-http.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +2 -2
- package/src/lib/seam/connect/auth.ts +95 -3
- package/src/lib/seam/connect/options.ts +105 -1
- package/src/lib/seam/connect/routes/access-codes-unmanaged.ts +38 -0
- package/src/lib/seam/connect/routes/access-codes.ts +38 -0
- package/src/lib/seam/connect/routes/acs-access-groups.ts +37 -47
- package/src/lib/seam/connect/routes/acs-credentials.ts +68 -0
- package/src/lib/seam/connect/routes/acs-systems.ts +38 -0
- package/src/lib/seam/connect/routes/acs-users.ts +38 -0
- package/src/lib/seam/connect/routes/acs.ts +38 -0
- package/src/lib/seam/connect/routes/action-attempts.ts +38 -0
- package/src/lib/seam/connect/routes/client-sessions.ts +53 -0
- package/src/lib/seam/connect/routes/connect-webviews.ts +38 -0
- package/src/lib/seam/connect/routes/connected-accounts.ts +38 -0
- package/src/lib/seam/connect/routes/devices-unmanaged.ts +38 -0
- package/src/lib/seam/connect/routes/devices.ts +38 -0
- package/src/lib/seam/connect/routes/events.ts +38 -0
- package/src/lib/seam/connect/routes/index.ts +1 -0
- package/src/lib/seam/connect/routes/locks.ts +38 -0
- package/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts +38 -0
- package/src/lib/seam/connect/routes/noise-sensors.ts +38 -0
- package/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts +38 -0
- package/src/lib/seam/connect/routes/thermostats.ts +38 -0
- package/src/lib/seam/connect/routes/user-identities.ts +261 -0
- package/src/lib/seam/connect/routes/webhooks.ts +38 -0
- package/src/lib/seam/connect/routes/workspaces.ts +38 -0
- package/src/lib/seam/connect/seam-http.ts +43 -0
- package/src/lib/version.ts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Client } from './client.js';
|
|
2
|
-
import { type SeamHttpFromPublishableKeyOptions, type SeamHttpOptions, type SeamHttpOptionsWithApiKey, type SeamHttpOptionsWithClient, type SeamHttpOptionsWithClientSessionToken } from './options.js';
|
|
3
|
-
import { SeamHttpAccessCodes, SeamHttpAcs, SeamHttpActionAttempts, SeamHttpClientSessions, SeamHttpConnectedAccounts, SeamHttpConnectWebviews, SeamHttpDevices, SeamHttpEvents, SeamHttpLocks, SeamHttpNoiseSensors, SeamHttpThermostats, SeamHttpWebhooks, SeamHttpWorkspaces } from './routes/index.js';
|
|
2
|
+
import { type SeamHttpFromPublishableKeyOptions, type SeamHttpOptions, type SeamHttpOptionsWithApiKey, type SeamHttpOptionsWithClient, type SeamHttpOptionsWithClientSessionToken, type SeamHttpOptionsWithConsoleSessionToken, type SeamHttpOptionsWithPersonalAccessToken } from './options.js';
|
|
3
|
+
import { SeamHttpAccessCodes, SeamHttpAcs, SeamHttpActionAttempts, SeamHttpClientSessions, SeamHttpConnectedAccounts, SeamHttpConnectWebviews, SeamHttpDevices, SeamHttpEvents, SeamHttpLocks, SeamHttpNoiseSensors, SeamHttpThermostats, SeamHttpUserIdentities, SeamHttpWebhooks, SeamHttpWorkspaces } from './routes/index.js';
|
|
4
4
|
export declare class SeamHttp {
|
|
5
5
|
client: Client;
|
|
6
6
|
constructor(apiKeyOrOptions?: string | SeamHttpOptions);
|
|
@@ -8,6 +8,8 @@ export declare class SeamHttp {
|
|
|
8
8
|
static fromApiKey(apiKey: SeamHttpOptionsWithApiKey['apiKey'], options?: Omit<SeamHttpOptionsWithApiKey, 'apiKey'>): SeamHttp;
|
|
9
9
|
static fromClientSessionToken(clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], options?: Omit<SeamHttpOptionsWithClientSessionToken, 'clientSessionToken'>): SeamHttp;
|
|
10
10
|
static fromPublishableKey(publishableKey: string, userIdentifierKey: string, options?: SeamHttpFromPublishableKeyOptions): Promise<SeamHttp>;
|
|
11
|
+
static fromConsoleSessionToken(consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], options?: Omit<SeamHttpOptionsWithConsoleSessionToken, 'consoleSessionToken' | 'workspaceId'>): SeamHttp;
|
|
12
|
+
static fromPersonalAccessToken(personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], options?: Omit<SeamHttpOptionsWithPersonalAccessToken, 'personalAccessToken' | 'workspaceId'>): SeamHttp;
|
|
11
13
|
get accessCodes(): SeamHttpAccessCodes;
|
|
12
14
|
get acs(): SeamHttpAcs;
|
|
13
15
|
get actionAttempts(): SeamHttpActionAttempts;
|
|
@@ -19,6 +21,7 @@ export declare class SeamHttp {
|
|
|
19
21
|
get locks(): SeamHttpLocks;
|
|
20
22
|
get noiseSensors(): SeamHttpNoiseSensors;
|
|
21
23
|
get thermostats(): SeamHttpThermostats;
|
|
24
|
+
get userIdentities(): SeamHttpUserIdentities;
|
|
22
25
|
get webhooks(): SeamHttpWebhooks;
|
|
23
26
|
get workspaces(): SeamHttpWorkspaces;
|
|
24
27
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { warnOnInsecureuserIdentifierKey } from './auth.js';
|
|
2
2
|
import { createClient } from './client.js';
|
|
3
|
-
import { isSeamHttpOptionsWithApiKey, isSeamHttpOptionsWithClient, isSeamHttpOptionsWithClientSessionToken, SeamHttpInvalidOptionsError, } from './options.js';
|
|
3
|
+
import { isSeamHttpOptionsWithApiKey, isSeamHttpOptionsWithClient, isSeamHttpOptionsWithClientSessionToken, isSeamHttpOptionsWithConsoleSessionToken, isSeamHttpOptionsWithPersonalAccessToken, SeamHttpInvalidOptionsError, } from './options.js';
|
|
4
4
|
import { parseOptions } from './parse-options.js';
|
|
5
|
-
import { SeamHttpAccessCodes, SeamHttpAcs, SeamHttpActionAttempts, SeamHttpClientSessions, SeamHttpConnectedAccounts, SeamHttpConnectWebviews, SeamHttpDevices, SeamHttpEvents, SeamHttpLocks, SeamHttpNoiseSensors, SeamHttpThermostats, SeamHttpWebhooks, SeamHttpWorkspaces, } from './routes/index.js';
|
|
5
|
+
import { SeamHttpAccessCodes, SeamHttpAcs, SeamHttpActionAttempts, SeamHttpClientSessions, SeamHttpConnectedAccounts, SeamHttpConnectWebviews, SeamHttpDevices, SeamHttpEvents, SeamHttpLocks, SeamHttpNoiseSensors, SeamHttpThermostats, SeamHttpUserIdentities, SeamHttpWebhooks, SeamHttpWorkspaces, } from './routes/index.js';
|
|
6
6
|
export class SeamHttp {
|
|
7
7
|
constructor(apiKeyOrOptions = {}) {
|
|
8
8
|
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
@@ -39,6 +39,20 @@ export class SeamHttp {
|
|
|
39
39
|
});
|
|
40
40
|
return SeamHttp.fromClientSessionToken(token, options);
|
|
41
41
|
}
|
|
42
|
+
static fromConsoleSessionToken(consoleSessionToken, workspaceId, options = {}) {
|
|
43
|
+
const constructorOptions = { ...options, consoleSessionToken, workspaceId };
|
|
44
|
+
if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
|
|
45
|
+
throw new SeamHttpInvalidOptionsError('Missing consoleSessionToken or workspaceId');
|
|
46
|
+
}
|
|
47
|
+
return new SeamHttp(constructorOptions);
|
|
48
|
+
}
|
|
49
|
+
static fromPersonalAccessToken(personalAccessToken, workspaceId, options = {}) {
|
|
50
|
+
const constructorOptions = { ...options, personalAccessToken, workspaceId };
|
|
51
|
+
if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
|
|
52
|
+
throw new SeamHttpInvalidOptionsError('Missing personalAccessToken or workspaceId');
|
|
53
|
+
}
|
|
54
|
+
return new SeamHttp(constructorOptions);
|
|
55
|
+
}
|
|
42
56
|
get accessCodes() {
|
|
43
57
|
return SeamHttpAccessCodes.fromClient(this.client);
|
|
44
58
|
}
|
|
@@ -72,6 +86,9 @@ export class SeamHttp {
|
|
|
72
86
|
get thermostats() {
|
|
73
87
|
return SeamHttpThermostats.fromClient(this.client);
|
|
74
88
|
}
|
|
89
|
+
get userIdentities() {
|
|
90
|
+
return SeamHttpUserIdentities.fromClient(this.client);
|
|
91
|
+
}
|
|
75
92
|
get webhooks() {
|
|
76
93
|
return SeamHttpWebhooks.fromClient(this.client);
|
|
77
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seam-http.js","sourceRoot":"","sources":["../../../src/lib/seam/connect/seam-http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,WAAW,CAAA;AAC3D,OAAO,EAAe,YAAY,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,uCAAuC,
|
|
1
|
+
{"version":3,"file":"seam-http.js","sourceRoot":"","sources":["../../../src/lib/seam/connect/seam-http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,WAAW,CAAA;AAC3D,OAAO,EAAe,YAAY,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,uCAAuC,EACvC,wCAAwC,EACxC,wCAAwC,EAExC,2BAA2B,GAO5B,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,sBAAsB,EACtB,sB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AAC;IAED,IAAI,UAAU;QACZ,OAAO,kBAAkB,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACnD,CAAC;CACF"}
|
package/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const seamapiJavascriptHttpVersion = "0.
|
|
1
|
+
declare const seamapiJavascriptHttpVersion = "0.6.0";
|
|
2
2
|
export default seamapiJavascriptHttpVersion;
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seamapi/http",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "JavaScript HTTP client for the Seam API written in TypeScript.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
94
94
|
"@seamapi/fake-seam-connect": "^1.43.0",
|
|
95
|
-
"@seamapi/types": "^1.
|
|
95
|
+
"@seamapi/types": "^1.44.1",
|
|
96
96
|
"@types/eslint": "^8.44.2",
|
|
97
97
|
"@types/node": "^18.11.18",
|
|
98
98
|
"ava": "^5.0.1",
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isSeamHttpOptionsWithApiKey,
|
|
3
3
|
isSeamHttpOptionsWithClientSessionToken,
|
|
4
|
+
isSeamHttpOptionsWithConsoleSessionToken,
|
|
5
|
+
isSeamHttpOptionsWithPersonalAccessToken,
|
|
4
6
|
SeamHttpInvalidOptionsError,
|
|
5
7
|
type SeamHttpOptionsWithApiKey,
|
|
6
8
|
type SeamHttpOptionsWithClientSessionToken,
|
|
9
|
+
type SeamHttpOptionsWithConsoleSessionToken,
|
|
10
|
+
type SeamHttpOptionsWithPersonalAccessToken,
|
|
7
11
|
} from './options.js'
|
|
8
12
|
import type { Options } from './parse-options.js'
|
|
9
13
|
|
|
@@ -22,8 +26,23 @@ export const getAuthHeaders = (options: Options): Headers => {
|
|
|
22
26
|
return getAuthHeadersForClientSessionToken(options)
|
|
23
27
|
}
|
|
24
28
|
|
|
29
|
+
if (isSeamHttpOptionsWithConsoleSessionToken(options)) {
|
|
30
|
+
return getAuthHeadersForConsoleSessionToken(options)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (isSeamHttpOptionsWithPersonalAccessToken(options)) {
|
|
34
|
+
return getAuthHeadersForPersonalAccessToken(options)
|
|
35
|
+
}
|
|
36
|
+
|
|
25
37
|
throw new SeamHttpInvalidOptionsError(
|
|
26
|
-
|
|
38
|
+
[
|
|
39
|
+
'Must specify',
|
|
40
|
+
'an apiKey,',
|
|
41
|
+
'clientSessionToken,',
|
|
42
|
+
'publishableKey,',
|
|
43
|
+
'consoleSessionToken with a workspaceId',
|
|
44
|
+
'or personalAccessToken with a workspaceId',
|
|
45
|
+
].join(' '),
|
|
27
46
|
)
|
|
28
47
|
}
|
|
29
48
|
|
|
@@ -96,6 +115,74 @@ const getAuthHeadersForClientSessionToken = ({
|
|
|
96
115
|
}
|
|
97
116
|
}
|
|
98
117
|
|
|
118
|
+
const getAuthHeadersForConsoleSessionToken = ({
|
|
119
|
+
consoleSessionToken,
|
|
120
|
+
workspaceId,
|
|
121
|
+
}: SeamHttpOptionsWithConsoleSessionToken): Headers => {
|
|
122
|
+
if (isAccessToken(consoleSessionToken)) {
|
|
123
|
+
throw new SeamHttpInvalidTokenError(
|
|
124
|
+
'An Access Token cannot be used as a consoleSessionToken',
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (isClientSessionToken(consoleSessionToken)) {
|
|
129
|
+
throw new SeamHttpInvalidTokenError(
|
|
130
|
+
'A Client Session Token cannot be used as a consoleSessionToken',
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (isPublishableKey(consoleSessionToken)) {
|
|
135
|
+
throw new SeamHttpInvalidTokenError(
|
|
136
|
+
'A Publishable Key cannot be used as a consoleSessionToken',
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (!isJwt(consoleSessionToken)) {
|
|
141
|
+
throw new SeamHttpInvalidTokenError(
|
|
142
|
+
`Unknown or invalid consoleSessionToken format, expected a JWT which starts with ${jwtPrefix}`,
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return {
|
|
147
|
+
authorization: `Bearer ${consoleSessionToken}`,
|
|
148
|
+
'seam-workspace-id': workspaceId,
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const getAuthHeadersForPersonalAccessToken = ({
|
|
153
|
+
personalAccessToken,
|
|
154
|
+
workspaceId,
|
|
155
|
+
}: SeamHttpOptionsWithPersonalAccessToken): Headers => {
|
|
156
|
+
if (isJwt(personalAccessToken)) {
|
|
157
|
+
throw new SeamHttpInvalidTokenError(
|
|
158
|
+
'A JWT cannot be used as a personalAccessToken',
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (isClientSessionToken(personalAccessToken)) {
|
|
163
|
+
throw new SeamHttpInvalidTokenError(
|
|
164
|
+
'A Client Session Token cannot be used as a personalAccessToken',
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (isPublishableKey(personalAccessToken)) {
|
|
169
|
+
throw new SeamHttpInvalidTokenError(
|
|
170
|
+
'A Publishable Key cannot be used as a personalAccessToken',
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (!isAccessToken(personalAccessToken)) {
|
|
175
|
+
throw new SeamHttpInvalidTokenError(
|
|
176
|
+
`Unknown or invalid personalAccessToken format, expected token to start with ${accessTokenPrefix}`,
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return {
|
|
181
|
+
authorization: `Bearer ${personalAccessToken}`,
|
|
182
|
+
'seam-workspace-id': workspaceId,
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
99
186
|
const getAuthHeadersForPublishableKey = (publishableKey: string): Headers => {
|
|
100
187
|
if (isJwt(publishableKey)) {
|
|
101
188
|
throw new SeamHttpInvalidTokenError(
|
|
@@ -153,6 +240,10 @@ export const warnOnInsecureuserIdentifierKey = (
|
|
|
153
240
|
|
|
154
241
|
const tokenPrefix = 'seam_'
|
|
155
242
|
|
|
243
|
+
const accessTokenPrefix = 'seam_at'
|
|
244
|
+
|
|
245
|
+
const jwtPrefix = 'ey'
|
|
246
|
+
|
|
156
247
|
const clientSessionTokenPrefix = 'seam_cst'
|
|
157
248
|
|
|
158
249
|
const publishableKeyTokenPrefix = 'seam_pk'
|
|
@@ -160,9 +251,10 @@ const publishableKeyTokenPrefix = 'seam_pk'
|
|
|
160
251
|
const isClientSessionToken = (token: string): boolean =>
|
|
161
252
|
token.startsWith(clientSessionTokenPrefix)
|
|
162
253
|
|
|
163
|
-
const isAccessToken = (token: string): boolean =>
|
|
254
|
+
const isAccessToken = (token: string): boolean =>
|
|
255
|
+
token.startsWith(accessTokenPrefix)
|
|
164
256
|
|
|
165
|
-
const isJwt = (token: string): boolean => token.startsWith(
|
|
257
|
+
const isJwt = (token: string): boolean => token.startsWith(jwtPrefix)
|
|
166
258
|
|
|
167
259
|
const isSeamToken = (token: string): boolean => token.startsWith(tokenPrefix)
|
|
168
260
|
|
|
@@ -5,6 +5,8 @@ export type SeamHttpOptions =
|
|
|
5
5
|
| SeamHttpOptionsWithClient
|
|
6
6
|
| SeamHttpOptionsWithApiKey
|
|
7
7
|
| SeamHttpOptionsWithClientSessionToken
|
|
8
|
+
| SeamHttpOptionsWithConsoleSessionToken
|
|
9
|
+
| SeamHttpOptionsWithPersonalAccessToken
|
|
8
10
|
|
|
9
11
|
interface SeamHttpCommonOptions extends ClientOptions {
|
|
10
12
|
endpoint?: string
|
|
@@ -53,6 +55,18 @@ export const isSeamHttpOptionsWithApiKey = (
|
|
|
53
55
|
)
|
|
54
56
|
}
|
|
55
57
|
|
|
58
|
+
if ('consoleSessionToken' in options && options.consoleSessionToken != null) {
|
|
59
|
+
throw new SeamHttpInvalidOptionsError(
|
|
60
|
+
'The consoleSessionToken option cannot be used with the apiKey option',
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if ('personalAccessToken' in options && options.personalAccessToken != null) {
|
|
65
|
+
throw new SeamHttpInvalidOptionsError(
|
|
66
|
+
'The personalAccessToken option cannot be used with the apiKey option',
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
56
70
|
return true
|
|
57
71
|
}
|
|
58
72
|
|
|
@@ -69,7 +83,97 @@ export const isSeamHttpOptionsWithClientSessionToken = (
|
|
|
69
83
|
|
|
70
84
|
if ('apiKey' in options && options.apiKey != null) {
|
|
71
85
|
throw new SeamHttpInvalidOptionsError(
|
|
72
|
-
'The
|
|
86
|
+
'The apiKey option cannot be used with the clientSessionToken option',
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if ('consoleSessionToken' in options && options.consoleSessionToken != null) {
|
|
91
|
+
throw new SeamHttpInvalidOptionsError(
|
|
92
|
+
'The consoleSessionToken option cannot be used with the clientSessionToken option',
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if ('personalAccessToken' in options && options.personalAccessToken != null) {
|
|
97
|
+
throw new SeamHttpInvalidOptionsError(
|
|
98
|
+
'The personalAccessToken option cannot be used with the clientSessionToken option',
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return true
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface SeamHttpOptionsWithConsoleSessionToken
|
|
106
|
+
extends SeamHttpCommonOptions {
|
|
107
|
+
consoleSessionToken: string
|
|
108
|
+
workspaceId: string
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export const isSeamHttpOptionsWithConsoleSessionToken = (
|
|
112
|
+
options: SeamHttpOptions,
|
|
113
|
+
): options is SeamHttpOptionsWithConsoleSessionToken => {
|
|
114
|
+
if (!('consoleSessionToken' in options)) return false
|
|
115
|
+
if (options.consoleSessionToken == null) return false
|
|
116
|
+
|
|
117
|
+
if (!('workspaceId' in options) || options.workspaceId == null) {
|
|
118
|
+
throw new SeamHttpInvalidOptionsError(
|
|
119
|
+
'Must pass a workspaceId when using a consoleSessionToken',
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if ('apiKey' in options && options.apiKey != null) {
|
|
124
|
+
throw new SeamHttpInvalidOptionsError(
|
|
125
|
+
'The apiKey option cannot be used with the consoleSessionToken option',
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if ('clientSessionToken' in options && options.clientSessionToken != null) {
|
|
130
|
+
throw new SeamHttpInvalidOptionsError(
|
|
131
|
+
'The clientSessionToken option cannot be used with the consoleSessionToken option',
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if ('personalAccessToken' in options && options.personalAccessToken != null) {
|
|
136
|
+
throw new SeamHttpInvalidOptionsError(
|
|
137
|
+
'The personalAccessToken option cannot be used with the consoleSessionToken option',
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return true
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface SeamHttpOptionsWithPersonalAccessToken
|
|
145
|
+
extends SeamHttpCommonOptions {
|
|
146
|
+
personalAccessToken: string
|
|
147
|
+
workspaceId: string
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export const isSeamHttpOptionsWithPersonalAccessToken = (
|
|
151
|
+
options: SeamHttpOptions,
|
|
152
|
+
): options is SeamHttpOptionsWithPersonalAccessToken => {
|
|
153
|
+
if (!('personalAccessToken' in options)) return false
|
|
154
|
+
if (options.personalAccessToken == null) return false
|
|
155
|
+
|
|
156
|
+
if (!('workspaceId' in options) || options.workspaceId == null) {
|
|
157
|
+
throw new SeamHttpInvalidOptionsError(
|
|
158
|
+
'Must pass a workspaceId when using a personalAccessToken',
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if ('apiKey' in options && options.apiKey != null) {
|
|
163
|
+
throw new SeamHttpInvalidOptionsError(
|
|
164
|
+
'The apiKey option cannot be used with the personalAccessToken option',
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if ('clientSessionToken' in options && options.clientSessionToken != null) {
|
|
169
|
+
throw new SeamHttpInvalidOptionsError(
|
|
170
|
+
'The clientSessionToken option cannot be used with the personalAccessToken option',
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if ('consoleSessionToken' in options && options.consoleSessionToken != null) {
|
|
175
|
+
throw new SeamHttpInvalidOptionsError(
|
|
176
|
+
'The consoleSessionToken option cannot be used with the personalAccessToken option',
|
|
73
177
|
)
|
|
74
178
|
}
|
|
75
179
|
|
|
@@ -12,12 +12,16 @@ import {
|
|
|
12
12
|
isSeamHttpOptionsWithApiKey,
|
|
13
13
|
isSeamHttpOptionsWithClient,
|
|
14
14
|
isSeamHttpOptionsWithClientSessionToken,
|
|
15
|
+
isSeamHttpOptionsWithConsoleSessionToken,
|
|
16
|
+
isSeamHttpOptionsWithPersonalAccessToken,
|
|
15
17
|
type SeamHttpFromPublishableKeyOptions,
|
|
16
18
|
SeamHttpInvalidOptionsError,
|
|
17
19
|
type SeamHttpOptions,
|
|
18
20
|
type SeamHttpOptionsWithApiKey,
|
|
19
21
|
type SeamHttpOptionsWithClient,
|
|
20
22
|
type SeamHttpOptionsWithClientSessionToken,
|
|
23
|
+
type SeamHttpOptionsWithConsoleSessionToken,
|
|
24
|
+
type SeamHttpOptionsWithPersonalAccessToken,
|
|
21
25
|
} from 'lib/seam/connect/options.js'
|
|
22
26
|
import { parseOptions } from 'lib/seam/connect/parse-options.js'
|
|
23
27
|
|
|
@@ -82,6 +86,40 @@ export class SeamHttpAccessCodesUnmanaged {
|
|
|
82
86
|
return SeamHttpAccessCodesUnmanaged.fromClientSessionToken(token, options)
|
|
83
87
|
}
|
|
84
88
|
|
|
89
|
+
static fromConsoleSessionToken(
|
|
90
|
+
consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
|
|
91
|
+
workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
|
|
92
|
+
options: Omit<
|
|
93
|
+
SeamHttpOptionsWithConsoleSessionToken,
|
|
94
|
+
'consoleSessionToken' | 'workspaceId'
|
|
95
|
+
> = {},
|
|
96
|
+
): SeamHttpAccessCodesUnmanaged {
|
|
97
|
+
const constructorOptions = { ...options, consoleSessionToken, workspaceId }
|
|
98
|
+
if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
|
|
99
|
+
throw new SeamHttpInvalidOptionsError(
|
|
100
|
+
'Missing consoleSessionToken or workspaceId',
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
return new SeamHttpAccessCodesUnmanaged(constructorOptions)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
static fromPersonalAccessToken(
|
|
107
|
+
personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
|
|
108
|
+
workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
|
|
109
|
+
options: Omit<
|
|
110
|
+
SeamHttpOptionsWithPersonalAccessToken,
|
|
111
|
+
'personalAccessToken' | 'workspaceId'
|
|
112
|
+
> = {},
|
|
113
|
+
): SeamHttpAccessCodesUnmanaged {
|
|
114
|
+
const constructorOptions = { ...options, personalAccessToken, workspaceId }
|
|
115
|
+
if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
|
|
116
|
+
throw new SeamHttpInvalidOptionsError(
|
|
117
|
+
'Missing personalAccessToken or workspaceId',
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
return new SeamHttpAccessCodesUnmanaged(constructorOptions)
|
|
121
|
+
}
|
|
122
|
+
|
|
85
123
|
async convertToManaged(
|
|
86
124
|
body?: AccessCodesUnmanagedConvertToManagedBody,
|
|
87
125
|
): Promise<void> {
|
|
@@ -12,12 +12,16 @@ import {
|
|
|
12
12
|
isSeamHttpOptionsWithApiKey,
|
|
13
13
|
isSeamHttpOptionsWithClient,
|
|
14
14
|
isSeamHttpOptionsWithClientSessionToken,
|
|
15
|
+
isSeamHttpOptionsWithConsoleSessionToken,
|
|
16
|
+
isSeamHttpOptionsWithPersonalAccessToken,
|
|
15
17
|
type SeamHttpFromPublishableKeyOptions,
|
|
16
18
|
SeamHttpInvalidOptionsError,
|
|
17
19
|
type SeamHttpOptions,
|
|
18
20
|
type SeamHttpOptionsWithApiKey,
|
|
19
21
|
type SeamHttpOptionsWithClient,
|
|
20
22
|
type SeamHttpOptionsWithClientSessionToken,
|
|
23
|
+
type SeamHttpOptionsWithConsoleSessionToken,
|
|
24
|
+
type SeamHttpOptionsWithPersonalAccessToken,
|
|
21
25
|
} from 'lib/seam/connect/options.js'
|
|
22
26
|
import { parseOptions } from 'lib/seam/connect/parse-options.js'
|
|
23
27
|
|
|
@@ -83,6 +87,40 @@ export class SeamHttpAccessCodes {
|
|
|
83
87
|
return SeamHttpAccessCodes.fromClientSessionToken(token, options)
|
|
84
88
|
}
|
|
85
89
|
|
|
90
|
+
static fromConsoleSessionToken(
|
|
91
|
+
consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
|
|
92
|
+
workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
|
|
93
|
+
options: Omit<
|
|
94
|
+
SeamHttpOptionsWithConsoleSessionToken,
|
|
95
|
+
'consoleSessionToken' | 'workspaceId'
|
|
96
|
+
> = {},
|
|
97
|
+
): SeamHttpAccessCodes {
|
|
98
|
+
const constructorOptions = { ...options, consoleSessionToken, workspaceId }
|
|
99
|
+
if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
|
|
100
|
+
throw new SeamHttpInvalidOptionsError(
|
|
101
|
+
'Missing consoleSessionToken or workspaceId',
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
return new SeamHttpAccessCodes(constructorOptions)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
static fromPersonalAccessToken(
|
|
108
|
+
personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
|
|
109
|
+
workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
|
|
110
|
+
options: Omit<
|
|
111
|
+
SeamHttpOptionsWithPersonalAccessToken,
|
|
112
|
+
'personalAccessToken' | 'workspaceId'
|
|
113
|
+
> = {},
|
|
114
|
+
): SeamHttpAccessCodes {
|
|
115
|
+
const constructorOptions = { ...options, personalAccessToken, workspaceId }
|
|
116
|
+
if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
|
|
117
|
+
throw new SeamHttpInvalidOptionsError(
|
|
118
|
+
'Missing personalAccessToken or workspaceId',
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
return new SeamHttpAccessCodes(constructorOptions)
|
|
122
|
+
}
|
|
123
|
+
|
|
86
124
|
get unmanaged(): SeamHttpAccessCodesUnmanaged {
|
|
87
125
|
return SeamHttpAccessCodesUnmanaged.fromClient(this.client)
|
|
88
126
|
}
|
|
@@ -12,12 +12,16 @@ import {
|
|
|
12
12
|
isSeamHttpOptionsWithApiKey,
|
|
13
13
|
isSeamHttpOptionsWithClient,
|
|
14
14
|
isSeamHttpOptionsWithClientSessionToken,
|
|
15
|
+
isSeamHttpOptionsWithConsoleSessionToken,
|
|
16
|
+
isSeamHttpOptionsWithPersonalAccessToken,
|
|
15
17
|
type SeamHttpFromPublishableKeyOptions,
|
|
16
18
|
SeamHttpInvalidOptionsError,
|
|
17
19
|
type SeamHttpOptions,
|
|
18
20
|
type SeamHttpOptionsWithApiKey,
|
|
19
21
|
type SeamHttpOptionsWithClient,
|
|
20
22
|
type SeamHttpOptionsWithClientSessionToken,
|
|
23
|
+
type SeamHttpOptionsWithConsoleSessionToken,
|
|
24
|
+
type SeamHttpOptionsWithPersonalAccessToken,
|
|
21
25
|
} from 'lib/seam/connect/options.js'
|
|
22
26
|
import { parseOptions } from 'lib/seam/connect/parse-options.js'
|
|
23
27
|
|
|
@@ -82,28 +86,43 @@ export class SeamHttpAcsAccessGroups {
|
|
|
82
86
|
return SeamHttpAcsAccessGroups.fromClientSessionToken(token, options)
|
|
83
87
|
}
|
|
84
88
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
static fromConsoleSessionToken(
|
|
90
|
+
consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
|
|
91
|
+
workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
|
|
92
|
+
options: Omit<
|
|
93
|
+
SeamHttpOptionsWithConsoleSessionToken,
|
|
94
|
+
'consoleSessionToken' | 'workspaceId'
|
|
95
|
+
> = {},
|
|
96
|
+
): SeamHttpAcsAccessGroups {
|
|
97
|
+
const constructorOptions = { ...options, consoleSessionToken, workspaceId }
|
|
98
|
+
if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
|
|
99
|
+
throw new SeamHttpInvalidOptionsError(
|
|
100
|
+
'Missing consoleSessionToken or workspaceId',
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
return new SeamHttpAcsAccessGroups(constructorOptions)
|
|
91
104
|
}
|
|
92
105
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
106
|
+
static fromPersonalAccessToken(
|
|
107
|
+
personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
|
|
108
|
+
workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
|
|
109
|
+
options: Omit<
|
|
110
|
+
SeamHttpOptionsWithPersonalAccessToken,
|
|
111
|
+
'personalAccessToken' | 'workspaceId'
|
|
112
|
+
> = {},
|
|
113
|
+
): SeamHttpAcsAccessGroups {
|
|
114
|
+
const constructorOptions = { ...options, personalAccessToken, workspaceId }
|
|
115
|
+
if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
|
|
116
|
+
throw new SeamHttpInvalidOptionsError(
|
|
117
|
+
'Missing personalAccessToken or workspaceId',
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
return new SeamHttpAcsAccessGroups(constructorOptions)
|
|
102
121
|
}
|
|
103
122
|
|
|
104
|
-
async
|
|
105
|
-
await this.client.request<
|
|
106
|
-
url: '/acs/access_groups/
|
|
123
|
+
async addUser(body?: AcsAccessGroupsAddUserBody): Promise<void> {
|
|
124
|
+
await this.client.request<AcsAccessGroupsAddUserResponse>({
|
|
125
|
+
url: '/acs/access_groups/add_user',
|
|
107
126
|
method: 'post',
|
|
108
127
|
data: body,
|
|
109
128
|
})
|
|
@@ -150,14 +169,6 @@ export class SeamHttpAcsAccessGroups {
|
|
|
150
169
|
data: body,
|
|
151
170
|
})
|
|
152
171
|
}
|
|
153
|
-
|
|
154
|
-
async update(body?: AcsAccessGroupsUpdateBody): Promise<void> {
|
|
155
|
-
await this.client.request<AcsAccessGroupsUpdateResponse>({
|
|
156
|
-
url: '/acs/access_groups/update',
|
|
157
|
-
method: 'post',
|
|
158
|
-
data: body,
|
|
159
|
-
})
|
|
160
|
-
}
|
|
161
172
|
}
|
|
162
173
|
|
|
163
174
|
export type AcsAccessGroupsAddUserBody =
|
|
@@ -167,20 +178,6 @@ export type AcsAccessGroupsAddUserResponse = SetNonNullable<
|
|
|
167
178
|
Required<RouteResponse<'/acs/access_groups/add_user'>>
|
|
168
179
|
>
|
|
169
180
|
|
|
170
|
-
export type AcsAccessGroupsCreateBody =
|
|
171
|
-
RouteRequestBody<'/acs/access_groups/create'>
|
|
172
|
-
|
|
173
|
-
export type AcsAccessGroupsCreateResponse = SetNonNullable<
|
|
174
|
-
Required<RouteResponse<'/acs/access_groups/create'>>
|
|
175
|
-
>
|
|
176
|
-
|
|
177
|
-
export type AcsAccessGroupsDeleteBody =
|
|
178
|
-
RouteRequestBody<'/acs/access_groups/delete'>
|
|
179
|
-
|
|
180
|
-
export type AcsAccessGroupsDeleteResponse = SetNonNullable<
|
|
181
|
-
Required<RouteResponse<'/acs/access_groups/delete'>>
|
|
182
|
-
>
|
|
183
|
-
|
|
184
181
|
export type AcsAccessGroupsGetParams =
|
|
185
182
|
RouteRequestBody<'/acs/access_groups/get'>
|
|
186
183
|
|
|
@@ -208,10 +205,3 @@ export type AcsAccessGroupsRemoveUserBody =
|
|
|
208
205
|
export type AcsAccessGroupsRemoveUserResponse = SetNonNullable<
|
|
209
206
|
Required<RouteResponse<'/acs/access_groups/remove_user'>>
|
|
210
207
|
>
|
|
211
|
-
|
|
212
|
-
export type AcsAccessGroupsUpdateBody =
|
|
213
|
-
RouteRequestBody<'/acs/access_groups/update'>
|
|
214
|
-
|
|
215
|
-
export type AcsAccessGroupsUpdateResponse = SetNonNullable<
|
|
216
|
-
Required<RouteResponse<'/acs/access_groups/update'>>
|
|
217
|
-
>
|