@osdk/oauth 1.2.0-beta.1 → 1.2.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/build/browser/common.js +3 -2
- package/build/browser/common.js.map +1 -1
- package/build/browser/common.test.js +4 -3
- package/build/browser/common.test.js.map +1 -1
- package/build/browser/createConfidentialOauthClient.js +4 -3
- package/build/browser/createConfidentialOauthClient.js.map +1 -1
- package/build/browser/createPublicOauthClient.js +9 -6
- package/build/browser/createPublicOauthClient.js.map +1 -1
- package/build/browser/publicOauth.test.js +37 -9
- package/build/browser/publicOauth.test.js.map +1 -1
- package/build/browser/utils.js +1 -1
- package/build/browser/utils.js.map +1 -1
- package/build/cjs/index.cjs +54 -49
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +2 -2
- package/build/esm/common.js +3 -2
- package/build/esm/common.js.map +1 -1
- package/build/esm/common.test.js +4 -3
- package/build/esm/common.test.js.map +1 -1
- package/build/esm/createConfidentialOauthClient.js +4 -3
- package/build/esm/createConfidentialOauthClient.js.map +1 -1
- package/build/esm/createPublicOauthClient.js +9 -6
- package/build/esm/createPublicOauthClient.js.map +1 -1
- package/build/esm/publicOauth.test.js +37 -9
- package/build/esm/publicOauth.test.js.map +1 -1
- package/build/esm/utils.js +1 -1
- package/build/esm/utils.js.map +1 -1
- package/build/types/common.d.ts +2 -1
- package/build/types/common.d.ts.map +1 -1
- package/build/types/createConfidentialOauthClient.d.ts.map +1 -1
- package/build/types/createPublicOauthClient.d.ts +2 -2
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/utils.d.ts +2 -1
- package/build/types/utils.d.ts.map +1 -1
- package/package.json +1 -1
package/build/esm/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["invariant","processOptionsAndAssignDefaults","url","redirect_uri","useHistory","loginPage","postLoginPage","scopes","fetchFn","ctxPath","options","process","env","NODE_ENV","window","location","toString","globalThis","fetch","refreshTokenMarker"],"sources":["utils.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 invariant from \"tiny-invariant\";\nimport type { PublicOauthClientOptions } from \"./createPublicOauthClient.js\";\n\ninterface ProcessedPublicOauthClientOptions\n
|
|
1
|
+
{"version":3,"file":"utils.js","names":["invariant","processOptionsAndAssignDefaults","url","redirect_uri","useHistory","loginPage","postLoginPage","scopes","fetchFn","ctxPath","options","process","env","NODE_ENV","window","location","toString","joinedScopes","sort","join","globalThis","fetch","refreshTokenMarker"],"sources":["utils.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 invariant from \"tiny-invariant\";\nimport type { PublicOauthClientOptions } from \"./createPublicOauthClient.js\";\n\ninterface ProcessedPublicOauthClientOptions extends\n Omit<\n Required<PublicOauthClientOptions>,\n \"loginPage\" | \"refreshTokenMarker\" | \"scopes\"\n >\n{\n loginPage?: string;\n refreshTokenMarker?: string;\n joinedScopes: string;\n}\n\nexport function processOptionsAndAssignDefaults(\n url: string,\n redirect_uri: string,\n useHistory?: boolean | PublicOauthClientOptions,\n loginPage?: string,\n postLoginPage?: string,\n scopes?: string[],\n fetchFn?: typeof globalThis.fetch,\n ctxPath?: string,\n): ProcessedPublicOauthClientOptions {\n let options: PublicOauthClientOptions = {};\n\n if (typeof useHistory === \"object\") {\n invariant(\n !loginPage && !postLoginPage && !scopes && !fetchFn && !ctxPath,\n \"If useHistory is an object, other options should not be provided\",\n );\n options = useHistory;\n } else {\n options = {\n useHistory,\n loginPage,\n postLoginPage,\n scopes,\n fetchFn,\n ctxPath,\n };\n }\n\n invariant(url, \"url is required\");\n invariant(redirect_uri, \"redirectUrl is required\");\n\n // Assign defaults\n return {\n useHistory: options.useHistory ?? true,\n loginPage: options.loginPage,\n postLoginPage: options.postLoginPage || window.location.toString(),\n joinedScopes: [\n ...options.scopes\n ?? [\n \"api:read-data\",\n \"api:write-data\",\n \"api:use-ontologies-read\",\n \"api:use-ontologies-write\",\n ],\n ]\n .sort().join(\" \"),\n fetchFn: options.fetchFn ?? globalThis.fetch,\n ctxPath: options.ctxPath ?? \"multipass\",\n refreshTokenMarker: options.refreshTokenMarker,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,SAAS,MAAM,gBAAgB;AActC,OAAO,SAASC,+BAA+BA,CAC7CC,GAAW,EACXC,YAAoB,EACpBC,UAA+C,EAC/CC,SAAkB,EAClBC,aAAsB,EACtBC,MAAiB,EACjBC,OAAiC,EACjCC,OAAgB,EACmB;EACnC,IAAIC,OAAiC,GAAG,CAAC,CAAC;EAE1C,IAAI,OAAON,UAAU,KAAK,QAAQ,EAAE;IAClC,EACE,CAACC,SAAS,IAAI,CAACC,aAAa,IAAI,CAACC,MAAM,IAAI,CAACC,OAAO,IAAI,CAACC,OAAO,IAAAE,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBADjEb,SAAS,QAEP,kEAAkE,IAFpEA,SAAS;IAITU,OAAO,GAAGN,UAAU;EACtB,CAAC,MAAM;IACLM,OAAO,GAAG;MACRN,UAAU;MACVC,SAAS;MACTC,aAAa;MACbC,MAAM;MACNC,OAAO;MACPC;IACF,CAAC;EACH;EAEA,CAAUP,GAAG,GAAAS,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAbb,SAAS,QAAM,iBAAiB,IAAhCA,SAAS;EACT,CAAUG,YAAY,GAAAQ,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAtBb,SAAS,QAAe,yBAAyB,IAAjDA,SAAS;;EAET;EACA,OAAO;IACLI,UAAU,EAAEM,OAAO,CAACN,UAAU,IAAI,IAAI;IACtCC,SAAS,EAAEK,OAAO,CAACL,SAAS;IAC5BC,aAAa,EAAEI,OAAO,CAACJ,aAAa,IAAIQ,MAAM,CAACC,QAAQ,CAACC,QAAQ,CAAC,CAAC;IAClEC,YAAY,EAAE,CACZ,IAAGP,OAAO,CAACH,MAAM,IACZ,CACD,eAAe,EACf,gBAAgB,EAChB,yBAAyB,EACzB,0BAA0B,CAC3B,EACJ,CACEW,IAAI,CAAC,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC;IACnBX,OAAO,EAAEE,OAAO,CAACF,OAAO,IAAIY,UAAU,CAACC,KAAK;IAC5CZ,OAAO,EAAEC,OAAO,CAACD,OAAO,IAAI,WAAW;IACvCa,kBAAkB,EAAEZ,OAAO,CAACY;EAC9B,CAAC;AACH","ignoreList":[]}
|
package/build/types/common.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { Token } from "./Token.js";
|
|
|
4
4
|
export interface LocalStorageState {
|
|
5
5
|
refresh_token?: string;
|
|
6
6
|
refreshTokenMarker?: string;
|
|
7
|
+
requestedScopes?: string;
|
|
7
8
|
}
|
|
8
9
|
export type SessionStorageState = {
|
|
9
10
|
codeVerifier?: never
|
|
@@ -24,7 +25,7 @@ export declare function readLocal(client: Client): LocalStorageState;
|
|
|
24
25
|
export declare function saveSession(client: Client, x: SessionStorageState): void;
|
|
25
26
|
export declare function removeSession(client: Client): void;
|
|
26
27
|
export declare function readSession(client: Client): SessionStorageState;
|
|
27
|
-
export declare function common<R extends undefined | (() => Promise<Token | undefined>)>(client: Client, as: AuthorizationServer, _signIn: () => Promise<Token>, oauthHttpOptions: HttpRequestOptions, refresh: R, refreshTokenMarker: string | undefined): {
|
|
28
|
+
export declare function common<R extends undefined | (() => Promise<Token | undefined>)>(client: Client, as: AuthorizationServer, _signIn: () => Promise<Token>, oauthHttpOptions: HttpRequestOptions, refresh: R, refreshTokenMarker: string | undefined, scopes: string): {
|
|
28
29
|
getToken: BaseOauthClient<keyof Events & string> & {
|
|
29
30
|
refresh: R
|
|
30
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cACE,qBACA,QACA,oBACA,mCACK,cAAe;AAItB,cAAc,iBAAiB,cAAc,sBAAuB;AAEpE,cAAc,aAAa,YAAa;AAwBxC,iBAAiB,kBAAkB;CACjC;CACA;AACD;AAED,YAAY,sBAER;CACA;CACA;CACA;AACD,IAEC;CACA;CACA;CACA;AACD,IAEC;CACA;CACA;CACA;AACD;AAMH,OAAO,iBAAS,UAAUA,QAAQ,QAAQC,GAAG;AAQ7C,OAAO,iBAAS,YAAYD,QAAQ;AAOpC,OAAO,iBAAS,UAAUA,QAAQ,SAAS;AAU3C,OAAO,iBAAS,YAAYA,QAAQ,QAAQE,GAAG;AAQ/C,OAAO,iBAAS,cAAcF,QAAQ;AAOtC,OAAO,iBAAS,YAAYA,QAAQ,SAAS;AAU7C,OAAO,iBAAS,OACd,6BAA6B,QAAQ,qBAErCA,QAAQ,QACRG,IAAI,qBACJC,eAAe,QAAQ,QACvBC,kBAAkB,oBAClBC,SAAS,GACTC,
|
|
1
|
+
{"mappings":"AAgBA,cACE,qBACA,QACA,oBACA,mCACK,cAAe;AAItB,cAAc,iBAAiB,cAAc,sBAAuB;AAEpE,cAAc,aAAa,YAAa;AAwBxC,iBAAiB,kBAAkB;CACjC;CACA;CAGA;AACD;AAED,YAAY,sBAER;CACA;CACA;CACA;AACD,IAEC;CACA;CACA;CACA;AACD,IAEC;CACA;CACA;CACA;AACD;AAMH,OAAO,iBAAS,UAAUA,QAAQ,QAAQC,GAAG;AAQ7C,OAAO,iBAAS,YAAYD,QAAQ;AAOpC,OAAO,iBAAS,UAAUA,QAAQ,SAAS;AAU3C,OAAO,iBAAS,YAAYA,QAAQ,QAAQE,GAAG;AAQ/C,OAAO,iBAAS,cAAcF,QAAQ;AAOtC,OAAO,iBAAS,YAAYA,QAAQ,SAAS;AAU7C,OAAO,iBAAS,OACd,6BAA6B,QAAQ,qBAErCA,QAAQ,QACRG,IAAI,qBACJC,eAAe,QAAQ,QACvBC,kBAAkB,oBAClBC,SAAS,GACTC,wCACAC,iBACC;CACD,UAAU,sBAAsB,mBAAmB;EAAE,SAAS;CAAG;CACjE,0BACEC,MAAM,6BACNC,MAAM,WAAW,cACd;AACN;AAgHD,OAAO,iBAAS,0BACdC,iBACAC,cACC,SACD,KACE,qBACE,WACA,mBACA,2BACA","names":["client: Client","x: LocalStorageState","x: SessionStorageState","as: AuthorizationServer","_signIn: () => Promise<Token>","oauthHttpOptions: HttpRequestOptions","refresh: R","refreshTokenMarker: string | undefined","scopes: string","resp: OAuth2TokenEndpointResponse","type: \"signIn\" | \"refresh\"","ctxPath: string","url: string"],"sources":["../../src/common.ts"],"version":3,"file":"common.d.ts"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAuBA,cAAc,+BAA+B,8BAA+B;;;;;;;;;;AAY5E,OAAO,iBAAS,8BACdA,mBACAC,uBACAC,aACAC,
|
|
1
|
+
{"mappings":"AAuBA,cAAc,+BAA+B,8BAA+B;;;;;;;;;;AAY5E,OAAO,iBAAS,8BACdA,mBACAC,uBACAC,aACAC,mBAMAC,iBAAgB,WAAW,OAC3BC,mBACC","names":["client_id: string","client_secret: string","url: string","scopes: string[]","fetchFn: typeof globalThis.fetch","ctxPath: string"],"sources":["../../src/createConfidentialOauthClient.ts"],"version":3,"file":"createConfidentialOauthClient.d.ts"}
|
|
@@ -13,7 +13,7 @@ export interface PublicOauthClientOptions {
|
|
|
13
13
|
*/
|
|
14
14
|
postLoginPage?: string;
|
|
15
15
|
/**
|
|
16
|
-
* * @param {string[]} [scopes=[]] - OAuth scopes to request. If not provided, defaults to `["api:read-data", "api:write-data"]`
|
|
16
|
+
* * @param {string[]} [scopes=[]] - OAuth scopes to request. If not provided, defaults to `["api:read-data", "api:write-data", "api:use-ontologies-read", "api:use-ontologies-write"]`
|
|
17
17
|
*/
|
|
18
18
|
scopes?: string[];
|
|
19
19
|
/**
|
|
@@ -48,7 +48,7 @@ export declare function createPublicOauthClient(clientId: string, url: string, r
|
|
|
48
48
|
* @param {boolean} useHistory - If true, uses `history.replaceState()`, otherwise uses `window.location.assign()` (defaults to true)
|
|
49
49
|
* @param {string} loginPage - Custom landing page URL prior to logging in
|
|
50
50
|
* @param {string} postLoginPage - URL to return to after completed authentication cycle (defaults to `window.location.toString()`)
|
|
51
|
-
* @param {string[]} scopes - OAuth scopes to request. If not provided, defaults to `["api:read-data", "api:write-data"]`
|
|
51
|
+
* @param {string[]} scopes - OAuth scopes to request. If not provided, defaults to `["api:read-data", "api:write-data", "api:use-ontologies-read", "api:use-ontologies-write"]`
|
|
52
52
|
* @param {typeof globalThis.fetch} fetchFn - Custom fetch function to use for requests (defaults to `globalThis.fetch`)
|
|
53
53
|
* @param {string} ctxPath - Context path for the authorization server (defaults to "multipass")
|
|
54
54
|
* @returns {PublicOauthClient} A client that can be used as a token provider
|
package/build/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { createConfidentialOauthClient } from "./createConfidentialOauthClient.js";
|
|
2
2
|
export { createPublicOauthClient } from "./createPublicOauthClient.js";
|
|
3
|
-
export type
|
|
3
|
+
export type { PublicOauthClient } from "./PublicOauthClient.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,SAAS,qCAAqC;AAC9C,SAAS,+BAA+B;AACxC,
|
|
1
|
+
{"mappings":"AAgBA,SAAS,qCAAqC;AAC9C,SAAS,+BAA+B;AACxC,cAAc,yBAAyB","names":[],"sources":["../../src/index.ts"],"version":3,"file":"index.d.ts"}
|
package/build/types/utils.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { PublicOauthClientOptions } from "./createPublicOauthClient.js";
|
|
2
|
-
interface ProcessedPublicOauthClientOptions extends Omit<Required<PublicOauthClientOptions>, "loginPage" | "refreshTokenMarker"> {
|
|
2
|
+
interface ProcessedPublicOauthClientOptions extends Omit<Required<PublicOauthClientOptions>, "loginPage" | "refreshTokenMarker" | "scopes"> {
|
|
3
3
|
loginPage?: string;
|
|
4
4
|
refreshTokenMarker?: string;
|
|
5
|
+
joinedScopes: string;
|
|
5
6
|
}
|
|
6
7
|
export declare function processOptionsAndAssignDefaults(url: string, redirect_uri: string, useHistory?: boolean | PublicOauthClientOptions, loginPage?: string, postLoginPage?: string, scopes?: string[], fetchFn?: typeof globalThis.fetch, ctxPath?: string): ProcessedPublicOauthClientOptions;
|
|
7
8
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAiBA,cAAc,gCAAgC,8BAA+B;UAEnE,
|
|
1
|
+
{"mappings":"AAiBA,cAAc,gCAAgC,8BAA+B;UAEnE,0CACR,KACE,SAAS,2BACT,cAAc,uBAAuB,UAEzC;CACE;CACA;CACA;AACD;AAED,OAAO,iBAAS,gCACdA,aACAC,sBACAC,uBAAuB,0BACvBC,oBACAC,wBACAC,mBACAC,iBAAiB,WAAW,OAC5BC,mBACC","names":["url: string","redirect_uri: string","useHistory?: boolean | PublicOauthClientOptions","loginPage?: string","postLoginPage?: string","scopes?: string[]","fetchFn?: typeof globalThis.fetch","ctxPath?: string"],"sources":["../../src/utils.ts"],"version":3,"file":"utils.d.ts"}
|