Skip to content
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
117 changes: 117 additions & 0 deletions example/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.7)
base64
nkf
rexml
activesupport (7.2.2)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
atomos (0.1.3)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.8)
claide (1.1.0)
cocoapods (1.15.2)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.15.2)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 2.1, < 3.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.6.0, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored2 (~> 3.1)
escape (~> 0.0.4)
fourflusher (>= 2.3.0, < 3.0)
gh_inspector (~> 1.0)
molinillo (~> 0.8.0)
nap (~> 1.0)
ruby-macho (>= 2.3.0, < 3.0)
xcodeproj (>= 1.23.0, < 2.0)
cocoapods-core (1.15.2)
activesupport (>= 5.0, < 8)
addressable (~> 2.8)
algoliasearch (~> 1.0)
concurrent-ruby (~> 1.1)
fuzzy_match (~> 2.0.4)
nap (~> 1.0)
netrc (~> 0.11)
public_suffix (~> 4.0)
typhoeus (~> 1.0)
cocoapods-deintegrate (1.0.5)
cocoapods-downloader (2.1)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.1)
cocoapods-trunk (1.6.0)
nap (>= 0.8, < 2.0)
netrc (~> 0.11)
cocoapods-try (1.2.0)
colored2 (3.1.2)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
drb (2.2.1)
escape (0.0.4)
ethon (0.16.0)
ffi (>= 1.15.0)
ffi (1.17.0)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
httpclient (2.8.3)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
json (2.8.2)
logger (1.6.1)
minitest (5.25.1)
molinillo (0.8.0)
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
nkf (0.2.0)
public_suffix (4.0.7)
rexml (3.3.9)
ruby-macho (2.5.1)
securerandom (0.3.2)
typhoeus (1.4.1)
ethon (>= 0.9.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
xcodeproj (1.25.1)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (>= 3.3.6, < 4.0)

PLATFORMS
ruby

DEPENDENCIES
activesupport (>= 6.1.7.5, != 7.1.0)
cocoapods (>= 1.13, != 1.15.1, != 1.15.0)
xcodeproj (< 1.26.0)

RUBY VERSION
ruby 3.1.6p260

BUNDLED WITH
2.3.27
3 changes: 3 additions & 0 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ android {
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
manifestPlaceholders = [
appAuthRedirectScheme: 'de.contentpass.demo'
]
}
signingConfigs {
debug {
Expand Down
6 changes: 5 additions & 1 deletion example/ios/ContentpassExample/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#import <RCTAppDelegate.h>
#import <UIKit/UIKit.h>
#import <React/RCTLinkingManager.h>
#import "RNAppAuthAuthorizationFlowManager.h"

@interface AppDelegate : RCTAppDelegate
@interface AppDelegate : RCTAppDelegate <RNAppAuthAuthorizationFlowManager>

@property(nonatomic, weak) id<RNAppAuthAuthorizationFlowManagerDelegate> authorizationFlowManagerDelegate;

@end
10 changes: 10 additions & 0 deletions example/ios/ContentpassExample/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

- (BOOL) application: (UIApplication *)application
openURL: (NSURL *)url
options: (NSDictionary<UIApplicationOpenURLOptionsKey, id> *) options
{
if ([self.authorizationFlowManagerDelegate resumeExternalUserAgentFlowWithURL:url]) {
return YES;
}
return [RCTLinkingManager application:application openURL:url options:options];
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
return [self bundleURL];
Expand Down
21 changes: 21 additions & 0 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
PODS:
- AppAuth (1.7.5):
- AppAuth/Core (= 1.7.5)
- AppAuth/ExternalUserAgent (= 1.7.5)
- AppAuth/Core (1.7.5)
- AppAuth/ExternalUserAgent (1.7.5):
- AppAuth/Core
- boost (1.84.0)
- DoubleConversion (1.1.6)
- FBLazyVector (0.76.2)
Expand Down Expand Up @@ -1242,6 +1248,9 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- react-native-app-auth (8.0.0):
- AppAuth (>= 1.7.3)
- React-Core
- react-native-contentpass (0.1.0):
- DoubleConversion
- glog
Expand All @@ -1263,6 +1272,8 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- react-native-encrypted-storage (4.0.3):
- React-Core
- React-nativeconfig (0.76.2)
- React-NativeModulesApple (0.76.2):
- glog
Expand Down Expand Up @@ -1571,7 +1582,9 @@ DEPENDENCIES:
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
- React-Mapbuffer (from `../node_modules/react-native/ReactCommon`)
- React-microtasksnativemodule (from `../node_modules/react-native/ReactCommon/react/nativemodule/microtasks`)
- react-native-app-auth (from `../node_modules/react-native-app-auth`)
- react-native-contentpass (from `../..`)
- react-native-encrypted-storage (from `../node_modules/react-native-encrypted-storage`)
- React-nativeconfig (from `../node_modules/react-native/ReactCommon`)
- React-NativeModulesApple (from `../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`)
- React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
Expand Down Expand Up @@ -1603,6 +1616,7 @@ DEPENDENCIES:

SPEC REPOS:
trunk:
- AppAuth
- SocketRocket

EXTERNAL SOURCES:
Expand Down Expand Up @@ -1677,8 +1691,12 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon"
React-microtasksnativemodule:
:path: "../node_modules/react-native/ReactCommon/react/nativemodule/microtasks"
react-native-app-auth:
:path: "../node_modules/react-native-app-auth"
react-native-contentpass:
:path: "../.."
react-native-encrypted-storage:
:path: "../node_modules/react-native-encrypted-storage"
React-nativeconfig:
:path: "../node_modules/react-native/ReactCommon"
React-NativeModulesApple:
Expand Down Expand Up @@ -1737,6 +1755,7 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/yoga"

SPEC CHECKSUMS:
AppAuth: 501c04eda8a8d11f179dbe8637b7a91bb7e5d2fa
boost: 1dca942403ed9342f98334bf4c3621f011aa7946
DoubleConversion: f16ae600a246532c4020132d54af21d0ddb2a385
FBLazyVector: bc70dcb22ad30ce734a7cce7210791dc737e230f
Expand Down Expand Up @@ -1772,7 +1791,9 @@ SPEC CHECKSUMS:
React-logger: 81d58ca6f1d93fca9a770bda6cc1c4fbfcc99c9c
React-Mapbuffer: 726951e68f4bb1c2513d322f2548798b2a3d628d
React-microtasksnativemodule: 7a69a9b8fded72ea3cf81923ecf75cad5558ed26
react-native-app-auth: c4a3b4edc11100070d8d7bc48d55fb66668cead9
react-native-contentpass: 8b690145a21ae8c50a96fe6b1a9252b6800b3a7e
react-native-encrypted-storage: db300a3f2f0aba1e818417c1c0a6be549038deb7
React-nativeconfig: 470fce6d871c02dc5eff250a362d56391b7f52d6
React-NativeModulesApple: 6297fc3136c1fd42884795c51d7207de6312b606
React-perflogger: f2c94413cfad44817c96cab33753831e73f0d0dd
Expand Down
4 changes: 3 additions & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
},
"dependencies": {
"react": "18.3.1",
"react-native": "0.76.2"
"react-native": "0.76.2",
"react-native-app-auth": "^8.0.0",
"react-native-encrypted-storage": "^4.0.3"
},
"devDependencies": {
"@babel/core": "^7.25.2",
Expand Down
20 changes: 8 additions & 12 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useEffect } from 'react';
import { StyleSheet, View, Text } from 'react-native';
import { multiply } from 'react-native-contentpass';
import { StyleSheet, View } from 'react-native';
import { ContentpassSdkProvider } from './ContentpassContext';
import ContentpassUsage from './ContentpassUsage';

const styles = StyleSheet.create({
container: {
Expand All @@ -16,15 +16,11 @@ const styles = StyleSheet.create({
});

export default function App() {
const [result, setResult] = useState<number | undefined>();

useEffect(() => {
setResult(multiply(3, 7));
}, []);

return (
<View style={styles.container}>
<Text>Result: {result}</Text>
</View>
<ContentpassSdkProvider>
<View style={styles.container}>
<ContentpassUsage />
</View>
</ContentpassSdkProvider>
);
}
43 changes: 43 additions & 0 deletions example/src/ContentpassContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React, { createContext, useContext, useEffect, useState } from 'react';
import { Contentpass } from 'react-native-contentpass';
import { contentpassConfig } from './contentpassConfig';

const contentpassSdkContext = createContext<Contentpass | undefined>(undefined);

export const ContentpassSdkProvider = ({
children,
}: {
children: React.ReactNode;
}) => {
const [contentpassSdk, setContentpassSdk] = useState<
Contentpass | undefined
>();

useEffect(() => {
const contentpass = new Contentpass(contentpassConfig);

setContentpassSdk(contentpass);
}, []);

if (!contentpassSdk) {
return null;
}

return (
<contentpassSdkContext.Provider value={contentpassSdk}>
{children}
</contentpassSdkContext.Provider>
);
};

export const useContentpassSdk = () => {
const contentpassSdk = useContext(contentpassSdkContext);

if (!contentpassSdk) {
throw new Error(
'useContentpassSdk must be used within a ContentpassSdkProvider'
);
}

return contentpassSdk;
};
23 changes: 23 additions & 0 deletions example/src/ContentpassUsage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { useContentpassSdk } from './ContentpassContext';
import { Button, Text } from 'react-native';
import { useState } from 'react';
import type { AuthenticateResult } from 'react-native-contentpass';

export default function ContentpassUsage() {
const [authResult, setAuthResult] = useState<
AuthenticateResult | undefined
>();
const contentpassSdk = useContentpassSdk();

const authenticate = async () => {
const result = await contentpassSdk.authenticate();
setAuthResult(result);
};

return (
<>
<Button title={'Authenticate'} onPress={authenticate} />
<Text>Result: {JSON.stringify(authResult)}</Text>
</>
);
}
6 changes: 6 additions & 0 deletions example/src/contentpassConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { Config } from 'react-native-contentpass';

export const contentpassConfig: Config = {
propertyId: 'cc3fc4ad-cbe5-4d09-bf85-a49796603b19',
redirectUrl: 'de.contentpass.demo://oauth',
};
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@
"prettier": "^3.0.3",
"react": "18.3.1",
"react-native": "0.76.2",
"react-native-app-auth": "^8.0.0",
"react-native-builder-bob": "^0.32.1",
"react-native-encrypted-storage": "^4.0.3",
"release-it": "^17.10.0",
"turbo": "^1.10.7",
"typescript": "^5.2.2"
Expand All @@ -92,7 +94,9 @@
},
"peerDependencies": {
"react": "*",
"react-native": "*"
"react-native": "*",
"react-native-app-auth": "*",
"react-native-encrypted-storage": "*"
},
"workspaces": [
"example"
Expand Down
Loading