@mondaydotcomorg/z2h-cli 0.18.0 → 0.18.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/dist/esm/util/auth/broker-credential-provider.d.ts.map +1 -1
- package/dist/esm/util/auth/broker-credential-provider.mjs +5 -2
- package/dist/esm/util/broker/app.d.ts.map +1 -1
- package/dist/esm/util/broker/app.mjs +3 -0
- package/dist/util/auth/broker-credential-provider.d.ts.map +1 -1
- package/dist/util/auth/broker-credential-provider.js +5 -2
- package/dist/util/broker/app.d.ts.map +1 -1
- package/dist/util/broker/app.js +3 -0
- package/package.json +1 -1
- package/src/util/auth/__tests__/broker-credential-provider.test.ts +20 -0
- package/src/util/auth/broker-credential-provider.ts +7 -2
- package/src/util/broker/app.ts +5 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broker-credential-provider.d.ts","sourceRoot":"","sources":["../../../../src/util/auth/broker-credential-provider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAyB,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAE3F,eAAO,MAAM,eAAe,6BAA6B,CAAC;AAC1D,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"broker-credential-provider.d.ts","sourceRoot":"","sources":["../../../../src/util/auth/broker-credential-provider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAyB,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAE3F,eAAO,MAAM,eAAe,6BAA6B,CAAC;AAC1D,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAiD3D;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAUzE;AA4DD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,EACvC,OAAO,EACP,SAAS,GACV,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,6BAA6B,CAIhC"}
|
|
@@ -26,8 +26,11 @@ async function postToBroker(path, body) {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
function assertBrokerOk(res) {
|
|
29
|
-
if (res.status === 401
|
|
30
|
-
throw new Error(`Z2H deploy token rejected by the broker (
|
|
29
|
+
if (res.status === 401) {
|
|
30
|
+
throw new Error(`Z2H deploy token rejected by the broker (401). Refresh user token by running 'z2h-cli generate-z2h-token'.`);
|
|
31
|
+
}
|
|
32
|
+
if (res.status === 403) {
|
|
33
|
+
throw new Error(`Access denied (403). You do not have editor access to this app. Ask the app owner to grant you access via 'z2h-cli grant'.`);
|
|
31
34
|
}
|
|
32
35
|
}
|
|
33
36
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../../src/util/broker/app.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../../src/util/broker/app.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAsBvE;AAwCD,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,aAAa,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAWtF"}
|
|
@@ -19,6 +19,9 @@ async function fetchApp(appName) {
|
|
|
19
19
|
if (res.status === 404) {
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
|
+
if (res.status === 403) {
|
|
23
|
+
throw new Error(`Access denied (403). You do not have access to this app. Ask the app owner to grant you access via 'z2h-cli grant'.`);
|
|
24
|
+
}
|
|
22
25
|
if (!res.ok) {
|
|
23
26
|
const text = await res.text();
|
|
24
27
|
throw new Error(`Z2H app lookup failed (${res.status}): ${text.slice(0, 512)}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broker-credential-provider.d.ts","sourceRoot":"","sources":["../../../src/util/auth/broker-credential-provider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAyB,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAE3F,eAAO,MAAM,eAAe,6BAA6B,CAAC;AAC1D,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"broker-credential-provider.d.ts","sourceRoot":"","sources":["../../../src/util/auth/broker-credential-provider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAyB,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAE3F,eAAO,MAAM,eAAe,6BAA6B,CAAC;AAC1D,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAiD3D;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAUzE;AA4DD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,EACvC,OAAO,EACP,SAAS,GACV,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,6BAA6B,CAIhC"}
|
|
@@ -28,8 +28,11 @@ async function postToBroker(path, body) {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
function assertBrokerOk(res) {
|
|
31
|
-
if (res.status === 401
|
|
32
|
-
throw new Error(`Z2H deploy token rejected by the broker (
|
|
31
|
+
if (res.status === 401) {
|
|
32
|
+
throw new Error(`Z2H deploy token rejected by the broker (401). Refresh user token by running 'z2h-cli generate-z2h-token'.`);
|
|
33
|
+
}
|
|
34
|
+
if (res.status === 403) {
|
|
35
|
+
throw new Error(`Access denied (403). You do not have editor access to this app. Ask the app owner to grant you access via 'z2h-cli grant'.`);
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
38
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/util/broker/app.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/util/broker/app.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAsBvE;AAwCD,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,aAAa,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAWtF"}
|
package/dist/util/broker/app.js
CHANGED
|
@@ -21,6 +21,9 @@ async function fetchApp(appName) {
|
|
|
21
21
|
if (res.status === 404) {
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
24
|
+
if (res.status === 403) {
|
|
25
|
+
throw new Error(`Access denied (403). You do not have access to this app. Ask the app owner to grant you access via 'z2h-cli grant'.`);
|
|
26
|
+
}
|
|
24
27
|
if (!res.ok) {
|
|
25
28
|
const text = await res.text();
|
|
26
29
|
throw new Error(`Z2H app lookup failed (${res.status}): ${text.slice(0, 512)}`);
|
package/package.json
CHANGED
|
@@ -62,6 +62,12 @@ describe('fetchDeployVersion', () => {
|
|
|
62
62
|
mockFetchOnce({}, { status: 401, text: 'Unauthorized' });
|
|
63
63
|
await expect(fetchDeployVersion('my-app')).rejects.toThrow(/token rejected by the broker/);
|
|
64
64
|
});
|
|
65
|
+
|
|
66
|
+
it('surfaces an access-denied hint on 403', async () => {
|
|
67
|
+
mockFetchOnce({}, { status: 403, text: 'Forbidden' });
|
|
68
|
+
await expect(fetchDeployVersion('my-app')).rejects.toThrow(/Access denied/);
|
|
69
|
+
await expect(fetchDeployVersion('my-app')).rejects.toThrow(/z2h-cli grant/);
|
|
70
|
+
});
|
|
65
71
|
});
|
|
66
72
|
|
|
67
73
|
describe('brokerCredentialProvider', () => {
|
|
@@ -132,6 +138,13 @@ describe('brokerCredentialProvider', () => {
|
|
|
132
138
|
await expect(provider()).rejects.toThrow(/generate-z2h-token/);
|
|
133
139
|
});
|
|
134
140
|
|
|
141
|
+
it('surfaces an access-denied hint on 403', async () => {
|
|
142
|
+
mockFetchOnce({}, { status: 403, text: 'Forbidden' });
|
|
143
|
+
const provider = brokerCredentialProvider({ appName: 'my-app' });
|
|
144
|
+
await expect(provider()).rejects.toThrow(/Access denied/);
|
|
145
|
+
await expect(provider()).rejects.toThrow(/z2h-cli grant/);
|
|
146
|
+
});
|
|
147
|
+
|
|
135
148
|
it('honors Z2H_BROKER_BASE_URL override', async () => {
|
|
136
149
|
vi.stubEnv('Z2H_BROKER_BASE_URL', 'https://staging.example.com');
|
|
137
150
|
const fetchMock = mockFetchOnce({ ...STUB_CREDS, expiration: FAR_FUTURE_EXPIRY });
|
|
@@ -191,6 +204,13 @@ describe('brokerCredentialProvider', () => {
|
|
|
191
204
|
await expect(provider()).rejects.toThrow(/generate-z2h-token/);
|
|
192
205
|
});
|
|
193
206
|
|
|
207
|
+
it('surfaces an access-denied hint on 403', async () => {
|
|
208
|
+
mockFetchOnce({}, { status: 403, text: 'Forbidden' });
|
|
209
|
+
const provider = brokerCredentialProvider({ appName: 'mf-my-app', previewId: 'preview-1' });
|
|
210
|
+
await expect(provider()).rejects.toThrow(/Access denied/);
|
|
211
|
+
await expect(provider()).rejects.toThrow(/z2h-cli grant/);
|
|
212
|
+
});
|
|
213
|
+
|
|
194
214
|
it('rejects responses missing required credential fields', async () => {
|
|
195
215
|
mockFetchOnce({ accessKeyId: 'AKIA-stub' });
|
|
196
216
|
const provider = brokerCredentialProvider({ appName: 'mf-my-app', previewId: 'preview-1' });
|
|
@@ -40,9 +40,14 @@ async function postToBroker(path: string, body: unknown): Promise<Response> {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
function assertBrokerOk(res: Response): void {
|
|
43
|
-
if (res.status === 401
|
|
43
|
+
if (res.status === 401) {
|
|
44
44
|
throw new Error(
|
|
45
|
-
`Z2H deploy token rejected by the broker (
|
|
45
|
+
`Z2H deploy token rejected by the broker (401). Refresh user token by running 'z2h-cli generate-z2h-token'.`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
if (res.status === 403) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
`Access denied (403). You do not have editor access to this app. Ask the app owner to grant you access via 'z2h-cli grant'.`
|
|
46
51
|
);
|
|
47
52
|
}
|
|
48
53
|
}
|
package/src/util/broker/app.ts
CHANGED
|
@@ -29,6 +29,11 @@ export async function fetchApp(appName: string): Promise<AppInfo | null> {
|
|
|
29
29
|
if (res.status === 404) {
|
|
30
30
|
return null;
|
|
31
31
|
}
|
|
32
|
+
if (res.status === 403) {
|
|
33
|
+
throw new Error(
|
|
34
|
+
`Access denied (403). You do not have access to this app. Ask the app owner to grant you access via 'z2h-cli grant'.`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
32
37
|
if (!res.ok) {
|
|
33
38
|
const text = await res.text();
|
|
34
39
|
throw new Error(`Z2H app lookup failed (${res.status}): ${text.slice(0, 512)}`);
|