2018-12-22 23:30:39 +01:00

3 lines
7.3 KiB
JavaScript

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("@firebase/app")):"function"==typeof define&&define.amd?define(["@firebase/app"],t):t(e.firebase)}(this,function(e){"use strict";try{(function(){e=e&&e.hasOwnProperty("default")?e.default:e;var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};function n(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{s(r.next(e))}catch(e){i(e)}}function u(e){try{s(r.throw(e))}catch(e){i(e)}}function s(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,u)}s((r=r.apply(e,t||[])).next())})}function r(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=r[2&i[0]?"return":i[0]?"throw":"next"])&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[0,o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var o={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"},i=function(e){function n(t,r,o){var i=e.call(this,r)||this;return Object.setPrototypeOf(i,n.prototype),i.code=t,i.details=o,i}return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(n,e),n}(Error);var a=function(){function e(e){this.app=e}return e.prototype.getAuthToken=function(){return n(this,void 0,void 0,function(){var e;return r(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.app.INTERNAL.getToken()];case 1:return(e=t.sent())?[2,e.accessToken]:[2,void 0];case 2:return t.sent(),[2,void 0];case 3:return[2]}})})},e.prototype.getInstanceIdToken=function(){return n(this,void 0,void 0,function(){var e;return r(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this.app.messaging?[4,this.app.messaging().getToken()]:[2,void 0];case 1:return(e=t.sent())?[2,e]:[2,void 0];case 2:return t.sent(),[2,void 0];case 3:return[2]}})})},e.prototype.getContext=function(){return n(this,void 0,void 0,function(){var e,t;return r(this,function(n){switch(n.label){case 0:return[4,this.getAuthToken()];case 1:return e=n.sent(),[4,this.getInstanceIdToken()];case 2:return t=n.sent(),[2,{authToken:e,instanceIdToken:t}]}})})},e}();function u(e,t){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]=t(e[r]));return n}var s,c=function(){function e(){}return e.prototype.encode=function(e){var t=this;if(null===e||void 0===e)return null;if(e instanceof Number&&(e=e.valueOf()),"number"==typeof e&&isFinite(e))return e;if(!0===e||!1===e)return e;if("[object String]"===Object.prototype.toString.call(e))return e;if(Array.isArray(e))return e.map(function(e){return t.encode(e)});if("function"==typeof e||"object"==typeof e)return u(e,function(e){return t.encode(e)});throw new Error("Data cannot be encoded in JSON: "+e)},e.prototype.decode=function(e){var t=this;if(null===e)return e;if(e["@type"])switch(e["@type"]){case"type.googleapis.com/google.protobuf.Int64Value":case"type.googleapis.com/google.protobuf.UInt64Value":var n=parseFloat(e.value);if(isNaN(n))throw new Error("Data cannot be decoded from JSON: "+e);return n;default:throw new Error("Data cannot be decoded from JSON: "+e)}return Array.isArray(e)?e.map(function(e){return t.decode(e)}):"function"==typeof e||"object"==typeof e?u(e,function(e){return t.decode(e)}):e},e}(),l=function(){function e(e,t){void 0===t&&(t="us-central1"),this.app_=e,this.region_=t,this.serializer=new c,this.emulatorOrigin=null,this.contextProvider=new a(e)}return Object.defineProperty(e.prototype,"app",{get:function(){return this.app_},enumerable:!0,configurable:!0}),e.prototype._url=function(e){var t=this.app_.options.projectId,n=this.region_;return null!==this.emulatorOrigin?this.emulatorOrigin+"/"+t+"/"+n+"/"+e:"https://"+n+"-"+t+".cloudfunctions.net/"+e},e.prototype.useFunctionsEmulator=function(e){this.emulatorOrigin=e},e.prototype.httpsCallable=function(e){var t=this;return function(n){return t.call(e,n)}},e.prototype.postJSON=function(e,t,o){return n(this,void 0,void 0,function(){var n,i;return r(this,function(r){switch(r.label){case 0:o.append("Content-Type","application/json"),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,fetch(e,{method:"POST",body:JSON.stringify(t),headers:o})];case 2:return n=r.sent(),[3,4];case 3:return r.sent(),[2,{status:0,json:null}];case 4:i=null,r.label=5;case 5:return r.trys.push([5,7,,8]),[4,n.json()];case 6:return i=r.sent(),[3,8];case 7:return r.sent(),[3,8];case 8:return[2,{status:n.status,json:i}]}})})},e.prototype.call=function(e,t){return n(this,void 0,void 0,function(){var n,a,u,s,c,l,f;return r(this,function(r){switch(r.label){case 0:return n=this._url(e),t=this.serializer.encode(t),a={data:t},u=new Headers,[4,this.contextProvider.getContext()];case 1:return(s=r.sent()).authToken&&u.append("Authorization","Bearer "+s.authToken),s.instanceIdToken&&u.append("Firebase-Instance-ID-Token",s.instanceIdToken),[4,this.postJSON(n,a,u)];case 2:if(c=r.sent(),l=function(e,t,n){var r=function(e){if(e>=200&&e<300)return"ok";switch(e){case 0:return"internal";case 400:return"invalid-argument";case 401:return"unauthenticated";case 403:return"permission-denied";case 404:return"not-found";case 409:return"aborted";case 429:return"resource-exhausted";case 499:return"cancelled";case 500:return"internal";case 501:return"unimplemented";case 503:return"unavailable";case 504:return"deadline-exceeded"}return"unknown"}(e),a=r,u=void 0;try{var s=t.error;if(s){var c=s.status;if("string"==typeof c){if(!o[c])return new i("internal","internal");r=o[c]}a=c;var l=s.message;"string"==typeof l&&(a=l),void 0!==(u=s.details)&&(u=n.decode(u))}}catch(e){}return"ok"===r?null:new i(r,a,u)}(c.status,c.json,this.serializer))throw l;if(!c.json)throw new i("internal","Response is not valid JSON object.");if(void 0===(f=c.json.data)&&(f=c.json.result),void 0===f)throw new i("internal","Response is missing data field.");return[2,{data:this.serializer.decode(f)}]}})})},e}(),f="functions";function p(e,t,n){return new l(e,n)}s={Functions:l},e.INTERNAL.registerService(f,p,s,void 0,!0)}).apply(this,arguments)}catch(e){throw console.error(e),new Error("Cannot instantiate firebase-functions - be sure to load firebase-app.js first.")}});
//# sourceMappingURL=firebase-functions.js.map