@space-df/sdk 0.0.1-dev.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +7 -0
- package/README.md +382 -0
- package/_shims/MultipartBody.d.ts +9 -0
- package/_shims/MultipartBody.d.ts.map +1 -0
- package/_shims/MultipartBody.js +16 -0
- package/_shims/MultipartBody.js.map +1 -0
- package/_shims/MultipartBody.mjs +12 -0
- package/_shims/MultipartBody.mjs.map +1 -0
- package/_shims/README.md +46 -0
- package/_shims/auto/runtime-bun.d.ts +5 -0
- package/_shims/auto/runtime-bun.d.ts.map +1 -0
- package/_shims/auto/runtime-bun.js +21 -0
- package/_shims/auto/runtime-bun.js.map +1 -0
- package/_shims/auto/runtime-bun.mjs +2 -0
- package/_shims/auto/runtime-bun.mjs.map +1 -0
- package/_shims/auto/runtime-node.d.ts +5 -0
- package/_shims/auto/runtime-node.d.ts.map +1 -0
- package/_shims/auto/runtime-node.js +21 -0
- package/_shims/auto/runtime-node.js.map +1 -0
- package/_shims/auto/runtime-node.mjs +2 -0
- package/_shims/auto/runtime-node.mjs.map +1 -0
- package/_shims/auto/runtime.d.ts +5 -0
- package/_shims/auto/runtime.d.ts.map +1 -0
- package/_shims/auto/runtime.js +21 -0
- package/_shims/auto/runtime.js.map +1 -0
- package/_shims/auto/runtime.mjs +2 -0
- package/_shims/auto/runtime.mjs.map +1 -0
- package/_shims/auto/types-node.d.ts +5 -0
- package/_shims/auto/types-node.d.ts.map +1 -0
- package/_shims/auto/types-node.js +21 -0
- package/_shims/auto/types-node.js.map +1 -0
- package/_shims/auto/types-node.mjs +2 -0
- package/_shims/auto/types-node.mjs.map +1 -0
- package/_shims/auto/types.d.ts +101 -0
- package/_shims/auto/types.js +3 -0
- package/_shims/auto/types.mjs +3 -0
- package/_shims/bun-runtime.d.ts +6 -0
- package/_shims/bun-runtime.d.ts.map +1 -0
- package/_shims/bun-runtime.js +14 -0
- package/_shims/bun-runtime.js.map +1 -0
- package/_shims/bun-runtime.mjs +10 -0
- package/_shims/bun-runtime.mjs.map +1 -0
- package/_shims/index.d.ts +72 -0
- package/_shims/index.js +13 -0
- package/_shims/index.mjs +7 -0
- package/_shims/manual-types.d.ts +12 -0
- package/_shims/manual-types.js +3 -0
- package/_shims/manual-types.mjs +3 -0
- package/_shims/node-runtime.d.ts +3 -0
- package/_shims/node-runtime.d.ts.map +1 -0
- package/_shims/node-runtime.js +89 -0
- package/_shims/node-runtime.js.map +1 -0
- package/_shims/node-runtime.mjs +56 -0
- package/_shims/node-runtime.mjs.map +1 -0
- package/_shims/node-types.d.ts +42 -0
- package/_shims/node-types.js +3 -0
- package/_shims/node-types.mjs +3 -0
- package/_shims/registry.d.ts +37 -0
- package/_shims/registry.d.ts.map +1 -0
- package/_shims/registry.js +41 -0
- package/_shims/registry.js.map +1 -0
- package/_shims/registry.mjs +37 -0
- package/_shims/registry.mjs.map +1 -0
- package/_shims/web-runtime.d.ts +5 -0
- package/_shims/web-runtime.d.ts.map +1 -0
- package/_shims/web-runtime.js +89 -0
- package/_shims/web-runtime.js.map +1 -0
- package/_shims/web-runtime.mjs +82 -0
- package/_shims/web-runtime.mjs.map +1 -0
- package/_shims/web-types.d.ts +83 -0
- package/_shims/web-types.js +3 -0
- package/_shims/web-types.mjs +3 -0
- package/core.d.ts +237 -0
- package/core.d.ts.map +1 -0
- package/core.js +855 -0
- package/core.js.map +1 -0
- package/core.mjs +829 -0
- package/core.mjs.map +1 -0
- package/error.d.ts +53 -0
- package/error.d.ts.map +1 -0
- package/error.js +143 -0
- package/error.js.map +1 -0
- package/error.mjs +127 -0
- package/error.mjs.map +1 -0
- package/index.d.mts +123 -0
- package/index.d.ts +123 -0
- package/index.d.ts.map +1 -0
- package/index.js +123 -0
- package/index.js.map +1 -0
- package/index.mjs +95 -0
- package/index.mjs.map +1 -0
- package/libs/utils.d.ts +34 -0
- package/libs/utils.d.ts.map +1 -0
- package/libs/utils.js +67 -0
- package/libs/utils.js.map +1 -0
- package/libs/utils.mjs +59 -0
- package/libs/utils.mjs.map +1 -0
- package/package.json +101 -0
- package/resource.d.ts +6 -0
- package/resource.d.ts.map +1 -0
- package/resource.js +10 -0
- package/resource.js.map +1 -0
- package/resource.mjs +6 -0
- package/resource.mjs.map +1 -0
- package/resources/auth/auth.d.ts +51 -0
- package/resources/auth/auth.d.ts.map +1 -0
- package/resources/auth/auth.js +26 -0
- package/resources/auth/auth.js.map +1 -0
- package/resources/auth/auth.mjs +22 -0
- package/resources/auth/auth.mjs.map +1 -0
- package/resources/auth/credentials.d.ts +9 -0
- package/resources/auth/credentials.d.ts.map +1 -0
- package/resources/auth/credentials.js +11 -0
- package/resources/auth/credentials.js.map +1 -0
- package/resources/auth/credentials.mjs +7 -0
- package/resources/auth/credentials.mjs.map +1 -0
- package/resources/auth/index.d.ts +7 -0
- package/resources/auth/index.d.ts.map +1 -0
- package/resources/auth/index.js +23 -0
- package/resources/auth/index.js.map +1 -0
- package/resources/auth/index.mjs +7 -0
- package/resources/auth/index.mjs.map +1 -0
- package/resources/auth/space-policies.d.ts +20 -0
- package/resources/auth/space-policies.d.ts.map +1 -0
- package/resources/auth/space-policies.js +18 -0
- package/resources/auth/space-policies.js.map +1 -0
- package/resources/auth/space-policies.mjs +14 -0
- package/resources/auth/space-policies.mjs.map +1 -0
- package/resources/auth/space-role-users.d.ts +17 -0
- package/resources/auth/space-role-users.d.ts.map +1 -0
- package/resources/auth/space-role-users.js +28 -0
- package/resources/auth/space-role-users.js.map +1 -0
- package/resources/auth/space-role-users.mjs +24 -0
- package/resources/auth/space-role-users.mjs.map +1 -0
- package/resources/auth/space-roles.d.ts +41 -0
- package/resources/auth/space-roles.d.ts.map +1 -0
- package/resources/auth/space-roles.js +52 -0
- package/resources/auth/space-roles.js.map +1 -0
- package/resources/auth/space-roles.mjs +48 -0
- package/resources/auth/space-roles.mjs.map +1 -0
- package/resources/auth/spaces.d.ts +61 -0
- package/resources/auth/spaces.d.ts.map +1 -0
- package/resources/auth/spaces.js +45 -0
- package/resources/auth/spaces.js.map +1 -0
- package/resources/auth/spaces.mjs +41 -0
- package/resources/auth/spaces.mjs.map +1 -0
- package/resources/console/index.d.ts +2 -0
- package/resources/console/index.d.ts.map +1 -0
- package/resources/console/index.js +18 -0
- package/resources/console/index.js.map +1 -0
- package/resources/console/index.mjs +2 -0
- package/resources/console/index.mjs.map +1 -0
- package/resources/console/oauth2.d.ts +53 -0
- package/resources/console/oauth2.d.ts.map +1 -0
- package/resources/console/oauth2.js +20 -0
- package/resources/console/oauth2.js.map +1 -0
- package/resources/console/oauth2.mjs +16 -0
- package/resources/console/oauth2.mjs.map +1 -0
- package/resources/dashboard/dashboards.d.ts +67 -0
- package/resources/dashboard/dashboards.d.ts.map +1 -0
- package/resources/dashboard/dashboards.js +96 -0
- package/resources/dashboard/dashboards.js.map +1 -0
- package/resources/dashboard/dashboards.mjs +92 -0
- package/resources/dashboard/dashboards.mjs.map +1 -0
- package/resources/dashboard/device-states.d.ts +69 -0
- package/resources/dashboard/device-states.d.ts.map +1 -0
- package/resources/dashboard/device-states.js +40 -0
- package/resources/dashboard/device-states.js.map +1 -0
- package/resources/dashboard/device-states.mjs +36 -0
- package/resources/dashboard/device-states.mjs.map +1 -0
- package/resources/dashboard/index.d.ts +3 -0
- package/resources/dashboard/index.d.ts.map +1 -0
- package/resources/dashboard/index.js +19 -0
- package/resources/dashboard/index.js.map +1 -0
- package/resources/dashboard/index.mjs +3 -0
- package/resources/dashboard/index.mjs.map +1 -0
- package/resources/index.d.ts +7 -0
- package/resources/index.d.ts.map +1 -0
- package/resources/index.js +23 -0
- package/resources/index.js.map +1 -0
- package/resources/index.mjs +4 -0
- package/resources/index.mjs.map +1 -0
- package/shims/node.d.ts +30 -0
- package/shims/node.d.ts.map +1 -0
- package/shims/node.js +31 -0
- package/shims/node.js.map +1 -0
- package/shims/node.mjs +5 -0
- package/shims/node.mjs.map +1 -0
- package/shims/web.d.ts +26 -0
- package/shims/web.d.ts.map +1 -0
- package/shims/web.js +31 -0
- package/shims/web.js.map +1 -0
- package/shims/web.mjs +5 -0
- package/shims/web.mjs.map +1 -0
- package/src/_shims/MultipartBody.ts +9 -0
- package/src/_shims/README.md +46 -0
- package/src/_shims/auto/runtime-bun.ts +4 -0
- package/src/_shims/auto/runtime-node.ts +4 -0
- package/src/_shims/auto/runtime.ts +4 -0
- package/src/_shims/auto/types-node.ts +4 -0
- package/src/_shims/auto/types.d.ts +101 -0
- package/src/_shims/auto/types.js +3 -0
- package/src/_shims/auto/types.mjs +3 -0
- package/src/_shims/bun-runtime.ts +14 -0
- package/src/_shims/index.d.ts +72 -0
- package/src/_shims/index.js +13 -0
- package/src/_shims/index.mjs +7 -0
- package/src/_shims/manual-types.d.ts +12 -0
- package/src/_shims/manual-types.js +3 -0
- package/src/_shims/manual-types.mjs +3 -0
- package/src/_shims/node-runtime.ts +78 -0
- package/src/_shims/node-types.d.ts +42 -0
- package/src/_shims/node-types.js +3 -0
- package/src/_shims/node-types.mjs +3 -0
- package/src/_shims/registry.ts +60 -0
- package/src/_shims/web-runtime.ts +91 -0
- package/src/_shims/web-types.d.ts +83 -0
- package/src/_shims/web-types.js +3 -0
- package/src/_shims/web-types.mjs +3 -0
- package/src/core.ts +1061 -0
- package/src/error.ts +134 -0
- package/src/index.ts +206 -0
- package/src/libs/utils.ts +66 -0
- package/src/resource.ts +9 -0
- package/src/resources/auth/auth.ts +92 -0
- package/src/resources/auth/credentials.ts +12 -0
- package/src/resources/auth/index.ts +6 -0
- package/src/resources/auth/space-policies.ts +55 -0
- package/src/resources/auth/space-role-users.ts +42 -0
- package/src/resources/auth/space-roles.ts +95 -0
- package/src/resources/auth/spaces.ts +118 -0
- package/src/resources/console/index.ts +1 -0
- package/src/resources/console/oauth2.ts +83 -0
- package/src/resources/dashboard/dashboards.ts +171 -0
- package/src/resources/dashboard/device-states.ts +142 -0
- package/src/resources/dashboard/index.ts +2 -0
- package/src/resources/index.ts +6 -0
- package/src/shims/node.ts +50 -0
- package/src/shims/web.ts +50 -0
- package/src/tsconfig.json +11 -0
- package/src/types/api.ts +31 -0
- package/src/types/jwt.ts +12 -0
- package/src/version.ts +1 -0
- package/types/api.d.ts +25 -0
- package/types/api.d.ts.map +1 -0
- package/types/api.js +3 -0
- package/types/api.js.map +1 -0
- package/types/api.mjs +2 -0
- package/types/api.mjs.map +1 -0
- package/types/jwt.d.ts +13 -0
- package/types/jwt.d.ts.map +1 -0
- package/types/jwt.js +3 -0
- package/types/jwt.js.map +1 -0
- package/types/jwt.mjs +2 -0
- package/types/jwt.mjs.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +5 -0
- package/version.js.map +1 -0
- package/version.mjs +2 -0
- package/version.mjs.map +1 -0
package/index.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
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 _a;
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.UnprocessableEntityError = exports.PermissionDeniedError = exports.InternalServerError = exports.AuthenticationError = exports.BadRequestError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.APIUserAbortError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIError = exports.SpaceDFError = exports.SpaceDFSDK = void 0;
|
|
28
|
+
const Errors = __importStar(require("./error.js"));
|
|
29
|
+
const Core = __importStar(require("./core.js"));
|
|
30
|
+
const API = __importStar(require("./resources/index.js"));
|
|
31
|
+
/**
|
|
32
|
+
* API Client for interfacing with the SpaceDF SDK API.
|
|
33
|
+
*/
|
|
34
|
+
class SpaceDFSDK extends Core.APIClient {
|
|
35
|
+
/**
|
|
36
|
+
* API Client for interfacing with the Spacedf SDK API.
|
|
37
|
+
*
|
|
38
|
+
* @param {string | null | undefined} [opts.organization=process.env['SPACEDF_ORG_ID'] ?? null]
|
|
39
|
+
* @param {string | undefined} [opts.APIKey=process.env['SPACEDF_API_KEY']]
|
|
40
|
+
* @param {string} [opts.baseURL=process.env['SPACEDF_SDK_BASE_URL'] ?? https://api.v0.spacedf.net/] - Override the default base URL for the API.
|
|
41
|
+
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
42
|
+
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
43
|
+
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
44
|
+
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
45
|
+
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
46
|
+
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
47
|
+
* @param {boolean} [opts.allowMultiOrgs=false] - Only set this option to `true` if you handle it on the server side or using multiple organizations.
|
|
48
|
+
*/
|
|
49
|
+
constructor({ baseURL = Core.readEnv('SPACEDF_SDK_BASE_URL'), organization = Core.readEnv('SPACEDF_ORG_ID') ?? null, APIKey = Core.readEnv('SPACEDF_API_KEY'), allowMultiOrgs = false, ...opts } = {}) {
|
|
50
|
+
if (!allowMultiOrgs) {
|
|
51
|
+
if (baseURL && organization)
|
|
52
|
+
throw new Errors.SpaceDFError('`baseURL` will be overridden by `organization`. You should only configure a single property.');
|
|
53
|
+
if (organization) {
|
|
54
|
+
baseURL = `https://${organization}.api.v0.spacedf.net/api`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const options = {
|
|
58
|
+
organization,
|
|
59
|
+
APIKey,
|
|
60
|
+
baseURL: baseURL || `https://api.v0.spacedf.net/api`,
|
|
61
|
+
...opts,
|
|
62
|
+
};
|
|
63
|
+
super({
|
|
64
|
+
APIKey: options.APIKey,
|
|
65
|
+
baseURL: options.baseURL,
|
|
66
|
+
timeout: options.timeout ?? 60 * 1000 /* 1 minute */,
|
|
67
|
+
httpAgent: options.httpAgent,
|
|
68
|
+
maxRetries: options.maxRetries,
|
|
69
|
+
allowMultiOrgs,
|
|
70
|
+
fetch: options.fetch,
|
|
71
|
+
});
|
|
72
|
+
this.auth = new API.Auth(this);
|
|
73
|
+
this.spacePolicies = new API.SpacePolicies(this);
|
|
74
|
+
this.spaceRoleUsers = new API.SpaceRoleUsers(this);
|
|
75
|
+
this.spaceRoles = new API.SpaceRoles(this);
|
|
76
|
+
this.spaces = new API.Spaces(this);
|
|
77
|
+
this.dashboards = new API.Dashboards(this);
|
|
78
|
+
this.deviceStates = new API.DeviceStates(this);
|
|
79
|
+
this.oauth2 = new API.OAuth2(this);
|
|
80
|
+
this.credentials = new API.Credentials(this);
|
|
81
|
+
this._options = options;
|
|
82
|
+
this.APIKey = APIKey;
|
|
83
|
+
this.organization = organization;
|
|
84
|
+
}
|
|
85
|
+
defaultQuery() {
|
|
86
|
+
return this._options.defaultQuery;
|
|
87
|
+
}
|
|
88
|
+
defaultHeaders(opts) {
|
|
89
|
+
return {
|
|
90
|
+
...super.defaultHeaders(opts),
|
|
91
|
+
...this._options.defaultHeaders,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
authHeaders(opts) {
|
|
95
|
+
const Authorization = `Bearer ${(this.allowMultiOrgs && opts.accessToken) || this.accessToken || ''}`;
|
|
96
|
+
const APIKey = (this.allowMultiOrgs && opts.APIKey) || this.APIKey;
|
|
97
|
+
return { Authorization, 'x-api-key': APIKey };
|
|
98
|
+
}
|
|
99
|
+
setAccessToken(token) {
|
|
100
|
+
this.accessToken = token;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.SpaceDFSDK = SpaceDFSDK;
|
|
104
|
+
_a = SpaceDFSDK;
|
|
105
|
+
SpaceDFSDK.SpaceDFSDK = _a;
|
|
106
|
+
SpaceDFSDK.DEFAULT_TIMEOUT = 60 * 1000; // 1 minute
|
|
107
|
+
SpaceDFSDK.SpaceDFError = Errors.SpaceDFError;
|
|
108
|
+
SpaceDFSDK.APIError = Errors.APIError;
|
|
109
|
+
SpaceDFSDK.APIConnectionError = Errors.APIConnectionError;
|
|
110
|
+
SpaceDFSDK.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
111
|
+
SpaceDFSDK.APIUserAbortError = Errors.APIUserAbortError;
|
|
112
|
+
SpaceDFSDK.NotFoundError = Errors.NotFoundError;
|
|
113
|
+
SpaceDFSDK.ConflictError = Errors.ConflictError;
|
|
114
|
+
SpaceDFSDK.RateLimitError = Errors.RateLimitError;
|
|
115
|
+
SpaceDFSDK.BadRequestError = Errors.BadRequestError;
|
|
116
|
+
SpaceDFSDK.AuthenticationError = Errors.AuthenticationError;
|
|
117
|
+
SpaceDFSDK.InternalServerError = Errors.InternalServerError;
|
|
118
|
+
SpaceDFSDK.PermissionDeniedError = Errors.PermissionDeniedError;
|
|
119
|
+
SpaceDFSDK.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
120
|
+
exports.SpaceDFError = Errors.SpaceDFError, exports.APIError = Errors.APIError, exports.APIConnectionError = Errors.APIConnectionError, exports.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError, exports.APIUserAbortError = Errors.APIUserAbortError, exports.NotFoundError = Errors.NotFoundError, exports.ConflictError = Errors.ConflictError, exports.RateLimitError = Errors.RateLimitError, exports.BadRequestError = Errors.BadRequestError, exports.AuthenticationError = Errors.AuthenticationError, exports.InternalServerError = Errors.InternalServerError, exports.PermissionDeniedError = Errors.PermissionDeniedError, exports.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
121
|
+
exports = module.exports = SpaceDFSDK;
|
|
122
|
+
exports.default = SpaceDFSDK;
|
|
123
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAkC;AAElC,gDAA+B;AAC/B,0DAAyC;AA2EzC;;GAEG;AACH,MAAa,UAAW,SAAQ,IAAI,CAAC,SAAS;IAM1C;;;;;;;;;;;;;OAaG;IACH,YAAY,EACR,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,EAC9C,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,IAAI,EACrD,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,EACxC,cAAc,GAAG,KAAK,EACtB,GAAG,IAAI,KACQ,EAAE;QACjB,IAAI,CAAC,cAAc,EAAE;YACjB,IAAI,OAAO,IAAI,YAAY;gBACvB,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,8FAA8F,CAAC,CAAC;YAElI,IAAI,YAAY,EAAE;gBACd,OAAO,GAAG,WAAW,YAAY,yB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AqB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACrD,mCAAwB,GAAG,MAAM,CAAC,wBAAwB,CAAC;AAIlE,oBAAY,GAaZ,MAAM,eAZN,gBAAQ,GAYR,MAAM,WAXN,0BAAkB,GAWlB,MAAM,qBAVN,iCAAyB,GAUzB,MAAM,4BATN,yBAAiB,GASjB,MAAM,oBARN,qBAAa,GAQb,MAAM,gBAPN,qBAAa,GAOb,MAAM,gBANN,sBAAc,GAMd,MAAM,iBALN,uBAAe,GAKf,MAAM,kBAJN,2BAAmB,GAInB,MAAM,sBAHN,2BAAmB,GAGnB,MAAM,sBAFN,6BAAqB,GAErB,MAAM,wBADN,gCAAwB,GACxB,MAAM,0BAAC;AAEX,kBAAe,UAAU,CAAC"}
|
package/index.mjs
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import * as Errors from "./error.mjs";
|
|
3
|
+
import * as Core from "./core.mjs";
|
|
4
|
+
import * as API from "./resources/index.mjs";
|
|
5
|
+
/**
|
|
6
|
+
* API Client for interfacing with the SpaceDF SDK API.
|
|
7
|
+
*/
|
|
8
|
+
export class SpaceDFSDK extends Core.APIClient {
|
|
9
|
+
/**
|
|
10
|
+
* API Client for interfacing with the Spacedf SDK API.
|
|
11
|
+
*
|
|
12
|
+
* @param {string | null | undefined} [opts.organization=process.env['SPACEDF_ORG_ID'] ?? null]
|
|
13
|
+
* @param {string | undefined} [opts.APIKey=process.env['SPACEDF_API_KEY']]
|
|
14
|
+
* @param {string} [opts.baseURL=process.env['SPACEDF_SDK_BASE_URL'] ?? https://api.v0.spacedf.net/] - Override the default base URL for the API.
|
|
15
|
+
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
16
|
+
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
17
|
+
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
18
|
+
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
19
|
+
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
20
|
+
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
21
|
+
* @param {boolean} [opts.allowMultiOrgs=false] - Only set this option to `true` if you handle it on the server side or using multiple organizations.
|
|
22
|
+
*/
|
|
23
|
+
constructor({ baseURL = Core.readEnv('SPACEDF_SDK_BASE_URL'), organization = Core.readEnv('SPACEDF_ORG_ID') ?? null, APIKey = Core.readEnv('SPACEDF_API_KEY'), allowMultiOrgs = false, ...opts } = {}) {
|
|
24
|
+
if (!allowMultiOrgs) {
|
|
25
|
+
if (baseURL && organization)
|
|
26
|
+
throw new Errors.SpaceDFError('`baseURL` will be overridden by `organization`. You should only configure a single property.');
|
|
27
|
+
if (organization) {
|
|
28
|
+
baseURL = `https://${organization}.api.v0.spacedf.net/api`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const options = {
|
|
32
|
+
organization,
|
|
33
|
+
APIKey,
|
|
34
|
+
baseURL: baseURL || `https://api.v0.spacedf.net/api`,
|
|
35
|
+
...opts,
|
|
36
|
+
};
|
|
37
|
+
super({
|
|
38
|
+
APIKey: options.APIKey,
|
|
39
|
+
baseURL: options.baseURL,
|
|
40
|
+
timeout: options.timeout ?? 60 * 1000 /* 1 minute */,
|
|
41
|
+
httpAgent: options.httpAgent,
|
|
42
|
+
maxRetries: options.maxRetries,
|
|
43
|
+
allowMultiOrgs,
|
|
44
|
+
fetch: options.fetch,
|
|
45
|
+
});
|
|
46
|
+
this.auth = new API.Auth(this);
|
|
47
|
+
this.spacePolicies = new API.SpacePolicies(this);
|
|
48
|
+
this.spaceRoleUsers = new API.SpaceRoleUsers(this);
|
|
49
|
+
this.spaceRoles = new API.SpaceRoles(this);
|
|
50
|
+
this.spaces = new API.Spaces(this);
|
|
51
|
+
this.dashboards = new API.Dashboards(this);
|
|
52
|
+
this.deviceStates = new API.DeviceStates(this);
|
|
53
|
+
this.oauth2 = new API.OAuth2(this);
|
|
54
|
+
this.credentials = new API.Credentials(this);
|
|
55
|
+
this._options = options;
|
|
56
|
+
this.APIKey = APIKey;
|
|
57
|
+
this.organization = organization;
|
|
58
|
+
}
|
|
59
|
+
defaultQuery() {
|
|
60
|
+
return this._options.defaultQuery;
|
|
61
|
+
}
|
|
62
|
+
defaultHeaders(opts) {
|
|
63
|
+
return {
|
|
64
|
+
...super.defaultHeaders(opts),
|
|
65
|
+
...this._options.defaultHeaders,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
authHeaders(opts) {
|
|
69
|
+
const Authorization = `Bearer ${(this.allowMultiOrgs && opts.accessToken) || this.accessToken || ''}`;
|
|
70
|
+
const APIKey = (this.allowMultiOrgs && opts.APIKey) || this.APIKey;
|
|
71
|
+
return { Authorization, 'x-api-key': APIKey };
|
|
72
|
+
}
|
|
73
|
+
setAccessToken(token) {
|
|
74
|
+
this.accessToken = token;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
_a = SpaceDFSDK;
|
|
78
|
+
SpaceDFSDK.SpaceDFSDK = _a;
|
|
79
|
+
SpaceDFSDK.DEFAULT_TIMEOUT = 60 * 1000; // 1 minute
|
|
80
|
+
SpaceDFSDK.SpaceDFError = Errors.SpaceDFError;
|
|
81
|
+
SpaceDFSDK.APIError = Errors.APIError;
|
|
82
|
+
SpaceDFSDK.APIConnectionError = Errors.APIConnectionError;
|
|
83
|
+
SpaceDFSDK.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
84
|
+
SpaceDFSDK.APIUserAbortError = Errors.APIUserAbortError;
|
|
85
|
+
SpaceDFSDK.NotFoundError = Errors.NotFoundError;
|
|
86
|
+
SpaceDFSDK.ConflictError = Errors.ConflictError;
|
|
87
|
+
SpaceDFSDK.RateLimitError = Errors.RateLimitError;
|
|
88
|
+
SpaceDFSDK.BadRequestError = Errors.BadRequestError;
|
|
89
|
+
SpaceDFSDK.AuthenticationError = Errors.AuthenticationError;
|
|
90
|
+
SpaceDFSDK.InternalServerError = Errors.InternalServerError;
|
|
91
|
+
SpaceDFSDK.PermissionDeniedError = Errors.PermissionDeniedError;
|
|
92
|
+
SpaceDFSDK.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
93
|
+
export const { SpaceDFError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } = Errors;
|
|
94
|
+
export default SpaceDFSDK;
|
|
95
|
+
//# sourceMappingURL=index.mjs.map
|
package/index.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";OAAO,KAAK,MAAM;OAEX,KAAK,IAAI;OACT,KAAK,GAAG;AA2Ef;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,IAAI,CAAC,SAAS;IAM1C;;;;;;;;;;;;;OAaG;IACH,YAAY,EACR,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,EAC9C,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,IAAI,EACrD,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,EACxC,cAAc,GAAG,KAAK,EACtB,GAAG,IAAI,KACQ,EAAE;QACjB,IAAI,CAAC,cAAc,EAAE;YACjB,IAAI,OAAO,IAAI,YAAY;gBACvB,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,8FAA8F,CAAC,CAAC;YAElI,IAAI,YAAY,EAAE;gBACd,OAAO,GAAG,WAAW,YAAY,yBAAyB,CAAC;aAC9D;SACJ;QAED,MAAM,OAAO,GAAkB;YAC3B,YAAY;YACZ,MAAM;YACN,OAAO,EAAE,OAAO,IAAI,gCAAgC;YACpD,GAAG,IAAI;SACV,CAAC;QAEF,KAA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iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GAC3B,GAAG,MAAM,CAAC;AAEX,eAAe,UAAU,CAAC"}
|
package/libs/utils.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Converts a given string to its Base64 encoded representation.
|
|
7
|
+
*
|
|
8
|
+
* @param {string | null | undefined} str - The input string to be encoded in Base64. If the input is `null` or `undefined`, an empty string is returned.
|
|
9
|
+
*
|
|
10
|
+
* @returns {string} - The Base64 encoded string. If the input is invalid (null or undefined), an empty string is returned.
|
|
11
|
+
*
|
|
12
|
+
* This function works in both Node.js and browser environments:
|
|
13
|
+
* - In **Node.js**, it uses `Buffer.from()` to convert the string into Base64.
|
|
14
|
+
* - In **browser environments**, it uses the `btoa()` function to generate the Base64 encoded string.
|
|
15
|
+
*
|
|
16
|
+
* If neither `Buffer` (Node.js) nor `btoa` (browser) are available, it throws a custom `SpaceDFError`.
|
|
17
|
+
*
|
|
18
|
+
* @throws {SpaceDFError} - Throws an error if neither `Buffer` nor `btoa` are available for Base64 encoding.
|
|
19
|
+
*/
|
|
20
|
+
export declare const toBase64: (str: string | null | undefined) => string;
|
|
21
|
+
/**
|
|
22
|
+
* Generates a SHA-256 hash for the provided data, compatible with both Node.js and browser environments.
|
|
23
|
+
*
|
|
24
|
+
* @param data - The data to hash, either as a string or a binary-like object.
|
|
25
|
+
* @returns A promise that resolves to the SHA-256 hash as an ArrayBuffer (in browser) or Buffer (in Node.js).
|
|
26
|
+
*/
|
|
27
|
+
export declare const toSHA256: (data: string | NodeJS.ArrayBufferView) => Promise<any>;
|
|
28
|
+
export declare function isObj(obj: unknown): obj is Record<string, unknown>;
|
|
29
|
+
/**
|
|
30
|
+
* https://stackoverflow.com/a/2117523
|
|
31
|
+
*/
|
|
32
|
+
export declare const uuid4: () => string;
|
|
33
|
+
export declare const rstripBase64: (base64: string) => string;
|
|
34
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/libs/utils.ts"],"names":[],"mappings":";;;;AAGA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,QAAQ,QAAS,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,MAWzD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,SAAgB,MAAM,GAAG,sBAAsB,iBAWnE,CAAC;AAEF,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAElE;AAED;;GAEG;AACH,eAAO,MAAM,KAAK,cAMjB,CAAC;AAEF,eAAO,MAAM,YAAY,WAAY,MAAM,WAAsE,CAAC"}
|
package/libs/utils.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rstripBase64 = exports.uuid4 = exports.isObj = exports.toSHA256 = exports.toBase64 = void 0;
|
|
4
|
+
const error_1 = require("../error.js");
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
|
+
/**
|
|
7
|
+
* Converts a given string to its Base64 encoded representation.
|
|
8
|
+
*
|
|
9
|
+
* @param {string | null | undefined} str - The input string to be encoded in Base64. If the input is `null` or `undefined`, an empty string is returned.
|
|
10
|
+
*
|
|
11
|
+
* @returns {string} - The Base64 encoded string. If the input is invalid (null or undefined), an empty string is returned.
|
|
12
|
+
*
|
|
13
|
+
* This function works in both Node.js and browser environments:
|
|
14
|
+
* - In **Node.js**, it uses `Buffer.from()` to convert the string into Base64.
|
|
15
|
+
* - In **browser environments**, it uses the `btoa()` function to generate the Base64 encoded string.
|
|
16
|
+
*
|
|
17
|
+
* If neither `Buffer` (Node.js) nor `btoa` (browser) are available, it throws a custom `SpaceDFError`.
|
|
18
|
+
*
|
|
19
|
+
* @throws {SpaceDFError} - Throws an error if neither `Buffer` nor `btoa` are available for Base64 encoding.
|
|
20
|
+
*/
|
|
21
|
+
const toBase64 = (str) => {
|
|
22
|
+
if (!str)
|
|
23
|
+
return '';
|
|
24
|
+
if (typeof Buffer !== 'undefined') {
|
|
25
|
+
return Buffer.from(str).toString('base64');
|
|
26
|
+
}
|
|
27
|
+
if (typeof btoa !== 'undefined') {
|
|
28
|
+
return btoa(str);
|
|
29
|
+
}
|
|
30
|
+
throw new error_1.SpaceDFError('Cannot generate b64 string; Expected `Buffer` or `btoa` to be defined');
|
|
31
|
+
};
|
|
32
|
+
exports.toBase64 = toBase64;
|
|
33
|
+
/**
|
|
34
|
+
* Generates a SHA-256 hash for the provided data, compatible with both Node.js and browser environments.
|
|
35
|
+
*
|
|
36
|
+
* @param data - The data to hash, either as a string or a binary-like object.
|
|
37
|
+
* @returns A promise that resolves to the SHA-256 hash as an ArrayBuffer (in browser) or Buffer (in Node.js).
|
|
38
|
+
*/
|
|
39
|
+
const toSHA256 = async (data) => {
|
|
40
|
+
const encodedData = typeof data === 'string' ? new TextEncoder().encode(data) : data;
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
if (typeof globalThis !== 'undefined' && typeof globalThis.crypto !== 'undefined') {
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
const hash = await globalThis.crypto.subtle.digest('SHA-256', encodedData);
|
|
45
|
+
return hash;
|
|
46
|
+
}
|
|
47
|
+
return (0, node_crypto_1.createHash)('sha256').update(encodedData).digest();
|
|
48
|
+
};
|
|
49
|
+
exports.toSHA256 = toSHA256;
|
|
50
|
+
function isObj(obj) {
|
|
51
|
+
return obj != null && typeof obj === 'object' && !Array.isArray(obj);
|
|
52
|
+
}
|
|
53
|
+
exports.isObj = isObj;
|
|
54
|
+
/**
|
|
55
|
+
* https://stackoverflow.com/a/2117523
|
|
56
|
+
*/
|
|
57
|
+
const uuid4 = () => {
|
|
58
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
59
|
+
const r = (Math.random() * 16) | 0;
|
|
60
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
61
|
+
return v.toString(16);
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
exports.uuid4 = uuid4;
|
|
65
|
+
const rstripBase64 = (base64) => base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
66
|
+
exports.rstripBase64 = rstripBase64;
|
|
67
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/libs/utils.ts"],"names":[],"mappings":";;;AAAA,uCAAwC;AACxC,6CAAyC;AAEzC;;;;;;;;;;;;;;GAcG;AACI,MAAM,QAAQ,GAAG,CAAC,GAA8B,EAAU,EAAE;IAC/D,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QAC/B,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;KAC9C;IAED,IAAI,OAAO,IAAI,KAAK,WAAW,EAAE;QAC7B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;KACpB;IAED,MAAM,IAAI,oBAAY,CAAC,uEAAuE,CAAC,CAAC;AACpG,CAAC,CAAC;AAXW,QAAA,QAAQ,YAWnB;AAEF;;;;;GAKG;AACI,MAAM,QAAQ,GAAG,KAAK,EAAE,IAAqC,EAAE,EAAE;IACpE,MAAM,WAAW,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAErF,aA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BAAyF"}
|
package/libs/utils.mjs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { SpaceDFError } from "../error.mjs";
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
/**
|
|
4
|
+
* Converts a given string to its Base64 encoded representation.
|
|
5
|
+
*
|
|
6
|
+
* @param {string | null | undefined} str - The input string to be encoded in Base64. If the input is `null` or `undefined`, an empty string is returned.
|
|
7
|
+
*
|
|
8
|
+
* @returns {string} - The Base64 encoded string. If the input is invalid (null or undefined), an empty string is returned.
|
|
9
|
+
*
|
|
10
|
+
* This function works in both Node.js and browser environments:
|
|
11
|
+
* - In **Node.js**, it uses `Buffer.from()` to convert the string into Base64.
|
|
12
|
+
* - In **browser environments**, it uses the `btoa()` function to generate the Base64 encoded string.
|
|
13
|
+
*
|
|
14
|
+
* If neither `Buffer` (Node.js) nor `btoa` (browser) are available, it throws a custom `SpaceDFError`.
|
|
15
|
+
*
|
|
16
|
+
* @throws {SpaceDFError} - Throws an error if neither `Buffer` nor `btoa` are available for Base64 encoding.
|
|
17
|
+
*/
|
|
18
|
+
export const toBase64 = (str) => {
|
|
19
|
+
if (!str)
|
|
20
|
+
return '';
|
|
21
|
+
if (typeof Buffer !== 'undefined') {
|
|
22
|
+
return Buffer.from(str).toString('base64');
|
|
23
|
+
}
|
|
24
|
+
if (typeof btoa !== 'undefined') {
|
|
25
|
+
return btoa(str);
|
|
26
|
+
}
|
|
27
|
+
throw new SpaceDFError('Cannot generate b64 string; Expected `Buffer` or `btoa` to be defined');
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Generates a SHA-256 hash for the provided data, compatible with both Node.js and browser environments.
|
|
31
|
+
*
|
|
32
|
+
* @param data - The data to hash, either as a string or a binary-like object.
|
|
33
|
+
* @returns A promise that resolves to the SHA-256 hash as an ArrayBuffer (in browser) or Buffer (in Node.js).
|
|
34
|
+
*/
|
|
35
|
+
export const toSHA256 = async (data) => {
|
|
36
|
+
const encodedData = typeof data === 'string' ? new TextEncoder().encode(data) : data;
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
if (typeof globalThis !== 'undefined' && typeof globalThis.crypto !== 'undefined') {
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
const hash = await globalThis.crypto.subtle.digest('SHA-256', encodedData);
|
|
41
|
+
return hash;
|
|
42
|
+
}
|
|
43
|
+
return createHash('sha256').update(encodedData).digest();
|
|
44
|
+
};
|
|
45
|
+
export function isObj(obj) {
|
|
46
|
+
return obj != null && typeof obj === 'object' && !Array.isArray(obj);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* https://stackoverflow.com/a/2117523
|
|
50
|
+
*/
|
|
51
|
+
export const uuid4 = () => {
|
|
52
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
53
|
+
const r = (Math.random() * 16) | 0;
|
|
54
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
55
|
+
return v.toString(16);
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
export const rstripBase64 = (base64) => base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
59
|
+
//# sourceMappingURL=utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../src/libs/utils.ts"],"names":[],"mappings":"OAAO,EAAE,YAAY,EAAE;OAChB,EAAE,UAAU,EAAE,MAAM,aAAa;AAExC;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAA8B,EAAU,EAAE;IAC/D,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QAC/B,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;KAC9C;IAED,IAAI,OAAO,IAAI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AG,CAAC;QAC1C,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@space-df/sdk",
|
|
3
|
+
"version": "0.0.1-dev.3.1",
|
|
4
|
+
"description": "The official TypeScript library for the Spacedf SDK API",
|
|
5
|
+
"author": "Spacedf SDK <support@digitalfortress.dev>",
|
|
6
|
+
"types": "./index.d.ts",
|
|
7
|
+
"main": "./index.js",
|
|
8
|
+
"type": "commonjs",
|
|
9
|
+
"repository": "git@github.com:Space-DF/spacedf-sdk-node.git",
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"packageManager": "yarn@1.22.22",
|
|
12
|
+
"files": [
|
|
13
|
+
"*"
|
|
14
|
+
],
|
|
15
|
+
"private": false,
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "./scripts/build",
|
|
18
|
+
"format": "prettier --write --cache --cache-strategy metadata . !dist",
|
|
19
|
+
"tsn": "ts-node -r tsconfig-paths/register",
|
|
20
|
+
"lint": "eslint \"{src,test}/**/*.ts\""
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@types/node": "^18.11.18",
|
|
24
|
+
"@types/node-fetch": "^2.6.4",
|
|
25
|
+
"abort-controller": "^3.0.0",
|
|
26
|
+
"agentkeepalive": "^4.2.1",
|
|
27
|
+
"form-data-encoder": "1.7.2",
|
|
28
|
+
"formdata-node": "^4.3.2",
|
|
29
|
+
"node-fetch": "^2.6.7"
|
|
30
|
+
},
|
|
31
|
+
"sideEffects": [
|
|
32
|
+
"./_shims/index.js",
|
|
33
|
+
"./_shims/index.mjs",
|
|
34
|
+
"./shims/node.js",
|
|
35
|
+
"./shims/node.mjs",
|
|
36
|
+
"./shims/web.js",
|
|
37
|
+
"./shims/web.mjs"
|
|
38
|
+
],
|
|
39
|
+
"imports": {
|
|
40
|
+
"@space-df/sdk": ".",
|
|
41
|
+
"@space-df/sdk/*": "./src/*"
|
|
42
|
+
},
|
|
43
|
+
"exports": {
|
|
44
|
+
"./_shims/auto/*": {
|
|
45
|
+
"deno": {
|
|
46
|
+
"types": "./_shims/auto/*.d.ts",
|
|
47
|
+
"require": "./_shims/auto/*.js",
|
|
48
|
+
"default": "./_shims/auto/*.mjs"
|
|
49
|
+
},
|
|
50
|
+
"bun": {
|
|
51
|
+
"types": "./_shims/auto/*.d.ts",
|
|
52
|
+
"require": "./_shims/auto/*-bun.js",
|
|
53
|
+
"default": "./_shims/auto/*-bun.mjs"
|
|
54
|
+
},
|
|
55
|
+
"browser": {
|
|
56
|
+
"types": "./_shims/auto/*.d.ts",
|
|
57
|
+
"require": "./_shims/auto/*.js",
|
|
58
|
+
"default": "./_shims/auto/*.mjs"
|
|
59
|
+
},
|
|
60
|
+
"worker": {
|
|
61
|
+
"types": "./_shims/auto/*.d.ts",
|
|
62
|
+
"require": "./_shims/auto/*.js",
|
|
63
|
+
"default": "./_shims/auto/*.mjs"
|
|
64
|
+
},
|
|
65
|
+
"workerd": {
|
|
66
|
+
"types": "./_shims/auto/*.d.ts",
|
|
67
|
+
"require": "./_shims/auto/*.js",
|
|
68
|
+
"default": "./_shims/auto/*.mjs"
|
|
69
|
+
},
|
|
70
|
+
"node": {
|
|
71
|
+
"types": "./_shims/auto/*-node.d.ts",
|
|
72
|
+
"require": "./_shims/auto/*-node.js",
|
|
73
|
+
"default": "./_shims/auto/*-node.mjs"
|
|
74
|
+
},
|
|
75
|
+
"types": "./_shims/auto/*.d.ts",
|
|
76
|
+
"require": "./_shims/auto/*.js",
|
|
77
|
+
"default": "./_shims/auto/*.mjs"
|
|
78
|
+
},
|
|
79
|
+
".": {
|
|
80
|
+
"require": {
|
|
81
|
+
"types": "./index.d.ts",
|
|
82
|
+
"default": "./index.js"
|
|
83
|
+
},
|
|
84
|
+
"types": "./index.d.mts",
|
|
85
|
+
"default": "./index.mjs"
|
|
86
|
+
},
|
|
87
|
+
"./*.mjs": {
|
|
88
|
+
"types": "./*.d.ts",
|
|
89
|
+
"default": "./*.mjs"
|
|
90
|
+
},
|
|
91
|
+
"./*.js": {
|
|
92
|
+
"types": "./*.d.ts",
|
|
93
|
+
"default": "./*.js"
|
|
94
|
+
},
|
|
95
|
+
"./*": {
|
|
96
|
+
"types": "./*.d.ts",
|
|
97
|
+
"require": "./*.js",
|
|
98
|
+
"default": "./*.mjs"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
package/resource.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,qBAAa,WAAW;IACpB,SAAS,CAAC,OAAO,EAAE,UAAU,CAAC;gBAElB,MAAM,EAAE,UAAU;CAGjC"}
|
package/resource.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.APIResource = void 0;
|
|
4
|
+
class APIResource {
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this._client = client;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.APIResource = APIResource;
|
|
10
|
+
//# sourceMappingURL=resource.js.map
|
package/resource.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.js","sourceRoot":"","sources":["src/resource.ts"],"names":[],"mappings":";;;AAEA,MAAa,WAAW;IAGpB,YAAY,MAAkB;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;CACJ;AAND,kCAMC"}
|
package/resource.mjs
ADDED
package/resource.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.mjs","sourceRoot":"","sources":["src/resource.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,WAAW;IAGpB,YAAY,MAAkB;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;CACJ"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { APIResource } from "../../resource.js";
|
|
2
|
+
import * as Core from "../../core.js";
|
|
3
|
+
export declare class Auth extends APIResource {
|
|
4
|
+
login(body: AuthLoginParams, options?: Core.RequestOptions): Core.APIPromise<AuthTokenPair>;
|
|
5
|
+
oauth2Google(body: OAuthLogin, options?: Core.RequestOptions): Core.APIPromise<OAuthLogin>;
|
|
6
|
+
oauth2SpaceDF(body: OAuthSpaceDF, options?: Core.RequestOptions): Core.APIPromise<OAuthSpaceDF>;
|
|
7
|
+
refreshToken(body: AuthRefreshTokenParams, options?: Core.RequestOptions): Core.APIPromise<CustomTokenRefresh>;
|
|
8
|
+
register(body: AuthRegisterParams, options?: Core.RequestOptions): Core.APIPromise<Registration>;
|
|
9
|
+
switchSpaces(body: AuthRefreshTokenParams, options?: Core.RequestOptions): Core.APIPromise<CustomTokenRefresh>;
|
|
10
|
+
}
|
|
11
|
+
export interface AuthTokenPair {
|
|
12
|
+
refresh: string;
|
|
13
|
+
access: string;
|
|
14
|
+
default_space: string;
|
|
15
|
+
}
|
|
16
|
+
export interface CustomTokenRefresh {
|
|
17
|
+
refresh: string;
|
|
18
|
+
access?: string;
|
|
19
|
+
space?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface OAuthLogin {
|
|
22
|
+
authorization_code: string;
|
|
23
|
+
code_verifier: string;
|
|
24
|
+
}
|
|
25
|
+
export interface OAuthSpaceDF {
|
|
26
|
+
code_verifier: string;
|
|
27
|
+
code: string;
|
|
28
|
+
client_id: string;
|
|
29
|
+
}
|
|
30
|
+
export interface Registration {
|
|
31
|
+
id?: number;
|
|
32
|
+
first_name: string;
|
|
33
|
+
last_name: string;
|
|
34
|
+
email: string;
|
|
35
|
+
default_space?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface AuthLoginParams {
|
|
38
|
+
email: string;
|
|
39
|
+
password: string;
|
|
40
|
+
}
|
|
41
|
+
export interface AuthRefreshTokenParams {
|
|
42
|
+
refresh: string;
|
|
43
|
+
space: string;
|
|
44
|
+
}
|
|
45
|
+
export interface AuthRegisterParams {
|
|
46
|
+
email: string;
|
|
47
|
+
password: string;
|
|
48
|
+
first_name: string;
|
|
49
|
+
last_name: string;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/resources/auth/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AAEnC,qBAAa,IAAK,SAAQ,WAAW;IACjC,KAAK,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;IAI3F,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;IAI1F,aAAa,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC;IAI/F,YAAY,CAAC,IAAI,EAAE,sBAAsB,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU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EAAE,MAAM,CAAC;IAEnB,SAAS,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Auth = void 0;
|
|
4
|
+
const resource_1 = require("../../resource.js");
|
|
5
|
+
class Auth extends resource_1.APIResource {
|
|
6
|
+
login(body, options) {
|
|
7
|
+
return this._client.post(`/auth/login`, { body, ...options });
|
|
8
|
+
}
|
|
9
|
+
oauth2Google(body, options) {
|
|
10
|
+
return this._client.post(`/auth/oauth2/google`, { body, ...options });
|
|
11
|
+
}
|
|
12
|
+
oauth2SpaceDF(body, options) {
|
|
13
|
+
return this._client.post(`/auth/oauth2/spacedf-console`, { body, ...options });
|
|
14
|
+
}
|
|
15
|
+
refreshToken(body, options) {
|
|
16
|
+
return this._client.post(`/auth/refresh-token`, { body, ...options });
|
|
17
|
+
}
|
|
18
|
+
register(body, options) {
|
|
19
|
+
return this._client.post(`/auth/register`, { body, ...options });
|
|
20
|
+
}
|
|
21
|
+
switchSpaces(body, options) {
|
|
22
|
+
return this._client.post(`/auth/spaces/switch`, { body, ...options });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.Auth = Auth;
|
|
26
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/resources/auth/auth.ts"],"names":[],"mappings":";;;AAAA,gDAA6C;AAG7C,MAAa,IAAK,SAAQ,sBAAW;IACjC,KAAK,CAAC,IAAqB,EAAE,OAA6B;QACtD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,YAAY,CAAC,IAAgB,EAAE,OAA6B;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,qBAAqB,EAA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