@mcpher/gas-fakes 2.0.0 → 2.0.2

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/package.json CHANGED
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "name": "@mcpher/gas-fakes",
35
35
  "author": "bruce mcpherson",
36
- "version": "2.0.0",
36
+ "version": "2.0.2",
37
37
  "license": "MIT",
38
38
  "main": "main.js",
39
39
  "description": "An implementation of the Google Workspace Apps Script runtime: Run native App Script Code on Node and Cloud Run",
@@ -133,7 +133,8 @@ if (typeof globalThis[name] === typeof undefined) {
133
133
  FULL: 'FULL'
134
134
  },
135
135
  __behavior: newFakeBehavior(),
136
- __newCacheDropin: newCacheDropin
136
+ __newCacheDropin: newCacheDropin,
137
+ __proxies: Proxies
137
138
  }
138
139
 
139
140
 
@@ -132,7 +132,9 @@ const setAuth = async (scopes = [], mcpLoading = false) => {
132
132
  mayLog(`...attempting to use service account: ${targetPrincipal}`)
133
133
 
134
134
  /// _sourceClient is the identity of the person/thing running the code
135
- _sourceClient = await _auth.getClient()
135
+ // we'll try to get the openid and email scopes for the source client too if they are in the manifest
136
+ const sourceScopes = scopes.filter(s => s === 'openid' || s === 'https://www.googleapis.com/auth/userinfo.email')
137
+ _sourceClient = await _auth.getClient(sourceScopes.length > 0 ? { scopes: sourceScopes } : {})
136
138
 
137
139
  // now to get who the real user is
138
140
  const { tokenInfo: userInfo } = await getSourceAccessTokenInfo()
@@ -99,12 +99,12 @@ export const sxInit = async ({ manifestPath, claspPath, settingsPath, cachePath,
99
99
  /// these all jst exist in this sub process so we need to send them back to parent process
100
100
  /// we'll send back the token, but it should be refreshed dynamically to handle expiry
101
101
  const activeUser = {
102
- id: activeInfo.tokenInfo.sub,
102
+ id: activeInfo.tokenInfo.sub || activeInfo.tokenInfo.email || activeInfo.tokenInfo.user_id || 'unknown-active-user',
103
103
  email: activeInfo.tokenInfo.email,
104
104
  token: activeInfo.token
105
105
  }
106
106
  const effectiveUser = {
107
- id: effectiveInfo.tokenInfo.sub,
107
+ id: effectiveInfo.tokenInfo.sub || effectiveInfo.tokenInfo.email || effectiveInfo.tokenInfo.user_id || 'unknown-effective-user',
108
108
  email: effectiveInfo.tokenInfo.email,
109
109
  token: effectiveInfo.token
110
110
  }
package/testlib.sh CHANGED
@@ -1,2 +1,2 @@
1
- node ./gas-fakes.js -l bmFiddler@13EWG4-lPrEf34itxQhAQ7b9JEbmCBfO8uE4Mhr99CHi3Pw65oxXtq-rU \
1
+ gas-fakes -l bmFiddler@13EWG4-lPrEf34itxQhAQ7b9JEbmCBfO8uE4Mhr99CHi3Pw65oxXtq-rU \
2
2
  -s "const sheet=SpreadsheetApp.openById('1h9IGIShgVBVUrUjjawk5MaCEQte_7t32XeEP1Z5jXKQ').getSheets()[0];const fiddler = new bmFiddler.Fiddler(sheet);console.log (fiddler.getData().slice(0, 5));"