Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add baseCdnUrl attribute in all packages #1014

Merged
merged 4 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/libs/sdk-mixins/jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ module.exports = {
global: {
branches: 12,
functions: 16,
lines: 36,
statements: 36,
lines: 35,
statements: 35,
},
},
// A set of global variables that need to be available in all test environments
Expand Down
1 change: 0 additions & 1 deletion packages/libs/sdk-mixins/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ export * from './mixins/initElementMixin';
export * from './mixins/initLifecycleMixin';
export * from './mixins/projectIdMixin';
export * from './mixins/baseUrlMixin';
export * from './mixins/baseStaticUrlMixin';
11 changes: 0 additions & 11 deletions packages/libs/sdk-mixins/src/mixins/baseStaticUrlMixin.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class AccessKeyManagementComponent implements OnInit, OnChanges {
projectId: string;
baseUrl?: string;
baseStaticUrl?: string;
baseCdnUrl?: string;
@Input() tenant: string;
@Input() widgetId: string;

Expand All @@ -29,6 +30,7 @@ export class AccessKeyManagementComponent implements OnInit, OnChanges {
this.projectId = descopeConfig.projectId;
this.baseUrl = descopeConfig.baseUrl;
this.baseStaticUrl = descopeConfig.baseStaticUrl;
this.baseCdnUrl = descopeConfig.baseCdnUrl;
}

ngOnInit() {
Expand All @@ -50,6 +52,9 @@ export class AccessKeyManagementComponent implements OnInit, OnChanges {
if (this.baseStaticUrl) {
this.webComponent.setAttribute('base-static-url', this.baseStaticUrl);
}
if (this.baseCdnUrl) {
this.webComponent.setAttribute('base-cdn-url', this.baseCdnUrl);
}
if (this.theme) {
this.webComponent.setAttribute('theme', this.theme);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class ApplicationsPortalComponent implements OnInit, OnChanges {
projectId: string;
baseUrl?: string;
baseStaticUrl?: string;
baseCdnUrl?: string;
@Input() widgetId: string;

@Input() theme: 'light' | 'dark' | 'os';
Expand All @@ -38,6 +39,7 @@ export class ApplicationsPortalComponent implements OnInit, OnChanges {
this.projectId = descopeConfig.projectId;
this.baseUrl = descopeConfig.baseUrl;
this.baseStaticUrl = descopeConfig.baseStaticUrl;
this.baseCdnUrl = descopeConfig.baseCdnUrl;
}

ngOnInit() {
Expand All @@ -58,6 +60,9 @@ export class ApplicationsPortalComponent implements OnInit, OnChanges {
if (this.baseStaticUrl) {
this.webComponent.setAttribute('base-static-url', this.baseStaticUrl);
}
if (this.baseCdnUrl) {
this.webComponent.setAttribute('base-cdn-url', this.baseCdnUrl);
}
if (this.theme) {
this.webComponent.setAttribute('theme', this.theme);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class AuditManagementComponent implements OnInit, OnChanges {
projectId: string;
baseUrl?: string;
baseStaticUrl?: string;
baseCdnUrl?: string;
@Input() tenant: string;
@Input() widgetId: string;

Expand All @@ -29,6 +30,7 @@ export class AuditManagementComponent implements OnInit, OnChanges {
this.projectId = descopeConfig.projectId;
this.baseUrl = descopeConfig.baseUrl;
this.baseStaticUrl = descopeConfig.baseStaticUrl;
this.baseCdnUrl = descopeConfig.baseCdnUrl;
}

ngOnInit() {
Expand All @@ -50,6 +52,9 @@ export class AuditManagementComponent implements OnInit, OnChanges {
if (this.baseStaticUrl) {
this.webComponent.setAttribute('base-static-url', this.baseStaticUrl);
}
if (this.baseCdnUrl) {
this.webComponent.setAttribute('base-cdn-url', this.baseCdnUrl);
}
if (this.theme) {
this.webComponent.setAttribute('theme', this.theme);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class DescopeComponent implements OnInit, OnChanges {
projectId: string;
baseUrl?: string;
baseStaticUrl?: string;
baseCdnUrl?: string;
storeLastAuthenticatedUser?: boolean;
@Input() flowId: string;

Expand Down Expand Up @@ -58,6 +59,7 @@ export class DescopeComponent implements OnInit, OnChanges {
this.projectId = descopeConfig.projectId;
this.baseUrl = descopeConfig.baseUrl;
this.baseStaticUrl = descopeConfig.baseStaticUrl;
this.baseCdnUrl = descopeConfig.baseCdnUrl;
this.storeLastAuthenticatedUser = descopeConfig.storeLastAuthenticatedUser;
}

Expand Down Expand Up @@ -103,6 +105,9 @@ export class DescopeComponent implements OnInit, OnChanges {
if (this.baseStaticUrl) {
this.webComponent.setAttribute('base-static-url', this.baseStaticUrl);
}
if (this.baseCdnUrl) {
this.webComponent.setAttribute('base-cdn-url', this.baseCdnUrl);
}
if (this.storeLastAuthenticatedUser) {
this.webComponent.setAttribute(
'store-last-authenticated-user',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class RoleManagementComponent implements OnInit, OnChanges {
projectId: string;
baseUrl?: string;
baseStaticUrl?: string;
baseCdnUrl?: string;
@Input() tenant: string;
@Input() widgetId: string;

Expand All @@ -29,6 +30,7 @@ export class RoleManagementComponent implements OnInit, OnChanges {
this.projectId = descopeConfig.projectId;
this.baseUrl = descopeConfig.baseUrl;
this.baseStaticUrl = descopeConfig.baseStaticUrl;
this.baseCdnUrl = descopeConfig.baseCdnUrl;
}

ngOnInit() {
Expand All @@ -50,6 +52,9 @@ export class RoleManagementComponent implements OnInit, OnChanges {
if (this.baseStaticUrl) {
this.webComponent.setAttribute('base-static-url', this.baseStaticUrl);
}
if (this.baseCdnUrl) {
this.webComponent.setAttribute('base-cdn-url', this.baseCdnUrl);
}
if (this.theme) {
this.webComponent.setAttribute('theme', this.theme);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class UserManagementComponent implements OnInit, OnChanges {
projectId: string;
baseUrl?: string;
baseStaticUrl?: string;
baseCdnUrl?: string;
@Input() tenant: string;
@Input() widgetId: string;

Expand All @@ -29,6 +30,7 @@ export class UserManagementComponent implements OnInit, OnChanges {
this.projectId = descopeConfig.projectId;
this.baseUrl = descopeConfig.baseUrl;
this.baseStaticUrl = descopeConfig.baseStaticUrl;
this.baseCdnUrl = descopeConfig.baseCdnUrl;
}

ngOnInit() {
Expand All @@ -51,6 +53,9 @@ export class UserManagementComponent implements OnInit, OnChanges {
if (this.baseStaticUrl) {
this.webComponent.setAttribute('base-static-url', this.baseStaticUrl);
}
if (this.baseCdnUrl) {
this.webComponent.setAttribute('base-cdn-url', this.baseCdnUrl);
}
if (this.theme) {
this.webComponent.setAttribute('theme', this.theme);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class UserProfileComponent implements OnInit, OnChanges {
projectId: string;
baseUrl?: string;
baseStaticUrl?: string;
baseCdnUrl?: string;
@Input() widgetId: string;

@Input() theme: 'light' | 'dark' | 'os';
Expand All @@ -38,6 +39,7 @@ export class UserProfileComponent implements OnInit, OnChanges {
this.projectId = descopeConfig.projectId;
this.baseUrl = descopeConfig.baseUrl;
this.baseStaticUrl = descopeConfig.baseStaticUrl;
this.baseCdnUrl = descopeConfig.baseCdnUrl;
}

ngOnInit() {
Expand All @@ -58,6 +60,9 @@ export class UserProfileComponent implements OnInit, OnChanges {
if (this.baseStaticUrl) {
this.webComponent.setAttribute('base-static-url', this.baseStaticUrl);
}
if (this.baseCdnUrl) {
this.webComponent.setAttribute('base-cdn-url', this.baseCdnUrl);
}
if (this.theme) {
this.webComponent.setAttribute('theme', this.theme);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export class DescopeAuthConfig {
projectId = '';
baseUrl?: string;
baseStaticUrl?: string;
baseCdnUrl?: string;
// If true, tokens will be stored on local storage
persistTokens?: boolean;
sessionTokenViaCookie?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function initializeApp(authService: DescopeAuthService) {
projectId: environment.descopeProjectId,
baseUrl: environment.descopeBaseUrl || '',
baseStaticUrl: environment.descopeBaseStaticUrl || '',
baseCdnUrl: environment.descopeBaseCdnUrl || '',
sessionTokenViaCookie: true
})
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export interface Env {
descopeProjectId: string;
descopeBaseUrl?: string;
descopeBaseStaticUrl?: string;
descopeBaseCdnUrl?: string;
descopeFlowId?: string;
descopeDebugMode?: false;
descopeTheme?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const environment: Env = {
descopeProjectId: '',
descopeBaseUrl: '',
descopeBaseStaticUrl: '',
descopeBaseCdnUrl: '',
descopeFlowId: '',
descopeDebugMode: false,
descopeTheme: '',
Expand Down
2 changes: 2 additions & 0 deletions packages/sdks/core-js-sdk/src/createSdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ type SdkConfig = {
projectId: string;
logger?: Logger;
baseUrl?: string;
baseStaticUrl?: string;
baseCdnUrl?: string;
hooks?: Hooks;
cookiePolicy?: RequestCredentials | null;
baseHeaders?: HeadersInit;
Expand Down
4 changes: 3 additions & 1 deletion packages/sdks/react-sdk/src/components/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const UserProfile = React.forwardRef<HTMLElement, UserProfileProps>(

useImperativeHandle(ref, () => innerRef);

const { projectId, baseUrl, baseStaticUrl } = React.useContext(Context);
const { projectId, baseUrl, baseStaticUrl, baseCdnUrl } =
React.useContext(Context);

useEffect(() => {
if (innerRef && onLogout) {
Expand All @@ -45,6 +46,7 @@ const UserProfile = React.forwardRef<HTMLElement, UserProfileProps>(
widgetId={widgetId}
baseUrl={baseUrl}
baseStaticUrl={baseStaticUrl}
baseCdnUrl={baseCdnUrl}
styleId={styleId}
ref={setInnerRef}
{...{
Expand Down
1 change: 1 addition & 0 deletions packages/sdks/react-sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export interface IContext {
baseUrl?: string;
styleId?: string;
baseStaticUrl?: string;
baseCdnUrl?: string;
storeLastAuthenticatedUser?: boolean;
keepLastAuthenticatedUserAfterLogout?: boolean;
sdk?: Sdk;
Expand Down
1 change: 1 addition & 0 deletions packages/sdks/vue-sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type Options = {
projectId: string;
baseUrl?: string;
baseStaticUrl?: string;
baseCdnUrl?: string;
// If true, tokens will be stored on local storage
persistTokens?: boolean;
sessionTokenViaCookie?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const flowRedirectUrlMixin = createSingletonMixin(
flowId: widgetFlow,
baseUrl: this.baseUrl,
baseStaticUrl: this.baseStaticUrl,
baseCdnUrl: this.baseCdnUrl,
}),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type FlowConfig = {
flowId: string;
baseUrl?: string;
baseStaticUrl?: string;
baseCdnUrl?: string;
};

export const createFlowTemplate = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ import {
createSingletonMixin,
withMemCache,
} from '@descope/sdk-helpers';
import {
baseStaticUrlMixin,
loggerMixin,
modalMixin,
themeMixin,
} from '@descope/sdk-mixins';
import { loggerMixin, modalMixin, themeMixin } from '@descope/sdk-mixins';
import { getName, getPicture } from '../../../state/selectors';
import { stateManagementMixin } from '../../stateManagementMixin';
import { initWidgetRootMixin } from './initWidgetRootMixin';
Expand All @@ -29,7 +24,6 @@ export const initAvatarMixin = createSingletonMixin(
loggerMixin,
initWidgetRootMixin,
modalMixin,
baseStaticUrlMixin,
)(superclass) {
avatar: AvatarDriver;

Expand Down Expand Up @@ -57,6 +51,7 @@ export const initAvatarMixin = createSingletonMixin(
flowId: this.avatar.flowId,
baseUrl: this.baseUrl,
baseStaticUrl: this.baseStaticUrl,
baseCdnUrl: this.baseCdnUrl,
}),
);
this.#flow.onSuccess(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const initEmailUserAttrMixin = createSingletonMixin(
flowId: this.emailUserAttr.editFlowId,
baseUrl: this.baseUrl,
baseStaticUrl: this.baseStaticUrl,
baseCdnUrl: this.baseCdnUrl,
}),
);
this.#editFlow.onSuccess(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const initNameUserAttrMixin = createSingletonMixin(
flowId: this.nameUserAttr.editFlowId,
baseUrl: this.baseUrl,
baseStaticUrl: this.baseStaticUrl,
baseCdnUrl: this.baseCdnUrl,
}),
);
this.#editFlow.onSuccess(() => {
Expand Down Expand Up @@ -82,6 +83,7 @@ export const initNameUserAttrMixin = createSingletonMixin(
flowId: this.nameUserAttr.deleteFlowId,
baseUrl: this.baseUrl,
baseStaticUrl: this.baseStaticUrl,
baseCdnUrl: this.baseCdnUrl,
}),
);
this.#deleteFlow.onSuccess(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const initPasskeyUserAuthMethodMixin = createSingletonMixin(
flowId: this.passkeyUserAuthMethod.flowId,
baseUrl: this.baseUrl,
baseStaticUrl: this.baseStaticUrl,
baseCdnUrl: this.baseCdnUrl,
}),
);
this.#flow.onSuccess(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const initPasswordUserAuthMethodMixin = createSingletonMixin(
flowId: this.passwordUserAuthMethod.flowId,
baseUrl: this.baseUrl,
baseStaticUrl: this.baseStaticUrl,
baseCdnUrl: this.baseCdnUrl,
}),
);
this.#flow.onSuccess(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const initPhoneUserAttrMixin = createSingletonMixin(
flowId: this.phoneUserAttr.editFlowId,
baseUrl: this.baseUrl,
baseStaticUrl: this.baseStaticUrl,
baseCdnUrl: this.baseCdnUrl,
}),
);
this.#editFlow.onSuccess(() => {
Expand Down Expand Up @@ -82,6 +83,7 @@ export const initPhoneUserAttrMixin = createSingletonMixin(
flowId: this.phoneUserAttr.deleteFlowId,
baseUrl: this.baseUrl,
baseStaticUrl: this.baseStaticUrl,
baseCdnUrl: this.baseCdnUrl,
}),
);
this.#deleteFlow.onSuccess(() => {
Expand Down
Loading