-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrapsplash.min.js
2 lines (2 loc) · 18.4 KB
/
wrapsplash.min.js
1
2
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("wrapsplash",[],t):"object"==typeof exports?exports.wrapsplash=t():e.wrapsplash=t()}("undefined"!=typeof self?self:this,function(){return function(e){var t={};function r(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=16)}([function(e){e.exports={API_LOCATION:"https://api.unsplash.com/",BEARER_TOKEN_URL:"https://unsplash.com/oauth/token",USERS_PUBLIC_PROFILE:"users/",USERS_PORTFOLIO:"users/:username/portfolio",USERS_PHOTOS:"users/:username/photos",USERS_LIKED_PHOTOS:"users/:username/likes",USERS_COLLECTIONS:"users/:username/collections",USERS_STATISTICS:"users/:username/statistics",LIST_PHOTOS:"photos",LIST_CURATED_PHOTOS:"photos/curated",GET_A_PHOTO:"photos/:id",GET_A_RANDOM_PHOTO:"photos/random",GET_A_PHOTO_STATISTICS:"photos/:id/statistics",GET_A_PHOTO_DOWNLOAD_LINK:"photos/:id/download",UPDATE_A_PHOTO:"photos/:id",LIKE_A_PHOTO:"photos/:id/like",UNLIKE_A_PHOTO:"photos/:id/like",SEARCH_PHOTOS:"search/photos",SEARCH_COLLECTIONS:"search/collections",SEARCH_USERS:"search/users",CURRENT_USER_PROFILE:"me",UPDATE_CURRENT_USER_PROFILE:"me",STATS_TOTALS:"stats/total",STATS_MONTH:"stats/month",LIST_COLLECTIONS:"collections",LIST_FEATURED_COLLECTIONS:"collections/featured",LIST_CURATED_COLLECTIONS:"collections/curated",GET_COLLECTION:"collections/:id",GET_CURATED_COLLECTION:"collections/curated/:id",GET_COLLECTION_PHOTOS:"collections/:id/photos",GET_CURATED_COLLECTION_PHOTOS:"collections/curated/:id/photos",LIST_RELATED_COLLECTION:"collections/:id/related",CREATE_NEW_COLLECTION:"collections",UPDATE_EXISTING_COLLECTION:"collections/:id",DELETE_COLLECTION:"collections/:id",ADD_PHOTO_TO_COLLECTION:"collections/:collection_id/add",REMOVE_PHOTO_FROM_COLLECTION:"collections/:collection_id/remove"}},function(e,t,r){"use strict";e.exports={url:"",method:"",baseURL:"",headers:{},data:{},timeout:1e3,withCredentials:!1,responseType:"json",responseEncoding:"utf8",xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",validateStatus:function(e){return e>=200&&e<300},maxRedirects:5,socketPath:null}},function(e,t){e.exports=require("axios")},function(e,t,r){"use strict";var i=n(r(2)),o=n(r(1));function n(e){return e&&e.__esModule?e:{default:e}}e.exports=function e(t){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.makeRequest=function(e,t,i,o){return r.url=e||function(){throw new Error("URL required")}(),r.queryParameters=i||{},r.body=o||{},r.method=t||"get",r.http({method:r.method,url:r.url,params:r.queryParameters,data:r.body})},this.url="",this.method="",this.options=t||o.default||{},this.queryParameters={},this.body={},this.http=i.default.create(this.options)}},function(e,t){e.exports=require("randomfill")},function(e,t){e.exports=require("public-encrypt")},function(e,t){e.exports=require("create-ecdh")},function(e,t){e.exports=require("browserify-sign")},function(e,t){e.exports=require("diffie-hellman")},function(e,t){e.exports=require("browserify-cipher")},function(e,t){e.exports=require("pbkdf2")},function(e,t){e.exports=require("browserify-sign/algos")},function(e,t){e.exports=require("create-hmac")},function(e,t){e.exports=require("create-hash")},function(e,t){e.exports=require("randombytes")},function(e,t,r){"use strict";t.randomBytes=t.rng=t.pseudoRandomBytes=t.prng=r(14),t.createHash=t.Hash=r(13),t.createHmac=t.Hmac=r(12);var i=r(11),o=Object.keys(i),n=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(o);t.getHashes=function(){return n};var a=r(10);t.pbkdf2=a.pbkdf2,t.pbkdf2Sync=a.pbkdf2Sync;var s=r(9);t.Cipher=s.Cipher,t.createCipher=s.createCipher,t.Cipheriv=s.Cipheriv,t.createCipheriv=s.createCipheriv,t.Decipher=s.Decipher,t.createDecipher=s.createDecipher,t.Decipheriv=s.Decipheriv,t.createDecipheriv=s.createDecipheriv,t.getCiphers=s.getCiphers,t.listCiphers=s.listCiphers;var c=r(8);t.DiffieHellmanGroup=c.DiffieHellmanGroup,t.createDiffieHellmanGroup=c.createDiffieHellmanGroup,t.getDiffieHellman=c.getDiffieHellman,t.createDiffieHellman=c.createDiffieHellman,t.DiffieHellman=c.DiffieHellman;var l=r(7);t.createSign=l.createSign,t.Sign=l.Sign,t.createVerify=l.createVerify,t.Verify=l.Verify,t.createECDH=r(6);var u=r(5);t.publicEncrypt=u.publicEncrypt,t.privateEncrypt=u.privateEncrypt,t.publicDecrypt=u.publicDecrypt,t.privateDecrypt=u.privateDecrypt;var d=r(4);t.randomFill=d.randomFill,t.randomFillSync=d.randomFillSync,t.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join("\n"))},t.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}},function(e,t,r){"use strict";var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n=c(r(15)),a=c(r(3)),s=c(r(0));function c(e){return e&&e.__esModule?e:{default:e}}e.exports=function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.init=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(e&&"object"===(void 0===e?"undefined":o(e))&&null!==e){t.options=i({},e);var r=n.default.createHmac("sha256",t.options.access_key?t.options.access_key:t.options.bearer_token).digest("hex");return t.options.bearer_token?void(t.headers=i({},t.headers,{Authorization:"Bearer "+t.options.bearer_token,"X-WrapSplash-Header":r})):(t.access_key=t.options.access_key?t.options.access_key:function(){throw new Error("Access Key missing!")}(),t.secret_key=t.options.secret_key?t.options.secret_key:function(){throw new Error("Secret Key missing!")}(),t.redirect_uri=t.options.redirect_uri?t.options.redirect_uri:function(){throw new Error("Redirect URI missing!")}(),t.code=t.options.code?t.options.code:function(){throw new Error("Authorization Code missing!")}(),void(t.headers=i({},t.headers,{Authorization:"Client-ID "+t.options.access_key,"X-WrapSplash-Header":r})))}throw new Error("Initilisation parameters required!")},this.fetchUrl=function(e,r){return new a.default({headers:t.headers?t.headers:""}).makeRequest(e,r.toLowerCase()).then(function(e){return 204===e.status?{status:e.status,statusText:e.statusText,message:"Content Deleted"}:403===e.status?{status:e.status,statusText:e.statusText,message:"Rate Limit Exceeded"}:e.data}).catch(function(e){return Promise.reject(e)})},this.generateBearerToken=function(){var e=t.BEARER_TOKEN_URL+"?client_id="+t.access_key+"&client_secret="+t.secret_key+"&redirect_uri="+t.redirect_uri+"&code="+t.code+"&grant_type="+t.grant_type;return t.fetchUrl(e,"POST")},this.getCurrentUserProfile=function(){var e=t.API_LOCATION+s.default.CURRENT_USER_PROFILE;return t.fetchUrl(e,"GET")},this.updateCurrentUserProfile=function(e,r,i,o,n,a,c,l){var u=t.API_LOCATION+s.default.UPDATE_CURRENT_USER_PROFILE+"?"+(e?"?username="+e:"")+(r?"&first_name="+r:"")+(i?"&last_name="+i:"")+(o?"&email="+o:"")+(n?"&url="+n:"")+(a?"&location="+a:"")+(c?"&bio="+c:"")+(l?"&instagram_username="+l:"");return t.fetchUrl(u,"PUT")},this.getPublicProfile=function(e,r,i){var o=t.API_LOCATION+s.default.USERS_PUBLIC_PROFILE+e+"?w="+(r&&!isNaN(r)?+r:"")+"&h="+(i&&!isNaN(i)?+i:"");return t.fetchUrl(o,"GET")},this.getUserPortfolio=function(e){if(!e||""===e||void 0===e)throw new Error("Parameter : username is required and cannot be empty!");var r=t.API_LOCATION+s.default.USERS_PORTFOLIO.replace(/:username/gi,e);return t.fetchUrl(r,"GET")},this.getUserPhotos=function(e,r,i,o,n,a,c){if(!e||""===e||void 0===e)throw new Error("Parameter : username is required and cannot be empty!");if(void 0!==c&&!t.availableOrders.includes(c))throw new Error("Parameter : order_by has an unsupported value!");if(void 0!==o&&"boolean"!=typeof o)throw new Error("Parameter : stats is a boolean or optional!");var l=t.API_LOCATION+s.default.USERS_PHOTOS.replace(/:username/gi,e)+"?page="+(r&&!isNaN(r)?+r:1)+"&per_page="+(i&&!isNaN(i)?+i:10)+"&order_by="+(c||"latest")+"&stats="+(o||"false")+"&resolution="+(n?encodeURIComponent(n):"days")+"&quantity="+(a||30);return t.fetchUrl(l,"GET")},this.getUserLikedPhotos=function(e,r,i,o){if(!e||""===e||void 0===e)throw new Error("Parameter : username is required and cannot be empty!");if(void 0!==o&&!t.availableOrders.includes(o))throw new Error("Parameter : order_by has an unsupported value!");var n=t.API_LOCATION+s.default.USERS_LIKED_PHOTOS.replace(/:username/gi,e)+"?page="+(r&&!isNaN(r)?+r:1)+"&per_page="+(i&&!isNaN(i)?+i:10)+"&order_by="+(o||"latest");return t.fetchUrl(n,"GET")},this.getUserCollections=function(e,r,i){if(!e||""===e||void 0===e)throw new Error("Parameter : username is required and cannot be empty!");var o=t.API_LOCATION+s.default.USERS_COLLECTIONS.replace(/:username/gi,e)+"?page="+(r&&!isNaN(r)?+r:1)+"&per_page="+(i&&!isNaN(i)?+i:10);return t.fetchUrl(o,"GET")},this.getUserStatistics=function(e,r,i){if(!e||""===e||void 0===e)throw new Error("Parameter : username is required and cannot be empty!");var o=t.API_LOCATION+s.default.USERS_STATISTICS.replace(/:username/gi,e)+"?resolution="+(r?encodeURIComponent(r):"days")+"&quantity="+(i||30);return t.fetchUrl(o,"GET")},this.listPhotos=function(e,r,i){if(void 0!==i&&!t.availableOrders.includes(i))throw new Error("Parameter : order_by has an unsupported value!");var o=t.API_LOCATION+s.default.LIST_PHOTOS+"?page="+(e&&!isNaN(e)?+e:1)+"&per_page="+(r&&!isNaN(r)?+r:10)+"&order_by="+(i||"latest");return t.fetchUrl(o,"GET")},this.listCuratedPhotos=function(e,r,i){if(void 0!==i&&!t.availableOrders.includes(i))throw new Error("Parameter : order_by has an unsupported value!");var o=t.API_LOCATION+s.default.LIST_CURATED_PHOTOS+"?page="+(e&&!isNaN(e)?+e:1)+"&per_page="+(r&&!isNaN(r)?+r:10)+"&order_by="+(i||"latest");return t.fetchUrl(o,"GET")},this.getAPhoto=function(e,r,i,o){if(!e||void 0===e||0===e.length)throw new Error("Parameter : id is required!");var n=t.API_LOCATION+s.default.GET_A_PHOTO.replace(/:id/gi,e)+"?w="+(r&&!isNaN(r)?+r:"")+"&h="+(i&&!isNaN(i)?+i:"")+"&rect="+(o&&"string"===o.typeof?+encodeURIComponent(o):"");return t.fetchUrl(n,"GET")},this.getARandomPhoto=function(e,r,i,o,n,a,c,l){if(!t.availableOrientations.includes(c)&&void 0!==c)throw new Error("Parameter : orientation has an unsupported value!");var u=t.API_LOCATION+s.default.GET_A_RANDOM_PHOTO+"?collections="+(e&&!isNaN(e)?+encodeURIComponent(e):"")+"&featured="+(r||!1)+"&username="+(i||"")+"&query="+(o?encodeURIComponent(o):"")+"&width="+(n||"")+"&height="+(a||"")+"&orientation="+(c||"landscape")+"&count="+(l||1);return t.fetchUrl(u,"GET")},this.getPhotoStatistics=function(e,r,i){if(!e||void 0===e||0===e.length)throw new Error("Parameter : id is required!");var o=t.API_LOCATION+s.default.GET_A_PHOTO_STATISTICS.replace(/:id/gi,e)+"?resolution="+(r?encodeURIComponent(r):"days")+"&quantity="+(i||30);return t.fetchUrl(o,"GET")},this.getPhotoLink=function(e){if(!e||void 0===e||0===e.length)throw new Error("Parameter : id is required!");var r=t.API_LOCATION+s.default.GET_A_PHOTO_DOWNLOAD_LINK.replace(/:id/gi,e);return t.fetchUrl(r,"GET")},this.updatePhoto=function(e,r,i){if(!e||void 0===e||0===e.length)throw new Error("Parameter : id is required!");r=Object.assign({},r)||{},i=Object.assign({},i)||{};var o=t.API_LOCATION+s.default.UPDATE_A_PHOTO.replace(/:id/,e)+"?"+(r.latitude?"&location[latitude]="+encodeURIComponent(r.latitude):"")+(r.longitude?"&location[longitude]="+encodeURIComponent(r.longitude):"")+(r.name?"&location[name]="+encodeURIComponent(r.name):"")+(r.city?"&location[city]="+encodeURIComponent(r.city):"")+(r.country?"&location[country]="+encodeURIComponent(r.country):"")+(r.confidential?"&location[confidential]="+encodeURIComponent(r.confidential):"")+(i.make?"&exif[make]="+encodeURIComponent(i.make):"")+(i.model?"&exif[model]="+encodeURIComponent(i.model):"")+(i.exposure_time?"&exif[exposure_time]="+encodeURIComponent(i.exposure_time):"")+(i.aperture_value?"&exif[aperture_value]="+encodeURIComponent(i.aperture_value):"")+(i.focal_length?"&exif[focal_length]="+encodeURIComponent(i.focal_length):"")+(i.iso_speed_ratings?"&exif[iso_speed_ratings]="+encodeURIComponent(i.iso_speed_ratings):"");return t.fetchUrl(o,"PUT")},this.likePhoto=function(e){if(!e||void 0===e||0===e.length)throw new Error("Parameter : id is required!");var r=t.API_LOCATION+s.default.LIKE_A_PHOTO.replace(/:id/gi,e);return t.fetchUrl(r,"POST")},this.unlikePhoto=function(e){if(!e||void 0===e||0===e.length)throw new Error("Parameter : id is required!");var r=t.API_LOCATION+s.default.UNLIKE_A_PHOTO.replace(/:id/gi,e);return t.fetchUrl(r,"DELETE")},this.search=function(e,r,i,o,n){if(!t.availableOrientations.includes(n)&&void 0!==n)throw new Error("Parameter : orientation has an unsupported value!");if(void 0===e)throw new Error("Parameter : query is missing!");var a=t.API_LOCATION+s.default.SEARCH_PHOTOS+"?query="+(e?encodeURIComponent(e):"")+"&page="+(r&&!isNaN(r)?+r:1)+"&per_page="+(i&&!isNaN(i)?+i:10)+"&collections="+(o&&!isNaN(o)?+o:"")+"&orientation="+(n?encodeURIComponent(n):"");return t.fetchUrl(a,"GET")},this.searchCollections=function(e,r,i){if(void 0===e)throw new Error("Parameter : query is missing!");var o=t.API_LOCATION+s.default.SEARCH_COLLECTIONS+"?query="+(e?encodeURIComponent(e):"")+"&page="+(r&&!isNaN(r)?+r:1)+"&per_page="+(i&&!isNaN(i)?+i:10);return t.fetchUrl(o,"GET")},this.searchUsers=function(e,r,i){if(void 0===e)throw new Error("Parameter : query is missing!");var o=t.API_LOCATION+s.default.SEARCH_USERS+"?query="+(e?encodeURIComponent(e):"")+"&page="+(r&&!isNaN(r)?+r:1)+"&per_page="+(i&&!isNaN(i)?+i:10);return t.fetchUrl(o,"GET")},this.getStatsTotals=function(){var e=t.API_LOCATION+s.default.STATS_TOTALS;return t.fetchUrl(e,"GET")},this.getStatsMonth=function(){var e=t.API_LOCATION+s.default.STATS_MONTH;return t.fetchUrl(e,"GET")},this.listCollections=function(e,r){var i=t.API_LOCATION+s.default.LIST_COLLECTIONS+"?page="+(e&&!isNaN(e)?+e:1)+"&per_page="+(r&&!isNaN(r)?+r:10);return t.fetchUrl(i,"GET")},this.listFeaturedCollections=function(e,r){var i=t.API_LOCATION+s.default.LIST_FEATURED_COLLECTIONS+"?page="+(e&&!isNaN(e)?+e:1)+"&per_page="+(r&&!isNaN(r)?+r:10);return t.fetchUrl(i,"GET")},this.listCuratedCollections=function(e,r){var i=t.API_LOCATION+s.default.LIST_CURATED_COLLECTIONS+"?page="+(e&&!isNaN(e)?+e:1)+"&per_page="+(r&&!isNaN(r)?+r:10);return t.fetchUrl(i,"GET")},this.getCollection=function(e){if(!e||void 0===e||0===e.length)throw new Error("Parameter : id is required!");var r=t.API_LOCATION+s.default.GET_COLLECTION.replace(/:id/gi,e);return t.fetchUrl(r,"GET")},this.getCuratedCollection=function(e){if(!e||void 0===e||0===e.length)throw new Error("Parameter : id is required!");var r=t.API_LOCATION+s.default.GET_CURATED_COLLECTION.replace(/:id/gi,e);return t.fetchUrl(r,"GET")},this.getCollectionPhotos=function(e,r,i){if(!e||void 0===e||0===e.length)throw new Error("Parameter : id is required!");var o=t.API_LOCATION+s.default.GET_COLLECTION_PHOTOS.replace(/:id/gi,e)+"?page="+(r&&!isNaN(r)?+r:1)+"&per_page="+(i&&!isNaN(i)?+i:10);return t.fetchUrl(o,"GET")},this.getCuratedCollectionPhotos=function(e,r,i){if(!e||void 0===e||0===e.length)throw new Error("Parameter : id is required!");var o=t.API_LOCATION+s.default.GET_CURATED_COLLECTION_PHOTOS.replace(/:id/gi,e)+"?page="+(r&&!isNaN(r)?+r:1)+"&per_page="+(i&&!isNaN(i)?+i:10);return t.fetchUrl(o,"GET")},this.listRelatedCollections=function(e){if(!e||void 0===e||0===e.length)throw new Error("Parameter : id is required!");var r=t.API_LOCATION+s.default.LIST_RELATED_COLLECTION.replace(/:id/gi,e);return t.fetchUrl(r,"GET")},this.createNewColection=function(e,r,i){if(!e||void 0===e||0===e.length)throw new Error("Parameter : title is required!");i=i||!1;var o=t.API_LOCATION+s.default.CREATE_NEW_COLLECTION+"?title="+encodeURIComponent(e)+(r?"&description="+encodeURIComponent(r):"")+"&private="+i;return t.fetchUrl(o,"POST")},this.updateExistingCollection=function(e,r,i,o){if(!e||void 0===e||0===e.length)throw new Error("Parameter : id is required!");if(!r||void 0===r||0===r.length)throw new Error("Parameter : title is required!");o=o||!1;var n=t.API_LOCATION+s.default.UPDATE_EXISTING_COLLECTION.replace(/:id/gi,e)+"?title="+encodeURIComponent(r)+(i?"&description="+encodeURIComponent(i):"")+"&private="+o;return t.fetchUrl(n,"PUT")},this.deleteCollection=function(e){if(!e||void 0===e||0===e.length)throw new Error("Parameter : id is required!");var r=t.API_LOCATION+s.default.DELETE_COLLECTION.replace(/:id/gi,e);return t.fetchUrl(r,"DELETE")},this.addPhotoToCollection=function(e,r){if(!e||void 0===e||0===e.length)throw new Error("Parameter : collection_id is required!");if(!r||void 0===r||0===r.length)throw new Error("Parameter : photo_id is required!");var i=t.API_LOCATION+s.default.ADD_PHOTO_TO_COLLECTION.replace(/:collection_id/gi,e)+"?photo_id="+r;return t.fetchUrl(i,"POST")},this.removePhotoFromCollection=function(e,r){if(!e||void 0===e||0===e.length)throw new Error("Parameter : collection_id is required!");if(!r||void 0===r||0===r.length)throw new Error("Parameter : photo_id is required!");var i=t.API_LOCATION+s.default.REMOVE_PHOTO_FROM_COLLECTION.replace(/:collection_id/gi,e)+"?photo_id="+r;return t.fetchUrl(i,"DELETE")},this.API_LOCATION=s.default.API_LOCATION,this.BEARER_TOKEN_URL=s.default.BEARER_TOKEN_URL,this.options={},this.access_key="",this.secret_key="",this.redirect_uri="",this.code="",this.grant_type="authorization_code",this.bearer_token="",this.headers={"Content-type":"application/json","X-Requested-With":"WrapSplash"},this.availableOrders=["latest","oldest","popular"],this.availableOrientations=["landscape","portrait","squarish"]}}])});
//# sourceMappingURL=wrapsplash.min.js.map