Skip to content

Commit

Permalink
Merge branch 'main' into feat/user_profile_widget_add_custom_fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitzperetz authored Nov 12, 2024
2 parents 0332f05 + f159ae8 commit c57559b
Show file tree
Hide file tree
Showing 26 changed files with 363 additions and 24 deletions.
7 changes: 7 additions & 0 deletions packages/libs/sdk-mixins/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.4.0](https://github.com/descope/descope-js/compare/sdk-mixins-0.3.2...sdk-mixins-0.4.0) (2024-11-10)


### Features

* **descope-ui-mixin:** use descopecdn.com ([#804](https://github.com/descope/descope-js/issues/804)) ([82e2fa7](https://github.com/descope/descope-js/commit/82e2fa779f48b99c8ed88af451fc2a9b329d1758))

## [0.3.2](https://github.com/descope/descope-js/compare/sdk-mixins-0.3.1...sdk-mixins-0.3.2) (2024-09-19)

### Dependency Updates
Expand Down
2 changes: 1 addition & 1 deletion packages/libs/sdk-mixins/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@descope/sdk-mixins",
"version": "0.3.2",
"version": "0.4.0",
"author": "Descope Team <info@descope.com>",
"homepage": "https://github.com/descope/sdk-mixins",
"bugs": {
Expand Down
16 changes: 16 additions & 0 deletions packages/sdks/angular-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

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

## [0.7.0](https://github.com/descope/descope-js/compare/angular-sdk-0.6.6...angular-sdk-0.7.0) (2024-11-10)

### Dependency Updates

* `access-key-management-widget` updated to version `0.2.0`
* `audit-management-widget` updated to version `0.2.0`
* `role-management-widget` updated to version `0.2.0`
* `user-management-widget` updated to version `0.5.0`
* `user-profile-widget` updated to version `0.1.0`
* `applications-portal-widget` updated to version `0.2.0`
* `web-component` updated to version `3.29.0`

### Features

* add style-id to widgets ([#840](https://github.com/descope/descope-js/issues/840)) ([0573afd](https://github.com/descope/descope-js/commit/0573afd7e3e873a18bfba605643dd20820cf0365))

## [0.6.6](https://github.com/descope/descope-js/compare/angular-sdk-0.6.5...angular-sdk-0.6.6) (2024-11-03)

### 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.6.6",
"version": "0.7.0",
"peerDependencies": {
"@angular/common": ">=16.0.0",
"@angular/core": ">=16.0.0"
Expand Down
6 changes: 6 additions & 0 deletions packages/sdks/nextjs-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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

## [0.3.7](https://github.com/descope/descope-js/compare/nextjs-sdk-0.3.6...nextjs-sdk-0.3.7) (2024-11-10)

### Dependency Updates

* `react-sdk` updated to version `2.2.0`
* `web-component` updated to version `3.29.0`
## [0.3.6](https://github.com/descope/descope-js/compare/nextjs-sdk-0.3.5...nextjs-sdk-0.3.6) (2024-11-03)

### 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.6",
"version": "0.3.7",
"description": "Descope NextJS SDK",
"author": "Descope Team <info@descope.com>",
"homepage": "https://github.com/descope/descope-js",
Expand Down
16 changes: 16 additions & 0 deletions packages/sdks/react-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

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

## [2.2.0](https://github.com/descope/descope-js/compare/react-sdk-2.1.6...react-sdk-2.2.0) (2024-11-10)

### Dependency Updates

* `access-key-management-widget` updated to version `0.2.0`
* `audit-management-widget` updated to version `0.2.0`
* `role-management-widget` updated to version `0.2.0`
* `user-management-widget` updated to version `0.5.0`
* `user-profile-widget` updated to version `0.1.0`
* `applications-portal-widget` updated to version `0.2.0`
* `web-component` updated to version `3.29.0`

### Features

* add style-id to widgets ([#840](https://github.com/descope/descope-js/issues/840)) ([0573afd](https://github.com/descope/descope-js/commit/0573afd7e3e873a18bfba605643dd20820cf0365))

## [2.1.6](https://github.com/descope/descope-js/compare/react-sdk-2.1.5...react-sdk-2.1.6) (2024-11-03)

### 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.1.6",
"version": "2.2.0",
"description": "Descope React SDK",
"author": "Descope Team <info@descope.com>",
"homepage": "https://github.com/descope/descope-js",
Expand Down
16 changes: 16 additions & 0 deletions packages/sdks/vue-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

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

## [2.2.0](https://github.com/descope/descope-js/compare/vue-sdk-2.1.6...vue-sdk-2.2.0) (2024-11-10)

### Dependency Updates

* `access-key-management-widget` updated to version `0.2.0`
* `audit-management-widget` updated to version `0.2.0`
* `role-management-widget` updated to version `0.2.0`
* `user-management-widget` updated to version `0.5.0`
* `user-profile-widget` updated to version `0.1.0`
* `applications-portal-widget` updated to version `0.2.0`
* `web-component` updated to version `3.29.0`

### Features

* add style-id to widgets ([#840](https://github.com/descope/descope-js/issues/840)) ([0573afd](https://github.com/descope/descope-js/commit/0573afd7e3e873a18bfba605643dd20820cf0365))

## [2.1.6](https://github.com/descope/descope-js/compare/vue-sdk-2.1.5...vue-sdk-2.1.6) (2024-11-03)

### 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.1.6",
"version": "2.2.0",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"type": "module",
Expand Down
11 changes: 11 additions & 0 deletions packages/sdks/web-component/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

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

## [3.29.0](https://github.com/descope/descope-js/compare/web-component-3.28.0...web-component-3.29.0) (2024-11-10)

### Dependency Updates

* `sdk-mixins` updated to version `0.4.0`

### Features

* Add nativeResume function and have polling check the current action ([#842](https://github.com/descope/descope-js/issues/842)) RELEASE ([e08a4b8](https://github.com/descope/descope-js/commit/e08a4b8c93516290868db09b0049ba6c374e7d64))
* **descope-ui-mixin:** use descopecdn.com ([#804](https://github.com/descope/descope-js/issues/804)) ([82e2fa7](https://github.com/descope/descope-js/commit/82e2fa779f48b99c8ed88af451fc2a9b329d1758))

## [3.28.0](https://github.com/descope/descope-js/compare/web-component-3.27.3...web-component-3.28.0) (2024-11-03)

### 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.28.0",
"version": "3.29.0",
"author": "Descope Team <info@descope.com>",
"homepage": "https://github.com/descope/descope-js",
"bugs": {
Expand Down
50 changes: 39 additions & 11 deletions packages/sdks/web-component/src/lib/descope-wc/DescopeWc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import {
FETCH_ERROR_RESPONSE_ERROR_CODE,
FETCH_EXCEPTION_ERROR_CODE,
RESPONSE_ACTIONS,
URL_CODE_PARAM_NAME,
URL_RUN_IDS_PARAM_NAME,
URL_TOKEN_PARAM_NAME,
} from '../constants';
import {
fetchContent,
Expand Down Expand Up @@ -103,8 +106,40 @@ class DescopeWc extends BaseDescopeWc {

// This callback will be initialized once a 'nativeBridge' action is
// received from a start or next request. It will then be called by
// the native layer as a response to a dispatched 'bridge' event.
nativeComplete: (bridgeResponse: string) => Promise<void>;
// nativeResume if appropriate as part of handling some payload types.
nativeComplete: (input: Record<string, any>) => Promise<void>;

// This callback is called by the native layer to resume a flow
// that's waiting for some external trigger, such as a magic link
// redirect or native OAuth authentication.
nativeResume = (type: string, payload: string) => {
const response = JSON.parse(payload);
this.logger.info(`nativeResume received payload of type '${type}'`);
if (type === 'oauthWeb' || type === 'sso') {
let { exchangeCode } = response;
if (!exchangeCode) {
const url = new URL(response.url);
exchangeCode = url.searchParams?.get(URL_CODE_PARAM_NAME);
}
this.nativeComplete({
exchangeCode,
idpInitiated: true,
});
} else if (type === 'magicLink') {
const url = new URL(response.url);
const token = url.searchParams.get(URL_TOKEN_PARAM_NAME);
const stepId = url.searchParams
.get(URL_RUN_IDS_PARAM_NAME)
.split('_')
.pop();
this.#resetPollingTimeout();
// update the state along with cancelling out the action to abort the polling mechanism
this.flowState.update({ token, stepId, action: undefined });
} else {
// expected: 'oauthNative', 'webauthnCreate', 'webauthnGet', 'failure'
this.nativeComplete(response);
}
};

// This object is set by the native layer to
// inject native specific data into the 'flowState'.
Expand Down Expand Up @@ -488,8 +523,7 @@ class DescopeWc extends BaseDescopeWc {
// prepare a callback with the current flow state, and accept
// the input to be a JSON, passed down from the native layer.
// this function will be called as an async response to a 'bridge' event
this.nativeComplete = async (bridgeResponse: string) => {
const input = JSON.parse(bridgeResponse);
this.nativeComplete = async (input: Record<string, any>) => {
const sdkResp = await this.sdk.flow.next(
executionId,
stepId,
Expand All @@ -512,7 +546,6 @@ class DescopeWc extends BaseDescopeWc {
this.#handlePollingResponse(
executionId,
stepId,
action,
flowConfig.version,
projectConfig.componentsVersion,
);
Expand Down Expand Up @@ -622,7 +655,6 @@ class DescopeWc extends BaseDescopeWc {
#handlePollingResponse = (
executionId: string,
stepId: string,
action: string,
flowVersion: number,
componentsVersion: string,
rescheduled: boolean = false,
Expand All @@ -632,7 +664,7 @@ class DescopeWc extends BaseDescopeWc {
const pollingThrottleDelay = 500;
const pollingThrottleThreshold = 500;
const pollingThrottleTimeout = 1000;
if (action === RESPONSE_ACTIONS.poll) {
if (this.flowState.current.action === RESPONSE_ACTIONS.poll) {
// schedule next polling request for 2 seconds from now
this.logger.debug('polling - Scheduling polling request');
const scheduledAt = Date.now();
Expand Down Expand Up @@ -676,7 +708,6 @@ class DescopeWc extends BaseDescopeWc {
this.#handlePollingResponse(
executionId,
stepId,
action,
flowVersion,
componentsVersion,
throttled,
Expand All @@ -691,7 +722,6 @@ class DescopeWc extends BaseDescopeWc {
this.#handlePollingResponse(
executionId,
stepId,
action,
flowVersion,
componentsVersion,
);
Expand All @@ -707,12 +737,10 @@ class DescopeWc extends BaseDescopeWc {
}

this.#handleSdkResponse(sdkResp);
const { action: nextAction } = sdkResp?.data ?? {};
// will poll again if needed
this.#handlePollingResponse(
executionId,
stepId,
nextAction,
flowVersion,
componentsVersion,
);
Expand Down
Loading

0 comments on commit c57559b

Please sign in to comment.