@taskcluster/client-web 105.0.0 → 106.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taskcluster/client-web",
3
- "version": "105.0.0",
3
+ "version": "106.0.0",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "exports": "./src/index.js",
package/src/Client.js CHANGED
@@ -32,6 +32,10 @@ export default class Client {
32
32
  throw new Error('options.randomizationFactor must be between 0 and 1');
33
33
  }
34
34
 
35
+ if (this.options.authorizedScopes != null && !Array.isArray(this.options.authorizedScopes)) {
36
+ throw new Error('options.authorizedScopes must be an array of scopes');
37
+ }
38
+
35
39
  if (this.options.accessToken) {
36
40
  throw new Error('options.accessToken is no longer supported; use options.credentials');
37
41
  }
@@ -105,7 +109,7 @@ export default class Client {
105
109
 
106
110
  // If set of authorized scopes is provided, we'll restrict the request
107
111
  // to only use these scopes
108
- if (Array.isArray(authorizedScopes)) {
112
+ if (authorizedScopes) {
109
113
  extra.authorizedScopes = authorizedScopes;
110
114
  }
111
115
 
@@ -41,6 +41,7 @@ export default class Auth extends Client {
41
41
  this.sentryDSN.entry = {"args":["project"],"category":"Sentry Credentials","method":"get","name":"sentryDSN","output":true,"query":[],"route":"/sentry/<project>/dsn","scopes":"auth:sentry:<project>","stability":"stable","type":"function"};
42
42
  this.websocktunnelToken.entry = {"args":["wstAudience","wstClient"],"category":"Websocktunnel Credentials","method":"get","name":"websocktunnelToken","output":true,"query":[],"route":"/websocktunnel/<wstAudience>/<wstClient>","scopes":"auth:websocktunnel-token:<wstAudience>/<wstClient>","stability":"stable","type":"function"};
43
43
  this.gcpCredentials.entry = {"args":["projectId","serviceAccount"],"category":"GCP Credentials","method":"get","name":"gcpCredentials","output":true,"query":[],"route":"/gcp/credentials/<projectId>/<serviceAccount>","scopes":"auth:gcp:access-token:<projectId>/<serviceAccount>","stability":"stable","type":"function"};
44
+ this.githubRepoToken.entry = {"args":["appName","owner"],"category":"Github Credentials","input":true,"method":"post","name":"githubRepoToken","output":true,"query":[],"route":"/github/<appName>/<owner>/repo-token","scopes":{"AllOf":[{"each":"auth:github-repo-token:<appName>/<owner>/<repoPerm>","for":"repoPerm","in":"repoPerms"}]},"stability":"experimental","type":"function"};
44
45
  this.authenticateHawk.entry = {"args":[],"category":"Scopes and Auth","input":true,"method":"post","name":"authenticateHawk","output":true,"query":[],"route":"/authenticate-hawk","stability":"stable","type":"function"};
45
46
  this.testAuthenticate.entry = {"args":[],"category":"Scopes and Auth","input":true,"method":"post","name":"testAuthenticate","output":true,"query":[],"route":"/test-authenticate","stability":"stable","type":"function"};
46
47
  this.testAuthenticateGet.entry = {"args":[],"category":"Scopes and Auth","method":"get","name":"testAuthenticateGet","output":true,"query":[],"route":"/test-authenticate-get/","stability":"stable","type":"function"};
@@ -344,6 +345,24 @@ export default class Auth extends Client {
344
345
 
345
346
  return this.request(this.gcpCredentials.entry, args);
346
347
  }
348
+ // Get a Github application installation token scoped to the given repositories
349
+ // and permissions, using the configured app `appName`.
350
+ // Requesting `<permission>: <level>` on `<owner>/<repo>` requires the scope
351
+ // `auth:github-repo-token:<appName>/<owner>/<repo>:<permission>:<level>`.
352
+ // Levels and permissions are matched exactly to github token permissions
353
+ // which can be found at
354
+ // https://docs.github.com/en/rest/apps/apps?apiVersion=2026-03-10#create-an-installation-access-token-for-an-app.
355
+ // While token access is widened (requesting a write token will give a read+write one)
356
+ // scopes are not. Holding `:contents:write` alone only allows requesting a `write` token.
357
+ // Both owner and repo must be in lowercase in the scope.
358
+ // The token expires after an hour but this behavior is github dependent.
359
+ // You should read the `expires` property from the response if you intend
360
+ // to maintain active credentials in your task.
361
+ githubRepoToken(...args) {
362
+ this.validate(this.githubRepoToken.entry, args);
363
+
364
+ return this.request(this.githubRepoToken.entry, args);
365
+ }
347
366
  // Validate the request signature given on input and return list of scopes
348
367
  // that the authenticating client has.
349
368
  // This method is used by other services that wish rely on Taskcluster