@earthlink/dotvault 0.14.1 → 0.14.3
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/dist/index.js +22 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -61,14 +61,18 @@ var InvalidCredentialsError = class extends EnvSyncError {
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
var PermissionDeniedError = class extends EnvSyncError {
|
|
64
|
-
constructor(project, env) {
|
|
65
|
-
|
|
64
|
+
constructor(project, env, serverMessage) {
|
|
65
|
+
const scope = project !== void 0 && env !== void 0 ? ` for project '${project}' env '${env}'` : "";
|
|
66
|
+
const detail = serverMessage !== void 0 && serverMessage.length > 0 ? ` (server: ${serverMessage})` : "";
|
|
67
|
+
super("PERMISSION_DENIED", `You do not have permission${scope}${detail}. Ask an org admin to grant access at https://app.dotvault.io.`, 4);
|
|
66
68
|
this.name = "PermissionDeniedError";
|
|
67
69
|
}
|
|
68
70
|
};
|
|
69
71
|
var ProjectNotFoundError = class extends EnvSyncError {
|
|
70
|
-
constructor(project, env) {
|
|
71
|
-
|
|
72
|
+
constructor(project, env, serverMessage) {
|
|
73
|
+
const scope = project !== void 0 && env !== void 0 ? ` for project '${project}' env '${env}'` : "";
|
|
74
|
+
const detail = serverMessage !== void 0 && serverMessage.length > 0 ? ` (server: ${serverMessage})` : "";
|
|
75
|
+
super("PROJECT_NOT_FOUND", `No secrets found${scope}${detail}. Check the names \u2014 they are case-sensitive \u2014 and that the project exists in the admin console.`, 5);
|
|
72
76
|
this.name = "ProjectNotFoundError";
|
|
73
77
|
}
|
|
74
78
|
};
|
|
@@ -607,16 +611,10 @@ async function handleResponse(res, ctx) {
|
|
|
607
611
|
throw new AuthRequiredError(message);
|
|
608
612
|
}
|
|
609
613
|
if (res.status === 403) {
|
|
610
|
-
throw new PermissionDeniedError(
|
|
611
|
-
ctx?.project ?? "(unknown project)",
|
|
612
|
-
ctx?.env ?? "(unknown env)"
|
|
613
|
-
);
|
|
614
|
+
throw new PermissionDeniedError(ctx?.project, ctx?.env, parsed?.message);
|
|
614
615
|
}
|
|
615
616
|
if (res.status === 404) {
|
|
616
|
-
throw new ProjectNotFoundError(
|
|
617
|
-
ctx?.project ?? "(unknown project)",
|
|
618
|
-
ctx?.env ?? "(unknown env)"
|
|
619
|
-
);
|
|
617
|
+
throw new ProjectNotFoundError(ctx?.project, ctx?.env, parsed?.message);
|
|
620
618
|
}
|
|
621
619
|
throw new EnvSyncError(code, message, 99);
|
|
622
620
|
}
|
|
@@ -757,22 +755,24 @@ async function globalDropCommand(opts) {
|
|
|
757
755
|
);
|
|
758
756
|
}
|
|
759
757
|
async function resolve2(opts) {
|
|
758
|
+
if (opts.project !== void 0) {
|
|
759
|
+
const http2 = opts.http ?? createHttpClient(await resolveApiUrl(opts.cwd));
|
|
760
|
+
const authedFetch2 = await buildAuthedFetch(http2);
|
|
761
|
+
return { http: http2, project: opts.project, authedFetch: authedFetch2 };
|
|
762
|
+
}
|
|
760
763
|
const cfg = await loadProjectConfig(opts.cwd);
|
|
761
|
-
const project = opts.project ?? cfg.name;
|
|
762
764
|
const http = opts.http ?? createHttpClient(cfg.proxy.apiUrl);
|
|
763
765
|
const authedFetch = await buildAuthedFetch(http);
|
|
764
|
-
return { http, project, authedFetch };
|
|
766
|
+
return { http, project: cfg.name, authedFetch };
|
|
765
767
|
}
|
|
766
768
|
async function resolvePool(opts) {
|
|
767
|
-
const
|
|
768
|
-
const http = opts.http ?? createHttpClient(cfg.proxy.apiUrl);
|
|
769
|
+
const http = opts.http ?? createHttpClient(await resolveApiUrl(opts.cwd));
|
|
769
770
|
const authedFetch = await buildAuthedFetch(http);
|
|
770
771
|
return { http, orgId: opts.orgId, authedFetch };
|
|
771
772
|
}
|
|
772
773
|
async function resolvePoolWithEnv(opts) {
|
|
773
|
-
const cfg = await loadProjectConfig(opts.cwd);
|
|
774
774
|
const env = opts.env ?? GLOBAL_ALL_ENV;
|
|
775
|
-
const http = opts.http ?? createHttpClient(
|
|
775
|
+
const http = opts.http ?? createHttpClient(await resolveApiUrl(opts.cwd));
|
|
776
776
|
const authedFetch = await buildAuthedFetch(http);
|
|
777
777
|
return { http, orgId: opts.orgId, env, authedFetch };
|
|
778
778
|
}
|
|
@@ -1630,8 +1630,7 @@ async function fileExists(path) {
|
|
|
1630
1630
|
|
|
1631
1631
|
// src/commands/project.ts
|
|
1632
1632
|
async function projectCreateCommand(opts) {
|
|
1633
|
-
const
|
|
1634
|
-
const http = createHttpClient(cfg.proxy.apiUrl);
|
|
1633
|
+
const http = createHttpClient(await resolveApiUrl(opts.cwd));
|
|
1635
1634
|
const body = {
|
|
1636
1635
|
name: opts.name,
|
|
1637
1636
|
...opts.orgId !== void 0 ? { owning_org_id: opts.orgId } : {}
|
|
@@ -1665,14 +1664,12 @@ async function buildAuthedFetch4(http) {
|
|
|
1665
1664
|
|
|
1666
1665
|
// src/commands/token.ts
|
|
1667
1666
|
async function tokenListCommand(opts) {
|
|
1668
|
-
const
|
|
1669
|
-
const http = createHttpClient(cfg.proxy.apiUrl);
|
|
1667
|
+
const http = createHttpClient(await resolveApiUrl(opts.cwd));
|
|
1670
1668
|
const authedFetch = await buildAuthedFetch5(http);
|
|
1671
1669
|
return authedFetch((bearer) => http.adminTokensList(bearer, { orgId: opts.orgId }));
|
|
1672
1670
|
}
|
|
1673
1671
|
async function tokenCreateCommand(opts) {
|
|
1674
|
-
const
|
|
1675
|
-
const http = createHttpClient(cfg.proxy.apiUrl);
|
|
1672
|
+
const http = createHttpClient(await resolveApiUrl(opts.cwd));
|
|
1676
1673
|
const authedFetch = await buildAuthedFetch5(http);
|
|
1677
1674
|
const body = {
|
|
1678
1675
|
name: opts.name,
|
|
@@ -1683,8 +1680,7 @@ async function tokenCreateCommand(opts) {
|
|
|
1683
1680
|
return authedFetch((bearer) => http.adminTokensCreate(bearer, { orgId: opts.orgId }, body));
|
|
1684
1681
|
}
|
|
1685
1682
|
async function tokenRevokeCommand(opts) {
|
|
1686
|
-
const
|
|
1687
|
-
const http = createHttpClient(cfg.proxy.apiUrl);
|
|
1683
|
+
const http = createHttpClient(await resolveApiUrl(opts.cwd));
|
|
1688
1684
|
const authedFetch = await buildAuthedFetch5(http);
|
|
1689
1685
|
await authedFetch(
|
|
1690
1686
|
(bearer) => http.adminTokensRevoke(bearer, { orgId: opts.orgId, tokenId: opts.tokenId })
|