@osdk/oauth 1.1.0-beta.1 → 1.1.0-beta.11

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/CHANGELOG.md +65 -0
  2. package/build/browser/AuthorizationServer.test.js +53 -0
  3. package/build/browser/AuthorizationServer.test.js.map +1 -0
  4. package/build/browser/BaseOauthClient.js +0 -15
  5. package/build/browser/BaseOauthClient.js.map +1 -1
  6. package/build/browser/ConfidentialOauthClient.js +0 -15
  7. package/build/browser/ConfidentialOauthClient.js.map +1 -1
  8. package/build/browser/PublicOauthClient.js +0 -15
  9. package/build/browser/PublicOauthClient.js.map +1 -1
  10. package/build/browser/Token.js +0 -15
  11. package/build/browser/Token.js.map +1 -1
  12. package/build/browser/__tests__/createPublicOauthClient.test.js +59 -0
  13. package/build/browser/__tests__/createPublicOauthClient.test.js.map +1 -0
  14. package/build/browser/common.js +25 -7
  15. package/build/browser/common.js.map +1 -1
  16. package/build/browser/common.test.js +65 -0
  17. package/build/browser/common.test.js.map +1 -0
  18. package/build/browser/createConfidentialOauthClient.js +4 -2
  19. package/build/browser/createConfidentialOauthClient.js.map +1 -1
  20. package/build/browser/createPublicOauthClient.js +74 -36
  21. package/build/browser/createPublicOauthClient.js.map +1 -1
  22. package/build/browser/index.js +1 -0
  23. package/build/browser/index.js.map +1 -1
  24. package/build/browser/publicOauth.test.js +318 -0
  25. package/build/browser/publicOauth.test.js.map +1 -0
  26. package/build/browser/throwIfError.js +1 -0
  27. package/build/browser/throwIfError.js.map +1 -1
  28. package/build/browser/utils.js +47 -0
  29. package/build/browser/utils.js.map +1 -0
  30. package/build/cjs/index.cjs +1299 -0
  31. package/build/cjs/index.cjs.map +1 -0
  32. package/build/cjs/index.d.cts +96 -0
  33. package/build/esm/AuthorizationServer.test.js +53 -0
  34. package/build/esm/AuthorizationServer.test.js.map +1 -0
  35. package/build/esm/BaseOauthClient.js +0 -15
  36. package/build/esm/BaseOauthClient.js.map +1 -1
  37. package/build/esm/ConfidentialOauthClient.js +0 -15
  38. package/build/esm/ConfidentialOauthClient.js.map +1 -1
  39. package/build/esm/PublicOauthClient.js +0 -15
  40. package/build/esm/PublicOauthClient.js.map +1 -1
  41. package/build/esm/Token.js +0 -15
  42. package/build/esm/Token.js.map +1 -1
  43. package/build/esm/__tests__/createPublicOauthClient.test.js +59 -0
  44. package/build/esm/__tests__/createPublicOauthClient.test.js.map +1 -0
  45. package/build/esm/common.js +25 -7
  46. package/build/esm/common.js.map +1 -1
  47. package/build/esm/common.test.js +65 -0
  48. package/build/esm/common.test.js.map +1 -0
  49. package/build/esm/createConfidentialOauthClient.js +4 -2
  50. package/build/esm/createConfidentialOauthClient.js.map +1 -1
  51. package/build/esm/createPublicOauthClient.js +74 -36
  52. package/build/esm/createPublicOauthClient.js.map +1 -1
  53. package/build/esm/index.js +1 -0
  54. package/build/esm/index.js.map +1 -1
  55. package/build/esm/publicOauth.test.js +318 -0
  56. package/build/esm/publicOauth.test.js.map +1 -0
  57. package/build/esm/throwIfError.js +1 -0
  58. package/build/esm/throwIfError.js.map +1 -1
  59. package/build/esm/utils.js +47 -0
  60. package/build/esm/utils.js.map +1 -0
  61. package/build/types/AuthorizationServer.test.d.ts +1 -0
  62. package/build/types/BaseOauthClient.d.ts +14 -0
  63. package/build/{esm → types}/ConfidentialOauthClient.d.ts +1 -3
  64. package/build/{browser → types}/PublicOauthClient.d.ts +1 -2
  65. package/build/types/Token.d.ts +6 -0
  66. package/build/types/__tests__/createPublicOauthClient.test.d.ts +1 -0
  67. package/build/{browser → types}/common.d.ts +20 -25
  68. package/build/types/common.test.d.ts +1 -0
  69. package/build/{browser → types}/createConfidentialOauthClient.d.ts +8 -9
  70. package/build/types/createPublicOauthClient.d.ts +56 -0
  71. package/build/{browser → types}/index.d.ts +1 -2
  72. package/build/types/publicOauth.test.d.ts +1 -0
  73. package/build/{browser → types}/throwIfError.d.ts +0 -1
  74. package/build/types/utils.d.ts +7 -0
  75. package/package.json +21 -7
  76. package/build/browser/BaseOauthClient.d.ts +0 -15
  77. package/build/browser/BaseOauthClient.d.ts.map +0 -1
  78. package/build/browser/ConfidentialOauthClient.d.ts +0 -4
  79. package/build/browser/ConfidentialOauthClient.d.ts.map +0 -1
  80. package/build/browser/PublicOauthClient.d.ts.map +0 -1
  81. package/build/browser/Token.d.ts +0 -7
  82. package/build/browser/Token.d.ts.map +0 -1
  83. package/build/browser/common.d.ts.map +0 -1
  84. package/build/browser/createConfidentialOauthClient.d.ts.map +0 -1
  85. package/build/browser/createPublicOauthClient.d.ts +0 -15
  86. package/build/browser/createPublicOauthClient.d.ts.map +0 -1
  87. package/build/browser/index.d.ts.map +0 -1
  88. package/build/browser/throwIfError.d.ts.map +0 -1
  89. package/build/esm/BaseOauthClient.d.ts +0 -15
  90. package/build/esm/BaseOauthClient.d.ts.map +0 -1
  91. package/build/esm/ConfidentialOauthClient.d.ts.map +0 -1
  92. package/build/esm/PublicOauthClient.d.ts +0 -6
  93. package/build/esm/PublicOauthClient.d.ts.map +0 -1
  94. package/build/esm/Token.d.ts +0 -7
  95. package/build/esm/Token.d.ts.map +0 -1
  96. package/build/esm/common.d.ts +0 -36
  97. package/build/esm/common.d.ts.map +0 -1
  98. package/build/esm/createConfidentialOauthClient.d.ts +0 -12
  99. package/build/esm/createConfidentialOauthClient.d.ts.map +0 -1
  100. package/build/esm/createPublicOauthClient.d.ts +0 -15
  101. package/build/esm/createPublicOauthClient.d.ts.map +0 -1
  102. package/build/esm/index.d.ts +0 -4
  103. package/build/esm/index.d.ts.map +0 -1
  104. package/build/esm/throwIfError.d.ts +0 -6
  105. package/build/esm/throwIfError.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,70 @@
1
1
  # @osdk/oauth
2
2
 
3
+ ## 1.1.0-beta.11
4
+
5
+ ### Minor Changes
6
+
7
+ - 9df2d99: Fixes CJS generation for OAuth
8
+
9
+ ## 1.1.0-beta.10
10
+
11
+ ### Minor Changes
12
+
13
+ - 44e62f6: Updating fetch for auth and other packages.
14
+
15
+ ## 1.1.0-beta.9
16
+
17
+ ### Minor Changes
18
+
19
+ - c691c8b: Package now has experimental support for commonjs
20
+
21
+ ## 1.1.0-beta.8
22
+
23
+ ### Minor Changes
24
+
25
+ - 02685ab: Adding return types to functions.
26
+ - 696c59c: Enables additional metadata to be required to match a refresh token in local storage
27
+
28
+ ## 1.1.0-beta.7
29
+
30
+ ### Minor Changes
31
+
32
+ - 0166d14: Fixes an infinite redirect issue on some errors in the OAuth flow
33
+ - c9da74c: Improves code quality by fixing linting errors
34
+
35
+ ## 1.1.0-beta.6
36
+
37
+ ### Minor Changes
38
+
39
+ - 3d2ba6f: Revert api:x-read/write back to api:read/write-x
40
+
41
+ ## 1.1.0-beta.5
42
+
43
+ ### Minor Changes
44
+
45
+ - 9d35a1f: Remove unused imports
46
+
47
+ ## 1.1.0-beta.4
48
+
49
+ ### Minor Changes
50
+
51
+ - e968bc0: Use api:ontologies-X instead of api:X-data
52
+
53
+ ## 1.1.0-beta.3
54
+
55
+ ### Minor Changes
56
+
57
+ - 91cfa3a: Fixing url parsing for client.
58
+ - d501104: Adds unit testing of public oauth flow
59
+ - 91cfa3a: Fixing URL parsing for custom entry points.
60
+
61
+ ## 1.1.0-beta.2
62
+
63
+ ### Minor Changes
64
+
65
+ - 33590c7: Add tests for createPublicOauthClient overload
66
+ - e00bb29: Overload createPublicOauthClient to support object of options
67
+
3
68
  ## 1.1.0-beta.1
4
69
 
5
70
  ### Minor Changes
@@ -0,0 +1,53 @@
1
+ /*
2
+ * Copyright 2024 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { describe, expect, it } from "vitest";
18
+ import { createAuthorizationServer } from "./common.js";
19
+ describe("Create authorization server", () => {
20
+ it("works with old multipass ctx path", () => {
21
+ const authServer = createAuthorizationServer("/multipass", "https://stack.palantir.com");
22
+ expect(authServer).toEqual({
23
+ token_endpoint: "https://stack.palantir.com/multipass/api/oauth2/token",
24
+ authorization_endpoint: "https://stack.palantir.com/multipass/api/oauth2/authorize",
25
+ revocation_endpoint: "https://stack.palantir.com/multipass/api/oauth2/revoke_token",
26
+ issuer: "https://stack.palantir.com/multipass"
27
+ });
28
+ });
29
+ it("works with new multipass ctx path", () => {
30
+ const authServer = createAuthorizationServer("multipass", "https://stack.palantir.com");
31
+ expect(authServer).toEqual({
32
+ token_endpoint: "https://stack.palantir.com/multipass/api/oauth2/token",
33
+ authorization_endpoint: "https://stack.palantir.com/multipass/api/oauth2/authorize",
34
+ revocation_endpoint: "https://stack.palantir.com/multipass/api/oauth2/revoke_token",
35
+ issuer: "https://stack.palantir.com/multipass"
36
+ });
37
+ const authServerCustom = createAuthorizationServer("multipass", "https://stack.palantir.com/foo/first/someStuff");
38
+ expect(authServerCustom).toEqual({
39
+ token_endpoint: "https://stack.palantir.com/foo/first/someStuff/multipass/api/oauth2/token",
40
+ authorization_endpoint: "https://stack.palantir.com/foo/first/someStuff/multipass/api/oauth2/authorize",
41
+ revocation_endpoint: "https://stack.palantir.com/foo/first/someStuff/multipass/api/oauth2/revoke_token",
42
+ issuer: "https://stack.palantir.com/foo/first/someStuff/multipass"
43
+ });
44
+ const authServerCustomWithTrailingSlash = createAuthorizationServer("multipass", "https://stack.palantir.com/foo/first/someStuff/");
45
+ expect(authServerCustomWithTrailingSlash).toEqual({
46
+ token_endpoint: "https://stack.palantir.com/foo/first/someStuff/multipass/api/oauth2/token",
47
+ authorization_endpoint: "https://stack.palantir.com/foo/first/someStuff/multipass/api/oauth2/authorize",
48
+ revocation_endpoint: "https://stack.palantir.com/foo/first/someStuff/multipass/api/oauth2/revoke_token",
49
+ issuer: "https://stack.palantir.com/foo/first/someStuff/multipass"
50
+ });
51
+ });
52
+ });
53
+ //# sourceMappingURL=AuthorizationServer.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthorizationServer.test.js","names":["describe","expect","it","createAuthorizationServer","authServer","toEqual","token_endpoint","authorization_endpoint","revocation_endpoint","issuer","authServerCustom","authServerCustomWithTrailingSlash"],"sources":["AuthorizationServer.test.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { describe, expect, it } from \"vitest\";\n\nimport { createAuthorizationServer } from \"./common.js\";\n\ndescribe(\"Create authorization server\", () => {\n it(\"works with old multipass ctx path\", () => {\n const authServer = createAuthorizationServer(\n \"/multipass\",\n \"https://stack.palantir.com\",\n );\n expect(authServer).toEqual({\n token_endpoint: \"https://stack.palantir.com/multipass/api/oauth2/token\",\n authorization_endpoint:\n \"https://stack.palantir.com/multipass/api/oauth2/authorize\",\n revocation_endpoint:\n \"https://stack.palantir.com/multipass/api/oauth2/revoke_token\",\n issuer: \"https://stack.palantir.com/multipass\",\n });\n });\n\n it(\"works with new multipass ctx path\", () => {\n const authServer = createAuthorizationServer(\n \"multipass\",\n \"https://stack.palantir.com\",\n );\n expect(authServer).toEqual({\n token_endpoint: \"https://stack.palantir.com/multipass/api/oauth2/token\",\n authorization_endpoint:\n \"https://stack.palantir.com/multipass/api/oauth2/authorize\",\n revocation_endpoint:\n \"https://stack.palantir.com/multipass/api/oauth2/revoke_token\",\n issuer: \"https://stack.palantir.com/multipass\",\n });\n\n const authServerCustom = createAuthorizationServer(\n \"multipass\",\n \"https://stack.palantir.com/foo/first/someStuff\",\n );\n expect(authServerCustom).toEqual({\n token_endpoint:\n \"https://stack.palantir.com/foo/first/someStuff/multipass/api/oauth2/token\",\n authorization_endpoint:\n \"https://stack.palantir.com/foo/first/someStuff/multipass/api/oauth2/authorize\",\n revocation_endpoint:\n \"https://stack.palantir.com/foo/first/someStuff/multipass/api/oauth2/revoke_token\",\n issuer: \"https://stack.palantir.com/foo/first/someStuff/multipass\",\n });\n const authServerCustomWithTrailingSlash = createAuthorizationServer(\n \"multipass\",\n \"https://stack.palantir.com/foo/first/someStuff/\",\n );\n expect(authServerCustomWithTrailingSlash).toEqual({\n token_endpoint:\n \"https://stack.palantir.com/foo/first/someStuff/multipass/api/oauth2/token\",\n authorization_endpoint:\n \"https://stack.palantir.com/foo/first/someStuff/multipass/api/oauth2/authorize\",\n revocation_endpoint:\n \"https://stack.palantir.com/foo/first/someStuff/multipass/api/oauth2/revoke_token\",\n issuer: \"https://stack.palantir.com/foo/first/someStuff/multipass\",\n });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAE7C,SAASC,yBAAyB,QAAQ,aAAa;AAEvDH,QAAQ,CAAC,6BAA6B,EAAE,MAAM;EAC5CE,EAAE,CAAC,mCAAmC,EAAE,MAAM;IAC5C,MAAME,UAAU,GAAGD,yBAAyB,CAC1C,YAAY,EACZ,4BACF,CAAC;IACDF,MAAM,CAACG,UAAU,CAAC,CAACC,OAAO,CAAC;MACzBC,cAAc,EAAE,uDAAuD;MACvEC,sBAAsB,EACpB,2DAA2D;MAC7DC,mBAAmB,EACjB,8DAA8D;MAChEC,MAAM,EAAE;IACV,CAAC,CAAC;EACJ,CAAC,CAAC;EAEFP,EAAE,CAAC,mCAAmC,EAAE,MAAM;IAC5C,MAAME,UAAU,GAAGD,yBAAyB,CAC1C,WAAW,EACX,4BACF,CAAC;IACDF,MAAM,CAACG,UAAU,CAAC,CAACC,OAAO,CAAC;MACzBC,cAAc,EAAE,uDAAuD;MACvEC,sBAAsB,EACpB,2DAA2D;MAC7DC,mBAAmB,EACjB,8DAA8D;MAChEC,MAAM,EAAE;IACV,CAAC,CAAC;IAEF,MAAMC,gBAAgB,GAAGP,yBAAyB,CAChD,WAAW,EACX,gDACF,CAAC;IACDF,MAAM,CAACS,gBAAgB,CAAC,CAACL,OAAO,CAAC;MAC/BC,cAAc,EACZ,2EAA2E;MAC7EC,sBAAsB,EACpB,+EAA+E;MACjFC,mBAAmB,EACjB,kFAAkF;MACpFC,MAAM,EAAE;IACV,CAAC,CAAC;IACF,MAAME,iCAAiC,GAAGR,yBAAyB,CACjE,WAAW,EACX,iDACF,CAAC;IACDF,MAAM,CAACU,iCAAiC,CAAC,CAACN,OAAO,CAAC;MAChDC,cAAc,EACZ,2EAA2E;MAC7EC,sBAAsB,EACpB,+EAA+E;MACjFC,mBAAmB,EACjB,kFAAkF;MACpFC,MAAM,EAAE;IACV,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -1,17 +1,2 @@
1
- /*
2
- * Copyright 2024 Palantir Technologies, Inc. All rights reserved.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
1
  export {};
17
2
  //# sourceMappingURL=BaseOauthClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseOauthClient.js","names":[],"sources":["BaseOauthClient.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport {};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"BaseOauthClient.js","names":[],"sources":["BaseOauthClient.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Token } from \"./Token.js\";\n\nexport type Events = {\n signIn: CustomEvent<Token>;\n signOut: Event;\n refresh: CustomEvent<Token>;\n};\n\nexport interface BaseOauthClient<K extends keyof Events & string> {\n (): Promise<string>;\n\n getTokenOrUndefined: () => string | undefined;\n signIn: () => Promise<Token>;\n signOut: () => Promise<void>;\n\n addEventListener: <T extends K>(\n type: T,\n listener: ((evt: Events[T]) => void) | null,\n options?: boolean | AddEventListenerOptions,\n ) => void;\n\n removeEventListener: <T extends K>(\n type: T,\n callback: ((evt: Events[T]) => void) | null,\n options?: EventListenerOptions | boolean,\n ) => void;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,17 +1,2 @@
1
- /*
2
- * Copyright 2024 Palantir Technologies, Inc. All rights reserved.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
1
  export {};
17
2
  //# sourceMappingURL=ConfidentialOauthClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConfidentialOauthClient.js","names":[],"sources":["ConfidentialOauthClient.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport {};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"ConfidentialOauthClient.js","names":[],"sources":["ConfidentialOauthClient.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { BaseOauthClient } from \"./BaseOauthClient.js\";\n\nexport interface ConfidentialOauthClient\n extends BaseOauthClient<\"signIn\" | \"signOut\">\n{\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,17 +1,2 @@
1
- /*
2
- * Copyright 2024 Palantir Technologies, Inc. All rights reserved.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
1
  export {};
17
2
  //# sourceMappingURL=PublicOauthClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PublicOauthClient.js","names":[],"sources":["PublicOauthClient.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport {};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"PublicOauthClient.js","names":[],"sources":["PublicOauthClient.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { BaseOauthClient } from \"./BaseOauthClient.js\";\nimport type { Token } from \"./Token.js\";\n\nexport interface PublicOauthClient\n extends BaseOauthClient<\"signIn\" | \"signOut\" | \"refresh\">\n{\n refresh: () => Promise<Token | undefined>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,17 +1,2 @@
1
- /*
2
- * Copyright 2024 Palantir Technologies, Inc. All rights reserved.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
1
  export {};
17
2
  //# sourceMappingURL=Token.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Token.js","names":[],"sources":["Token.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport {};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"Token.js","names":[],"sources":["Token.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface Token {\n readonly access_token: string;\n readonly expires_in: number;\n readonly refresh_token?: string;\n readonly expires_at: number;\n}\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,59 @@
1
+ /*
2
+ * Copyright 2024 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { createPublicOauthClient } from "@osdk/oauth";
18
+ import * as oauthModule from "@osdk/oauth";
19
+ import { describe, expect, it, vi } from "vitest";
20
+ import * as utilsModule from "../utils.js";
21
+ const originalCreatePublicOauthClient = oauthModule.createPublicOauthClient;
22
+ const FOUNDRY_CLIENT_ID = "example-foundry-client-id";
23
+ const FOUNDRY_URL = "http://example-foundry-url.com";
24
+ const REDIRECT_URI = "http://localhost:8080/auth/callback";
25
+ vi.stubGlobal("window", {
26
+ location: {
27
+ toString: vi.fn().mockReturnValue("http://example.com")
28
+ }
29
+ });
30
+ describe("createPublicOauthClient", () => {
31
+ it("should return the same processed options for both client creation methods", async () => {
32
+ const mockProcessOptionsAndAssignDefaults = vi.fn();
33
+
34
+ // Mock processOptionsAndAssignDefaults to call the mock function
35
+ vi.spyOn(utilsModule, "processOptionsAndAssignDefaults").mockImplementation((...args) => {
36
+ mockProcessOptionsAndAssignDefaults(...args);
37
+ return utilsModule.processOptionsAndAssignDefaults(...args);
38
+ });
39
+
40
+ // Mock createPublicOauthClient to call both the mock and the original function
41
+ vi.spyOn(oauthModule, "createPublicOauthClient").mockImplementation((...args) => {
42
+ const [_client_id, ...rest] = args;
43
+ mockProcessOptionsAndAssignDefaults(...rest);
44
+ return originalCreatePublicOauthClient(...args);
45
+ });
46
+ const authClient = createPublicOauthClient(FOUNDRY_CLIENT_ID, FOUNDRY_URL, REDIRECT_URI, true, undefined, undefined, undefined, fetch, undefined);
47
+ expect(authClient).toBeDefined();
48
+ expect(mockProcessOptionsAndAssignDefaults).toHaveBeenCalledTimes(1);
49
+ const authClientWithOptions = createPublicOauthClient(FOUNDRY_CLIENT_ID, FOUNDRY_URL, REDIRECT_URI, {
50
+ useHistory: true,
51
+ fetchFn: fetch
52
+ });
53
+ expect(authClientWithOptions).toBeDefined();
54
+ expect(mockProcessOptionsAndAssignDefaults).toHaveBeenCalledTimes(2);
55
+ const [result1, result2] = mockProcessOptionsAndAssignDefaults.mock.results;
56
+ expect(result1.value).toEqual(result2.value);
57
+ });
58
+ });
59
+ //# sourceMappingURL=createPublicOauthClient.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createPublicOauthClient.test.js","names":["createPublicOauthClient","oauthModule","describe","expect","it","vi","utilsModule","originalCreatePublicOauthClient","FOUNDRY_CLIENT_ID","FOUNDRY_URL","REDIRECT_URI","stubGlobal","location","toString","fn","mockReturnValue","mockProcessOptionsAndAssignDefaults","spyOn","mockImplementation","args","processOptionsAndAssignDefaults","_client_id","rest","authClient","undefined","fetch","toBeDefined","toHaveBeenCalledTimes","authClientWithOptions","useHistory","fetchFn","result1","result2","mock","results","value","toEqual"],"sources":["createPublicOauthClient.test.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createPublicOauthClient } from \"@osdk/oauth\";\nimport * as oauthModule from \"@osdk/oauth\";\nimport { describe, expect, it, vi } from \"vitest\";\nimport * as utilsModule from \"../utils.js\";\n\nconst originalCreatePublicOauthClient = oauthModule.createPublicOauthClient;\n\nconst FOUNDRY_CLIENT_ID = \"example-foundry-client-id\";\nconst FOUNDRY_URL = \"http://example-foundry-url.com\";\nconst REDIRECT_URI = \"http://localhost:8080/auth/callback\";\n\nvi.stubGlobal(\"window\", {\n location: {\n toString: vi.fn().mockReturnValue(\"http://example.com\"),\n },\n});\n\ntype CreatePublicOauthClientParams = Parameters<typeof createPublicOauthClient>;\n\ntype ProcessedPublicOauthClientOptionsParams = Parameters<\n typeof utilsModule.processOptionsAndAssignDefaults\n>;\n\ntype ProcessedPublicOauthClientOptionsReturn = ReturnType<\n typeof utilsModule.processOptionsAndAssignDefaults\n>;\n\ndescribe(\"createPublicOauthClient\", () => {\n it(\"should return the same processed options for both client creation methods\", async () => {\n const mockProcessOptionsAndAssignDefaults = vi.fn<\n (\n ...args: ProcessedPublicOauthClientOptionsParams\n ) => ProcessedPublicOauthClientOptionsReturn\n >();\n\n // Mock processOptionsAndAssignDefaults to call the mock function\n vi.spyOn(utilsModule, \"processOptionsAndAssignDefaults\").mockImplementation(\n (\n ...args: ProcessedPublicOauthClientOptionsParams\n ) => {\n mockProcessOptionsAndAssignDefaults(...args);\n return utilsModule.processOptionsAndAssignDefaults(...args);\n },\n );\n\n // Mock createPublicOauthClient to call both the mock and the original function\n vi.spyOn(oauthModule, \"createPublicOauthClient\").mockImplementation(\n (\n ...args: CreatePublicOauthClientParams\n ) => {\n const [_client_id, ...rest] = args;\n mockProcessOptionsAndAssignDefaults(...rest);\n return originalCreatePublicOauthClient(...args);\n },\n );\n\n const authClient = createPublicOauthClient(\n FOUNDRY_CLIENT_ID,\n FOUNDRY_URL,\n REDIRECT_URI,\n true,\n undefined,\n undefined,\n undefined,\n fetch,\n undefined,\n );\n\n expect(authClient).toBeDefined();\n expect(mockProcessOptionsAndAssignDefaults).toHaveBeenCalledTimes(1);\n\n const authClientWithOptions = createPublicOauthClient(\n FOUNDRY_CLIENT_ID,\n FOUNDRY_URL,\n REDIRECT_URI,\n {\n useHistory: true,\n fetchFn: fetch,\n },\n );\n\n expect(authClientWithOptions).toBeDefined();\n expect(mockProcessOptionsAndAssignDefaults).toHaveBeenCalledTimes(2);\n\n const [result1, result2] = mockProcessOptionsAndAssignDefaults.mock.results;\n expect(result1.value).toEqual(result2.value);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,uBAAuB,QAAQ,aAAa;AACrD,OAAO,KAAKC,WAAW,MAAM,aAAa;AAC1C,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,QAAQ;AACjD,OAAO,KAAKC,WAAW,MAAM,aAAa;AAE1C,MAAMC,+BAA+B,GAAGN,WAAW,CAACD,uBAAuB;AAE3E,MAAMQ,iBAAiB,GAAG,2BAA2B;AACrD,MAAMC,WAAW,GAAG,gCAAgC;AACpD,MAAMC,YAAY,GAAG,qCAAqC;AAE1DL,EAAE,CAACM,UAAU,CAAC,QAAQ,EAAE;EACtBC,QAAQ,EAAE;IACRC,QAAQ,EAAER,EAAE,CAACS,EAAE,CAAC,CAAC,CAAC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,CAAC,CAAC,CAAC;IAEpE,MAAM,CAACI,OAAO,EAAEC,OAAO,CAAC,GAAGhB,mCAAmC,CAACiB,IAAI,CAACC,OAAO;IAC3E/B,MAAM,CAAC4B,OAAO,CAACI,KAAK,CAAC,CAACC,OAAO,CAACJ,OAAO,CAACG,KAAK,CAAC;EAC9C,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+
16
17
  import { processRevocationResponse, revocationRequest } from "oauth4webapi";
17
18
  import invariant from "tiny-invariant";
18
19
  import { TypedEventTarget } from "typescript-event-target";
@@ -20,21 +21,36 @@ import { throwIfError } from "./throwIfError.js";
20
21
  // Node 18 is supposed to have a `CustomEvent` but it is not exposed on `globalThis`
21
22
  // which creates a problem for making a single codebase for node and browser. This polyfill works around it
22
23
  const CustomEvent = globalThis.CustomEvent;
23
- const localStorage = globalThis.localStorage;
24
+ function localStorageKey(client) {
25
+ return `@osdk/oauth : refresh : ${client.client_id}`;
26
+ }
24
27
  export function saveLocal(client, x) {
25
28
  // MUST `localStorage?` as nodejs does not have localStorage
26
- localStorage?.setItem(`@osdk/oauth : refresh : ${client.client_id}`, JSON.stringify(x));
29
+ globalThis.localStorage?.setItem(localStorageKey(client), JSON.stringify(x));
27
30
  }
28
31
  export function removeLocal(client) {
29
32
  // MUST `localStorage?` as nodejs does not have localStorage
30
- localStorage?.removeItem(`@osdk/oauth : refresh : ${client.client_id}`);
33
+ globalThis.localStorage?.removeItem(localStorageKey(client));
31
34
  }
32
35
  export function readLocal(client) {
33
36
  return JSON.parse(
34
37
  // MUST `localStorage?` as nodejs does not have localStorage
35
- localStorage?.getItem(`@osdk/oauth : refresh : ${client.client_id}`) ?? "{}");
38
+ globalThis.localStorage?.getItem(localStorageKey(client)) ?? "{}");
39
+ }
40
+ export function saveSession(client, x) {
41
+ // MUST `sessionStorage?` as nodejs does not have sessionStorage
42
+ globalThis.sessionStorage?.setItem(localStorageKey(client), JSON.stringify(x));
43
+ }
44
+ export function removeSession(client) {
45
+ // MUST `sessionStorage?` as nodejs does not have sessionStorage
46
+ globalThis.sessionStorage?.removeItem(localStorageKey(client));
36
47
  }
37
- export function common(client, as, _signIn, oauthHttpOptions, refresh) {
48
+ export function readSession(client) {
49
+ return JSON.parse(
50
+ // MUST `sessionStorage?` as nodejs does not have sessionStorage
51
+ globalThis.sessionStorage?.getItem(localStorageKey(client)) ?? "{}");
52
+ }
53
+ export function common(client, as, _signIn, oauthHttpOptions, refresh, refreshTokenMarker) {
38
54
  let token;
39
55
  const eventTarget = new TypedEventTarget();
40
56
  function makeTokenAndSaveRefresh(resp, type) {
@@ -45,7 +61,8 @@ export function common(client, as, _signIn, oauthHttpOptions, refresh) {
45
61
  } = resp;
46
62
  !(expires_in != null) ? process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
47
63
  saveLocal(client, {
48
- refresh_token
64
+ refresh_token,
65
+ refreshTokenMarker
49
66
  });
50
67
  token = {
51
68
  refresh_token,
@@ -100,6 +117,7 @@ export function common(client, as, _signIn, oauthHttpOptions, refresh) {
100
117
  !token ? process.env.NODE_ENV !== "production" ? invariant(false, "not signed in") : invariant(false) : void 0;
101
118
  const result = await processRevocationResponse(await revocationRequest(as, client, token.access_token, oauthHttpOptions));
102
119
  rmTimeout();
120
+
103
121
  // Clean up
104
122
  removeLocal(client);
105
123
  token = undefined;
@@ -117,7 +135,7 @@ export function common(client, as, _signIn, oauthHttpOptions, refresh) {
117
135
  };
118
136
  }
119
137
  export function createAuthorizationServer(ctxPath, url) {
120
- const issuer = `${new URL(ctxPath, url)}`;
138
+ const issuer = `${new URL(ctxPath, url.endsWith("/") ? url : url + "/")}`;
121
139
  return {
122
140
  token_endpoint: `${issuer}/api/oauth2/token`,
123
141
  authorization_endpoint: `${issuer}/api/oauth2/authorize`,
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","names":["processRevocationResponse","revocationRequest","invariant","TypedEventTarget","throwIfError","CustomEvent","globalThis","localStorage","saveLocal","client","x","setItem","client_id","JSON","stringify","removeLocal","removeItem","readLocal","parse","getItem","common","as","_signIn","oauthHttpOptions","refresh","token","eventTarget","makeTokenAndSaveRefresh","resp","type","refresh_token","expires_in","access_token","process","env","NODE_ENV","expires_at","Date","now","dispatchTypedEvent","detail","refreshTimeout","rmTimeout","clearTimeout","restartRefreshTimer","evt","setTimeout","pendingSignIn","signIn","undefined","addEventListener","getTokenOrUndefined","getToken","Object","assign","signOut","result","Event","bind","removeEventListener","createAuthorizationServer","ctxPath","url","issuer","URL","token_endpoint","authorization_endpoint","revocation_endpoint"],"sources":["common.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { processRevocationResponse, revocationRequest } from \"oauth4webapi\";\nimport invariant from \"tiny-invariant\";\nimport { TypedEventTarget } from \"typescript-event-target\";\nimport { throwIfError } from \"./throwIfError.js\";\n// Node 18 is supposed to have a `CustomEvent` but it is not exposed on `globalThis`\n// which creates a problem for making a single codebase for node and browser. This polyfill works around it\nconst CustomEvent = process.env.TARGET === \"browser\"\n ? globalThis.CustomEvent\n : globalThis.CustomEvent\n ?? class CustomEvent extends Event {\n #detail;\n constructor(type, options) {\n super(type, options);\n this.#detail = options?.detail ?? null;\n }\n get detail() {\n return this.#detail;\n }\n };\nconst localStorage = globalThis.localStorage;\nexport function saveLocal(client, x) {\n // MUST `localStorage?` as nodejs does not have localStorage\n localStorage?.setItem(`@osdk/oauth : refresh : ${client.client_id}`, JSON.stringify(x));\n}\nexport function removeLocal(client) {\n // MUST `localStorage?` as nodejs does not have localStorage\n localStorage?.removeItem(`@osdk/oauth : refresh : ${client.client_id}`);\n}\nexport function readLocal(client) {\n return JSON.parse(\n // MUST `localStorage?` as nodejs does not have localStorage\n localStorage?.getItem(`@osdk/oauth : refresh : ${client.client_id}`)\n ?? \"{}\");\n}\nexport function common(client, as, _signIn, oauthHttpOptions, refresh) {\n let token;\n const eventTarget = new TypedEventTarget();\n function makeTokenAndSaveRefresh(resp, type) {\n const { refresh_token, expires_in, access_token } = resp;\n invariant(expires_in != null);\n saveLocal(client, { refresh_token });\n token = {\n refresh_token,\n expires_in,\n access_token,\n expires_at: Date.now() + expires_in * 1000,\n };\n eventTarget.dispatchTypedEvent(type, new CustomEvent(type, { detail: token }));\n return token;\n }\n let refreshTimeout;\n function rmTimeout() {\n if (refreshTimeout)\n clearTimeout(refreshTimeout);\n }\n function restartRefreshTimer(evt) {\n if (refresh) {\n rmTimeout();\n refreshTimeout = setTimeout(refresh, evt.detail.expires_in * 1000 - 60 * 1000);\n }\n }\n async function signOut() {\n invariant(token, \"not signed in\");\n const result = await processRevocationResponse(await revocationRequest(as, client, token.access_token, oauthHttpOptions));\n rmTimeout();\n // Clean up\n removeLocal(client);\n token = undefined;\n throwIfError(result);\n eventTarget.dispatchTypedEvent(\"signOut\", new Event(\"signOut\"));\n }\n let pendingSignIn;\n async function signIn() {\n if (pendingSignIn) {\n return pendingSignIn;\n }\n try {\n pendingSignIn = _signIn();\n return await pendingSignIn;\n }\n finally {\n pendingSignIn = undefined;\n }\n }\n eventTarget.addEventListener(\"signIn\", restartRefreshTimer);\n eventTarget.addEventListener(\"refresh\", restartRefreshTimer);\n function getTokenOrUndefined() {\n if (!token || Date.now() >= token.expires_at) {\n return undefined;\n }\n return token?.access_token;\n }\n const getToken = Object.assign(async function getToken() {\n if (!token || Date.now() >= token.expires_at) {\n token = await signIn();\n }\n return token?.access_token;\n }, {\n signIn,\n refresh,\n signOut,\n rmTimeout,\n getTokenOrUndefined,\n addEventListener: eventTarget.addEventListener.bind(eventTarget),\n removeEventListener: eventTarget.removeEventListener.bind(eventTarget),\n });\n return { getToken, makeTokenAndSaveRefresh };\n}\nexport function createAuthorizationServer(ctxPath, url) {\n const issuer = `${new URL(ctxPath, url)}`;\n return {\n token_endpoint: `${issuer}/api/oauth2/token`,\n authorization_endpoint: `${issuer}/api/oauth2/authorize`,\n revocation_endpoint: `${issuer}/api/oauth2/revoke_token`,\n issuer,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,yBAAyB,EAAEC,iBAAiB,QAAQ,cAAc;AAC3E,OAAOC,SAAS,MAAM,gBAAgB;AACtC,SAASC,gBAAgB,QAAQ,yBAAyB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AAChD;AACA;AACA,MAAMC,WAAW,GACXC,UAAU,CAACD,WAWR;AACT,MAAME,YAAY,GAAGD,UAAU,CAACC,YAAY;AAC5C,OAAO,SAASC,SAASA,CAACC,MAAM,EAAEC,CAAC,EAAE;EACjC;EACAH,YAAY,EAAEI,OAAO,CAAC,2BAA2BF,MAAM,CAACG,SAAS,EAAE,EAAEC,IAAI,CAACC,SAAS,CAACJ,CAAC,CAAC,CAAC;AAC3F;AACA,OAAO,SAASK,WAAWA,CAACN,MAAM,EAAE;EAChC;EACAF,YAAY,EAAES,UAAU,CAAC,2BAA2BP,MAAM,CAACG,SAAS,EAAE,CAAC;AAC3E;AACA,OAAO,SAASK,SAASA,CAACR,MAAM,EAAE;EAC9B,OAAOI,IAAI,CAACK,KAAK;EACjB;EACAX,YAAY,EAAEY,OAAO,CAAC,2BAA2BV,MAAM,CAACG,SAAS,EAAE,CAAC,IAC7D,IAAI,CAAC;AAChB;AACA,OAAO,SAASQ,MAAMA,CAACX,MAAM,EAAEY,EAAE,EAAEC,OAAO,EAAEC,gBAAgB,EAAEC,OAAO,EAAE;EACnE,I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B,EAAEjC,WAAW,CAACiC,mBAAmB,CAACD,IAAI,CAAChC,WAAW;EACzE,CAAC,CAAC;EACF,OAAO;IAAE0B,QAAQ;IAAEzB;EAAwB,CAAC;AAChD;AACA,OAAO,SAASiC,yBAAyBA,CAACC,OAAO,EAAEC,GAAG,EAAE;EACpD,MAAMC,MAAM,GAAG,GAAG,IAAIC,GAAG,CAACH,OAAO,EAAEC,GAAG,CAAC,EAAE;EACzC,OAAO;IACHG,cAAc,EAAE,GAAGF,MAAM,mBAAmB;IAC5CG,sBAAsB,EAAE,GAAGH,MAAM,uBAAuB;IACxDI,mBAAmB,EAAE,GAAGJ,MAAM,0BAA0B;IACxDA;EACJ,CAAC;AACL","ignoreList":[]}
1
+ {"version":3,"file":"common.js","names":["processRevocationResponse","revocationRequest","invariant","TypedEventTarget","throwIfError","CustomEvent","globalThis","localStorageKey","client","client_id","saveLocal","x","localStorage","setItem","JSON","stringify","removeLocal","removeItem","readLocal","parse","getItem","saveSession","sessionStorage","removeSession","readSession","common","as","_signIn","oauthHttpOptions","refresh","refreshTokenMarker","token","eventTarget","makeTokenAndSaveRefresh","resp","type","refresh_token","expires_in","access_token","process","env","NODE_ENV","expires_at","Date","now","dispatchTypedEvent","detail","refreshTimeout","rmTimeout","clearTimeout","restartRefreshTimer","evt","setTimeout","pendingSignIn","signIn","undefined","addEventListener","getTokenOrUndefined","getToken","Object","assign","signOut","result","Event","bind","removeEventListener","createAuthorizationServer","ctxPath","url","issuer","URL","endsWith","token_endpoint","authorization_endpoint","revocation_endpoint"],"sources":["common.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n AuthorizationServer,\n Client,\n HttpRequestOptions,\n OAuth2TokenEndpointResponse,\n} from \"oauth4webapi\";\nimport { processRevocationResponse, revocationRequest } from \"oauth4webapi\";\nimport invariant from \"tiny-invariant\";\nimport { TypedEventTarget } from \"typescript-event-target\";\nimport type { BaseOauthClient, Events } from \"./BaseOauthClient.js\";\nimport { throwIfError } from \"./throwIfError.js\";\nimport type { Token } from \"./Token.js\";\n\n// Node 18 is supposed to have a `CustomEvent` but it is not exposed on `globalThis`\n// which creates a problem for making a single codebase for node and browser. This polyfill works around it\nconst CustomEvent = process.env.TARGET === \"browser\"\n ? globalThis.CustomEvent\n : globalThis.CustomEvent\n ?? class CustomEvent<T> extends Event {\n #detail: T | null;\n\n constructor(type: string, options: EventInit & { detail: T }) {\n super(type, options);\n this.#detail = options?.detail ?? null;\n }\n\n get detail() {\n return this.#detail;\n }\n };\n\ndeclare const process: {\n env: Record<string, string | undefined>;\n};\n\nexport interface LocalStorageState {\n refresh_token?: string;\n refreshTokenMarker?: string;\n}\n\nexport type SessionStorageState =\n // when we are going to the login page\n | {\n codeVerifier?: never;\n state?: never;\n oldUrl: string;\n }\n // when we are redirecting to oauth login\n | {\n codeVerifier: string;\n state: string;\n oldUrl: string;\n }\n // when we have the refresh token\n | {\n codeVerifier?: never;\n state?: never;\n oldUrl?: never;\n };\n\nfunction localStorageKey(client: Client) {\n return `@osdk/oauth : refresh : ${client.client_id}`;\n}\n\nexport function saveLocal(client: Client, x: LocalStorageState): void {\n // MUST `localStorage?` as nodejs does not have localStorage\n globalThis.localStorage?.setItem(\n localStorageKey(client),\n JSON.stringify(x),\n );\n}\n\nexport function removeLocal(client: Client): void {\n // MUST `localStorage?` as nodejs does not have localStorage\n globalThis.localStorage?.removeItem(\n localStorageKey(client),\n );\n}\n\nexport function readLocal(client: Client): LocalStorageState {\n return JSON.parse(\n // MUST `localStorage?` as nodejs does not have localStorage\n globalThis.localStorage?.getItem(\n localStorageKey(client),\n )\n ?? \"{}\",\n );\n}\n\nexport function saveSession(client: Client, x: SessionStorageState): void {\n // MUST `sessionStorage?` as nodejs does not have sessionStorage\n globalThis.sessionStorage?.setItem(\n localStorageKey(client),\n JSON.stringify(x),\n );\n}\n\nexport function removeSession(client: Client): void {\n // MUST `sessionStorage?` as nodejs does not have sessionStorage\n globalThis.sessionStorage?.removeItem(\n localStorageKey(client),\n );\n}\n\nexport function readSession(client: Client): SessionStorageState {\n return JSON.parse(\n // MUST `sessionStorage?` as nodejs does not have sessionStorage\n globalThis.sessionStorage?.getItem(\n localStorageKey(client),\n )\n ?? \"{}\",\n );\n}\n\nexport function common<\n R extends undefined | (() => Promise<Token | undefined>),\n>(\n client: Client,\n as: AuthorizationServer,\n _signIn: () => Promise<Token>,\n oauthHttpOptions: HttpRequestOptions,\n refresh: R,\n refreshTokenMarker: string | undefined,\n): {\n getToken: BaseOauthClient<keyof Events & string> & { refresh: R };\n makeTokenAndSaveRefresh: (\n resp: OAuth2TokenEndpointResponse,\n type: \"signIn\" | \"refresh\",\n ) => Token;\n} {\n let token: Token | undefined;\n const eventTarget = new TypedEventTarget<Events>();\n\n function makeTokenAndSaveRefresh(\n resp: OAuth2TokenEndpointResponse,\n type: \"signIn\" | \"refresh\",\n ): Token {\n const { refresh_token, expires_in, access_token } = resp;\n invariant(expires_in != null);\n saveLocal(client, {\n refresh_token,\n refreshTokenMarker,\n });\n token = {\n refresh_token,\n expires_in,\n access_token,\n expires_at: Date.now() + expires_in * 1000,\n };\n\n eventTarget.dispatchTypedEvent(\n type,\n new CustomEvent(\n type,\n { detail: token },\n ),\n );\n return token;\n }\n\n let refreshTimeout: ReturnType<typeof setTimeout>;\n function rmTimeout() {\n if (refreshTimeout) clearTimeout(refreshTimeout);\n }\n function restartRefreshTimer(evt: CustomEvent<Token>) {\n if (refresh) {\n rmTimeout();\n refreshTimeout = setTimeout(\n refresh,\n evt.detail.expires_in * 1000 - 60 * 1000,\n );\n }\n }\n\n async function signOut() {\n invariant(token, \"not signed in\");\n\n const result = await processRevocationResponse(\n await revocationRequest(\n as,\n client,\n token.access_token,\n oauthHttpOptions,\n ),\n );\n\n rmTimeout();\n\n // Clean up\n removeLocal(client);\n token = undefined;\n throwIfError(result);\n eventTarget.dispatchTypedEvent(\"signOut\", new Event(\"signOut\"));\n }\n\n let pendingSignIn: Promise<Token> | undefined;\n async function signIn() {\n if (pendingSignIn) {\n return pendingSignIn;\n }\n try {\n pendingSignIn = _signIn();\n return await pendingSignIn;\n } finally {\n pendingSignIn = undefined;\n }\n }\n\n eventTarget.addEventListener(\"signIn\", restartRefreshTimer);\n eventTarget.addEventListener(\"refresh\", restartRefreshTimer);\n\n function getTokenOrUndefined() {\n if (!token || Date.now() >= token.expires_at) {\n return undefined;\n }\n return token?.access_token;\n }\n\n const getToken = Object.assign(async function getToken() {\n if (!token || Date.now() >= token.expires_at) {\n token = await signIn();\n }\n return token?.access_token;\n }, {\n signIn,\n refresh,\n signOut,\n rmTimeout,\n getTokenOrUndefined,\n addEventListener: eventTarget.addEventListener.bind(\n eventTarget,\n ) as typeof eventTarget.addEventListener,\n removeEventListener: eventTarget.removeEventListener.bind(\n eventTarget,\n ) as typeof eventTarget.removeEventListener,\n });\n\n return { getToken, makeTokenAndSaveRefresh };\n}\n\nexport function createAuthorizationServer(\n ctxPath: string,\n url: string,\n): Required<\n Pick<\n AuthorizationServer,\n | \"issuer\"\n | \"token_endpoint\"\n | \"authorization_endpoint\"\n | \"revocation_endpoint\"\n >\n> {\n const issuer = `${new URL(ctxPath, url.endsWith(\"/\") ? url : url + \"/\")}`;\n return {\n token_endpoint: `${issuer}/api/oauth2/token`,\n authorization_endpoint: `${issuer}/api/oauth2/authorize`,\n revocation_endpoint: `${issuer}/api/oauth2/revoke_token`,\n issuer,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SAAS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AW,CAACa,kBAAkB,CAAC,SAAS,EAAE,IAAIkB,KAAK,CAAC,SAAS,CAAC,CAAC;IACjE,CAiCS;IACPf,SAAS;IACTS,mBAAmB;IACnBD,gBAAgB,EAAExB,WAAW,CAACwB,gBAAgB,CAACQ,IAAI,CACjDhC,WACF,CAAwC;IACxCiC,mBAAmB,EAAEjC,WAAW,CAACiC,mBAAmB,CAACD,IAAI,CACvDhC,WACF;EACF,CAAC,CAAC;EAEF,OAAO;IAAE0B,QAAQ;IAAEzB;EAAwB,CAAC;AAC9C;AAEA,OAAO,SAASiC,yBAAyBA,CACvCC,OAAe,EACfC,GAAW,EASX;EACA,MAAMC,MAAM,GAAG,GAAG,IAAIC,GAAG,CAACH,OAAO,EAAEC,GAAG,CAACG,QAAQ,CAAC,GAAG,CAAC,GAAGH,GAAG,GAAGA,GAAG,GAAG,GAAG,CAAC,EAAE;EACzE,OAAO;IACLI,cAAc,EAAE,GAAGH,MAAM,mBAAmB;IAC5CI,sBAAsB,EAAE,GAAGJ,MAAM,uBAAuB;IACxDK,mBAAmB,EAAE,GAAGL,MAAM,0BAA0B;IACxDA;EACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,65 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
18
+ import { common, createAuthorizationServer, readLocal, removeLocal, saveLocal } from "./common.js";
19
+ describe("local functions", () => {
20
+ beforeEach(() => {
21
+ vi.stubGlobal("localStorage", {
22
+ setItem: vi.fn(),
23
+ removeItem: vi.fn(),
24
+ getItem: vi.fn()
25
+ });
26
+ });
27
+ afterEach(() => {
28
+ vi.unstubAllGlobals();
29
+ });
30
+ it("should use the old style keys when there is no refresh token marker", () => {
31
+ const client = {
32
+ client_id: "hi_mom",
33
+ $refreshTokenMarker: undefined
34
+ };
35
+ const oldLocalStorageKey = `@osdk/oauth : refresh : ${client.client_id}`;
36
+ readLocal(client);
37
+ removeLocal(client);
38
+ saveLocal(client, {});
39
+ expect(vi.mocked(globalThis.localStorage.getItem)).toBeCalledWith(oldLocalStorageKey);
40
+ expect(vi.mocked(globalThis.localStorage.setItem)).toBeCalledWith(oldLocalStorageKey, expect.anything());
41
+ expect(vi.mocked(globalThis.localStorage.removeItem)).toBeCalledWith(oldLocalStorageKey);
42
+ });
43
+ it("should save the refreshTokenMaker if it exists", () => {
44
+ const client = {
45
+ client_id: "hi_mom"
46
+ };
47
+ const signIn = vi.fn();
48
+ const refresh = vi.fn();
49
+ const authServer = createAuthorizationServer("multipass", "https://stack.palantir.com");
50
+ const {
51
+ makeTokenAndSaveRefresh
52
+ } = common(client, authServer, signIn, {}, refresh, "marker marker");
53
+ makeTokenAndSaveRefresh({
54
+ refresh_token: "refresh",
55
+ access_token: "access",
56
+ token_type: "idk",
57
+ expires_in: 10_000
58
+ }, "signIn");
59
+ expect(globalThis.localStorage.setItem).toBeCalledWith(`@osdk/oauth : refresh : ${client.client_id}`, JSON.stringify({
60
+ refresh_token: "refresh",
61
+ refreshTokenMarker: "marker marker"
62
+ }));
63
+ });
64
+ });
65
+ //# sourceMappingURL=common.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.test.js","names":["afterEach","beforeEach","describe","expect","it","vi","common","createAuthorizationServer","readLocal","removeLocal","saveLocal","stubGlobal","setItem","fn","removeItem","getItem","unstubAllGlobals","client","client_id","$refreshTokenMarker","undefined","oldLocalStorageKey","mocked","globalThis","localStorage","toBeCalledWith","anything","signIn","refresh","authServer","makeTokenAndSaveRefresh","refresh_token","access_token","token_type","expires_in","JSON","stringify","refreshTokenMarker"],"sources":["common.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { afterEach, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport {\n common,\n createAuthorizationServer,\n readLocal,\n removeLocal,\n saveLocal,\n} from \"./common.js\";\n\ndescribe(\"local functions\", () => {\n beforeEach(() => {\n vi.stubGlobal(\"localStorage\", {\n setItem: vi.fn(),\n removeItem: vi.fn(),\n getItem: vi.fn(),\n });\n });\n\n afterEach(() => {\n vi.unstubAllGlobals();\n });\n\n it(\"should use the old style keys when there is no refresh token marker\", () => {\n const client = {\n client_id: \"hi_mom\",\n $refreshTokenMarker: undefined,\n };\n\n const oldLocalStorageKey = `@osdk/oauth : refresh : ${client.client_id}`;\n\n readLocal(client);\n removeLocal(client);\n saveLocal(client, {});\n\n expect(vi.mocked(globalThis.localStorage.getItem)).toBeCalledWith(\n oldLocalStorageKey,\n );\n\n expect(vi.mocked(globalThis.localStorage.setItem)).toBeCalledWith(\n oldLocalStorageKey,\n expect.anything(),\n );\n\n expect(vi.mocked(globalThis.localStorage.removeItem)).toBeCalledWith(\n oldLocalStorageKey,\n );\n });\n\n it(\"should save the refreshTokenMaker if it exists\", () => {\n const client = {\n client_id: \"hi_mom\",\n };\n\n const signIn = vi.fn();\n const refresh = vi.fn();\n\n const authServer = createAuthorizationServer(\n \"multipass\",\n \"https://stack.palantir.com\",\n );\n\n const { makeTokenAndSaveRefresh } = common(\n client,\n authServer,\n signIn,\n {},\n refresh,\n \"marker marker\",\n );\n\n makeTokenAndSaveRefresh({\n refresh_token: \"refresh\",\n access_token: \"access\",\n token_type: \"idk\",\n expires_in: 10_000,\n }, \"signIn\");\n\n expect(globalThis.localStorage.setItem).toBeCalledWith(\n `@osdk/oauth : refresh : ${client.client_id}`,\n JSON.stringify({\n refresh_token: \"refresh\",\n refreshTokenMarker: \"marker marker\",\n }),\n );\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,QAAQ;AACxE,SACEC,MAAM,EACNC,yBAAyB,EACzBC,SAAS,EACTC,WAAW,EACXC,SAAS,QACJ,aAAa;AAEpBR,QAAQ,CAAC,iBAAiB,EAAE,MAAM;EAChCD,UAAU,CAAC,MAAM;IACfI,EAAE,CAACM,UAAU,CAAC,cAAc,EAAE;MAC5BC,OAAO,EAAEP,EAAE,CAACQ,EAAE,CAAC,CAAC;MAChBC,UAAU,EAAET,EAAE,CAACQ,EAAE,CAAC,CAAC;MACnBE,OAAO,EAAEV,EAAE,CAACQ,EAAE,CAAC;IACjB,CAAC,CAAC;EACJ,CAAC,CAAC;EAEFb,SAAS,CAAC,MAAM;IACdK,EAAE,CAACW,gBAAgB,CAAC,CAAC;EACvB,CAAC,CAAC;EAEFZ,EAAE,CAAC,qEAAqE,EAAE,MAAM;IAC9E,MAAMa,MAAM,GAAG;MACbC,SAAS,EAAE,QAAQ;MACnBC,mBAAmB,EAAEC;IACvB,CAAC;IAED,MAAMC,kBAAkB,GAAG,2BAA2BJ,MAAM,CAACC,SAAS,EAAE;IAExEV,SAAS,CAACS,MAAM,CAAC;IACjBR,WAAW,CAACQ,MAAM,CAAC;IACnBP,SAAS,CAACO,MAAM,EAAE,CAAC,CAAC,CAAC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ignoreList":[]}
@@ -13,9 +13,11 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+
16
17
  import { clientCredentialsGrantRequest, customFetch, processClientCredentialsResponse } from "oauth4webapi";
17
18
  import { common, createAuthorizationServer } from "./common.js";
18
19
  import { throwIfError } from "./throwIfError.js";
20
+
19
21
  /**
20
22
  * @param client_id
21
23
  * @param client_secret
@@ -25,7 +27,7 @@ import { throwIfError } from "./throwIfError.js";
25
27
  * @param ctxPath
26
28
  * @returns which can be used as a token provider
27
29
  */
28
- export function createConfidentialOauthClient(client_id, client_secret, url, scopes = ["api:read-data", "api:write-data"], fetchFn = globalThis.fetch, ctxPath = "/multipass") {
30
+ export function createConfidentialOauthClient(client_id, client_secret, url, scopes = ["api:read-data", "api:write-data"], fetchFn = globalThis.fetch, ctxPath = "multipass") {
29
31
  const client = {
30
32
  client_id,
31
33
  client_secret
@@ -41,7 +43,7 @@ export function createConfidentialOauthClient(client_id, client_secret, url, sco
41
43
  return makeTokenAndSaveRefresh(throwIfError(await processClientCredentialsResponse(authServer, client, await clientCredentialsGrantRequest(authServer, client, new URLSearchParams({
42
44
  scope: scopes.join(" ")
43
45
  }), oauthHttpOptions))), "signIn");
44
- }, oauthHttpOptions, undefined);
46
+ }, oauthHttpOptions, undefined, undefined);
45
47
  return getToken;
46
48
  }
47
49
  //# sourceMappingURL=createConfidentialOauthClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createConfidentialOauthClient.js","names":["clientCredentialsGrantRequest","customFetch","processClientCredentialsResponse","common","createAuthorizationServer","throwIfError","createConfidentialOauthClient","client_id","client_secret","url","scopes","fetchFn","globalThis","fetch","ctxPath","client","authServer","oauthHttpOptions","getToken","makeTokenAndSaveRefresh","URLSearchParams","scope","join","undefined"],"sources":["createConfidentialOauthClient.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { clientCredentialsGrantRequest, customFetch, processClientCredentialsResponse, } from \"oauth4webapi\";\nimport { common, createAuthorizationServer } from \"./common.js\";\nimport { throwIfError } from \"./throwIfError.js\";\n/**\n * @param client_id\n * @param client_secret\n * @param url the base url of your foundry server\n * @param scopes\n * @param fetchFn\n * @param ctxPath\n * @returns which can be used as a token provider\n */\nexport function createConfidentialOauthClient(client_id, client_secret, url, scopes = [\"api:read-data\", \"api:write-data\"], fetchFn = globalThis.fetch, ctxPath = \"/multipass\") {\n const client = { client_id, client_secret };\n const authServer = createAuthorizationServer(ctxPath, url);\n const oauthHttpOptions = { [customFetch]: fetchFn };\n const { getToken, makeTokenAndSaveRefresh } = common(client, authServer, _signIn, oauthHttpOptions, undefined);\n async function _signIn() {\n return makeTokenAndSaveRefresh(throwIfError(await processClientCredentialsResponse(authServer, client, await clientCredentialsGrantRequest(authServer, client, new URLSearchParams({ scope: scopes.join(\" \") }), oauthHttpOptions))), \"signIn\");\n }\n return getToken;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,6BAA6B,EAAEC,WAAW,EAAEC,gCAAgC,QAAS,cAAc;AAC5G,SAASC,MAAM,EAAEC,yBAAyB,QAAQ,aAAa;AAC/D,SAASC,YAAY,QAAQ,mBAAmB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,6BAA6BA,CAACC,SAAS,EAAEC,aAAa,EAAEC,GAAG,EAAEC,MAAM,GAAG,CAAC,eAAe,EAAE,gBAAgB,CAAC,EAAEC,OAAO,GAAGC,UAAU,CAACC,KAAK,EAAEC,OAAO,GAAG,YAAY,EAAE;EAC3K,MAAMC,MAAM,GAAG;IAAER,SAAS;IAAEC;EAAc,CAAC;EAC3C,MAAMQ,UAAU,GAAGZ,yBAAyB,CAACU,OAAO,EAAEL,GAAG,CAAC;EAC1D,MAAMQ,gBAAgB,GAAG;IAAE,CAAChB,WAAW,GAAGU;EAAQ,CAAC;EACnD,MAAM;IAAEO,QAAQ;IAAEC;EAAwB,CAAC,GAAGhB,MAAM,CAACY,MAAM,EAAEC,UAAU,EACvE,kBAAyB;IACrB,OAAOG,uBAAuB,CAACd,YAAY,CAAC,MAAMH,gCAAgC,CAACc,UAAU,EAAED,MAAM,EAAE,MAAMf,6BAA6B,CAACgB,UAAU,EAAED,MAAM,EAAE,IAAIK,eAAe,CAAC;MAAEC,KAAK,EAAEX,MAAM,CAACY,IAAI,CAAC,GAAG;IAAE,CAAC,CAAC,EAAEL,gBAAgB,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC;EACnP,CAAC,EAHiFA,gBAAgB,EAAEM,SAAS,CAAC;EAI9G,OAAOL,QAAQ;AACnB","ignoreList":[]}
1
+ {"version":3,"file":"createConfidentialOauthClient.js","names":["clientCredentialsGrantRequest","customFetch","processClientCredentialsResponse","common","createAuthorizationServer","throwIfError","createConfidentialOauthClient","client_id","client_secret","url","scopes","fetchFn","globalThis","fetch","ctxPath","client","authServer","oauthHttpOptions","getToken","makeTokenAndSaveRefresh","URLSearchParams","scope","join","undefined"],"sources":["createConfidentialOauthClient.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Client, HttpRequestOptions } from \"oauth4webapi\";\nimport {\n clientCredentialsGrantRequest,\n customFetch,\n processClientCredentialsResponse,\n} from \"oauth4webapi\";\nimport { common, createAuthorizationServer } from \"./common.js\";\nimport type { ConfidentialOauthClient } from \"./ConfidentialOauthClient.js\";\nimport { throwIfError } from \"./throwIfError.js\";\n\n/**\n * @param client_id\n * @param client_secret\n * @param url the base url of your foundry server\n * @param scopes\n * @param fetchFn\n * @param ctxPath\n * @returns which can be used as a token provider\n */\nexport function createConfidentialOauthClient(\n client_id: string,\n client_secret: string,\n url: string,\n scopes: string[] = [\"api:read-data\", \"api:write-data\"],\n fetchFn: typeof globalThis.fetch = globalThis.fetch,\n ctxPath: string = \"multipass\",\n): ConfidentialOauthClient {\n const client: Client = { client_id, client_secret };\n const authServer = createAuthorizationServer(ctxPath, url);\n const oauthHttpOptions: HttpRequestOptions = { [customFetch]: fetchFn };\n\n const { getToken, makeTokenAndSaveRefresh } = common(\n client,\n authServer,\n _signIn,\n oauthHttpOptions,\n undefined,\n undefined,\n );\n\n async function _signIn() {\n return makeTokenAndSaveRefresh(\n throwIfError(\n await processClientCredentialsResponse(\n authServer,\n client,\n await clientCredentialsGrantRequest(\n authServer,\n client,\n new URLSearchParams({ scope: scopes.join(\" \") }),\n oauthHttpOptions,\n ),\n ),\n ),\n \"signIn\",\n );\n }\n\n return getToken;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SACEA,6BAA6B,EAC7BC,WAAW,EACXC,gCAAgC,QAC3B,cAAc;AACrB,SAASC,MAAM,EAAEC,yBAAyB,QAAQ,aAAa;AAE/D,SAASC,YAAY,QAAQ,mBAAmB;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,6BAA6BA,CAC3CC,SAAiB,EACjBC,aAAqB,EACrBC,GAAW,EACXC,MAAgB,GAAG,CAAC,eAAe,EAAE,gBAAgB,CAAC,EACtDC,OAAgC,GAAGC,UAAU,CAACC,KAAK,EACnDC,OAAe,GAAG,WAAW,EACJ;EACzB,MAAMC,MAAc,GAAG;IAAER,SAAS;IAAEC;EAAc,CAAC;EACnD,MAAMQ,UAAU,GAAGZ,yBAAyB,CAACU,OAAO,EAAEL,GAAG,CAAC;EAC1D,MAAMQ,gBAAoC,GAAG;IAAE,CAAChB,WAAW,GAAGU;EAAQ,CAAC;EAEvE,MAAM;IAAEO,QAAQ;IAAEC;EAAwB,CAAC,GAAGhB,MAAM,CAClDY,MAAM,EACNC,UAAU,EAOZ,kBAAyB;IACvB,OAAOG,uBAAuB,CAC5Bd,YAAY,CACV,MAAMH,gCAAgC,CACpCc,UAAU,EACVD,MAAM,EACN,MAAMf,6BAA6B,CACjCgB,UAAU,EACVD,MAAM,EACN,IAAIK,eAAe,CAAC;MAAEC,KAAK,EAAEX,MAAM,CAACY,IAAI,CAAC,GAAG;IAAE,CAAC,CAAC,EAChDL,gBACF,CACF,CACF,CAAC,EACD,QACF,CAAC;EACH,CAAC,EArBCA,gBAAgB,EAChBM,SAAS,EACTA,SACF,CAAC;EAoBD,OAAOL,QAAQ;AACjB","ignoreList":[]}