@mcpher/gas-fakes 2.2.6 → 2.2.7
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/README.md
CHANGED
|
@@ -196,7 +196,7 @@ As I mentioned earlier, to take this further, I'm going to need a lot of help to
|
|
|
196
196
|
- [how libhandler works](libhandler.md)
|
|
197
197
|
- [article:using apps script libraries with gas-fakes](https://ramblings.mcpher.com/how-to-use-apps-script-libraries-directly-from-node/)
|
|
198
198
|
- [named range identity](named-range-identity.md)
|
|
199
|
-
- [
|
|
199
|
+
- [sensitive scopes with local authentication](senstive_scopes.md)
|
|
200
200
|
- [push test pull](pull-test-push.md)
|
|
201
201
|
- [sharing cache and properties between gas-fakes and live apps script](https://ramblings.mcpher.com/sharing-cache-and-properties-between-gas-fakes-and-live-apps-script/)
|
|
202
202
|
- [gas-fakes-cli now has built in mcp server and gemini extension](https://ramblings.mcpher.com/gas-fakes-cli-now-has-built-in-mcp-server-and-gemini-extension/)
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"node": ">=20.11.0"
|
|
4
4
|
},
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@azure/identity": "^4.13.
|
|
6
|
+
"@azure/identity": "^4.13.1",
|
|
7
7
|
"@mcpher/fake-gasenum": "^1.0.6",
|
|
8
8
|
"@mcpher/gas-flex-cache": "^1.1.5",
|
|
9
9
|
"@microsoft/microsoft-graph-client": "^3.0.7",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"archiver": "^7.0.1",
|
|
14
14
|
"commander": "^14.0.3",
|
|
15
15
|
"dotenv": "^17.3.1",
|
|
16
|
-
"fast-xml-parser": "^5.
|
|
16
|
+
"fast-xml-parser": "^5.5.8",
|
|
17
17
|
"get-stream": "^9.0.1",
|
|
18
18
|
"google-auth-library": "^10.6.2",
|
|
19
19
|
"googleapis": "^171.4.0",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"name": "@mcpher/gas-fakes",
|
|
41
41
|
"author": "bruce mcpherson",
|
|
42
|
-
"version": "2.2.
|
|
42
|
+
"version": "2.2.7",
|
|
43
43
|
"license": "MIT",
|
|
44
44
|
"main": "main.js",
|
|
45
45
|
"description": "An implementation of the Google Workspace Apps Script runtime: Run native App Script Code on Node and Cloud Run",
|
package/src/cli/setup.js
CHANGED
|
@@ -283,6 +283,7 @@ export async function initializeConfiguration(options = {}) {
|
|
|
283
283
|
"https://www.googleapis.com/auth/userinfo.email",
|
|
284
284
|
"openid",
|
|
285
285
|
"https://www.googleapis.com/auth/cloud-platform",
|
|
286
|
+
"https://www.googleapis.com/auth/drive.readonly",
|
|
286
287
|
];
|
|
287
288
|
responses.DEFAULT_SCOPES = DEFAULT_SCOPES_VALUES.join(",");
|
|
288
289
|
responses.EXTRA_SCOPES = manifestScopes
|
|
@@ -303,12 +304,12 @@ export async function initializeConfiguration(options = {}) {
|
|
|
303
304
|
initial: existingConfig.GOOGLE_SERVICE_ACCOUNT_NAME || "gas-fakes-sa",
|
|
304
305
|
},
|
|
305
306
|
{
|
|
306
|
-
type: "text",
|
|
307
|
+
type: responses.AUTH_TYPE === "adc" ? "text" : null,
|
|
307
308
|
name: "CLIENT_CREDENTIAL_FILE",
|
|
308
309
|
message: "Enter path to OAuth client credentials JSON (optional, required for restricted scopes with ADC)",
|
|
309
310
|
initial: existingConfig.CLIENT_CREDENTIAL_FILE || "",
|
|
310
311
|
}
|
|
311
|
-
|
|
312
|
+
];
|
|
312
313
|
|
|
313
314
|
const googleResponses = await prompts(googleQuestions);
|
|
314
315
|
if (typeof googleResponses.GOOGLE_CLOUD_PROJECT === "undefined") {
|
|
@@ -342,10 +343,10 @@ export async function initializeConfiguration(options = {}) {
|
|
|
342
343
|
message: "What type of Microsoft account are you using?",
|
|
343
344
|
choices: [
|
|
344
345
|
{ title: "Consumer (Personal, Outlook.com, Hotmail, etc.)", value: "consumers" },
|
|
345
|
-
{ title: "Business/Education (Work or School)", value: "organizations" },
|
|
346
|
+
{ title: "Business/Education (Work or School) ", value: "organizations" },
|
|
346
347
|
{ title: "Standard Multi-tenant", value: "common" }
|
|
347
348
|
],
|
|
348
|
-
initial: existingConfig.MS_GRAPH_TENANT_ID === "
|
|
349
|
+
initial: existingConfig.MS_GRAPH_TENANT_ID === "organizations" ? 1 : (existingConfig.MS_GRAPH_TENANT_ID === "common" ? 2 : 0)
|
|
349
350
|
});
|
|
350
351
|
|
|
351
352
|
if (typeof msAccountType.type === "undefined") {
|
|
@@ -604,13 +605,13 @@ export async function authenticateUser(options = {}) {
|
|
|
604
605
|
const msScopes = mapGasScopesToMsGraph(gasScopes);
|
|
605
606
|
|
|
606
607
|
try {
|
|
608
|
+
const tenantId = process.env.MS_GRAPH_TENANT_ID || 'consumers';
|
|
607
609
|
const azCmd = `az config set core.login_experience_v2=off && az login --allow-no-subscriptions --output none`;
|
|
608
610
|
|
|
609
611
|
console.log(`Executing: ${azCmd}`);
|
|
610
612
|
try {
|
|
611
613
|
runCommandSync(azCmd);
|
|
612
614
|
console.log(`\n\x1b[1;32mSuccess!\x1b[0m Azure CLI session discovered.`);
|
|
613
|
-
const tenantId = process.env.MS_GRAPH_TENANT_ID || 'consumers';
|
|
614
615
|
console.log(`Silent fallback is now enabled for: \x1b[1;36m${tenantId}\x1b[0m`);
|
|
615
616
|
} catch (e) {
|
|
616
617
|
console.error(`\x1b[1;31mAzure CLI Login failed.\x1b[0m`);
|
|
@@ -662,7 +663,11 @@ export async function authenticateUser(options = {}) {
|
|
|
662
663
|
...(EXTRA_SCOPES || "").split(","),
|
|
663
664
|
])).filter(s => s).join(",");
|
|
664
665
|
|
|
665
|
-
|
|
666
|
+
const adcScopes = AUTH_TYPE === "dwd"
|
|
667
|
+
? Array.from(new Set((DEFAULT_SCOPES || "").split(","))).filter(s => s).join(",")
|
|
668
|
+
: scopes;
|
|
669
|
+
|
|
670
|
+
console.log(`...requesting scopes: ${adcScopes}`);
|
|
666
671
|
|
|
667
672
|
const driveAccessFlag = "--enable-gdrive-access";
|
|
668
673
|
const activeConfig = AC || "default";
|
|
@@ -684,7 +689,7 @@ export async function authenticateUser(options = {}) {
|
|
|
684
689
|
runCommandSync(`gcloud auth login ${driveAccessFlag}`);
|
|
685
690
|
|
|
686
691
|
let clientFlag = "";
|
|
687
|
-
if (CLIENT_CREDENTIAL_FILE) {
|
|
692
|
+
if (AUTH_TYPE !== "dwd" && CLIENT_CREDENTIAL_FILE) {
|
|
688
693
|
const clientPath = path.resolve(process.cwd(), CLIENT_CREDENTIAL_FILE);
|
|
689
694
|
if (fs.existsSync(clientPath)) {
|
|
690
695
|
console.log(`...using client credentials from ${clientPath}`);
|
|
@@ -693,7 +698,8 @@ export async function authenticateUser(options = {}) {
|
|
|
693
698
|
}
|
|
694
699
|
|
|
695
700
|
console.log("Setting up Application Default Credentials (ADC)...");
|
|
696
|
-
|
|
701
|
+
const adcScopeFlag = `--scopes="${adcScopes}"`;
|
|
702
|
+
runCommandSync(`gcloud auth application-default login ${adcScopeFlag} ${clientFlag}`.trim());
|
|
697
703
|
runCommandSync(`gcloud auth application-default set-quota-project ${projectId}`);
|
|
698
704
|
|
|
699
705
|
// --- DWD Specific Setup (if configured) ---
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Proxies } from "../../support/proxies.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* create a new FakeContainerInfo instance
|
|
5
|
+
* @param {...any} args
|
|
6
|
+
* @returns {FakeContainerInfo}
|
|
7
|
+
*/
|
|
8
|
+
export const newFakeContainerInfo = (...args) => {
|
|
9
|
+
return Proxies.guard(new FakeContainerInfo(...args));
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Access to the chart's container position.
|
|
14
|
+
*/
|
|
15
|
+
export class FakeContainerInfo {
|
|
16
|
+
/**
|
|
17
|
+
* @param {object} overlayPosition The overlayPosition object from Sheets API
|
|
18
|
+
*/
|
|
19
|
+
constructor(overlayPosition) {
|
|
20
|
+
this.__overlayPosition = overlayPosition || {};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Returns the column index where the drawing is anchored.
|
|
25
|
+
* @returns {number}
|
|
26
|
+
*/
|
|
27
|
+
getAnchorColumn() {
|
|
28
|
+
return (this.__overlayPosition.anchorCell?.columnIndex || 0) + 1;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Returns the row index where the drawing is anchored.
|
|
33
|
+
* @returns {number}
|
|
34
|
+
*/
|
|
35
|
+
getAnchorRow() {
|
|
36
|
+
return (this.__overlayPosition.anchorCell?.rowIndex || 0) + 1;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Returns the horizontal offset in pixels from the anchor column.
|
|
41
|
+
* @returns {number}
|
|
42
|
+
*/
|
|
43
|
+
getOffsetX() {
|
|
44
|
+
return this.__overlayPosition.offsetXPixels || 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Returns the vertical offset in pixels from the anchor row.
|
|
49
|
+
* @returns {number}
|
|
50
|
+
*/
|
|
51
|
+
getOffsetY() {
|
|
52
|
+
return this.__overlayPosition.offsetYPixels || 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
toString() {
|
|
56
|
+
return "ContainerInfo";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -2,6 +2,7 @@ import { Proxies } from "../../support/proxies.js";
|
|
|
2
2
|
import { notYetImplemented, signatureArgs } from "../../support/helpers.js";
|
|
3
3
|
import { batchUpdate } from "./sheetrangehelpers.js";
|
|
4
4
|
import { newFakeEmbeddedChartBuilder } from "./fakeembeddedchartbuilder.js";
|
|
5
|
+
import { newFakeContainerInfo } from "./fakecontainerinfo.js";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @returns {FakeEmbeddedChart}
|
|
@@ -25,13 +26,20 @@ export class FakeEmbeddedChart {
|
|
|
25
26
|
const props = [
|
|
26
27
|
"getAs",
|
|
27
28
|
"getBlob",
|
|
28
|
-
"getContainerInfo",
|
|
29
29
|
];
|
|
30
30
|
props.forEach((f) => {
|
|
31
31
|
this[f] = () => notYetImplemented(f);
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Returns information about where the chart is positioned within a sheet.
|
|
37
|
+
* @returns {FakeContainerInfo}
|
|
38
|
+
*/
|
|
39
|
+
getContainerInfo() {
|
|
40
|
+
return newFakeContainerInfo(this.__apiChart.position?.overlayPosition);
|
|
41
|
+
}
|
|
42
|
+
|
|
35
43
|
/**
|
|
36
44
|
* Returns the ID of this chart.
|
|
37
45
|
* @returns {number}
|
|
@@ -166,7 +166,7 @@ async function isGcpEnv() {
|
|
|
166
166
|
* Gets a Microsoft Graph token.
|
|
167
167
|
*/
|
|
168
168
|
export async function getMsGraphToken(scopes = ['User.Read']) {
|
|
169
|
-
const envTenant = process.env.MS_GRAPH_TENANT_ID || '
|
|
169
|
+
const envTenant = process.env.MS_GRAPH_TENANT_ID || 'consumers';
|
|
170
170
|
const clientId = process.env.MS_GRAPH_CLIENT_ID;
|
|
171
171
|
const clientSecret = process.env.MS_GRAPH_CLIENT_SECRET;
|
|
172
172
|
const msAuthType = process.env.MS_AUTH_TYPE;
|