expo-line-login 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +5 -0
- package/android/.gradle/8.1.1/checksums/checksums.lock +0 -0
- package/android/.gradle/8.1.1/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/8.1.1/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.1.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.1.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.1.1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build.gradle +89 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/dev/stanma/line/ExpoLineLoginModule.kt +16 -0
- package/app.plugin.js +1 -0
- package/build/ExpoLineLogin.types.d.ts +7 -0
- package/build/ExpoLineLogin.types.d.ts.map +1 -0
- package/build/ExpoLineLogin.types.js +2 -0
- package/build/ExpoLineLogin.types.js.map +1 -0
- package/build/ExpoLineLoginModule.d.ts +3 -0
- package/build/ExpoLineLoginModule.d.ts.map +1 -0
- package/build/ExpoLineLoginModule.js +5 -0
- package/build/ExpoLineLoginModule.js.map +1 -0
- package/build/ExpoLineLoginModule.web.d.ts +7 -0
- package/build/ExpoLineLoginModule.web.d.ts.map +1 -0
- package/build/ExpoLineLoginModule.web.js +12 -0
- package/build/ExpoLineLoginModule.web.js.map +1 -0
- package/build/ExpoLineLoginView.d.ts +4 -0
- package/build/ExpoLineLoginView.d.ts.map +1 -0
- package/build/ExpoLineLoginView.js +7 -0
- package/build/ExpoLineLoginView.js.map +1 -0
- package/build/ExpoLineLoginView.web.d.ts +4 -0
- package/build/ExpoLineLoginView.web.d.ts.map +1 -0
- package/build/ExpoLineLoginView.web.js +6 -0
- package/build/ExpoLineLoginView.web.js.map +1 -0
- package/build/index.d.ts +16 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +30 -0
- package/build/index.js.map +1 -0
- package/build/types/index.d.ts +28 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/index.js +2 -0
- package/build/types/index.js.map +1 -0
- package/expo-module.config.json +10 -0
- package/ios/AppDelegate.swift +29 -0
- package/ios/ExpoLineLogin.podspec +28 -0
- package/ios/ExpoLineLoginModule.swift +99 -0
- package/package.json +42 -0
- package/plugin/build/index.d.ts +6 -0
- package/plugin/build/index.js +33 -0
- package/plugin/src/index.ts +58 -0
- package/plugin/tsconfig.json +9 -0
- package/src/ExpoLineLoginModule.ts +5 -0
- package/src/index.ts +41 -0
- package/src/types/index.ts +29 -0
- package/tsconfig.json +9 -0
package/.eslintrc.js
ADDED
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
apply plugin: 'com.android.library'
|
|
2
|
+
apply plugin: 'kotlin-android'
|
|
3
|
+
apply plugin: 'maven-publish'
|
|
4
|
+
|
|
5
|
+
group = 'dev.stanma.line'
|
|
6
|
+
version = '0.1.0'
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
10
|
+
if (expoModulesCorePlugin.exists()) {
|
|
11
|
+
apply from: expoModulesCorePlugin
|
|
12
|
+
applyKotlinExpoModulesCorePlugin()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Simple helper that allows the root project to override versions declared by this library.
|
|
16
|
+
ext.safeExtGet = { prop, fallback ->
|
|
17
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Ensures backward compatibility
|
|
21
|
+
ext.getKotlinVersion = {
|
|
22
|
+
if (ext.has("kotlinVersion")) {
|
|
23
|
+
ext.kotlinVersion()
|
|
24
|
+
} else {
|
|
25
|
+
ext.safeExtGet("kotlinVersion", "1.8.10")
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
repositories {
|
|
30
|
+
mavenCentral()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
dependencies {
|
|
34
|
+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}")
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
afterEvaluate {
|
|
39
|
+
publishing {
|
|
40
|
+
publications {
|
|
41
|
+
release(MavenPublication) {
|
|
42
|
+
from components.release
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
repositories {
|
|
46
|
+
maven {
|
|
47
|
+
url = mavenLocal().url
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
android {
|
|
54
|
+
compileSdkVersion safeExtGet("compileSdkVersion", 33)
|
|
55
|
+
|
|
56
|
+
compileOptions {
|
|
57
|
+
sourceCompatibility JavaVersion.VERSION_11
|
|
58
|
+
targetCompatibility JavaVersion.VERSION_11
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
kotlinOptions {
|
|
62
|
+
jvmTarget = JavaVersion.VERSION_11.majorVersion
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
namespace "dev.stanma.line"
|
|
66
|
+
defaultConfig {
|
|
67
|
+
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
68
|
+
targetSdkVersion safeExtGet("targetSdkVersion", 33)
|
|
69
|
+
versionCode 1
|
|
70
|
+
versionName "0.1.0"
|
|
71
|
+
}
|
|
72
|
+
lintOptions {
|
|
73
|
+
abortOnError false
|
|
74
|
+
}
|
|
75
|
+
publishing {
|
|
76
|
+
singleVariant("release") {
|
|
77
|
+
withSourcesJar()
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
repositories {
|
|
83
|
+
mavenCentral()
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
dependencies {
|
|
87
|
+
implementation project(':expo-modules-core')
|
|
88
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
|
|
89
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package dev.stanma.line
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.modules.Module
|
|
4
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
|
+
|
|
6
|
+
class ExpoLineLoginModule : Module() {
|
|
7
|
+
// Each module class must implement the definition function. The definition consists of components
|
|
8
|
+
// that describes the module's functionality and behavior.
|
|
9
|
+
// See https://docs.expo.dev/modules/module-api for more details about available components.
|
|
10
|
+
override fun definition() = ModuleDefinition {
|
|
11
|
+
// Sets the name of the module that JavaScript code will use to refer to the module. Takes a string as an argument.
|
|
12
|
+
// Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
|
|
13
|
+
// The module will be accessible from `requireNativeModule('ExpoLineLogin')` in JavaScript.
|
|
14
|
+
Name("ExpoLineLogin")
|
|
15
|
+
}
|
|
16
|
+
}
|
package/app.plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("./plugin/build");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoLineLogin.types.d.ts","sourceRoot":"","sources":["../src/ExpoLineLogin.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoLineLogin.types.js","sourceRoot":"","sources":["../src/ExpoLineLogin.types.ts"],"names":[],"mappings":"","sourcesContent":["export type ChangeEventPayload = {\n value: string;\n};\n\nexport type ExpoLineLoginViewProps = {\n name: string;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoLineLoginModule.d.ts","sourceRoot":"","sources":["../src/ExpoLineLoginModule.ts"],"names":[],"mappings":";AAIA,wBAAoD"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { requireNativeModule } from "expo-modules-core";
|
|
2
|
+
// It loads the native module object from the JSI or falls back to
|
|
3
|
+
// the bridge module (from NativeModulesProxy) if the remote debugger is on.
|
|
4
|
+
export default requireNativeModule("ExpoLineLogin");
|
|
5
|
+
//# sourceMappingURL=ExpoLineLoginModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoLineLoginModule.js","sourceRoot":"","sources":["../src/ExpoLineLoginModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,kEAAkE;AAClE,4EAA4E;AAC5E,eAAe,mBAAmB,CAAC,eAAe,CAAC,CAAC","sourcesContent":["import { requireNativeModule } from \"expo-modules-core\";\n\n// It loads the native module object from the JSI or falls back to\n// the bridge module (from NativeModulesProxy) if the remote debugger is on.\nexport default requireNativeModule(\"ExpoLineLogin\");\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoLineLoginModule.web.d.ts","sourceRoot":"","sources":["../src/ExpoLineLoginModule.web.ts"],"names":[],"mappings":";;yBAM6B,MAAM,GAAG,QAAQ,IAAI,CAAC;;;AAFnD,wBAQE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EventEmitter } from 'expo-modules-core';
|
|
2
|
+
const emitter = new EventEmitter({});
|
|
3
|
+
export default {
|
|
4
|
+
PI: Math.PI,
|
|
5
|
+
async setValueAsync(value) {
|
|
6
|
+
emitter.emit('onChange', { value });
|
|
7
|
+
},
|
|
8
|
+
hello() {
|
|
9
|
+
return 'Hello world! 👋';
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=ExpoLineLoginModule.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoLineLoginModule.web.js","sourceRoot":"","sources":["../src/ExpoLineLoginModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,EAAS,CAAC,CAAC;AAE5C,eAAe;IACb,EAAE,EAAE,IAAI,CAAC,EAAE;IACX,KAAK,CAAC,aAAa,CAAC,KAAa;QAC/B,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACtC,CAAC;IACD,KAAK;QACH,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CACF,CAAC","sourcesContent":["import { EventEmitter } from 'expo-modules-core';\n\nconst emitter = new EventEmitter({} as any);\n\nexport default {\n PI: Math.PI,\n async setValueAsync(value: string): Promise<void> {\n emitter.emit('onChange', { value });\n },\n hello() {\n return 'Hello world! 👋';\n },\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoLineLoginView.d.ts","sourceRoot":"","sources":["../src/ExpoLineLoginView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAK/D,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,qBAEtE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { requireNativeViewManager } from 'expo-modules-core';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
const NativeView = requireNativeViewManager('ExpoLineLogin');
|
|
4
|
+
export default function ExpoLineLoginView(props) {
|
|
5
|
+
return React.createElement(NativeView, { ...props });
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=ExpoLineLoginView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoLineLoginView.js","sourceRoot":"","sources":["../src/ExpoLineLoginView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,UAAU,GACd,wBAAwB,CAAC,eAAe,CAAC,CAAC;AAE5C,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,KAA6B;IACrE,OAAO,oBAAC,UAAU,OAAK,KAAK,GAAI,CAAC;AACnC,CAAC","sourcesContent":["import { requireNativeViewManager } from 'expo-modules-core';\nimport * as React from 'react';\n\nimport { ExpoLineLoginViewProps } from './ExpoLineLogin.types';\n\nconst NativeView: React.ComponentType<ExpoLineLoginViewProps> =\n requireNativeViewManager('ExpoLineLogin');\n\nexport default function ExpoLineLoginView(props: ExpoLineLoginViewProps) {\n return <NativeView {...props} />;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoLineLoginView.web.d.ts","sourceRoot":"","sources":["../src/ExpoLineLoginView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,qBAMtE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoLineLoginView.web.js","sourceRoot":"","sources":["../src/ExpoLineLoginView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,KAA6B;IACrE,OAAO,CACL;QACE,kCAAO,KAAK,CAAC,IAAI,CAAQ,CACrB,CACP,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\n\nimport { ExpoLineLoginViewProps } from './ExpoLineLogin.types';\n\nexport default function ExpoLineLoginView(props: ExpoLineLoginViewProps) {\n return (\n <div>\n <span>{props.name}</span>\n </div>\n );\n}\n"]}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LoginResult, ProfileResult, AccessToken } from "./types";
|
|
2
|
+
export declare enum LoginPermission {
|
|
3
|
+
EMAIL = "email",
|
|
4
|
+
PROFILE = "profile",
|
|
5
|
+
OPEN_ID = "openid"
|
|
6
|
+
}
|
|
7
|
+
export declare enum BotPrompt {
|
|
8
|
+
NORMAL = "normal",
|
|
9
|
+
AGGRESSIVE = "aggressive"
|
|
10
|
+
}
|
|
11
|
+
export declare const login: (scopes: LoginPermission[], botPrompt: BotPrompt) => Promise<LoginResult>;
|
|
12
|
+
export declare const logout: () => Promise<any>;
|
|
13
|
+
export declare const getProfile: () => Promise<ProfileResult>;
|
|
14
|
+
export declare const getAccessToken: () => Promise<AccessToken>;
|
|
15
|
+
export declare const getBotFriendshipStatus: () => Promise<boolean>;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAElE,oBAAY,eAAe;IACzB,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,OAAO,WAAW;CACnB;AAED,oBAAY,SAAS;IACnB,MAAM,WAAW;IACjB,UAAU,eAAe;CAC1B;AAED,eAAO,MAAM,KAAK,WACR,eAAe,EAAE,aACd,SAAS,KACnB,QAAQ,WAAW,CAKrB,CAAC;AAEF,eAAO,MAAM,MAAM,oBAElB,CAAC;AAEF,eAAO,MAAM,UAAU,QAAa,QAAQ,aAAa,CAExD,CAAC;AAEF,eAAO,MAAM,cAAc,QAAa,QAAQ,WAAW,CAE1D,CAAC;AAEF,eAAO,MAAM,sBAAsB,QAAa,QAAQ,OAAO,CAE9D,CAAC"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Import the native module. On web, it will be resolved to ExpoLineLogin.web.ts
|
|
2
|
+
// and on native platforms to ExpoLineLogin.ts
|
|
3
|
+
import ExpoLineLoginModule from "./ExpoLineLoginModule";
|
|
4
|
+
export var LoginPermission;
|
|
5
|
+
(function (LoginPermission) {
|
|
6
|
+
LoginPermission["EMAIL"] = "email";
|
|
7
|
+
LoginPermission["PROFILE"] = "profile";
|
|
8
|
+
LoginPermission["OPEN_ID"] = "openid";
|
|
9
|
+
})(LoginPermission || (LoginPermission = {}));
|
|
10
|
+
export var BotPrompt;
|
|
11
|
+
(function (BotPrompt) {
|
|
12
|
+
BotPrompt["NORMAL"] = "normal";
|
|
13
|
+
BotPrompt["AGGRESSIVE"] = "aggressive";
|
|
14
|
+
})(BotPrompt || (BotPrompt = {}));
|
|
15
|
+
export const login = async (scopes, botPrompt) => {
|
|
16
|
+
return await ExpoLineLoginModule.login(scopes.map((scope) => scope.toString()), botPrompt.toString());
|
|
17
|
+
};
|
|
18
|
+
export const logout = async () => {
|
|
19
|
+
return await ExpoLineLoginModule.logout();
|
|
20
|
+
};
|
|
21
|
+
export const getProfile = async () => {
|
|
22
|
+
return await ExpoLineLoginModule.getProfile();
|
|
23
|
+
};
|
|
24
|
+
export const getAccessToken = async () => {
|
|
25
|
+
return await ExpoLineLoginModule.getAccessToken();
|
|
26
|
+
};
|
|
27
|
+
export const getBotFriendshipStatus = async () => {
|
|
28
|
+
return await ExpoLineLoginModule.getBotFriendshipStatus();
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,8CAA8C;AAC9C,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAGxD,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,sCAAmB,CAAA;IACnB,qCAAkB,CAAA;AACpB,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B;AAED,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,8BAAiB,CAAA;IACjB,sCAAyB,CAAA;AAC3B,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EACxB,MAAyB,EACzB,SAAoB,EACE,EAAE;IACxB,OAAO,MAAM,mBAAmB,CAAC,KAAK,CACpC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,EACvC,SAAS,CAAC,QAAQ,EAAE,CACrB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,IAAI,EAAE;IAC/B,OAAO,MAAM,mBAAmB,CAAC,MAAM,EAAE,CAAC;AAC5C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,IAA4B,EAAE;IAC3D,OAAO,MAAM,mBAAmB,CAAC,UAAU,EAAE,CAAC;AAChD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,IAA0B,EAAE;IAC7D,OAAO,MAAM,mBAAmB,CAAC,cAAc,EAAE,CAAC;AACpD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,IAAsB,EAAE;IACjE,OAAO,MAAM,mBAAmB,CAAC,sBAAsB,EAAE,CAAC;AAC5D,CAAC,CAAC","sourcesContent":["// Import the native module. On web, it will be resolved to ExpoLineLogin.web.ts\n// and on native platforms to ExpoLineLogin.ts\nimport ExpoLineLoginModule from \"./ExpoLineLoginModule\";\nimport { LoginResult, ProfileResult, AccessToken } from \"./types\";\n\nexport enum LoginPermission {\n EMAIL = \"email\",\n PROFILE = \"profile\",\n OPEN_ID = \"openid\",\n}\n\nexport enum BotPrompt {\n NORMAL = \"normal\",\n AGGRESSIVE = \"aggressive\",\n}\n\nexport const login = async (\n scopes: LoginPermission[],\n botPrompt: BotPrompt,\n): Promise<LoginResult> => {\n return await ExpoLineLoginModule.login(\n scopes.map((scope) => scope.toString()),\n botPrompt.toString(),\n );\n};\n\nexport const logout = async () => {\n return await ExpoLineLoginModule.logout();\n};\n\nexport const getProfile = async (): Promise<ProfileResult> => {\n return await ExpoLineLoginModule.getProfile();\n};\n\nexport const getAccessToken = async (): Promise<AccessToken> => {\n return await ExpoLineLoginModule.getAccessToken();\n};\n\nexport const getBotFriendshipStatus = async (): Promise<boolean> => {\n return await ExpoLineLoginModule.getBotFriendshipStatus();\n};\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface AccessToken {
|
|
2
|
+
token_type: string;
|
|
3
|
+
scope: string;
|
|
4
|
+
refresh_token: string;
|
|
5
|
+
createdAt: number;
|
|
6
|
+
access_token: string;
|
|
7
|
+
id_token?: string;
|
|
8
|
+
expires_in: number;
|
|
9
|
+
}
|
|
10
|
+
interface UserProfile {
|
|
11
|
+
pictureUrl: string;
|
|
12
|
+
userId: string;
|
|
13
|
+
displayName: string;
|
|
14
|
+
}
|
|
15
|
+
export interface LoginResult {
|
|
16
|
+
friendshipStatusChanged?: boolean;
|
|
17
|
+
scope: string;
|
|
18
|
+
IDTokenNonce?: string;
|
|
19
|
+
accessToken: AccessToken;
|
|
20
|
+
userProfile?: UserProfile;
|
|
21
|
+
}
|
|
22
|
+
export interface ProfileResult {
|
|
23
|
+
displayName: string;
|
|
24
|
+
pictureUrl: string;
|
|
25
|
+
userId: string;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,WAAW;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"","sourcesContent":["export interface AccessToken {\n token_type: string;\n scope: string;\n refresh_token: string;\n createdAt: number;\n access_token: string;\n id_token?: string;\n expires_in: number;\n}\n\ninterface UserProfile {\n pictureUrl: string;\n userId: string;\n displayName: string;\n}\n\nexport interface LoginResult {\n friendshipStatusChanged?: boolean;\n scope: string;\n IDTokenNonce?: string;\n accessToken: AccessToken;\n userProfile?: UserProfile;\n}\n\nexport interface ProfileResult {\n displayName: string;\n pictureUrl: string;\n userId: string;\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
import LineSDK
|
|
3
|
+
|
|
4
|
+
public class AppLifecycleDelegate: ExpoAppDelegateSubscriber {
|
|
5
|
+
|
|
6
|
+
public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
|
|
7
|
+
let channelID = Bundle.main.object(forInfoDictionaryKey: "LINE_CHANNEL_ID") as! String
|
|
8
|
+
let univeralLinkStr = Bundle.main.object(forInfoDictionaryKey: "LINE_UNIVERSAL_LINK") as? String
|
|
9
|
+
debugPrint(channelID)
|
|
10
|
+
debugPrint(univeralLinkStr as Any)
|
|
11
|
+
|
|
12
|
+
if univeralLinkStr != nil {
|
|
13
|
+
let universalLink = URL(string: univeralLinkStr ?? "")
|
|
14
|
+
LoginManager.shared.setup(channelID: channelID, universalLinkURL: universalLink)
|
|
15
|
+
} else {
|
|
16
|
+
LoginManager.shared.setup(channelID: channelID, universalLinkURL: nil)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return true
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
|
|
23
|
+
return LoginManager.shared.application(app, open: url, options: options)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
|
|
27
|
+
return LoginManager.shared.application(application, open: userActivity.webpageURL)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'ExpoLineLogin'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.description = package['description']
|
|
10
|
+
s.license = package['license']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.homepage = package['homepage']
|
|
13
|
+
s.platform = :ios, '13.0'
|
|
14
|
+
s.swift_version = '5.4'
|
|
15
|
+
s.source = { git: 'https://github.com/stanma9107/expo-line-login' }
|
|
16
|
+
s.static_framework = true
|
|
17
|
+
|
|
18
|
+
s.dependency 'ExpoModulesCore'
|
|
19
|
+
s.dependency 'LineSDKSwift', '~> 5.0'
|
|
20
|
+
|
|
21
|
+
# Swift/Objective-C compatibility
|
|
22
|
+
s.pod_target_xcconfig = {
|
|
23
|
+
'DEFINES_MODULE' => 'YES',
|
|
24
|
+
'SWIFT_COMPILATION_MODE' => 'wholemodule'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
s.source_files = "**/*.{h,m,swift}"
|
|
28
|
+
end
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
import LineSDK
|
|
3
|
+
|
|
4
|
+
enum BotPromptType: String, Enumerable {
|
|
5
|
+
case aggressive
|
|
6
|
+
case normal
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
public class ExpoLineLoginModule: Module {
|
|
10
|
+
// Each module class must implement the definition function. The definition consists of components
|
|
11
|
+
// that describes the module's functionality and behavior.
|
|
12
|
+
// See https://docs.expo.dev/modules/module-api for more details about available components.
|
|
13
|
+
public func definition() -> ModuleDefinition {
|
|
14
|
+
Name("ExpoLineLogin")
|
|
15
|
+
|
|
16
|
+
AsyncFunction("login") { (scope: [String], botPrompt: BotPromptType?, promise: Promise) in
|
|
17
|
+
let scopes = scope.map{ LoginPermission(rawValue: $0) }
|
|
18
|
+
var parameters: LoginManager.Parameters = LoginManager.Parameters.init()
|
|
19
|
+
if (botPrompt != nil) {
|
|
20
|
+
parameters.botPromptStyle = LoginManager.BotPrompt(rawValue: botPrompt!.rawValue)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
DispatchQueue.main.async {
|
|
24
|
+
LoginManager.shared.login(
|
|
25
|
+
permissions: Set(scopes),
|
|
26
|
+
in: nil,
|
|
27
|
+
parameters: parameters
|
|
28
|
+
) { result in
|
|
29
|
+
switch result {
|
|
30
|
+
case .success(let value):
|
|
31
|
+
do {
|
|
32
|
+
let valueJson = try value.toJSON()
|
|
33
|
+
promise.resolve(valueJson)
|
|
34
|
+
} catch {
|
|
35
|
+
promise.reject(Exception(name: "JSON Parse Error", description: "Error in Parse to JSON"))
|
|
36
|
+
}
|
|
37
|
+
case .failure(let error):
|
|
38
|
+
promise.reject(error)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
AsyncFunction("logout") { (promise: Promise) in
|
|
45
|
+
LoginManager.shared.logout{ result in
|
|
46
|
+
switch(result) {
|
|
47
|
+
case .success: promise.resolve(nil)
|
|
48
|
+
case .failure(let error): promise.reject(error)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
AsyncFunction("getProfile") { (promise: Promise) in
|
|
54
|
+
API.getProfile{ result in
|
|
55
|
+
switch result {
|
|
56
|
+
case .success(let profile):
|
|
57
|
+
do {
|
|
58
|
+
let profileJson = try profile.toJSON()
|
|
59
|
+
promise.resolve(profileJson)
|
|
60
|
+
} catch {
|
|
61
|
+
promise.reject(Exception(name: "JSON Parse Error", description: "Error in Parse to JSON"))
|
|
62
|
+
}
|
|
63
|
+
case .failure(let error):
|
|
64
|
+
promise.reject(error)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
AsyncFunction("getAccessToken") { (promise: Promise) in
|
|
70
|
+
if let token = AccessTokenStore.shared.current {
|
|
71
|
+
do {
|
|
72
|
+
promise.resolve(try token.toJSON())
|
|
73
|
+
} catch {
|
|
74
|
+
promise.reject(Exception(name: "JSON Parse Error", description: "Error in Parse to JSON"))
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
promise.reject(Exception(name: "Error", description: "Get AccessToken Error"))
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
AsyncFunction("getBotFriendshipStatus") { (promise: Promise) in
|
|
82
|
+
API.getBotFriendshipStatus{ result in
|
|
83
|
+
switch result {
|
|
84
|
+
case .success(let value):
|
|
85
|
+
promise.resolve(value.friendFlag)
|
|
86
|
+
case .failure(let error):
|
|
87
|
+
promise.reject(error)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
extension Encodable {
|
|
95
|
+
func toJSON() throws -> Any {
|
|
96
|
+
let data = try JSONEncoder().encode(self)
|
|
97
|
+
return try JSONSerialization.jsonObject(with: data, options: [])
|
|
98
|
+
}
|
|
99
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "expo-line-login",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Integrate LINE login to Expo App",
|
|
5
|
+
"main": "build/index.js",
|
|
6
|
+
"types": "build/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "expo-module build",
|
|
9
|
+
"clean": "expo-module clean",
|
|
10
|
+
"lint": "expo-module lint",
|
|
11
|
+
"test": "expo-module test",
|
|
12
|
+
"prepare": "husky install",
|
|
13
|
+
"prepublishOnly": "expo-module prepublishOnly",
|
|
14
|
+
"expo-module": "expo-module",
|
|
15
|
+
"open:ios": "open -a \"Xcode\" example/ios",
|
|
16
|
+
"open:android": "open -a \"Android Studio\" example/android"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"react-native",
|
|
20
|
+
"expo",
|
|
21
|
+
"expo-line-login",
|
|
22
|
+
"ExpoLineLogin"
|
|
23
|
+
],
|
|
24
|
+
"repository": "https://github.com/stanma9107/expo-line-login",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/stanma9107/expo-line-login/issues"
|
|
27
|
+
},
|
|
28
|
+
"author": "Stan <stan@syntax.email> (https://github.com/stanma9107)",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"homepage": "https://github.com/stanma9107/expo-line-login#readme",
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/react": "^18.0.25",
|
|
33
|
+
"expo-module-scripts": "^3.0.11",
|
|
34
|
+
"expo-modules-core": "^1.5.11",
|
|
35
|
+
"husky": "^8.0.3"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"expo": "*",
|
|
39
|
+
"react": "*",
|
|
40
|
+
"react-native": "*"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ios_1 = require("@expo/config-plugins/build/ios");
|
|
4
|
+
const config_plugins_1 = require("expo/config-plugins");
|
|
5
|
+
const withMyApiKey = (config, { channelId, universalLink }) => {
|
|
6
|
+
config = (0, config_plugins_1.withInfoPlist)(config, (config) => {
|
|
7
|
+
config.modResults["LINE_CHANNEL_ID"] = channelId;
|
|
8
|
+
// push scheme to CFBundleURLSchemes
|
|
9
|
+
config.modResults["CFBundleURLTypes"] = [
|
|
10
|
+
{
|
|
11
|
+
CFBundleURLSchemes: [
|
|
12
|
+
...config.ios?.infoPlist?.CFBundleURLTypes?.[0]?.CFBundleURLSchemes,
|
|
13
|
+
`line3rdp.${ios_1.BundleIdentifier.getBundleIdentifier(config)}`,
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
];
|
|
17
|
+
config.modResults["LSApplicationQueriesSchemes"] = ["lineauth2"];
|
|
18
|
+
if (universalLink) {
|
|
19
|
+
config.modResults["LINE_UNIVERSAL_LINK_URL"] = universalLink;
|
|
20
|
+
}
|
|
21
|
+
return config;
|
|
22
|
+
});
|
|
23
|
+
config = (0, config_plugins_1.withAndroidManifest)(config, (config) => {
|
|
24
|
+
const mainApplication = config_plugins_1.AndroidConfig.Manifest.getMainApplicationOrThrow(config.modResults);
|
|
25
|
+
config_plugins_1.AndroidConfig.Manifest.addMetaDataItemToMainApplication(mainApplication, "LINE_CHANNEL_ID", channelId);
|
|
26
|
+
if (universalLink) {
|
|
27
|
+
config_plugins_1.AndroidConfig.Manifest.addMetaDataItemToMainApplication(mainApplication, "LINE_UNIVERSAL_LINK_URL", universalLink);
|
|
28
|
+
}
|
|
29
|
+
return config;
|
|
30
|
+
});
|
|
31
|
+
return config;
|
|
32
|
+
};
|
|
33
|
+
exports.default = withMyApiKey;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { BundleIdentifier } from "@expo/config-plugins/build/ios";
|
|
2
|
+
import {
|
|
3
|
+
withInfoPlist,
|
|
4
|
+
withAndroidManifest,
|
|
5
|
+
AndroidConfig,
|
|
6
|
+
ConfigPlugin,
|
|
7
|
+
} from "expo/config-plugins";
|
|
8
|
+
|
|
9
|
+
const withMyApiKey: ConfigPlugin<{
|
|
10
|
+
channelId: string;
|
|
11
|
+
universalLink?: string;
|
|
12
|
+
}> = (config, { channelId, universalLink }) => {
|
|
13
|
+
config = withInfoPlist(config, (config) => {
|
|
14
|
+
config.modResults["LINE_CHANNEL_ID"] = channelId;
|
|
15
|
+
// push scheme to CFBundleURLSchemes
|
|
16
|
+
config.modResults["CFBundleURLTypes"] = [
|
|
17
|
+
{
|
|
18
|
+
CFBundleURLSchemes: [
|
|
19
|
+
...config.ios?.infoPlist?.CFBundleURLTypes?.[0]?.CFBundleURLSchemes,
|
|
20
|
+
`line3rdp.${BundleIdentifier.getBundleIdentifier(config)}`,
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
config.modResults["LSApplicationQueriesSchemes"] = ["lineauth2"];
|
|
25
|
+
|
|
26
|
+
if (universalLink) {
|
|
27
|
+
config.modResults["LINE_UNIVERSAL_LINK_URL"] = universalLink;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return config;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
config = withAndroidManifest(config, (config) => {
|
|
34
|
+
const mainApplication = AndroidConfig.Manifest.getMainApplicationOrThrow(
|
|
35
|
+
config.modResults,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
AndroidConfig.Manifest.addMetaDataItemToMainApplication(
|
|
39
|
+
mainApplication,
|
|
40
|
+
"LINE_CHANNEL_ID",
|
|
41
|
+
channelId,
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
if (universalLink) {
|
|
45
|
+
AndroidConfig.Manifest.addMetaDataItemToMainApplication(
|
|
46
|
+
mainApplication,
|
|
47
|
+
"LINE_UNIVERSAL_LINK_URL",
|
|
48
|
+
universalLink,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return config;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return config;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default withMyApiKey;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Import the native module. On web, it will be resolved to ExpoLineLogin.web.ts
|
|
2
|
+
// and on native platforms to ExpoLineLogin.ts
|
|
3
|
+
import ExpoLineLoginModule from "./ExpoLineLoginModule";
|
|
4
|
+
import { LoginResult, ProfileResult, AccessToken } from "./types";
|
|
5
|
+
|
|
6
|
+
export enum LoginPermission {
|
|
7
|
+
EMAIL = "email",
|
|
8
|
+
PROFILE = "profile",
|
|
9
|
+
OPEN_ID = "openid",
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export enum BotPrompt {
|
|
13
|
+
NORMAL = "normal",
|
|
14
|
+
AGGRESSIVE = "aggressive",
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const login = async (
|
|
18
|
+
scopes: LoginPermission[],
|
|
19
|
+
botPrompt: BotPrompt,
|
|
20
|
+
): Promise<LoginResult> => {
|
|
21
|
+
return await ExpoLineLoginModule.login(
|
|
22
|
+
scopes.map((scope) => scope.toString()),
|
|
23
|
+
botPrompt.toString(),
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const logout = async () => {
|
|
28
|
+
return await ExpoLineLoginModule.logout();
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const getProfile = async (): Promise<ProfileResult> => {
|
|
32
|
+
return await ExpoLineLoginModule.getProfile();
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const getAccessToken = async (): Promise<AccessToken> => {
|
|
36
|
+
return await ExpoLineLoginModule.getAccessToken();
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const getBotFriendshipStatus = async (): Promise<boolean> => {
|
|
40
|
+
return await ExpoLineLoginModule.getBotFriendshipStatus();
|
|
41
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface AccessToken {
|
|
2
|
+
token_type: string;
|
|
3
|
+
scope: string;
|
|
4
|
+
refresh_token: string;
|
|
5
|
+
createdAt: number;
|
|
6
|
+
access_token: string;
|
|
7
|
+
id_token?: string;
|
|
8
|
+
expires_in: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface UserProfile {
|
|
12
|
+
pictureUrl: string;
|
|
13
|
+
userId: string;
|
|
14
|
+
displayName: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface LoginResult {
|
|
18
|
+
friendshipStatusChanged?: boolean;
|
|
19
|
+
scope: string;
|
|
20
|
+
IDTokenNonce?: string;
|
|
21
|
+
accessToken: AccessToken;
|
|
22
|
+
userProfile?: UserProfile;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ProfileResult {
|
|
26
|
+
displayName: string;
|
|
27
|
+
pictureUrl: string;
|
|
28
|
+
userId: string;
|
|
29
|
+
}
|