celitech-sdk 1.2.5 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # Celitech TypeScript SDK 1.2.5
1
+ # Celitech TypeScript SDK 1.3.3
2
2
 
3
3
  Welcome to the Celitech SDK documentation. This guide will help you get started with integrating and using the Celitech SDK in your project.
4
4
 
5
5
  ## Versions
6
6
 
7
7
  - API version: `1.1.0`
8
- - SDK version: `1.2.5`
8
+ - SDK version: `1.3.3`
9
9
 
10
10
  ## About the API
11
11
 
@@ -16,6 +16,8 @@ Welcome to the CELITECH API documentation! Useful links: [Homepage](https://www.
16
16
  - [Setup & Configuration](#setup--configuration)
17
17
  - [Supported Language Versions](#supported-language-versions)
18
18
  - [Installation](#installation)
19
+ - [Authentication](#authentication)
20
+ - [OAuth Authentication](#oauth-authentication)
19
21
  - [Environment Variables](#environment-variables)
20
22
  - [Setting a Custom Timeout](#setting-a-custom-timeout)
21
23
  - [Sample Usage](#sample-usage)
@@ -37,6 +39,24 @@ To get started with the SDK, we recommend installing using `npm`:
37
39
  npm install celitech-sdk
38
40
  ```
39
41
 
42
+ ## Authentication
43
+
44
+ ### OAuth Authentication
45
+
46
+ The Celitech API uses OAuth for authentication.
47
+
48
+ You need to provide the OAuth parameters when initializing the SDK.
49
+
50
+ ```ts
51
+
52
+ ```
53
+
54
+ If you need to set or update the OAuth parameters after the SDK initialization, you can use:
55
+
56
+ ```ts
57
+
58
+ ```
59
+
40
60
  ## Environment Variables
41
61
 
42
62
  These are the environment variables for the SDK:
@@ -66,10 +86,7 @@ Below is a comprehensive example demonstrating how to authenticate and call a si
66
86
  import { Celitech } from 'celitech-sdk';
67
87
 
68
88
  (async () => {
69
- const celitech = new Celitech({
70
- clientId: 'client-id',
71
- clientSecret: 'client-secret',
72
- });
89
+ const celitech = new Celitech({});
73
90
 
74
91
  const { data } = await celitech.destinations.listDestinations();
75
92
 
@@ -86,6 +103,7 @@ The SDK provides various services to interact with the API.
86
103
 
87
104
  | Name |
88
105
  | :------------------------------------------------------------------- |
106
+ | [OAuthService](documentation/services/OAuthService.md) |
89
107
  | [DestinationsService](documentation/services/DestinationsService.md) |
90
108
  | [PackagesService](documentation/services/PackagesService.md) |
91
109
  | [PurchasesService](documentation/services/PurchasesService.md) |
@@ -102,6 +120,8 @@ The SDK includes several models that represent the data structures used in API r
102
120
 
103
121
  | Name | Description |
104
122
  | :------------------------------------------------------------------------------------------- | :---------- |
123
+ | [GetAccessTokenRequest](documentation/models/GetAccessTokenRequest.md) | |
124
+ | [GetAccessTokenOkResponse](documentation/models/GetAccessTokenOkResponse.md) | |
105
125
  | [ListDestinationsOkResponse](documentation/models/ListDestinationsOkResponse.md) | |
106
126
  | [ListPackagesOkResponse](documentation/models/ListPackagesOkResponse.md) | |
107
127
  | [ListPurchasesOkResponse](documentation/models/ListPurchasesOkResponse.md) | |
package/dist/index.d.ts CHANGED
@@ -46,6 +46,19 @@ declare enum SerializationStyle {
46
46
  NONE = "none"
47
47
  }
48
48
 
49
+ declare class OAuthToken {
50
+ accessToken: string;
51
+ scopes: Set<string>;
52
+ expiresAt: number | null;
53
+ constructor(accessToken: string, scopes: Set<string>, expiresAt: number | null);
54
+ hasAllScopes(scopes: Set<string>): boolean;
55
+ }
56
+ declare class OAuthTokenManager {
57
+ private static instance;
58
+ private token?;
59
+ getToken(scopes: Set<string>, config: SdkConfig): Promise<OAuthToken>;
60
+ }
61
+
49
62
  interface CreateRequestParameters<FullResponse, Page = unknown[]> {
50
63
  baseUrl: string;
51
64
  method: HttpMethod;
@@ -62,6 +75,8 @@ interface CreateRequestParameters<FullResponse, Page = unknown[]> {
62
75
  validation: ValidationOptions;
63
76
  retry: RetryOptions;
64
77
  pagination?: RequestPagination<Page>;
78
+ scopes: Set<string>;
79
+ tokenManager: OAuthTokenManager;
65
80
  }
66
81
  interface RequestParameter {
67
82
  key: string | undefined;
@@ -93,6 +108,8 @@ declare class Request<T = unknown, PageSchema = unknown[]> {
93
108
  validation: ValidationOptions;
94
109
  retry: RetryOptions;
95
110
  pagination?: RequestPagination<PageSchema>;
111
+ scopes: Set<string>;
112
+ tokenManager: OAuthTokenManager;
96
113
  private readonly pathPattern;
97
114
  constructor(params: CreateRequestParameters<T, PageSchema>);
98
115
  addHeaderParam(key: string, param: RequestParameter): void;
@@ -114,8 +131,8 @@ interface SdkConfig {
114
131
  baseUrl?: string;
115
132
  environment?: Environment;
116
133
  timeoutMs?: number;
117
- clientId?: string;
118
- clientSecret?: string;
134
+ clientId: string;
135
+ clientSecret: string;
119
136
  retry?: RetryOptions;
120
137
  validation?: ValidationOptions;
121
138
  }
@@ -152,11 +169,17 @@ interface ValidationOptions {
152
169
  responseValidation?: boolean;
153
170
  }
154
171
 
172
+ declare class HttpError extends Error {
173
+ readonly error: string;
174
+ readonly metadata: HttpMetadata;
175
+ readonly raw?: ArrayBuffer;
176
+ constructor(metadata: HttpMetadata, raw?: ArrayBuffer, error?: string);
177
+ }
178
+
155
179
  declare class CustomHook implements Hook {
156
- getToken(clientId: string, clientSecret: string): Promise<any>;
157
180
  beforeRequest(request: HttpRequest, params: Map<string, string>): Promise<HttpRequest>;
158
181
  afterResponse(request: HttpRequest, response: HttpResponse$1<any>, params: Map<string, string>): Promise<HttpResponse$1<any>>;
159
- onError(request: HttpRequest, response: HttpResponse$1<any>, params: Map<string, string>): Promise<HttpError$1>;
182
+ onError(request: HttpRequest, response: HttpResponse$1<any>, params: Map<string, string>): Promise<HttpError>;
160
183
  }
161
184
 
162
185
  declare class HttpClient {
@@ -172,8 +195,9 @@ declare class HttpClient {
172
195
 
173
196
  declare class BaseService {
174
197
  config: SdkConfig;
198
+ protected tokenManager: OAuthTokenManager;
175
199
  client: HttpClient;
176
- constructor(config: SdkConfig);
200
+ constructor(config: SdkConfig, tokenManager: OAuthTokenManager);
177
201
  set baseUrl(baseUrl: string);
178
202
  set environment(environment: Environment);
179
203
  set timeoutMs(timeoutMs: number);
@@ -181,6 +205,68 @@ declare class BaseService {
181
205
  set clientSecret(clientSecret: string);
182
206
  }
183
207
 
208
+ /**
209
+ * The shape of the model inside the application code - what the users use
210
+ */
211
+ declare const getAccessTokenRequest: z.ZodLazy<z.ZodObject<{
212
+ grantType: z.ZodOptional<z.ZodString>;
213
+ clientId: z.ZodOptional<z.ZodString>;
214
+ clientSecret: z.ZodOptional<z.ZodString>;
215
+ }, "strip", z.ZodTypeAny, {
216
+ grantType?: string | undefined;
217
+ clientId?: string | undefined;
218
+ clientSecret?: string | undefined;
219
+ }, {
220
+ grantType?: string | undefined;
221
+ clientId?: string | undefined;
222
+ clientSecret?: string | undefined;
223
+ }>>;
224
+ /**
225
+ *
226
+ * @typedef {GetAccessTokenRequest} getAccessTokenRequest
227
+ * @property {GrantType}
228
+ * @property {string}
229
+ * @property {string}
230
+ */
231
+ type GetAccessTokenRequest = z.infer<typeof getAccessTokenRequest>;
232
+
233
+ /**
234
+ * The shape of the model inside the application code - what the users use
235
+ */
236
+ declare const getAccessTokenOkResponse: z.ZodLazy<z.ZodObject<{
237
+ accessToken: z.ZodOptional<z.ZodString>;
238
+ tokenType: z.ZodOptional<z.ZodString>;
239
+ expiresIn: z.ZodOptional<z.ZodNumber>;
240
+ }, "strip", z.ZodTypeAny, {
241
+ accessToken?: string | undefined;
242
+ tokenType?: string | undefined;
243
+ expiresIn?: number | undefined;
244
+ }, {
245
+ accessToken?: string | undefined;
246
+ tokenType?: string | undefined;
247
+ expiresIn?: number | undefined;
248
+ }>>;
249
+ /**
250
+ *
251
+ * @typedef {GetAccessTokenOkResponse} getAccessTokenOkResponse
252
+ * @property {string}
253
+ * @property {string}
254
+ * @property {number}
255
+ */
256
+ type GetAccessTokenOkResponse = z.infer<typeof getAccessTokenOkResponse>;
257
+
258
+ declare class OAuthService extends BaseService {
259
+ /**
260
+ * This endpoint was added by liblab
261
+ * @returns {Promise<HttpResponse<GetAccessTokenOkResponse>>} Successful Response
262
+ */
263
+ getAccessToken(body: GetAccessTokenRequest, requestConfig?: RequestConfig): Promise<HttpResponse<GetAccessTokenOkResponse>>;
264
+ }
265
+
266
+ declare enum GrantType {
267
+ CLIENT_CREDENTIALS = "client_credentials"
268
+ }
269
+
184
270
  /**
185
271
  * The shape of the model inside the application code - what the users use
186
272
  */
@@ -1521,19 +1607,14 @@ declare const getEsimMacOkResponseEsim: z.ZodLazy<z.ZodObject<{
1521
1607
  */
1522
1608
  type GetEsimMacOkResponseEsim = z.infer<typeof getEsimMacOkResponseEsim>;
1523
1609
 
1524
- declare class HttpError extends Error {
1525
- readonly error: string;
1526
- readonly metadata: HttpMetadata;
1527
- readonly raw?: ArrayBuffer;
1528
- constructor(metadata: HttpMetadata, raw?: ArrayBuffer, error?: string);
1529
- }
1530
-
1531
1610
  declare class Celitech {
1532
1611
  config: SdkConfig;
1612
+ readonly oAuth: OAuthService;
1533
1613
  readonly destinations: DestinationsService;
1534
1614
  readonly packages: PackagesService;
1535
1615
  readonly purchases: PurchasesService;
1536
1616
  readonly eSim: ESimService;
1617
+ protected tokenManager: OAuthTokenManager;
1537
1618
  constructor(config: SdkConfig);
1538
1619
  set baseUrl(baseUrl: string);
1539
1620
  set environment(environment: Environment);
@@ -1542,4 +1623,4 @@ declare class Celitech {
1542
1623
  set clientSecret(clientSecret: string);
1543
1624
  }
1544
1625
 
1545
- export { Celitech, CreatePurchaseOkResponse, CreatePurchaseOkResponseProfile, CreatePurchaseOkResponsePurchase, CreatePurchaseRequest, Destinations, DestinationsService, Device, ESimService, EditPurchaseOkResponse, EditPurchaseRequest, Environment, GetEsimDeviceOkResponse, GetEsimHistoryOkResponse, GetEsimHistoryOkResponseEsim, GetEsimMacOkResponse, GetEsimMacOkResponseEsim, GetEsimOkResponse, GetEsimOkResponseEsim, GetPurchaseConsumptionOkResponse, History, HttpError, HttpMetadata, HttpMethod, HttpResponse, ListDestinationsOkResponse, ListPackagesOkResponse, ListPurchasesOkResponse, Package_, Packages, PackagesService, Purchases, PurchasesEsim, PurchasesService, RequestConfig, RetryOptions, SdkConfig, TopUpEsimOkResponse, TopUpEsimOkResponseProfile, TopUpEsimOkResponsePurchase, TopUpEsimRequest, ValidationOptions };
1626
+ export { Celitech, CreatePurchaseOkResponse, CreatePurchaseOkResponseProfile, CreatePurchaseOkResponsePurchase, CreatePurchaseRequest, Destinations, DestinationsService, Device, ESimService, EditPurchaseOkResponse, EditPurchaseRequest, Environment, GetAccessTokenOkResponse, GetAccessTokenRequest, GetEsimDeviceOkResponse, GetEsimHistoryOkResponse, GetEsimHistoryOkResponseEsim, GetEsimMacOkResponse, GetEsimMacOkResponseEsim, GetEsimOkResponse, GetEsimOkResponseEsim, GetPurchaseConsumptionOkResponse, GrantType, History, HttpError, HttpMetadata, HttpMethod, HttpResponse, ListDestinationsOkResponse, ListPackagesOkResponse, ListPurchasesOkResponse, OAuthService, Package_, Packages, PackagesService, Purchases, PurchasesEsim, PurchasesService, RequestConfig, RetryOptions, SdkConfig, TopUpEsimOkResponse, TopUpEsimOkResponseProfile, TopUpEsimOkResponsePurchase, TopUpEsimRequest, ValidationOptions };