ado-npm-auth 0.1.2 → 0.1.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.
Files changed (105) hide show
  1. package/README.md +25 -0
  2. package/dist/ado-npm-auth.cjs +10632 -1892
  3. package/lib/.tsbuildinfo +1 -1
  4. package/lib/{npmrc → ado}/make-ado-request.d.ts +1 -1
  5. package/lib/ado/make-ado-request.d.ts.map +1 -0
  6. package/lib/{npmrc → ado}/make-ado-request.js +3 -2
  7. package/lib/ado/make-ado-request.js.map +1 -0
  8. package/lib/args.d.ts +7 -0
  9. package/lib/args.d.ts.map +1 -0
  10. package/lib/args.js +28 -0
  11. package/lib/args.js.map +1 -0
  12. package/lib/azureauth/ado.d.ts.map +1 -1
  13. package/lib/azureauth/ado.js +3 -7
  14. package/lib/azureauth/ado.js.map +1 -1
  15. package/lib/azureauth/azureauth-command.d.ts +6 -3
  16. package/lib/azureauth/azureauth-command.d.ts.map +1 -1
  17. package/lib/azureauth/azureauth-command.js +12 -6
  18. package/lib/azureauth/azureauth-command.js.map +1 -1
  19. package/lib/azureauth/is-azureauth-installed.d.ts.map +1 -1
  20. package/lib/azureauth/is-azureauth-installed.js +3 -2
  21. package/lib/azureauth/is-azureauth-installed.js.map +1 -1
  22. package/lib/azureauth/is-azureauth-installed.test.js +5 -2
  23. package/lib/azureauth/is-azureauth-installed.test.js.map +1 -1
  24. package/lib/cli.d.ts +2 -1
  25. package/lib/cli.d.ts.map +1 -1
  26. package/lib/cli.js +58 -11
  27. package/lib/cli.js.map +1 -1
  28. package/lib/fileProvider.d.ts +35 -0
  29. package/lib/fileProvider.d.ts.map +1 -0
  30. package/lib/fileProvider.js +78 -0
  31. package/lib/fileProvider.js.map +1 -0
  32. package/lib/npmrc/generate-npmrc-pat.d.ts.map +1 -1
  33. package/lib/npmrc/generate-npmrc-pat.js +2 -2
  34. package/lib/npmrc/generate-npmrc-pat.js.map +1 -1
  35. package/lib/npmrc/npmrcFileProvider.d.ts +12 -0
  36. package/lib/npmrc/npmrcFileProvider.d.ts.map +1 -0
  37. package/lib/npmrc/npmrcFileProvider.js +148 -0
  38. package/lib/npmrc/npmrcFileProvider.js.map +1 -0
  39. package/lib/telemetry/index.d.ts.map +1 -1
  40. package/lib/telemetry/index.js +1 -2
  41. package/lib/telemetry/index.js.map +1 -1
  42. package/lib/utils/encoding.d.ts +13 -0
  43. package/lib/utils/encoding.d.ts.map +1 -0
  44. package/lib/utils/encoding.js +15 -0
  45. package/lib/utils/encoding.js.map +1 -0
  46. package/lib/utils/exec.d.ts +0 -1
  47. package/lib/utils/exec.d.ts.map +1 -1
  48. package/lib/utils/get-feed-without-protocol.d.ts +0 -2
  49. package/lib/utils/get-feed-without-protocol.d.ts.map +1 -1
  50. package/lib/utils/get-feed-without-protocol.js +0 -2
  51. package/lib/utils/get-feed-without-protocol.js.map +1 -1
  52. package/lib/utils/get-feed-without-protocol.test.js.map +1 -1
  53. package/lib/utils/get-organization-from-feed-url.d.ts.map +1 -1
  54. package/lib/utils/get-organization-from-feed-url.js +8 -5
  55. package/lib/utils/get-organization-from-feed-url.js.map +1 -1
  56. package/lib/utils/get-organization-from-feed-url.test.js +1 -1
  57. package/lib/utils/get-organization-from-feed-url.test.js.map +1 -1
  58. package/lib/utils/partition.d.ts +2 -0
  59. package/lib/utils/partition.d.ts.map +1 -0
  60. package/lib/utils/partition.js +15 -0
  61. package/lib/utils/partition.js.map +1 -0
  62. package/lib/utils/request.d.ts +0 -1
  63. package/lib/utils/request.d.ts.map +1 -1
  64. package/lib/utils/request.js +10 -2
  65. package/lib/utils/request.js.map +1 -1
  66. package/lib/yarnrc/yarnrcFileProvider.d.ts +29 -0
  67. package/lib/yarnrc/yarnrcFileProvider.d.ts.map +1 -0
  68. package/lib/yarnrc/yarnrcFileProvider.js +81 -0
  69. package/lib/yarnrc/yarnrcFileProvider.js.map +1 -0
  70. package/package.json +14 -8
  71. package/dist/ado-auto-auth.cjs +0 -39047
  72. package/lib/npmrc/base64.d.ts +0 -7
  73. package/lib/npmrc/base64.d.ts.map +0 -1
  74. package/lib/npmrc/base64.js +0 -7
  75. package/lib/npmrc/base64.js.map +0 -1
  76. package/lib/npmrc/check-tokens.d.ts +0 -11
  77. package/lib/npmrc/check-tokens.d.ts.map +0 -1
  78. package/lib/npmrc/check-tokens.js +0 -31
  79. package/lib/npmrc/check-tokens.js.map +0 -1
  80. package/lib/npmrc/get-repo-npmrc-ado-orgs.d.ts +0 -12
  81. package/lib/npmrc/get-repo-npmrc-ado-orgs.d.ts.map +0 -1
  82. package/lib/npmrc/get-repo-npmrc-ado-orgs.js +0 -49
  83. package/lib/npmrc/get-repo-npmrc-ado-orgs.js.map +0 -1
  84. package/lib/npmrc/get-user-pat.d.ts +0 -14
  85. package/lib/npmrc/get-user-pat.d.ts.map +0 -1
  86. package/lib/npmrc/get-user-pat.js +0 -33
  87. package/lib/npmrc/get-user-pat.js.map +0 -1
  88. package/lib/npmrc/is-valid-pat.d.ts +0 -2
  89. package/lib/npmrc/is-valid-pat.d.ts.map +0 -1
  90. package/lib/npmrc/is-valid-pat.js +0 -59
  91. package/lib/npmrc/is-valid-pat.js.map +0 -1
  92. package/lib/npmrc/make-ado-request.d.ts.map +0 -1
  93. package/lib/npmrc/make-ado-request.js.map +0 -1
  94. package/lib/npmrc/npmrc.d.ts +0 -15
  95. package/lib/npmrc/npmrc.d.ts.map +0 -1
  96. package/lib/npmrc/npmrc.js +0 -22
  97. package/lib/npmrc/npmrc.js.map +0 -1
  98. package/lib/npmrc/pat.d.ts +0 -13
  99. package/lib/npmrc/pat.d.ts.map +0 -1
  100. package/lib/npmrc/pat.js +0 -32
  101. package/lib/npmrc/pat.js.map +0 -1
  102. package/lib/npmrc/set-npmrc-pat.d.ts +0 -16
  103. package/lib/npmrc/set-npmrc-pat.d.ts.map +0 -1
  104. package/lib/npmrc/set-npmrc-pat.js +0 -109
  105. package/lib/npmrc/set-npmrc-pat.js.map +0 -1
@@ -1,7 +0,0 @@
1
- /**
2
- * Decode a base64 encoded string
3
- * @param {string} base64string
4
- * @returns
5
- */
6
- export declare const decode: (base64string: string) => string;
7
- //# sourceMappingURL=base64.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../src/npmrc/base64.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,MAAM,iBAAkB,MAAM,WACkB,CAAC"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Decode a base64 encoded string
3
- * @param {string} base64string
4
- * @returns
5
- */
6
- export const decode = (base64string) => Buffer.from(base64string, "base64").toString("utf8").trim();
7
- //# sourceMappingURL=base64.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base64.js","sourceRoot":"","sources":["../../src/npmrc/base64.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,YAAoB,EAAE,EAAE,CAC7C,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC"}
@@ -1,11 +0,0 @@
1
- import { NpmrcOrg } from "./get-repo-npmrc-ado-orgs.js";
2
- /**
3
- * Validates the tokens for each feed/organization by making a simple network request to ADO
4
- * @param { Object } options
5
- * @param { boolean } [options.silent]
6
- * @param { Array<NpmrcOrg> } [options.feeds]
7
- */
8
- export declare const checkTokens: ({ feeds }: {
9
- feeds: NpmrcOrg[];
10
- }) => Promise<boolean>;
11
- //# sourceMappingURL=check-tokens.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"check-tokens.d.ts","sourceRoot":"","sources":["../../src/npmrc/check-tokens.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAGxD;;;;;GAKG;AACH,eAAO,MAAM,WAAW,cAA8B;IAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;CAAE,qBAyB1E,CAAC"}
@@ -1,31 +0,0 @@
1
- import { makeADORequest } from "./make-ado-request.js";
2
- import { getUserPat } from "./get-user-pat.js";
3
- import { getUserNPMRC } from "./npmrc.js";
4
- /**
5
- * Validates the tokens for each feed/organization by making a simple network request to ADO
6
- * @param { Object } options
7
- * @param { boolean } [options.silent]
8
- * @param { Array<NpmrcOrg> } [options.feeds]
9
- */
10
- export const checkTokens = async function ({ feeds }) {
11
- const userNpmRc = getUserNPMRC();
12
- const feedsWithPat = await getUserPat({ npmrc: userNpmRc, feeds });
13
- const missingPats = feedsWithPat.filter((item) => !item.pat);
14
- if (missingPats.length) {
15
- return false;
16
- }
17
- try {
18
- // check each feed for validity
19
- for (const feed of feedsWithPat) {
20
- await makeADORequest({
21
- password: feed.pat || "",
22
- organization: feed.organization,
23
- });
24
- }
25
- }
26
- catch (e) {
27
- return false;
28
- }
29
- return true;
30
- };
31
- //# sourceMappingURL=check-tokens.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"check-tokens.js","sourceRoot":"","sources":["../../src/npmrc/check-tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,WAAW,EAAE,KAAK,EAAyB;IACzE,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IAEjC,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;IAEnE,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAE7D,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;QACvB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,IAAI,CAAC;QACH,+BAA+B;QAC/B,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;YAChC,MAAM,cAAc,CAAC;gBACnB,QAAQ,EAAE,IAAI,CAAC,GAAG,IAAI,EAAE;gBACxB,YAAY,EAAE,IAAI,CAAC,YAAY;aAChC,CAAC,CAAC;QACL,CAAC;IAEH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
@@ -1,12 +0,0 @@
1
- export type NpmrcOrg = {
2
- feed: string;
3
- organization: string;
4
- pat?: string;
5
- };
6
- /**
7
- * Determine what ADO organizations are used in the workspace's .npmrc
8
- * These should be used to authenticate against
9
- * @returns A list of the feeds/ado orgs used in the .npmrc
10
- */
11
- export declare const getRepoNpmrcAdoOrganizations: () => Promise<Array<NpmrcOrg>>;
12
- //# sourceMappingURL=get-repo-npmrc-ado-orgs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-repo-npmrc-ado-orgs.d.ts","sourceRoot":"","sources":["../../src/npmrc/get-repo-npmrc-ado-orgs.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,QAAa,QACpD,MAAM,QAAQ,CAAC,CA4ChB,CAAC"}
@@ -1,49 +0,0 @@
1
- import Config from "@npmcli/config";
2
- import { getWorkspaceRoot } from "workspace-tools";
3
- import { join } from "node:path";
4
- import fs from "node:fs/promises";
5
- import { getOrganizationFromFeedUrl } from "../utils/get-organization-from-feed-url.js";
6
- /**
7
- * Determine what ADO organizations are used in the workspace's .npmrc
8
- * These should be used to authenticate against
9
- * @returns A list of the feeds/ado orgs used in the .npmrc
10
- */
11
- export const getRepoNpmrcAdoOrganizations = async () => {
12
- var _a;
13
- const workspaceRoot = getWorkspaceRoot(process.cwd()) || "";
14
- let config;
15
- const npmrcPath = join(workspaceRoot, ".npmrc");
16
- try {
17
- await fs.access(npmrcPath);
18
- }
19
- catch (error) {
20
- throw new Error("No project .npmrc file found");
21
- }
22
- try {
23
- config = new Config({
24
- npmPath: npmrcPath,
25
- shorthands: {},
26
- definitions: {}, // needed so we can access random feed names
27
- });
28
- await config.load();
29
- }
30
- catch (error) {
31
- if (error instanceof TypeError && error.message.includes("Invalid URL")) {
32
- throw new Error("Registry URL missing or invalid");
33
- }
34
- throw new Error("Error loading .npmrc");
35
- }
36
- // @npmcli/config does not have a normal way to display all keys
37
- // so we use this ugly access instead
38
- const projectNpmrcKeys = Object.keys((((_a = config.data) === null || _a === void 0 ? void 0 : _a.get("project")) || {})["data"] || {});
39
- // find any and all keys which are a registry
40
- const registries = projectNpmrcKeys.filter((key) => key.includes("registry"));
41
- return registries.map((registry) => {
42
- const feed = config.get(registry, "project");
43
- return {
44
- feed,
45
- organization: getOrganizationFromFeedUrl(feed),
46
- };
47
- });
48
- };
49
- //# sourceMappingURL=get-repo-npmrc-ado-orgs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-repo-npmrc-ado-orgs.js","sourceRoot":"","sources":["../../src/npmrc/get-repo-npmrc-ado-orgs.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACjC,OAAO,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAC;AAQxF;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,KAAK,IAE/C,EAAE;;IACF,MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC,GAAG,E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E,SAAS,CAAW,CAAC;QAEvD,OAAO;YACL,IAAI;YACJ,YAAY,EAAE,0BAA0B,CAAC,IAAI,CAAC;SAC/C,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -1,14 +0,0 @@
1
- import { NpmrcOrg } from "./get-repo-npmrc-ado-orgs.js";
2
- /**
3
- * Get the User's PAT(s) from the .npmrc file
4
- * They will be scoped to a particular feed and ADO organization
5
- * @param {Object} options
6
- * @param {string} options.npmrc Path to the users' .npmrc file
7
- * @param {Array<NpmrcOrg> } [options.feeds] Feeds to get the PATs for
8
- * @returns {Promise<Array<NpmrcOrg>> }
9
- */
10
- export declare const getUserPat: ({ npmrc, feeds }: {
11
- npmrc: string;
12
- feeds?: NpmrcOrg[];
13
- }) => Promise<NpmrcOrg[]>;
14
- //# sourceMappingURL=get-user-pat.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-user-pat.d.ts","sourceRoot":"","sources":["../../src/npmrc/get-user-pat.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAIxD;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,qBAAiC;IACtD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;CACpB,wBAwBA,CAAC"}
@@ -1,33 +0,0 @@
1
- import { decode } from "./base64.js";
2
- import { getFeedWithoutProtocol } from "../utils/get-feed-without-protocol.js";
3
- import { readNpmRC } from "./npmrc.js";
4
- /**
5
- * Get the User's PAT(s) from the .npmrc file
6
- * They will be scoped to a particular feed and ADO organization
7
- * @param {Object} options
8
- * @param {string} options.npmrc Path to the users' .npmrc file
9
- * @param {Array<NpmrcOrg> } [options.feeds] Feeds to get the PATs for
10
- * @returns {Promise<Array<NpmrcOrg>> }
11
- */
12
- export const getUserPat = async ({ npmrc, feeds = [] }) => {
13
- try {
14
- const contents = await readNpmRC({ npmrc });
15
- const feedsWithPat = feeds.slice(); // create a copy of feeds
16
- for (let i = 0; i < feeds.length; i++) {
17
- const match = contents.toString().match(
18
- // SHould match the URL from the user .npmrc
19
- new RegExp(`${getFeedWithoutProtocol(feeds[i].feed)}:_password=(.*)`));
20
- if (match) {
21
- const [, base64password] = match;
22
- const pat = decode(base64password);
23
- feedsWithPat[i].pat = pat;
24
- }
25
- }
26
- return feedsWithPat;
27
- }
28
- catch (error) {
29
- // user npmrc does not exist, or is invalid
30
- return [];
31
- }
32
- };
33
- //# sourceMappingURL=get-user-pat.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-user-pat.js","sourceRoot":"","sources":["../../src/npmrc/get-user-pat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,GAAG,EAAE,EAGnD,EAAE,EAAE;IACH,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5C,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,yBAAyB;QAE7D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK;YACrC,4CAA4C;YAC5C,IAAI,MAAM,CAAC,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CACtE,CAAC;YAEF,IAAI,KAAK,EAAE,CAAC;gBACV,MAAM,CAAC,EAAE,cAAc,CAAC,GAAG,KAAK,CAAC;gBACjC,MAAM,GAAG,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;gBAEnC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC;YAC5B,CAAC;QACH,CAAC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,2CAA2C;QAC3C,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const isValidPat: () => Promise<boolean>;
2
- //# sourceMappingURL=is-valid-pat.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-valid-pat.d.ts","sourceRoot":"","sources":["../../src/npmrc/is-valid-pat.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,UAAU,QAAa,QAAQ,OAAO,CAKlD,CAAC"}
@@ -1,59 +0,0 @@
1
- import { checkTokens } from "./check-tokens.js";
2
- import { getOrganizationFromFeedUrl } from "../utils/get-organization-from-feed-url.js";
3
- import { homedir, EOL } from "node:os";
4
- import { join } from "node:path";
5
- import { readFile, writeFile } from "node:fs/promises";
6
- import { getRepoNpmrcAdoOrganizations, } from "./get-repo-npmrc-ado-orgs.js";
7
- export const isValidPat = async () => {
8
- await removeUserNpmrcRegistries();
9
- const feeds = await getNpmrcFeeds();
10
- return await checkTokens({ feeds });
11
- };
12
- const removeUserNpmrcRegistries = async () => {
13
- const userNpmrc = join(homedir(), ".npmrc");
14
- try {
15
- const npmrcContent = await readFile(userNpmrc, "utf-8");
16
- // remove the entry for registries in the user-level .npmrc
17
- const updatedNpmrcContent = npmrcContent
18
- .split(EOL)
19
- .filter((line) => !line.includes("registry="))
20
- .join(EOL);
21
- await writeFile(userNpmrc, updatedNpmrcContent);
22
- }
23
- catch (error) {
24
- // user npmrc does not exist so make an empty one
25
- await writeFile(userNpmrc, "");
26
- }
27
- };
28
- const getNpmrcFeeds = async () => {
29
- const projectNpmrcOrgs = await getRepoNpmrcAdoOrganizations();
30
- const userNpmrc = await getUserNpmrcFeeds();
31
- // make a lookup map for pats by org
32
- const tokenMap = userNpmrc.reduce((acc, curr) => {
33
- acc[curr.organization] = curr.pat;
34
- return acc;
35
- }, {});
36
- // try to fill up pats for each project feed from user npmrc feeds
37
- projectNpmrcOrgs.forEach((feed) => {
38
- feed.pat = tokenMap[feed.organization];
39
- });
40
- return projectNpmrcOrgs;
41
- };
42
- const getUserNpmrcFeeds = async () => {
43
- const userNpmrcFilepath = join(homedir(), ".npmrc");
44
- const userNpmrcContent = await readFile(userNpmrcFilepath, "utf-8");
45
- return userNpmrcContent
46
- .split(EOL)
47
- .filter((line) => line.includes(":_password="))
48
- .map((line) => {
49
- const [feedRaw, pat] = line.split(":_password=");
50
- const feed = `https:${feedRaw}`;
51
- const organization = getOrganizationFromFeedUrl(feed);
52
- return {
53
- feed,
54
- organization,
55
- pat,
56
- };
57
- });
58
- };
59
- //# sourceMappingURL=is-valid-pat.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-valid-pat.js","sourceRoot":"","sources":["../../src/npmrc/is-valid-pat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAC;AACxF,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAEL,4BAA4B,GAC7B,MAAM,8BAA8B,CAAC;AAEtC,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,IAAsB,EAAE;IACrD,MAAM,yBAAyB,EAAE,CAAC;IAElC,MAAM,KAAK,GAAG,MAAM,aAAa,EAAE,CAAC;IACpC,OAAO,MAAM,WAAW,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AACtC,CAAC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,iBAAiB,GAAG,KAAK,IAA8B,EAAE;IAC7D,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC;IACpD,MAAM,gBAAgB,GAAG,MAAM,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;IACpE,OAAO,gBAAgB;SACpB,KAAK,CAAC,GAAG,CAAC;SACV,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;SAC9C,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACjD,MAAM,IAAI,GAAG,SAAS,OAAO,EAAE,CAAC;QAChC,MAAM,YAAY,GAAG,0BAA0B,CAAC,IAAI,CAAC,CAAC;QACtD,OAAO;YACL,IAAI;YACJ,YAAY;YACZ,GAAG;SACJ,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"make-ado-request.d.ts","sourceRoot":"","sources":["../../src/npmrc/make-ado-request.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,+BAAsC;IAC/D,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB,kBAyBA,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"make-ado-request.js","sourceRoot":"","sources":["../../src/npmrc/make-ado-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,EAAE,QAAQ,EAAE,YAAY,EAG5D,EAAE,EAAE;IACH,MAAM,IAAI,GAAG,SAAS,MAAM,CAAC,IAAI,CAAC,KAAK,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;IAExE,MAAM,OAAO,GAAG;QACd,QAAQ,EAAE,qBAAqB;QAC/B,IAAI,EAAE,GAAG;QACT,IAAI,EAAE,IAAI,YAAY,oDAAoD;QAC1E,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;YAC1B,aAAa,EAAE,IAAI;SACpB;KACF,CAAC;IAEF,IAAI,CAAC;QACH,MAAM,WAAW,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAAC,QAAO,kBAAmB,KAAK,EAAE,CAAC;QAClC,IAAK,KAAa,CAAC,UAAU,KAAK,GAAG,EAAE,CAAC;YACtC,+DAA+D;YAC/D,+EAA+E;YAC/E,OAAO;QACT,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC"}
@@ -1,15 +0,0 @@
1
- /**
2
- * Cross platform way to find the users' .npmrc file
3
- * @returns The user's npmrc from home or user profile
4
- */
5
- export declare const getUserNPMRC: () => string;
6
- /**
7
- * Read the an .npmrc file
8
- * @param {Object} options
9
- * @param {string} options.npmrc Path to the users' .npmrc file
10
- * @returns
11
- */
12
- export declare const readNpmRC: ({ npmrc }: {
13
- npmrc: string;
14
- }) => Promise<string>;
15
- //# sourceMappingURL=npmrc.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"npmrc.d.ts","sourceRoot":"","sources":["../../src/npmrc/npmrc.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,eAAO,MAAM,YAAY,cAKxB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,cAAqB;IAAE,KAAK,EAAE,MAAM,CAAC;CAAE,oBAI5D,CAAC"}
@@ -1,22 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
- /**
4
- * Cross platform way to find the users' .npmrc file
5
- * @returns The user's npmrc from home or user profile
6
- */
7
- export const getUserNPMRC = () => {
8
- const userHome = process.env["HOME"] || process.env["USERPROFILE"] || "";
9
- const userNpmRc = path.join(userHome, ".npmrc");
10
- return userNpmRc;
11
- };
12
- /**
13
- * Read the an .npmrc file
14
- * @param {Object} options
15
- * @param {string} options.npmrc Path to the users' .npmrc file
16
- * @returns
17
- */
18
- export const readNpmRC = async ({ npmrc }) => {
19
- const contents = await fs.promises.readFile(npmrc, "utf8");
20
- return contents;
21
- };
22
- //# sourceMappingURL=npmrc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"npmrc.js","sourceRoot":"","sources":["../../src/npmrc/npmrc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE;IAC/B,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IACzE,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAEhD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,EAAE,KAAK,EAAsB,EAAE,EAAE;IAC/D,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAE3D,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
@@ -1,13 +0,0 @@
1
- import { NpmrcOrg } from "./get-repo-npmrc-ado-orgs.js";
2
- /**
3
- * Get the User's PAT from the .npmrc file
4
- * @param {Object} options
5
- * @param {string} options.npmrc Path to the users' .npmrc file
6
- * @param { Array<NpmrcOrg> } [options.feeds] Feeds to get the PATs for
7
- * @returns { Promise<Array<NpmrcOrg>> }
8
- */
9
- export declare const getUserPat: ({ npmrc, feeds }: {
10
- npmrc: string;
11
- feeds: NpmrcOrg[];
12
- }) => Promise<NpmrcOrg[]>;
13
- //# sourceMappingURL=pat.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pat.d.ts","sourceRoot":"","sources":["../../src/npmrc/pat.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAIxD;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,qBAAiC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,QAAQ,EAAE,CAAA;CAAC,wBAwB1F,CAAC"}
package/lib/npmrc/pat.js DELETED
@@ -1,32 +0,0 @@
1
- import { decode } from "./base64.js";
2
- import { getFeedWithoutProtocol } from "../utils/get-feed-without-protocol.js";
3
- import { readNpmRC } from "./npmrc.js";
4
- /**
5
- * Get the User's PAT from the .npmrc file
6
- * @param {Object} options
7
- * @param {string} options.npmrc Path to the users' .npmrc file
8
- * @param { Array<NpmrcOrg> } [options.feeds] Feeds to get the PATs for
9
- * @returns { Promise<Array<NpmrcOrg>> }
10
- */
11
- export const getUserPat = async ({ npmrc, feeds = [] }) => {
12
- try {
13
- const contents = await readNpmRC({ npmrc });
14
- const feedsWithPat = feeds.slice(); // create a copy of feeds
15
- for (let i = 0; i < feeds.length; i++) {
16
- const match = contents.toString().match(
17
- // SHould match the URL from the user .npmrc
18
- new RegExp(`${getFeedWithoutProtocol(feeds[i].feed)}:_password=(.*)`));
19
- if (match) {
20
- const [, base64password] = match;
21
- const pat = decode(base64password);
22
- feedsWithPat[i].pat = pat;
23
- }
24
- }
25
- return feedsWithPat;
26
- }
27
- catch (error) {
28
- // user npmrc does not exist, or is invalid
29
- return [];
30
- }
31
- };
32
- //# sourceMappingURL=pat.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pat.js","sourceRoot":"","sources":["../../src/npmrc/pat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,GAAG,EAAE,EAAuC,EAAE,EAAE;IAC7F,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5C,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,yBAAyB;QAE7D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK;YACrC,4CAA4C;YAC5C,IAAI,MAAM,CAAC,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CACtE,CAAC;YAEF,IAAI,KAAK,EAAE,CAAC;gBACV,MAAM,CAAC,EAAE,cAAc,CAAC,GAAG,KAAK,CAAC;gBACjC,MAAM,GAAG,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;gBAEnC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC;YAC5B,CAAC;QACH,CAAC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,2CAA2C;QAC3C,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC"}
@@ -1,16 +0,0 @@
1
- import { NpmrcOrg } from "./get-repo-npmrc-ado-orgs.js";
2
- /**
3
- *
4
- * @param {Object} options
5
- * @param {Record<string, string>} [options.organizationPatMap] Map of ADO Organization to packaging PAT for that org
6
- * @param {boolean} [options.accept]
7
- * @param {string} [options.npmrcFilePath]
8
- * @param {boolean} [options.silent]
9
- * @returnsshort
10
- */
11
- export declare const setupNpmrc: ({ organizationPatMap, feeds, }: {
12
- organizationPatMap: Record<string, string>;
13
- feeds: NpmrcOrg[];
14
- }) => Promise<void>;
15
- export declare const setNpmrcPat: () => Promise<void>;
16
- //# sourceMappingURL=set-npmrc-pat.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"set-npmrc-pat.d.ts","sourceRoot":"","sources":["../../src/npmrc/set-npmrc-pat.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAgC,MAAM,8BAA8B,CAAC;AAyEtF;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,mCAGpB;IACD,kBAAkB,EAAE,OAAO,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB,kBAgCA,CAAC;AAEF,eAAO,MAAM,WAAW,QAAa,QAAQ,IAAI,CAgBhD,CAAC"}
@@ -1,109 +0,0 @@
1
- import fs from "fs";
2
- import { EOL } from "os";
3
- import { generateNpmrcPat } from "./generate-npmrc-pat.js";
4
- import { getRepoNpmrcAdoOrganizations } from "./get-repo-npmrc-ado-orgs.js";
5
- import { getUserNPMRC, readNpmRC } from "./npmrc.js";
6
- import { getFeedWithoutProtocol } from "../utils/get-feed-without-protocol.js";
7
- // /**
8
- // * URL for the user's PAT settings
9
- // * @param { string } organization
10
- // */
11
- // const getTokenUrl = (organization: string) =>
12
- // `https://dev.azure.com/${organization}/_usersSettings/tokens`;
13
- /**
14
- * Default user to be used in the .npmrc
15
- */
16
- const defaultUser = "me";
17
- /**
18
- * Default email to be used in the .npmrc
19
- */
20
- const defaultEmail = "me@example.com";
21
- /**
22
- * Create a base64 encoded string from a string
23
- * @param {string} input
24
- * @returns {string}
25
- */
26
- const base64 = (input) => {
27
- return Buffer.from(input).toString("base64");
28
- };
29
- /**
30
- * Create the user npmrc given an array of registry urls and a token
31
- * @param {object} options
32
- * @param {Array<import("../../utils/pat.js").NpmrcOrg> } options.feeds
33
- * @param {string} options.existingNpmrc
34
- * @returns {string}
35
- */
36
- const createUserNpmrc = async ({ feeds, existingNpmrc }) => {
37
- let newUserNpmRc = existingNpmrc;
38
- if (newUserNpmRc.indexOf("Azure Artifacts Auth") === -1) {
39
- newUserNpmRc = `# Generated by Azure Artifacts Auth${EOL}${newUserNpmRc}`;
40
- }
41
- for (const feed of feeds) {
42
- const feedWithoutProtocol = "//" + getFeedWithoutProtocol(feed.feed);
43
- let isAlreadyInNpmrc = newUserNpmRc.indexOf(feedWithoutProtocol) > -1;
44
- if (isAlreadyInNpmrc) {
45
- newUserNpmRc = newUserNpmRc.replace(new RegExp(`${feedWithoutProtocol}:_password\=(.*)`), `${feedWithoutProtocol}:_password=${feed.pat}`);
46
- }
47
- else {
48
- const entry = [
49
- `${feedWithoutProtocol}:username=${defaultUser}`,
50
- `${feedWithoutProtocol}:email=${defaultEmail}`,
51
- `${feedWithoutProtocol}:_password=${feed.pat}`,
52
- "",
53
- ].join(EOL);
54
- newUserNpmRc += entry + EOL;
55
- }
56
- }
57
- return newUserNpmRc;
58
- };
59
- const userNpmrc = getUserNPMRC();
60
- /**
61
- *
62
- * @param {Object} options
63
- * @param {Record<string, string>} [options.organizationPatMap] Map of ADO Organization to packaging PAT for that org
64
- * @param {boolean} [options.accept]
65
- * @param {string} [options.npmrcFilePath]
66
- * @param {boolean} [options.silent]
67
- * @returnsshort
68
- */
69
- export const setupNpmrc = async function ({ organizationPatMap = {}, feeds, }) {
70
- for (const feed of feeds) {
71
- try {
72
- let pat = organizationPatMap[feed.organization];
73
- if (!pat) {
74
- throw new Error(`No PAT found for ${feed.organization}`);
75
- }
76
- const b64Pat = base64(pat);
77
- feed.pat = b64Pat;
78
- }
79
- catch (e) {
80
- throw new Error(`Error setting up npmrc for ${feed.organization} organization: ${e.message}`);
81
- }
82
- }
83
- let userNpmrcFile = "";
84
- try {
85
- userNpmrcFile = await readNpmRC({ npmrc: userNpmrc });
86
- }
87
- catch (e) {
88
- /* No user .npmrc file, that's ok */
89
- }
90
- // const newnpmrc =
91
- let newnpmrc = await createUserNpmrc({
92
- existingNpmrc: userNpmrcFile,
93
- feeds,
94
- });
95
- await fs.promises.writeFile(userNpmrc, newnpmrc);
96
- };
97
- export const setNpmrcPat = async () => {
98
- const adoOrgs = await getRepoNpmrcAdoOrganizations();
99
- // get a token for each feed
100
- const organizationPatMap = {};
101
- for (const adoOrg of adoOrgs) {
102
- organizationPatMap[adoOrg.organization] = await generateNpmrcPat(adoOrg.organization, false);
103
- }
104
- await setupNpmrc({
105
- organizationPatMap,
106
- feeds: adoOrgs
107
- });
108
- };
109
- //# sourceMappingURL=set-npmrc-pat.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"set-npmrc-pat.js","sourceRoot":"","sources":["../../src/npmrc/set-npmrc-pat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,GAAG,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAY,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,MAAM;AACN,qCAAqC;AACrC,oCAAoC;AACpC,MAAM;AACN,gDAAgD;AAChD,mEAAmE;AAEnE;;GAEG;AACH,MAAM,WAAW,GAAG,IAAI,CAAC;AAEzB;;GAEG;AACH,MAAM,YAAY,GAAG,gBAAgB,CAAC;AAEtC;;;;GAIG;AACH,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,EAAE;IAC/B,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC/C,CAAC,CAAC;AAGF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