@seamapi/http 1.39.0 → 1.39.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connect.cjs +0 -1128
- package/dist/connect.cjs.map +1 -1
- package/dist/connect.d.cts +3 -279
- package/dist/index.cjs.map +1 -1
- package/lib/seam/connect/routes/seam/index.d.ts +0 -3
- package/lib/seam/connect/routes/seam/index.js +0 -3
- package/lib/seam/connect/routes/seam/index.js.map +1 -1
- package/lib/seam/connect/routes/seam-http-endpoints.d.ts +2 -16
- package/lib/seam/connect/routes/seam-http-endpoints.js +0 -95
- package/lib/seam/connect/routes/seam-http-endpoints.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +3 -3
- package/src/lib/seam/connect/routes/seam/index.ts +0 -3
- package/src/lib/seam/connect/routes/seam-http-endpoints.ts +0 -252
- package/src/lib/version.ts +1 -1
- package/lib/seam/connect/routes/seam/bridge/index.d.ts +0 -1
- package/lib/seam/connect/routes/seam/bridge/index.js +0 -6
- package/lib/seam/connect/routes/seam/bridge/index.js.map +0 -1
- package/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/bridge-client-sessions.d.ts +0 -86
- package/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/bridge-client-sessions.js +0 -150
- package/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/bridge-client-sessions.js.map +0 -1
- package/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/index.d.ts +0 -1
- package/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/index.js +0 -6
- package/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/index.js.map +0 -1
- package/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/bridge-connected-systems.d.ts +0 -34
- package/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/bridge-connected-systems.js +0 -102
- package/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/bridge-connected-systems.js.map +0 -1
- package/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/index.d.ts +0 -1
- package/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/index.js +0 -6
- package/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/index.js.map +0 -1
- package/lib/seam/connect/routes/seam/bridge/v1/index.d.ts +0 -3
- package/lib/seam/connect/routes/seam/bridge/v1/index.js +0 -8
- package/lib/seam/connect/routes/seam/bridge/v1/index.js.map +0 -1
- package/lib/seam/connect/routes/seam/bridge/v1/v1.d.ts +0 -23
- package/lib/seam/connect/routes/seam/bridge/v1/v1.js +0 -97
- package/lib/seam/connect/routes/seam/bridge/v1/v1.js.map +0 -1
- package/lib/seam/connect/routes/seam/instant-key/index.d.ts +0 -1
- package/lib/seam/connect/routes/seam/instant-key/index.js +0 -6
- package/lib/seam/connect/routes/seam/instant-key/index.js.map +0 -1
- package/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/client-sessions.d.ts +0 -34
- package/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/client-sessions.js +0 -102
- package/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/client-sessions.js.map +0 -1
- package/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/index.d.ts +0 -1
- package/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/index.js +0 -6
- package/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/index.js.map +0 -1
- package/lib/seam/connect/routes/seam/instant-key/v1/index.d.ts +0 -2
- package/lib/seam/connect/routes/seam/instant-key/v1/index.js +0 -7
- package/lib/seam/connect/routes/seam/instant-key/v1/index.js.map +0 -1
- package/lib/seam/connect/routes/seam/instant-key/v1/v1.d.ts +0 -21
- package/lib/seam/connect/routes/seam/instant-key/v1/v1.js +0 -93
- package/lib/seam/connect/routes/seam/instant-key/v1/v1.js.map +0 -1
- package/lib/seam/connect/routes/seam/mobile-sdk/index.d.ts +0 -1
- package/lib/seam/connect/routes/seam/mobile-sdk/index.js +0 -6
- package/lib/seam/connect/routes/seam/mobile-sdk/index.js.map +0 -1
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/acs.d.ts +0 -21
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/acs.js +0 -93
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/acs.js.map +0 -1
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/credentials.d.ts +0 -34
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/credentials.js +0 -102
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/credentials.js.map +0 -1
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/index.d.ts +0 -1
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/index.js +0 -6
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/index.js.map +0 -1
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/index.d.ts +0 -2
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/index.js +0 -7
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/index.js.map +0 -1
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/index.d.ts +0 -3
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/index.js +0 -8
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/index.js.map +0 -1
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/index.d.ts +0 -1
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/index.js +0 -6
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/index.js.map +0 -1
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/phone-sessions.d.ts +0 -34
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/phone-sessions.js +0 -102
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/phone-sessions.js.map +0 -1
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/v1.d.ts +0 -23
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/v1.js +0 -97
- package/lib/seam/connect/routes/seam/mobile-sdk/v1/v1.js.map +0 -1
- package/src/lib/seam/connect/routes/seam/bridge/index.ts +0 -6
- package/src/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/bridge-client-sessions.ts +0 -398
- package/src/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/index.ts +0 -6
- package/src/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/bridge-connected-systems.ts +0 -215
- package/src/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/index.ts +0 -6
- package/src/lib/seam/connect/routes/seam/bridge/v1/index.ts +0 -8
- package/src/lib/seam/connect/routes/seam/bridge/v1/v1.ts +0 -184
- package/src/lib/seam/connect/routes/seam/instant-key/index.ts +0 -6
- package/src/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/client-sessions.ts +0 -219
- package/src/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/index.ts +0 -6
- package/src/lib/seam/connect/routes/seam/instant-key/v1/index.ts +0 -7
- package/src/lib/seam/connect/routes/seam/instant-key/v1/v1.ts +0 -176
- package/src/lib/seam/connect/routes/seam/mobile-sdk/index.ts +0 -6
- package/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/acs.ts +0 -176
- package/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/credentials.ts +0 -215
- package/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/index.ts +0 -6
- package/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/index.ts +0 -7
- package/src/lib/seam/connect/routes/seam/mobile-sdk/v1/index.ts +0 -8
- package/src/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/index.ts +0 -6
- package/src/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/phone-sessions.ts +0 -215
- package/src/lib/seam/connect/routes/seam/mobile-sdk/v1/v1.ts +0 -181
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Automatically generated by codegen/smith.ts.
|
|
3
|
-
* Do not edit this file or add other files to this directory.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect'
|
|
7
|
-
|
|
8
|
-
import { seamApiLtsVersion } from 'lib/lts-version.js'
|
|
9
|
-
import {
|
|
10
|
-
getAuthHeadersForClientSessionToken,
|
|
11
|
-
warnOnInsecureuserIdentifierKey,
|
|
12
|
-
} from 'lib/seam/connect/auth.js'
|
|
13
|
-
import { type Client, createClient } from 'lib/seam/connect/client.js'
|
|
14
|
-
import {
|
|
15
|
-
isSeamHttpOptionsWithApiKey,
|
|
16
|
-
isSeamHttpOptionsWithClient,
|
|
17
|
-
isSeamHttpOptionsWithClientSessionToken,
|
|
18
|
-
isSeamHttpOptionsWithConsoleSessionToken,
|
|
19
|
-
isSeamHttpOptionsWithPersonalAccessToken,
|
|
20
|
-
type SeamHttpFromPublishableKeyOptions,
|
|
21
|
-
SeamHttpInvalidOptionsError,
|
|
22
|
-
type SeamHttpOptions,
|
|
23
|
-
type SeamHttpOptionsWithApiKey,
|
|
24
|
-
type SeamHttpOptionsWithClient,
|
|
25
|
-
type SeamHttpOptionsWithClientSessionToken,
|
|
26
|
-
type SeamHttpOptionsWithConsoleSessionToken,
|
|
27
|
-
type SeamHttpOptionsWithPersonalAccessToken,
|
|
28
|
-
type SeamHttpRequestOptions,
|
|
29
|
-
} from 'lib/seam/connect/options.js'
|
|
30
|
-
import {
|
|
31
|
-
limitToSeamHttpRequestOptions,
|
|
32
|
-
parseOptions,
|
|
33
|
-
} from 'lib/seam/connect/parse-options.js'
|
|
34
|
-
import { SeamHttpClientSessions } from 'lib/seam/connect/routes/client-sessions/index.js'
|
|
35
|
-
import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
|
|
36
|
-
import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js'
|
|
37
|
-
import type { SetNonNullable } from 'lib/types.js'
|
|
38
|
-
|
|
39
|
-
export class SeamHttpSeamMobileSdkV1PhoneSessions {
|
|
40
|
-
client: Client
|
|
41
|
-
readonly defaults: Required<SeamHttpRequestOptions>
|
|
42
|
-
readonly ltsVersion = seamApiLtsVersion
|
|
43
|
-
static ltsVersion = seamApiLtsVersion
|
|
44
|
-
|
|
45
|
-
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
46
|
-
const options = parseOptions(apiKeyOrOptions)
|
|
47
|
-
if (!options.isUndocumentedApiEnabled) {
|
|
48
|
-
throw new Error(
|
|
49
|
-
'Cannot use undocumented API without isUndocumentedApiEnabled',
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
this.client = 'client' in options ? options.client : createClient(options)
|
|
53
|
-
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
static fromClient(
|
|
57
|
-
client: SeamHttpOptionsWithClient['client'],
|
|
58
|
-
options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
|
|
59
|
-
): SeamHttpSeamMobileSdkV1PhoneSessions {
|
|
60
|
-
const constructorOptions = { ...options, client }
|
|
61
|
-
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
62
|
-
throw new SeamHttpInvalidOptionsError('Missing client')
|
|
63
|
-
}
|
|
64
|
-
return new SeamHttpSeamMobileSdkV1PhoneSessions(constructorOptions)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
static fromApiKey(
|
|
68
|
-
apiKey: SeamHttpOptionsWithApiKey['apiKey'],
|
|
69
|
-
options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
|
|
70
|
-
): SeamHttpSeamMobileSdkV1PhoneSessions {
|
|
71
|
-
const constructorOptions = { ...options, apiKey }
|
|
72
|
-
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
73
|
-
throw new SeamHttpInvalidOptionsError('Missing apiKey')
|
|
74
|
-
}
|
|
75
|
-
return new SeamHttpSeamMobileSdkV1PhoneSessions(constructorOptions)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
static fromClientSessionToken(
|
|
79
|
-
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
80
|
-
options: Omit<
|
|
81
|
-
SeamHttpOptionsWithClientSessionToken,
|
|
82
|
-
'clientSessionToken'
|
|
83
|
-
> = {},
|
|
84
|
-
): SeamHttpSeamMobileSdkV1PhoneSessions {
|
|
85
|
-
const constructorOptions = { ...options, clientSessionToken }
|
|
86
|
-
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
87
|
-
throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
|
|
88
|
-
}
|
|
89
|
-
return new SeamHttpSeamMobileSdkV1PhoneSessions(constructorOptions)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
static async fromPublishableKey(
|
|
93
|
-
publishableKey: string,
|
|
94
|
-
userIdentifierKey: string,
|
|
95
|
-
options: SeamHttpFromPublishableKeyOptions = {},
|
|
96
|
-
): Promise<SeamHttpSeamMobileSdkV1PhoneSessions> {
|
|
97
|
-
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
98
|
-
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
99
|
-
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
100
|
-
throw new SeamHttpInvalidOptionsError(
|
|
101
|
-
'The client option cannot be used with SeamHttpSeamMobileSdkV1PhoneSessions.fromPublishableKey',
|
|
102
|
-
)
|
|
103
|
-
}
|
|
104
|
-
const client = createClient(clientOptions)
|
|
105
|
-
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
106
|
-
const { token } = await clientSessions.getOrCreate({
|
|
107
|
-
user_identifier_key: userIdentifierKey,
|
|
108
|
-
})
|
|
109
|
-
return SeamHttpSeamMobileSdkV1PhoneSessions.fromClientSessionToken(
|
|
110
|
-
token,
|
|
111
|
-
options,
|
|
112
|
-
)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
static fromConsoleSessionToken(
|
|
116
|
-
consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
|
|
117
|
-
workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
|
|
118
|
-
options: Omit<
|
|
119
|
-
SeamHttpOptionsWithConsoleSessionToken,
|
|
120
|
-
'consoleSessionToken' | 'workspaceId'
|
|
121
|
-
> = {},
|
|
122
|
-
): SeamHttpSeamMobileSdkV1PhoneSessions {
|
|
123
|
-
const constructorOptions = { ...options, consoleSessionToken, workspaceId }
|
|
124
|
-
if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
|
|
125
|
-
throw new SeamHttpInvalidOptionsError(
|
|
126
|
-
'Missing consoleSessionToken or workspaceId',
|
|
127
|
-
)
|
|
128
|
-
}
|
|
129
|
-
return new SeamHttpSeamMobileSdkV1PhoneSessions(constructorOptions)
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
static fromPersonalAccessToken(
|
|
133
|
-
personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
|
|
134
|
-
workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
|
|
135
|
-
options: Omit<
|
|
136
|
-
SeamHttpOptionsWithPersonalAccessToken,
|
|
137
|
-
'personalAccessToken' | 'workspaceId'
|
|
138
|
-
> = {},
|
|
139
|
-
): SeamHttpSeamMobileSdkV1PhoneSessions {
|
|
140
|
-
const constructorOptions = { ...options, personalAccessToken, workspaceId }
|
|
141
|
-
if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
|
|
142
|
-
throw new SeamHttpInvalidOptionsError(
|
|
143
|
-
'Missing personalAccessToken or workspaceId',
|
|
144
|
-
)
|
|
145
|
-
}
|
|
146
|
-
return new SeamHttpSeamMobileSdkV1PhoneSessions(constructorOptions)
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
|
|
150
|
-
request: SeamHttpRequest<TResponse, TResponseKey>,
|
|
151
|
-
): SeamPaginator<TResponse, TResponseKey> {
|
|
152
|
-
return new SeamPaginator<TResponse, TResponseKey>(this, request)
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
async updateClientSessionToken(
|
|
156
|
-
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
157
|
-
): Promise<void> {
|
|
158
|
-
const { headers } = this.client.defaults
|
|
159
|
-
const authHeaders = getAuthHeadersForClientSessionToken({
|
|
160
|
-
clientSessionToken,
|
|
161
|
-
})
|
|
162
|
-
for (const key of Object.keys(authHeaders)) {
|
|
163
|
-
if (headers[key] == null) {
|
|
164
|
-
throw new Error(
|
|
165
|
-
'Cannot update a clientSessionToken on a client created without a clientSessionToken',
|
|
166
|
-
)
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
this.client.defaults.headers = { ...headers, ...authHeaders }
|
|
170
|
-
const clientSessions = SeamHttpClientSessions.fromClient(this.client)
|
|
171
|
-
await clientSessions.get()
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
getOrCreate(
|
|
175
|
-
parameters?: SeamMobileSdkV1PhoneSessionsGetOrCreateParameters,
|
|
176
|
-
options: SeamMobileSdkV1PhoneSessionsGetOrCreateOptions = {},
|
|
177
|
-
): SeamMobileSdkV1PhoneSessionsGetOrCreateRequest {
|
|
178
|
-
if (!this.defaults.isUndocumentedApiEnabled) {
|
|
179
|
-
throw new Error(
|
|
180
|
-
'Cannot use undocumented API without isUndocumentedApiEnabled',
|
|
181
|
-
)
|
|
182
|
-
}
|
|
183
|
-
return new SeamHttpRequest(this, {
|
|
184
|
-
pathname: '/seam/mobile_sdk/v1/phone_sessions/get_or_create',
|
|
185
|
-
method: 'POST',
|
|
186
|
-
body: parameters,
|
|
187
|
-
responseKey: 'phone_session',
|
|
188
|
-
options,
|
|
189
|
-
})
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export type SeamMobileSdkV1PhoneSessionsGetOrCreateParameters =
|
|
194
|
-
RouteRequestBody<'/seam/mobile_sdk/v1/phone_sessions/get_or_create'>
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* @deprecated Use SeamMobileSdkV1PhoneSessionsGetOrCreateParameters instead.
|
|
198
|
-
*/
|
|
199
|
-
export type SeamMobileSdkV1PhoneSessionsGetOrCreateBody =
|
|
200
|
-
SeamMobileSdkV1PhoneSessionsGetOrCreateParameters
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* @deprecated Use SeamMobileSdkV1PhoneSessionsGetOrCreateRequest instead.
|
|
204
|
-
*/
|
|
205
|
-
export type SeamMobileSdkV1PhoneSessionsGetOrCreateResponse = SetNonNullable<
|
|
206
|
-
Required<RouteResponse<'/seam/mobile_sdk/v1/phone_sessions/get_or_create'>>
|
|
207
|
-
>
|
|
208
|
-
|
|
209
|
-
export type SeamMobileSdkV1PhoneSessionsGetOrCreateRequest = SeamHttpRequest<
|
|
210
|
-
SeamMobileSdkV1PhoneSessionsGetOrCreateResponse,
|
|
211
|
-
'phone_session'
|
|
212
|
-
>
|
|
213
|
-
|
|
214
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
215
|
-
export interface SeamMobileSdkV1PhoneSessionsGetOrCreateOptions {}
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Automatically generated by codegen/smith.ts.
|
|
3
|
-
* Do not edit this file or add other files to this directory.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { seamApiLtsVersion } from 'lib/lts-version.js'
|
|
7
|
-
import {
|
|
8
|
-
getAuthHeadersForClientSessionToken,
|
|
9
|
-
warnOnInsecureuserIdentifierKey,
|
|
10
|
-
} from 'lib/seam/connect/auth.js'
|
|
11
|
-
import { type Client, createClient } from 'lib/seam/connect/client.js'
|
|
12
|
-
import {
|
|
13
|
-
isSeamHttpOptionsWithApiKey,
|
|
14
|
-
isSeamHttpOptionsWithClient,
|
|
15
|
-
isSeamHttpOptionsWithClientSessionToken,
|
|
16
|
-
isSeamHttpOptionsWithConsoleSessionToken,
|
|
17
|
-
isSeamHttpOptionsWithPersonalAccessToken,
|
|
18
|
-
type SeamHttpFromPublishableKeyOptions,
|
|
19
|
-
SeamHttpInvalidOptionsError,
|
|
20
|
-
type SeamHttpOptions,
|
|
21
|
-
type SeamHttpOptionsWithApiKey,
|
|
22
|
-
type SeamHttpOptionsWithClient,
|
|
23
|
-
type SeamHttpOptionsWithClientSessionToken,
|
|
24
|
-
type SeamHttpOptionsWithConsoleSessionToken,
|
|
25
|
-
type SeamHttpOptionsWithPersonalAccessToken,
|
|
26
|
-
type SeamHttpRequestOptions,
|
|
27
|
-
} from 'lib/seam/connect/options.js'
|
|
28
|
-
import {
|
|
29
|
-
limitToSeamHttpRequestOptions,
|
|
30
|
-
parseOptions,
|
|
31
|
-
} from 'lib/seam/connect/parse-options.js'
|
|
32
|
-
import { SeamHttpClientSessions } from 'lib/seam/connect/routes/client-sessions/index.js'
|
|
33
|
-
import type { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
|
|
34
|
-
import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js'
|
|
35
|
-
|
|
36
|
-
import { SeamHttpSeamMobileSdkV1Acs } from './acs/index.js'
|
|
37
|
-
import { SeamHttpSeamMobileSdkV1PhoneSessions } from './phone-sessions/index.js'
|
|
38
|
-
|
|
39
|
-
export class SeamHttpSeamMobileSdkV1 {
|
|
40
|
-
client: Client
|
|
41
|
-
readonly defaults: Required<SeamHttpRequestOptions>
|
|
42
|
-
readonly ltsVersion = seamApiLtsVersion
|
|
43
|
-
static ltsVersion = seamApiLtsVersion
|
|
44
|
-
|
|
45
|
-
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
46
|
-
const options = parseOptions(apiKeyOrOptions)
|
|
47
|
-
if (!options.isUndocumentedApiEnabled) {
|
|
48
|
-
throw new Error(
|
|
49
|
-
'Cannot use undocumented API without isUndocumentedApiEnabled',
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
this.client = 'client' in options ? options.client : createClient(options)
|
|
53
|
-
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
static fromClient(
|
|
57
|
-
client: SeamHttpOptionsWithClient['client'],
|
|
58
|
-
options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
|
|
59
|
-
): SeamHttpSeamMobileSdkV1 {
|
|
60
|
-
const constructorOptions = { ...options, client }
|
|
61
|
-
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
62
|
-
throw new SeamHttpInvalidOptionsError('Missing client')
|
|
63
|
-
}
|
|
64
|
-
return new SeamHttpSeamMobileSdkV1(constructorOptions)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
static fromApiKey(
|
|
68
|
-
apiKey: SeamHttpOptionsWithApiKey['apiKey'],
|
|
69
|
-
options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
|
|
70
|
-
): SeamHttpSeamMobileSdkV1 {
|
|
71
|
-
const constructorOptions = { ...options, apiKey }
|
|
72
|
-
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
73
|
-
throw new SeamHttpInvalidOptionsError('Missing apiKey')
|
|
74
|
-
}
|
|
75
|
-
return new SeamHttpSeamMobileSdkV1(constructorOptions)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
static fromClientSessionToken(
|
|
79
|
-
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
80
|
-
options: Omit<
|
|
81
|
-
SeamHttpOptionsWithClientSessionToken,
|
|
82
|
-
'clientSessionToken'
|
|
83
|
-
> = {},
|
|
84
|
-
): SeamHttpSeamMobileSdkV1 {
|
|
85
|
-
const constructorOptions = { ...options, clientSessionToken }
|
|
86
|
-
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
87
|
-
throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
|
|
88
|
-
}
|
|
89
|
-
return new SeamHttpSeamMobileSdkV1(constructorOptions)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
static async fromPublishableKey(
|
|
93
|
-
publishableKey: string,
|
|
94
|
-
userIdentifierKey: string,
|
|
95
|
-
options: SeamHttpFromPublishableKeyOptions = {},
|
|
96
|
-
): Promise<SeamHttpSeamMobileSdkV1> {
|
|
97
|
-
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
98
|
-
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
99
|
-
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
100
|
-
throw new SeamHttpInvalidOptionsError(
|
|
101
|
-
'The client option cannot be used with SeamHttpSeamMobileSdkV1.fromPublishableKey',
|
|
102
|
-
)
|
|
103
|
-
}
|
|
104
|
-
const client = createClient(clientOptions)
|
|
105
|
-
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
106
|
-
const { token } = await clientSessions.getOrCreate({
|
|
107
|
-
user_identifier_key: userIdentifierKey,
|
|
108
|
-
})
|
|
109
|
-
return SeamHttpSeamMobileSdkV1.fromClientSessionToken(token, options)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
static fromConsoleSessionToken(
|
|
113
|
-
consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
|
|
114
|
-
workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
|
|
115
|
-
options: Omit<
|
|
116
|
-
SeamHttpOptionsWithConsoleSessionToken,
|
|
117
|
-
'consoleSessionToken' | 'workspaceId'
|
|
118
|
-
> = {},
|
|
119
|
-
): SeamHttpSeamMobileSdkV1 {
|
|
120
|
-
const constructorOptions = { ...options, consoleSessionToken, workspaceId }
|
|
121
|
-
if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
|
|
122
|
-
throw new SeamHttpInvalidOptionsError(
|
|
123
|
-
'Missing consoleSessionToken or workspaceId',
|
|
124
|
-
)
|
|
125
|
-
}
|
|
126
|
-
return new SeamHttpSeamMobileSdkV1(constructorOptions)
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
static fromPersonalAccessToken(
|
|
130
|
-
personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
|
|
131
|
-
workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
|
|
132
|
-
options: Omit<
|
|
133
|
-
SeamHttpOptionsWithPersonalAccessToken,
|
|
134
|
-
'personalAccessToken' | 'workspaceId'
|
|
135
|
-
> = {},
|
|
136
|
-
): SeamHttpSeamMobileSdkV1 {
|
|
137
|
-
const constructorOptions = { ...options, personalAccessToken, workspaceId }
|
|
138
|
-
if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
|
|
139
|
-
throw new SeamHttpInvalidOptionsError(
|
|
140
|
-
'Missing personalAccessToken or workspaceId',
|
|
141
|
-
)
|
|
142
|
-
}
|
|
143
|
-
return new SeamHttpSeamMobileSdkV1(constructorOptions)
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
|
|
147
|
-
request: SeamHttpRequest<TResponse, TResponseKey>,
|
|
148
|
-
): SeamPaginator<TResponse, TResponseKey> {
|
|
149
|
-
return new SeamPaginator<TResponse, TResponseKey>(this, request)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
async updateClientSessionToken(
|
|
153
|
-
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
154
|
-
): Promise<void> {
|
|
155
|
-
const { headers } = this.client.defaults
|
|
156
|
-
const authHeaders = getAuthHeadersForClientSessionToken({
|
|
157
|
-
clientSessionToken,
|
|
158
|
-
})
|
|
159
|
-
for (const key of Object.keys(authHeaders)) {
|
|
160
|
-
if (headers[key] == null) {
|
|
161
|
-
throw new Error(
|
|
162
|
-
'Cannot update a clientSessionToken on a client created without a clientSessionToken',
|
|
163
|
-
)
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
this.client.defaults.headers = { ...headers, ...authHeaders }
|
|
167
|
-
const clientSessions = SeamHttpClientSessions.fromClient(this.client)
|
|
168
|
-
await clientSessions.get()
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
get acs(): SeamHttpSeamMobileSdkV1Acs {
|
|
172
|
-
return SeamHttpSeamMobileSdkV1Acs.fromClient(this.client, this.defaults)
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
get phoneSessions(): SeamHttpSeamMobileSdkV1PhoneSessions {
|
|
176
|
-
return SeamHttpSeamMobileSdkV1PhoneSessions.fromClient(
|
|
177
|
-
this.client,
|
|
178
|
-
this.defaults,
|
|
179
|
-
)
|
|
180
|
-
}
|
|
181
|
-
}
|