-
Notifications
You must be signed in to change notification settings - Fork 2
SDKS-3941: Migrate Protect from Legacy to new Ping SDK #274
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
Conversation
|
6af5770
to
579c6ba
Compare
View your CI Pipeline Execution ↗ for commit f3ecb6c.
☁️ Nx Cloud last updated this comment at |
Deployed f34d851 to https://ForgeRock.github.io/ping-javascript-sdk/pr-274/f34d851c0e15e3adfffb2d7e51203b615c130c46 branch gh-pages in ForgeRock/ping-javascript-sdk |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #274 +/- ##
=======================================
Coverage 50.26% 50.26%
=======================================
Files 29 29
Lines 1711 1711
Branches 196 195 -1
=======================================
Hits 860 860
Misses 851 851 🚀 New features to boost your workflow:
|
579c6ba
to
6e4b133
Compare
6e4b133
to
24a1fed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I'll let @ryanbas21 be the final arbiter as most of this has to do with the usual scaffolding/infrastructure implementation.
24a1fed
to
8623e44
Compare
moved loading signals sdk out of protect api. added test for failed signals sdk load. |
packages/protect/package.json
Outdated
"url": "git+https://github.com/ForgeRock/ping-javascript-sdk.git", | ||
"directory": "packages/protect" | ||
}, | ||
"sideEffects": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may have misled you. What I meant was something like this:
This is my reasoning/thought process so let me know if this tracks with you.
Tree shaking is the process of dead code removal. This is a static process, so bundlers are doing this based on the static code available during the uglification/minify process.
The signals SDK is not a module. It's just like an iiffe that is executed when the script loads. Additionally, it modifies the window with new functions that it uses. These modify the global scope (window) which are side effects.
So we need to tell bundlers that this file is effectful. It can't be removed. We rely on the effects produced by this in other code that.
So here we can use an array to say the files we are asking not be removed.
Another common input in sideEffect arrays would be CSS files (in a glob syntax) because CSS also changes the dom.
Another one would be a polyfill that extends the Array prototype.
Now - truth be told, I'm not sure the code style of factory functions is very tree shakeable to begin with because the bundler can't execute the factory to determine if some of the code is used or not later on. So it must include it.
But I could be wrong, or maybe things advanced and I'm not sure, so its worth including it anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
@ryanbas21 @cerebrl please review again. Added support for marketplace nodes, updated readme with important note, and changed the module name from |
927f19b
to
a522e9a
Compare
export interface ProtectInitializeConfig | ||
extends Omit<ProtectConfig, 'envId' | 'waitForWindowLoad' | 'hubUrl' | 'externalIdentifiers'> { | ||
_type: 'PingOneProtect'; | ||
_action: 'protect_initialize'; | ||
envId?: string; | ||
customHost?: string; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ryan says, "It's fine"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. I think there's just one correction needed in the README.md file to reflect the name change in the exported function.
packages/protect/README.md
Outdated
The `start` method can be called at application startup, or when you receive the `PingOneProtectInitializeCallback` callback from the server. We recommend you call `start` as soon as you can to collect as much data as possible for higher accuracy. | ||
|
||
```js | ||
import { createProtect } from '@pingidentity/protect'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import is now just protect
, yeah?
b9d2d27
to
86c863d
Compare
updated readme with new naming for protect module and squashed commits |
return undefined; | ||
} | ||
|
||
const protectMetadataCb = cbs.find((metadataCallback) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any chance that there are no metadata
callbacks and this produces undefined
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember, so maybe i should look into this. I maybe wrote it like this originally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nevermind I see the check below
86c863d
to
f3ecb6c
Compare
JIRA Ticket
https://pingidentity.atlassian.net/browse/SDKS-3941
Description
Moves Ping Protect module from legacy SDK using functional pattern. Improves JS Doc annotations and unit tests.
No changeset.