Skip to content

Commit 5d61062

Browse files
authored
fix: registration hook type (#3975)
OKTA-720583 fix: registration hook type retirejs ignorefile update fix release-update script
1 parent 31b0934 commit 5d61062

7 files changed

Lines changed: 104 additions & 54 deletions

File tree

.retireignore.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
"version": "1.12.4",
55
"justification": "CVE issues (CVE-2019-11358, CVE-2020-11023) have been mitigated with a patched version of jQuery (packages/@okta/courage-dist/esm/src/courage/vendor/lib/jquery-1.12.4.js)"
66
},
7+
{
8+
"component": "underscore.js",
9+
"version": "1.13.1",
10+
"justification": "CVE-2026-27601: _.flatten and _.isEqual DoS via unbounded recursion. Mitigated - the widget does not pass untrusted external input to these functions. Upstream fix requires rebuilding courage-dist with underscore 1.13.8."
11+
},
712
{
813
"component": "dompurify",
914
"version": "2.5.8",

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@
263263
"parse-ms": "^2.0.0",
264264
"q": "1.4.1",
265265
"u2f-api-polyfill": "0.4.3",
266-
"underscore": "1.13.1"
266+
"underscore": "1.13.8"
267267
},
268268
"optionalDependencies": {
269269
"fsevents": "*"
@@ -286,7 +286,8 @@
286286
"**/testcafe-hammerhead/tough-cookie": "^4.1.4",
287287
"stylis": "^4.3.0",
288288
"**/debug": "^4.3.4",
289-
"**/mout": "^1.2.4"
289+
"**/mout": "^1.2.4",
290+
"underscore": "1.13.8"
290291
},
291292
"workspaces": {
292293
"packages": [

scripts/release-update.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ if ! npm install -g yarn@1.22.19; then
1919
fi
2020

2121
export PATH="$PATH:$(npm config get prefix)/bin"
22+
export PATH="$PATH:$(yarn global bin)"
2223

2324
# get latest
2425
git fetch origin && \

src/types/registration.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { APIError } from '@okta/okta-auth-js';
1+
import { APIError, Input } from '@okta/okta-auth-js';
22
import {
33
SimpleCallback
44
} from './results';
@@ -88,6 +88,24 @@ export type Field =
8888
FieldBoolean |
8989
FieldArray;
9090

91+
/**
92+
* Schema element used in OIE (Identity Engine) registration flows.
93+
* In OIE mode, the parseSchema callback receives an array of these elements
94+
* rather than a single RegistrationSchema object.
95+
*
96+
* This type extends the Input type from @okta/okta-auth-js, which represents
97+
* an IDX remediation input field. At runtime, the widget converts Input[]
98+
* into RegistrationElementSchema[] by spreading each Input and adding
99+
* UI-specific properties ('label-top', 'data-se', 'wide', etc.).
100+
*/
101+
export interface RegistrationElementSchema extends Input {
102+
'label-top'?: boolean;
103+
placeholder?: string;
104+
'data-se'?: string;
105+
sublabel?: string;
106+
wide?: boolean;
107+
}
108+
91109
export interface RegistrationSchema {
92110
lastUpdate: number;
93111
policyId: string;
@@ -106,14 +124,14 @@ export interface RegistrationData {
106124
[key: string]: FieldValue;
107125
}
108126

109-
export type RegistrationSchemaCallback = (schema: RegistrationSchema) => void;
127+
export type RegistrationSchemaCallback = (schema: RegistrationSchema | RegistrationElementSchema[]) => void;
110128
export type RegistrationDataCallback = (data: RegistrationData) => void;
111129
export type RegistrationPostSubmitCallback = (response: string) => void;
112130
export type RegistrationErrorCallback = (error: APIError) => void
113131
export interface RegistrationOptions {
114132
click?: SimpleCallback;
115133
parseSchema?: (
116-
schema: RegistrationSchema,
134+
schema: RegistrationSchema | RegistrationElementSchema[],
117135
onSuccess: RegistrationSchemaCallback,
118136
onFailure: RegistrationErrorCallback
119137
) => void;

test/types/options.test-d.ts

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import OktaSignIn, {
22
FieldStringWithFormatAndEnum,
3-
RegistrationSchema,
43
RegistrationData,
54
RegistrationSchemaCallback,
65
RegistrationDataCallback,
@@ -113,25 +112,32 @@ const signIn2 = new OktaSignIn({
113112
click: () => {
114113
window.location.href = 'https://acme.com/sign-up';
115114
},
116-
parseSchema: (schema: RegistrationSchema, onSuccess: RegistrationSchemaCallback, _onFailure: RegistrationErrorCallback) => {
117-
schema.profileSchema.properties.address = {
118-
type: 'string',
119-
description: 'Street Address',
120-
default: 'Enter your street address',
121-
maxLength: 255
122-
};
123-
const countryCode: FieldStringWithFormatAndEnum = {
124-
type: 'country_code',
125-
enum: ['US', 'CA'],
126-
oneOf: [
127-
{title: 'Canada', const: 'CA'},
128-
{title: 'United States', const: 'US'},
129-
]
130-
};
131-
schema.profileSchema.properties['country_code'] = countryCode;
132-
schema.profileSchema.fieldOrder.push('address');
133-
schema.profileSchema.required.push('country_code');
134-
onSuccess(schema);
115+
parseSchema: (schema, onSuccess: RegistrationSchemaCallback, _onFailure: RegistrationErrorCallback) => {
116+
// Classic (V1) path: schema is RegistrationSchema object
117+
if (!Array.isArray(schema)) {
118+
schema.profileSchema.properties.address = {
119+
type: 'string',
120+
description: 'Street Address',
121+
default: 'Enter your street address',
122+
maxLength: 255
123+
};
124+
const countryCode: FieldStringWithFormatAndEnum = {
125+
type: 'country_code',
126+
enum: ['US', 'CA'],
127+
oneOf: [
128+
{title: 'Canada', const: 'CA'},
129+
{title: 'United States', const: 'US'},
130+
]
131+
};
132+
schema.profileSchema.properties['country_code'] = countryCode;
133+
schema.profileSchema.fieldOrder.push('address');
134+
schema.profileSchema.required.push('country_code');
135+
onSuccess(schema);
136+
} else {
137+
// OIE (V2/V3) path: schema is RegistrationElementSchema[]
138+
schema.push({ name: 'address', label: 'Street Address' });
139+
onSuccess(schema);
140+
}
135141
},
136142
preSubmit: (postData: RegistrationData, onSuccess: RegistrationDataCallback, onFailure: RegistrationErrorCallback) => {
137143
const username = <string> postData.username;

test/types/registration.test-d.ts

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-unused-vars */
22
import OktaSignIn, {
33
FieldStringWithFormatAndEnum,
4-
RegistrationSchema,
54
RegistrationData,
65
RegistrationSchemaCallback,
76
RegistrationDataCallback,
@@ -19,25 +18,32 @@ const signIn = new OktaSignIn({
1918
click: () => {
2019
window.location.href = 'https://acme.com/sign-up';
2120
},
22-
parseSchema: (schema: RegistrationSchema, onSuccess: RegistrationSchemaCallback, _onFailure: RegistrationErrorCallback) => {
23-
schema.profileSchema.properties.address = {
24-
type: 'string',
25-
description: 'Street Address',
26-
default: 'Enter your street address',
27-
maxLength: 255
28-
};
29-
const countryCode: FieldStringWithFormatAndEnum = {
30-
type: 'country_code',
31-
enum: ['US', 'CA'],
32-
oneOf: [
33-
{title: 'Canada', const: 'CA'},
34-
{title: 'United States', const: 'US'},
35-
]
36-
};
37-
schema.profileSchema.properties['country_code'] = countryCode;
38-
schema.profileSchema.fieldOrder.push('address');
39-
schema.profileSchema.required.push('country_code');
40-
onSuccess(schema);
21+
parseSchema: (schema, onSuccess: RegistrationSchemaCallback, _onFailure: RegistrationErrorCallback) => {
22+
// Classic (V1) path: schema is RegistrationSchema object
23+
if (!Array.isArray(schema)) {
24+
schema.profileSchema.properties.address = {
25+
type: 'string',
26+
description: 'Street Address',
27+
default: 'Enter your street address',
28+
maxLength: 255
29+
};
30+
const countryCode: FieldStringWithFormatAndEnum = {
31+
type: 'country_code',
32+
enum: ['US', 'CA'],
33+
oneOf: [
34+
{title: 'Canada', const: 'CA'},
35+
{title: 'United States', const: 'US'},
36+
]
37+
};
38+
schema.profileSchema.properties['country_code'] = countryCode;
39+
schema.profileSchema.fieldOrder.push('address');
40+
schema.profileSchema.required.push('country_code');
41+
onSuccess(schema);
42+
} else {
43+
// OIE (V2/V3) path: schema is RegistrationElementSchema[]
44+
schema.push({ name: 'address', label: 'Street Address' });
45+
onSuccess(schema);
46+
}
4147
},
4248
preSubmit: (postData: RegistrationData, onSuccess: RegistrationDataCallback, onFailure: RegistrationErrorCallback) => {
4349
const username = <string> postData.username;
@@ -65,3 +71,21 @@ const signIn = new OktaSignIn({
6571
},
6672
});
6773
expectType<OktaSignIn>(signIn);
74+
75+
// Test OIE registration with RegistrationElementSchema[]
76+
const signInOIE = new OktaSignIn({
77+
baseUrl: 'https://{yourOktaDomain}',
78+
registration: {
79+
parseSchema: (schema, onSuccess: RegistrationSchemaCallback, _onFailure: RegistrationErrorCallback) => {
80+
// OIE path: schema is RegistrationElementSchema[]
81+
if (Array.isArray(schema)) {
82+
schema.push({ name: 'address', label: 'Street Address' });
83+
onSuccess(schema);
84+
}
85+
},
86+
preSubmit: (postData: RegistrationData, onSuccess: RegistrationDataCallback, _onFailure: RegistrationErrorCallback) => {
87+
onSuccess(postData);
88+
},
89+
},
90+
});
91+
expectType<OktaSignIn>(signInOIE);

yarn.lock

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20777,15 +20777,10 @@ underscore.string@~3.3.5:
2077720777
sprintf-js "^1.1.1"
2077820778
util-deprecate "^1.0.2"
2077920779

20780-
underscore@1.13.1:
20781-
version "1.13.1"
20782-
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.1.tgz#0c1c6bd2df54b6b69f2314066d65b6cde6fcf9d1"
20783-
integrity sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g==
20784-
20785-
underscore@~1.12.1:
20786-
version "1.12.1"
20787-
resolved "https://registry.npmjs.org/underscore/-/underscore-1.12.1.tgz#7bb8cc9b3d397e201cf8553336d262544ead829e"
20788-
integrity sha512-hEQt0+ZLDVUMhebKxL4x1BTtDY7bavVofhZ9KZ4aI26X9SRaE+Y3m83XUL1UP2jn8ynjndwCCpEHdUG+9pP1Tw==
20780+
underscore@1.13.8, underscore@~1.12.1:
20781+
version "1.13.8"
20782+
resolved "https://registry.npmjs.org/underscore/-/underscore-1.13.8.tgz#a93a21186c049dbf0e847496dba72b7bd8c1e92b"
20783+
integrity sha512-DXtD3ZtEQzc7M8m4cXotyHR+FAS18C64asBYY5vqZexfYryNNnDc02W4hKg3rdQuqOYas1jkseX0+nZXjTXnvQ==
2078920784

2079020785
undici-types@~5.26.4:
2079120786
version "5.26.5"

0 commit comments

Comments
 (0)