@scalekit-sdk/node 1.0.3 → 1.0.5

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 (49) hide show
  1. package/.github/dependabot.yml +10 -0
  2. package/README.md +81 -11
  3. package/lib/connect.js +5 -4
  4. package/lib/connect.js.map +1 -1
  5. package/lib/connection.d.ts +17 -3
  6. package/lib/connection.js +36 -2
  7. package/lib/connection.js.map +1 -1
  8. package/lib/constants/user.d.ts +1 -1
  9. package/lib/core.d.ts +9 -5
  10. package/lib/core.js +27 -23
  11. package/lib/core.js.map +1 -1
  12. package/lib/domain.d.ts +1 -12
  13. package/lib/domain.js +0 -19
  14. package/lib/domain.js.map +1 -1
  15. package/lib/index.d.ts +4 -4
  16. package/lib/index.js +3 -3
  17. package/lib/index.js.map +1 -1
  18. package/lib/organization.d.ts +22 -4
  19. package/lib/organization.js +44 -7
  20. package/lib/organization.js.map +1 -1
  21. package/lib/scalekit.d.ts +12 -14
  22. package/lib/scalekit.js +18 -14
  23. package/lib/scalekit.js.map +1 -1
  24. package/lib/types/{user.d.ts → auth.d.ts} +5 -0
  25. package/lib/types/{user.js → auth.js} +1 -1
  26. package/lib/types/auth.js.map +1 -0
  27. package/lib/types/scalekit.d.ts +10 -9
  28. package/lib/types/scalekit.js.map +1 -1
  29. package/package.json +10 -11
  30. package/src/connect.ts +5 -5
  31. package/src/connection.ts +38 -15
  32. package/src/constants/user.ts +1 -1
  33. package/src/core.ts +32 -25
  34. package/src/domain.ts +0 -21
  35. package/src/index.ts +4 -4
  36. package/src/organization.ts +52 -5
  37. package/src/pkg/grpc/scalekit/v1/commons/commons_pb.ts +1 -1
  38. package/src/pkg/grpc/scalekit/v1/connections/connections_connect.ts +64 -1
  39. package/src/pkg/grpc/scalekit/v1/connections/connections_pb.ts +508 -156
  40. package/src/pkg/grpc/scalekit/v1/domains/domains_connect.ts +10 -1
  41. package/src/pkg/grpc/scalekit/v1/domains/domains_pb.ts +75 -1
  42. package/src/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.ts +1 -1
  43. package/src/pkg/grpc/scalekit/v1/options/options_pb.ts +9 -1
  44. package/src/pkg/grpc/scalekit/v1/organizations/organizations_connect.ts +19 -1
  45. package/src/pkg/grpc/scalekit/v1/organizations/organizations_pb.ts +142 -1
  46. package/src/scalekit.ts +27 -17
  47. package/src/types/{user.ts → auth.ts} +6 -0
  48. package/src/types/scalekit.ts +11 -10
  49. package/lib/types/user.js.map +0 -1
@@ -0,0 +1,10 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "npm"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ time: "06:00"
8
+ timezone: "Asia/Kolkata"
9
+ reviewers:
10
+ - "dhawani"
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- <p align="center">
1
+ <p align="left">
2
2
  <a href="https://scalekit.com" target="_blank" rel="noopener noreferrer">
3
3
  <picture>
4
4
  <img src="https://cdn.scalekit.cloud/v1/scalekit-logo-dark.svg" height="64">
@@ -6,21 +6,24 @@
6
6
  </a>
7
7
  <br/>
8
8
  </p>
9
- <h1 align="center">
10
- Official Scalekit Node SDK
11
- </h1>
12
9
 
13
- Scalekit helps you in shipping enterprise auth in days.
10
+ # Official Node.js SDK
11
+ <a href="https://scalekit.com" target="_blank" rel="noopener noreferrer">Scalekit</a> is an Enterprise Authentication Platform purpose built for B2B applications. This Node.js SDK helps implement Enterprise Capabilities like Single Sign-on via SAML or OIDC in your Node.js applications within a few hours.
14
12
 
15
- This Node SDK is a wrapper around Scalekit's REST API to help you integrate Scalekit with your Node.js applications.
13
+ <div>
14
+ 📚 <a target="_blank" href="https://docs.scalekit.com">Documentation</a> - 🚀 <a target="_blank" href="https://docs.scalekit.com">Quick-start Guide</a> - 💻 <a target="_blank" href="https://docs.scalekit.com/apis">API Reference</a>
15
+ </div>
16
+ <hr />
16
17
 
17
- ## Getting Started
18
+ ## Pre-requisites
18
19
 
19
20
  1. [Sign up](https://scalekit.com) for a Scalekit account.
20
21
  2. Get your ```env_url```, ```client_id``` and ```client_secret``` from the Scalekit dashboard.
21
22
 
22
23
  ## Installation
23
24
 
25
+ Install Scalekit SDK using your preferred package manager.
26
+
24
27
  ```sh
25
28
  npm install @scalekit-sdk/node
26
29
  #or
@@ -31,19 +34,86 @@ pnpm add @scalekit-sdk/node
31
34
 
32
35
  ## Usage
33
36
 
37
+ Initialize the Scalekit client using the appropriate credentials. Refer code sample below.
38
+
34
39
  ```javascript
35
- import { Scalekit } from "@scalekit-sdk/node";
40
+ import { ScalekitClient } from "@scalekit-sdk/node";
36
41
 
37
- const scalekit = new Scalekit(
42
+ const sc = new ScalekitClient(
38
43
  process.env.SCALEKIT_ENV_URL!,
39
44
  process.env.SCALEKIT_CLIENT_ID!,
40
45
  process.env.SCALEKIT_CLIENT_SECRET!
41
46
  );
47
+
48
+ // Use the sc object to interact with the Scalekit API
49
+ const authUrl = sc.getAuthorizationUrl("https://acme-corp.com/redirect-uri", {
50
+ state: "state",
51
+ connectionId: "connection_id",
52
+ });
53
+
42
54
  ```
43
55
 
56
+ ## Examples - SSO with Express.js
57
+
58
+ Below is a simple code sample that showcases how to implement Single Sign-on using Scalekit SDK
59
+
60
+ ```javascript
61
+ import express from "express";
62
+ import { ScalekitClient } from "@scalekit-sdk/node";
63
+
64
+ const app = express();
65
+
66
+ const sc = new ScalekitClient(
67
+ process.env.SCALEKIT_ENV_URL!,
68
+ process.env.SCALEKIT_CLIENT_ID!,
69
+ process.env.SCALEKIT_CLIENT_SECRET!
70
+ );
71
+
72
+ const redirectUri = `${process.env.HOST}/auth/callback`;
73
+
74
+ // Get the authorization URL and redirect the user to the IdP login page
75
+ app.get("/auth/login", (req, res) => {
76
+ const authUrl = sc.getAuthorizationUrl(
77
+ redirectUri,
78
+ {
79
+ state: "state",
80
+ connectionId: "connection_id",
81
+ }
82
+ );
83
+
84
+ res.redirect(authUrl);
85
+ });
86
+
87
+ // Handle the callback from Scalekit
88
+ app.get("/auth/callback", async (req, res) => {
89
+ const code = req.query.code as string;
90
+ const authResp = await sc.authenticateWithCode(code, redirectUri);
91
+ res.cookie("access_token", authResp.accessToken);
92
+ res.json(authResp.accessToken);
93
+ });
94
+
95
+ app.listen(3000, () => {
96
+ console.log("Server is running on port 3000");
97
+ });
98
+ ```
99
+
100
+ ## Example Apps
101
+
102
+ Fully functional sample applications written using some popular web application frameworks and Scalekit SDK. Feel free to clone the repo and run them locally.
103
+
104
+ - [Express.js](https://github.com/scalekit-inc/scalekit-express-example.git)
105
+ - [Next.js](https://github.com/scalekit-inc/scalekit-nextjs-example.git)
106
+
44
107
  ## API Reference
45
- See the [Scalekit API docs](https://docs.scalekit.com) for more information about the API and authentication.
108
+
109
+ Refer to our [API reference docs](https://docs.scalekit.com/apis) for detailed information about all our API endpoints and their usage.
110
+
111
+ ## More Information
112
+
113
+ - Quickstart Guide to implement Single Sign-on in your application: [SSO Quickstart Guide](https://docs.scalekit.com)
114
+ - Understand Single Sign-on basics: [SSO Basics](https://docs.scalekit.com/best-practices/single-sign-on)
46
115
 
47
116
  ## License
117
+
48
118
  This project is licensed under the **MIT license**.
49
- See the [LICENSE](LICENSE) file for more information.
119
+ See the [LICENSE](LICENSE) file for more information.
package/lib/connect.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const connect_1 = require("@connectrpc/connect");
4
4
  const connect_node_1 = require("@connectrpc/connect-node");
5
+ const core_1 = require("./core");
5
6
  class GrpcConnect {
6
7
  constructor(coreClient) {
7
8
  this.coreClient = coreClient;
@@ -11,11 +12,11 @@ class GrpcConnect {
11
12
  interceptors: [
12
13
  (next) => {
13
14
  return (req) => {
14
- req.header.set("User-Agent", this.coreClient.userAgent);
15
- req.header.set("x-sdk-version", this.coreClient.sdkVersion);
16
- req.header.set("x-api-version", this.coreClient.apiVersion);
15
+ req.header.set(core_1.headers['user-agent'], this.coreClient.userAgent);
16
+ req.header.set(core_1.headers['x-sdk-version'], this.coreClient.sdkVersion);
17
+ req.header.set(core_1.headers['x-api-version'], this.coreClient.apiVersion);
17
18
  if (this.coreClient.accessToken) {
18
- req.header.set("Authorization", `Bearer ${this.coreClient.accessToken}`);
19
+ req.header.set(core_1.headers.authorization, `Bearer ${this.coreClient.accessToken}`);
19
20
  }
20
21
  return next(req);
21
22
  };
@@ -1 +1 @@
1
- {"version":3,"file":"connect.js","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":";;AACA,iDAAoF;AACpF,2DAA+D;AAG/D,MAAqB,WAAW;IAE9B,YACmB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;QAEvC,IAAI,CAAC,SAAS,GAAG,IAAA,kCAAmB,EAAC;YACnC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM;YAC/B,WAAW,EAAE,GAAG;YAChB,YAAY,EAAE;gBACZ,CAAC,IAAI,EAAE,EAAE;oBACP,OAAO,CAAC,GAAG,EAAE,EAAE;wBACb,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;wBACvD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;wBAC3D,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;wBAC3D,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;4BAChC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,CAAA;wBAC1E,CAAC;wBACD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;oBAClB,CAAC,CAAA;gBACH,CAAC;aACF;SACF,CAAC,CAAC;IACL,CAAC;IAED,YAAY,CAAwB,OAAU;QAC5C,OAAO,IAAA,6B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;CACF;AA3BD,8BA2BC"}
@@ -1,6 +1,6 @@
1
1
  import GrpcConnect from './connect';
2
2
  import CoreClient from './core';
3
- import { GetConnectionResponse, ListConnectionsResponse } from './pkg/grpc/scalekit/v1/connections/connections_pb';
3
+ import { GetConnectionResponse, ToggleConnectionResponse, ListConnectionsResponse } from './pkg/grpc/scalekit/v1/connections/connections_pb';
4
4
  export default class ConnectionClient {
5
5
  private readonly grpcConncet;
6
6
  private readonly coreClient;
@@ -8,11 +8,11 @@ export default class ConnectionClient {
8
8
  constructor(grpcConncet: GrpcConnect, coreClient: CoreClient);
9
9
  /**
10
10
  * Get a connection by id and organization id
11
- * @param id The connection id
12
11
  * @param organizationId The organization id
12
+ * @param id The connection id
13
13
  * @returns {Promise<GetConnectionResponse>} The connection
14
14
  */
15
- getConnection(id: string, organizationId: string): Promise<GetConnectionResponse>;
15
+ getConnection(organizationId: string, id: string): Promise<GetConnectionResponse>;
16
16
  /**
17
17
  * List connections by domain
18
18
  * @param domain The domain
@@ -25,4 +25,18 @@ export default class ConnectionClient {
25
25
  * @returns {Promise<ListConnectionsResponse>} The list of connections
26
26
  */
27
27
  listConnections(organizationId: string): Promise<ListConnectionsResponse>;
28
+ /**
29
+ * Enable a connection by id and organization id
30
+ * @param organizationId The organization id
31
+ * @param id The connection id
32
+ * @returns {Promise<ToggleConnectionResponse>} The connection enable response
33
+ */
34
+ enableConnection(organizationId: string, id: string): Promise<ToggleConnectionResponse>;
35
+ /**
36
+ * Disable a connection by id and organization id
37
+ * @param organizationId The organization id
38
+ * @param id The connection id
39
+ * @returns {Promise<ToggleConnectionResponse>} The connection enable response
40
+ */
41
+ disableConnection(organizationId: string, id: string): Promise<ToggleConnectionResponse>;
28
42
  }
package/lib/connection.js CHANGED
@@ -18,11 +18,11 @@ class ConnectionClient {
18
18
  }
19
19
  /**
20
20
  * Get a connection by id and organization id
21
- * @param id The connection id
22
21
  * @param organizationId The organization id
22
+ * @param id The connection id
23
23
  * @returns {Promise<GetConnectionResponse>} The connection
24
24
  */
25
- getConnection(id, organizationId) {
25
+ getConnection(organizationId, id) {
26
26
  return __awaiter(this, void 0, void 0, function* () {
27
27
  return this.coreClient.connectExec(this.client.getConnection, {
28
28
  id,
@@ -63,6 +63,40 @@ class ConnectionClient {
63
63
  });
64
64
  });
65
65
  }
66
+ /**
67
+ * Enable a connection by id and organization id
68
+ * @param organizationId The organization id
69
+ * @param id The connection id
70
+ * @returns {Promise<ToggleConnectionResponse>} The connection enable response
71
+ */
72
+ enableConnection(organizationId, id) {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ return this.coreClient.connectExec(this.client.enableConnection, {
75
+ id,
76
+ identities: {
77
+ case: 'organizationId',
78
+ value: organizationId
79
+ }
80
+ });
81
+ });
82
+ }
83
+ /**
84
+ * Disable a connection by id and organization id
85
+ * @param organizationId The organization id
86
+ * @param id The connection id
87
+ * @returns {Promise<ToggleConnectionResponse>} The connection enable response
88
+ */
89
+ disableConnection(organizationId, id) {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ return this.coreClient.connectExec(this.client.disableConnection, {
92
+ id,
93
+ identities: {
94
+ case: 'organizationId',
95
+ value: organizationId
96
+ }
97
+ });
98
+ });
99
+ }
66
100
  }
67
101
  exports.default = ConnectionClient;
68
102
  //# sourceMappingURL=connection.js.map
@@ -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,EAAU,EAAE,cAAsB;;YACpD,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAChC,IAAI,CAAC,MAAM,CAAC,aAAa,EACzB;gBACE,EAAE;gBACF,UAAU,EAAE;oBACV,IAAI,EAAE,gBAAgB;oBACtB,KAAK,EAAE,cAAc;iBACtB;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,UAAU,EAAE;oBACV,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,MAAM;iBACd;aACF,CACF,CAAA;QACH,CAAC;KAAA;IAED;;;;OAIG;IACG,eAAe,CAAC,cAAsB;;YAC1C,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAChC,IAAI,CAAC,MAAM,CAAC,eAAe,EAC3B;gBACE,UAAU,EAAE;oBACV,IAAI,EAAE,gBAAgB;oBACtB,KAAK,EAAE,cAAc;iBACtB;aACF,CACF,CAAA;QACH,CAAC;KAAA;CACF;AA7DD,mCA6DC"}
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,UAAU,EAAE;oBACV,IAAI,EAAE,gBAAgB;oBACtB,KAAK,EAAE,cAAc;iBACtB;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,UAAU,EAAE;oBACV,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,MAAM;iBACd;aACF,CACF,CAAA;QACH,CAAC;KAAA;IAED;;;;OAIG;IACG,eAAe,CAAC,cAAsB;;YAC1C,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAChC,IAAI,CAAC,MAAM,CAAC,eAAe,EAC3B;gBACE,UAAU,EAAE;oBACV,IAAI,EAAE,gBAAgB;oBACtB,KAAK,EAAE,cAAc;iBACtB;aACF,CACF,CAAA;QACH,CAAC;KAAA;IAED;;;;;OAKG;IACG,gBAAgB,CAAC,cAAsB,EAAE,EAAU;;YACvD,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAChC,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAC5B;gBACE,EAAE;gBACF,UAAU,EAAE;oBACV,IAAI,EAAE,gBAAgB;oBACtB,KAAK,EAAE,cAAc;iBACtB;aACF,CACF,CAAA;QACH,CAAC;KAAA;IAED;;;;;OAKG;IACG,iBAAiB,CAAC,cAAsB,EAAE,EAAU;;YACxD,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAChC,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAC7B;gBACE,EAAE;gBACF,UAAU,EAAE;oBACV,IAAI,EAAE,gBAAgB;oBACtB,KAAK,EAAE,cAAc;iBACtB;aACF,CACF,CAAA;QACH,CAAC;KAAA;CACF;AAnGD,mCAmGC"}
@@ -1,4 +1,4 @@
1
- import type { IdTokenClaim, User } from '../types/user';
1
+ import type { IdTokenClaim, User } from '../types/auth';
2
2
  export declare const IdTokenClaimToUserMap: {
3
3
  [k in keyof IdTokenClaim]: keyof User;
4
4
  };
package/lib/core.d.ts CHANGED
@@ -1,5 +1,12 @@
1
1
  import { Axios, AxiosResponse } from "axios";
2
2
  import { JWK } from 'jose';
3
+ import { TokenResponse } from './types/auth';
4
+ export declare const headers: {
5
+ "user-agent": string;
6
+ "x-sdk-version": string;
7
+ "x-api-version": string;
8
+ authorization: string;
9
+ };
3
10
  export default class CoreClient {
4
11
  readonly envUrl: string;
5
12
  readonly clientId: string;
@@ -15,12 +22,9 @@ export default class CoreClient {
15
22
  /**
16
23
  * Authenticate with the code
17
24
  * @param {string} data Data to authenticate
18
- * @returns {Promise<AxiosResponse<{ access_token: string, id_token: string }>>} Returns access token and id token
25
+ * @returns {Promise<AxiosResponse<TokenResponse>>} Returns access token and id token
19
26
  */
20
- authenticate(data: string): Promise<AxiosResponse<{
21
- access_token: string;
22
- id_token: string;
23
- }, any>>;
27
+ authenticate(data: string): Promise<AxiosResponse<TokenResponse, any>>;
24
28
  /**
25
29
  * Get the JWKS from the server and store it in the client instance
26
30
  * @returns {Promise<void>} Returns nothing
package/lib/core.js CHANGED
@@ -35,12 +35,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.headers = void 0;
38
39
  const connect_1 = require("@connectrpc/connect");
39
40
  const axios_1 = __importStar(require("axios"));
40
41
  const os_1 = __importDefault(require("os"));
41
42
  const qs_1 = __importDefault(require("qs"));
42
43
  const scalekit_1 = require("./types/scalekit");
43
44
  const errdetails_pb_1 = require("./pkg/grpc/scalekit/v1/errdetails/errdetails_pb");
45
+ exports.headers = {
46
+ "user-agent": "user-agent",
47
+ "x-sdk-version": "x-sdk-version",
48
+ "x-api-version": "x-api-version",
49
+ "authorization": "authorization"
50
+ };
44
51
  const tokenEndpoint = "oauth/token";
45
52
  const jwksEndpoint = "keys";
46
53
  class CoreClient {
@@ -50,16 +57,16 @@ class CoreClient {
50
57
  this.clientSecret = clientSecret;
51
58
  this.keys = [];
52
59
  this.accessToken = null;
53
- this.sdkVersion = `Scalekit-Node/1.0.3`;
60
+ this.sdkVersion = `Scalekit-Node/1.0.4`;
54
61
  this.apiVersion = "20240430";
55
62
  this.userAgent = `${this.sdkVersion} Node/${process.version} (${process.platform}; ${os_1.default.arch()})`;
56
63
  this.axios = axios_1.default.create({ baseURL: envUrl });
57
64
  this.axios.interceptors.request.use((config) => {
58
- config.headers["User-Agent"] = this.userAgent;
59
- config.headers["x-sdk-version"] = this.sdkVersion;
60
- config.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;
61
68
  if (this.accessToken) {
62
- config.headers["Authorization"] = `Bearer ${this.accessToken}`;
69
+ config.headers[exports.headers.authorization] = `Bearer ${this.accessToken}`;
63
70
  }
64
71
  return config;
65
72
  });
@@ -78,7 +85,7 @@ class CoreClient {
78
85
  /**
79
86
  * Authenticate with the code
80
87
  * @param {string} data Data to authenticate
81
- * @returns {Promise<AxiosResponse<{ access_token: string, id_token: string }>>} Returns access token and id token
88
+ * @returns {Promise<AxiosResponse<TokenResponse>>} Returns access token and id token
82
89
  */
83
90
  authenticate(data) {
84
91
  return __awaiter(this, void 0, void 0, function* () {
@@ -117,10 +124,10 @@ class CoreClient {
117
124
  }
118
125
  catch (error) {
119
126
  if (retryLeft > 0) {
120
- let isUnauthenticatedError = false;
127
+ let isUnAuthenticatedError = false;
121
128
  if (error instanceof axios_1.AxiosError) {
122
129
  if (error.status == axios_1.HttpStatusCode.Unauthorized) {
123
- isUnauthenticatedError = true;
130
+ isUnAuthenticatedError = true;
124
131
  }
125
132
  else {
126
133
  throw new Error(error.message);
@@ -129,24 +136,21 @@ class CoreClient {
129
136
  // ConnectError is a custom error class that extends Error class and has a code property
130
137
  if (error instanceof connect_1.ConnectError) {
131
138
  if (error.code == connect_1.Code.Unauthenticated) {
132
- isUnauthenticatedError = true;
139
+ isUnAuthenticatedError = true;
133
140
  }
134
- else {
135
- if (error.code == connect_1.Code.InvalidArgument) {
136
- const message = error.findDetails(errdetails_pb_1.ErrorInfo).map((detail) => {
137
- if (detail.validationErrorInfo) {
138
- return detail.validationErrorInfo.fieldViolations.map((fv) => {
139
- return `${fv.field}: ${fv.description}`;
140
- }).join("\n");
141
- }
142
- return error.message;
143
- }).join("\n");
144
- throw new Error(message);
145
- }
146
- throw new Error(error.message);
141
+ if (error.code == connect_1.Code.InvalidArgument) {
142
+ const messages = [error.message];
143
+ error.findDetails(errdetails_pb_1.ErrorInfo).forEach((detail) => {
144
+ if (detail.validationErrorInfo) {
145
+ detail.validationErrorInfo.fieldViolations.forEach((fv) => {
146
+ messages.push(`${fv.field}: ${fv.description}`);
147
+ });
148
+ }
149
+ });
150
+ throw new Error(messages.join("\n"));
147
151
  }
148
152
  }
149
- if (isUnauthenticatedError) {
153
+ if (isUnAuthenticatedError) {
150
154
  yield this.authenticateClient();
151
155
  return this.connectExec(fn, data, retryLeft - 1);
152
156
  }
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;AAC7C,mFAA4E;AAE5E,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,C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AAC,OAAO,CAAC,CAAC;wBACjC,CAAC;oBACH,CAAC;oBACD,wFAAwF;oBACxF,IAAI,KAAK,YAAY,sBAAY,EAAE,CAAC;wBAClC,IAAI,KAAK,CAAC,IAAI,IAAI,cAAI,CAAC,eAAe,EAAE,CAAC;4BACvC,sBAAsB,GAAG,IAAI,CAAC;wBAChC,CAAC;wBACD,IAAI,KAAK,CAAC,IAAI,IAAI,cAAI,CAAC,eAAe,EAAE,CAAC;4BACvC,MAAM,QAAQ,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;4BAChC,KAAK,CAAC,WAAW,CAAC,yBAAS,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;gCAC9C,IAAI,MAAM,CAAC,mBAAmB,EAAE,CAAC;oCAC/B,MAAM,CAAC,mBAAmB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;wCACxD,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,KAAK,EAAE,CAAC,WAAW,EAAE,CAAC,CAAA;oCACjD,CAAC,CAAC,CAAA;gCACJ,CAAC;4BACH,CAAC,CAAC,CAAA;4BAEF,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;wBACvC,CAAC;oBACH,CAAC;oBACD,IAAI,sBAAsB,EAAE,CAAC;wBAC3B,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAC;wBAChC,OAAO,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,GAAG,CAAC,CAAC,CAAC;oBACnD,CAAC;gBACH,CAAC;gBACD,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;KAAA;CACF;AAnHD,6BAmHC"}
package/lib/domain.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import GrpcConnect from './connect';
2
2
  import CoreClient from './core';
3
- import { CreateDomainResponse, GetDomainResponse, ListDomainResponse } from './pkg/grpc/scalekit/v1/domains/domains_pb';
3
+ import { CreateDomainResponse, ListDomainResponse } from './pkg/grpc/scalekit/v1/domains/domains_pb';
4
4
  export default class DomainClient {
5
5
  private readonly grpcConncet;
6
6
  private readonly coreClient;
@@ -13,17 +13,6 @@ export default class DomainClient {
13
13
  * @returns {Promise<CreateDomainResponse>} The created domain
14
14
  */
15
15
  createDomain(organizationId: string, name: string): Promise<CreateDomainResponse>;
16
- /**
17
- * Get a domain by id
18
- * @param {object} options The options to get a domain
19
- * @param {string} options.id The domain id
20
- * @param {string} options.organizationId The organization id
21
- * @returns {Promise<GetDomainResponse>} The domain
22
- */
23
- getDomain(options: {
24
- id: string;
25
- organizationId: string;
26
- }): Promise<GetDomainResponse>;
27
16
  /**
28
17
  * List domains for an organization
29
18
  * @param organizationId The organization id
package/lib/domain.js CHANGED
@@ -35,25 +35,6 @@ class DomainClient {
35
35
  });
36
36
  });
37
37
  }
38
- /**
39
- * Get a domain by id
40
- * @param {object} options The options to get a domain
41
- * @param {string} options.id The domain id
42
- * @param {string} options.organizationId The organization id
43
- * @returns {Promise<GetDomainResponse>} The domain
44
- */
45
- getDomain(options) {
46
- return __awaiter(this, void 0, void 0, function* () {
47
- const { id, organizationId } = options;
48
- return this.coreClient.connectExec(this.client.getDomain, {
49
- id,
50
- identities: {
51
- case: 'organizationId',
52
- value: organizationId
53
- }
54
- });
55
- });
56
- }
57
38
  /**
58
39
  * List domains for an organization
59
40
  * @param organizationId The organization id
package/lib/domain.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"domain.js","sourceRoot":"","sources":["../src/domain.ts"],"names":[],"mappings":";;;;;;;;;;;AAGA,oFAA+E;AAG/E,MAAqB,YAAY;IAE/B,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,+BAAa,CAAC,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AY;;YACrD,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAChC,IAAI,CAAC,MAAM,CAAC,YAAY,EACxB;gBACE,UAAU,EAAE;oBACV,IAAI,EAAE,gBAAgB;oBACtB,KAAK,EAAE,cAAc;iBACtB;gBACD,MAAM,EAAE;oBACN,MAAM,EAAE,IAAI;iBACb;aACF,CACF,CAAA;QACH,CAAC;KAAA;IAED;;;;OAIG;IACG,WAAW,CAAC,cAAsB;;YACtC,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAChC,IAAI,CAAC,MAAM,CAAC,WAAW,EACvB;gBACE,UAAU,EAAE;oBACV,IAAI,EAAE,gBAAgB;oBACtB,KAAK,EAAE,cAAc;iBACtB;aACF,CACF,CAAC;QACJ,CAAC;KAAA;CACF;AA9CD,+BA8CC"}
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import Scalekit from "./scalekit";
2
- export { Scalekit };
3
- export default Scalekit;
1
+ import ScalekitClient from "./scalekit";
2
+ export { ScalekitClient };
3
+ export default ScalekitClient;
4
4
  export * from "./types/scalekit";
5
- export * from "./types/user";
5
+ export * from "./types/auth";
package/lib/index.js CHANGED
@@ -17,10 +17,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.Scalekit = void 0;
20
+ exports.ScalekitClient = void 0;
21
21
  const scalekit_1 = __importDefault(require("./scalekit"));
22
- exports.Scalekit = scalekit_1.default;
22
+ exports.ScalekitClient = scalekit_1.default;
23
23
  exports.default = scalekit_1.default;
24
24
  __exportStar(require("./types/scalekit"), exports);
25
- __exportStar(require("./types/user"), exports);
25
+ __exportStar(require("./types/auth"), exports);
26
26
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,0DAAkC;AAEzB,mBAFF,kBAAQ,CAEE;AACjB,kBAAe,kBAAQ,CAAC;AAExB,mDAAiC;AACjC,+CAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,0DAAwC;AAE/B,yBAFF,kBAAc,CAEE;AACvB,kBAAe,kBAAc,CAAC;AAE9B,mDAAiC;AACjC,+CAA6B"}
@@ -1,4 +1,4 @@
1
- import { PartialMessage } from '@bufbuild/protobuf';
1
+ import { Empty, PartialMessage } from '@bufbuild/protobuf';
2
2
  import GrpcConnect from './connect';
3
3
  import CoreClient from './core';
4
4
  import { CreateOrganizationResponse, GetOrganizationResponse, Link, ListOrganizationsResponse, UpdateOrganization, UpdateOrganizationResponse } from './pkg/grpc/scalekit/v1/organizations/organizations_pb';
@@ -9,13 +9,12 @@ export default class OrganizationClient {
9
9
  constructor(grpcConncet: GrpcConnect, coreClient: CoreClient);
10
10
  /**
11
11
  * Create an organization with the given name. Optionally, you can provide an external id.
12
+ * @param {string} name The organization name
12
13
  * @param {object} options The options to create an organization
13
- * @param {string} options.name The organization name
14
14
  * @param {string} options.externalId The external id
15
15
  * @returns {Promise<CreateOrganizationResponse>} The created organization
16
16
  */
17
- createOrganization(options: {
18
- name: string;
17
+ createOrganization(name: string, options?: {
19
18
  externalId?: string;
20
19
  }): Promise<CreateOrganizationResponse>;
21
20
  /**
@@ -55,10 +54,29 @@ export default class OrganizationClient {
55
54
  * @returns {Promise<UpdateOrganizationResponse>} The updated organization
56
55
  */
57
56
  updateOrganizationByExternalId(externalId: string, organization: PartialMessage<UpdateOrganization>): Promise<UpdateOrganizationResponse>;
57
+ /**
58
+ * Delete an organization by id
59
+ * @param {string} organizationId The organization id
60
+ * @returns {Promise<Empty>} Returns nothing
61
+ */
62
+ deleteOrganization(organizationId: string): Promise<Empty>;
58
63
  /**
59
64
  * Generate admin portal link for an organization
60
65
  * @param organizationId The organization id
61
66
  * @returns {Promise<Link>} The admin portal link object with expiration time and location
62
67
  */
63
68
  generatePortalLink(organizationId: string): Promise<Link>;
69
+ /**
70
+ * Get admin portal links for an organization
71
+ * @param organizationId The organization id
72
+ * @returns {Promise<Link[]>} The admin portal link object with expiration time and location
73
+ */
74
+ getPortalLinks(organizationId: string): Promise<Link[]>;
75
+ /**
76
+ * Delete admin portal link for an organization
77
+ * @param organizationId The organization id
78
+ * @param linkId The link id
79
+ * @returns {Promise<Empty>} Returns nothing
80
+ */
81
+ deletePortalLink(organizationId: string, linkId: string): Promise<Empty>;
64
82
  }
@@ -18,19 +18,17 @@ class OrganizationClient {
18
18
  }
19
19
  /**
20
20
  * Create an organization with the given name. Optionally, you can provide an external id.
21
+ * @param {string} name The organization name
21
22
  * @param {object} options The options to create an organization
22
- * @param {string} options.name The organization name
23
23
  * @param {string} options.externalId The external id
24
24
  * @returns {Promise<CreateOrganizationResponse>} The created organization
25
25
  */
26
- createOrganization(options) {
26
+ createOrganization(name, options) {
27
27
  return __awaiter(this, void 0, void 0, function* () {
28
- const { name, externalId } = options;
29
28
  return this.coreClient.connectExec(this.client.createOrganization, {
30
- organization: {
31
- displayName: name,
32
- externalId: externalId
33
- }
29
+ organization: Object.assign({ displayName: name }, ((options === null || options === void 0 ? void 0 : options.externalId) && {
30
+ externalId: options.externalId
31
+ }))
34
32
  });
35
33
  });
36
34
  }
@@ -94,6 +92,18 @@ class OrganizationClient {
94
92
  });
95
93
  });
96
94
  }
95
+ /**
96
+ * Delete an organization by id
97
+ * @param {string} organizationId The organization id
98
+ * @returns {Promise<Empty>} Returns nothing
99
+ */
100
+ deleteOrganization(organizationId) {
101
+ return __awaiter(this, void 0, void 0, function* () {
102
+ return this.coreClient.connectExec(this.client.deleteOrganization, {
103
+ identities: { case: "id", value: organizationId, },
104
+ });
105
+ });
106
+ }
97
107
  /**
98
108
  * Generate admin portal link for an organization
99
109
  * @param organizationId The organization id
@@ -110,6 +120,33 @@ class OrganizationClient {
110
120
  return response.link;
111
121
  });
112
122
  }
123
+ /**
124
+ * Get admin portal links for an organization
125
+ * @param organizationId The organization id
126
+ * @returns {Promise<Link[]>} The admin portal link object with expiration time and location
127
+ */
128
+ getPortalLinks(organizationId) {
129
+ return __awaiter(this, void 0, void 0, function* () {
130
+ const response = yield this.coreClient.connectExec(this.client.getPortalLinks, {
131
+ id: organizationId
132
+ });
133
+ return response.links;
134
+ });
135
+ }
136
+ /**
137
+ * Delete admin portal link for an organization
138
+ * @param organizationId The organization id
139
+ * @param linkId The link id
140
+ * @returns {Promise<Empty>} Returns nothing
141
+ */
142
+ deletePortalLink(organizationId, linkId) {
143
+ return __awaiter(this, void 0, void 0, function* () {
144
+ return this.coreClient.connectExec(this.client.deletePortalLink, {
145
+ id: organizationId,
146
+ linkId
147
+ });
148
+ });
149
+ }
113
150
  }
114
151
  exports.default = OrganizationClient;
115
152
  //# sourceMappingURL=organization.js.map