Skip to content

Commit

Permalink
Merge branch 'main' into react-19
Browse files Browse the repository at this point in the history
  • Loading branch information
asafshen committed Dec 18, 2024
2 parents eee7b80 + 334053c commit e95d8e0
Show file tree
Hide file tree
Showing 27 changed files with 1,327 additions and 2,314 deletions.
12 changes: 12 additions & 0 deletions packages/sdks/angular-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [0.7.7](https://github.com/descope/descope-js/compare/angular-sdk-0.7.6...angular-sdk-0.7.7) (2024-12-18)

### Dependency Updates

* `access-key-management-widget` updated to version `0.3.3`
* `audit-management-widget` updated to version `0.2.7`
* `role-management-widget` updated to version `0.2.7`
* `user-management-widget` updated to version `0.6.1`
* `user-profile-widget` updated to version `0.2.3`
* `applications-portal-widget` updated to version `0.2.7`
* `web-component` updated to version `3.31.2`
* `web-js-sdk` updated to version `1.23.0`
## [0.7.6](https://github.com/descope/descope-js/compare/angular-sdk-0.7.5...angular-sdk-0.7.6) (2024-12-18)

### Dependency Updates
Expand Down
2 changes: 1 addition & 1 deletion packages/sdks/angular-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@descope/angular-sdk",
"version": "0.7.6",
"version": "0.7.7",
"peerDependencies": {
"@angular/common": ">=16.0.0",
"@angular/core": ">=16.0.0"
Expand Down
7 changes: 7 additions & 0 deletions packages/sdks/nextjs-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [0.3.14](https://github.com/descope/descope-js/compare/nextjs-sdk-0.3.13...nextjs-sdk-0.3.14) (2024-12-18)

### Dependency Updates

* `web-js-sdk` updated to version `1.23.0`
* `react-sdk` updated to version `2.3.6`
* `web-component` updated to version `3.31.2`
## [0.3.13](https://github.com/descope/descope-js/compare/nextjs-sdk-0.3.12...nextjs-sdk-0.3.13) (2024-12-18)

### Dependency Updates
Expand Down
2 changes: 1 addition & 1 deletion packages/sdks/nextjs-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@descope/nextjs-sdk",
"version": "0.3.13-alpha.0",
"version": "0.3.14",
"description": "Descope NextJS SDK",
"author": "Descope Team <[email protected]>",
"homepage": "https://github.com/descope/descope-js",
Expand Down
12 changes: 12 additions & 0 deletions packages/sdks/react-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [2.3.6](https://github.com/descope/descope-js/compare/react-sdk-2.3.5...react-sdk-2.3.6) (2024-12-18)

### Dependency Updates

* `access-key-management-widget` updated to version `0.3.3`
* `audit-management-widget` updated to version `0.2.7`
* `role-management-widget` updated to version `0.2.7`
* `user-management-widget` updated to version `0.6.1`
* `user-profile-widget` updated to version `0.2.3`
* `applications-portal-widget` updated to version `0.2.7`
* `web-component` updated to version `3.31.2`
* `web-js-sdk` updated to version `1.23.0`
## [2.3.5](https://github.com/descope/descope-js/compare/react-sdk-2.3.4...react-sdk-2.3.5) (2024-12-18)

### Dependency Updates
Expand Down
2 changes: 1 addition & 1 deletion packages/sdks/react-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@descope/react-sdk",
"version": "2.3.5",
"version": "2.3.6",
"description": "Descope React SDK",
"author": "Descope Team <[email protected]>",
"homepage": "https://github.com/descope/descope-js",
Expand Down
12 changes: 12 additions & 0 deletions packages/sdks/vue-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [2.2.7](https://github.com/descope/descope-js/compare/vue-sdk-2.2.6...vue-sdk-2.2.7) (2024-12-18)

### Dependency Updates

* `access-key-management-widget` updated to version `0.3.3`
* `audit-management-widget` updated to version `0.2.7`
* `role-management-widget` updated to version `0.2.7`
* `user-management-widget` updated to version `0.6.1`
* `user-profile-widget` updated to version `0.2.3`
* `applications-portal-widget` updated to version `0.2.7`
* `web-component` updated to version `3.31.2`
* `web-js-sdk` updated to version `1.23.0`
## [2.2.6](https://github.com/descope/descope-js/compare/vue-sdk-2.2.5...vue-sdk-2.2.6) (2024-12-18)

### Dependency Updates
Expand Down
2 changes: 1 addition & 1 deletion packages/sdks/vue-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@descope/vue-sdk",
"version": "2.2.6",
"version": "2.2.7",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"type": "module",
Expand Down
5 changes: 5 additions & 0 deletions packages/sdks/web-component/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [3.31.2](https://github.com/descope/descope-js/compare/web-component-3.31.1...web-component-3.31.2) (2024-12-18)

### Dependency Updates

* `web-js-sdk` updated to version `1.23.0`
## [3.31.1](https://github.com/descope/descope-js/compare/web-component-3.31.0...web-component-3.31.1) (2024-12-18)

### Dependency Updates
Expand Down
2 changes: 1 addition & 1 deletion packages/sdks/web-component/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@descope/web-component",
"version": "3.31.1",
"version": "3.31.2",
"author": "Descope Team <[email protected]>",
"homepage": "https://github.com/descope/descope-js",
"bugs": {
Expand Down
7 changes: 7 additions & 0 deletions packages/sdks/web-js-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [1.23.0](https://github.com/descope/descope-js/compare/web-js-sdk-1.22.0...web-js-sdk-1.23.0) (2024-12-18)


### Features

* Support for isDismissed from FedCM ([#862](https://github.com/descope/descope-js/issues/862)) ([27e977c](https://github.com/descope/descope-js/commit/27e977c536da4d4f966bdf4989bdef8066438060))

## [1.22.0](https://github.com/descope/descope-js/compare/web-js-sdk-1.21.0...web-js-sdk-1.22.0) (2024-12-08)

### Dependency Updates
Expand Down
2 changes: 1 addition & 1 deletion packages/sdks/web-js-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@descope/web-js-sdk",
"version": "1.22.0",
"version": "1.23.0",
"author": "Descope Team <[email protected]>",
"homepage": "https://github.com/descope/descope-js",
"bugs": {
Expand Down
44 changes: 41 additions & 3 deletions packages/sdks/web-js-sdk/src/sdk/fedcm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ type OneTapInitialize = ({

type PromptNotification = {
isSkippedMoment: () => boolean;
isDismissedMoment: () => boolean;
getDismissedReason: () => string;
getSkippedReason: () => string;
};

/**
Expand All @@ -112,7 +115,8 @@ const createFedCM = (sdk: CoreSdk, projectId: string) => ({
provider?: string,
oneTapConfig?: OneTapConfig,
loginOptions?: LoginOptions,
onSkip?: () => void,
onSkip?: (reason?: string) => void,
onDismissed?: (reason?: string) => void,
) {
const readyProvider = provider ?? 'google';
const startResponse = await sdk.oauth.startNative(
Expand Down Expand Up @@ -150,8 +154,17 @@ const createFedCM = (sdk: CoreSdk, projectId: string) => ({
});

googleClient.prompt((notification) => {
if (notification?.isSkippedMoment()) {
onSkip?.();
if (onDismissed && notification?.isDismissedMoment()) {
const reason = notification.getDismissedReason?.();
onDismissed?.(reason);
return;
}

// Fallback to onSkip
if (onSkip && notification?.isSkippedMoment()) {
const reason = notification.getSkippedReason?.();
onSkip?.(reason);
return;
}
});
});
Expand Down Expand Up @@ -179,6 +192,31 @@ const createFedCM = (sdk: CoreSdk, projectId: string) => ({
isSupported(): boolean {
return IS_BROWSER && 'IdentityCredential' in window;
},
async isLoggedIn(
context?: IdentityCredentialRequestOptionsContext,
): Promise<boolean> {
const configURL = sdk.httpClient.buildUrl(
projectId + apiPaths.fedcm.config,
);
try {
const req: FedCMCredentialRequestOptions = {
identity: {
context: context || 'signin',
providers: [
{
configURL,
clientId: projectId,
},
],
},
};
const res = await navigator.credentials?.get(req as any);
return !!res && !!(res as any as FedCMAssertionResponse).token;
} catch (e) {
// Any error likely indicates no active session.
return false;
}
},
});

// Helpers functions
Expand Down
75 changes: 75 additions & 0 deletions packages/sdks/web-js-sdk/test/fedcm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,34 @@ describe('fedcm', () => {
promptCallback({ isSkippedMoment: () => true });
expect(onSkip).toHaveBeenCalled();
});
it('call onDismissed callback on prompt dismiss with detailed reason', async () => {
coreJs.oauth.startNative.mockResolvedValue({
ok: true,
data: { clientId: 'C123', stateId: 'S123', nonce: 'N123' },
});

const onDismissed = jest.fn();

// Call oneTap with onDismissed callback
sdk.fedcm.oneTap(
'google',
{ auto_select: true },
{ stepup: false },
undefined,
onDismissed,
);

await new Promise(process.nextTick);

// Simulate prompt callback with isDismissedMoment and getDismissedReason
const promptCallback = googleClient.prompt.mock.calls[0][0];
promptCallback({
isDismissedMoment: () => true,
getDismissedReason: () => 'credential_returned',
});

expect(onDismissed).toHaveBeenCalledWith('credential_returned');
});
});
describe('launch', () => {
it('should call navigator.credentials.get with correct parameters', async () => {
Expand Down Expand Up @@ -189,4 +217,51 @@ describe('fedcm', () => {
expect(sdk.fedcm.isSupported()).toBe(false);
});
});
describe('isLoggedIn', () => {
it('should return true if navigator.credentials.get returns a valid token', async () => {
const mockGet = jest.fn();
// @ts-ignore
global.navigator.credentials = { get: mockGet };
mockGet.mockResolvedValue({ token: 'mockToken' });

const result = await sdk.fedcm.isLoggedIn();

expect(mockGet).toHaveBeenCalledWith({
identity: {
context: 'signin',
providers: [
{
configURL: 'http://localhost:3000/P123/fedcm/config',
clientId: 'P123',
},
],
},
});
expect(result).toBe(true);
});

it('should return false if navigator.credentials.get returns null', async () => {
const mockGet = jest.fn();
// @ts-ignore
global.navigator.credentials = { get: mockGet };
mockGet.mockResolvedValue(null);

const result = await sdk.fedcm.isLoggedIn();

expect(mockGet).toHaveBeenCalled();
expect(result).toBe(false);
});

it('should return false if navigator.credentials.get throws an error', async () => {
const mockGet = jest.fn();
// @ts-ignore
global.navigator.credentials = { get: mockGet };
mockGet.mockRejectedValue(new Error('Test Error'));

const result = await sdk.fedcm.isLoggedIn();

expect(mockGet).toHaveBeenCalled();
expect(result).toBe(false);
});
});
});
5 changes: 5 additions & 0 deletions packages/widgets/access-key-management-widget/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [0.3.3](https://github.com/descope/descope-js/compare/access-key-management-widget-0.3.2...access-key-management-widget-0.3.3) (2024-12-18)

### Dependency Updates

* `web-js-sdk` updated to version `1.23.0`
## [0.3.2](https://github.com/descope/descope-js/compare/access-key-management-widget-0.3.1...access-key-management-widget-0.3.2) (2024-12-18)

### Dependency Updates
Expand Down
2 changes: 1 addition & 1 deletion packages/widgets/access-key-management-widget/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@descope/access-key-management-widget",
"version": "0.3.2",
"version": "0.3.3",
"author": "Descope Team <[email protected]>",
"homepage": "https://github.com/descope/descope-js",
"bugs": {
Expand Down
5 changes: 5 additions & 0 deletions packages/widgets/applications-portal-widget/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [0.2.7](https://github.com/descope/descope-js/compare/applications-portal-widget-0.2.6...applications-portal-widget-0.2.7) (2024-12-18)

### Dependency Updates

* `web-js-sdk` updated to version `1.23.0`
## [0.2.6](https://github.com/descope/descope-js/compare/applications-portal-widget-0.2.5...applications-portal-widget-0.2.6) (2024-12-18)

### Dependency Updates
Expand Down
2 changes: 1 addition & 1 deletion packages/widgets/applications-portal-widget/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@descope/applications-portal-widget",
"version": "0.2.6",
"version": "0.2.7",
"author": "Descope Team <[email protected]>",
"homepage": "https://github.com/descope/descope-js",
"bugs": {
Expand Down
5 changes: 5 additions & 0 deletions packages/widgets/audit-management-widget/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [0.2.7](https://github.com/descope/descope-js/compare/audit-management-widget-0.2.6...audit-management-widget-0.2.7) (2024-12-18)

### Dependency Updates

* `web-js-sdk` updated to version `1.23.0`
## [0.2.6](https://github.com/descope/descope-js/compare/audit-management-widget-0.2.5...audit-management-widget-0.2.6) (2024-12-18)

### Dependency Updates
Expand Down
2 changes: 1 addition & 1 deletion packages/widgets/audit-management-widget/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@descope/audit-management-widget",
"version": "0.2.6",
"version": "0.2.7",
"author": "Descope Team <[email protected]>",
"homepage": "https://github.com/descope/descope-js",
"bugs": {
Expand Down
5 changes: 5 additions & 0 deletions packages/widgets/role-management-widget/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [0.2.7](https://github.com/descope/descope-js/compare/role-management-widget-0.2.6...role-management-widget-0.2.7) (2024-12-18)

### Dependency Updates

* `web-js-sdk` updated to version `1.23.0`
## [0.2.6](https://github.com/descope/descope-js/compare/role-management-widget-0.2.5...role-management-widget-0.2.6) (2024-12-18)

### Dependency Updates
Expand Down
2 changes: 1 addition & 1 deletion packages/widgets/role-management-widget/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@descope/role-management-widget",
"version": "0.2.6",
"version": "0.2.7",
"author": "Descope Team <[email protected]>",
"homepage": "https://github.com/descope/descope-js",
"bugs": {
Expand Down
5 changes: 5 additions & 0 deletions packages/widgets/user-management-widget/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [0.6.1](https://github.com/descope/descope-js/compare/user-management-widget-0.6.0...user-management-widget-0.6.1) (2024-12-18)

### Dependency Updates

* `web-js-sdk` updated to version `1.23.0`
## [0.6.0](https://github.com/descope/descope-js/compare/user-management-widget-0.5.5...user-management-widget-0.6.0) (2024-12-18)

### Dependency Updates
Expand Down
Loading

0 comments on commit e95d8e0

Please sign in to comment.