@scalekit-sdk/node 2.1.6 → 2.1.8

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.
Files changed (92) hide show
  1. package/buf.gen.yaml +1 -0
  2. package/lib/auth.d.ts +41 -9
  3. package/lib/auth.js +44 -12
  4. package/lib/auth.js.map +1 -1
  5. package/lib/connection.d.ts +195 -21
  6. package/lib/connection.js +197 -23
  7. package/lib/connection.js.map +1 -1
  8. package/lib/core.d.ts +2 -2
  9. package/lib/core.js +13 -12
  10. package/lib/core.js.map +1 -1
  11. package/lib/directory.d.ts +293 -40
  12. package/lib/directory.js +308 -44
  13. package/lib/directory.js.map +1 -1
  14. package/lib/domain.d.ts +166 -18
  15. package/lib/domain.js +178 -29
  16. package/lib/domain.js.map +1 -1
  17. package/lib/organization.d.ts +407 -40
  18. package/lib/organization.js +433 -49
  19. package/lib/organization.js.map +1 -1
  20. package/lib/permission.d.ts +179 -35
  21. package/lib/permission.js +190 -38
  22. package/lib/permission.js.map +1 -1
  23. package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.d.ts +3 -3
  24. package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.js +2 -2
  25. package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.js.map +1 -1
  26. package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.d.ts +16 -16
  27. package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js +21 -21
  28. package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js.map +1 -1
  29. package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.d.ts +82 -0
  30. package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.js +90 -0
  31. package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.js.map +1 -0
  32. package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.d.ts +647 -0
  33. package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.js +993 -0
  34. package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.js.map +1 -0
  35. package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.d.ts +142 -0
  36. package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js +165 -1
  37. package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js.map +1 -1
  38. package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.d.ts +1 -10
  39. package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js +0 -9
  40. package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js.map +1 -1
  41. package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.d.ts +28 -63
  42. package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js +9 -90
  43. package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js.map +1 -1
  44. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.d.ts +6 -6
  45. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.js +5 -5
  46. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.d.ts +19 -30
  47. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.js +22 -31
  48. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.js.map +1 -1
  49. package/lib/pkg/grpc/scalekit/v1/users/users_pb.d.ts +2 -2
  50. package/lib/pkg/grpc/scalekit/v1/users/users_pb.js +1 -1
  51. package/lib/pkg/grpc/scalekit/v1/users/users_pb.js.map +1 -1
  52. package/lib/role.d.ts +252 -56
  53. package/lib/role.js +262 -62
  54. package/lib/role.js.map +1 -1
  55. package/lib/scalekit.d.ts +323 -54
  56. package/lib/scalekit.js +354 -76
  57. package/lib/scalekit.js.map +1 -1
  58. package/lib/session.d.ts +235 -22
  59. package/lib/session.js +237 -24
  60. package/lib/session.js.map +1 -1
  61. package/lib/types/organization.d.ts +3 -0
  62. package/lib/user.d.ts +571 -53
  63. package/lib/user.js +598 -89
  64. package/lib/user.js.map +1 -1
  65. package/lib/webauthn.d.ts +33 -0
  66. package/lib/webauthn.js +80 -0
  67. package/lib/webauthn.js.map +1 -0
  68. package/package.json +2 -2
  69. package/src/auth.ts +53 -19
  70. package/src/connection.ts +237 -62
  71. package/src/core.ts +39 -33
  72. package/src/directory.ts +356 -98
  73. package/src/domain.ts +215 -68
  74. package/src/organization.ts +506 -105
  75. package/src/permission.ts +234 -88
  76. package/src/pkg/grpc/scalekit/v1/auth/auth_connect.ts +3 -3
  77. package/src/pkg/grpc/scalekit/v1/auth/auth_pb.ts +24 -24
  78. package/src/pkg/grpc/scalekit/v1/auth/webauthn_connect.ts +89 -0
  79. package/src/pkg/grpc/scalekit/v1/auth/webauthn_pb.ts +1263 -0
  80. package/src/pkg/grpc/scalekit/v1/commons/commons_pb.ts +217 -0
  81. package/src/pkg/grpc/scalekit/v1/connections/connections_connect.ts +1 -10
  82. package/src/pkg/grpc/scalekit/v1/connections/connections_pb.ts +42 -129
  83. package/src/pkg/grpc/scalekit/v1/organizations/organizations_connect.ts +6 -6
  84. package/src/pkg/grpc/scalekit/v1/organizations/organizations_pb.ts +28 -43
  85. package/src/pkg/grpc/scalekit/v1/users/users_pb.ts +3 -3
  86. package/src/role.ts +336 -136
  87. package/src/scalekit.ts +478 -149
  88. package/src/session.ts +266 -63
  89. package/src/types/organization.ts +4 -0
  90. package/src/user.ts +675 -168
  91. package/src/webauthn.ts +98 -0
  92. package/tests/organization.test.ts +16 -0
package/lib/connection.js CHANGED
@@ -10,6 +10,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const connections_connect_1 = require("./pkg/grpc/scalekit/v1/connections/connections_connect");
13
+ /**
14
+ * Client for managing enterprise SSO connections for organizations.
15
+ *
16
+ * Connections represent the SSO integration between an organization and their identity provider (IdP).
17
+ * Each organization can have an enterprise connection supporting different protocols (SAML, OIDC) and
18
+ * providers (Okta, Azure AD, Google Workspace, etc.). Use this client to retrieve connection details,
19
+ * list connections, and enable/disable them.
20
+ *
21
+ * @example
22
+ * const scalekitClient = new ScalekitClient(envUrl, clientId, clientSecret);
23
+ * const connectionClient = scalekitClient.connection;
24
+ *
25
+ * @see {@link https://docs.scalekit.com/apis/#tag/connections | Connection API Documentation}
26
+ */
13
27
  class ConnectionClient {
14
28
  constructor(grpcConncet, coreClient) {
15
29
  this.grpcConncet = grpcConncet;
@@ -17,68 +31,228 @@ class ConnectionClient {
17
31
  this.client = this.grpcConncet.createClient(connections_connect_1.ConnectionService);
18
32
  }
19
33
  /**
20
- * Get a connection by id and organization id
21
- * @param organizationId The organization id
22
- * @param id The connection id
23
- * @returns {Promise<GetConnectionResponse>} The connection
34
+ * Retrieves complete configuration and status details for a specific SSO connection.
35
+ *
36
+ * Use this method to fetch comprehensive information about an organization's SSO connection,
37
+ * including provider settings, protocol details (SAML/OIDC), enabled status, and configuration
38
+ * metadata. This is useful for verifying connection setup, auditing configurations, checking
39
+ * connection health before authentication flows, or displaying connection details to administrators.
40
+ *
41
+ * @param {string} organizationId - The organization ID that owns the connection (format: "org_...")
42
+ * @param {string} id - The connection identifier to retrieve (format: "conn_...")
43
+ *
44
+ * @returns {Promise<GetConnectionResponse>} Response containing:
45
+ * - connection: Complete connection object with:
46
+ * - id: Unique connection identifier
47
+ * - organizationId: Parent organization ID
48
+ * - provider: Identity provider name (e.g., "okta", "azure_ad", "google")
49
+ * - type: Protocol type ("saml", "oidc")
50
+ * - enabled: Whether the connection is active
51
+ * - status: Configuration status
52
+ * - domains: Associated email domains for this connection
53
+ * - metadata: Provider-specific configuration details
54
+ * - createTime: When the connection was created
55
+ * - updateTime: When the connection was last modified
56
+ *
57
+ * @throws {Error} If the organization or connection is not found
58
+ *
59
+ * @example
60
+ * // Get connection details
61
+ * const response = await scalekitClient.connection.getConnection(
62
+ * 'org_123456',
63
+ * 'conn_abc123'
64
+ * );
65
+ *
66
+ * const conn = response.connection;
67
+ * console.log('Provider:', conn.provider);
68
+ * console.log('Type:', conn.type);
69
+ * console.log('Status:', conn.enabled ? 'Enabled' : 'Disabled');
70
+ * console.log('Domains:', conn.domains);
71
+ *
72
+ * @example
73
+ * // Verify connection is ready for authentication
74
+ * const response = await scalekitClient.connection.getConnection(orgId, connId);
75
+ *
76
+ * if (response.connection.enabled && response.connection.status === 'active') {
77
+ * console.log('Connection is ready for SSO authentication');
78
+ * } else {
79
+ * console.log('Connection not ready:', response.connection.status);
80
+ * }
81
+ *
82
+ *
83
+ * @see {@link https://docs.scalekit.com/apis/#tag/connections | Get Connection API}
84
+ * @see {@link listConnections} - List all connections for an organization
85
+ * @see {@link enableConnection} - Enable this connection
86
+ * @see {@link disableConnection} - Disable this connection
24
87
  */
25
88
  getConnection(organizationId, id) {
26
89
  return __awaiter(this, void 0, void 0, function* () {
27
90
  return this.coreClient.connectExec(this.client.getConnection, {
28
91
  id,
29
- organizationId
92
+ organizationId,
30
93
  });
31
94
  });
32
95
  }
33
96
  /**
34
- * List connections by domain
35
- * @param domain The domain
36
- * @returns {Promise<ListConnectionsResponse>} The connection
97
+ * Lists all SSO connections associated with a specific email domain.
98
+ *
99
+ * Use this method to discover which organizations have SSO configured for a particular
100
+ * domain. This is useful for implementing domain-based SSO routing where users are
101
+ * automatically directed to their organization's SSO based on their email domain.
102
+ *
103
+ * @param {string} domain - The email domain to search for (e.g., "acme.com")
104
+ *
105
+ * @returns {Promise<ListConnectionsResponse>} Response containing:
106
+ * - connections: Array of connection objects for the domain
107
+ *
108
+ * @example
109
+ * // Find SSO connections for a domain
110
+ * const response = await scalekitClient.connection.listConnectionsByDomain('acme.com');
111
+ *
112
+ * if (response.connections.length > 0) {
113
+ * console.log('SSO available for domain acme.com');
114
+ * const connection = response.connections[0];
115
+ * console.log('Organization:', connection.organizationId);
116
+ * console.log('Provider:', connection.provider);
117
+ * }
118
+ *
119
+ * @example
120
+ * // Implement domain-based SSO routing
121
+ * app.post('/auth/login', async (req, res) => {
122
+ * const email = req.body.email;
123
+ * const domain = email.split('@')[1];
124
+ *
125
+ * const response = await scalekitClient.connection.listConnectionsByDomain(domain);
126
+ *
127
+ * if (response.connections.length > 0) {
128
+ * // Redirect to SSO
129
+ * const authUrl = scalekitClient.getAuthorizationUrl(redirectUri, {
130
+ * connectionId: response.connections[0].id,
131
+ * loginHint: email
132
+ * });
133
+ * return res.redirect(authUrl);
134
+ * } else {
135
+ * // Use password-based login
136
+ * return res.render('password-login');
137
+ * }
138
+ * });
139
+ *
140
+ * @see {@link https://docs.scalekit.com/apis/#tag/connections | List Connections API}
141
+ * @see {@link listConnections} - List all connections for an organization
37
142
  */
38
143
  listConnectionsByDomain(domain) {
39
144
  return __awaiter(this, void 0, void 0, function* () {
40
145
  return this.coreClient.connectExec(this.client.listConnections, {
41
- domain
146
+ domain,
42
147
  });
43
148
  });
44
149
  }
45
150
  /**
46
- * List connections by organization id
47
- * @param organizationId The organization id
48
- * @returns {Promise<ListConnectionsResponse>} The list of connections
151
+ * Lists all SSO connections configured for an organization.
152
+ *
153
+ * Retrieves all enterprise SSO connections (SAML, OIDC) that have been configured for
154
+ * the specified organization. Each connection includes details about the provider,
155
+ * status, and configuration.
156
+ *
157
+ * @param {string} organizationId - The organization ID
158
+ *
159
+ * @returns {Promise<ListConnectionsResponse>} Response containing:
160
+ * - connections: Array of connection objects with provider details and status
161
+ *
162
+ * @example
163
+ * // List all SSO connections for an organization
164
+ * const response = await scalekitClient.connection.listConnections('org_123456');
165
+ *
166
+ * console.log(`Found ${response.connections.length} connections`);
167
+ * response.connections.forEach(conn => {
168
+ * console.log(`- ${conn.provider} (${conn.type}): ${conn.enabled ? 'Enabled' : 'Disabled'}`);
169
+ * });
170
+ *
171
+ * @example
172
+ * // Check if organization has any enabled connections
173
+ * const response = await scalekitClient.connection.listConnections('org_123456');
174
+ * const hasEnabledSSO = response.connections.some(conn => conn.enabled);
175
+ *
176
+ * if (!hasEnabledSSO) {
177
+ * console.log('No SSO connections enabled for this organization');
178
+ * }
179
+ *
180
+ * @see {@link https://docs.scalekit.com/apis/#tag/connections | List Connections API}
181
+ * @see {@link getConnection} - Get details of a specific connection
182
+ * @see {@link enableConnection} - Enable a connection
183
+ * @see {@link disableConnection} - Disable a connection
49
184
  */
50
185
  listConnections(organizationId) {
51
186
  return __awaiter(this, void 0, void 0, function* () {
52
187
  return this.coreClient.connectExec(this.client.listConnections, {
53
- organizationId
188
+ organizationId,
54
189
  });
55
190
  });
56
191
  }
57
192
  /**
58
- * Enable a connection by id and organization id
59
- * @param organizationId The organization id
60
- * @param id The connection id
61
- * @returns {Promise<ToggleConnectionResponse>} The connection enable response
193
+ * Enables an SSO connection for an organization.
194
+ *
195
+ * Activates a previously disabled or newly configured SSO connection, allowing users
196
+ * from the organization to authenticate using this identity provider. Once enabled,
197
+ * users can immediately start using SSO to log in.
198
+ *
199
+ * @param {string} organizationId - The organization ID
200
+ * @param {string} id - The connection ID to enable
201
+ *
202
+ * @returns {Promise<ToggleConnectionResponse>} Response with updated connection status
203
+ *
204
+ * @example
205
+ * // Enable an SSO connection
206
+ * const response = await scalekitClient.connection.enableConnection(
207
+ * 'org_123456',
208
+ * 'conn_abc123'
209
+ * );
210
+ *
211
+ * console.log('Connection enabled:', response.connection.enabled); // true
212
+ *
213
+ *
214
+ * @see {@link https://docs.scalekit.com/apis/#tag/connections | Enable Connection API}
215
+ * @see {@link disableConnection} - Disable a connection
216
+ * @see {@link listConnections} - List all connections
62
217
  */
63
218
  enableConnection(organizationId, id) {
64
219
  return __awaiter(this, void 0, void 0, function* () {
65
220
  return this.coreClient.connectExec(this.client.enableConnection, {
66
221
  id,
67
- organizationId
222
+ organizationId,
68
223
  });
69
224
  });
70
225
  }
71
226
  /**
72
- * Disable a connection by id and organization id
73
- * @param organizationId The organization id
74
- * @param id The connection id
75
- * @returns {Promise<ToggleConnectionResponse>} The connection enable response
227
+ * Disables an SSO connection for an organization.
228
+ *
229
+ * Deactivates an SSO connection, preventing users from authenticating via this identity
230
+ * provider. This is useful for temporarily suspending SSO access, during maintenance,
231
+ * or when migrating to a different provider. Existing user sessions remain valid.
232
+ *
233
+ * @param {string} organizationId - The organization ID
234
+ * @param {string} id - The connection ID to disable
235
+ *
236
+ * @returns {Promise<ToggleConnectionResponse>} Response with updated connection status
237
+ *
238
+ * @example
239
+ * // Disable an SSO connection
240
+ * const response = await scalekitClient.connection.disableConnection(
241
+ * 'org_123456',
242
+ * 'conn_abc123'
243
+ * );
244
+ *
245
+ * console.log('Connection disabled:', !response.connection.enabled); // true
246
+ *
247
+ * @see {@link https://docs.scalekit.com/apis/#tag/connections | Disable Connection API}
248
+ * @see {@link enableConnection} - Enable a connection
249
+ * @see {@link listConnections} - List all connections
76
250
  */
77
251
  disableConnection(organizationId, id) {
78
252
  return __awaiter(this, void 0, void 0, function* () {
79
253
  return this.coreClient.connectExec(this.client.disableConnection, {
80
254
  id,
81
- organizationId
255
+ organizationId,
82
256
  });
83
257
  });
84
258
  }
@@ -1 +1 @@
1
- {"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":";;;;;;;;;;;AAGA,gGAA2F;AAG3F,MAAqB,gBAAgB;IAEnC,YACmB,WAAwB,EACxB,UAAsB;QADtB,gBAAW,GAAX,WAAW,CAAa;QACxB,eAAU,GAAV,UAAU,CAAY;QAEvC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,uCAAiB,CAAC,CAAC;IACjE,CAAC;IAED;;;;;OAKG;IACG,aAAa,CAAC,cAAsB,EAAE,EAAU;;YACpD,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAChC,IAAI,CAAC,MAAM,CAAC,aAAa,EACzB;gBACE,EAAE;gBACF,cAAc;aACf,CACF,CAAA;QACH,CAAC;KAAA;IAED;;;;OAIG;IACG,uBAAuB,CAAC,MAAc;;YAC1C,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAChC,IAAI,CAAC,MAAM,CAAC,eAAe,EAC3B;gBACE,MAAM;aACP,CACF,CAAA;QACH,CAAC;KAAA;IAED;;;;OAI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8CG;IACG,uBAAuB,CAC3B,MAAc;;YAEd,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE;gBAC9D,MAAM;aACP,CAAC,CAAC;QACL,CAAC;KAAA;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACG,eAAe,CACnB,cAAsB;;YAEtB,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE;gBAC9D,cAAc;aACf,CAAC,CAAC;QACL,CAAC;KAAA;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,gBAAgB,CACpB,cAAsB,EACtB,EAAU;;YAEV,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE;gBAC/D,EAAE;gBACF,cAAc;aACf,CAAC,CAAC;QACL,CAAC;KAAA;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,iBAAiB,CACrB,cAAsB,EACtB,EAAU;;YAEV,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE;gBAChE,EAAE;gBACF,cAAc;aACf,CAAC,CAAC;QACL,CAAC;KAAA;CACF;AAlPD,mCAkPC"}
package/lib/core.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Axios, AxiosResponse } from "axios";
2
- import { JWK } from 'jose';
3
- import { TokenResponse } from './types/auth';
2
+ import { JWK } from "jose";
3
+ import { TokenResponse } from "./types/auth";
4
4
  export declare const headers: {
5
5
  "user-agent": string;
6
6
  "x-sdk-version": string;
package/lib/core.js CHANGED
@@ -46,7 +46,7 @@ exports.headers = {
46
46
  "user-agent": "user-agent",
47
47
  "x-sdk-version": "x-sdk-version",
48
48
  "x-api-version": "x-api-version",
49
- "authorization": "authorization"
49
+ authorization: "authorization",
50
50
  };
51
51
  const tokenEndpoint = "oauth/token";
52
52
  const jwksEndpoint = "keys";
@@ -57,27 +57,28 @@ class CoreClient {
57
57
  this.clientSecret = clientSecret;
58
58
  this.keys = [];
59
59
  this.accessToken = null;
60
- this.sdkVersion = `Scalekit-Node/2.1.6`;
61
- this.apiVersion = "20250830";
60
+ this.sdkVersion = `Scalekit-Node/2.1.8`;
61
+ this.apiVersion = "20251215";
62
62
  this.userAgent = `${this.sdkVersion} Node/${process.version} (${process.platform}; ${os_1.default.arch()})`;
63
63
  this.axios = axios_1.default.create({ baseURL: envUrl });
64
64
  this.axios.interceptors.request.use((config) => {
65
- config.headers[exports.headers['user-agent']] = this.userAgent;
66
- config.headers[exports.headers['x-sdk-version']] = this.sdkVersion;
67
- config.headers[exports.headers['x-api-version']] = this.apiVersion;
65
+ config.headers[exports.headers["user-agent"]] = this.userAgent;
66
+ config.headers[exports.headers["x-sdk-version"]] = this.sdkVersion;
67
+ config.headers[exports.headers["x-api-version"]] = this.apiVersion;
68
68
  if (this.accessToken) {
69
69
  config.headers[exports.headers.authorization] = `Bearer ${this.accessToken}`;
70
70
  }
71
71
  return config;
72
72
  });
73
- this.authenticateClient();
73
+ // removing token creation at the time of constructor and instead letting the retry functionality handle generating a token whenever required.
74
+ //this.authenticateClient();
74
75
  }
75
76
  authenticateClient() {
76
77
  return __awaiter(this, void 0, void 0, function* () {
77
78
  const res = yield this.authenticate(qs_1.default.stringify({
78
79
  grant_type: scalekit_1.GrantType.ClientCredentials,
79
80
  client_id: this.clientId,
80
- client_secret: this.clientSecret
81
+ client_secret: this.clientSecret,
81
82
  }));
82
83
  this.accessToken = res.data.access_token;
83
84
  });
@@ -91,8 +92,8 @@ class CoreClient {
91
92
  return __awaiter(this, void 0, void 0, function* () {
92
93
  return this.axios.post(tokenEndpoint, data, {
93
94
  headers: {
94
- "Content-Type": "application/x-www-form-urlencoded"
95
- }
95
+ "Content-Type": "application/x-www-form-urlencoded",
96
+ },
96
97
  });
97
98
  });
98
99
  }
@@ -105,7 +106,7 @@ class CoreClient {
105
106
  if (this.keys.length) {
106
107
  return Promise.resolve();
107
108
  }
108
- const { data: { keys } } = yield this.axios.get(jwksEndpoint);
109
+ const { data: { keys }, } = yield this.axios.get(jwksEndpoint);
109
110
  this.keys = keys;
110
111
  });
111
112
  }
@@ -123,7 +124,7 @@ class CoreClient {
123
124
  return res;
124
125
  }
125
126
  catch (error) {
126
- // Handle gRPC Connect errors
127
+ // Handle gRPC Connect errors
127
128
  if (error instanceof connect_1.ConnectError) {
128
129
  if (retryLeft > 0) {
129
130
  const serverException = new base_exception_1.ScalekitServerException(error);
package/lib/core.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAyD;AACzD,+CAAgF;AAEhF,4CAAoB;AACpB,4CAA6B;AAC7B,+CAA6C;AAE7C,4DAAqF;AAExE,QAAA,OAAO,GAAG;IACrB,YAAY,EAAE,YAAY;IAC1B,eAAe,EAAE,eAAe;IAChC,eAAe,EAAE,eAAe;IAChC,eAAe,EAAE,eAAe;CACjC,CAAA;AAED,MAAM,aAAa,GAAG,aAAa,CAAC;AACpC,MAAM,YAAY,GAAG,MAAM,CAAC;AAC5B,MAAqB,UAAU;IAO7B,YACW,MAAc,EACd,QAAgB,EAChB,YAAoB;QAFpB,WAAM,GAAN,MAAM,CAAQ;QACd,aAAQ,GAAR,QAAQ,CAAQ;QAChB,iBAAY,GAAZ,YAAY,CAAQ;QATxB,SAAI,GAAU,EAAE,CAAC;QACjB,gBAAW,GAAkB,IAAI,CAAC;QAElC,eAAU,GAAG,qBAAqB,CAAC;QACnC,eAAU,GAAG,UAAU,CAAC;QACxB,cAAS,GAAG,GAAG,IAAI,CAAC,UAAU,SAAS,OAAO,CAAC,OAAO,KAAK,OAAO,CAAC,QAAQ,KAAK,YAAE,CAAC,IAAI,EAAE,GAAG,CAAC;QA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