diff --git a/package-lock.json b/package-lock.json index a77171d..78d064d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,10 +8,6 @@ "name": "@capacitor-community/apple-sign-in", "version": "6.0.0", "license": "MIT", - "dependencies": { - "@types/scriptjs": "0.0.2", - "scriptjs": "^2.5.9" - }, "devDependencies": { "@capacitor/android": "^6.0.0", "@capacitor/cli": "^6.0.0", @@ -634,10 +630,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/scriptjs": { - "version": "0.0.2", - "license": "MIT" - }, "node_modules/@types/slice-ansi": { "version": "4.0.0", "dev": true, @@ -4939,10 +4931,6 @@ "node": ">=v12.22.7" } }, - "node_modules/scriptjs": { - "version": "2.5.9", - "license": "MIT" - }, "node_modules/semver": { "version": "7.6.0", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", diff --git a/package.json b/package.json index 2ebb5d7..ff6a0fa 100644 --- a/package.json +++ b/package.json @@ -25,10 +25,7 @@ "prettier": "@ionic/prettier-config", "swiftlint": "@ionic/swiftlint-config", "license": "MIT", - "dependencies": { - "@types/scriptjs": "0.0.2", - "scriptjs": "^2.5.9" - }, + "dependencies": {}, "devDependencies": { "@capacitor/android": "^6.0.0", "@capacitor/cli": "^6.0.0", diff --git a/src/web.ts b/src/web.ts index 5e19477..4c5ac39 100755 --- a/src/web.ts +++ b/src/web.ts @@ -1,5 +1,4 @@ import { WebPlugin } from '@capacitor/core'; -import * as $script from 'scriptjs'; import type { SignInWithAppleOptions, @@ -75,7 +74,23 @@ export class SignInWithAppleWeb return new Promise(resolve => { if (!this.isAppleScriptLoaded) { if (typeof window !== undefined) { - $script.get(this.appleScriptUrl, () => resolve(true)); + if ( + !document.getElementById( + 'capacitor-community__apple-sign-in__script', + ) + ) { + const script = document.createElement('script'); + script.id = 'capacitor-community__apple-sign-in__script'; + script.async = true; + script.src = this.appleScriptUrl; + script.onload = script.onerror = () => { + script.onload = null; + resolve(true); + }; + document.head.insertBefore(script, document.head.lastChild); + } else { + resolve(true); + } } else { resolve(false); }