@osdk/oauth 1.1.0-beta.0 → 1.1.0-beta.10

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 +320 -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 +25 -9
  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
@@ -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,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AM,CAACyB,qBAAqB,CAAC,CAACF,WAAW,CAAC,CAAC;IAC3CvB,MAAM,CAACa,mCAAmC,CAAC,CAACW,qBAAqB,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";
@@ -29,21 +30,36 @@ const CustomEvent = globalThis.CustomEvent ?? class extends Event {
29
30
  return this.#detail;
30
31
  }
31
32
  };
32
- const localStorage = globalThis.localStorage;
33
+ function localStorageKey(client) {
34
+ return `@osdk/oauth : refresh : ${client.client_id}`;
35
+ }
33
36
  export function saveLocal(client, x) {
34
37
  // MUST `localStorage?` as nodejs does not have localStorage
35
- localStorage?.setItem(`@osdk/oauth : refresh : ${client.client_id}`, JSON.stringify(x));
38
+ globalThis.localStorage?.setItem(localStorageKey(client), JSON.stringify(x));
36
39
  }
37
40
  export function removeLocal(client) {
38
41
  // MUST `localStorage?` as nodejs does not have localStorage
39
- localStorage?.removeItem(`@osdk/oauth : refresh : ${client.client_id}`);
42
+ globalThis.localStorage?.removeItem(localStorageKey(client));
40
43
  }
41
44
  export function readLocal(client) {
42
45
  return JSON.parse(
43
46
  // MUST `localStorage?` as nodejs does not have localStorage
44
- localStorage?.getItem(`@osdk/oauth : refresh : ${client.client_id}`) ?? "{}");
47
+ globalThis.localStorage?.getItem(localStorageKey(client)) ?? "{}");
48
+ }
49
+ export function saveSession(client, x) {
50
+ // MUST `sessionStorage?` as nodejs does not have sessionStorage
51
+ globalThis.sessionStorage?.setItem(localStorageKey(client), JSON.stringify(x));
52
+ }
53
+ export function removeSession(client) {
54
+ // MUST `sessionStorage?` as nodejs does not have sessionStorage
55
+ globalThis.sessionStorage?.removeItem(localStorageKey(client));
45
56
  }
46
- export function common(client, as, _signIn, oauthHttpOptions, refresh) {
57
+ export function readSession(client) {
58
+ return JSON.parse(
59
+ // MUST `sessionStorage?` as nodejs does not have sessionStorage
60
+ globalThis.sessionStorage?.getItem(localStorageKey(client)) ?? "{}");
61
+ }
62
+ export function common(client, as, _signIn, oauthHttpOptions, refresh, refreshTokenMarker) {
47
63
  let token;
48
64
  const eventTarget = new TypedEventTarget();
49
65
  function makeTokenAndSaveRefresh(resp, type) {
@@ -54,7 +70,8 @@ export function common(client, as, _signIn, oauthHttpOptions, refresh) {
54
70
  } = resp;
55
71
  !(expires_in != null) ? process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
56
72
  saveLocal(client, {
57
- refresh_token
73
+ refresh_token,
74
+ refreshTokenMarker
58
75
  });
59
76
  token = {
60
77
  refresh_token,
@@ -109,6 +126,7 @@ export function common(client, as, _signIn, oauthHttpOptions, refresh) {
109
126
  !token ? process.env.NODE_ENV !== "production" ? invariant(false, "not signed in") : invariant(false) : void 0;
110
127
  const result = await processRevocationResponse(await revocationRequest(as, client, token.access_token, oauthHttpOptions));
111
128
  rmTimeout();
129
+
112
130
  // Clean up
113
131
  removeLocal(client);
114
132
  token = undefined;
@@ -126,7 +144,7 @@ export function common(client, as, _signIn, oauthHttpOptions, refresh) {
126
144
  };
127
145
  }
128
146
  export function createAuthorizationServer(ctxPath, url) {
129
- const issuer = `${new URL(ctxPath, url)}`;
147
+ const issuer = `${new URL(ctxPath, url.endsWith("/") ? url : url + "/")}`;
130
148
  return {
131
149
  token_endpoint: `${issuer}/api/oauth2/token`,
132
150
  authorization_endpoint: `${issuer}/api/oauth2/authorize`,
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","names":["processRevocationResponse","revocationRequest","invariant","TypedEventTarget","throwIfError","CustomEvent","globalThis","Event","detail","constructor","type","options","localStorage","saveLocal","client","x","setItem","client_id","JSON","stringify","removeLocal","removeItem","readLocal","parse","getItem","common","as","_signIn","oauthHttpOptions","refresh","token","eventTarget","makeTokenAndSaveRefresh","resp","refresh_token","expires_in","access_token","process","env","NODE_ENV","expires_at","Date","now","dispatchTypedEvent","refreshTimeout","rmTimeout","clearTimeout","restartRefreshTimer","evt","setTimeout","pendingSignIn","signIn","undefined","addEventListener","getTokenOrUndefined","getToken","Object","assign","signOut","result","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,GAEXC,UAAU,CAACD,WAAW,IACjB,cAA0BE,KAAK,CAAC;EAC/B,CAACC,MAAM;EACPC,WAAWA,CAACC,IAAI,EAAEC,OAAO,EAAE;IACvB,KAAK,CAACD,IAAI,EAAEC,OAAO,CAAC;IACpB,IAAI,CAAC,CAACH,MAAM,GAAGG,OAAO,EAAEH,MAAM,IAAI,IAAI;EAC1C;EACA,IAAIA,MAAMA,CAAA,EAAG;IACT,OAAO,IAAI,CAAC,CAACA,MAAM;EACvB;AACJ,CAAC;AACT,MAAMI,YAAY,GAAGN,UAAU,CAACM,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,2BAA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AC,CAAC;MACX;MACAzB,WAAW,CAACN,MAAM,CAAC;MACnBgB,KAAK,GAAGsB,SAAS;MACjBhD,YAAY,CAACuD,MAAM,CAAC;MACpB5B,WAAW,CAACY,kBAAkB,CAAC,SAAS,EAAE,IAAIpC,KAAK,CAAC,SAAS,CAAC,CAAC;IACnE,CA8BW;IACPsC,SAAS;IACTS,mBAAmB;IACnBD,gBAAgB,EAAEtB,WAAW,CAACsB,gBAAgB,CAACO,IAAI,CAAC7B,WAAW,CAAC;IAChE8B,mBAAmB,EAAE9B,WAAW,CAAC8B,mBAAmB,CAACD,IAAI,CAAC7B,WAAW;EACzE,CAAC,CAAC;EACF,OAAO;IAAEwB,QAAQ;IAAEvB;EAAwB,CAAC;AAChD;AACA,OAAO,SAAS8B,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","Event","detail","constructor","type","options","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","refresh_token","expires_in","access_token","process","env","NODE_ENV","expires_at","Date","now","dispatchTypedEvent","refreshTimeout","rmTimeout","clearTimeout","restartRefreshTimer","evt","setTimeout","pendingSignIn","signIn","undefined","addEventListener","getTokenOrUndefined","getToken","Object","assign","signOut","result","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,SAASA,yBAAyB,EAAEC,iBAAiB,QAAQ,cAAc;AAC3E,OAAOC,SAAS,MAAM,gBAAgB;AACtC,SAASC,gBAAgB,QAAQ,yBAAyB;AAE1D,SAASC,YAAY,QAAQ,mBAAmB;AAGhD;AACA;AACA,MAAMC,WAAW,GAEbC,UAAU,CAACD,WAAW,IACnB,cAA6BE,KAAK,CAAC;EACpC,CAACC,MAAM;EAEPC,WAAWA,CAACC,IAAY,EAAEC,OAAkC,EAAE;IAC5D,KAAK,CAACD,IAAI,EAAEC,OAAO,CAAC;IACpB,IAAI,CAAC,CAACH,MAAM,GAAGG,OAAO,EAAEH,MAAM,IAAI,IAAI;EACxC;EAEA,IAAIA,MAAMA,CAAA,EAAG;IACX,OAAO,IAAI,CAAC,CAACA,MAAM;EACrB;AACF,CAAC;AA+BL,SAASI,eAAeA,CAACC,MAAc,EAAE;EACvC,OAAO,2BAA2BA,MAAM,CAACC,SAAS,EAAE;AACtD;AAEA,OAAO,SAASC,SAASA,CAACF,MAAc,EAAEG,CAAoB,EAAQ;EACpE;EACAV,UAAU,CAACW,YAAY,EAAEC,OAAO,CAC9BN,eAAe,CAACC,MAAM,CAAC,EACvBM,IAAI,CAACC,SAAS,CAACJ,CAAC,CAClB,CAAC;AACH;AAEA,OAAO,SAASK,WAAWA,CAACR,MAAc,EAAQ;EAChD;EACAP,UAAU,CAACW,YAAY,EAAEK,UAAU,CACjCV,eAAe,CAACC,MAAM,CACxB,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BAAmB;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,M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AAO,GAAGvB,EAAE,CAACQ,EAAE,CAAC,CAAC;IAEvB,MAAMgB,UAAU,GAAGtB,yBAAyB,CAC1C,WAAW,EACX,4BACF,CAAC;IAED,MAAM;MAAEuB;IAAwB,CAAC,GAAGxB,MAAM,CACxCW,MAAM,EACNY,UAAU,EACVF,MAAM,EACN,CAAC,CAAC,EACFC,OAAO,EACP,eACF,CAAC;IAEDE,uBAAuB,CAAC;MACtBC,aAAa,EAAE,SAAS;MACxBC,YAAY,EAAE,QAAQ;MACtBC,UAAU,EAAE,KAAK;MACjBC,UAAU,EAAE;IACd,CAAC,EAAE,QAAQ,CAAC;IAEZ/B,MAAM,CAACoB,UAAU,CAACC,YAAY,CAACZ,OAAO,CAAC,CAACa,cAAc,CACpD,2BAA2BR,MAAM,CAACC,SAAS,EAAE,EAC7CiB,IAAI,CAACC,SAAS,CAAC;MACbL,aAAa,EAAE,SAAS;MACxBM,kBAAkB,EAAE;IACtB,CAAC,CACH,CAAC;EACH,CAAC,CAAC;AACJ,CAAC,CAAC","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":[]}