1/* 2 * Copyright (c) 2020-2025, FusionAuth, All Rights Reserved 3 */ 4'use strict'; 5 6var FusionAuth = FusionAuth || {}; 7FusionAuth.IdentityProvider = FusionAuth.IdentityProvider || {}; 8 9/** 10 * @constructor 11 */ 12FusionAuth.IdentityProvider.Apple = function() { 13 Prime.Utils.bindAll(this); 14 15 Prime.Document.onReady(function() { 16 Prime.Document.addDelegatedEventListener('click', '.apple.login-button', this._handleLoginClick); 17 }.bind(this)); 18}; 19 20FusionAuth.IdentityProvider.Apple.constructor = FusionAuth.IdentityProvider.Apple; 21FusionAuth.IdentityProvider.Apple.prototype = { 22 23 /* =================================================================================================================== 24 * Private methods 25 * ===================================================================================================================*/ 26 27 _handleLoginClick: function(event, target) { 28 Prime.Utils.stopEvent(event); 29 30 if (FusionAuth.IdentityProvider.InProgress) { 31 FusionAuth.IdentityProvider.InProgress.open(); 32 // In Safari, if the user closes the prompt we need to turn off the In Progress indicator. 33 // - I can't find an event to listen for, this will have to do for now. 34 setTimeout(function() { 35 FusionAuth.IdentityProvider.InProgress.close(); 36 }, 3000); // Numeric separators aren't supported until Safari 13, so we shouldn't use 3_000 37 } 38 39 var button = new Prime.Document.Element(target); 40 var identityProviderId = button.getDataAttribute('identityProviderId') ?? '13d2a5db-7ef9-4d62-b909-0df58612e775'; 41 var state = FusionAuth.IdentityProvider.Helper.captureState({ 42 identityProviderId: identityProviderId 43 }); 44 var servicesId = button.getDataAttribute('servicesId'); 45 var scope = button.getDataAttribute('scope'); 46 47 const redirectURI = window.location.protocol 48 + '//' + window.location.hostname 49 + ((window.location.port) ? (':' + window.location.port) : '') 50 + '/oauth2/callback'; 51 52 AppleID.auth.init({ 53 clientId : servicesId, 54 scope : scope, 55 redirectURI : redirectURI, 56 state : state, 57 usePopup : false 58 }); 59 60 AppleID.auth.signIn(); 61 } 62}; 63 64FusionAuth.IdentityProvider.Apple.instance = new FusionAuth.IdentityProvider.Apple(); 65 66//noinspection DuplicatedCode 67if (document.getElementById('idp_helper') === null) { 68 var element = document.createElement('script'); 69 element.id = 'idp_helper'; 70 element.src = '/js/identityProvider/Helper.js?version=' + (FusionAuth.Version || '1.11.0'); 71 element.async = false; 72 document.getElementsByTagName("head")[0].appendChild(element); 73}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.