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

feat!: rename to @capacitor-community/generic-oauth2 and re-init plugin #257

Merged
merged 1 commit into from
May 3, 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
8 changes: 0 additions & 8 deletions .editorconfig

This file was deleted.

2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
dist
62 changes: 59 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,61 @@
.idea
node_modules
# node files
dist
node_modules

# iOS files
Pods
Podfile.lock
Build
xcuserdata

# macOS files
.DS_Store
*.tgz



# Based on Android gitignore template: https://github.com/github/gitignore/blob/HEAD/Android.gitignore

# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin
gen
out

# Gradle files
.gradle
build

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation

# Android Studio captures folder
captures

# IntelliJ
*.iml
.idea

# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
#*.jks

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ require 'json'
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))

Pod::Spec.new do |s|
s.name = 'ByteowlsCapacitorOauth2'
s.name = 'CapacitorCommunityGenericOAuth2'
s.version = package['version']
s.summary = package['description']
s.license = package['license']
s.homepage = package['repository']['url']
s.author = package['author']
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
s.source_files = 'ios/ByteowlsCapacitorOauth2/Source/*.{swift,h,m,c,cc,mm,cpp}'
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
s.ios.deployment_target = '13.0'
s.dependency 'Capacitor'
s.dependency 'OAuthSwift', '2.2.0'
Expand Down
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

<a href="#sponsors"><img src="https://img.shields.io/badge/plugin-Sponsors-blue?style=flat-square" /></a>
<a href="https://github.com/moberwasserlechner/capacitor-oauth2/actions/workflows/ci.yml"><img src="https://github.com/moberwasserlechner/capacitor-oauth2/actions/workflows/ci.yml/badge.svg?branch=main" /></a>
<a href="https://www.npmjs.com/package/@byteowls/capacitor-oauth2"><img src="https://img.shields.io/npm/dw/@byteowls/capacitor-oauth2?style=flat-square" /></a>
<a href="https://www.npmjs.com/package/@byteowls/capacitor-oauth2"><img src="https://img.shields.io/npm/v/@byteowls/capacitor-oauth2?style=flat-square" /></a>
<a href="LICENSE"><img src="https://img.shields.io/npm/l/@byteowls/capacitor-oauth2?style=flat-square" /></a>
<a href="https://www.npmjs.com/package/@capacitor-community/generic-oauth"><img src="https://img.shields.io/npm/dw/@capacitor-community/generic-oauth?style=flat-square" /></a>
<a href="https://www.npmjs.com/package/@capacitor-community/generic-oauth"><img src="https://img.shields.io/npm/v/@capacitor-community/generic-oauth?style=flat-square" /></a>
<a href="LICENSE"><img src="https://img.shields.io/npm/l/@capacitor-community/generic-oauth?style=flat-square" /></a>

This is a **generic OAuth 2 client** plugin. It let you configure the oauth parameters yourself instead of using SDKs. Therefore it is usable with various providers.
See [identity providers](#list-of-providers) the community has already used this plugin with.
Expand All @@ -13,18 +13,18 @@ See [identity providers](#list-of-providers) the community has already used this

For Capacitor v5
```bash
npm i @byteowls/capacitor-oauth2
npm i @capacitor-community/generic-oauth
npx cap sync
```

For Capacitor v4
```bash
npm i @byteowls/capacitor-oauth2@4
npm i @capacitor-community/generic-oauth@4
npx cap sync
```
For Capacitor v3
```bash
npm i @byteowls/capacitor-oauth2@3
npm i @capacitor-community/generic-oauth@3
npx cap sync
```

Expand Down Expand Up @@ -111,7 +111,7 @@ Starting with version 3.0.0, the plugin is registered automatically on all platf
### Use it

```typescript
import {OAuth2Client} from "@byteowls/capacitor-oauth2";
import {OAuth2Client} from "@capacitor-community/generic-oauth";

@Component({
template: '<button (click)="onOAuthBtnClick()">Login with OAuth</button>' +
Expand Down Expand Up @@ -236,15 +236,15 @@ These parameters are overrideable in every platform

| parameter | default | required | description | since |
|------------------------------ |--------- |---------- |-------------------------------------------------------------------------------------------------------------------------- |------- |
| customHandlerClass | | | Provide a class name implementing `com.byteowls.capacitor.oauth2.handler.OAuth2CustomHandler` | |
| customHandlerClass | | | Provide a class name implementing `com.getcapacitor.community.genericoauth2.handler.OAuth2CustomHandler` | |
| handleResultOnNewIntent | `false` | | Alternative to handle the activity result. The `onNewIntent` method is only call if the App was killed while logging in. | |
| handleResultOnActivityResult | `true` | | | |

**Platform iOS**

| parameter | default | required | description | since |
|-------------------- |--------- |---------- |------------------------------------------------------------------------------------------------ |------- |
| customHandlerClass | | | Provide a class name implementing `ByteowlsCapacitorOauth2.OAuth2CustomHandler` | |
| customHandlerClass | | | Provide a class name implementing `CapacitorCommunityGenericOAuth2.OAuth2CustomHandler` | |
| siwaUseScope | | | SiWA default scope is `name email` if you want to use the configured one set this param `true` | 2.1.0 |


Expand Down Expand Up @@ -416,7 +416,7 @@ This plugin should be as generic as possible, so I don't want to include provide

Therefore, I created a mechanism which let developers integrate custom SDK features in this plugin.
Simply configure the class name in the option property `ios.customHandlerClass`.
This class has to implement `ByteowlsCapacitorOauth2.OAuth2CustomHandler`.
This class has to implement `CapacitorCommunityGenericOAuth2.OAuth2CustomHandler`.

See a full working example below!

Expand Down Expand Up @@ -489,7 +489,7 @@ In Angular do sth like
```typescript
import {Component, OnInit} from '@angular/core';
import {Device, DeviceInfo} from "@capacitor/device";
import {OAuth2Client} from "@byteowls/capacitor-oauth2";
import {OAuth2Client} from "@capacitor-community/generic-oauth";

@Component({
templateUrl: './siwa.component.html'
Expand Down Expand Up @@ -549,7 +549,7 @@ They share the same core features and therefore the plugin should work either wa
#### PWA

```typescript
import {OAuth2AuthenticateOptions, OAuth2Client} from "@byteowls/capacitor-oauth2";
import {OAuth2AuthenticateOptions, OAuth2Client} from "@capacitor-community/generic-oauth";

export class AuthService {

Expand Down Expand Up @@ -589,7 +589,7 @@ Try to experiment with the config until Azure includes everything you need in th
<summary>A configuration with custom scopes might look like this:</summary>

```typescript
import {OAuth2Client} from "@byteowls/capacitor-oauth2";
import {OAuth2Client} from "@capacitor-community/generic-oauth";

getAzureB2cOAuth2Options(): OAuth2AuthenticateOptions {
return {
Expand Down Expand Up @@ -623,7 +623,7 @@ import {OAuth2Client} from "@byteowls/capacitor-oauth2";
<summary>Other configs that works in prior versions</summary>

```typescript
import {OAuth2Client} from "@byteowls/capacitor-oauth2";
import {OAuth2Client} from "@capacitor-community/generic-oauth";

azureLogin() {
OAuth2Client.authenticate({
Expand Down Expand Up @@ -654,7 +654,7 @@ azureLogin() {
```

```typescript
import {OAuth2Client} from "@byteowls/capacitor-oauth2";
import {OAuth2Client} from "@capacitor-community/generic-oauth";

azureLogin() {
OAuth2Client.authenticate({
Expand Down Expand Up @@ -787,7 +787,7 @@ See this [example repo](https://github.com/loonix/capacitor-oauth2-azure-example

#### PWA
```typescript
import {OAuth2Client} from "@byteowls/capacitor-oauth2";
import {OAuth2Client} from "@capacitor-community/generic-oauth";

googleLogin() {
OAuth2Client.authenticate({
Expand Down Expand Up @@ -833,7 +833,7 @@ See [iOS Default Config](#ios-default-config)
#### PWA

```typescript
import {OAuth2Client} from "@byteowls/capacitor-oauth2";
import {OAuth2Client} from "@capacitor-community/generic-oauth";

facebookLogin() {
let fbApiVersion = "2.11";
Expand Down Expand Up @@ -916,8 +916,8 @@ package com.companyname.appname;

import android.app.Activity;

import com.byteowls.capacitor.oauth2.handler.AccessTokenCallback;
import com.byteowls.capacitor.oauth2.handler.OAuth2CustomHandler;
import com.getcapacitor.community.genericoauth2.handler.AccessTokenCallback;
import com.getcapacitor.community.genericoauth2.handler.OAuth2CustomHandler;
import com.companyname.appname.MainActivity;
import com.facebook.AccessToken;
import com.facebook.FacebookCallback;
Expand Down Expand Up @@ -1018,7 +1018,7 @@ install! 'cocoapods', :disable_input_output_paths => true
def capacitor_pods
pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
pod 'ByteowlsCapacitorOauth2', :path => '../../node_modules/@byteowls/capacitor-oauth2'
pod 'CapacitorCommunityGenericOAuth2', :path => '../../node_modules/@capacitor-community/generic-oauth2'
# core plugins
pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app'
pod 'CapacitorDevice', :path => '../../node_modules/@capacitor/device'
Expand Down Expand Up @@ -1067,7 +1067,7 @@ import Foundation
import FacebookCore
import FacebookLogin
import Capacitor
import ByteowlsCapacitorOauth2
import CapacitorCommunityGenericOAuth2

@objc class YourIOsFacebookOAuth2Handler: NSObject, OAuth2CustomHandler {

Expand Down
8 changes: 0 additions & 8 deletions android/.editorconfig

This file was deleted.

6 changes: 1 addition & 5 deletions android/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
build/
.gradle/
.idea/
*.iml
local.properties
/build
12 changes: 0 additions & 12 deletions android/.npmignore

This file was deleted.

8 changes: 4 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ buildscript {
apply plugin: 'com.android.library'

android {
namespace "com.byteowls.capacitor.oauth2"
namespace "com.getcapacitor.community.genericoauth2"
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
defaultConfig {
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
Expand Down Expand Up @@ -51,14 +51,14 @@ android {

unitTestVariants.all {
it.mergedFlavor.manifestPlaceholders += [
appAuthRedirectScheme: "com.byteowls.capacitorapp"
appAuthRedirectScheme: "com.getcapacitor.community.genericoauth2app"
]
}

// testOptions {
// unitTests {
// all {
// include 'com.byteowls.capacitor.oauth2'
// include 'com.getcapacitor.community.genericoauth2'
// }
// }
// }
Expand Down Expand Up @@ -90,5 +90,5 @@ dependencies {
// ###############

android.defaultConfig.manifestPlaceholders = [
'appAuthRedirectScheme': 'com.byteowls.capacitorapp'
'appAuthRedirectScheme': 'com.getcapacitor.community.genericoauth2app'
]
23 changes: 20 additions & 3 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
group=com.byteowls.capacitor
artifactId=capacitor-oauth2
android.useAndroidX=true
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
Binary file modified android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
1 change: 1 addition & 0 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
12 changes: 8 additions & 4 deletions android/gradlew
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

Expand Down Expand Up @@ -133,10 +130,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
Expand Down Expand Up @@ -197,6 +197,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
Loading
Loading