Skip to content
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

refactor!: remove polyfill and fix encoding issue #27

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions packages/rn-sample/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// eslint-disable-next-line import/no-unassigned-import
import '@logto/rn/polyfill';

import { LogtoProvider, Prompt, useLogto, type IdTokenClaims } from '@logto/rn';
import { StatusBar } from 'expo-status-bar';
import { useEffect, useState } from 'react';
Expand Down
8 changes: 4 additions & 4 deletions packages/rn-sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@
"ios": "expo run:ios"
},
"dependencies": {
"@expo/metro-runtime": "~3.1.3",
"@expo/metro-runtime": "~3.2.1",
"@logto/rn": "workspace:^",
"@react-native-async-storage/async-storage": "^1.22.0",
"@react-native-async-storage/async-storage": "^1.23.1",
"expo": "~51.0.8",
"expo-crypto": "^13.0.2",
"expo-secure-store": "^13.0.1",
"expo-status-bar": "~1.12.1",
"expo-web-browser": "^13.0.3",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.73.7",
"react-native": "0.74.1",
"react-native-web": "~0.19.6"
},
"devDependencies": {
"@babel/core": "^7.24.4",
"@silverhand/eslint-config": "^6.0.1",
"@silverhand/eslint-config-react": "^6.0.2",
"@types/react": "~18.2.45",
"@types/react": "~18.2.79",
"eslint": "^8.57.0",
"prettier": "^3.2.5",
"stylelint": "^15.0.0",
Expand Down
8 changes: 2 additions & 6 deletions packages/rn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
"import": "./lib/index.js",
"require": "./lib/index.js",
"types": "./lib/index.d.ts"
},
"./polyfill": {
"import": "./lib/polyfill.js",
"require": "./lib/polyfill.js"
}
},
"files": [
Expand Down Expand Up @@ -56,13 +52,13 @@
"@logto/client": "2.4.0",
"@logto/js": "4.0.0",
"crypto-es": "^2.1.0",
"js-base64": "^3.7.6"
"js-base64": "^3.7.7"
},
"peerDependencies": {
"@react-native-async-storage/async-storage": "^1.23.1",
"expo-crypto": "^13.0.2",
"expo-secure-store": "^13.0.1",
"expo-web-browser": "^13.0.3",
"react-native": ">=0.73.4 <1"
"react-native": ">=0.74.1 <1"
}
}
13 changes: 0 additions & 13 deletions packages/rn/src/polyfill.ts

This file was deleted.

5 changes: 3 additions & 2 deletions packages/rn/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as Crypto from 'expo-crypto';
import { encode, fromUint8Array, toUint8Array } from 'js-base64';
import { fromUint8Array } from 'js-base64';

export const generateRandomString = async (byteLength = 64) =>
fromUint8Array(await Crypto.getRandomBytesAsync(byteLength), true);

export const generateCodeChallenge = async (codeVerifier: string): Promise<string> => {
const encodedCodeVerifier = new TextEncoder().encode(codeVerifier);
const codeChallenge = new Uint8Array(
await Crypto.digest(Crypto.CryptoDigestAlgorithm.SHA256, toUint8Array(encode(codeVerifier)))
await Crypto.digest(Crypto.CryptoDigestAlgorithm.SHA256, encodedCodeVerifier)
);
return fromUint8Array(codeChallenge, true);
};
Loading
Loading