-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create
@magic-sdk/react-native-bare
SDK (#401)
* Remove 'Expo' related dependencies * Pass Mobile App BundeID via MagicSDKExtensionsOptions * Prevent Type.js syntax error * Revert-Pass Mobile App BundeID via MagicSDKExtensionsOptions * Integrate react-native-device-info * @magic-sdk/react-native-bare => @magic-sdk/react-native * Bump version to 12.0.1 * Update README * Update SDK Enviornment Variables * Includes Beta language in README * Update Dependencies * Clean up unecessary log files * Clean up unecessary updates to package.json
- Loading branch information
Showing
56 changed files
with
770 additions
and
342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/node_modules | ||
/coverage | ||
/dist | ||
/.eslintrc.js | ||
/jest.config.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
extends: ['../../../.eslintrc.js'], | ||
parserOptions: { | ||
project: ['./tsconfig.json'], | ||
tsconfigRootDir: __dirname, | ||
}, | ||
} |
File renamed without changes.
File renamed without changes.
110 changes: 110 additions & 0 deletions
110
packages/@magic-ext/bare-react-native-oauth/CHANGELOG.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# v5.0.0 (Tue Dec 20 2022) | ||
|
||
#### 🐛 Bug Fix | ||
|
||
- Merge branch 'master' into mushfichowdhury-sc-61149-implement-event-emitting-in-magic-sdk-based ([@mushfichowdhury-magic](https://github.com/mushfichowdhury-magic)) | ||
- Adds more Context about Expo dependency in `@magic-ext/react-native-oauth` to README [#386](https://github.com/magiclabs/magic-js/pull/386) ([@Ariflo](https://github.com/Ariflo)) | ||
|
||
#### ⚠️ Pushed to `master` | ||
|
||
- Add bundleId to the OAuth query ([@Ethella](https://github.com/Ethella)) | ||
|
||
#### Authors: 3 | ||
|
||
- Arian Flores ([@Ariflo](https://github.com/Ariflo)) | ||
- Jerry Liu ([@Ethella](https://github.com/Ethella)) | ||
- Mushfi Chowdhury ([@mushfichowdhury-magic](https://github.com/mushfichowdhury-magic)) | ||
|
||
--- | ||
|
||
# v3.1.0 (Wed Aug 10 2022) | ||
|
||
#### 🚀 Enhancement | ||
|
||
- bump web-expo-browser version [#345](https://github.com/magiclabs/magic-js/pull/345) ([@Ethella](https://github.com/Ethella)) | ||
|
||
#### Authors: 1 | ||
|
||
- Jerry Liu ([@Ethella](https://github.com/Ethella)) | ||
|
||
--- | ||
|
||
# v2.2.0 (Mon Mar 07 2022) | ||
|
||
#### 🐛 Bug Fix | ||
|
||
- Merge branch 'master' into smithki/better-build-system-documentation ([@smithki](https://github.com/smithki)) | ||
|
||
#### Authors: 1 | ||
|
||
- Ian K Smith ([@smithki](https://github.com/smithki)) | ||
|
||
--- | ||
|
||
# v2.0.0 (Tue Jan 25 2022) | ||
|
||
#### 💥 Breaking Change | ||
|
||
- Switch from `microbundle` to `esbuild` [#220](https://github.com/magiclabs/magic-js/pull/220) ([@smithki](https://github.com/smithki)) | ||
|
||
#### 🐛 Bug Fix | ||
|
||
- Merge with master ([@smithki](https://github.com/smithki)) | ||
- Merge branch 'master' into feat/faster-builds ([@smithki](https://github.com/smithki)) | ||
- Fix build errors related to isolatedModules ([@smithki](https://github.com/smithki)) | ||
|
||
#### Authors: 1 | ||
|
||
- Ian K Smith ([@smithki](https://github.com/smithki)) | ||
|
||
--- | ||
|
||
# v0.5.4 (Thu Oct 21 2021) | ||
|
||
#### 🐛 Bug Fix | ||
|
||
- Revert to `.js` extension for ES module builds targeting webpack/CRA [#232](https://github.com/magiclabs/magic-js/pull/232) ([@smithki](https://github.com/smithki)) | ||
|
||
#### Authors: 1 | ||
|
||
- Ian K Smith ([@smithki](https://github.com/smithki)) | ||
|
||
--- | ||
|
||
# v0.5.3 (Wed Oct 20 2021) | ||
|
||
#### ⚠️ Pushed to `master` | ||
|
||
- Merge branch 'master' of github.com:magiclabs/magic-js ([@smithki](https://github.com/smithki)) | ||
- Force re-publish ([@smithki](https://github.com/smithki)) | ||
|
||
#### Authors: 1 | ||
|
||
- Ian K Smith ([@smithki](https://github.com/smithki)) | ||
|
||
--- | ||
|
||
# v0.5.2 (Wed Oct 20 2021) | ||
|
||
#### 🐛 Bug Fix | ||
|
||
- Use '.mjs' extension for ESM build files [#230](https://github.com/magiclabs/magic-js/pull/230) ([@smithki](https://github.com/smithki)) | ||
|
||
#### Authors: 1 | ||
|
||
- Ian K Smith ([@smithki](https://github.com/smithki)) | ||
|
||
--- | ||
|
||
# v0.4.1 (Thu Sep 23 2021) | ||
|
||
#### 🐛 Bug Fix | ||
|
||
- Port `@magic-ext/oauth`, `@magic-ext/react-native-oauth`, `@magic-ext/webauthn` extensions to Magic SDK monorepo [#218](https://github.com/magiclabs/magic-js/pull/218) ([@smithki](https://github.com/smithki)) | ||
|
||
#### Authors: 1 | ||
|
||
- Ian K Smith ([@smithki](https://github.com/smithki)) | ||
|
||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018-present Magic Labs, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "@magic-ext/bare-react-native-oauth", | ||
"version": "6.0.0", | ||
"description": "Magic SDK OAuth Extension for React Native environments.", | ||
"author": "Magic <[email protected]> (https://magic.link/)", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/magiclabs/magic-js" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"target": "node", | ||
"main": "./dist/cjs/index.js", | ||
"module": "./dist/es/index.js", | ||
"types": "./dist/types/index.d.ts", | ||
"exports": { | ||
"import": "./dist/es/index.mjs", | ||
"require": "./dist/cjs/index.js" | ||
}, | ||
"externals": { | ||
"include": [ | ||
"@magic-sdk/react-native-bare" | ||
] | ||
}, | ||
"dependencies": { | ||
"@magic-sdk/types": "^10.0.0", | ||
"crypto-js": "^3.3.0", | ||
"react-native-device-info": "^10.3.0", | ||
"react-native-inappbrowser-reborn": "^3.7.0" | ||
}, | ||
"devDependencies": { | ||
"@magic-sdk/react-native-bare": "^12.0.0", | ||
"@types/crypto-js": "~3.1.47" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { WordArray } from 'crypto-js'; | ||
import sha256Fallback from 'crypto-js/sha256'; | ||
import Base64 from 'crypto-js/enc-base64'; | ||
|
||
const CHARSET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~'; | ||
const HAS_CRYPTO = typeof window !== 'undefined' && !!(window.crypto as any); | ||
const HAS_SUBTLE_CRYPTO = HAS_CRYPTO && !!(window.crypto.subtle as any); | ||
|
||
/** | ||
* Stringifies `bytes` using the OAuth 2.0 `code_verifier` character set. | ||
*/ | ||
function bytesToVerifierString(bytes: Uint8Array) { | ||
return Array.from(bytes) | ||
.map((value: number) => CHARSET[value % CHARSET.length]) | ||
.join(''); | ||
} | ||
|
||
/** | ||
* Stringifies argument (as CryptoJS `WordArray` or EcmaScript `ArrayBuffer`) | ||
* and encodes to URL-safe Base64. | ||
*/ | ||
function base64URLEncodeFromByteArray(wordArray: WordArray): string; | ||
function base64URLEncodeFromByteArray(arrayBuffer: ArrayBuffer): string; | ||
function base64URLEncodeFromByteArray(arg: WordArray | ArrayBuffer): string { | ||
const makeURLSafe = (base64: string) => { | ||
return base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, ''); | ||
}; | ||
|
||
if (arg instanceof ArrayBuffer) { | ||
const bytes = new Uint8Array(arg); | ||
const utf8Binary = Array.from(bytes) | ||
.map((value) => String.fromCharCode(value)) | ||
.join(''); | ||
|
||
const base64 = btoa(utf8Binary); | ||
return makeURLSafe(base64); | ||
} | ||
|
||
return makeURLSafe(Base64.stringify(arg)); | ||
} | ||
|
||
/** | ||
* Produces a SHA-256 hash of the given `message`. This function first attempts | ||
* to use the browser's built-in `SubtleCrypto` API, falling back to | ||
* CryptoJS if required. | ||
*/ | ||
async function sha256(message: string) { | ||
if (HAS_SUBTLE_CRYPTO) { | ||
const bytes = new TextEncoder().encode(message); | ||
return crypto.subtle.digest('SHA-256', bytes).then(base64URLEncodeFromByteArray); | ||
} | ||
|
||
return base64URLEncodeFromByteArray(sha256Fallback(message)); | ||
} | ||
|
||
/** | ||
* Creates a cryptographically random string using the browser's built-in | ||
* `Crypto` API, falling back to `Math.random` if required. | ||
*/ | ||
function createRandomString(size: number) { | ||
const bytes = new Uint8Array(size); | ||
|
||
if (HAS_CRYPTO) { | ||
window.crypto.getRandomValues(bytes); | ||
} else { | ||
for (let i = 0; i < size; i += 1) bytes[i] = Math.floor(Math.random() * Math.floor(255)); | ||
} | ||
|
||
return bytesToVerifierString(bytes); | ||
} | ||
|
||
/** | ||
* Creates OAuth 2.0-compatible `code_verifier`, `code_challenge`, and `state` | ||
* parameters. | ||
*/ | ||
export async function createCryptoChallenge() { | ||
const state = createRandomString(128); | ||
const verifier = createRandomString(128); | ||
const challenge = await sha256(verifier); | ||
return { verifier, challenge, state }; | ||
} |
Oops, something went wrong.