@seamapi/http 0.1.0 → 0.2.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/dist/connect.cjs +752 -366
- package/dist/connect.cjs.map +1 -1
- package/dist/connect.d.cts +186 -142
- package/lib/params-serializer.d.ts +5 -0
- package/lib/params-serializer.js +42 -0
- package/lib/params-serializer.js.map +1 -0
- package/lib/seam/connect/auth.d.ts +3 -2
- package/lib/seam/connect/auth.js +55 -4
- package/lib/seam/connect/auth.js.map +1 -1
- package/lib/seam/connect/client.d.ts +10 -22
- package/lib/seam/connect/client.js +17 -77
- package/lib/seam/connect/client.js.map +1 -1
- package/lib/seam/connect/index.d.ts +2 -1
- package/lib/seam/connect/index.js +2 -1
- package/lib/seam/connect/index.js.map +1 -1
- package/lib/seam/connect/{client-options.d.ts → options.d.ts} +7 -7
- package/lib/seam/connect/{client-options.js → options.js} +5 -10
- package/lib/seam/connect/options.js.map +1 -0
- package/lib/seam/connect/parse-options.d.ts +6 -2
- package/lib/seam/connect/parse-options.js +34 -16
- package/lib/seam/connect/parse-options.js.map +1 -1
- package/lib/seam/connect/routes/access-codes-unmanaged.d.ts +10 -9
- package/lib/seam/connect/routes/access-codes-unmanaged.js +26 -14
- package/lib/seam/connect/routes/access-codes-unmanaged.js.map +1 -1
- package/lib/seam/connect/routes/access-codes.d.ts +15 -14
- package/lib/seam/connect/routes/access-codes.js +29 -17
- package/lib/seam/connect/routes/access-codes.js.map +1 -1
- package/lib/seam/connect/routes/acs-access-groups.d.ts +13 -12
- package/lib/seam/connect/routes/acs-access-groups.js +26 -14
- package/lib/seam/connect/routes/acs-access-groups.js.map +1 -1
- package/lib/seam/connect/routes/acs-credentials.d.ts +9 -8
- package/lib/seam/connect/routes/acs-credentials.js +26 -14
- package/lib/seam/connect/routes/acs-credentials.js.map +1 -1
- package/lib/seam/connect/routes/acs-systems.d.ts +9 -8
- package/lib/seam/connect/routes/acs-systems.js +29 -17
- package/lib/seam/connect/routes/acs-systems.js.map +1 -1
- package/lib/seam/connect/routes/acs-users.d.ts +18 -11
- package/lib/seam/connect/routes/acs-users.js +40 -14
- package/lib/seam/connect/routes/acs-users.js.map +1 -1
- package/lib/seam/connect/routes/acs.d.ts +5 -4
- package/lib/seam/connect/routes/acs.js +26 -14
- package/lib/seam/connect/routes/acs.js.map +1 -1
- package/lib/seam/connect/routes/action-attempts.d.ts +7 -6
- package/lib/seam/connect/routes/action-attempts.js +26 -14
- package/lib/seam/connect/routes/action-attempts.js.map +1 -1
- package/lib/seam/connect/routes/client-sessions.d.ts +13 -9
- package/lib/seam/connect/routes/client-sessions.js +33 -14
- package/lib/seam/connect/routes/client-sessions.js.map +1 -1
- package/lib/seam/connect/routes/connect-webviews.d.ts +11 -10
- package/lib/seam/connect/routes/connect-webviews.js +29 -17
- package/lib/seam/connect/routes/connect-webviews.js.map +1 -1
- package/lib/seam/connect/routes/connected-accounts.d.ts +8 -7
- package/lib/seam/connect/routes/connected-accounts.js +26 -14
- package/lib/seam/connect/routes/connected-accounts.js.map +1 -1
- package/lib/seam/connect/routes/devices-unmanaged.d.ts +8 -7
- package/lib/seam/connect/routes/devices-unmanaged.js +26 -14
- package/lib/seam/connect/routes/devices-unmanaged.js.map +1 -1
- package/lib/seam/connect/routes/devices.d.ts +10 -9
- package/lib/seam/connect/routes/devices.js +26 -14
- package/lib/seam/connect/routes/devices.js.map +1 -1
- package/lib/seam/connect/routes/events.d.ts +7 -6
- package/lib/seam/connect/routes/events.js +26 -14
- package/lib/seam/connect/routes/events.js.map +1 -1
- package/lib/seam/connect/routes/locks.d.ts +9 -8
- package/lib/seam/connect/routes/locks.js +26 -14
- package/lib/seam/connect/routes/locks.js.map +1 -1
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.d.ts +10 -9
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js +26 -14
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js.map +1 -1
- package/lib/seam/connect/routes/noise-sensors.d.ts +5 -4
- package/lib/seam/connect/routes/noise-sensors.js +26 -14
- package/lib/seam/connect/routes/noise-sensors.js.map +1 -1
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.d.ts +10 -9
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js +26 -14
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js.map +1 -1
- package/lib/seam/connect/routes/thermostats.d.ts +13 -12
- package/lib/seam/connect/routes/thermostats.js +26 -14
- package/lib/seam/connect/routes/thermostats.js.map +1 -1
- package/lib/seam/connect/routes/webhooks.d.ts +9 -8
- package/lib/seam/connect/routes/webhooks.js +26 -14
- package/lib/seam/connect/routes/webhooks.js.map +1 -1
- package/lib/seam/connect/routes/workspaces.d.ts +8 -7
- package/lib/seam/connect/routes/workspaces.js +26 -14
- package/lib/seam/connect/routes/workspaces.js.map +1 -1
- package/lib/seam/connect/seam-http.d.ts +24 -0
- package/lib/seam/connect/seam-http.js +82 -0
- package/lib/seam/connect/seam-http.js.map +1 -0
- package/package.json +7 -4
- package/src/lib/params-serializer.ts +55 -0
- package/src/lib/seam/connect/auth.ts +94 -6
- package/src/lib/seam/connect/client.ts +22 -127
- package/src/lib/seam/connect/env.d.ts +11 -0
- package/src/lib/seam/connect/index.ts +2 -1
- package/src/lib/seam/connect/{client-options.ts → options.ts} +13 -19
- package/src/lib/seam/connect/parse-options.ts +50 -23
- package/src/lib/seam/connect/routes/access-codes-unmanaged.ts +44 -31
- package/src/lib/seam/connect/routes/access-codes.ts +48 -48
- package/src/lib/seam/connect/routes/acs-access-groups.ts +49 -40
- package/src/lib/seam/connect/routes/acs-credentials.ts +40 -28
- package/src/lib/seam/connect/routes/acs-systems.ts +40 -30
- package/src/lib/seam/connect/routes/acs-users.ts +70 -36
- package/src/lib/seam/connect/routes/acs.ts +33 -17
- package/src/lib/seam/connect/routes/action-attempts.ts +36 -22
- package/src/lib/seam/connect/routes/client-sessions.ts +58 -30
- package/src/lib/seam/connect/routes/connect-webviews.ts +45 -34
- package/src/lib/seam/connect/routes/connected-accounts.ts +40 -25
- package/src/lib/seam/connect/routes/devices-unmanaged.ts +39 -25
- package/src/lib/seam/connect/routes/devices.ts +39 -31
- package/src/lib/seam/connect/routes/events.ts +36 -22
- package/src/lib/seam/connect/routes/locks.ts +38 -28
- package/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts +47 -31
- package/src/lib/seam/connect/routes/noise-sensors.ts +33 -17
- package/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts +47 -31
- package/src/lib/seam/connect/routes/thermostats.ts +42 -40
- package/src/lib/seam/connect/routes/webhooks.ts +38 -28
- package/src/lib/seam/connect/routes/workspaces.ts +38 -25
- package/src/lib/seam/connect/seam-http.ts +141 -0
- package/lib/seam/connect/axios.d.ts +0 -3
- package/lib/seam/connect/axios.js +0 -19
- package/lib/seam/connect/axios.js.map +0 -1
- package/lib/seam/connect/client-options.js.map +0 -1
- package/src/lib/seam/connect/axios.ts +0 -25
package/dist/connect.cjs
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var axios = require('axios');
|
|
4
|
+
var axiosRetry = require('axios-retry');
|
|
4
5
|
|
|
5
6
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
7
|
|
|
7
8
|
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
9
|
+
var axiosRetry__default = /*#__PURE__*/_interopDefault(axiosRetry);
|
|
8
10
|
|
|
9
|
-
// src/lib/seam/connect/
|
|
10
|
-
|
|
11
|
-
// src/lib/seam/connect/client-options.ts
|
|
11
|
+
// src/lib/seam/connect/options.ts
|
|
12
12
|
var isSeamHttpOptionsWithClient = (options) => {
|
|
13
13
|
if (!("client" in options))
|
|
14
14
|
return false;
|
|
15
15
|
if (options.client == null)
|
|
16
16
|
return false;
|
|
17
|
-
const keys = Object.keys(options).filter(
|
|
18
|
-
(k) => !["client", "enableLegacyMethodBehaivor"].includes(k)
|
|
19
|
-
);
|
|
17
|
+
const keys = Object.keys(options).filter((k) => k !== "client");
|
|
20
18
|
if (keys.length > 0) {
|
|
21
19
|
throw new SeamHttpInvalidOptionsError(
|
|
22
|
-
`The client option cannot be used with any other option
|
|
20
|
+
`The client option cannot be used with any other option, but received: ${keys.join(
|
|
23
21
|
", "
|
|
24
22
|
)}`
|
|
25
23
|
);
|
|
@@ -33,7 +31,7 @@ var isSeamHttpOptionsWithApiKey = (options) => {
|
|
|
33
31
|
return false;
|
|
34
32
|
if ("clientSessionToken" in options && options.clientSessionToken != null) {
|
|
35
33
|
throw new SeamHttpInvalidOptionsError(
|
|
36
|
-
"The clientSessionToken option cannot be used with the apiKey option
|
|
34
|
+
"The clientSessionToken option cannot be used with the apiKey option"
|
|
37
35
|
);
|
|
38
36
|
}
|
|
39
37
|
return true;
|
|
@@ -45,7 +43,7 @@ var isSeamHttpOptionsWithClientSessionToken = (options) => {
|
|
|
45
43
|
return false;
|
|
46
44
|
if ("apiKey" in options && options.apiKey != null) {
|
|
47
45
|
throw new SeamHttpInvalidOptionsError(
|
|
48
|
-
"The clientSessionToken option cannot be used with the apiKey option
|
|
46
|
+
"The clientSessionToken option cannot be used with the apiKey option"
|
|
49
47
|
);
|
|
50
48
|
}
|
|
51
49
|
return true;
|
|
@@ -60,6 +58,9 @@ var SeamHttpInvalidOptionsError = class extends Error {
|
|
|
60
58
|
|
|
61
59
|
// src/lib/seam/connect/auth.ts
|
|
62
60
|
var getAuthHeaders = (options) => {
|
|
61
|
+
if ("publishableKey" in options) {
|
|
62
|
+
return getAuthHeadersForPublishableKey(options.publishableKey);
|
|
63
|
+
}
|
|
63
64
|
if (isSeamHttpOptionsWithApiKey(options)) {
|
|
64
65
|
return getAuthHeadersForApiKey(options);
|
|
65
66
|
}
|
|
@@ -67,7 +68,7 @@ var getAuthHeaders = (options) => {
|
|
|
67
68
|
return getAuthHeadersForClientSessionToken(options);
|
|
68
69
|
}
|
|
69
70
|
throw new SeamHttpInvalidOptionsError(
|
|
70
|
-
"Must specify an apiKey or
|
|
71
|
+
"Must specify an apiKey, clientSessionToken, or publishableKey"
|
|
71
72
|
);
|
|
72
73
|
};
|
|
73
74
|
var getAuthHeadersForApiKey = ({
|
|
@@ -78,12 +79,20 @@ var getAuthHeadersForApiKey = ({
|
|
|
78
79
|
"A Client Session Token cannot be used as an apiKey"
|
|
79
80
|
);
|
|
80
81
|
}
|
|
82
|
+
if (isJwt(apiKey)) {
|
|
83
|
+
throw new SeamHttpInvalidTokenError("A JWT cannot be used as an apiKey");
|
|
84
|
+
}
|
|
81
85
|
if (isAccessToken(apiKey)) {
|
|
82
86
|
throw new SeamHttpInvalidTokenError(
|
|
83
|
-
"An
|
|
87
|
+
"An Access Token cannot be used as an apiKey"
|
|
84
88
|
);
|
|
85
89
|
}
|
|
86
|
-
if (
|
|
90
|
+
if (isPublishableKey(apiKey)) {
|
|
91
|
+
throw new SeamHttpInvalidTokenError(
|
|
92
|
+
"A Publishable Key cannot be used as an apiKey"
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
if (!isSeamToken(apiKey)) {
|
|
87
96
|
throw new SeamHttpInvalidTokenError(
|
|
88
97
|
`Unknown or invalid apiKey format, expected token to start with ${tokenPrefix}`
|
|
89
98
|
);
|
|
@@ -95,6 +104,21 @@ var getAuthHeadersForApiKey = ({
|
|
|
95
104
|
var getAuthHeadersForClientSessionToken = ({
|
|
96
105
|
clientSessionToken
|
|
97
106
|
}) => {
|
|
107
|
+
if (isJwt(clientSessionToken)) {
|
|
108
|
+
throw new SeamHttpInvalidTokenError(
|
|
109
|
+
"A JWT cannot be used as a clientSessionToken"
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
if (isAccessToken(clientSessionToken)) {
|
|
113
|
+
throw new SeamHttpInvalidTokenError(
|
|
114
|
+
"An Access Token cannot be used as a clientSessionToken"
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
if (isPublishableKey(clientSessionToken)) {
|
|
118
|
+
throw new SeamHttpInvalidTokenError(
|
|
119
|
+
"A Publishable Key cannot be used as a clientSessionToken"
|
|
120
|
+
);
|
|
121
|
+
}
|
|
98
122
|
if (!isClientSessionToken(clientSessionToken)) {
|
|
99
123
|
throw new SeamHttpInvalidTokenError(
|
|
100
124
|
`Unknown or invalid clientSessionToken format, expected token to start with ${clientSessionTokenPrefix}`
|
|
@@ -105,6 +129,31 @@ var getAuthHeadersForClientSessionToken = ({
|
|
|
105
129
|
"client-session-token": clientSessionToken
|
|
106
130
|
};
|
|
107
131
|
};
|
|
132
|
+
var getAuthHeadersForPublishableKey = (publishableKey) => {
|
|
133
|
+
if (isJwt(publishableKey)) {
|
|
134
|
+
throw new SeamHttpInvalidTokenError(
|
|
135
|
+
"A JWT cannot be used as a publishableKey"
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
if (isAccessToken(publishableKey)) {
|
|
139
|
+
throw new SeamHttpInvalidTokenError(
|
|
140
|
+
"An Access Token cannot be used as a publishableKey"
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
if (isClientSessionToken(publishableKey)) {
|
|
144
|
+
throw new SeamHttpInvalidTokenError(
|
|
145
|
+
"A Client Session Token Key cannot be used as a publishableKey"
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
if (!isPublishableKey(publishableKey)) {
|
|
149
|
+
throw new SeamHttpInvalidTokenError(
|
|
150
|
+
`Unknown or invalid publishableKey format, expected token to start with ${publishableKeyTokenPrefix}`
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
"seam-publishable-key": publishableKey
|
|
155
|
+
};
|
|
156
|
+
};
|
|
108
157
|
var SeamHttpInvalidTokenError = class extends Error {
|
|
109
158
|
constructor(message) {
|
|
110
159
|
super(`SeamHttp received an invalid token: ${message}`);
|
|
@@ -112,75 +161,257 @@ var SeamHttpInvalidTokenError = class extends Error {
|
|
|
112
161
|
Error.captureStackTrace(this, this.constructor);
|
|
113
162
|
}
|
|
114
163
|
};
|
|
164
|
+
var warnOnInsecureuserIdentifierKey = (userIdentifierKey) => {
|
|
165
|
+
if (isEmail(userIdentifierKey)) {
|
|
166
|
+
console.warn(
|
|
167
|
+
...[
|
|
168
|
+
"Using an email for the userIdentifierKey is insecure and may return an error in the future!",
|
|
169
|
+
"This is insecure because an email is common knowledge or easily guessed.",
|
|
170
|
+
"Use something with sufficient entropy known only to the owner of the client session.",
|
|
171
|
+
"For help choosing a user identifier key see",
|
|
172
|
+
"https://docs.seam.co/latest/seam-components/overview/get-started-with-client-side-components#3-select-a-user-identifier-key"
|
|
173
|
+
]
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
115
177
|
var tokenPrefix = "seam_";
|
|
116
178
|
var clientSessionTokenPrefix = "seam_cst";
|
|
179
|
+
var publishableKeyTokenPrefix = "seam_pk";
|
|
117
180
|
var isClientSessionToken = (token) => token.startsWith(clientSessionTokenPrefix);
|
|
118
181
|
var isAccessToken = (token) => token.startsWith("seam_at");
|
|
119
182
|
var isJwt = (token) => token.startsWith("ey");
|
|
120
183
|
var isSeamToken = (token) => token.startsWith(tokenPrefix);
|
|
184
|
+
var isPublishableKey = (token) => token.startsWith(publishableKeyTokenPrefix);
|
|
185
|
+
var isEmail = (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
|
|
121
186
|
|
|
122
|
-
// src/lib/
|
|
123
|
-
var
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
187
|
+
// src/lib/params-serializer.ts
|
|
188
|
+
var paramsSerializer = (params) => {
|
|
189
|
+
const searchParams = new URLSearchParams();
|
|
190
|
+
for (const [name, value] of Object.entries(params)) {
|
|
191
|
+
if (value == null)
|
|
192
|
+
continue;
|
|
193
|
+
if (Array.isArray(value)) {
|
|
194
|
+
if (value.length === 0)
|
|
195
|
+
searchParams.set(name, "");
|
|
196
|
+
if (value.length === 1 && value[0] === "") {
|
|
197
|
+
throw new UnserializableParamError(
|
|
198
|
+
name,
|
|
199
|
+
`is a single element array containing the empty string which is unsupported because it serializes to the empty array`
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
for (const v of value) {
|
|
203
|
+
throwIfUnserializable(name, v);
|
|
204
|
+
searchParams.append(name, v);
|
|
205
|
+
}
|
|
206
|
+
continue;
|
|
134
207
|
}
|
|
208
|
+
throwIfUnserializable(name, value);
|
|
209
|
+
searchParams.set(name, value);
|
|
210
|
+
}
|
|
211
|
+
searchParams.sort();
|
|
212
|
+
return searchParams.toString();
|
|
213
|
+
};
|
|
214
|
+
var throwIfUnserializable = (k, v) => {
|
|
215
|
+
if (v == null) {
|
|
216
|
+
throw new UnserializableParamError(k, `is ${v} or contains ${v}`);
|
|
217
|
+
}
|
|
218
|
+
if (typeof v === "function") {
|
|
219
|
+
throw new UnserializableParamError(
|
|
220
|
+
k,
|
|
221
|
+
"is a function or contains a function"
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
if (typeof v === "object") {
|
|
225
|
+
throw new UnserializableParamError(k, "is an object or contains an object");
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
var UnserializableParamError = class extends Error {
|
|
229
|
+
constructor(name, message) {
|
|
230
|
+
super(`Could not serialize parameter: '${name}' ${message}`);
|
|
231
|
+
this.name = this.constructor.name;
|
|
232
|
+
Error.captureStackTrace(this, this.constructor);
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
// src/lib/seam/connect/client.ts
|
|
237
|
+
var createClient = (options) => {
|
|
238
|
+
if (options.client != null)
|
|
239
|
+
return options.client;
|
|
240
|
+
const client = axios__default.default.create({
|
|
241
|
+
paramsSerializer,
|
|
242
|
+
...options.axiosOptions
|
|
243
|
+
});
|
|
244
|
+
axiosRetry__default.default(client, {
|
|
245
|
+
retries: 2,
|
|
246
|
+
retryDelay: axiosRetry.exponentialDelay,
|
|
247
|
+
...options.axiosRetryOptions
|
|
135
248
|
});
|
|
249
|
+
return client;
|
|
136
250
|
};
|
|
137
251
|
|
|
138
252
|
// src/lib/seam/connect/parse-options.ts
|
|
139
|
-
var
|
|
253
|
+
var defaultEndpoint = "https://connect.getseam.com";
|
|
140
254
|
var parseOptions = (apiKeyOrOptions) => {
|
|
255
|
+
const options = getNormalizedOptions(apiKeyOrOptions);
|
|
256
|
+
if (isSeamHttpOptionsWithClient(options))
|
|
257
|
+
return options;
|
|
258
|
+
return {
|
|
259
|
+
axiosOptions: {
|
|
260
|
+
baseURL: options.endpoint ?? getEndpointFromEnv() ?? defaultEndpoint,
|
|
261
|
+
withCredentials: isSeamHttpOptionsWithClientSessionToken(options),
|
|
262
|
+
...options.axiosOptions,
|
|
263
|
+
headers: {
|
|
264
|
+
...getAuthHeaders(options),
|
|
265
|
+
...options.axiosOptions?.headers
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
axiosRetryOptions: {
|
|
269
|
+
...options.axiosRetryOptions
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
var getNormalizedOptions = (apiKeyOrOptions) => {
|
|
141
274
|
const options = typeof apiKeyOrOptions === "string" ? { apiKey: apiKeyOrOptions } : apiKeyOrOptions;
|
|
142
275
|
if (isSeamHttpOptionsWithClient(options))
|
|
143
|
-
return
|
|
144
|
-
|
|
145
|
-
enableLegacyMethodBehaivor: options.enableLegacyMethodBehaivor ?? enableLegacyMethodBehaivorDefault
|
|
146
|
-
};
|
|
147
|
-
const endpoint = options.endpoint ?? globalThis.process?.env?.["SEAM_ENDPOINT"] ?? globalThis.process?.env?.["SEAM_API_URL"] ?? "https://connect.getseam.com";
|
|
148
|
-
const apiKey = "apiKey" in options ? options.apiKey : globalThis.process?.env?.["SEAM_API_KEY"];
|
|
276
|
+
return options;
|
|
277
|
+
const apiKey = "apiKey" in options ? options.apiKey : getApiKeyFromEnv(options);
|
|
149
278
|
return {
|
|
150
279
|
...options,
|
|
151
|
-
...apiKey != null ? { apiKey } : {}
|
|
152
|
-
endpoint,
|
|
153
|
-
axiosOptions: options.axiosOptions ?? {},
|
|
154
|
-
enableLegacyMethodBehaivor: options.enableLegacyMethodBehaivor ?? enableLegacyMethodBehaivorDefault
|
|
280
|
+
...apiKey != null ? { apiKey } : {}
|
|
155
281
|
};
|
|
156
282
|
};
|
|
283
|
+
var getApiKeyFromEnv = (options) => {
|
|
284
|
+
if ("clientSessionToken" in options && options.clientSessionToken != null) {
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
return globalThis.process?.env?.SEAM_API_KEY;
|
|
288
|
+
};
|
|
289
|
+
var getEndpointFromEnv = () => {
|
|
290
|
+
return globalThis.process?.env?.SEAM_ENDPOINT ?? globalThis.process?.env?.SEAM_API_URL;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
// src/lib/seam/connect/routes/client-sessions.ts
|
|
294
|
+
var SeamHttpClientSessions = class _SeamHttpClientSessions {
|
|
295
|
+
constructor(apiKeyOrOptions = {}) {
|
|
296
|
+
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
297
|
+
this.client = createClient(clientOptions);
|
|
298
|
+
}
|
|
299
|
+
static fromClient(client, options = {}) {
|
|
300
|
+
const constructorOptions = { ...options, client };
|
|
301
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
302
|
+
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
303
|
+
}
|
|
304
|
+
return new _SeamHttpClientSessions(constructorOptions);
|
|
305
|
+
}
|
|
306
|
+
static fromApiKey(apiKey, options = {}) {
|
|
307
|
+
const constructorOptions = { ...options, apiKey };
|
|
308
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
309
|
+
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
310
|
+
}
|
|
311
|
+
return new _SeamHttpClientSessions(constructorOptions);
|
|
312
|
+
}
|
|
313
|
+
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
314
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
315
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
316
|
+
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
317
|
+
}
|
|
318
|
+
return new _SeamHttpClientSessions(constructorOptions);
|
|
319
|
+
}
|
|
320
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
321
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
322
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
323
|
+
const client = createClient(clientOptions);
|
|
324
|
+
const clientSessions = _SeamHttpClientSessions.fromClient(client);
|
|
325
|
+
const { token } = await clientSessions.getOrCreate({
|
|
326
|
+
user_identifier_key: userIdentifierKey
|
|
327
|
+
});
|
|
328
|
+
return _SeamHttpClientSessions.fromClientSessionToken(token, options);
|
|
329
|
+
}
|
|
330
|
+
async create(body) {
|
|
331
|
+
const { data } = await this.client.request({
|
|
332
|
+
url: "/client_sessions/create",
|
|
333
|
+
method: "post",
|
|
334
|
+
data: body
|
|
335
|
+
});
|
|
336
|
+
return data.client_session;
|
|
337
|
+
}
|
|
338
|
+
async delete(body) {
|
|
339
|
+
await this.client.request({
|
|
340
|
+
url: "/client_sessions/delete",
|
|
341
|
+
method: "post",
|
|
342
|
+
data: body
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
async get(body) {
|
|
346
|
+
const { data } = await this.client.request({
|
|
347
|
+
url: "/client_sessions/get",
|
|
348
|
+
method: "post",
|
|
349
|
+
data: body
|
|
350
|
+
});
|
|
351
|
+
return data.client_session;
|
|
352
|
+
}
|
|
353
|
+
async getOrCreate(body) {
|
|
354
|
+
const { data } = await this.client.request({
|
|
355
|
+
url: "/client_sessions/get_or_create",
|
|
356
|
+
method: "post",
|
|
357
|
+
data: body
|
|
358
|
+
});
|
|
359
|
+
return data.client_session;
|
|
360
|
+
}
|
|
361
|
+
async grantAccess(body) {
|
|
362
|
+
const { data } = await this.client.request({
|
|
363
|
+
url: "/client_sessions/grant_access",
|
|
364
|
+
method: "post",
|
|
365
|
+
data: body
|
|
366
|
+
});
|
|
367
|
+
return data.client_session;
|
|
368
|
+
}
|
|
369
|
+
async list(body) {
|
|
370
|
+
const { data } = await this.client.request({
|
|
371
|
+
url: "/client_sessions/list",
|
|
372
|
+
method: "post",
|
|
373
|
+
data: body
|
|
374
|
+
});
|
|
375
|
+
return data.client_sessions;
|
|
376
|
+
}
|
|
377
|
+
};
|
|
157
378
|
|
|
158
379
|
// src/lib/seam/connect/routes/access-codes-unmanaged.ts
|
|
159
380
|
var SeamHttpAccessCodesUnmanaged = class _SeamHttpAccessCodesUnmanaged {
|
|
160
|
-
constructor(apiKeyOrOptions) {
|
|
161
|
-
const
|
|
162
|
-
this.client =
|
|
381
|
+
constructor(apiKeyOrOptions = {}) {
|
|
382
|
+
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
383
|
+
this.client = createClient(clientOptions);
|
|
163
384
|
}
|
|
164
385
|
static fromClient(client, options = {}) {
|
|
165
|
-
const
|
|
166
|
-
if (!isSeamHttpOptionsWithClient(
|
|
386
|
+
const constructorOptions = { ...options, client };
|
|
387
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
167
388
|
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
168
389
|
}
|
|
169
|
-
return new _SeamHttpAccessCodesUnmanaged(
|
|
390
|
+
return new _SeamHttpAccessCodesUnmanaged(constructorOptions);
|
|
170
391
|
}
|
|
171
392
|
static fromApiKey(apiKey, options = {}) {
|
|
172
|
-
const
|
|
173
|
-
if (!isSeamHttpOptionsWithApiKey(
|
|
393
|
+
const constructorOptions = { ...options, apiKey };
|
|
394
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
174
395
|
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
175
396
|
}
|
|
176
|
-
return new _SeamHttpAccessCodesUnmanaged(
|
|
397
|
+
return new _SeamHttpAccessCodesUnmanaged(constructorOptions);
|
|
177
398
|
}
|
|
178
399
|
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
179
|
-
const
|
|
180
|
-
if (!isSeamHttpOptionsWithClientSessionToken(
|
|
400
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
401
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
181
402
|
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
182
403
|
}
|
|
183
|
-
return new _SeamHttpAccessCodesUnmanaged(
|
|
404
|
+
return new _SeamHttpAccessCodesUnmanaged(constructorOptions);
|
|
405
|
+
}
|
|
406
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
407
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
408
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
409
|
+
const client = createClient(clientOptions);
|
|
410
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
411
|
+
const { token } = await clientSessions.getOrCreate({
|
|
412
|
+
user_identifier_key: userIdentifierKey
|
|
413
|
+
});
|
|
414
|
+
return _SeamHttpAccessCodesUnmanaged.fromClientSessionToken(token, options);
|
|
184
415
|
}
|
|
185
416
|
async convertToManaged(body) {
|
|
186
417
|
await this.client.request({
|
|
@@ -225,30 +456,40 @@ var SeamHttpAccessCodesUnmanaged = class _SeamHttpAccessCodesUnmanaged {
|
|
|
225
456
|
|
|
226
457
|
// src/lib/seam/connect/routes/access-codes.ts
|
|
227
458
|
var SeamHttpAccessCodes = class _SeamHttpAccessCodes {
|
|
228
|
-
constructor(apiKeyOrOptions) {
|
|
229
|
-
const
|
|
230
|
-
this.client =
|
|
459
|
+
constructor(apiKeyOrOptions = {}) {
|
|
460
|
+
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
461
|
+
this.client = createClient(clientOptions);
|
|
231
462
|
}
|
|
232
463
|
static fromClient(client, options = {}) {
|
|
233
|
-
const
|
|
234
|
-
if (!isSeamHttpOptionsWithClient(
|
|
464
|
+
const constructorOptions = { ...options, client };
|
|
465
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
235
466
|
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
236
467
|
}
|
|
237
|
-
return new _SeamHttpAccessCodes(
|
|
468
|
+
return new _SeamHttpAccessCodes(constructorOptions);
|
|
238
469
|
}
|
|
239
470
|
static fromApiKey(apiKey, options = {}) {
|
|
240
|
-
const
|
|
241
|
-
if (!isSeamHttpOptionsWithApiKey(
|
|
471
|
+
const constructorOptions = { ...options, apiKey };
|
|
472
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
242
473
|
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
243
474
|
}
|
|
244
|
-
return new _SeamHttpAccessCodes(
|
|
475
|
+
return new _SeamHttpAccessCodes(constructorOptions);
|
|
245
476
|
}
|
|
246
477
|
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
247
|
-
const
|
|
248
|
-
if (!isSeamHttpOptionsWithClientSessionToken(
|
|
478
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
479
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
249
480
|
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
250
481
|
}
|
|
251
|
-
return new _SeamHttpAccessCodes(
|
|
482
|
+
return new _SeamHttpAccessCodes(constructorOptions);
|
|
483
|
+
}
|
|
484
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
485
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
486
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
487
|
+
const client = createClient(clientOptions);
|
|
488
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
489
|
+
const { token } = await clientSessions.getOrCreate({
|
|
490
|
+
user_identifier_key: userIdentifierKey
|
|
491
|
+
});
|
|
492
|
+
return _SeamHttpAccessCodes.fromClientSessionToken(token, options);
|
|
252
493
|
}
|
|
253
494
|
get unmanaged() {
|
|
254
495
|
return SeamHttpAccessCodesUnmanaged.fromClient(this.client);
|
|
@@ -276,12 +517,12 @@ var SeamHttpAccessCodes = class _SeamHttpAccessCodes {
|
|
|
276
517
|
data: body
|
|
277
518
|
});
|
|
278
519
|
}
|
|
279
|
-
async generateCode(
|
|
520
|
+
async generateCode(body) {
|
|
280
521
|
const { data } = await this.client.request(
|
|
281
522
|
{
|
|
282
523
|
url: "/access_codes/generate_code",
|
|
283
|
-
method: "
|
|
284
|
-
|
|
524
|
+
method: "post",
|
|
525
|
+
data: body
|
|
285
526
|
}
|
|
286
527
|
);
|
|
287
528
|
return data.generated_code;
|
|
@@ -321,30 +562,40 @@ var SeamHttpAccessCodes = class _SeamHttpAccessCodes {
|
|
|
321
562
|
|
|
322
563
|
// src/lib/seam/connect/routes/acs-access-groups.ts
|
|
323
564
|
var SeamHttpAcsAccessGroups = class _SeamHttpAcsAccessGroups {
|
|
324
|
-
constructor(apiKeyOrOptions) {
|
|
325
|
-
const
|
|
326
|
-
this.client =
|
|
565
|
+
constructor(apiKeyOrOptions = {}) {
|
|
566
|
+
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
567
|
+
this.client = createClient(clientOptions);
|
|
327
568
|
}
|
|
328
569
|
static fromClient(client, options = {}) {
|
|
329
|
-
const
|
|
330
|
-
if (!isSeamHttpOptionsWithClient(
|
|
570
|
+
const constructorOptions = { ...options, client };
|
|
571
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
331
572
|
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
332
573
|
}
|
|
333
|
-
return new _SeamHttpAcsAccessGroups(
|
|
574
|
+
return new _SeamHttpAcsAccessGroups(constructorOptions);
|
|
334
575
|
}
|
|
335
576
|
static fromApiKey(apiKey, options = {}) {
|
|
336
|
-
const
|
|
337
|
-
if (!isSeamHttpOptionsWithApiKey(
|
|
577
|
+
const constructorOptions = { ...options, apiKey };
|
|
578
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
338
579
|
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
339
580
|
}
|
|
340
|
-
return new _SeamHttpAcsAccessGroups(
|
|
581
|
+
return new _SeamHttpAcsAccessGroups(constructorOptions);
|
|
341
582
|
}
|
|
342
583
|
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
343
|
-
const
|
|
344
|
-
if (!isSeamHttpOptionsWithClientSessionToken(
|
|
584
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
585
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
345
586
|
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
346
587
|
}
|
|
347
|
-
return new _SeamHttpAcsAccessGroups(
|
|
588
|
+
return new _SeamHttpAcsAccessGroups(constructorOptions);
|
|
589
|
+
}
|
|
590
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
591
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
592
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
593
|
+
const client = createClient(clientOptions);
|
|
594
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
595
|
+
const { token } = await clientSessions.getOrCreate({
|
|
596
|
+
user_identifier_key: userIdentifierKey
|
|
597
|
+
});
|
|
598
|
+
return _SeamHttpAcsAccessGroups.fromClientSessionToken(token, options);
|
|
348
599
|
}
|
|
349
600
|
async addUser(body) {
|
|
350
601
|
await this.client.request({
|
|
@@ -410,30 +661,40 @@ var SeamHttpAcsAccessGroups = class _SeamHttpAcsAccessGroups {
|
|
|
410
661
|
|
|
411
662
|
// src/lib/seam/connect/routes/acs-credentials.ts
|
|
412
663
|
var SeamHttpAcsCredentials = class _SeamHttpAcsCredentials {
|
|
413
|
-
constructor(apiKeyOrOptions) {
|
|
414
|
-
const
|
|
415
|
-
this.client =
|
|
664
|
+
constructor(apiKeyOrOptions = {}) {
|
|
665
|
+
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
666
|
+
this.client = createClient(clientOptions);
|
|
416
667
|
}
|
|
417
668
|
static fromClient(client, options = {}) {
|
|
418
|
-
const
|
|
419
|
-
if (!isSeamHttpOptionsWithClient(
|
|
669
|
+
const constructorOptions = { ...options, client };
|
|
670
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
420
671
|
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
421
672
|
}
|
|
422
|
-
return new _SeamHttpAcsCredentials(
|
|
673
|
+
return new _SeamHttpAcsCredentials(constructorOptions);
|
|
423
674
|
}
|
|
424
675
|
static fromApiKey(apiKey, options = {}) {
|
|
425
|
-
const
|
|
426
|
-
if (!isSeamHttpOptionsWithApiKey(
|
|
676
|
+
const constructorOptions = { ...options, apiKey };
|
|
677
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
427
678
|
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
428
679
|
}
|
|
429
|
-
return new _SeamHttpAcsCredentials(
|
|
680
|
+
return new _SeamHttpAcsCredentials(constructorOptions);
|
|
430
681
|
}
|
|
431
682
|
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
432
|
-
const
|
|
433
|
-
if (!isSeamHttpOptionsWithClientSessionToken(
|
|
683
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
684
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
434
685
|
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
435
686
|
}
|
|
436
|
-
return new _SeamHttpAcsCredentials(
|
|
687
|
+
return new _SeamHttpAcsCredentials(constructorOptions);
|
|
688
|
+
}
|
|
689
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
690
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
691
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
692
|
+
const client = createClient(clientOptions);
|
|
693
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
694
|
+
const { token } = await clientSessions.getOrCreate({
|
|
695
|
+
user_identifier_key: userIdentifierKey
|
|
696
|
+
});
|
|
697
|
+
return _SeamHttpAcsCredentials.fromClientSessionToken(token, options);
|
|
437
698
|
}
|
|
438
699
|
async create(body) {
|
|
439
700
|
const { data } = await this.client.request({
|
|
@@ -470,30 +731,40 @@ var SeamHttpAcsCredentials = class _SeamHttpAcsCredentials {
|
|
|
470
731
|
|
|
471
732
|
// src/lib/seam/connect/routes/acs-systems.ts
|
|
472
733
|
var SeamHttpAcsSystems = class _SeamHttpAcsSystems {
|
|
473
|
-
constructor(apiKeyOrOptions) {
|
|
474
|
-
const
|
|
475
|
-
this.client =
|
|
734
|
+
constructor(apiKeyOrOptions = {}) {
|
|
735
|
+
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
736
|
+
this.client = createClient(clientOptions);
|
|
476
737
|
}
|
|
477
738
|
static fromClient(client, options = {}) {
|
|
478
|
-
const
|
|
479
|
-
if (!isSeamHttpOptionsWithClient(
|
|
739
|
+
const constructorOptions = { ...options, client };
|
|
740
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
480
741
|
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
481
742
|
}
|
|
482
|
-
return new _SeamHttpAcsSystems(
|
|
743
|
+
return new _SeamHttpAcsSystems(constructorOptions);
|
|
483
744
|
}
|
|
484
745
|
static fromApiKey(apiKey, options = {}) {
|
|
485
|
-
const
|
|
486
|
-
if (!isSeamHttpOptionsWithApiKey(
|
|
746
|
+
const constructorOptions = { ...options, apiKey };
|
|
747
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
487
748
|
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
488
749
|
}
|
|
489
|
-
return new _SeamHttpAcsSystems(
|
|
750
|
+
return new _SeamHttpAcsSystems(constructorOptions);
|
|
490
751
|
}
|
|
491
752
|
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
492
|
-
const
|
|
493
|
-
if (!isSeamHttpOptionsWithClientSessionToken(
|
|
753
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
754
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
494
755
|
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
495
756
|
}
|
|
496
|
-
return new _SeamHttpAcsSystems(
|
|
757
|
+
return new _SeamHttpAcsSystems(constructorOptions);
|
|
758
|
+
}
|
|
759
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
760
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
761
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
762
|
+
const client = createClient(clientOptions);
|
|
763
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
764
|
+
const { token } = await clientSessions.getOrCreate({
|
|
765
|
+
user_identifier_key: userIdentifierKey
|
|
766
|
+
});
|
|
767
|
+
return _SeamHttpAcsSystems.fromClientSessionToken(token, options);
|
|
497
768
|
}
|
|
498
769
|
async get(body) {
|
|
499
770
|
const { data } = await this.client.request({
|
|
@@ -503,11 +774,11 @@ var SeamHttpAcsSystems = class _SeamHttpAcsSystems {
|
|
|
503
774
|
});
|
|
504
775
|
return data.acs_system;
|
|
505
776
|
}
|
|
506
|
-
async list(
|
|
777
|
+
async list(body) {
|
|
507
778
|
const { data } = await this.client.request({
|
|
508
779
|
url: "/acs/systems/list",
|
|
509
|
-
method: "
|
|
510
|
-
|
|
780
|
+
method: "post",
|
|
781
|
+
data: body
|
|
511
782
|
});
|
|
512
783
|
return data.acs_systems;
|
|
513
784
|
}
|
|
@@ -515,30 +786,40 @@ var SeamHttpAcsSystems = class _SeamHttpAcsSystems {
|
|
|
515
786
|
|
|
516
787
|
// src/lib/seam/connect/routes/acs-users.ts
|
|
517
788
|
var SeamHttpAcsUsers = class _SeamHttpAcsUsers {
|
|
518
|
-
constructor(apiKeyOrOptions) {
|
|
519
|
-
const
|
|
520
|
-
this.client =
|
|
789
|
+
constructor(apiKeyOrOptions = {}) {
|
|
790
|
+
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
791
|
+
this.client = createClient(clientOptions);
|
|
521
792
|
}
|
|
522
793
|
static fromClient(client, options = {}) {
|
|
523
|
-
const
|
|
524
|
-
if (!isSeamHttpOptionsWithClient(
|
|
794
|
+
const constructorOptions = { ...options, client };
|
|
795
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
525
796
|
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
526
797
|
}
|
|
527
|
-
return new _SeamHttpAcsUsers(
|
|
798
|
+
return new _SeamHttpAcsUsers(constructorOptions);
|
|
528
799
|
}
|
|
529
800
|
static fromApiKey(apiKey, options = {}) {
|
|
530
|
-
const
|
|
531
|
-
if (!isSeamHttpOptionsWithApiKey(
|
|
801
|
+
const constructorOptions = { ...options, apiKey };
|
|
802
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
532
803
|
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
533
804
|
}
|
|
534
|
-
return new _SeamHttpAcsUsers(
|
|
805
|
+
return new _SeamHttpAcsUsers(constructorOptions);
|
|
535
806
|
}
|
|
536
807
|
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
537
|
-
const
|
|
538
|
-
if (!isSeamHttpOptionsWithClientSessionToken(
|
|
808
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
809
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
539
810
|
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
540
811
|
}
|
|
541
|
-
return new _SeamHttpAcsUsers(
|
|
812
|
+
return new _SeamHttpAcsUsers(constructorOptions);
|
|
813
|
+
}
|
|
814
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
815
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
816
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
817
|
+
const client = createClient(clientOptions);
|
|
818
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
819
|
+
const { token } = await clientSessions.getOrCreate({
|
|
820
|
+
user_identifier_key: userIdentifierKey
|
|
821
|
+
});
|
|
822
|
+
return _SeamHttpAcsUsers.fromClientSessionToken(token, options);
|
|
542
823
|
}
|
|
543
824
|
async addToAccessGroup(body) {
|
|
544
825
|
await this.client.request({
|
|
@@ -585,6 +866,20 @@ var SeamHttpAcsUsers = class _SeamHttpAcsUsers {
|
|
|
585
866
|
data: body
|
|
586
867
|
});
|
|
587
868
|
}
|
|
869
|
+
async suspend(body) {
|
|
870
|
+
await this.client.request({
|
|
871
|
+
url: "/acs/users/suspend",
|
|
872
|
+
method: "post",
|
|
873
|
+
data: body
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
async unsuspend(body) {
|
|
877
|
+
await this.client.request({
|
|
878
|
+
url: "/acs/users/unsuspend",
|
|
879
|
+
method: "post",
|
|
880
|
+
data: body
|
|
881
|
+
});
|
|
882
|
+
}
|
|
588
883
|
async update(body) {
|
|
589
884
|
await this.client.request({
|
|
590
885
|
url: "/acs/users/update",
|
|
@@ -596,30 +891,40 @@ var SeamHttpAcsUsers = class _SeamHttpAcsUsers {
|
|
|
596
891
|
|
|
597
892
|
// src/lib/seam/connect/routes/acs.ts
|
|
598
893
|
var SeamHttpAcs = class _SeamHttpAcs {
|
|
599
|
-
constructor(apiKeyOrOptions) {
|
|
600
|
-
const
|
|
601
|
-
this.client =
|
|
894
|
+
constructor(apiKeyOrOptions = {}) {
|
|
895
|
+
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
896
|
+
this.client = createClient(clientOptions);
|
|
602
897
|
}
|
|
603
898
|
static fromClient(client, options = {}) {
|
|
604
|
-
const
|
|
605
|
-
if (!isSeamHttpOptionsWithClient(
|
|
899
|
+
const constructorOptions = { ...options, client };
|
|
900
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
606
901
|
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
607
902
|
}
|
|
608
|
-
return new _SeamHttpAcs(
|
|
903
|
+
return new _SeamHttpAcs(constructorOptions);
|
|
609
904
|
}
|
|
610
905
|
static fromApiKey(apiKey, options = {}) {
|
|
611
|
-
const
|
|
612
|
-
if (!isSeamHttpOptionsWithApiKey(
|
|
906
|
+
const constructorOptions = { ...options, apiKey };
|
|
907
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
613
908
|
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
614
909
|
}
|
|
615
|
-
return new _SeamHttpAcs(
|
|
910
|
+
return new _SeamHttpAcs(constructorOptions);
|
|
616
911
|
}
|
|
617
912
|
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
618
|
-
const
|
|
619
|
-
if (!isSeamHttpOptionsWithClientSessionToken(
|
|
913
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
914
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
620
915
|
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
621
916
|
}
|
|
622
|
-
return new _SeamHttpAcs(
|
|
917
|
+
return new _SeamHttpAcs(constructorOptions);
|
|
918
|
+
}
|
|
919
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
920
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
921
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
922
|
+
const client = createClient(clientOptions);
|
|
923
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
924
|
+
const { token } = await clientSessions.getOrCreate({
|
|
925
|
+
user_identifier_key: userIdentifierKey
|
|
926
|
+
});
|
|
927
|
+
return _SeamHttpAcs.fromClientSessionToken(token, options);
|
|
623
928
|
}
|
|
624
929
|
get accessGroups() {
|
|
625
930
|
return SeamHttpAcsAccessGroups.fromClient(this.client);
|
|
@@ -637,30 +942,40 @@ var SeamHttpAcs = class _SeamHttpAcs {
|
|
|
637
942
|
|
|
638
943
|
// src/lib/seam/connect/routes/action-attempts.ts
|
|
639
944
|
var SeamHttpActionAttempts = class _SeamHttpActionAttempts {
|
|
640
|
-
constructor(apiKeyOrOptions) {
|
|
641
|
-
const
|
|
642
|
-
this.client =
|
|
945
|
+
constructor(apiKeyOrOptions = {}) {
|
|
946
|
+
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
947
|
+
this.client = createClient(clientOptions);
|
|
643
948
|
}
|
|
644
949
|
static fromClient(client, options = {}) {
|
|
645
|
-
const
|
|
646
|
-
if (!isSeamHttpOptionsWithClient(
|
|
950
|
+
const constructorOptions = { ...options, client };
|
|
951
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
647
952
|
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
648
953
|
}
|
|
649
|
-
return new _SeamHttpActionAttempts(
|
|
954
|
+
return new _SeamHttpActionAttempts(constructorOptions);
|
|
650
955
|
}
|
|
651
956
|
static fromApiKey(apiKey, options = {}) {
|
|
652
|
-
const
|
|
653
|
-
if (!isSeamHttpOptionsWithApiKey(
|
|
957
|
+
const constructorOptions = { ...options, apiKey };
|
|
958
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
654
959
|
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
655
960
|
}
|
|
656
|
-
return new _SeamHttpActionAttempts(
|
|
961
|
+
return new _SeamHttpActionAttempts(constructorOptions);
|
|
657
962
|
}
|
|
658
963
|
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
659
|
-
const
|
|
660
|
-
if (!isSeamHttpOptionsWithClientSessionToken(
|
|
964
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
965
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
661
966
|
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
662
967
|
}
|
|
663
|
-
return new _SeamHttpActionAttempts(
|
|
968
|
+
return new _SeamHttpActionAttempts(constructorOptions);
|
|
969
|
+
}
|
|
970
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
971
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
972
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
973
|
+
const client = createClient(clientOptions);
|
|
974
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
975
|
+
const { token } = await clientSessions.getOrCreate({
|
|
976
|
+
user_identifier_key: userIdentifierKey
|
|
977
|
+
});
|
|
978
|
+
return _SeamHttpActionAttempts.fromClientSessionToken(token, options);
|
|
664
979
|
}
|
|
665
980
|
async get(body) {
|
|
666
981
|
const { data } = await this.client.request({
|
|
@@ -680,100 +995,42 @@ var SeamHttpActionAttempts = class _SeamHttpActionAttempts {
|
|
|
680
995
|
}
|
|
681
996
|
};
|
|
682
997
|
|
|
683
|
-
// src/lib/seam/connect/routes/client-sessions.ts
|
|
684
|
-
var SeamHttpClientSessions = class _SeamHttpClientSessions {
|
|
685
|
-
constructor(apiKeyOrOptions) {
|
|
686
|
-
const options = parseOptions(apiKeyOrOptions);
|
|
687
|
-
this.client = createAxiosClient(options);
|
|
688
|
-
}
|
|
689
|
-
static fromClient(client, options = {}) {
|
|
690
|
-
const opts = { ...options, client };
|
|
691
|
-
if (!isSeamHttpOptionsWithClient(opts)) {
|
|
692
|
-
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
693
|
-
}
|
|
694
|
-
return new _SeamHttpClientSessions(opts);
|
|
695
|
-
}
|
|
696
|
-
static fromApiKey(apiKey, options = {}) {
|
|
697
|
-
const opts = { ...options, apiKey };
|
|
698
|
-
if (!isSeamHttpOptionsWithApiKey(opts)) {
|
|
699
|
-
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
700
|
-
}
|
|
701
|
-
return new _SeamHttpClientSessions(opts);
|
|
702
|
-
}
|
|
703
|
-
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
704
|
-
const opts = { ...options, clientSessionToken };
|
|
705
|
-
if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
|
|
706
|
-
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
707
|
-
}
|
|
708
|
-
return new _SeamHttpClientSessions(opts);
|
|
709
|
-
}
|
|
710
|
-
async create(body) {
|
|
711
|
-
const { data } = await this.client.request({
|
|
712
|
-
url: "/client_sessions/create",
|
|
713
|
-
method: "post",
|
|
714
|
-
data: body
|
|
715
|
-
});
|
|
716
|
-
return data.client_session;
|
|
717
|
-
}
|
|
718
|
-
async delete(body) {
|
|
719
|
-
await this.client.request({
|
|
720
|
-
url: "/client_sessions/delete",
|
|
721
|
-
method: "post",
|
|
722
|
-
data: body
|
|
723
|
-
});
|
|
724
|
-
}
|
|
725
|
-
async get(body) {
|
|
726
|
-
const { data } = await this.client.request({
|
|
727
|
-
url: "/client_sessions/get",
|
|
728
|
-
method: "post",
|
|
729
|
-
data: body
|
|
730
|
-
});
|
|
731
|
-
return data.client_session;
|
|
732
|
-
}
|
|
733
|
-
async grantAccess(body) {
|
|
734
|
-
const { data } = await this.client.request({
|
|
735
|
-
url: "/client_sessions/grant_access",
|
|
736
|
-
method: "post",
|
|
737
|
-
data: body
|
|
738
|
-
});
|
|
739
|
-
return data.client_session;
|
|
740
|
-
}
|
|
741
|
-
async list(body) {
|
|
742
|
-
const { data } = await this.client.request({
|
|
743
|
-
url: "/client_sessions/list",
|
|
744
|
-
method: "post",
|
|
745
|
-
data: body
|
|
746
|
-
});
|
|
747
|
-
return data.client_sessions;
|
|
748
|
-
}
|
|
749
|
-
};
|
|
750
|
-
|
|
751
998
|
// src/lib/seam/connect/routes/connect-webviews.ts
|
|
752
999
|
var SeamHttpConnectWebviews = class _SeamHttpConnectWebviews {
|
|
753
|
-
constructor(apiKeyOrOptions) {
|
|
754
|
-
const
|
|
755
|
-
this.client =
|
|
1000
|
+
constructor(apiKeyOrOptions = {}) {
|
|
1001
|
+
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
1002
|
+
this.client = createClient(clientOptions);
|
|
756
1003
|
}
|
|
757
1004
|
static fromClient(client, options = {}) {
|
|
758
|
-
const
|
|
759
|
-
if (!isSeamHttpOptionsWithClient(
|
|
1005
|
+
const constructorOptions = { ...options, client };
|
|
1006
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
760
1007
|
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
761
1008
|
}
|
|
762
|
-
return new _SeamHttpConnectWebviews(
|
|
1009
|
+
return new _SeamHttpConnectWebviews(constructorOptions);
|
|
763
1010
|
}
|
|
764
1011
|
static fromApiKey(apiKey, options = {}) {
|
|
765
|
-
const
|
|
766
|
-
if (!isSeamHttpOptionsWithApiKey(
|
|
1012
|
+
const constructorOptions = { ...options, apiKey };
|
|
1013
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
767
1014
|
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
768
1015
|
}
|
|
769
|
-
return new _SeamHttpConnectWebviews(
|
|
1016
|
+
return new _SeamHttpConnectWebviews(constructorOptions);
|
|
770
1017
|
}
|
|
771
1018
|
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
772
|
-
const
|
|
773
|
-
if (!isSeamHttpOptionsWithClientSessionToken(
|
|
1019
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
1020
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
774
1021
|
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
775
1022
|
}
|
|
776
|
-
return new _SeamHttpConnectWebviews(
|
|
1023
|
+
return new _SeamHttpConnectWebviews(constructorOptions);
|
|
1024
|
+
}
|
|
1025
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
1026
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
1027
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
1028
|
+
const client = createClient(clientOptions);
|
|
1029
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
1030
|
+
const { token } = await clientSessions.getOrCreate({
|
|
1031
|
+
user_identifier_key: userIdentifierKey
|
|
1032
|
+
});
|
|
1033
|
+
return _SeamHttpConnectWebviews.fromClientSessionToken(token, options);
|
|
777
1034
|
}
|
|
778
1035
|
async create(body) {
|
|
779
1036
|
const { data } = await this.client.request({
|
|
@@ -798,11 +1055,11 @@ var SeamHttpConnectWebviews = class _SeamHttpConnectWebviews {
|
|
|
798
1055
|
});
|
|
799
1056
|
return data.connect_webview;
|
|
800
1057
|
}
|
|
801
|
-
async list(
|
|
1058
|
+
async list(body) {
|
|
802
1059
|
const { data } = await this.client.request({
|
|
803
1060
|
url: "/connect_webviews/list",
|
|
804
|
-
method: "
|
|
805
|
-
|
|
1061
|
+
method: "post",
|
|
1062
|
+
data: body
|
|
806
1063
|
});
|
|
807
1064
|
return data.connect_webviews;
|
|
808
1065
|
}
|
|
@@ -817,30 +1074,40 @@ var SeamHttpConnectWebviews = class _SeamHttpConnectWebviews {
|
|
|
817
1074
|
|
|
818
1075
|
// src/lib/seam/connect/routes/connected-accounts.ts
|
|
819
1076
|
var SeamHttpConnectedAccounts = class _SeamHttpConnectedAccounts {
|
|
820
|
-
constructor(apiKeyOrOptions) {
|
|
821
|
-
const
|
|
822
|
-
this.client =
|
|
1077
|
+
constructor(apiKeyOrOptions = {}) {
|
|
1078
|
+
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
1079
|
+
this.client = createClient(clientOptions);
|
|
823
1080
|
}
|
|
824
1081
|
static fromClient(client, options = {}) {
|
|
825
|
-
const
|
|
826
|
-
if (!isSeamHttpOptionsWithClient(
|
|
1082
|
+
const constructorOptions = { ...options, client };
|
|
1083
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
827
1084
|
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
828
1085
|
}
|
|
829
|
-
return new _SeamHttpConnectedAccounts(
|
|
1086
|
+
return new _SeamHttpConnectedAccounts(constructorOptions);
|
|
830
1087
|
}
|
|
831
1088
|
static fromApiKey(apiKey, options = {}) {
|
|
832
|
-
const
|
|
833
|
-
if (!isSeamHttpOptionsWithApiKey(
|
|
1089
|
+
const constructorOptions = { ...options, apiKey };
|
|
1090
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
834
1091
|
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
835
1092
|
}
|
|
836
|
-
return new _SeamHttpConnectedAccounts(
|
|
1093
|
+
return new _SeamHttpConnectedAccounts(constructorOptions);
|
|
837
1094
|
}
|
|
838
1095
|
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
839
|
-
const
|
|
840
|
-
if (!isSeamHttpOptionsWithClientSessionToken(
|
|
1096
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
1097
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
841
1098
|
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
842
1099
|
}
|
|
843
|
-
return new _SeamHttpConnectedAccounts(
|
|
1100
|
+
return new _SeamHttpConnectedAccounts(constructorOptions);
|
|
1101
|
+
}
|
|
1102
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
1103
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
1104
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
1105
|
+
const client = createClient(clientOptions);
|
|
1106
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
1107
|
+
const { token } = await clientSessions.getOrCreate({
|
|
1108
|
+
user_identifier_key: userIdentifierKey
|
|
1109
|
+
});
|
|
1110
|
+
return _SeamHttpConnectedAccounts.fromClientSessionToken(token, options);
|
|
844
1111
|
}
|
|
845
1112
|
async delete(body) {
|
|
846
1113
|
await this.client.request({
|
|
@@ -869,30 +1136,40 @@ var SeamHttpConnectedAccounts = class _SeamHttpConnectedAccounts {
|
|
|
869
1136
|
|
|
870
1137
|
// src/lib/seam/connect/routes/devices-unmanaged.ts
|
|
871
1138
|
var SeamHttpDevicesUnmanaged = class _SeamHttpDevicesUnmanaged {
|
|
872
|
-
constructor(apiKeyOrOptions) {
|
|
873
|
-
const
|
|
874
|
-
this.client =
|
|
1139
|
+
constructor(apiKeyOrOptions = {}) {
|
|
1140
|
+
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
1141
|
+
this.client = createClient(clientOptions);
|
|
875
1142
|
}
|
|
876
1143
|
static fromClient(client, options = {}) {
|
|
877
|
-
const
|
|
878
|
-
if (!isSeamHttpOptionsWithClient(
|
|
1144
|
+
const constructorOptions = { ...options, client };
|
|
1145
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
879
1146
|
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
880
1147
|
}
|
|
881
|
-
return new _SeamHttpDevicesUnmanaged(
|
|
1148
|
+
return new _SeamHttpDevicesUnmanaged(constructorOptions);
|
|
882
1149
|
}
|
|
883
1150
|
static fromApiKey(apiKey, options = {}) {
|
|
884
|
-
const
|
|
885
|
-
if (!isSeamHttpOptionsWithApiKey(
|
|
1151
|
+
const constructorOptions = { ...options, apiKey };
|
|
1152
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
886
1153
|
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
887
1154
|
}
|
|
888
|
-
return new _SeamHttpDevicesUnmanaged(
|
|
1155
|
+
return new _SeamHttpDevicesUnmanaged(constructorOptions);
|
|
889
1156
|
}
|
|
890
1157
|
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
891
|
-
const
|
|
892
|
-
if (!isSeamHttpOptionsWithClientSessionToken(
|
|
1158
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
1159
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
893
1160
|
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
894
1161
|
}
|
|
895
|
-
return new _SeamHttpDevicesUnmanaged(
|
|
1162
|
+
return new _SeamHttpDevicesUnmanaged(constructorOptions);
|
|
1163
|
+
}
|
|
1164
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
1165
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
1166
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
1167
|
+
const client = createClient(clientOptions);
|
|
1168
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
1169
|
+
const { token } = await clientSessions.getOrCreate({
|
|
1170
|
+
user_identifier_key: userIdentifierKey
|
|
1171
|
+
});
|
|
1172
|
+
return _SeamHttpDevicesUnmanaged.fromClientSessionToken(token, options);
|
|
896
1173
|
}
|
|
897
1174
|
async get(body) {
|
|
898
1175
|
const { data } = await this.client.request({
|
|
@@ -921,30 +1198,40 @@ var SeamHttpDevicesUnmanaged = class _SeamHttpDevicesUnmanaged {
|
|
|
921
1198
|
|
|
922
1199
|
// src/lib/seam/connect/routes/devices.ts
|
|
923
1200
|
var SeamHttpDevices = class _SeamHttpDevices {
|
|
924
|
-
constructor(apiKeyOrOptions) {
|
|
925
|
-
const
|
|
926
|
-
this.client =
|
|
1201
|
+
constructor(apiKeyOrOptions = {}) {
|
|
1202
|
+
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
1203
|
+
this.client = createClient(clientOptions);
|
|
927
1204
|
}
|
|
928
1205
|
static fromClient(client, options = {}) {
|
|
929
|
-
const
|
|
930
|
-
if (!isSeamHttpOptionsWithClient(
|
|
1206
|
+
const constructorOptions = { ...options, client };
|
|
1207
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
931
1208
|
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
932
1209
|
}
|
|
933
|
-
return new _SeamHttpDevices(
|
|
1210
|
+
return new _SeamHttpDevices(constructorOptions);
|
|
934
1211
|
}
|
|
935
1212
|
static fromApiKey(apiKey, options = {}) {
|
|
936
|
-
const
|
|
937
|
-
if (!isSeamHttpOptionsWithApiKey(
|
|
1213
|
+
const constructorOptions = { ...options, apiKey };
|
|
1214
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
938
1215
|
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
939
1216
|
}
|
|
940
|
-
return new _SeamHttpDevices(
|
|
1217
|
+
return new _SeamHttpDevices(constructorOptions);
|
|
941
1218
|
}
|
|
942
1219
|
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
943
|
-
const
|
|
944
|
-
if (!isSeamHttpOptionsWithClientSessionToken(
|
|
1220
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
1221
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
945
1222
|
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
946
1223
|
}
|
|
947
|
-
return new _SeamHttpDevices(
|
|
1224
|
+
return new _SeamHttpDevices(constructorOptions);
|
|
1225
|
+
}
|
|
1226
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
1227
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
1228
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
1229
|
+
const client = createClient(clientOptions);
|
|
1230
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
1231
|
+
const { token } = await clientSessions.getOrCreate({
|
|
1232
|
+
user_identifier_key: userIdentifierKey
|
|
1233
|
+
});
|
|
1234
|
+
return _SeamHttpDevices.fromClientSessionToken(token, options);
|
|
948
1235
|
}
|
|
949
1236
|
get unmanaged() {
|
|
950
1237
|
return SeamHttpDevicesUnmanaged.fromClient(this.client);
|
|
@@ -991,30 +1278,40 @@ var SeamHttpDevices = class _SeamHttpDevices {
|
|
|
991
1278
|
|
|
992
1279
|
// src/lib/seam/connect/routes/events.ts
|
|
993
1280
|
var SeamHttpEvents = class _SeamHttpEvents {
|
|
994
|
-
constructor(apiKeyOrOptions) {
|
|
995
|
-
const
|
|
996
|
-
this.client =
|
|
1281
|
+
constructor(apiKeyOrOptions = {}) {
|
|
1282
|
+
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
1283
|
+
this.client = createClient(clientOptions);
|
|
997
1284
|
}
|
|
998
1285
|
static fromClient(client, options = {}) {
|
|
999
|
-
const
|
|
1000
|
-
if (!isSeamHttpOptionsWithClient(
|
|
1286
|
+
const constructorOptions = { ...options, client };
|
|
1287
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
1001
1288
|
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
1002
1289
|
}
|
|
1003
|
-
return new _SeamHttpEvents(
|
|
1290
|
+
return new _SeamHttpEvents(constructorOptions);
|
|
1004
1291
|
}
|
|
1005
1292
|
static fromApiKey(apiKey, options = {}) {
|
|
1006
|
-
const
|
|
1007
|
-
if (!isSeamHttpOptionsWithApiKey(
|
|
1293
|
+
const constructorOptions = { ...options, apiKey };
|
|
1294
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
1008
1295
|
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
1009
1296
|
}
|
|
1010
|
-
return new _SeamHttpEvents(
|
|
1297
|
+
return new _SeamHttpEvents(constructorOptions);
|
|
1011
1298
|
}
|
|
1012
1299
|
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
1013
|
-
const
|
|
1014
|
-
if (!isSeamHttpOptionsWithClientSessionToken(
|
|
1300
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
1301
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
1015
1302
|
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
1016
1303
|
}
|
|
1017
|
-
return new _SeamHttpEvents(
|
|
1304
|
+
return new _SeamHttpEvents(constructorOptions);
|
|
1305
|
+
}
|
|
1306
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
1307
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
1308
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
1309
|
+
const client = createClient(clientOptions);
|
|
1310
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
1311
|
+
const { token } = await clientSessions.getOrCreate({
|
|
1312
|
+
user_identifier_key: userIdentifierKey
|
|
1313
|
+
});
|
|
1314
|
+
return _SeamHttpEvents.fromClientSessionToken(token, options);
|
|
1018
1315
|
}
|
|
1019
1316
|
async get(body) {
|
|
1020
1317
|
const { data } = await this.client.request({
|
|
@@ -1036,30 +1333,40 @@ var SeamHttpEvents = class _SeamHttpEvents {
|
|
|
1036
1333
|
|
|
1037
1334
|
// src/lib/seam/connect/routes/locks.ts
|
|
1038
1335
|
var SeamHttpLocks = class _SeamHttpLocks {
|
|
1039
|
-
constructor(apiKeyOrOptions) {
|
|
1040
|
-
const
|
|
1041
|
-
this.client =
|
|
1336
|
+
constructor(apiKeyOrOptions = {}) {
|
|
1337
|
+
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
1338
|
+
this.client = createClient(clientOptions);
|
|
1042
1339
|
}
|
|
1043
1340
|
static fromClient(client, options = {}) {
|
|
1044
|
-
const
|
|
1045
|
-
if (!isSeamHttpOptionsWithClient(
|
|
1341
|
+
const constructorOptions = { ...options, client };
|
|
1342
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
1046
1343
|
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
1047
1344
|
}
|
|
1048
|
-
return new _SeamHttpLocks(
|
|
1345
|
+
return new _SeamHttpLocks(constructorOptions);
|
|
1049
1346
|
}
|
|
1050
1347
|
static fromApiKey(apiKey, options = {}) {
|
|
1051
|
-
const
|
|
1052
|
-
if (!isSeamHttpOptionsWithApiKey(
|
|
1348
|
+
const constructorOptions = { ...options, apiKey };
|
|
1349
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
1053
1350
|
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
1054
1351
|
}
|
|
1055
|
-
return new _SeamHttpLocks(
|
|
1352
|
+
return new _SeamHttpLocks(constructorOptions);
|
|
1056
1353
|
}
|
|
1057
1354
|
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
1058
|
-
const
|
|
1059
|
-
if (!isSeamHttpOptionsWithClientSessionToken(
|
|
1355
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
1356
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
1060
1357
|
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
1061
1358
|
}
|
|
1062
|
-
return new _SeamHttpLocks(
|
|
1359
|
+
return new _SeamHttpLocks(constructorOptions);
|
|
1360
|
+
}
|
|
1361
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
1362
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
1363
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
1364
|
+
const client = createClient(clientOptions);
|
|
1365
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
1366
|
+
const { token } = await clientSessions.getOrCreate({
|
|
1367
|
+
user_identifier_key: userIdentifierKey
|
|
1368
|
+
});
|
|
1369
|
+
return _SeamHttpLocks.fromClientSessionToken(token, options);
|
|
1063
1370
|
}
|
|
1064
1371
|
async get(body) {
|
|
1065
1372
|
const { data } = await this.client.request({
|
|
@@ -1097,30 +1404,43 @@ var SeamHttpLocks = class _SeamHttpLocks {
|
|
|
1097
1404
|
|
|
1098
1405
|
// src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts
|
|
1099
1406
|
var SeamHttpNoiseSensorsNoiseThresholds = class _SeamHttpNoiseSensorsNoiseThresholds {
|
|
1100
|
-
constructor(apiKeyOrOptions) {
|
|
1101
|
-
const
|
|
1102
|
-
this.client =
|
|
1407
|
+
constructor(apiKeyOrOptions = {}) {
|
|
1408
|
+
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
1409
|
+
this.client = createClient(clientOptions);
|
|
1103
1410
|
}
|
|
1104
1411
|
static fromClient(client, options = {}) {
|
|
1105
|
-
const
|
|
1106
|
-
if (!isSeamHttpOptionsWithClient(
|
|
1412
|
+
const constructorOptions = { ...options, client };
|
|
1413
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
1107
1414
|
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
1108
1415
|
}
|
|
1109
|
-
return new _SeamHttpNoiseSensorsNoiseThresholds(
|
|
1416
|
+
return new _SeamHttpNoiseSensorsNoiseThresholds(constructorOptions);
|
|
1110
1417
|
}
|
|
1111
1418
|
static fromApiKey(apiKey, options = {}) {
|
|
1112
|
-
const
|
|
1113
|
-
if (!isSeamHttpOptionsWithApiKey(
|
|
1419
|
+
const constructorOptions = { ...options, apiKey };
|
|
1420
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
1114
1421
|
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
1115
1422
|
}
|
|
1116
|
-
return new _SeamHttpNoiseSensorsNoiseThresholds(
|
|
1423
|
+
return new _SeamHttpNoiseSensorsNoiseThresholds(constructorOptions);
|
|
1117
1424
|
}
|
|
1118
1425
|
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
1119
|
-
const
|
|
1120
|
-
if (!isSeamHttpOptionsWithClientSessionToken(
|
|
1426
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
1427
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
1121
1428
|
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
1122
1429
|
}
|
|
1123
|
-
return new _SeamHttpNoiseSensorsNoiseThresholds(
|
|
1430
|
+
return new _SeamHttpNoiseSensorsNoiseThresholds(constructorOptions);
|
|
1431
|
+
}
|
|
1432
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
1433
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
1434
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
1435
|
+
const client = createClient(clientOptions);
|
|
1436
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
1437
|
+
const { token } = await clientSessions.getOrCreate({
|
|
1438
|
+
user_identifier_key: userIdentifierKey
|
|
1439
|
+
});
|
|
1440
|
+
return _SeamHttpNoiseSensorsNoiseThresholds.fromClientSessionToken(
|
|
1441
|
+
token,
|
|
1442
|
+
options
|
|
1443
|
+
);
|
|
1124
1444
|
}
|
|
1125
1445
|
async create(body) {
|
|
1126
1446
|
await this.client.request({
|
|
@@ -1163,30 +1483,40 @@ var SeamHttpNoiseSensorsNoiseThresholds = class _SeamHttpNoiseSensorsNoiseThresh
|
|
|
1163
1483
|
|
|
1164
1484
|
// src/lib/seam/connect/routes/noise-sensors.ts
|
|
1165
1485
|
var SeamHttpNoiseSensors = class _SeamHttpNoiseSensors {
|
|
1166
|
-
constructor(apiKeyOrOptions) {
|
|
1167
|
-
const
|
|
1168
|
-
this.client =
|
|
1486
|
+
constructor(apiKeyOrOptions = {}) {
|
|
1487
|
+
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
1488
|
+
this.client = createClient(clientOptions);
|
|
1169
1489
|
}
|
|
1170
1490
|
static fromClient(client, options = {}) {
|
|
1171
|
-
const
|
|
1172
|
-
if (!isSeamHttpOptionsWithClient(
|
|
1491
|
+
const constructorOptions = { ...options, client };
|
|
1492
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
1173
1493
|
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
1174
1494
|
}
|
|
1175
|
-
return new _SeamHttpNoiseSensors(
|
|
1495
|
+
return new _SeamHttpNoiseSensors(constructorOptions);
|
|
1176
1496
|
}
|
|
1177
1497
|
static fromApiKey(apiKey, options = {}) {
|
|
1178
|
-
const
|
|
1179
|
-
if (!isSeamHttpOptionsWithApiKey(
|
|
1498
|
+
const constructorOptions = { ...options, apiKey };
|
|
1499
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
1180
1500
|
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
1181
1501
|
}
|
|
1182
|
-
return new _SeamHttpNoiseSensors(
|
|
1502
|
+
return new _SeamHttpNoiseSensors(constructorOptions);
|
|
1183
1503
|
}
|
|
1184
1504
|
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
1185
|
-
const
|
|
1186
|
-
if (!isSeamHttpOptionsWithClientSessionToken(
|
|
1505
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
1506
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
1187
1507
|
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
1188
1508
|
}
|
|
1189
|
-
return new _SeamHttpNoiseSensors(
|
|
1509
|
+
return new _SeamHttpNoiseSensors(constructorOptions);
|
|
1510
|
+
}
|
|
1511
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
1512
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
1513
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
1514
|
+
const client = createClient(clientOptions);
|
|
1515
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
1516
|
+
const { token } = await clientSessions.getOrCreate({
|
|
1517
|
+
user_identifier_key: userIdentifierKey
|
|
1518
|
+
});
|
|
1519
|
+
return _SeamHttpNoiseSensors.fromClientSessionToken(token, options);
|
|
1190
1520
|
}
|
|
1191
1521
|
get noiseThresholds() {
|
|
1192
1522
|
return SeamHttpNoiseSensorsNoiseThresholds.fromClient(this.client);
|
|
@@ -1195,30 +1525,43 @@ var SeamHttpNoiseSensors = class _SeamHttpNoiseSensors {
|
|
|
1195
1525
|
|
|
1196
1526
|
// src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts
|
|
1197
1527
|
var SeamHttpThermostatsClimateSettingSchedules = class _SeamHttpThermostatsClimateSettingSchedules {
|
|
1198
|
-
constructor(apiKeyOrOptions) {
|
|
1199
|
-
const
|
|
1200
|
-
this.client =
|
|
1528
|
+
constructor(apiKeyOrOptions = {}) {
|
|
1529
|
+
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
1530
|
+
this.client = createClient(clientOptions);
|
|
1201
1531
|
}
|
|
1202
1532
|
static fromClient(client, options = {}) {
|
|
1203
|
-
const
|
|
1204
|
-
if (!isSeamHttpOptionsWithClient(
|
|
1533
|
+
const constructorOptions = { ...options, client };
|
|
1534
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
1205
1535
|
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
1206
1536
|
}
|
|
1207
|
-
return new _SeamHttpThermostatsClimateSettingSchedules(
|
|
1537
|
+
return new _SeamHttpThermostatsClimateSettingSchedules(constructorOptions);
|
|
1208
1538
|
}
|
|
1209
1539
|
static fromApiKey(apiKey, options = {}) {
|
|
1210
|
-
const
|
|
1211
|
-
if (!isSeamHttpOptionsWithApiKey(
|
|
1540
|
+
const constructorOptions = { ...options, apiKey };
|
|
1541
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
1212
1542
|
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
1213
1543
|
}
|
|
1214
|
-
return new _SeamHttpThermostatsClimateSettingSchedules(
|
|
1544
|
+
return new _SeamHttpThermostatsClimateSettingSchedules(constructorOptions);
|
|
1215
1545
|
}
|
|
1216
1546
|
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
1217
|
-
const
|
|
1218
|
-
if (!isSeamHttpOptionsWithClientSessionToken(
|
|
1547
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
1548
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
1219
1549
|
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
1220
1550
|
}
|
|
1221
|
-
return new _SeamHttpThermostatsClimateSettingSchedules(
|
|
1551
|
+
return new _SeamHttpThermostatsClimateSettingSchedules(constructorOptions);
|
|
1552
|
+
}
|
|
1553
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
1554
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
1555
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
1556
|
+
const client = createClient(clientOptions);
|
|
1557
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
1558
|
+
const { token } = await clientSessions.getOrCreate({
|
|
1559
|
+
user_identifier_key: userIdentifierKey
|
|
1560
|
+
});
|
|
1561
|
+
return _SeamHttpThermostatsClimateSettingSchedules.fromClientSessionToken(
|
|
1562
|
+
token,
|
|
1563
|
+
options
|
|
1564
|
+
);
|
|
1222
1565
|
}
|
|
1223
1566
|
async create(body) {
|
|
1224
1567
|
const { data } = await this.client.request(
|
|
@@ -1270,30 +1613,40 @@ var SeamHttpThermostatsClimateSettingSchedules = class _SeamHttpThermostatsClima
|
|
|
1270
1613
|
|
|
1271
1614
|
// src/lib/seam/connect/routes/thermostats.ts
|
|
1272
1615
|
var SeamHttpThermostats = class _SeamHttpThermostats {
|
|
1273
|
-
constructor(apiKeyOrOptions) {
|
|
1274
|
-
const
|
|
1275
|
-
this.client =
|
|
1616
|
+
constructor(apiKeyOrOptions = {}) {
|
|
1617
|
+
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
1618
|
+
this.client = createClient(clientOptions);
|
|
1276
1619
|
}
|
|
1277
1620
|
static fromClient(client, options = {}) {
|
|
1278
|
-
const
|
|
1279
|
-
if (!isSeamHttpOptionsWithClient(
|
|
1621
|
+
const constructorOptions = { ...options, client };
|
|
1622
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
1280
1623
|
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
1281
1624
|
}
|
|
1282
|
-
return new _SeamHttpThermostats(
|
|
1625
|
+
return new _SeamHttpThermostats(constructorOptions);
|
|
1283
1626
|
}
|
|
1284
1627
|
static fromApiKey(apiKey, options = {}) {
|
|
1285
|
-
const
|
|
1286
|
-
if (!isSeamHttpOptionsWithApiKey(
|
|
1628
|
+
const constructorOptions = { ...options, apiKey };
|
|
1629
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
1287
1630
|
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
1288
1631
|
}
|
|
1289
|
-
return new _SeamHttpThermostats(
|
|
1632
|
+
return new _SeamHttpThermostats(constructorOptions);
|
|
1290
1633
|
}
|
|
1291
1634
|
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
1292
|
-
const
|
|
1293
|
-
if (!isSeamHttpOptionsWithClientSessionToken(
|
|
1635
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
1636
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
1294
1637
|
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
1295
1638
|
}
|
|
1296
|
-
return new _SeamHttpThermostats(
|
|
1639
|
+
return new _SeamHttpThermostats(constructorOptions);
|
|
1640
|
+
}
|
|
1641
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
1642
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
1643
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
1644
|
+
const client = createClient(clientOptions);
|
|
1645
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
1646
|
+
const { token } = await clientSessions.getOrCreate({
|
|
1647
|
+
user_identifier_key: userIdentifierKey
|
|
1648
|
+
});
|
|
1649
|
+
return _SeamHttpThermostats.fromClientSessionToken(token, options);
|
|
1297
1650
|
}
|
|
1298
1651
|
get climateSettingSchedules() {
|
|
1299
1652
|
return SeamHttpThermostatsClimateSettingSchedules.fromClient(this.client);
|
|
@@ -1360,30 +1713,40 @@ var SeamHttpThermostats = class _SeamHttpThermostats {
|
|
|
1360
1713
|
|
|
1361
1714
|
// src/lib/seam/connect/routes/webhooks.ts
|
|
1362
1715
|
var SeamHttpWebhooks = class _SeamHttpWebhooks {
|
|
1363
|
-
constructor(apiKeyOrOptions) {
|
|
1364
|
-
const
|
|
1365
|
-
this.client =
|
|
1716
|
+
constructor(apiKeyOrOptions = {}) {
|
|
1717
|
+
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
1718
|
+
this.client = createClient(clientOptions);
|
|
1366
1719
|
}
|
|
1367
1720
|
static fromClient(client, options = {}) {
|
|
1368
|
-
const
|
|
1369
|
-
if (!isSeamHttpOptionsWithClient(
|
|
1721
|
+
const constructorOptions = { ...options, client };
|
|
1722
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
1370
1723
|
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
1371
1724
|
}
|
|
1372
|
-
return new _SeamHttpWebhooks(
|
|
1725
|
+
return new _SeamHttpWebhooks(constructorOptions);
|
|
1373
1726
|
}
|
|
1374
1727
|
static fromApiKey(apiKey, options = {}) {
|
|
1375
|
-
const
|
|
1376
|
-
if (!isSeamHttpOptionsWithApiKey(
|
|
1728
|
+
const constructorOptions = { ...options, apiKey };
|
|
1729
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
1377
1730
|
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
1378
1731
|
}
|
|
1379
|
-
return new _SeamHttpWebhooks(
|
|
1732
|
+
return new _SeamHttpWebhooks(constructorOptions);
|
|
1380
1733
|
}
|
|
1381
1734
|
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
1382
|
-
const
|
|
1383
|
-
if (!isSeamHttpOptionsWithClientSessionToken(
|
|
1735
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
1736
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
1384
1737
|
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
1385
1738
|
}
|
|
1386
|
-
return new _SeamHttpWebhooks(
|
|
1739
|
+
return new _SeamHttpWebhooks(constructorOptions);
|
|
1740
|
+
}
|
|
1741
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
1742
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
1743
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
1744
|
+
const client = createClient(clientOptions);
|
|
1745
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
1746
|
+
const { token } = await clientSessions.getOrCreate({
|
|
1747
|
+
user_identifier_key: userIdentifierKey
|
|
1748
|
+
});
|
|
1749
|
+
return _SeamHttpWebhooks.fromClientSessionToken(token, options);
|
|
1387
1750
|
}
|
|
1388
1751
|
async create(body) {
|
|
1389
1752
|
const { data } = await this.client.request({
|
|
@@ -1420,30 +1783,40 @@ var SeamHttpWebhooks = class _SeamHttpWebhooks {
|
|
|
1420
1783
|
|
|
1421
1784
|
// src/lib/seam/connect/routes/workspaces.ts
|
|
1422
1785
|
var SeamHttpWorkspaces = class _SeamHttpWorkspaces {
|
|
1423
|
-
constructor(apiKeyOrOptions) {
|
|
1424
|
-
const
|
|
1425
|
-
this.client =
|
|
1786
|
+
constructor(apiKeyOrOptions = {}) {
|
|
1787
|
+
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
1788
|
+
this.client = createClient(clientOptions);
|
|
1426
1789
|
}
|
|
1427
1790
|
static fromClient(client, options = {}) {
|
|
1428
|
-
const
|
|
1429
|
-
if (!isSeamHttpOptionsWithClient(
|
|
1791
|
+
const constructorOptions = { ...options, client };
|
|
1792
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
1430
1793
|
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
1431
1794
|
}
|
|
1432
|
-
return new _SeamHttpWorkspaces(
|
|
1795
|
+
return new _SeamHttpWorkspaces(constructorOptions);
|
|
1433
1796
|
}
|
|
1434
1797
|
static fromApiKey(apiKey, options = {}) {
|
|
1435
|
-
const
|
|
1436
|
-
if (!isSeamHttpOptionsWithApiKey(
|
|
1798
|
+
const constructorOptions = { ...options, apiKey };
|
|
1799
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
1437
1800
|
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
1438
1801
|
}
|
|
1439
|
-
return new _SeamHttpWorkspaces(
|
|
1802
|
+
return new _SeamHttpWorkspaces(constructorOptions);
|
|
1440
1803
|
}
|
|
1441
1804
|
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
1442
|
-
const
|
|
1443
|
-
if (!isSeamHttpOptionsWithClientSessionToken(
|
|
1805
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
1806
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
1444
1807
|
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
1445
1808
|
}
|
|
1446
|
-
return new _SeamHttpWorkspaces(
|
|
1809
|
+
return new _SeamHttpWorkspaces(constructorOptions);
|
|
1810
|
+
}
|
|
1811
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
1812
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
1813
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
1814
|
+
const client = createClient(clientOptions);
|
|
1815
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
1816
|
+
const { token } = await clientSessions.getOrCreate({
|
|
1817
|
+
user_identifier_key: userIdentifierKey
|
|
1818
|
+
});
|
|
1819
|
+
return _SeamHttpWorkspaces.fromClientSessionToken(token, options);
|
|
1447
1820
|
}
|
|
1448
1821
|
async get(params) {
|
|
1449
1822
|
const { data } = await this.client.request({
|
|
@@ -1470,33 +1843,42 @@ var SeamHttpWorkspaces = class _SeamHttpWorkspaces {
|
|
|
1470
1843
|
}
|
|
1471
1844
|
};
|
|
1472
1845
|
|
|
1473
|
-
// src/lib/seam/connect/
|
|
1846
|
+
// src/lib/seam/connect/seam-http.ts
|
|
1474
1847
|
var SeamHttp = class _SeamHttp {
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
this.client = createAxiosClient(options);
|
|
1848
|
+
constructor(apiKeyOrOptions = {}) {
|
|
1849
|
+
const clientOptions = parseOptions(apiKeyOrOptions);
|
|
1850
|
+
this.client = createClient(clientOptions);
|
|
1479
1851
|
}
|
|
1480
1852
|
static fromClient(client, options = {}) {
|
|
1481
|
-
const
|
|
1482
|
-
if (!isSeamHttpOptionsWithClient(
|
|
1853
|
+
const constructorOptions = { ...options, client };
|
|
1854
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
1483
1855
|
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
1484
1856
|
}
|
|
1485
|
-
return new _SeamHttp(
|
|
1857
|
+
return new _SeamHttp(constructorOptions);
|
|
1486
1858
|
}
|
|
1487
1859
|
static fromApiKey(apiKey, options = {}) {
|
|
1488
|
-
const
|
|
1489
|
-
if (!isSeamHttpOptionsWithApiKey(
|
|
1860
|
+
const constructorOptions = { ...options, apiKey };
|
|
1861
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
1490
1862
|
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
1491
1863
|
}
|
|
1492
|
-
return new _SeamHttp(
|
|
1864
|
+
return new _SeamHttp(constructorOptions);
|
|
1493
1865
|
}
|
|
1494
1866
|
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
1495
|
-
const
|
|
1496
|
-
if (!isSeamHttpOptionsWithClientSessionToken(
|
|
1867
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
1868
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
1497
1869
|
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
1498
1870
|
}
|
|
1499
|
-
return new _SeamHttp(
|
|
1871
|
+
return new _SeamHttp(constructorOptions);
|
|
1872
|
+
}
|
|
1873
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
1874
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
1875
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
1876
|
+
const client = createClient(clientOptions);
|
|
1877
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
1878
|
+
const { token } = await clientSessions.getOrCreate({
|
|
1879
|
+
user_identifier_key: userIdentifierKey
|
|
1880
|
+
});
|
|
1881
|
+
return _SeamHttp.fromClientSessionToken(token, options);
|
|
1500
1882
|
}
|
|
1501
1883
|
get accessCodes() {
|
|
1502
1884
|
return SeamHttpAccessCodes.fromClient(this.client);
|
|
@@ -1540,5 +1922,9 @@ var SeamHttp = class _SeamHttp {
|
|
|
1540
1922
|
};
|
|
1541
1923
|
|
|
1542
1924
|
exports.SeamHttp = SeamHttp;
|
|
1925
|
+
exports.SeamHttpInvalidOptionsError = SeamHttpInvalidOptionsError;
|
|
1926
|
+
exports.isSeamHttpOptionsWithApiKey = isSeamHttpOptionsWithApiKey;
|
|
1927
|
+
exports.isSeamHttpOptionsWithClient = isSeamHttpOptionsWithClient;
|
|
1928
|
+
exports.isSeamHttpOptionsWithClientSessionToken = isSeamHttpOptionsWithClientSessionToken;
|
|
1543
1929
|
//# sourceMappingURL=out.js.map
|
|
1544
1930
|
//# sourceMappingURL=connect.cjs.map
|