-
Notifications
You must be signed in to change notification settings - Fork 3
Webcrypto Polyfill package #23
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
Changes from all commits
716eafe
43e995c
43e8267
302e2d4
51df65b
944accf
d0d6649
7987ca3
79af38e
48c49ea
474b9da
572e589
ddcc08b
f4d9c4f
5bbfbcb
83352e8
2fd97ee
fb56ffa
4f619d3
c010dc9
ebd8b56
7eb295d
c2b2fb5
c35d929
5a3a370
61cd93d
1c74261
1039a05
2c6011a
e68679c
0662bc7
2b6983b
409d7b6
cd339bd
496cb92
49b378d
abe0bb3
6d6ea74
8d49b7f
43b0c04
307a619
6bd4cc1
1b60869
322073d
83706b9
07e0d2c
5464599
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| version: 2.1 | ||
|
|
||
| orbs: | ||
| general-platform-helpers: okta/general-platform-helpers@1.9.4 | ||
| platform-helpers: okta/platform-helpers@2.0.0 | ||
| macos: circleci/macos@2 | ||
| android: circleci/android@3.1.0 | ||
|
|
||
| executors: | ||
| # android: | ||
| # docker: | ||
| # - image: cimg/android:2024.12 | ||
| # environment: | ||
| # GRADLE_OPTS: -Xmx2g | ||
| # resource_class: large | ||
|
|
||
| macos: | ||
| macos: | ||
| xcode: "16.3" | ||
| resource_class: m4pro.medium | ||
|
|
||
| jobs: | ||
| test-android: | ||
| executor: | ||
| name: android/android_machine | ||
| resource_class: large | ||
| tag: default | ||
| steps: | ||
| - checkout | ||
|
|
||
| - restore_cache: | ||
| keys: | ||
| - gradle-{{ checksum "packages/react-native-webcrypto-bridge/android/build.gradle" }} | ||
| - gradle- | ||
|
|
||
| - run: | ||
| name: Run Android Unit and Integration Tests | ||
| command: | | ||
| cd packages/react-native-webcrypto-bridge/android | ||
| ./gradlew testDebugUnitTest --info | ||
|
|
||
| - save_cache: | ||
| key: gradle-{{ checksum "packages/react-native-webcrypto-bridge/android/build.gradle" }} | ||
| paths: | ||
| - ~/.gradle | ||
| - .gradle | ||
|
|
||
| - store_test_results: | ||
| path: packages/react-native-webcrypto-bridge/android/build/test-results | ||
|
|
||
| - store_artifacts: | ||
| path: packages/react-native-webcrypto-bridge/android/build/reports | ||
| destination: android-test-reports | ||
|
|
||
| test-ios: | ||
| executor: macos | ||
| steps: | ||
| - checkout | ||
|
|
||
| - restore_cache: | ||
| keys: | ||
| - swift-spm-{{ checksum "packages/react-native-webcrypto-bridge/ios/Package.swift" }} | ||
| - swift-spm- | ||
|
|
||
| - run: | ||
| name: Run iOS Unit and Integration Tests | ||
| command: | | ||
| cd packages/react-native-webcrypto-bridge/ios | ||
| swift test --verbose | ||
|
|
||
| - save_cache: | ||
| key: swift-spm-{{ checksum "packages/react-native-webcrypto-bridge/ios/Package.swift" }} | ||
| paths: | ||
| - packages/react-native-webcrypto-bridge/ios/.build | ||
|
|
||
| - store_test_results: | ||
| path: packages/react-native-webcrypto-bridge/ios/.build/test-results | ||
|
|
||
| - store_artifacts: | ||
| path: packages/react-native-webcrypto-bridge/ios/.build | ||
| destination: ios-build-artifacts | ||
|
|
||
| workflows: | ||
| version: 2 | ||
| build_and_test: | ||
| jobs: | ||
| - test-android | ||
| - test-ios |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,3 +39,5 @@ yarn-error.* | |
| *.tsbuildinfo | ||
|
|
||
| app-example | ||
|
|
||
| .idea/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| module.exports = function (api) { | ||
| api.cache(true); | ||
|
|
||
| return { | ||
| presets: ['babel-preset-expo'], | ||
| plugins: [ | ||
| '@babel/plugin-transform-class-static-block', | ||
| ], | ||
| }; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,29 @@ | ||
| import { useCallback } from 'react'; | ||
| import { useRouter, type Router } from 'expo-router'; | ||
| import { Platform } from 'react-native'; | ||
| import { openAuthSessionAsync } from 'expo-web-browser'; | ||
| import { AuthorizationCodeFlow, SessionLogoutFlow, AuthTransaction } from '@okta/oauth2-flows'; | ||
| import { Credential } from '@okta/auth-foundation'; | ||
| // import { AuthorizationCodeFlow, SessionLogoutFlow, AuthTransaction } from '@okta/oauth2-flows'; | ||
| // import { Credential } from '@okta/auth-foundation/core'; | ||
| import { | ||
| AuthorizationCodeFlow, | ||
| SessionLogoutFlow, | ||
| AuthTransaction, | ||
| Credential | ||
| } from '@okta/react-native-platform'; | ||
| import { client } from '@/auth'; | ||
|
|
||
|
|
||
| async function performSignIn () { | ||
| try { | ||
| console.log('here 1') | ||
| // Platform-specific redirect URI - iOS uses single slash, Android uses double slash | ||
| const redirectUri = Platform.OS === 'ios' | ||
| ? 'com.oktapreview.jperreault-test:/callback' | ||
| : 'com.oktapreview.jperreault-test://callback'; | ||
|
Comment on lines
+19
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is really platform specific, you can just change the OIDC config to match in the auth server configuration.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just test app code - I'll clean this up in a follow up PR |
||
|
|
||
| // TODO: move to env | ||
| const flow = new AuthorizationCodeFlow(client, { | ||
| redirectUri: 'com.oktapreview.jperreault-test:/callback' | ||
| redirectUri | ||
| }); | ||
|
|
||
| // TODO: improve this pattern, too awkward | ||
|
|
@@ -23,7 +35,7 @@ async function performSignIn () { | |
| // @ts-ignore | ||
| const transaction = new AuthTransaction(flow.context); | ||
| await transaction.save(); | ||
| const result = await openAuthSessionAsync(uri.href, 'com.oktapreview.jperreault-test:/callback'); | ||
| const result = await openAuthSessionAsync(uri.href, redirectUri); | ||
| console.log('result: ', result) | ||
| // @ts-ignore | ||
| const { token, context } = await flow.resume(result.url); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import '@expo/metro-runtime'; | ||
| import 'expo-router/entry'; | ||
|
|
||
| import { Platform, installWebCryptoPolyfill } from '@okta/react-native-platform'; | ||
| installWebCryptoPolyfill(); | ||
|
|
||
| console.log('Plat', Platform, Platform.TimeCoordinator) | ||
| console.log("globalThis.crypto", globalThis.crypto); | ||
| // global.crypto = global.crypto ?? globalThis.crypto; | ||
|
|
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.
Commented-out?
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 is just test app code - I'll clean this up in a follow up PR