@scalekit-sdk/node 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +49 -0
- package/buf.gen.yaml +14 -0
- package/lib/connect.d.ts +9 -0
- package/lib/connect.js +31 -0
- package/lib/connect.js.map +1 -0
- package/lib/connection.d.ts +28 -0
- package/lib/connection.js +68 -0
- package/lib/connection.js.map +1 -0
- package/lib/constants/user.d.ts +4 -0
- package/lib/constants/user.js +24 -0
- package/lib/constants/user.js.map +1 -0
- package/lib/core.d.ts +37 -0
- package/lib/core.js +160 -0
- package/lib/core.js.map +1 -0
- package/lib/domain.d.ts +33 -0
- package/lib/domain.js +74 -0
- package/lib/domain.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +26 -0
- package/lib/index.js.map +1 -0
- package/lib/organization.d.ts +64 -0
- package/lib/organization.js +116 -0
- package/lib/organization.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.d.ts +20 -0
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js +36 -0
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.d.ts +73 -0
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js +81 -0
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.d.ts +1252 -0
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js +1536 -0
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/domains/domains_connect.d.ts +55 -0
- package/lib/pkg/grpc/scalekit/v1/domains/domains_connect.js +63 -0
- package/lib/pkg/grpc/scalekit/v1/domains/domains_connect.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.d.ts +394 -0
- package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.js +469 -0
- package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.d.ts +245 -0
- package/lib/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.js +369 -0
- package/lib/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/options/options_pb.d.ts +98 -0
- package/lib/pkg/grpc/scalekit/v1/options/options_pb.js +135 -0
- package/lib/pkg/grpc/scalekit/v1/options/options_pb.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.d.ts +92 -0
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.js +100 -0
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.d.ts +424 -0
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.js +559 -0
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.js.map +1 -0
- package/lib/scalekit.d.ts +60 -0
- package/lib/scalekit.js +140 -0
- package/lib/scalekit.js.map +1 -0
- package/lib/types/scalekit.d.ts +26 -0
- package/lib/types/scalekit.js +10 -0
- package/lib/types/scalekit.js.map +1 -0
- package/lib/types/user.d.ts +56 -0
- package/lib/types/user.js +3 -0
- package/lib/types/user.js.map +1 -0
- package/package.json +45 -0
- package/src/connect.ts +33 -0
- package/src/connection.ts +69 -0
- package/src/constants/user.ts +22 -0
- package/src/core.ts +127 -0
- package/src/domain.ts +75 -0
- package/src/index.ts +7 -0
- package/src/organization.ts +129 -0
- package/src/pkg/grpc/scalekit/v1/commons/commons_pb.ts +36 -0
- package/src/pkg/grpc/scalekit/v1/connections/connections_connect.ts +80 -0
- package/src/pkg/grpc/scalekit/v1/connections/connections_pb.ts +2138 -0
- package/src/pkg/grpc/scalekit/v1/domains/domains_connect.ts +62 -0
- package/src/pkg/grpc/scalekit/v1/domains/domains_pb.ts +687 -0
- package/src/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.ts +461 -0
- package/src/pkg/grpc/scalekit/v1/options/options_pb.ts +156 -0
- package/src/pkg/grpc/scalekit/v1/organizations/organizations_connect.ts +99 -0
- package/src/pkg/grpc/scalekit/v1/organizations/organizations_pb.ts +774 -0
- package/src/scalekit.ts +155 -0
- package/src/types/scalekit.ts +30 -0
- package/src/types/user.ts +59 -0
- package/tsconfig.json +18 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Scalekit Inc
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://scalekit.com" target="_blank" rel="noopener noreferrer">
|
|
3
|
+
<picture>
|
|
4
|
+
<img src="data:image/svg+xml,%3csvg%20width='78'%20height='17'%20viewBox='0%200%2078%2017'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M5.51283%209.57909C4.15822%209.14596%202.93087%208.93145%202.93087%208.06518C2.93087%207.07103%203.94067%206.79053%204.80269%206.83178C5.66471%206.85241%206.63345%207.28554%207.06036%208.10643L8.63252%206.7864C7.92238%205.553%206.22297%204.83936%204.43735%204.83936C2.15505%204.85998%200.348913%205.98614%200.348913%208.08168C0.348913%2010.3092%202.24125%2010.9775%203.87499%2011.5179C5.16802%2011.9304%206.32559%2012.2109%206.32559%2013.073C6.32559%2013.9352%205.50872%2014.3271%204.28137%2014.2858C3.16074%2014.2198%202.0237%2013.6588%201.61321%2012.7307L0%2014.1373C0.775818%2015.412%202.51628%2016.2782%204.58102%2016.2782C6.99058%2016.2989%208.96912%2015.2387%208.96912%2013.0772C8.96912%2010.8084%207.13835%2010.1154%205.50462%209.57496L5.51283%209.57909Z'%20fill='%23202020'/%3e%3cpath%20d='M16.1209%2013.8393C14.2491%2013.8599%2012.874%2012.544%2012.874%2010.5516C12.874%208.55918%2014.2491%207.2639%2016.1209%207.28865C17.1964%207.28865%2018.0994%207.72178%2018.6823%208.50143L20.4474%207.03289C19.413%205.67162%2017.9312%204.87134%2015.9731%204.85072C12.5292%204.83009%2010.2715%207.20615%2010.2715%2010.5145C10.2715%2013.8228%2012.5292%2016.2855%2015.9731%2016.2855C17.9517%2016.2855%2019.4582%2015.378%2020.5131%2013.9713L18.707%2012.5646C18.1487%2013.3855%2017.2005%2013.8393%2016.125%2013.8393H16.1209Z'%20fill='%23202020'/%3e%3cpath%20d='M31.0285%207.4615C30.3184%205.94759%2029.0294%204.84619%2027.0057%204.84619C23.9066%204.84619%2021.8008%207.20161%2021.8008%2010.5099C21.8008%2013.8183%2023.9107%2016.2809%2027.0057%2016.2809C29.0294%2016.2809%2030.3184%2015.1548%2031.0285%2013.5996V16.0211H33.7172V5.06069H31.0285V7.4615ZM27.7364%2013.8389C25.8851%2013.8389%2024.51%2012.5436%2024.51%2010.5512C24.51%208.55877%2025.8851%207.28824%2027.7364%207.28824C29.5877%207.28824%2031.008%208.54227%2031.008%2010.5512C31.008%2012.5601%2029.5877%2013.8389%2027.7364%2013.8389Z'%20fill='%23202020'/%3e%3cpath%20d='M38.6672%200H35.9785V16.0425H38.6672V0Z'%20fill='%23202020'/%3e%3cpath%20d='M46.1342%204.84619C42.5835%204.84619%2040.4531%207.20161%2040.4531%2010.5099C40.4531%2013.8183%2042.7354%2016.2809%2046.3929%2016.2809C48.3057%2016.2809%2050.0298%2015.5879%2051.1052%2014.3586L49.1472%2012.9314C48.5028%2013.5996%2047.5135%2014.0121%2046.3929%2013.9915C44.6072%2013.9915%2043.3594%2012.8654%2043.187%2011.2236H51.7702C52.0083%207.5275%2049.9189%204.84619%2046.1342%204.84619ZM43.187%209.81692C43.3799%208.17513%2044.48%207.11499%2046.2656%207.11499C48.0512%207.11499%2049.2129%208.15451%2049.4058%209.77567L43.187%209.81692Z'%20fill='%23202020'/%3e%3cpath%20d='M64.3536%205.06148H61.2545L56.9074%209.01744V0H54.2188V16.0425H56.9074V10.9851L61.5993%2016.0425H64.7847L59.1241%209.99097L64.3536%205.06148Z'%20fill='%23202020'/%3e%3cpath%20d='M66.6133%2016.0414H69.302V5.03564H66.6133V16.0414Z'%20fill='%23202020'/%3e%3cpath%20d='M75.5443%2011.9125V7.26358H77.7404V5.05665H75.5443V2.07422L72.8556%202.72185V5.05665H71.1973V7.26358H72.8556V12.3003C72.8556%2015.7613%2074.6618%2016.2769%2077.999%2016.017V13.9215C76.1929%2014.0494%2075.5484%2013.5956%2075.5484%2011.9125H75.5443Z'%20fill='%23202020'/%3e%3cpath%20d='M67.9605%203.30041C68.8674%203.30041%2069.6026%202.56158%2069.6026%201.6502C69.6026%200.738821%2068.8674%200%2067.9605%200C67.0536%200%2066.3184%200.738821%2066.3184%201.6502C66.3184%202.56158%2067.0536%203.30041%2067.9605%203.30041Z'%20fill='%23202020'/%3e%3c/svg%3e" height="64">
|
|
5
|
+
</picture>
|
|
6
|
+
</a>
|
|
7
|
+
<br/>
|
|
8
|
+
</p>
|
|
9
|
+
<h1 align="center">
|
|
10
|
+
Official Scalekit Node SDK
|
|
11
|
+
</h1>
|
|
12
|
+
|
|
13
|
+
Scalekit helps you in shipping enterprise auth in days.
|
|
14
|
+
|
|
15
|
+
This Node SDK is a wrapper around Scalekit's REST API to help you integrate Scalekit with your Node.js applications.
|
|
16
|
+
|
|
17
|
+
## Getting Started
|
|
18
|
+
|
|
19
|
+
1. [Sign up](https://scalekit.com) for a Scalekit account.
|
|
20
|
+
2. Get your ```env_url```, ```client_id``` and ```client_secret``` from the Scalekit dashboard.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
npm install @scalekit-sdk/node-sdk
|
|
26
|
+
#or
|
|
27
|
+
yarn add @scalekit-sdk/node-sdk
|
|
28
|
+
#or
|
|
29
|
+
pnpm add @scalekit-sdk/node-sdk
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
import { Scalekit } from "@scalekit-sdk/node";
|
|
36
|
+
|
|
37
|
+
const scalekit = new Scalekit(
|
|
38
|
+
process.env.SCALEKIT_ENV_URL!,
|
|
39
|
+
process.env.SCALEKIT_CLIENT_ID!,
|
|
40
|
+
process.env.SCALEKIT_CLIENT_SECRET!
|
|
41
|
+
);
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## API Reference
|
|
45
|
+
See the [Scalekit API docs](https://docs.scalekit.com) for more information about the API and authentication.
|
|
46
|
+
|
|
47
|
+
## License
|
|
48
|
+
This project is licensed under the **MIT license**.
|
|
49
|
+
See the [LICENSE](LICENSE) file for more information.
|
package/buf.gen.yaml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
version: v1
|
|
2
|
+
plugins:
|
|
3
|
+
- plugin: es
|
|
4
|
+
opt: target=ts
|
|
5
|
+
out: src/pkg/grpc
|
|
6
|
+
- plugin: connect-es
|
|
7
|
+
opt: target=ts
|
|
8
|
+
out: src/pkg/grpc
|
|
9
|
+
types:
|
|
10
|
+
include:
|
|
11
|
+
- scalekit.v1.errdetails
|
|
12
|
+
- scalekit.v1.connections
|
|
13
|
+
- scalekit.v1.domains
|
|
14
|
+
- scalekit.v1.organizations
|
package/lib/connect.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ServiceType } from '@bufbuild/protobuf';
|
|
2
|
+
import { PromiseClient } from '@connectrpc/connect';
|
|
3
|
+
import CoreClient from './core';
|
|
4
|
+
export default class GrpcConnect {
|
|
5
|
+
private readonly coreClient;
|
|
6
|
+
private transport;
|
|
7
|
+
constructor(coreClient: CoreClient);
|
|
8
|
+
createClient<T extends ServiceType>(service: T): PromiseClient<T>;
|
|
9
|
+
}
|
package/lib/connect.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const connect_1 = require("@connectrpc/connect");
|
|
4
|
+
const connect_node_1 = require("@connectrpc/connect-node");
|
|
5
|
+
class GrpcConnect {
|
|
6
|
+
constructor(coreClient) {
|
|
7
|
+
this.coreClient = coreClient;
|
|
8
|
+
this.transport = (0, connect_node_1.createGrpcTransport)({
|
|
9
|
+
baseUrl: this.coreClient.envUrl,
|
|
10
|
+
httpVersion: "2",
|
|
11
|
+
interceptors: [
|
|
12
|
+
(next) => {
|
|
13
|
+
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);
|
|
17
|
+
if (this.coreClient.accessToken) {
|
|
18
|
+
req.header.set("Authorization", `Bearer ${this.coreClient.accessToken}`);
|
|
19
|
+
}
|
|
20
|
+
return next(req);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
createClient(service) {
|
|
27
|
+
return (0, connect_1.createPromiseClient)(service, this.transport);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.default = GrpcConnect;
|
|
31
|
+
//# sourceMappingURL=connect.js.map
|
|
@@ -0,0 +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,6BAAmB,EAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC;CACF;AA3BD,8BA2BC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import GrpcConnect from './connect';
|
|
2
|
+
import CoreClient from './core';
|
|
3
|
+
import { GetConnectionResponse, ListConnectionsResponse } from './pkg/grpc/scalekit/v1/connections/connections_pb';
|
|
4
|
+
export default class ConnectionClient {
|
|
5
|
+
private readonly grpcConncet;
|
|
6
|
+
private readonly coreClient;
|
|
7
|
+
private client;
|
|
8
|
+
constructor(grpcConncet: GrpcConnect, coreClient: CoreClient);
|
|
9
|
+
/**
|
|
10
|
+
* Get a connection by id and organization id
|
|
11
|
+
* @param id The connection id
|
|
12
|
+
* @param organizationId The organization id
|
|
13
|
+
* @returns {Promise<GetConnectionResponse>} The connection
|
|
14
|
+
*/
|
|
15
|
+
getConnection(id: string, organizationId: string): Promise<GetConnectionResponse>;
|
|
16
|
+
/**
|
|
17
|
+
* List connections by domain
|
|
18
|
+
* @param domain The domain
|
|
19
|
+
* @returns {Promise<ListConnectionsResponse>} The connection
|
|
20
|
+
*/
|
|
21
|
+
listConnectionsByDomain(domain: string): Promise<ListConnectionsResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* List connections by organization id
|
|
24
|
+
* @param organizationId The organization id
|
|
25
|
+
* @returns {Promise<ListConnectionsResponse>} The list of connections
|
|
26
|
+
*/
|
|
27
|
+
listConnections(organizationId: string): Promise<ListConnectionsResponse>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const connections_connect_1 = require("./pkg/grpc/scalekit/v1/connections/connections_connect");
|
|
13
|
+
class ConnectionClient {
|
|
14
|
+
constructor(grpcConncet, coreClient) {
|
|
15
|
+
this.grpcConncet = grpcConncet;
|
|
16
|
+
this.coreClient = coreClient;
|
|
17
|
+
this.client = this.grpcConncet.createClient(connections_connect_1.ConnectionService);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get a connection by id and organization id
|
|
21
|
+
* @param id The connection id
|
|
22
|
+
* @param organizationId The organization id
|
|
23
|
+
* @returns {Promise<GetConnectionResponse>} The connection
|
|
24
|
+
*/
|
|
25
|
+
getConnection(id, organizationId) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
return this.coreClient.connectExec(this.client.getConnection, {
|
|
28
|
+
id,
|
|
29
|
+
identities: {
|
|
30
|
+
case: 'organizationId',
|
|
31
|
+
value: organizationId
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* List connections by domain
|
|
38
|
+
* @param domain The domain
|
|
39
|
+
* @returns {Promise<ListConnectionsResponse>} The connection
|
|
40
|
+
*/
|
|
41
|
+
listConnectionsByDomain(domain) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
return this.coreClient.connectExec(this.client.listConnections, {
|
|
44
|
+
identities: {
|
|
45
|
+
case: 'domain',
|
|
46
|
+
value: domain
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* List connections by organization id
|
|
53
|
+
* @param organizationId The organization id
|
|
54
|
+
* @returns {Promise<ListConnectionsResponse>} The list of connections
|
|
55
|
+
*/
|
|
56
|
+
listConnections(organizationId) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
return this.coreClient.connectExec(this.client.listConnections, {
|
|
59
|
+
identities: {
|
|
60
|
+
case: 'organizationId',
|
|
61
|
+
value: organizationId
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.default = ConnectionClient;
|
|
68
|
+
//# sourceMappingURL=connection.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IdTokenClaimToUserMap = void 0;
|
|
4
|
+
exports.IdTokenClaimToUserMap = {
|
|
5
|
+
"sub": "id",
|
|
6
|
+
"name": "name",
|
|
7
|
+
"preferred_username": "username",
|
|
8
|
+
"given_name": "givenName",
|
|
9
|
+
"family_name": "familyName",
|
|
10
|
+
"email": "email",
|
|
11
|
+
"email_verified": "emailVerified",
|
|
12
|
+
"phone_number": "phoneNumber",
|
|
13
|
+
"phone_number_verified": "phoneNumberVerified",
|
|
14
|
+
"profile": 'profile',
|
|
15
|
+
"picture": "picture",
|
|
16
|
+
"gender": "gender",
|
|
17
|
+
"birthdate": "birthDate",
|
|
18
|
+
"zoneinfo": "zoneInfo",
|
|
19
|
+
"locale": "locale",
|
|
20
|
+
"updated_at": "updatedAt",
|
|
21
|
+
"identities": "identities",
|
|
22
|
+
"metadata": "metadata"
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/constants/user.ts"],"names":[],"mappings":";;;AAEa,QAAA,qBAAqB,GAA8C;IAC9E,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,MAAM;IACd,oBAAoB,EAAE,UAAU;IAChC,YAAY,EAAE,WAAW;IACzB,aAAa,EAAE,YAAY;IAC3B,OAAO,EAAE,OAAO;IAChB,gBAAgB,EAAE,eAAe;IACjC,cAAc,EAAE,aAAa;IAC7B,uBAAuB,EAAE,qBAAqB;IAC9C,SAAS,EAAE,SAAS;IACpB,SAAS,EAAE,SAAS;IACpB,QAAQ,EAAE,QAAQ;IAClB,WAAW,EAAE,WAAW;IACxB,UAAU,EAAE,UAAU;IACtB,QAAQ,EAAE,QAAQ;IAClB,YAAY,EAAE,WAAW;IACzB,YAAY,EAAE,YAAY;IAC1B,UAAU,EAAE,UAAU;CACvB,CAAA"}
|
package/lib/core.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Axios, AxiosResponse } from "axios";
|
|
2
|
+
import { JWK } from 'jose';
|
|
3
|
+
export default class CoreClient {
|
|
4
|
+
readonly envUrl: string;
|
|
5
|
+
readonly clientId: string;
|
|
6
|
+
readonly clientSecret: string;
|
|
7
|
+
keys: JWK[];
|
|
8
|
+
accessToken: string | null;
|
|
9
|
+
axios: Axios;
|
|
10
|
+
sdkVersion: string;
|
|
11
|
+
apiVersion: string;
|
|
12
|
+
userAgent: string;
|
|
13
|
+
constructor(envUrl: string, clientId: string, clientSecret: string);
|
|
14
|
+
private authenticateClient;
|
|
15
|
+
/**
|
|
16
|
+
* Authenticate with the code
|
|
17
|
+
* @param {string} data Data to authenticate
|
|
18
|
+
* @returns {Promise<AxiosResponse<{ access_token: string, id_token: string }>>} Returns access token and id token
|
|
19
|
+
*/
|
|
20
|
+
authenticate(data: string): Promise<AxiosResponse<{
|
|
21
|
+
access_token: string;
|
|
22
|
+
id_token: string;
|
|
23
|
+
}, any>>;
|
|
24
|
+
/**
|
|
25
|
+
* Get the JWKS from the server and store it in the client instance
|
|
26
|
+
* @returns {Promise<void>} Returns nothing
|
|
27
|
+
*/
|
|
28
|
+
getJwks(): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param fn Function to execute
|
|
32
|
+
* @param data Data to pass to the function
|
|
33
|
+
* @param retryLeft Number of retries left
|
|
34
|
+
* @returns {Promise<TResponse>} Returns the response
|
|
35
|
+
*/
|
|
36
|
+
connectExec<TRequest, TResponse>(fn: (request: TRequest) => Promise<TResponse>, data: TRequest, retryLeft?: number): Promise<TResponse>;
|
|
37
|
+
}
|
package/lib/core.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
const connect_1 = require("@connectrpc/connect");
|
|
39
|
+
const axios_1 = __importStar(require("axios"));
|
|
40
|
+
const os_1 = __importDefault(require("os"));
|
|
41
|
+
const qs_1 = __importDefault(require("qs"));
|
|
42
|
+
const scalekit_1 = require("./types/scalekit");
|
|
43
|
+
const errdetails_pb_1 = require("./pkg/grpc/scalekit/v1/errdetails/errdetails_pb");
|
|
44
|
+
const tokenEndpoint = "oauth/token";
|
|
45
|
+
const jwksEndpoint = "keys";
|
|
46
|
+
class CoreClient {
|
|
47
|
+
constructor(envUrl, clientId, clientSecret) {
|
|
48
|
+
this.envUrl = envUrl;
|
|
49
|
+
this.clientId = clientId;
|
|
50
|
+
this.clientSecret = clientSecret;
|
|
51
|
+
this.keys = [];
|
|
52
|
+
this.accessToken = null;
|
|
53
|
+
this.sdkVersion = `Scalekit-Node/1.0.0`;
|
|
54
|
+
this.apiVersion = "20240430";
|
|
55
|
+
this.userAgent = `${this.sdkVersion} Node/${process.version} (${process.platform}; ${os_1.default.arch()})`;
|
|
56
|
+
this.axios = axios_1.default.create({ baseURL: envUrl });
|
|
57
|
+
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;
|
|
61
|
+
if (this.accessToken) {
|
|
62
|
+
config.headers["Authorization"] = `Bearer ${this.accessToken}`;
|
|
63
|
+
}
|
|
64
|
+
return config;
|
|
65
|
+
});
|
|
66
|
+
this.authenticateClient();
|
|
67
|
+
}
|
|
68
|
+
authenticateClient() {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const res = yield this.authenticate(qs_1.default.stringify({
|
|
71
|
+
grant_type: scalekit_1.GrantType.ClientCredentials,
|
|
72
|
+
client_id: this.clientId,
|
|
73
|
+
client_secret: this.clientSecret
|
|
74
|
+
}));
|
|
75
|
+
this.accessToken = res.data.access_token;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Authenticate with the code
|
|
80
|
+
* @param {string} data Data to authenticate
|
|
81
|
+
* @returns {Promise<AxiosResponse<{ access_token: string, id_token: string }>>} Returns access token and id token
|
|
82
|
+
*/
|
|
83
|
+
authenticate(data) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
return this.axios.post(tokenEndpoint, data, {
|
|
86
|
+
headers: {
|
|
87
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get the JWKS from the server and store it in the client instance
|
|
94
|
+
* @returns {Promise<void>} Returns nothing
|
|
95
|
+
*/
|
|
96
|
+
getJwks() {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
if (this.keys.length) {
|
|
99
|
+
return Promise.resolve();
|
|
100
|
+
}
|
|
101
|
+
const { data: { keys } } = yield this.axios.get(jwksEndpoint);
|
|
102
|
+
this.keys = keys;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
*
|
|
107
|
+
* @param fn Function to execute
|
|
108
|
+
* @param data Data to pass to the function
|
|
109
|
+
* @param retryLeft Number of retries left
|
|
110
|
+
* @returns {Promise<TResponse>} Returns the response
|
|
111
|
+
*/
|
|
112
|
+
connectExec(fn_1, data_1) {
|
|
113
|
+
return __awaiter(this, arguments, void 0, function* (fn, data, retryLeft = 1) {
|
|
114
|
+
try {
|
|
115
|
+
const res = yield fn(data);
|
|
116
|
+
return res;
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
if (retryLeft > 0) {
|
|
120
|
+
let isUnauthenticatedError = false;
|
|
121
|
+
if (error instanceof axios_1.AxiosError) {
|
|
122
|
+
if (error.status == axios_1.HttpStatusCode.Unauthorized) {
|
|
123
|
+
isUnauthenticatedError = true;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
throw new Error(error.message);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// ConnectError is a custom error class that extends Error class and has a code property
|
|
130
|
+
if (error instanceof connect_1.ConnectError) {
|
|
131
|
+
if (error.code == connect_1.Code.Unauthenticated) {
|
|
132
|
+
isUnauthenticatedError = true;
|
|
133
|
+
}
|
|
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);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (isUnauthenticatedError) {
|
|
150
|
+
yield this.authenticateClient();
|
|
151
|
+
return this.connectExec(fn, data, retryLeft - 1);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
exports.default = CoreClient;
|
|
160
|
+
//# sourceMappingURL=core.js.map
|
package/lib/core.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"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"}
|
package/lib/domain.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import GrpcConnect from './connect';
|
|
2
|
+
import CoreClient from './core';
|
|
3
|
+
import { CreateDomainResponse, GetDomainResponse, ListDomainResponse } from './pkg/grpc/scalekit/v1/domains/domains_pb';
|
|
4
|
+
export default class DomainClient {
|
|
5
|
+
private readonly grpcConncet;
|
|
6
|
+
private readonly coreClient;
|
|
7
|
+
private client;
|
|
8
|
+
constructor(grpcConncet: GrpcConnect, coreClient: CoreClient);
|
|
9
|
+
/**
|
|
10
|
+
* Create a domain for an organization with the given name. Optionally, you can provide an external id.
|
|
11
|
+
* @param {string} organizationId The organization id
|
|
12
|
+
* @param {string} name The domain name
|
|
13
|
+
* @returns {Promise<CreateDomainResponse>} The created domain
|
|
14
|
+
*/
|
|
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
|
+
/**
|
|
28
|
+
* List domains for an organization
|
|
29
|
+
* @param organizationId The organization id
|
|
30
|
+
* @returns {Promise<ListDomainResponse>} The list of domains for the organization
|
|
31
|
+
*/
|
|
32
|
+
listDomains(organizationId: string): Promise<ListDomainResponse>;
|
|
33
|
+
}
|
package/lib/domain.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const domains_connect_1 = require("./pkg/grpc/scalekit/v1/domains/domains_connect");
|
|
13
|
+
class DomainClient {
|
|
14
|
+
constructor(grpcConncet, coreClient) {
|
|
15
|
+
this.grpcConncet = grpcConncet;
|
|
16
|
+
this.coreClient = coreClient;
|
|
17
|
+
this.client = this.grpcConncet.createClient(domains_connect_1.DomainService);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Create a domain for an organization with the given name. Optionally, you can provide an external id.
|
|
21
|
+
* @param {string} organizationId The organization id
|
|
22
|
+
* @param {string} name The domain name
|
|
23
|
+
* @returns {Promise<CreateDomainResponse>} The created domain
|
|
24
|
+
*/
|
|
25
|
+
createDomain(organizationId, name) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
return this.coreClient.connectExec(this.client.createDomain, {
|
|
28
|
+
identities: {
|
|
29
|
+
case: 'organizationId',
|
|
30
|
+
value: organizationId
|
|
31
|
+
},
|
|
32
|
+
domain: {
|
|
33
|
+
domain: name
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
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
|
+
/**
|
|
58
|
+
* List domains for an organization
|
|
59
|
+
* @param organizationId The organization id
|
|
60
|
+
* @returns {Promise<ListDomainResponse>} The list of domains for the organization
|
|
61
|
+
*/
|
|
62
|
+
listDomains(organizationId) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
return this.coreClient.connectExec(this.client.listDomains, {
|
|
65
|
+
identities: {
|
|
66
|
+
case: 'organizationId',
|
|
67
|
+
value: organizationId
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.default = DomainClient;
|
|
74
|
+
//# sourceMappingURL=domain.js.map
|
|
@@ -0,0 +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,CAAC;IAC7D,CAAC;IAED;;;;;MAKE;IACI,YAAY,CAAC,cAAsB,EAAE,IAAY;;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;;;;;;MAME;IACI,SAAS,CAAC,OAA+C;;YAC7D,MAAM,EAAE,EAAE,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;YACvC,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAChC,IAAI,CAAC,MAAM,CAAC,SAAS,EACrB;gBACE,EAAE;gBACF,UAAU,EAAE;oBACV,IAAI,EAAE,gBAAgB;oBACtB,KAAK,EAAE,cAAc;iBACtB;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;AAnED,+BAmEC"}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.Scalekit = void 0;
|
|
21
|
+
const scalekit_1 = __importDefault(require("./scalekit"));
|
|
22
|
+
exports.Scalekit = scalekit_1.default;
|
|
23
|
+
exports.default = scalekit_1.default;
|
|
24
|
+
__exportStar(require("./types/scalekit"), exports);
|
|
25
|
+
__exportStar(require("./types/user"), exports);
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +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"}
|