@civic/auth
Advanced tools
Comparing version 0.1.4-beta.2 to 0.1.4-beta.3
# 0.1.4 Refactor hooks and providers | ||
- Refactor the internal hooks and providers implementation | ||
- change modalIframe prop to new iframeMode that can be either 'embedded' or 'modal' (default) | ||
- Move the idToken, accessToken, refreshToken and forwardedTokens from the User object to the UserContext | ||
@@ -6,0 +5,0 @@ # 0.1.3 Update README |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// These are the default exports of the project. | ||
// They are limited by design to ensure that the public API does not expose any internal implementation details. | ||
// Do not change this without thinking carefully about the impact on the client-facing public API. | ||
const version_js_1 = require("./version.js"); | ||
console.log(version_js_1.VERSION); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CivicAuthProvider = exports.NextjsClientStorage = exports.NextjsCookieStorage = exports.clearAuthCookies = exports.createUserInfoCookie = exports.createTokenCookies = exports.handler = exports.getUser = exports.createCivicAuthPlugin = void 0; | ||
const version_js_1 = require("../version.js"); | ||
console.log(version_js_1.VERSION); | ||
var config_js_1 = require("../nextjs/config.js"); | ||
@@ -5,0 +7,0 @@ Object.defineProperty(exports, "createCivicAuthPlugin", { enumerable: true, get: function () { return config_js_1.createCivicAuthPlugin; } }); |
@@ -54,9 +54,9 @@ "use strict"; | ||
const useCivicAuthConfig_js_1 = require("../../shared/hooks/useCivicAuthConfig.js"); | ||
const index_js_1 = require("../../reactjs/index.js"); | ||
const IFrameAndLoading_js_1 = require("../../shared/components/IFrameAndLoading.js"); | ||
const BlockDisplay_js_1 = require("../../shared/components/BlockDisplay.js"); | ||
const LoadingIcon_js_1 = require("../../shared/components/LoadingIcon.js"); | ||
const useIframe_js_1 = require("../../shared/hooks/useIframe.js"); | ||
const CivicNextAuthProviderInternal = ({ children, resolvedConfig, ...props }) => { | ||
const { iframeMode } = props; | ||
const { iframeRef } = (0, index_js_1.useIframe)(); | ||
const { iframeRef } = (0, useIframe_js_1.useIframe)(); | ||
const [isLoading, setIsLoading] = (0, react_1.useState)(false); | ||
@@ -63,0 +63,0 @@ const civicAuthConfig = (0, useCivicAuthConfig_js_1.useCivicAuthConfig)(); |
@@ -21,2 +21,4 @@ "use strict"; | ||
// Do not change this without thinking carefully about the impact on the client-facing public API. | ||
const version_js_1 = require("../version.js"); | ||
console.log(`${version_js_1.VERSION}`); | ||
__exportStar(require("../reactjs/hooks/index.js"), exports); | ||
@@ -23,0 +25,0 @@ var index_js_1 = require("../reactjs/providers/index.js"); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.refreshTokens = exports.getUser = exports.buildLoginUrl = exports.isLoggedIn = exports.resolveOAuthAccessCode = exports.CookieStorage = void 0; | ||
const version_js_1 = require("../version.js"); | ||
console.log(version_js_1.VERSION); | ||
var storage_js_1 = require("../shared/lib/storage.js"); | ||
@@ -5,0 +7,0 @@ Object.defineProperty(exports, "CookieStorage", { enumerable: true, get: function () { return storage_js_1.CookieStorage; } }); |
@@ -15,4 +15,4 @@ "use strict"; | ||
const isInIframe = (0, useIsInIframe_js_1.useIsInIframe)(); | ||
const { renderIframe, iframeIsVisible, setIframeIsVisible, iframeMode } = (0, useIframe_js_1.useIframe)(); | ||
const showIframeLoadingOverlay = iframeMode === "modal" && (isInIframe || isLoading); | ||
const { renderIframe, iframeIsVisible, setIframeIsVisible } = (0, useIframe_js_1.useIframe)(); | ||
const showLoadingOverlay = isInIframe || isLoading; | ||
return (react_1.default.createElement(react_1.default.Fragment, null, | ||
@@ -25,3 +25,3 @@ renderIframe && (react_1.default.createElement("div", { style: iframeIsVisible ? { display: "block" } : { display: "none" } }, | ||
error?.message))), | ||
showIframeLoadingOverlay && !error && (react_1.default.createElement(BlockDisplay_js_1.BlockDisplay, null, | ||
showLoadingOverlay && !error && (react_1.default.createElement(BlockDisplay_js_1.BlockDisplay, null, | ||
react_1.default.createElement(LoadingIcon_js_1.LoadingIcon, null))))); | ||
@@ -28,0 +28,0 @@ }; |
@@ -1,2 +0,6 @@ | ||
export {}; | ||
// These are the default exports of the project. | ||
// They are limited by design to ensure that the public API does not expose any internal implementation details. | ||
// Do not change this without thinking carefully about the impact on the client-facing public API. | ||
import { VERSION } from "./version.js"; | ||
console.log(VERSION); | ||
//# sourceMappingURL=index.js.map |
@@ -0,1 +1,3 @@ | ||
import { VERSION } from "../version.js"; | ||
console.log(VERSION); | ||
export { createCivicAuthPlugin } from "../nextjs/config.js"; | ||
@@ -2,0 +4,0 @@ export { getUser } from "../nextjs/GetUser.js"; |
@@ -18,6 +18,6 @@ "use client"; | ||
import { useCivicAuthConfig } from "../../shared/hooks/useCivicAuthConfig.js"; | ||
import { useIframe } from "../../reactjs/index.js"; | ||
import { IFrameAndLoading } from "../../shared/components/IFrameAndLoading.js"; | ||
import { BlockDisplay } from "../../shared/components/BlockDisplay.js"; | ||
import { LoadingIcon } from "../../shared/components/LoadingIcon.js"; | ||
import { useIframe } from "../../shared/hooks/useIframe.js"; | ||
const CivicNextAuthProviderInternal = ({ children, resolvedConfig, ...props }) => { | ||
@@ -24,0 +24,0 @@ const { iframeMode } = props; |
// These are the default exports of the project. | ||
// They are limited by design to ensure that the public API does not expose any internal implementation details. | ||
// Do not change this without thinking carefully about the impact on the client-facing public API. | ||
import { VERSION } from "../version.js"; | ||
console.log(`${VERSION}`); | ||
export * from "../reactjs/hooks/index.js"; | ||
@@ -5,0 +7,0 @@ export { CivicAuthProvider, } from "../reactjs/providers/index.js"; |
@@ -0,1 +1,3 @@ | ||
import { VERSION } from "../version.js"; | ||
console.log(VERSION); | ||
export { CookieStorage } from "../shared/lib/storage.js"; | ||
@@ -2,0 +4,0 @@ export { resolveOAuthAccessCode, isLoggedIn, buildLoginUrl, } from "../server/login.js"; |
@@ -9,4 +9,4 @@ import React from "react"; | ||
const isInIframe = useIsInIframe(); | ||
const { renderIframe, iframeIsVisible, setIframeIsVisible, iframeMode } = useIframe(); | ||
const showIframeLoadingOverlay = iframeMode === "modal" && (isInIframe || isLoading); | ||
const { renderIframe, iframeIsVisible, setIframeIsVisible } = useIframe(); | ||
const showLoadingOverlay = isInIframe || isLoading; | ||
return (React.createElement(React.Fragment, null, | ||
@@ -19,3 +19,3 @@ renderIframe && (React.createElement("div", { style: iframeIsVisible ? { display: "block" } : { display: "none" } }, | ||
error?.message))), | ||
showIframeLoadingOverlay && !error && (React.createElement(BlockDisplay, null, | ||
showLoadingOverlay && !error && (React.createElement(BlockDisplay, null, | ||
React.createElement(LoadingIcon, null))))); | ||
@@ -22,0 +22,0 @@ }; |
{ | ||
"name": "@civic/auth", | ||
"version": "0.1.4-beta.2", | ||
"version": "0.1.4-beta.3", | ||
"type": "module", | ||
@@ -95,7 +95,8 @@ "module": "dist/index.js", | ||
"tsup": "^8.3.0", | ||
"tsx": "^4.19.1", | ||
"vite": "^5.4.8", | ||
"vite-plugin-dts": "^4.2.3", | ||
"vitest": "^2.1.2", | ||
"@repo/typescript-config": "0.0.0", | ||
"@repo/eslint-config": "0.0.0" | ||
"@repo/eslint-config": "0.0.0", | ||
"@repo/typescript-config": "0.0.0" | ||
}, | ||
@@ -106,13 +107,15 @@ "optionalDependency": { | ||
"scripts": { | ||
"prebuild": "rm -rf .turbo dist && pnpm generate-version", | ||
"build": "pnpm build:cjs && pnpm build:esm", | ||
"build:cjs": "tsc -p tsconfig.cjs.json --noEmit false && tsc-alias -p tsconfig.cjs.json", | ||
"build:esm": "tsc -p tsconfig.esm.json --noEmit false && tsc-alias -p tsconfig.esm.json", | ||
"prepublish": "node ../../etc/scripts/prompt-changelog.js && pnpm build", | ||
"prepublish": "pnpm generate-version && node ../../etc/scripts/prompt-changelog.js && pnpm build", | ||
"dev": "tsc --watch", | ||
"pretest": "pnpm generate-version", | ||
"test": "vitest", | ||
"lint": "eslint \"src/**/*.ts*\" --max-warnings 0", | ||
"lint:fix": "pnpm lint --fix", | ||
"clean": "rm -rf .turbo dist node_modules", | ||
"test:update": "vitest --update" | ||
"test:update": "vitest --update", | ||
"generate-version": "npx tsx ./generateVersion.ts" | ||
} | ||
} |
@@ -179,7 +179,2 @@ - [Civic Auth Client SDK](#civic-auth-client-sdk) | ||
user: User | null; | ||
// these are the OAuth tokens created during authentication | ||
accessToken?: string | null; | ||
idToken?: string | null; | ||
forwardedTokens?: ForwardedTokens; | ||
// functions and flags for UI and signIn/signOut | ||
isLoading: boolean; | ||
@@ -206,8 +201,11 @@ error: Error | null; | ||
type User<T extends UnknownObject = EmptyObject> = BaseUser & T; | ||
type Tokens = { | ||
idToken: string; | ||
accessToken: string; | ||
refreshToken: string; | ||
forwardedTokens: ForwardedTokens; | ||
}; | ||
type User = BaseUser & Tokens | ||
``` | ||
Where you can pass extra user attributes to the object that you know will be present in user claims, e.g. | ||
```typescript | ||
const UserWithNickName = User<{ nickname: string }>; | ||
``` | ||
@@ -214,0 +212,0 @@ Field descriptions: |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
23
8
1161262
26
597
8588
412