@palantir/pack.auth 0.0.1-beta.1

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 (51) hide show
  1. package/.turbo/turbo-lint.log +42 -0
  2. package/.turbo/turbo-transpileBrowser.log +5 -0
  3. package/.turbo/turbo-transpileCjs.log +5 -0
  4. package/.turbo/turbo-transpileEsm.log +5 -0
  5. package/.turbo/turbo-transpileTypes.log +5 -0
  6. package/.turbo/turbo-typecheck.log +4 -0
  7. package/LICENSE.txt +13 -0
  8. package/README.md +105 -0
  9. package/build/browser/index.js +155 -0
  10. package/build/browser/index.js.map +1 -0
  11. package/build/cjs/index.cjs +163 -0
  12. package/build/cjs/index.cjs.map +1 -0
  13. package/build/cjs/index.d.cts +189 -0
  14. package/build/esm/index.js +155 -0
  15. package/build/esm/index.js.map +1 -0
  16. package/build/types/__tests__/AuthModuleImpl.test.d.ts +1 -0
  17. package/build/types/__tests__/AuthModuleImpl.test.d.ts.map +1 -0
  18. package/build/types/constants/AuthModuleKey.d.ts +4 -0
  19. package/build/types/constants/AuthModuleKey.d.ts.map +1 -0
  20. package/build/types/index.d.ts +11 -0
  21. package/build/types/index.d.ts.map +1 -0
  22. package/build/types/types/AuthModule.d.ts +82 -0
  23. package/build/types/types/AuthModule.d.ts.map +1 -0
  24. package/build/types/types/AuthState.d.ts +14 -0
  25. package/build/types/types/AuthState.d.ts.map +1 -0
  26. package/build/types/types/BaseAuthService.d.ts +22 -0
  27. package/build/types/types/BaseAuthService.d.ts.map +1 -0
  28. package/build/types/types/TokenChange.d.ts +5 -0
  29. package/build/types/types/TokenChange.d.ts.map +1 -0
  30. package/build/types/types/UnverifiedTokenInfo.d.ts +13 -0
  31. package/build/types/types/UnverifiedTokenInfo.d.ts.map +1 -0
  32. package/build/types/types/UserRef.d.ts +21 -0
  33. package/build/types/types/UserRef.d.ts.map +1 -0
  34. package/build/types/utils/AuthModuleConfig.d.ts +16 -0
  35. package/build/types/utils/AuthModuleConfig.d.ts.map +1 -0
  36. package/build/types/utils/AuthModuleImpl.d.ts +25 -0
  37. package/build/types/utils/AuthModuleImpl.d.ts.map +1 -0
  38. package/package.json +67 -0
  39. package/src/__tests__/AuthModuleImpl.test.ts +249 -0
  40. package/src/constants/AuthModuleKey.ts +31 -0
  41. package/src/index.ts +27 -0
  42. package/src/types/AuthModule.ts +117 -0
  43. package/src/types/AuthState.ts +33 -0
  44. package/src/types/BaseAuthService.ts +39 -0
  45. package/src/types/TokenChange.ts +25 -0
  46. package/src/types/UnverifiedTokenInfo.ts +30 -0
  47. package/src/types/UserRef.ts +77 -0
  48. package/src/utils/AuthModuleConfig.ts +40 -0
  49. package/src/utils/AuthModuleImpl.ts +124 -0
  50. package/tsconfig.json +21 -0
  51. package/vitest.config.mjs +26 -0
@@ -0,0 +1,189 @@
1
+ import { Flavored, PackAppInternal, Unsubscribe, ModuleConfigTuple } from '@palantir/pack.core';
2
+
3
+ declare const AuthState: {
4
+ readonly Authenticated: "authenticated";
5
+ readonly Authenticating: "authenticating";
6
+ readonly Error: "error";
7
+ readonly Initializing: "initializing";
8
+ readonly Unauthenticated: "unauthenticated";
9
+ };
10
+ type AuthState = typeof AuthState[keyof typeof AuthState];
11
+ interface AuthStateChangeEvent {
12
+ readonly previousState?: AuthState;
13
+ readonly state: AuthState;
14
+ readonly error?: Error;
15
+ }
16
+ type AuthStateCallback = (event: AuthStateChangeEvent) => void;
17
+
18
+ declare const UserRefBrand: unique symbol;
19
+ type UserId = Flavored<"pack:UserId">;
20
+ /**
21
+ * Reference to a user from the platform API.
22
+ * Provides access to user information with caching.
23
+ */
24
+ interface UserRef {
25
+ readonly userId: UserId;
26
+ readonly [UserRefBrand]: typeof UserRefBrand;
27
+ /**
28
+ * Get the current user data from the platform API.
29
+ * Results are cached to avoid excessive API calls.
30
+ * @param force - Force refresh of cached data
31
+ */
32
+ readonly get: (force?: boolean) => Promise<unknown>;
33
+ }
34
+ declare function invalidUserRef(): UserRef;
35
+ declare function isValidUserRef(userRef: UserRef): boolean;
36
+ declare const createUserRef: (app: PackAppInternal, userId: UserId) => UserRef;
37
+
38
+ /**
39
+ * Represents the parsed payload from a JWT token (unverified).
40
+ * The information provided should not be used for security-sensitive
41
+ * applications unless verified through some other process.
42
+ */
43
+ interface UnverifiedTokenInfo {
44
+ readonly expiryInstantUtc?: number;
45
+ readonly orgId?: string;
46
+ readonly sessionId?: string;
47
+ readonly tokenId?: string;
48
+ readonly userId?: UserId;
49
+ }
50
+
51
+ /**
52
+ * Callback function for token change events. A signout may fire a token change with undefined token.
53
+ */
54
+ type TokenChangeCallback = (token: string | undefined, info: UnverifiedTokenInfo) => void;
55
+
56
+ /**
57
+ * AuthModule provides unified authentication services for PACK applications.
58
+ *
59
+ * It wraps OSDK OAuth clients and provides a consistent interface for authentication
60
+ * state management, token access, and auth lifecycle events.
61
+ */
62
+ interface AuthModule {
63
+ /**
64
+ * Get the current user information.
65
+ * Returns undefined if not authenticated or user data not available.
66
+ */
67
+ readonly getCurrentUser: () => UserRef | undefined;
68
+ /**
69
+ * Get an access token, automatically refreshing if needed.
70
+ * Throws if authentication fails or user is not signed in.
71
+ */
72
+ readonly getToken: () => Promise<string>;
73
+ /**
74
+ * Get the current access token without refresh, returns undefined if expired or unavailable.
75
+ */
76
+ readonly getTokenOrUndefined: () => string | undefined;
77
+ /**
78
+ * Get user data for a specific user ID.
79
+ * @param userId - The user ID to fetch data for
80
+ * @param force - Force refresh of cached data
81
+ * @returns Promise resolving to user data
82
+ */
83
+ readonly getUserData: (userId: string, force?: boolean) => Promise<unknown>;
84
+ /**
85
+ * Check if the user is currently authenticated with a valid token.
86
+ */
87
+ readonly isAuthenticated: () => boolean;
88
+ /**
89
+ * Subscribe to authentication state changes.
90
+ *
91
+ * @param callback Function called when auth state changes
92
+ * @returns Unsubscribe function
93
+ */
94
+ readonly onAuthStateChange: (callback: AuthStateCallback) => Unsubscribe;
95
+ /**
96
+ * Subscribe to token changes.
97
+ *
98
+ * @param callback Function called when token changes
99
+ * @returns Unsubscribe function
100
+ */
101
+ readonly onTokenChange: (callback: TokenChangeCallback) => Unsubscribe;
102
+ /**
103
+ * Manually refresh the access token using the refresh token.
104
+ * Only available for public OAuth clients.
105
+ */
106
+ readonly refresh?: () => Promise<void>;
107
+ /**
108
+ * Initiate sign-in flow. For public clients, this redirects to OAuth.
109
+ * For confidential clients, this performs client credentials flow.
110
+ */
111
+ readonly signIn: () => Promise<void>;
112
+ /**
113
+ * Sign out the current user and clear tokens.
114
+ */
115
+ readonly signOut: () => Promise<void>;
116
+ /**
117
+ * Validate the current token by checking with the platform API.
118
+ * Returns true if the token is valid, false otherwise.
119
+ */
120
+ readonly validateToken: () => Promise<boolean>;
121
+ /**
122
+ * Wait for authentication to complete. Resolves when authenticated,
123
+ * rejects if authentication fails or times out.
124
+ */
125
+ readonly waitForAuth: () => Promise<void>;
126
+ }
127
+ /**
128
+ * Get the auth module from an PACK app instance.
129
+ *
130
+ * @param app - PACK app instance
131
+ * @returns The auth module
132
+ */
133
+ declare function getAuthModule(app: PackAppInternal): AuthModule;
134
+
135
+ /**
136
+ * Base interface for auth services that wrap different OAuth client implementations
137
+ */
138
+ interface BaseAuthService {
139
+ dispose(): void;
140
+ getCurrentState(): AuthState;
141
+ getCurrentUserId(): string | undefined;
142
+ getToken(): Promise<string>;
143
+ getTokenOrUndefined(): string | undefined;
144
+ getUserData(userId: string, force?: boolean): Promise<unknown>;
145
+ isAuthenticated(): boolean;
146
+ isValidated(): boolean;
147
+ onAuthStateChange(callback: AuthStateCallback): Unsubscribe;
148
+ onTokenChange(callback: TokenChangeCallback): Unsubscribe;
149
+ refresh?(): Promise<void>;
150
+ signIn(): Promise<void>;
151
+ signOut(): Promise<void>;
152
+ validateToken(): Promise<boolean>;
153
+ }
154
+
155
+ /**
156
+ * Configuration for AuthModule initialization
157
+ */
158
+ interface AuthModuleConfig {
159
+ readonly authService: BaseAuthService;
160
+ }
161
+ /**
162
+ * Creates an auth module configuration tuple.
163
+ *
164
+ * @param authService - The auth service to use
165
+ * @returns Module configuration tuple for the auth module
166
+ */
167
+ declare function createAuthModuleConfig(authService: BaseAuthService): ModuleConfigTuple<AuthModule>;
168
+
169
+ declare class AuthModuleImpl implements AuthModule {
170
+ #private;
171
+ private readonly app;
172
+ private signInPromise?;
173
+ constructor(app: PackAppInternal, authService: BaseAuthService);
174
+ isAuthenticated(): boolean;
175
+ getToken(): Promise<string>;
176
+ getTokenOrUndefined(): string | undefined;
177
+ signIn(): Promise<void>;
178
+ signOut(): Promise<void>;
179
+ refresh(): Promise<void>;
180
+ onAuthStateChange(callback: AuthStateCallback): Unsubscribe;
181
+ onTokenChange(callback: TokenChangeCallback): Unsubscribe;
182
+ waitForAuth(): Promise<void>;
183
+ getCurrentUser(): UserRef | undefined;
184
+ validateToken(): Promise<boolean>;
185
+ getUserData(userId: string, force?: boolean): Promise<unknown>;
186
+ dispose(): void;
187
+ }
188
+
189
+ export { type AuthModule, type AuthModuleConfig, AuthModuleImpl, AuthState, type AuthStateCallback, type AuthStateChangeEvent, type BaseAuthService, type TokenChangeCallback, type UnverifiedTokenInfo, type UserId, type UserRef, createAuthModuleConfig, createUserRef, getAuthModule, invalidUserRef, isValidUserRef };
@@ -0,0 +1,155 @@
1
+ import { assertIsAppInternal } from '@palantir/pack.core';
2
+
3
+ // src/types/AuthModule.ts
4
+
5
+ // src/types/AuthState.ts
6
+ var AuthState = {
7
+ Authenticated: "authenticated",
8
+ Authenticating: "authenticating",
9
+ Error: "error",
10
+ Initializing: "initializing",
11
+ Unauthenticated: "unauthenticated"
12
+ };
13
+
14
+ // src/types/UserRef.ts
15
+ var UserRefBrand = Symbol("UserRef");
16
+ var INVALID_USER_ID = "INVALID_USER_REF";
17
+ var INVALID_USER_REF = Object.freeze({
18
+ userId: INVALID_USER_ID,
19
+ [UserRefBrand]: UserRefBrand,
20
+ get: () => Promise.reject(new Error("Invalid user reference"))
21
+ });
22
+ function invalidUserRef() {
23
+ return INVALID_USER_REF;
24
+ }
25
+ function isValidUserRef(userRef) {
26
+ return userRef.userId !== INVALID_USER_ID && userRef.userId !== "";
27
+ }
28
+ var createUserRef = (app, userId) => {
29
+ return new UserRefImpl(app, userId);
30
+ };
31
+ var UserRefImpl = class {
32
+ userId;
33
+ #authModule;
34
+ constructor(app, userId) {
35
+ this.#authModule = getAuthModule(app);
36
+ this.userId = userId;
37
+ }
38
+ get(force) {
39
+ return this.#authModule.getUserData(this.userId, force);
40
+ }
41
+ };
42
+
43
+ // src/utils/AuthModuleImpl.ts
44
+ var AuthModuleImpl = class {
45
+ #authService;
46
+ app;
47
+ signInPromise;
48
+ constructor(app, authService) {
49
+ this.app = app;
50
+ this.#authService = authService;
51
+ }
52
+ // AuthModule interface implementation
53
+ isAuthenticated() {
54
+ return this.#authService.isAuthenticated();
55
+ }
56
+ async getToken() {
57
+ return this.#authService.getToken();
58
+ }
59
+ getTokenOrUndefined() {
60
+ return this.#authService.getTokenOrUndefined();
61
+ }
62
+ async signIn() {
63
+ if (this.signInPromise) {
64
+ return this.signInPromise;
65
+ }
66
+ this.signInPromise = (async () => {
67
+ try {
68
+ await this.#authService.signIn();
69
+ } finally {
70
+ this.signInPromise = void 0;
71
+ }
72
+ })();
73
+ return this.signInPromise;
74
+ }
75
+ async signOut() {
76
+ return this.#authService.signOut();
77
+ }
78
+ async refresh() {
79
+ if (!this.#authService.refresh) {
80
+ throw new Error("Refresh not supported for this auth client type");
81
+ }
82
+ return this.#authService.refresh();
83
+ }
84
+ onAuthStateChange(callback) {
85
+ return this.#authService.onAuthStateChange(callback);
86
+ }
87
+ onTokenChange(callback) {
88
+ return this.#authService.onTokenChange(callback);
89
+ }
90
+ async waitForAuth() {
91
+ if (this.isAuthenticated()) {
92
+ return Promise.resolve();
93
+ }
94
+ return new Promise((resolve, reject) => {
95
+ const unsubscribe = this.onAuthStateChange((event) => {
96
+ if (event.state === AuthState.Authenticated) {
97
+ unsubscribe();
98
+ resolve();
99
+ } else if (event.state === AuthState.Error) {
100
+ unsubscribe();
101
+ reject(new Error("Authentication failed", {
102
+ cause: event.error
103
+ }));
104
+ }
105
+ });
106
+ });
107
+ }
108
+ getCurrentUser() {
109
+ const userId = this.#authService.getCurrentUserId();
110
+ if (!userId) {
111
+ return void 0;
112
+ }
113
+ return createUserRef(this.app, userId);
114
+ }
115
+ async validateToken() {
116
+ return this.#authService.validateToken();
117
+ }
118
+ async getUserData(userId, force) {
119
+ return this.#authService.getUserData(userId, force);
120
+ }
121
+ dispose() {
122
+ this.#authService.dispose();
123
+ this.signInPromise = void 0;
124
+ }
125
+ };
126
+
127
+ // src/constants/AuthModuleKey.ts
128
+ var AUTH_MODULE_KEY = {
129
+ appMemberName: "auth",
130
+ key: Symbol.for("pack.auth"),
131
+ initModule: (app, config) => {
132
+ if (!config) {
133
+ throw new Error("AuthModuleConfig is required to initialize AuthModule");
134
+ }
135
+ return new AuthModuleImpl(app, config.authService);
136
+ }
137
+ };
138
+
139
+ // src/types/AuthModule.ts
140
+ function getAuthModule(app) {
141
+ assertIsAppInternal(app);
142
+ return app.getModule(AUTH_MODULE_KEY);
143
+ }
144
+
145
+ // src/utils/AuthModuleConfig.ts
146
+ function createAuthModuleConfig(authService) {
147
+ const config = {
148
+ authService
149
+ };
150
+ return [AUTH_MODULE_KEY, config];
151
+ }
152
+
153
+ export { AuthModuleImpl, AuthState, createAuthModuleConfig, createUserRef, getAuthModule, invalidUserRef, isValidUserRef };
154
+ //# sourceMappingURL=index.js.map
155
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/types/AuthState.ts","../../src/types/UserRef.ts","../../src/utils/AuthModuleImpl.ts","../../src/constants/AuthModuleKey.ts","../../src/types/AuthModule.ts","../../src/utils/AuthModuleConfig.ts"],"names":[],"mappings":";;;;;AAgBO,IAAM,SAAA,GAAY;AAAA,EACvB,aAAA,EAAe,eAAA;AAAA,EACf,cAAA,EAAgB,gBAAA;AAAA,EAChB,KAAA,EAAO,OAAA;AAAA,EAC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CAAO,GAAA,CAAI,WAAW,CAAA;AAAA,EAC3B,UAAA,EAAY,CAAC,GAAA,EAAK,MAAA,KAAW;AAC3B,IAAA,IAAI,CAAC,MAAA,EAAQ;AACX,MAAA,MAAM,IAAI,MAAM,uDAAuD,CAAA;AAAA,IACzE;AACA,IAAA,OAAO,IAAI,cAAA,CAAe,GAAA,EAAK,MAAA,CAAO,WAAW,CAAA;AAAA,EACnD;AACF,CAAA;;;ACOO,SAAS,cAAc,GAAA,EAAK;AACjC,EAAA,mBAAA,CAAoB,GAAG,CAAA;AACvB,EAAA,OAAO,GAAA,CAAI,UAAU,eAAe,CAAA;AACtC;;;ACRO,SAAS,uBAAuB,WAAA,EAAa;AAClD,EAAA,MAAM,MAAA,GAAS;AAAA,IACb;AAAA,GACF;AACA,EAAA,OAAO,CAAC,iBAAiB,MAAM,CAAA;AACjC","file":"index.js","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\nexport const AuthState = {\n Authenticated: \"authenticated\",\n Authenticating: \"authenticating\",\n Error: \"error\",\n Initializing: \"initializing\",\n Unauthenticated: \"unauthenticated\"\n};","/*\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 { getAuthModule } from \"./AuthModule.js\";\nconst UserRefBrand = Symbol(\"UserRef\");\n\n/**\n * Reference to a user from the platform API.\n * Provides access to user information with caching.\n */\n\nconst INVALID_USER_ID = \"INVALID_USER_REF\";\nconst INVALID_USER_REF = Object.freeze({\n userId: INVALID_USER_ID,\n [UserRefBrand]: UserRefBrand,\n get: () => Promise.reject(new Error(\"Invalid user reference\"))\n});\nexport function invalidUserRef() {\n return INVALID_USER_REF;\n}\nexport function isValidUserRef(userRef) {\n return userRef.userId !== INVALID_USER_ID && userRef.userId !== \"\";\n}\nexport const createUserRef = (app, userId) => {\n return new UserRefImpl(app, userId);\n};\nclass UserRefImpl {\n userId;\n #authModule;\n constructor(app, userId) {\n this.#authModule = getAuthModule(app);\n this.userId = userId;\n }\n get(force) {\n return this.#authModule.getUserData(this.userId, force);\n }\n}","/*\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 { AuthState } from \"../types/AuthState.js\";\nimport { createUserRef } from \"../types/UserRef.js\";\nexport class AuthModuleImpl {\n #authService;\n app;\n signInPromise;\n constructor(app, authService) {\n this.app = app;\n this.#authService = authService;\n }\n\n // AuthModule interface implementation\n isAuthenticated() {\n return this.#authService.isAuthenticated();\n }\n async getToken() {\n return this.#authService.getToken();\n }\n getTokenOrUndefined() {\n return this.#authService.getTokenOrUndefined();\n }\n async signIn() {\n if (this.signInPromise) {\n return this.signInPromise;\n }\n this.signInPromise = (async () => {\n try {\n await this.#authService.signIn();\n } finally {\n this.signInPromise = undefined;\n }\n })();\n return this.signInPromise;\n }\n async signOut() {\n return this.#authService.signOut();\n }\n async refresh() {\n if (!this.#authService.refresh) {\n throw new Error(\"Refresh not supported for this auth client type\");\n }\n return this.#authService.refresh();\n }\n onAuthStateChange(callback) {\n return this.#authService.onAuthStateChange(callback);\n }\n onTokenChange(callback) {\n return this.#authService.onTokenChange(callback);\n }\n async waitForAuth() {\n // If already authenticated, resolve immediately\n if (this.isAuthenticated()) {\n return Promise.resolve();\n }\n return new Promise((resolve, reject) => {\n const unsubscribe = this.onAuthStateChange(event => {\n if (event.state === AuthState.Authenticated) {\n unsubscribe();\n resolve();\n } else if (event.state === AuthState.Error) {\n unsubscribe();\n reject(new Error(\"Authentication failed\", {\n cause: event.error\n }));\n }\n });\n });\n }\n getCurrentUser() {\n const userId = this.#authService.getCurrentUserId();\n if (!userId) {\n return undefined;\n }\n return createUserRef(this.app, userId);\n }\n async validateToken() {\n return this.#authService.validateToken();\n }\n async getUserData(userId, force) {\n return this.#authService.getUserData(userId, force);\n }\n dispose() {\n this.#authService.dispose();\n this.signInPromise = undefined;\n }\n}","/*\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 { AuthModuleImpl } from \"../utils/AuthModuleImpl.js\";\nexport const AUTH_MODULE_KEY = {\n appMemberName: \"auth\",\n key: Symbol.for(\"pack.auth\"),\n initModule: (app, config) => {\n if (!config) {\n throw new Error(\"AuthModuleConfig is required to initialize AuthModule\");\n }\n return new AuthModuleImpl(app, config.authService);\n }\n};","/*\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 { assertIsAppInternal } from \"@palantir/pack.core\";\nimport { AUTH_MODULE_KEY } from \"../constants/AuthModuleKey.js\";\n\n/**\n * AuthModule provides unified authentication services for PACK applications.\n *\n * It wraps OSDK OAuth clients and provides a consistent interface for authentication\n * state management, token access, and auth lifecycle events.\n */\n// TODO: functions should be method style\n\n/**\n * Get the auth module from an PACK app instance.\n *\n * @param app - PACK app instance\n * @returns The auth module\n */\nexport function getAuthModule(app) {\n assertIsAppInternal(app);\n return app.getModule(AUTH_MODULE_KEY);\n}","/*\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 { AUTH_MODULE_KEY } from \"../constants/AuthModuleKey.js\";\n\n/**\n * Configuration for AuthModule initialization\n */\n\n/**\n * Creates an auth module configuration tuple.\n *\n * @param authService - The auth service to use\n * @returns Module configuration tuple for the auth module\n */\nexport function createAuthModuleConfig(authService) {\n const config = {\n authService\n };\n return [AUTH_MODULE_KEY, config];\n}"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ {"mappings":"","names":[],"sources":["../../../src/__tests__/AuthModuleImpl.test.ts"],"version":3,"file":"AuthModuleImpl.test.d.ts"}
@@ -0,0 +1,4 @@
1
+ import type { ModuleKey } from "@palantir/pack.core";
2
+ import type { AuthModule } from "../types/AuthModule.js";
3
+ import type { AuthModuleConfig } from "../utils/AuthModuleConfig.js";
4
+ export declare const AUTH_MODULE_KEY: ModuleKey<AuthModule, AuthModuleConfig>;
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cAAc,iBAAkC;AAChD,cAAc,kBAAkB;AAChC,cAAc,wBAAwB;AAGtC,OAAO,cAAMA,iBAAiB,UAAU,YAAY","names":["AUTH_MODULE_KEY: ModuleKey<AuthModule, AuthModuleConfig>"],"sources":["../../../src/constants/AuthModuleKey.ts"],"version":3,"file":"AuthModuleKey.d.ts"}
@@ -0,0 +1,11 @@
1
+ export { getAuthModule } from "./types/AuthModule.js";
2
+ export type { AuthModule } from "./types/AuthModule.js";
3
+ export { AuthState } from "./types/AuthState.js";
4
+ export type { AuthStateCallback, AuthStateChangeEvent } from "./types/AuthState.js";
5
+ export type { BaseAuthService } from "./types/BaseAuthService.js";
6
+ export type { TokenChangeCallback } from "./types/TokenChange.js";
7
+ export type { UnverifiedTokenInfo } from "./types/UnverifiedTokenInfo.js";
8
+ export { createUserRef, invalidUserRef, isValidUserRef } from "./types/UserRef.js";
9
+ export type { UserId, UserRef } from "./types/UserRef.js";
10
+ export { type AuthModuleConfig, createAuthModuleConfig } from "./utils/AuthModuleConfig.js";
11
+ export { AuthModuleImpl } from "./utils/AuthModuleImpl.js";
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,SAAS,qBAAqB;AAC9B,cAAc,kBAAkB;AAChC,SAAS,iBAAiB;AAC1B,cAAc,mBAAmB,4BAA4B;AAC7D,cAAc,uBAAuB;AACrC,cAAc,2BAA2B;AACzC,cAAc,2BAA2B;AACzC,SAAS,eAAe,gBAAgB,sBAAsB;AAC9D,cAAc,QAAQ,eAAe;AACrC,cAAc,kBAAkB,8BAA8B;AAC9D,SAAS,sBAAsB","names":[],"sources":["../../src/index.ts"],"version":3,"file":"index.d.ts"}
@@ -0,0 +1,82 @@
1
+ import type { PackAppInternal, Unsubscribe } from "@palantir/pack.core";
2
+ import type { AuthStateCallback } from "./AuthState.js";
3
+ import type { TokenChangeCallback } from "./TokenChange.js";
4
+ import type { UserRef } from "./UserRef.js";
5
+ /**
6
+ * AuthModule provides unified authentication services for PACK applications.
7
+ *
8
+ * It wraps OSDK OAuth clients and provides a consistent interface for authentication
9
+ * state management, token access, and auth lifecycle events.
10
+ */
11
+ export interface AuthModule {
12
+ /**
13
+ * Get the current user information.
14
+ * Returns undefined if not authenticated or user data not available.
15
+ */
16
+ readonly getCurrentUser: () => UserRef | undefined;
17
+ /**
18
+ * Get an access token, automatically refreshing if needed.
19
+ * Throws if authentication fails or user is not signed in.
20
+ */
21
+ readonly getToken: () => Promise<string>;
22
+ /**
23
+ * Get the current access token without refresh, returns undefined if expired or unavailable.
24
+ */
25
+ readonly getTokenOrUndefined: () => string | undefined;
26
+ /**
27
+ * Get user data for a specific user ID.
28
+ * @param userId - The user ID to fetch data for
29
+ * @param force - Force refresh of cached data
30
+ * @returns Promise resolving to user data
31
+ */
32
+ readonly getUserData: (userId: string, force?: boolean) => Promise<unknown>;
33
+ /**
34
+ * Check if the user is currently authenticated with a valid token.
35
+ */
36
+ readonly isAuthenticated: () => boolean;
37
+ /**
38
+ * Subscribe to authentication state changes.
39
+ *
40
+ * @param callback Function called when auth state changes
41
+ * @returns Unsubscribe function
42
+ */
43
+ readonly onAuthStateChange: (callback: AuthStateCallback) => Unsubscribe;
44
+ /**
45
+ * Subscribe to token changes.
46
+ *
47
+ * @param callback Function called when token changes
48
+ * @returns Unsubscribe function
49
+ */
50
+ readonly onTokenChange: (callback: TokenChangeCallback) => Unsubscribe;
51
+ /**
52
+ * Manually refresh the access token using the refresh token.
53
+ * Only available for public OAuth clients.
54
+ */
55
+ readonly refresh?: () => Promise<void>;
56
+ /**
57
+ * Initiate sign-in flow. For public clients, this redirects to OAuth.
58
+ * For confidential clients, this performs client credentials flow.
59
+ */
60
+ readonly signIn: () => Promise<void>;
61
+ /**
62
+ * Sign out the current user and clear tokens.
63
+ */
64
+ readonly signOut: () => Promise<void>;
65
+ /**
66
+ * Validate the current token by checking with the platform API.
67
+ * Returns true if the token is valid, false otherwise.
68
+ */
69
+ readonly validateToken: () => Promise<boolean>;
70
+ /**
71
+ * Wait for authentication to complete. Resolves when authenticated,
72
+ * rejects if authentication fails or times out.
73
+ */
74
+ readonly waitForAuth: () => Promise<void>;
75
+ }
76
+ /**
77
+ * Get the auth module from an PACK app instance.
78
+ *
79
+ * @param app - PACK app instance
80
+ * @returns The auth module
81
+ */
82
+ export declare function getAuthModule(app: PackAppInternal): AuthModule;
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cAAc,iBAAiB,mBAAmB;AAGlD,cAAc,yBAAyB;AACvC,cAAc,2BAA2B;AACzC,cAAc,eAAe;;;;;;;AAS7B,iBAAiB,WAAW;;;;;UAKjB,sBAAsB;;;;;UAMtB,gBAAgB;;;;UAKhB;;;;;;;UAQA,cAAc,gBAAgB,oBAAoB;;;;UAKlD;;;;;;;UAQA,oBAAoB,UAAU,sBAAsB;;;;;;;UAQpD,gBAAgB,UAAU,wBAAwB;;;;;UAMlD,gBAAgB;;;;;UAMhB,cAAc;;;;UAKd,eAAe;;;;;UAMf,qBAAqB;;;;;UAMrB,mBAAmB;;;;;;;;AAS9B,OAAO,iBAAS,cAAc,KAAK,kBAAkB","names":[],"sources":["../../../src/types/AuthModule.ts"],"version":3,"file":"AuthModule.d.ts"}
@@ -0,0 +1,14 @@
1
+ export declare const AuthState: {
2
+ readonly Authenticated: "authenticated";
3
+ readonly Authenticating: "authenticating";
4
+ readonly Error: "error";
5
+ readonly Initializing: "initializing";
6
+ readonly Unauthenticated: "unauthenticated";
7
+ };
8
+ export type AuthState = typeof AuthState[keyof typeof AuthState];
9
+ export interface AuthStateChangeEvent {
10
+ readonly previousState?: AuthState;
11
+ readonly state: AuthState;
12
+ readonly error?: Error;
13
+ }
14
+ export type AuthStateCallback = (event: AuthStateChangeEvent) => void;
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,OAAO,cAAM;UACX,eAAe;UACf,gBAAgB;UAChB,OAAO;UACP,cAAc;UACd,iBAAiB;;AAGnB,YAAY,mBAAmB,uBAAuB;AAEtD,iBAAiB,qBAAqB;UAC3B,gBAAgB;UAChB,OAAO;UACP,QAAQ;;AAGnB,YAAY,qBAAqB,OAAO","names":[],"sources":["../../../src/types/AuthState.ts"],"version":3,"file":"AuthState.d.ts"}
@@ -0,0 +1,22 @@
1
+ import type { Unsubscribe } from "@palantir/pack.core";
2
+ import type { AuthState, AuthStateCallback } from "./AuthState.js";
3
+ import type { TokenChangeCallback } from "./TokenChange.js";
4
+ /**
5
+ * Base interface for auth services that wrap different OAuth client implementations
6
+ */
7
+ export interface BaseAuthService {
8
+ dispose(): void;
9
+ getCurrentState(): AuthState;
10
+ getCurrentUserId(): string | undefined;
11
+ getToken(): Promise<string>;
12
+ getTokenOrUndefined(): string | undefined;
13
+ getUserData(userId: string, force?: boolean): Promise<unknown>;
14
+ isAuthenticated(): boolean;
15
+ isValidated(): boolean;
16
+ onAuthStateChange(callback: AuthStateCallback): Unsubscribe;
17
+ onTokenChange(callback: TokenChangeCallback): Unsubscribe;
18
+ refresh?(): Promise<void>;
19
+ signIn(): Promise<void>;
20
+ signOut(): Promise<void>;
21
+ validateToken(): Promise<boolean>;
22
+ }
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cAAc,mBAAmB;AACjC,cAAc,WAAW,yBAAyB;AAClD,cAAc,2BAA2B;;;;AAKzC,iBAAiB,gBAAgB;CAC/B;CACA,mBAAmB;CACnB;CACA,YAAY;CACZ;CACA,YAAY,gBAAgB,kBAAkB;CAC9C;CACA;CACA,kBAAkB,UAAU,oBAAoB;CAChD,cAAc,UAAU,sBAAsB;CAC9C,YAAY;CACZ,UAAU;CACV,WAAW;CACX,iBAAiB","names":[],"sources":["../../../src/types/BaseAuthService.ts"],"version":3,"file":"BaseAuthService.d.ts"}
@@ -0,0 +1,5 @@
1
+ import type { UnverifiedTokenInfo } from "./UnverifiedTokenInfo.js";
2
+ /**
3
+ * Callback function for token change events. A signout may fire a token change with undefined token.
4
+ */
5
+ export type TokenChangeCallback = (token: string | undefined, info: UnverifiedTokenInfo) => void;
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cAAc,2BAA2B;;;;AAKzC,YAAY,uBACV,2BACA,MAAM","names":[],"sources":["../../../src/types/TokenChange.ts"],"version":3,"file":"TokenChange.d.ts"}
@@ -0,0 +1,13 @@
1
+ import type { UserId } from "./UserRef.js";
2
+ /**
3
+ * Represents the parsed payload from a JWT token (unverified).
4
+ * The information provided should not be used for security-sensitive
5
+ * applications unless verified through some other process.
6
+ */
7
+ export interface UnverifiedTokenInfo {
8
+ readonly expiryInstantUtc?: number;
9
+ readonly orgId?: string;
10
+ readonly sessionId?: string;
11
+ readonly tokenId?: string;
12
+ readonly userId?: UserId;
13
+ }
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cAAc,cAAc;;;;;;AAO5B,iBAAiB,oBAAoB;UAC1B;UACA;UACA;UACA;UACA,SAAS","names":[],"sources":["../../../src/types/UnverifiedTokenInfo.ts"],"version":3,"file":"UnverifiedTokenInfo.d.ts"}
@@ -0,0 +1,21 @@
1
+ import type { Flavored, PackAppInternal } from "@palantir/pack.core";
2
+ declare const UserRefBrand: unique symbol;
3
+ export type UserId = Flavored<"pack:UserId">;
4
+ /**
5
+ * Reference to a user from the platform API.
6
+ * Provides access to user information with caching.
7
+ */
8
+ export interface UserRef {
9
+ readonly userId: UserId;
10
+ readonly [UserRefBrand]: typeof UserRefBrand;
11
+ /**
12
+ * Get the current user data from the platform API.
13
+ * Results are cached to avoid excessive API calls.
14
+ * @param force - Force refresh of cached data
15
+ */
16
+ readonly get: (force?: boolean) => Promise<unknown>;
17
+ }
18
+ export declare function invalidUserRef(): UserRef;
19
+ export declare function isValidUserRef(userRef: UserRef): boolean;
20
+ export declare const createUserRef: (app: PackAppInternal, userId: UserId) => UserRef;
21
+ export {};
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cAAc,UAAU,uBAAuB;AAI/C,cAAMA;AACN,YAAY,SAAS,SAAS;;;;;AAM9B,iBAAiB,QAAQ;UACd,QAAQ;WACP,sBAAsB;;;;;;UAOvB,MAAM,oBAAoB;;AAYrC,OAAO,iBAAS,kBAAkB;AAIlC,OAAO,iBAAS,eAAe,SAAS;AAIxC,OAAO,cAAM,gBACX,KAAK,iBACL,QAAQ,WACP","names":["UserRefBrand: unique symbol"],"sources":["../../../src/types/UserRef.ts"],"version":3,"file":"UserRef.d.ts"}
@@ -0,0 +1,16 @@
1
+ import type { ModuleConfigTuple } from "@palantir/pack.core";
2
+ import type { AuthModule } from "../types/AuthModule.js";
3
+ import type { BaseAuthService } from "../types/BaseAuthService.js";
4
+ /**
5
+ * Configuration for AuthModule initialization
6
+ */
7
+ export interface AuthModuleConfig {
8
+ readonly authService: BaseAuthService;
9
+ }
10
+ /**
11
+ * Creates an auth module configuration tuple.
12
+ *
13
+ * @param authService - The auth service to use
14
+ * @returns Module configuration tuple for the auth module
15
+ */
16
+ export declare function createAuthModuleConfig(authService: BaseAuthService): ModuleConfigTuple<AuthModule>;
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cAAc,yBAAoC;AAElD,cAAc,kBAAkB;AAChC,cAAc,uBAAuB;;;;AAKrC,iBAAiB,iBAAiB;UACvB,aAAa;;;;;;;;AASxB,OAAO,iBAAS,uBACd,aAAa,kBACZ,kBAAkB","names":[],"sources":["../../../src/utils/AuthModuleConfig.ts"],"version":3,"file":"AuthModuleConfig.d.ts"}
@@ -0,0 +1,25 @@
1
+ import { type PackAppInternal, type Unsubscribe } from "@palantir/pack.core";
2
+ import type { AuthModule } from "../types/AuthModule.js";
3
+ import type { AuthStateCallback } from "../types/AuthState.js";
4
+ import type { BaseAuthService } from "../types/BaseAuthService.js";
5
+ import type { TokenChangeCallback } from "../types/TokenChange.js";
6
+ import type { UserRef } from "../types/UserRef.js";
7
+ export declare class AuthModuleImpl implements AuthModule {
8
+ #private;
9
+ private readonly app;
10
+ private signInPromise?;
11
+ constructor(app: PackAppInternal, authService: BaseAuthService);
12
+ isAuthenticated(): boolean;
13
+ getToken(): Promise<string>;
14
+ getTokenOrUndefined(): string | undefined;
15
+ signIn(): Promise<void>;
16
+ signOut(): Promise<void>;
17
+ refresh(): Promise<void>;
18
+ onAuthStateChange(callback: AuthStateCallback): Unsubscribe;
19
+ onTokenChange(callback: TokenChangeCallback): Unsubscribe;
20
+ waitForAuth(): Promise<void>;
21
+ getCurrentUser(): UserRef | undefined;
22
+ validateToken(): Promise<boolean>;
23
+ getUserData(userId: string, force?: boolean): Promise<unknown>;
24
+ dispose(): void;
25
+ }
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cAAc,sBAAsB,mBAAmB;AACvD,cAAc,kBAAkB;AAChC,cAAc,yBAAyB;AAEvC,cAAc,uBAAuB;AACrC,cAAc,2BAA2B;AACzC,cAAc,eAAe;AAG7B,OAAO,cAAM,0BAA0B,WAAW;;CAEhD,iBAAiB;CACjB,QAAQ;CAER,YAAY,KAAK,iBAAiB,aAAa;CAM/C;CAIA,AAAM,YAAY;CAIlB;CAIA,AAAM,UAAU;CAgBhB,AAAM,WAAW;CAIjB,AAAM,WAAW;CAQjB,kBAAkB,UAAU,oBAAoB;CAIhD,cAAc,UAAU,sBAAsB;CAI9C,AAAM,eAAe;CAmBrB,kBAAkB;CAQlB,AAAM,iBAAiB;CAIvB,AAAM,YAAY,gBAAgB,kBAAkB;CAIpD","names":[],"sources":["../../../src/utils/AuthModuleImpl.ts"],"version":3,"file":"AuthModuleImpl.d.ts"}