@shipeasy/devtools-core 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/LICENSE +40 -0
  2. package/README.md +19 -0
  3. package/dist/api.d.mts +143 -0
  4. package/dist/api.d.ts +143 -0
  5. package/dist/api.js +10 -0
  6. package/dist/api.mjs +10 -0
  7. package/dist/auth.d.mts +57 -0
  8. package/dist/auth.d.ts +57 -0
  9. package/dist/auth.js +12 -0
  10. package/dist/auth.mjs +12 -0
  11. package/dist/chunk-2B75JLTX.js +25 -0
  12. package/dist/chunk-5VQLXGNR.mjs +101 -0
  13. package/dist/chunk-6SU5REDK.mjs +2848 -0
  14. package/dist/chunk-7NO55TFC.mjs +25 -0
  15. package/dist/chunk-GUTBZI2O.js +2848 -0
  16. package/dist/chunk-I2KLQ2HA.js +22 -0
  17. package/dist/chunk-KPO3R7ND.js +28 -0
  18. package/dist/chunk-LCRTLHGL.js +101 -0
  19. package/dist/chunk-LZDNBMH6.mjs +1394 -0
  20. package/dist/chunk-MK56AKZR.js +178 -0
  21. package/dist/chunk-RANNOC72.js +72 -0
  22. package/dist/chunk-RH6X24HG.mjs +28 -0
  23. package/dist/chunk-U5DDQYSF.mjs +22 -0
  24. package/dist/chunk-VHYOR3XA.mjs +178 -0
  25. package/dist/chunk-WP2TWHG3.mjs +72 -0
  26. package/dist/chunk-YQHCUZGP.js +1394 -0
  27. package/dist/feedback-state.d.mts +29 -0
  28. package/dist/feedback-state.d.ts +29 -0
  29. package/dist/feedback-state.js +9 -0
  30. package/dist/feedback-state.mjs +9 -0
  31. package/dist/forms.d.mts +95 -0
  32. package/dist/forms.d.ts +95 -0
  33. package/dist/forms.js +21 -0
  34. package/dist/forms.mjs +21 -0
  35. package/dist/gate-flow.d.mts +41 -0
  36. package/dist/gate-flow.d.ts +41 -0
  37. package/dist/gate-flow.js +17 -0
  38. package/dist/gate-flow.mjs +17 -0
  39. package/dist/index.d.mts +10 -0
  40. package/dist/index.d.ts +10 -0
  41. package/dist/index.js +86 -0
  42. package/dist/index.mjs +86 -0
  43. package/dist/public-report.d.mts +56 -0
  44. package/dist/public-report.d.ts +56 -0
  45. package/dist/public-report.js +12 -0
  46. package/dist/public-report.mjs +12 -0
  47. package/dist/self-report.d.mts +25 -0
  48. package/dist/self-report.d.ts +25 -0
  49. package/dist/self-report.js +73 -0
  50. package/dist/self-report.mjs +73 -0
  51. package/dist/types-D0sroUDD.d.mts +278 -0
  52. package/dist/types-D0sroUDD.d.ts +278 -0
  53. package/dist/zod.gen-DTKpgw-T.d.mts +64 -0
  54. package/dist/zod.gen-DTKpgw-T.d.ts +64 -0
  55. package/package.json +58 -0
@@ -0,0 +1,22 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+
19
+
20
+
21
+
22
+ exports.__export = __export; exports.__reExport = __reExport;
@@ -0,0 +1,28 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }
2
+
3
+
4
+ var _chunkI2KLQ2HAjs = require('./chunk-I2KLQ2HA.js');
5
+
6
+ // src/types.ts
7
+ var types_exports = {};
8
+ _chunkI2KLQ2HAjs.__export.call(void 0, types_exports, {
9
+ DEFAULT_ADMIN_BASE_URL: () => DEFAULT_ADMIN_BASE_URL,
10
+ DEFAULT_EDGE_BASE_URL: () => DEFAULT_EDGE_BASE_URL,
11
+ PERMISSIVE_CONFIG_SCHEMA: () => PERMISSIVE_CONFIG_SCHEMA
12
+ });
13
+ _chunkI2KLQ2HAjs.__reExport.call(void 0, types_exports, devtools_contract_star);
14
+ var _devtoolscontract = require('@shipeasy/sdk/devtools-contract'); var devtools_contract_star = _interopRequireWildcard(_devtoolscontract);
15
+ var DEFAULT_ADMIN_BASE_URL = "https://shipeasy.ai";
16
+ var DEFAULT_EDGE_BASE_URL = "https://api.shipeasy.ai";
17
+ var PERMISSIVE_CONFIG_SCHEMA = {
18
+ type: "object",
19
+ properties: {},
20
+ additionalProperties: true
21
+ };
22
+
23
+
24
+
25
+
26
+
27
+
28
+ exports.DEFAULT_ADMIN_BASE_URL = DEFAULT_ADMIN_BASE_URL; exports.DEFAULT_EDGE_BASE_URL = DEFAULT_EDGE_BASE_URL; exports.PERMISSIVE_CONFIG_SCHEMA = PERMISSIVE_CONFIG_SCHEMA; exports.types_exports = types_exports;
@@ -0,0 +1,101 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+
5
+ var _chunkKPO3R7NDjs = require('./chunk-KPO3R7ND.js');
6
+
7
+ // src/auth.ts
8
+ var LoginCancelled = class extends Error {
9
+ constructor() {
10
+ super("Login cancelled");
11
+ this.name = "LoginCancelled";
12
+ }
13
+ };
14
+ function defaultRandomUUID() {
15
+ const c = globalThis.crypto;
16
+ if (_optionalChain([c, 'optionalAccess', _ => _.randomUUID])) return c.randomUUID();
17
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (ch) => {
18
+ const r = Math.random() * 16 | 0;
19
+ return (ch === "x" ? r : r & 3 | 8).toString(16);
20
+ });
21
+ }
22
+ async function defaultSha256Base64Url(input) {
23
+ const subtle = _optionalChain([globalThis, 'access', _2 => _2.crypto, 'optionalAccess', _3 => _3.subtle]);
24
+ if (!subtle) {
25
+ throw new Error(
26
+ "No crypto.subtle available \u2014 pass adapters.sha256Base64Url (e.g. expo-crypto's digestStringAsync)."
27
+ );
28
+ }
29
+ const hash = await subtle.digest("SHA-256", new TextEncoder().encode(input));
30
+ const bytes = new Uint8Array(hash);
31
+ let binary = "";
32
+ for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
33
+ return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
34
+ }
35
+ function makeVerifier(randomUUID) {
36
+ return (randomUUID() + randomUUID()).replace(/-/g, "");
37
+ }
38
+ function parseDeepLinkQuery(url) {
39
+ const q = url.indexOf("?");
40
+ if (q < 0) return {};
41
+ const out = {};
42
+ const query = url.slice(q + 1).split("#")[0];
43
+ for (const pair of query.split("&")) {
44
+ if (!pair) continue;
45
+ const eq = pair.indexOf("=");
46
+ const k = eq < 0 ? pair : pair.slice(0, eq);
47
+ const v = eq < 0 ? "" : pair.slice(eq + 1);
48
+ try {
49
+ out[decodeURIComponent(k)] = decodeURIComponent(v.replace(/\+/g, " "));
50
+ } catch (e) {
51
+ out[k] = v;
52
+ }
53
+ }
54
+ return out;
55
+ }
56
+ async function startDeviceAuth(opts, adapters) {
57
+ const edge = (_nullishCoalesce(opts.edgeBaseUrl, () => ( _chunkKPO3R7NDjs.DEFAULT_EDGE_BASE_URL))).replace(/\/$/, "");
58
+ const admin = (_nullishCoalesce(opts.adminBaseUrl, () => ( _chunkKPO3R7NDjs.DEFAULT_ADMIN_BASE_URL))).replace(/\/$/, "");
59
+ const fetchImpl = _nullishCoalesce(adapters.fetch, () => ( ((...args) => fetch(...args))));
60
+ const randomUUID = _nullishCoalesce(adapters.randomUUID, () => ( defaultRandomUUID));
61
+ const digest = _nullishCoalesce(adapters.sha256Base64Url, () => ( defaultSha256Base64Url));
62
+ const verifier = makeVerifier(randomUUID);
63
+ const challenge = await digest(verifier);
64
+ const startRes = await fetchImpl(`${edge}/auth/device/start`, {
65
+ method: "POST",
66
+ headers: { "Content-Type": "application/json" },
67
+ body: JSON.stringify({ code_challenge: challenge })
68
+ });
69
+ if (!startRes.ok) {
70
+ throw new Error(`Login could not start (HTTP ${startRes.status}). Please try again.`);
71
+ }
72
+ const { state } = await startRes.json();
73
+ if (!state) throw new Error("Login could not start (no state). Please try again.");
74
+ const authUrl = `${admin}/cli-auth?state=${encodeURIComponent(state)}&code_challenge=${encodeURIComponent(challenge)}&redirect_uri=${encodeURIComponent(opts.redirectUri)}` + (opts.projectId ? `&project_id=${encodeURIComponent(opts.projectId)}` : "") + (!opts.projectId && opts.clientKey ? `&client_key=${encodeURIComponent(opts.clientKey)}` : "");
75
+ const result = await adapters.openAuthSession(authUrl, opts.redirectUri);
76
+ if (result.type !== "success" || !result.url) throw new LoginCancelled();
77
+ const params = parseDeepLinkQuery(result.url);
78
+ if (!params.state || params.state !== state) throw new Error("Auth state mismatch");
79
+ const tokenRes = await fetchImpl(`${edge}/auth/device/token`, {
80
+ method: "POST",
81
+ headers: { "Content-Type": "application/json" },
82
+ body: JSON.stringify({ state, code_verifier: verifier })
83
+ });
84
+ if (!tokenRes.ok) {
85
+ throw new Error(`Login did not complete (HTTP ${tokenRes.status}). Please try again.`);
86
+ }
87
+ const data = await tokenRes.json();
88
+ if (!data.token || !data.project_id) throw new Error("Login did not return a token");
89
+ return {
90
+ token: data.token,
91
+ projectId: data.project_id,
92
+ userEmail: _nullishCoalesce(data.user_email, () => ( null)),
93
+ projectName: _nullishCoalesce(data.project_name, () => ( null))
94
+ };
95
+ }
96
+
97
+
98
+
99
+
100
+
101
+ exports.LoginCancelled = LoginCancelled; exports.parseDeepLinkQuery = parseDeepLinkQuery; exports.startDeviceAuth = startDeviceAuth;