@space-df/sdk 0.0.1-dev.10
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/.editorconfig +24 -0
- package/.github/pull_request_template.md +25 -0
- package/.github/workflows/bump-version.yml +67 -0
- package/.github/workflows/publish-package.yml +28 -0
- package/.gitignore +11 -0
- package/CODE_OF_CONDUCT.md +128 -0
- package/CONTRIBUTING.md +89 -0
- package/LICENSE +7 -0
- package/README.md +382 -0
- package/api.doc.md +1558 -0
- package/dist/LICENSE +7 -0
- package/dist/README.md +382 -0
- package/dist/_shims/MultipartBody.d.ts +9 -0
- package/dist/_shims/MultipartBody.d.ts.map +1 -0
- package/dist/_shims/MultipartBody.js +16 -0
- package/dist/_shims/MultipartBody.js.map +1 -0
- package/dist/_shims/MultipartBody.mjs +12 -0
- package/dist/_shims/MultipartBody.mjs.map +1 -0
- package/dist/_shims/README.md +46 -0
- package/dist/_shims/auto/runtime-bun.d.ts +5 -0
- package/dist/_shims/auto/runtime-bun.d.ts.map +1 -0
- package/dist/_shims/auto/runtime-bun.js +21 -0
- package/dist/_shims/auto/runtime-bun.js.map +1 -0
- package/dist/_shims/auto/runtime-bun.mjs +2 -0
- package/dist/_shims/auto/runtime-bun.mjs.map +1 -0
- package/dist/_shims/auto/runtime-node.d.ts +5 -0
- package/dist/_shims/auto/runtime-node.d.ts.map +1 -0
- package/dist/_shims/auto/runtime-node.js +21 -0
- package/dist/_shims/auto/runtime-node.js.map +1 -0
- package/dist/_shims/auto/runtime-node.mjs +2 -0
- package/dist/_shims/auto/runtime-node.mjs.map +1 -0
- package/dist/_shims/auto/runtime.d.ts +5 -0
- package/dist/_shims/auto/runtime.d.ts.map +1 -0
- package/dist/_shims/auto/runtime.js +21 -0
- package/dist/_shims/auto/runtime.js.map +1 -0
- package/dist/_shims/auto/runtime.mjs +2 -0
- package/dist/_shims/auto/runtime.mjs.map +1 -0
- package/dist/_shims/auto/types-node.d.ts +5 -0
- package/dist/_shims/auto/types-node.d.ts.map +1 -0
- package/dist/_shims/auto/types-node.js +21 -0
- package/dist/_shims/auto/types-node.js.map +1 -0
- package/dist/_shims/auto/types-node.mjs +2 -0
- package/dist/_shims/auto/types-node.mjs.map +1 -0
- package/dist/_shims/auto/types.d.ts +101 -0
- package/dist/_shims/auto/types.js +3 -0
- package/dist/_shims/auto/types.mjs +3 -0
- package/dist/_shims/bun-runtime.d.ts +6 -0
- package/dist/_shims/bun-runtime.d.ts.map +1 -0
- package/dist/_shims/bun-runtime.js +14 -0
- package/dist/_shims/bun-runtime.js.map +1 -0
- package/dist/_shims/bun-runtime.mjs +10 -0
- package/dist/_shims/bun-runtime.mjs.map +1 -0
- package/dist/_shims/index.d.ts +72 -0
- package/dist/_shims/index.js +13 -0
- package/dist/_shims/index.mjs +7 -0
- package/dist/_shims/manual-types.d.ts +12 -0
- package/dist/_shims/manual-types.js +3 -0
- package/dist/_shims/manual-types.mjs +3 -0
- package/dist/_shims/node-runtime.d.ts +3 -0
- package/dist/_shims/node-runtime.d.ts.map +1 -0
- package/dist/_shims/node-runtime.js +89 -0
- package/dist/_shims/node-runtime.js.map +1 -0
- package/dist/_shims/node-runtime.mjs +56 -0
- package/dist/_shims/node-runtime.mjs.map +1 -0
- package/dist/_shims/node-types.d.ts +42 -0
- package/dist/_shims/node-types.js +3 -0
- package/dist/_shims/node-types.mjs +3 -0
- package/dist/_shims/registry.d.ts +37 -0
- package/dist/_shims/registry.d.ts.map +1 -0
- package/dist/_shims/registry.js +41 -0
- package/dist/_shims/registry.js.map +1 -0
- package/dist/_shims/registry.mjs +37 -0
- package/dist/_shims/registry.mjs.map +1 -0
- package/dist/_shims/web-runtime.d.ts +5 -0
- package/dist/_shims/web-runtime.d.ts.map +1 -0
- package/dist/_shims/web-runtime.js +89 -0
- package/dist/_shims/web-runtime.js.map +1 -0
- package/dist/_shims/web-runtime.mjs +82 -0
- package/dist/_shims/web-runtime.mjs.map +1 -0
- package/dist/_shims/web-types.d.ts +83 -0
- package/dist/_shims/web-types.js +3 -0
- package/dist/_shims/web-types.mjs +3 -0
- package/dist/core.d.ts +237 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +855 -0
- package/dist/core.js.map +1 -0
- package/dist/core.mjs +829 -0
- package/dist/core.mjs.map +1 -0
- package/dist/error.d.ts +53 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +143 -0
- package/dist/error.js.map +1 -0
- package/dist/error.mjs +127 -0
- package/dist/error.mjs.map +1 -0
- package/dist/index.d.mts +125 -0
- package/dist/index.d.ts +125 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +125 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +97 -0
- package/dist/index.mjs.map +1 -0
- package/dist/libs/utils.d.ts +34 -0
- package/dist/libs/utils.d.ts.map +1 -0
- package/dist/libs/utils.js +67 -0
- package/dist/libs/utils.js.map +1 -0
- package/dist/libs/utils.mjs +59 -0
- package/dist/libs/utils.mjs.map +1 -0
- package/dist/package.json +101 -0
- package/dist/resource.d.ts +6 -0
- package/dist/resource.d.ts.map +1 -0
- package/dist/resource.js +10 -0
- package/dist/resource.js.map +1 -0
- package/dist/resource.mjs +6 -0
- package/dist/resource.mjs.map +1 -0
- package/dist/resources/auth/auth.d.ts +60 -0
- package/dist/resources/auth/auth.d.ts.map +1 -0
- package/dist/resources/auth/auth.js +32 -0
- package/dist/resources/auth/auth.js.map +1 -0
- package/dist/resources/auth/auth.mjs +28 -0
- package/dist/resources/auth/auth.mjs.map +1 -0
- package/dist/resources/auth/credentials.d.ts +9 -0
- package/dist/resources/auth/credentials.d.ts.map +1 -0
- package/dist/resources/auth/credentials.js +11 -0
- package/dist/resources/auth/credentials.js.map +1 -0
- package/dist/resources/auth/credentials.mjs +7 -0
- package/dist/resources/auth/credentials.mjs.map +1 -0
- package/dist/resources/auth/index.d.ts +9 -0
- package/dist/resources/auth/index.d.ts.map +1 -0
- package/dist/resources/auth/index.js +25 -0
- package/dist/resources/auth/index.js.map +1 -0
- package/dist/resources/auth/index.mjs +9 -0
- package/dist/resources/auth/index.mjs.map +1 -0
- package/dist/resources/auth/presigned-url.d.ts +10 -0
- package/dist/resources/auth/presigned-url.d.ts.map +1 -0
- package/dist/resources/auth/presigned-url.js +11 -0
- package/dist/resources/auth/presigned-url.js.map +1 -0
- package/dist/resources/auth/presigned-url.mjs +7 -0
- package/dist/resources/auth/presigned-url.mjs.map +1 -0
- package/dist/resources/auth/space-policies.d.ts +20 -0
- package/dist/resources/auth/space-policies.d.ts.map +1 -0
- package/dist/resources/auth/space-policies.js +18 -0
- package/dist/resources/auth/space-policies.js.map +1 -0
- package/dist/resources/auth/space-policies.mjs +14 -0
- package/dist/resources/auth/space-policies.mjs.map +1 -0
- package/dist/resources/auth/space-role-users.d.ts +22 -0
- package/dist/resources/auth/space-role-users.d.ts.map +1 -0
- package/dist/resources/auth/space-role-users.js +44 -0
- package/dist/resources/auth/space-role-users.js.map +1 -0
- package/dist/resources/auth/space-role-users.mjs +40 -0
- package/dist/resources/auth/space-role-users.mjs.map +1 -0
- package/dist/resources/auth/space-roles.d.ts +41 -0
- package/dist/resources/auth/space-roles.d.ts.map +1 -0
- package/dist/resources/auth/space-roles.js +52 -0
- package/dist/resources/auth/space-roles.js.map +1 -0
- package/dist/resources/auth/space-roles.mjs +48 -0
- package/dist/resources/auth/space-roles.mjs.map +1 -0
- package/dist/resources/auth/spaces.d.ts +74 -0
- package/dist/resources/auth/spaces.d.ts.map +1 -0
- package/dist/resources/auth/spaces.js +51 -0
- package/dist/resources/auth/spaces.js.map +1 -0
- package/dist/resources/auth/spaces.mjs +47 -0
- package/dist/resources/auth/spaces.mjs.map +1 -0
- package/dist/resources/auth/users.d.ts +19 -0
- package/dist/resources/auth/users.d.ts.map +1 -0
- package/dist/resources/auth/users.js +17 -0
- package/dist/resources/auth/users.js.map +1 -0
- package/dist/resources/auth/users.mjs +13 -0
- package/dist/resources/auth/users.mjs.map +1 -0
- package/dist/resources/console/index.d.ts +2 -0
- package/dist/resources/console/index.d.ts.map +1 -0
- package/dist/resources/console/index.js +18 -0
- package/dist/resources/console/index.js.map +1 -0
- package/dist/resources/console/index.mjs +2 -0
- package/dist/resources/console/index.mjs.map +1 -0
- package/dist/resources/console/oauth2.d.ts +53 -0
- package/dist/resources/console/oauth2.d.ts.map +1 -0
- package/dist/resources/console/oauth2.js +20 -0
- package/dist/resources/console/oauth2.js.map +1 -0
- package/dist/resources/console/oauth2.mjs +16 -0
- package/dist/resources/console/oauth2.mjs.map +1 -0
- package/dist/resources/dashboard/dashboards.d.ts +67 -0
- package/dist/resources/dashboard/dashboards.d.ts.map +1 -0
- package/dist/resources/dashboard/dashboards.js +96 -0
- package/dist/resources/dashboard/dashboards.js.map +1 -0
- package/dist/resources/dashboard/dashboards.mjs +92 -0
- package/dist/resources/dashboard/dashboards.mjs.map +1 -0
- package/dist/resources/dashboard/device-states.d.ts +69 -0
- package/dist/resources/dashboard/device-states.d.ts.map +1 -0
- package/dist/resources/dashboard/device-states.js +40 -0
- package/dist/resources/dashboard/device-states.js.map +1 -0
- package/dist/resources/dashboard/device-states.mjs +36 -0
- package/dist/resources/dashboard/device-states.mjs.map +1 -0
- package/dist/resources/dashboard/index.d.ts +3 -0
- package/dist/resources/dashboard/index.d.ts.map +1 -0
- package/dist/resources/dashboard/index.js +19 -0
- package/dist/resources/dashboard/index.js.map +1 -0
- package/dist/resources/dashboard/index.mjs +3 -0
- package/dist/resources/dashboard/index.mjs.map +1 -0
- package/dist/resources/index.d.ts +7 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +23 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/resources/index.mjs +4 -0
- package/dist/resources/index.mjs.map +1 -0
- package/dist/shims/node.d.ts +30 -0
- package/dist/shims/node.d.ts.map +1 -0
- package/dist/shims/node.js +31 -0
- package/dist/shims/node.js.map +1 -0
- package/dist/shims/node.mjs +5 -0
- package/dist/shims/node.mjs.map +1 -0
- package/dist/shims/web.d.ts +26 -0
- package/dist/shims/web.d.ts.map +1 -0
- package/dist/shims/web.js +31 -0
- package/dist/shims/web.js.map +1 -0
- package/dist/shims/web.mjs +5 -0
- package/dist/shims/web.mjs.map +1 -0
- package/dist/src/_shims/MultipartBody.ts +9 -0
- package/dist/src/_shims/README.md +46 -0
- package/dist/src/_shims/auto/runtime-bun.ts +4 -0
- package/dist/src/_shims/auto/runtime-node.ts +4 -0
- package/dist/src/_shims/auto/runtime.ts +4 -0
- package/dist/src/_shims/auto/types-node.ts +4 -0
- package/dist/src/_shims/auto/types.d.ts +101 -0
- package/dist/src/_shims/auto/types.js +3 -0
- package/dist/src/_shims/auto/types.mjs +3 -0
- package/dist/src/_shims/bun-runtime.ts +14 -0
- package/dist/src/_shims/index.d.ts +72 -0
- package/dist/src/_shims/index.js +13 -0
- package/dist/src/_shims/index.mjs +7 -0
- package/dist/src/_shims/manual-types.d.ts +12 -0
- package/dist/src/_shims/manual-types.js +3 -0
- package/dist/src/_shims/manual-types.mjs +3 -0
- package/dist/src/_shims/node-runtime.ts +78 -0
- package/dist/src/_shims/node-types.d.ts +42 -0
- package/dist/src/_shims/node-types.js +3 -0
- package/dist/src/_shims/node-types.mjs +3 -0
- package/dist/src/_shims/registry.ts +60 -0
- package/dist/src/_shims/web-runtime.ts +91 -0
- package/dist/src/_shims/web-types.d.ts +83 -0
- package/dist/src/_shims/web-types.js +3 -0
- package/dist/src/_shims/web-types.mjs +3 -0
- package/dist/src/core.ts +1061 -0
- package/dist/src/error.ts +134 -0
- package/dist/src/index.ts +208 -0
- package/dist/src/libs/utils.ts +66 -0
- package/dist/src/resource.ts +9 -0
- package/dist/src/resources/auth/auth.ts +110 -0
- package/dist/src/resources/auth/credentials.ts +12 -0
- package/dist/src/resources/auth/index.ts +8 -0
- package/dist/src/resources/auth/presigned-url.ts +13 -0
- package/dist/src/resources/auth/space-policies.ts +55 -0
- package/dist/src/resources/auth/space-role-users.ts +64 -0
- package/dist/src/resources/auth/space-roles.ts +95 -0
- package/dist/src/resources/auth/spaces.ts +140 -0
- package/dist/src/resources/auth/users.ts +36 -0
- package/dist/src/resources/console/index.ts +1 -0
- package/dist/src/resources/console/oauth2.ts +83 -0
- package/dist/src/resources/dashboard/dashboards.ts +171 -0
- package/dist/src/resources/dashboard/device-states.ts +142 -0
- package/dist/src/resources/dashboard/index.ts +2 -0
- package/dist/src/resources/index.ts +6 -0
- package/dist/src/shims/node.ts +50 -0
- package/dist/src/shims/web.ts +50 -0
- package/dist/src/tsconfig.json +11 -0
- package/dist/src/types/api.ts +31 -0
- package/dist/src/types/jwt.ts +12 -0
- package/dist/src/version.ts +1 -0
- package/dist/types/api.d.ts +25 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/api.js +3 -0
- package/dist/types/api.js.map +1 -0
- package/dist/types/api.mjs +2 -0
- package/dist/types/api.mjs.map +1 -0
- package/dist/types/jwt.d.ts +13 -0
- package/dist/types/jwt.d.ts.map +1 -0
- package/dist/types/jwt.js +3 -0
- package/dist/types/jwt.js.map +1 -0
- package/dist/types/jwt.mjs +2 -0
- package/dist/types/jwt.mjs.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/dist/version.mjs +2 -0
- package/dist/version.mjs.map +1 -0
- package/eslint.config.mjs +33 -0
- package/examples/auth/login.ts +14 -0
- package/examples/auth/register.ts +15 -0
- package/examples/console/oauth2.ts +15 -0
- package/package.json +118 -0
- package/scripts/build +56 -0
- package/scripts/utils/check-version.cjs +20 -0
- package/scripts/utils/fix-index-exports.cjs +8 -0
- package/scripts/utils/make-dist-package-json.cjs +21 -0
- package/scripts/utils/postprocess-files.cjs +153 -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-deno.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-deno.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-deno.ts +105 -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 +208 -0
- package/src/libs/utils.ts +66 -0
- package/src/resource.ts +9 -0
- package/src/resources/auth/auth.ts +110 -0
- package/src/resources/auth/credentials.ts +12 -0
- package/src/resources/auth/index.ts +8 -0
- package/src/resources/auth/presigned-url.ts +13 -0
- package/src/resources/auth/space-policies.ts +55 -0
- package/src/resources/auth/space-role-users.ts +64 -0
- package/src/resources/auth/space-roles.ts +95 -0
- package/src/resources/auth/spaces.ts +140 -0
- package/src/resources/auth/users.ts +36 -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/types/api.ts +31 -0
- package/src/types/jwt.ts +12 -0
- package/src/version.ts +1 -0
- package/tsc-multi.json +7 -0
- package/tsconfig.build.json +18 -0
- package/tsconfig.deno.json +20 -0
- package/tsconfig.dist-src.json +11 -0
- package/tsconfig.json +38 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
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.users = new API.Users(this);
|
|
82
|
+
this.presignedUrl = new API.PresignedUrl(this);
|
|
83
|
+
this._options = options;
|
|
84
|
+
this.APIKey = APIKey;
|
|
85
|
+
this.organization = organization;
|
|
86
|
+
}
|
|
87
|
+
defaultQuery() {
|
|
88
|
+
return this._options.defaultQuery;
|
|
89
|
+
}
|
|
90
|
+
defaultHeaders(opts) {
|
|
91
|
+
return {
|
|
92
|
+
...super.defaultHeaders(opts),
|
|
93
|
+
...this._options.defaultHeaders,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
authHeaders(opts) {
|
|
97
|
+
const Authorization = `Bearer ${(this.allowMultiOrgs && opts.accessToken) || this.accessToken || ''}`;
|
|
98
|
+
const APIKey = (this.allowMultiOrgs && opts.APIKey) || this.APIKey;
|
|
99
|
+
return { Authorization, 'x-api-key': APIKey };
|
|
100
|
+
}
|
|
101
|
+
setAccessToken(token) {
|
|
102
|
+
this.accessToken = token;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.SpaceDFSDK = SpaceDFSDK;
|
|
106
|
+
_a = SpaceDFSDK;
|
|
107
|
+
SpaceDFSDK.SpaceDFSDK = _a;
|
|
108
|
+
SpaceDFSDK.DEFAULT_TIMEOUT = 60 * 1000; // 1 minute
|
|
109
|
+
SpaceDFSDK.SpaceDFError = Errors.SpaceDFError;
|
|
110
|
+
SpaceDFSDK.APIError = Errors.APIError;
|
|
111
|
+
SpaceDFSDK.APIConnectionError = Errors.APIConnectionError;
|
|
112
|
+
SpaceDFSDK.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
113
|
+
SpaceDFSDK.APIUserAbortError = Errors.APIUserAbortError;
|
|
114
|
+
SpaceDFSDK.NotFoundError = Errors.NotFoundError;
|
|
115
|
+
SpaceDFSDK.ConflictError = Errors.ConflictError;
|
|
116
|
+
SpaceDFSDK.RateLimitError = Errors.RateLimitError;
|
|
117
|
+
SpaceDFSDK.BadRequestError = Errors.BadRequestError;
|
|
118
|
+
SpaceDFSDK.AuthenticationError = Errors.AuthenticationError;
|
|
119
|
+
SpaceDFSDK.InternalServerError = Errors.InternalServerError;
|
|
120
|
+
SpaceDFSDK.PermissionDeniedError = Errors.PermissionDeniedError;
|
|
121
|
+
SpaceDFSDK.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
122
|
+
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;
|
|
123
|
+
exports = module.exports = SpaceDFSDK;
|
|
124
|
+
exports.default = SpaceDFSDK;
|
|
125
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -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,yBAAyB,CAAC;aAC9D;SACJ;QAED,MAAM,OAAO,GAAkB;YAC3B,YAAY;YACZ,MAAM;YACN,OAAO,EAAE,OAAO,IAAI,gCAAgC;YACpD,GAAG,IAAI;SACV,CAAC;QAEF,KAAK,CAAC;YACF,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,OAAO,EAAE,OAAO,CAAC,OAAQ;YACzB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE,GAAG,IAAI,CAAC,cAAc;YACpD,SAAS,E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AUzB,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/dist/index.mjs
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
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.users = new API.Users(this);
|
|
56
|
+
this.presignedUrl = new API.PresignedUrl(this);
|
|
57
|
+
this._options = options;
|
|
58
|
+
this.APIKey = APIKey;
|
|
59
|
+
this.organization = organization;
|
|
60
|
+
}
|
|
61
|
+
defaultQuery() {
|
|
62
|
+
return this._options.defaultQuery;
|
|
63
|
+
}
|
|
64
|
+
defaultHeaders(opts) {
|
|
65
|
+
return {
|
|
66
|
+
...super.defaultHeaders(opts),
|
|
67
|
+
...this._options.defaultHeaders,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
authHeaders(opts) {
|
|
71
|
+
const Authorization = `Bearer ${(this.allowMultiOrgs && opts.accessToken) || this.accessToken || ''}`;
|
|
72
|
+
const APIKey = (this.allowMultiOrgs && opts.APIKey) || this.APIKey;
|
|
73
|
+
return { Authorization, 'x-api-key': APIKey };
|
|
74
|
+
}
|
|
75
|
+
setAccessToken(token) {
|
|
76
|
+
this.accessToken = token;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
_a = SpaceDFSDK;
|
|
80
|
+
SpaceDFSDK.SpaceDFSDK = _a;
|
|
81
|
+
SpaceDFSDK.DEFAULT_TIMEOUT = 60 * 1000; // 1 minute
|
|
82
|
+
SpaceDFSDK.SpaceDFError = Errors.SpaceDFError;
|
|
83
|
+
SpaceDFSDK.APIError = Errors.APIError;
|
|
84
|
+
SpaceDFSDK.APIConnectionError = Errors.APIConnectionError;
|
|
85
|
+
SpaceDFSDK.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
86
|
+
SpaceDFSDK.APIUserAbortError = Errors.APIUserAbortError;
|
|
87
|
+
SpaceDFSDK.NotFoundError = Errors.NotFoundError;
|
|
88
|
+
SpaceDFSDK.ConflictError = Errors.ConflictError;
|
|
89
|
+
SpaceDFSDK.RateLimitError = Errors.RateLimitError;
|
|
90
|
+
SpaceDFSDK.BadRequestError = Errors.BadRequestError;
|
|
91
|
+
SpaceDFSDK.AuthenticationError = Errors.AuthenticationError;
|
|
92
|
+
SpaceDFSDK.InternalServerError = Errors.InternalServerError;
|
|
93
|
+
SpaceDFSDK.PermissionDeniedError = Errors.PermissionDeniedError;
|
|
94
|
+
SpaceDFSDK.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
95
|
+
export const { SpaceDFError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } = Errors;
|
|
96
|
+
export default SpaceDFSDK;
|
|
97
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -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,KAAK,CAAC;YACF,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,OAAO,EAAE,OAAO,CAAC,OAAQ;YACzB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE,G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zB,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"}
|
|
@@ -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"}
|
|
@@ -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,aAAa;IACb,IAAI,OAAO,UAAU,KAAK,WAA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|
|
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,KAAK,WAAW,EAAE;QAC7B,OAAO,IAAI,CAAC,GAAG,CAAC,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AC,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"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@space-df/sdk",
|
|
3
|
+
"version": "0.0.1-dev.10",
|
|
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
|
+
}
|
|
@@ -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/dist/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
|
|
@@ -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"}
|
|
@@ -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,60 @@
|
|
|
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
|
+
googleLogin(body: GoogleLogin, options?: Core.RequestOptions): Core.APIPromise<AuthTokenPair>;
|
|
7
|
+
oauthSendOtp(body: OAuthSendOtp, options?: Core.RequestOptions): Core.APIPromise<OAuthSendOtp>;
|
|
8
|
+
oauth2SpaceDF(body: OAuthSpaceDF, options?: Core.RequestOptions): Core.APIPromise<OAuthSpaceDF>;
|
|
9
|
+
refreshToken(body: AuthRefreshTokenParams, options?: Core.RequestOptions): Core.APIPromise<CustomTokenRefresh>;
|
|
10
|
+
register(body: AuthRegisterParams, options?: Core.RequestOptions): Core.APIPromise<Registration>;
|
|
11
|
+
switchSpaces(body: AuthRefreshTokenParams, options?: Core.RequestOptions): Core.APIPromise<CustomTokenRefresh>;
|
|
12
|
+
}
|
|
13
|
+
export interface AuthTokenPair {
|
|
14
|
+
refresh: string;
|
|
15
|
+
access: string;
|
|
16
|
+
default_space: string;
|
|
17
|
+
}
|
|
18
|
+
export interface CustomTokenRefresh {
|
|
19
|
+
refresh: string;
|
|
20
|
+
access?: string;
|
|
21
|
+
space?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface OAuthLogin {
|
|
24
|
+
authorization_code: string;
|
|
25
|
+
code_verifier: string;
|
|
26
|
+
}
|
|
27
|
+
export interface GoogleLogin {
|
|
28
|
+
authorization_code: string;
|
|
29
|
+
}
|
|
30
|
+
export interface OAuthSendOtp {
|
|
31
|
+
email: string;
|
|
32
|
+
}
|
|
33
|
+
export interface OAuthSpaceDF {
|
|
34
|
+
code_verifier: string;
|
|
35
|
+
code: string;
|
|
36
|
+
client_id: string;
|
|
37
|
+
}
|
|
38
|
+
export interface Registration {
|
|
39
|
+
id?: number;
|
|
40
|
+
first_name: string;
|
|
41
|
+
last_name: string;
|
|
42
|
+
email: string;
|
|
43
|
+
default_space?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface AuthLoginParams {
|
|
46
|
+
email: string;
|
|
47
|
+
password: string;
|
|
48
|
+
}
|
|
49
|
+
export interface AuthRefreshTokenParams {
|
|
50
|
+
refresh: string;
|
|
51
|
+
space_slug_name: string;
|
|
52
|
+
}
|
|
53
|
+
export interface AuthRegisterParams {
|
|
54
|
+
email: string;
|
|
55
|
+
password: string;
|
|
56
|
+
first_name: string;
|
|
57
|
+
last_name: string;
|
|
58
|
+
otp: string;
|
|
59
|
+
}
|
|
60
|
+
//# 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,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,IAAI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