You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

unsplash-js

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.1 to 2.1.0

49

dist/unsplash.js

@@ -365,10 +365,7 @@ (function webpackUniversalModuleDefinition(root, factory) {

removePhotoFromCollection: function removePhotoFromCollection(collectionId, photoId) {
var url = "/collections/" + collectionId + "/remove";
var url = "/collections/" + collectionId + "/remove?photo_id=" + photoId;
return _this.request({
url: url,
method: "DELETE",
body: {
photo_id: photoId
}
method: "DELETE"
});

@@ -465,3 +462,3 @@ }

url: endpointUrl,
method: "POST",
method: "PUT",
body: body

@@ -487,3 +484,6 @@ });

return {
listPhotos: function listPhotos(page, perPage) {
listPhotos: function listPhotos() {
var page = arguments.length <= 0 || arguments[0] === undefined ? 1 : arguments[0];
var perPage = arguments.length <= 1 || arguments[1] === undefined ? 10 : arguments[1];
var url = "/photos";

@@ -505,4 +505,4 @@

var category = arguments.length <= 1 || arguments[1] === undefined ? [""] : arguments[1];
var page = arguments[2];
var perPage = arguments[3];
var page = arguments.length <= 2 || arguments[2] === undefined ? 1 : arguments[2];
var perPage = arguments.length <= 3 || arguments[3] === undefined ? 10 : arguments[3];

@@ -541,4 +541,4 @@ var url = "/photos/search";

getRandomPhoto: function getRandomPhoto(width, height, q, username, featured, category) {
var cacheBuster = arguments.length <= 6 || arguments[6] === undefined ? new Date().getTime() : arguments[6];
getRandomPhoto: function getRandomPhoto() {
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];

@@ -548,11 +548,17 @@ var url = "/photos/random";

var query = {
category: category,
featured: featured,
username: username,
query: q,
w: width,
h: height,
cacheBuster: cacheBuster // Avoid ajax response caching
category: options.category,
featured: options.featured,
username: options.username,
q: options.query,
w: options.width,
h: options.height,
c: options.cacheBuster || new Date().getTime() // Avoid ajax response caching
};
Object.keys(query).forEach(function (key) {
if (!query[key]) {
delete query[key];
}
});
return _this.request({

@@ -624,3 +630,3 @@ url: url,

total: function total() {
var url = "/stats";
var url = "/stats/total";

@@ -667,3 +673,6 @@ return _this.request({

likes: function likes(username, page, perPage) {
likes: function likes(username) {
var page = arguments.length <= 1 || arguments[1] === undefined ? 1 : arguments[1];
var perPage = arguments.length <= 2 || arguments[2] === undefined ? 10 : arguments[2];
var url = "/users/" + username + "/likes";

@@ -670,0 +679,0 @@

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Unsplash=t():e.Unsplash=t()}(this,function(){return function(e){function t(o){if(r[o])return r[o].exports;var n=r[o]={exports:{},id:o,loaded:!1};return e[o].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e){return e.json()}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}();t.toJson=u;var s=r(1),a=r(11),c=r(10),l=r(3),d=o(l),f=r(6),h=o(f),p=r(9),v=o(p),_=r(7),b=o(_),m=r(4),y=o(m),g=r(5),T=o(g),q=r(8),O=o(q),E=(0,c.requireFetch)(),U=function(){function e(t){n(this,e),this._apiUrl=t.apiUrl||s.API_URL,this._apiVersion=t.apiVersion||s.API_VERSION,this._applicationId=t.applicationId,this._secret=t.secret,this._callbackUrl=t.callbackUrl,this._bearerToken=t.bearerToken,this.auth=d["default"].bind(this)(),this.currentUser=h["default"].bind(this)(),this.users=v["default"].bind(this)(),this.photos=b["default"].bind(this)(),this.categories=y["default"].bind(this)(),this.collections=T["default"].bind(this)(),this.stats=O["default"].bind(this)()}return i(e,[{key:"request",value:function(e){var t=a.buildFetchOptions.bind(this)(e),r=t.url,o=t.options;return E(r,o)}}]),e}();t["default"]=U},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.API_URL="https://api.unsplash.com",t.API_VERSION="v1",t.OAUTH_AUTHORIZE_URL="https://unsplash.com/oauth/authorize",t.OAUTH_TOKEN_URL="https://unsplash.com/oauth/token"},function(e,t,r){"use strict";t.decode=t.parse=r(13),t.encode=t.stringify=r(14)},function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function n(){var e=this;return{getAuthenticationUrl:function(){var t=arguments.length<=0||void 0===arguments[0]?["public"]:arguments[0],r=i["default"].stringify({client_id:e._applicationId,redirect_uri:e._callbackUrl,response_type:"code",scope:t.length>1?t.join("+"):t.toString()});return decodeURIComponent(s.OAUTH_AUTHORIZE_URL+"?"+r)},userAuthentication:function(t){var r=s.OAUTH_TOKEN_URL;return e.request({url:r,method:"POST",body:{client_id:e._applicationId,client_secret:e._secret,redirect_uri:e._callbackUrl,grant_type:"authorization_code",code:t},oauth:!0})},setBearerToken:function(t){t&&(e._bearerToken=t)}}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=n;var u=r(2),i=o(u),s=r(1)},function(e,t){"use strict";function r(){var e=this;return{listCategories:function(){var t="/categories";return e.request({url:t,method:"GET"})},category:function(t){var r="/categories/"+t;return e.request({url:r,method:"GET"})},categoryPhotos:function(t,r,o){var n="/categories/"+t+"/photos",u={page:r,per_page:o};return e.request({url:n,method:"GET",query:u})}}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r},function(e,t){"use strict";function r(){var e=this;return{listCollections:function(){var t=arguments.length<=0||void 0===arguments[0]?1:arguments[0],r=arguments.length<=1||void 0===arguments[1]?10:arguments[1],o="/collections",n={page:t,per_page:r};return e.request({url:o,method:"GET",query:n})},listCuratedCollections:function(){var t=arguments.length<=0||void 0===arguments[0]?1:arguments[0],r=arguments.length<=1||void 0===arguments[1]?10:arguments[1],o="/collections/curated",n={page:t,per_page:r};return e.request({url:o,method:"GET",query:n})},getCollection:o.bind(this,!1),getCuratedCollection:o.bind(this,!0),getCuratedCollectionPhotos:n.bind(this,!0),getCollectionPhotos:n.bind(this,!1),createCollection:u.bind(this,null),updateCollection:u.bind(this),deleteCollection:function(t){var r="/collections/"+t;return e.request({url:r,method:"DELETE"})},addPhotoToCollection:function(t,r){var o="/collections/"+t+"/add";return e.request({url:o,method:"POST",body:{photo_id:r}})},removePhotoFromCollection:function(t,r){var o="/collections/"+t+"/remove";return e.request({url:o,method:"DELETE",body:{photo_id:r}})}}}function o(e,t){var r=e?"/collections/curated/"+t:"/collections/"+t;return this.request({url:r,method:"GET"})}function n(e,t){var r=e?"/collections/curated/"+t+"/photos":"/collections/"+t+"/photos";return this.request({url:r,method:"GET"})}function u(e,t,r,o){var n=e?"/collections/"+e:"/collections",u={title:t,description:r,"private":o};return this.request({url:n,method:e?"PUT":"POST",body:u})}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r},function(e,t){"use strict";function r(){var e=this;return{profile:function(){var t="/me";return e.request({url:t,method:"GET"})},updateProfile:function(t){var r="/me",o=t.username,n=t.firstName,u=t.lastName,i=t.email,s=t.url,a=t.location,c=t.bio,l=t.instagramUsername,d={username:o,first_name:n,last_name:u,email:i,url:s,location:a,bio:c,instagram_username:l};return Object.keys(d).forEach(function(e){d[e]||delete d[e]}),e.request({url:r,method:"POST",body:d})}}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r},function(e,t){"use strict";function r(){var e=this;return{listPhotos:function(t,r){var o="/photos",n={page:t,per_page:r};return e.request({url:o,method:"GET",query:n})},searchPhotos:function(t){var r=arguments.length<=1||void 0===arguments[1]?[""]:arguments[1],o=arguments[2],n=arguments[3],u="/photos/search",i={query:t,category:r.length>1?r.join(","):r.toString(),page:o,per_page:n};return e.request({url:u,method:"GET",query:i})},getPhoto:function(t,r,o,n){var u="/photos/"+t,i={w:r,h:o,rect:n};return e.request({url:u,method:"GET",query:i})},getRandomPhoto:function(t,r,o,n,u,i){var s=arguments.length<=6||void 0===arguments[6]?(new Date).getTime():arguments[6],a="/photos/random",c={category:i,featured:u,username:n,query:o,w:t,h:r,cacheBuster:s};return e.request({url:a,method:"GET",query:c})},uploadPhoto:function(t){if(!e._bearerToken)throw new Error("Requires a bearerToken to be set.");var r="/photos";return e.request({url:r,method:"POST",body:{photo:t}})},likePhoto:function(t){if(!e._bearerToken)throw new Error("Requires a bearerToken to be set.");var r="/photos/"+t+"/like";return e.request({url:r,method:"POST"})},unlikePhoto:function(t){if(!e._bearerToken)throw new Error("Requires a bearerToken to be set.");var r="/photos/"+t+"/like";return e.request({url:r,method:"DELETE"})}}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r},function(e,t){"use strict";function r(){var e=this;return{total:function(){var t="/stats";return e.request({url:t,method:"GET"})}}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r},function(e,t){"use strict";function r(){var e=this;return{profile:function(t){var r="/users/"+t;return e.request({url:r,method:"GET"})},photos:function(t){var r="/users/"+t+"/photos";return e.request({url:r,method:"GET"})},likes:function(t,r,o){var n="/users/"+t+"/likes",u={page:r,per_page:o};return e.request({url:n,method:"GET",query:u})}}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r},function(e,t,r){"use strict";function o(){var e=!0;return e?window.fetch:r(!function(){var e=new Error('Cannot find module "node-fetch"');throw e.code="MODULE_NOT_FOUND",e}())}Object.defineProperty(t,"__esModule",{value:!0}),t.requireFetch=o},function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function n(e){return(0,c["default"])(e)}function u(e){var t=e.method,r=e.query,o=e.oauth,u=e.body,a=o===!0?e.url:""+this._apiUrl+e.url,c=i({},e.headers,{"Accept-Version":this._apiVersion,Authorization:this._bearerToken?"Bearer "+this._bearerToken:"Client-ID "+this._applicationId});return u&&(c["Content-Type"]="application/x-www-form-urlencoded"),r&&(a=decodeURIComponent(a+"?"+(0,s.stringify)(r))),{url:a,options:{method:t,headers:c,body:"GET"!==t&&u?n(u):void 0}}}Object.defineProperty(t,"__esModule",{value:!0});var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e};t.formUrlEncode=n,t.buildFetchOptions=u;var s=r(2),a=r(12),c=o(a)},function(e,t){e.exports=function(e,t){function r(e){return String(e).replace(/[^ !'()~\*]*/g,encodeURIComponent).replace(/ /g,"+").replace(/[!'()~\*]/g,function(e){return"%"+e.charCodeAt().toString(16).slice(-2).toUpperCase()})}function o(e){var r=Object.keys(e);return t.sorted?r.sort():r}function n(e){return e.filter(function(e){return e}).join("&")}function u(e,t){return n(o(t).map(function(r){return s(e+"["+r+"]",t[r])}))}function i(e,t){return n(t.map(function(t){return s(e+"[]",t)}))}function s(e,o){var n=typeof o,s=null;return o===s?s=t.ignorenull?s:r(e)+"="+s:/string|number|boolean/.test(n)?s=r(e)+"="+r(o):Array.isArray(o)?s=i(e,o):"object"===n&&(s=u(e,o)),s}return t="object"==typeof t?t:{},n(o(e).map(function(t){return s(t,e[t])}))}},function(e,t){"use strict";function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,t,o,n){t=t||"&",o=o||"=";var u={};if("string"!=typeof e||0===e.length)return u;var i=/\+/g;e=e.split(t);var s=1e3;n&&"number"==typeof n.maxKeys&&(s=n.maxKeys);var a=e.length;s>0&&a>s&&(a=s);for(var c=0;a>c;++c){var l,d,f,h,p=e[c].replace(i,"%20"),v=p.indexOf(o);v>=0?(l=p.substr(0,v),d=p.substr(v+1)):(l=p,d=""),f=decodeURIComponent(l),h=decodeURIComponent(d),r(u,f)?Array.isArray(u[f])?u[f].push(h):u[f]=[u[f],h]:u[f]=h}return u}},function(e,t){"use strict";var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};e.exports=function(e,t,o,n){return t=t||"&",o=o||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map(function(n){var u=encodeURIComponent(r(n))+o;return Array.isArray(e[n])?e[n].map(function(e){return u+encodeURIComponent(r(e))}).join(t):u+encodeURIComponent(r(e[n]))}).join(t):n?encodeURIComponent(r(n))+o+encodeURIComponent(r(e)):""}}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Unsplash=t():e.Unsplash=t()}(this,function(){return function(e){function t(o){if(r[o])return r[o].exports;var n=r[o]={exports:{},id:o,loaded:!1};return e[o].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e){return e.json()}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}();t.toJson=u;var s=r(1),a=r(11),c=r(10),l=r(3),d=o(l),f=r(6),h=o(f),p=r(9),v=o(p),m=r(7),_=o(m),b=r(4),y=o(b),g=r(5),T=o(g),q=r(8),O=o(q),E=(0,c.requireFetch)(),U=function(){function e(t){n(this,e),this._apiUrl=t.apiUrl||s.API_URL,this._apiVersion=t.apiVersion||s.API_VERSION,this._applicationId=t.applicationId,this._secret=t.secret,this._callbackUrl=t.callbackUrl,this._bearerToken=t.bearerToken,this.auth=d["default"].bind(this)(),this.currentUser=h["default"].bind(this)(),this.users=v["default"].bind(this)(),this.photos=_["default"].bind(this)(),this.categories=y["default"].bind(this)(),this.collections=T["default"].bind(this)(),this.stats=O["default"].bind(this)()}return i(e,[{key:"request",value:function(e){var t=a.buildFetchOptions.bind(this)(e),r=t.url,o=t.options;return E(r,o)}}]),e}();t["default"]=U},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.API_URL="https://api.unsplash.com",t.API_VERSION="v1",t.OAUTH_AUTHORIZE_URL="https://unsplash.com/oauth/authorize",t.OAUTH_TOKEN_URL="https://unsplash.com/oauth/token"},function(e,t,r){"use strict";t.decode=t.parse=r(13),t.encode=t.stringify=r(14)},function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function n(){var e=this;return{getAuthenticationUrl:function(){var t=arguments.length<=0||void 0===arguments[0]?["public"]:arguments[0],r=i["default"].stringify({client_id:e._applicationId,redirect_uri:e._callbackUrl,response_type:"code",scope:t.length>1?t.join("+"):t.toString()});return decodeURIComponent(s.OAUTH_AUTHORIZE_URL+"?"+r)},userAuthentication:function(t){var r=s.OAUTH_TOKEN_URL;return e.request({url:r,method:"POST",body:{client_id:e._applicationId,client_secret:e._secret,redirect_uri:e._callbackUrl,grant_type:"authorization_code",code:t},oauth:!0})},setBearerToken:function(t){t&&(e._bearerToken=t)}}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=n;var u=r(2),i=o(u),s=r(1)},function(e,t){"use strict";function r(){var e=this;return{listCategories:function(){var t="/categories";return e.request({url:t,method:"GET"})},category:function(t){var r="/categories/"+t;return e.request({url:r,method:"GET"})},categoryPhotos:function(t,r,o){var n="/categories/"+t+"/photos",u={page:r,per_page:o};return e.request({url:n,method:"GET",query:u})}}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r},function(e,t){"use strict";function r(){var e=this;return{listCollections:function(){var t=arguments.length<=0||void 0===arguments[0]?1:arguments[0],r=arguments.length<=1||void 0===arguments[1]?10:arguments[1],o="/collections",n={page:t,per_page:r};return e.request({url:o,method:"GET",query:n})},listCuratedCollections:function(){var t=arguments.length<=0||void 0===arguments[0]?1:arguments[0],r=arguments.length<=1||void 0===arguments[1]?10:arguments[1],o="/collections/curated",n={page:t,per_page:r};return e.request({url:o,method:"GET",query:n})},getCollection:o.bind(this,!1),getCuratedCollection:o.bind(this,!0),getCuratedCollectionPhotos:n.bind(this,!0),getCollectionPhotos:n.bind(this,!1),createCollection:u.bind(this,null),updateCollection:u.bind(this),deleteCollection:function(t){var r="/collections/"+t;return e.request({url:r,method:"DELETE"})},addPhotoToCollection:function(t,r){var o="/collections/"+t+"/add";return e.request({url:o,method:"POST",body:{photo_id:r}})},removePhotoFromCollection:function(t,r){var o="/collections/"+t+"/remove?photo_id="+r;return e.request({url:o,method:"DELETE"})}}}function o(e,t){var r=e?"/collections/curated/"+t:"/collections/"+t;return this.request({url:r,method:"GET"})}function n(e,t){var r=e?"/collections/curated/"+t+"/photos":"/collections/"+t+"/photos";return this.request({url:r,method:"GET"})}function u(e,t,r,o){var n=e?"/collections/"+e:"/collections",u={title:t,description:r,"private":o};return this.request({url:n,method:e?"PUT":"POST",body:u})}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r},function(e,t){"use strict";function r(){var e=this;return{profile:function(){var t="/me";return e.request({url:t,method:"GET"})},updateProfile:function(t){var r="/me",o=t.username,n=t.firstName,u=t.lastName,i=t.email,s=t.url,a=t.location,c=t.bio,l=t.instagramUsername,d={username:o,first_name:n,last_name:u,email:i,url:s,location:a,bio:c,instagram_username:l};return Object.keys(d).forEach(function(e){d[e]||delete d[e]}),e.request({url:r,method:"PUT",body:d})}}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r},function(e,t){"use strict";function r(){var e=this;return{listPhotos:function(){var t=arguments.length<=0||void 0===arguments[0]?1:arguments[0],r=arguments.length<=1||void 0===arguments[1]?10:arguments[1],o="/photos",n={page:t,per_page:r};return e.request({url:o,method:"GET",query:n})},searchPhotos:function(t){var r=arguments.length<=1||void 0===arguments[1]?[""]:arguments[1],o=arguments.length<=2||void 0===arguments[2]?1:arguments[2],n=arguments.length<=3||void 0===arguments[3]?10:arguments[3],u="/photos/search",i={query:t,category:r.length>1?r.join(","):r.toString(),page:o,per_page:n};return e.request({url:u,method:"GET",query:i})},getPhoto:function(t,r,o,n){var u="/photos/"+t,i={w:r,h:o,rect:n};return e.request({url:u,method:"GET",query:i})},getRandomPhoto:function(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],r="/photos/random",o={category:t.category,featured:t.featured,username:t.username,q:t.query,w:t.width,h:t.height,c:t.cacheBuster||(new Date).getTime()};return Object.keys(o).forEach(function(e){o[e]||delete o[e]}),e.request({url:r,method:"GET",query:o})},uploadPhoto:function(t){if(!e._bearerToken)throw new Error("Requires a bearerToken to be set.");var r="/photos";return e.request({url:r,method:"POST",body:{photo:t}})},likePhoto:function(t){if(!e._bearerToken)throw new Error("Requires a bearerToken to be set.");var r="/photos/"+t+"/like";return e.request({url:r,method:"POST"})},unlikePhoto:function(t){if(!e._bearerToken)throw new Error("Requires a bearerToken to be set.");var r="/photos/"+t+"/like";return e.request({url:r,method:"DELETE"})}}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r},function(e,t){"use strict";function r(){var e=this;return{total:function(){var t="/stats/total";return e.request({url:t,method:"GET"})}}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r},function(e,t){"use strict";function r(){var e=this;return{profile:function(t){var r="/users/"+t;return e.request({url:r,method:"GET"})},photos:function(t){var r="/users/"+t+"/photos";return e.request({url:r,method:"GET"})},likes:function(t){var r=arguments.length<=1||void 0===arguments[1]?1:arguments[1],o=arguments.length<=2||void 0===arguments[2]?10:arguments[2],n="/users/"+t+"/likes",u={page:r,per_page:o};return e.request({url:n,method:"GET",query:u})}}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r},function(e,t,r){"use strict";function o(){var e=!0;return e?window.fetch:r(!function(){var e=new Error('Cannot find module "node-fetch"');throw e.code="MODULE_NOT_FOUND",e}())}Object.defineProperty(t,"__esModule",{value:!0}),t.requireFetch=o},function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function n(e){return(0,c["default"])(e)}function u(e){var t=e.method,r=e.query,o=e.oauth,u=e.body,a=o===!0?e.url:""+this._apiUrl+e.url,c=i({},e.headers,{"Accept-Version":this._apiVersion,Authorization:this._bearerToken?"Bearer "+this._bearerToken:"Client-ID "+this._applicationId});return u&&(c["Content-Type"]="application/x-www-form-urlencoded"),r&&(a=decodeURIComponent(a+"?"+(0,s.stringify)(r))),{url:a,options:{method:t,headers:c,body:"GET"!==t&&u?n(u):void 0}}}Object.defineProperty(t,"__esModule",{value:!0});var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e};t.formUrlEncode=n,t.buildFetchOptions=u;var s=r(2),a=r(12),c=o(a)},function(e,t){e.exports=function(e,t){function r(e){return String(e).replace(/[^ !'()~\*]*/g,encodeURIComponent).replace(/ /g,"+").replace(/[!'()~\*]/g,function(e){return"%"+e.charCodeAt().toString(16).slice(-2).toUpperCase()})}function o(e){var r=Object.keys(e);return t.sorted?r.sort():r}function n(e){return e.filter(function(e){return e}).join("&")}function u(e,t){return n(o(t).map(function(r){return s(e+"["+r+"]",t[r])}))}function i(e,t){return n(t.map(function(t){return s(e+"[]",t)}))}function s(e,o){var n=typeof o,s=null;return o===s?s=t.ignorenull?s:r(e)+"="+s:/string|number|boolean/.test(n)?s=r(e)+"="+r(o):Array.isArray(o)?s=i(e,o):"object"===n&&(s=u(e,o)),s}return t="object"==typeof t?t:{},n(o(e).map(function(t){return s(t,e[t])}))}},function(e,t){"use strict";function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,t,o,n){t=t||"&",o=o||"=";var u={};if("string"!=typeof e||0===e.length)return u;var i=/\+/g;e=e.split(t);var s=1e3;n&&"number"==typeof n.maxKeys&&(s=n.maxKeys);var a=e.length;s>0&&a>s&&(a=s);for(var c=0;a>c;++c){var l,d,f,h,p=e[c].replace(i,"%20"),v=p.indexOf(o);v>=0?(l=p.substr(0,v),d=p.substr(v+1)):(l=p,d=""),f=decodeURIComponent(l),h=decodeURIComponent(d),r(u,f)?Array.isArray(u[f])?u[f].push(h):u[f]=[u[f],h]:u[f]=h}return u}},function(e,t){"use strict";var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};e.exports=function(e,t,o,n){return t=t||"&",o=o||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map(function(n){var u=encodeURIComponent(r(n))+o;return Array.isArray(e[n])?e[n].map(function(e){return u+encodeURIComponent(r(e))}).join(t):u+encodeURIComponent(r(e[n]))}).join(t):n?encodeURIComponent(r(n))+o+encodeURIComponent(r(e)):""}}])});

@@ -7,34 +7,208 @@ import config from 'universal-config';

secret: config.get('SECRET'),
callbackUrl: config.get('CALLBACK_URL'),
bearerToken: 'ed43869e7e06a867310efdaa321398eed457c357d41aa43fa4217a6d2e54bad2'
callbackUrl: config.get('CALLBACK_URL')
});
// 6ee984319858837846570233c5bddbf54c5bd1376b318a72570c3ebfea929e9f
let authenticationUrl = unsplash.auth.getAuthenticationUrl([
"public",
"read_user",
"write_user",
"read_photos",
"write_photos",
"write_likes",
"read_collections",
"write_collections"
]);
// let authenticationUrl = unsplash.auth.getAuthenticationUrl([
// "public",
// "read_user",
// "write_user",
// "read_photos",
// "write_photos",
// "write_likes",
// "read_collections",
// "write_collections"
// ]);
console.log(userAuthentication(code));
currentUser();
users();
photos();
collections();
stats();
// console.log(authenticationUrl);
function userAuthentication(code) {
return unsplash.auth.userAuthentication(code)
.then(toJson)
.then(json => json.access_token);
}
// unsplash.auth.userAuthentication('bdc63933bd0d939889638194394e524c4eda7a08becf1cf8fe7fb0b1f3b6c6a5')
// .then(toJson)
// .then(json => {
// console.log(json);
// // console.log(json.access_token);
// })
// .catch(e => {
// console.log(e)
// });
unsplash.currentUser.profile()
.then(toJson)
.then(json => {
console.log('profile', json);
});
function currentUser() {
console.log("\nCurrent User");
unsplash.currentUser.profile()
.then(toJson)
.then(json => {
console.log('profile', json);
});
unsplash.currentUser.updateProfile({ location: "¯\_(ツ)_/¯" })
.then(toJson)
.then(json => {
console.log('updateProfile', json);
});
}
function users() {
console.log("\nUsers")
unsplash.users.profile('naoufal')
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.users.photos("naoufal")
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.users.likes("naoufal")
.then(toJson)
.then(json => {
console.log(json);
});
}
function photos() {
console.log("\nPhotos");
unsplash.photos.listPhotos(1, 10)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.photos.searchPhotos("bear", undefined, 1, 1)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.photos.getPhoto("kZ8dyUT0h30")
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.photos.getRandomPhoto({ featured: true })
.then(toJson)
.then(json => {
console.log(json.links.html);
});
unsplash.photos.likePhoto("kZ8dyUT0h30")
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.photos.unlikePhoto("kZ8dyUT0h30")
.then(toJson)
.then(json => {
console.log(json);
});
}
function categories() {
console.log("\nCategories");
unsplash.categories.listCategories()
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.categories.category(4)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.categories.categoryPhotos(4, 1, 1)
.then(toJson)
.then(json => {
console.log(json);
});
}
function collections() {
console.log("\nCollections");
unsplash.collections.listCollections(1, 10)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.listCuratedCollections(1, 10)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.getCollection(151165)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.getCuratedCollection(94)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.getCollectionPhotos(151165)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.getCuratedCollectionPhotos(94)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.createCollection("Birds", "Wild birds from 'round the world", true)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.updateCollection(152645, "Wild", "Wild")
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.deleteCollection(152645)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.addPhotoToCollection(151165, '-yPg8cusGD8')
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.removePhotoFromCollection(151165, '-yPg8cusGD8')
.then(toJson)
.then(json => {
console.log(json);
});
}
function stats() {
console.log("\nStats");
unsplash.stats.total()
.then(toJson)
.then(json => {
console.log(json);
});
}

@@ -80,10 +80,7 @@ "use strict";

removePhotoFromCollection: function removePhotoFromCollection(collectionId, photoId) {
var url = "/collections/" + collectionId + "/remove";
var url = "/collections/" + collectionId + "/remove?photo_id=" + photoId;
return _this.request({
url: url,
method: "DELETE",
body: {
photo_id: photoId
}
method: "DELETE"
});

@@ -90,0 +87,0 @@ }

@@ -50,3 +50,3 @@ "use strict";

url: endpointUrl,
method: "POST",
method: "PUT",
body: body

@@ -53,0 +53,0 @@ });

@@ -11,3 +11,6 @@ "use strict";

return {
listPhotos: function listPhotos(page, perPage) {
listPhotos: function listPhotos() {
var page = arguments.length <= 0 || arguments[0] === undefined ? 1 : arguments[0];
var perPage = arguments.length <= 1 || arguments[1] === undefined ? 10 : arguments[1];
var url = "/photos";

@@ -29,4 +32,4 @@

var category = arguments.length <= 1 || arguments[1] === undefined ? [""] : arguments[1];
var page = arguments[2];
var perPage = arguments[3];
var page = arguments.length <= 2 || arguments[2] === undefined ? 1 : arguments[2];
var perPage = arguments.length <= 3 || arguments[3] === undefined ? 10 : arguments[3];

@@ -65,4 +68,4 @@ var url = "/photos/search";

getRandomPhoto: function getRandomPhoto(width, height, q, username, featured, category) {
var cacheBuster = arguments.length <= 6 || arguments[6] === undefined ? new Date().getTime() : arguments[6];
getRandomPhoto: function getRandomPhoto() {
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];

@@ -72,11 +75,17 @@ var url = "/photos/random";

var query = {
category: category,
featured: featured,
username: username,
query: q,
w: width,
h: height,
cacheBuster: cacheBuster // Avoid ajax response caching
category: options.category,
featured: options.featured,
username: options.username,
q: options.query,
w: options.width,
h: options.height,
c: options.cacheBuster || new Date().getTime() // Avoid ajax response caching
};
Object.keys(query).forEach(function (key) {
if (!query[key]) {
delete query[key];
}
});
return _this.request({

@@ -83,0 +92,0 @@ url: url,

@@ -12,3 +12,3 @@ "use strict";

total: function total() {
var url = "/stats";
var url = "/stats/total";

@@ -15,0 +15,0 @@ return _this.request({

@@ -29,3 +29,6 @@ "use strict";

likes: function likes(username, page, perPage) {
likes: function likes(username) {
var page = arguments.length <= 1 || arguments[1] === undefined ? 1 : arguments[1];
var perPage = arguments.length <= 2 || arguments[2] === undefined ? 10 : arguments[2];
var url = "/users/" + username + "/likes";

@@ -32,0 +35,0 @@

{
"name": "unsplash-js",
"version": "2.0.1",
"version": "2.1.0",
"description": "A Universal JavaScript wrapper for the Unsplash API",

@@ -5,0 +5,0 @@ "main": "lib/unsplash.js",

@@ -344,3 +344,3 @@ # Unsplash

### photos.getRandomPhoto(width, height, query, username, featured, category)
### photos.getRandomPhoto({ width, height, query, username, featured, category })
Retrieve a single random photo, given optional filters.

@@ -350,2 +350,4 @@

_An Object containing the follow keys:_
| Argument | Type | Opt/Required |

@@ -362,3 +364,3 @@ |---|---|---|

```js
unsplash.photos.getRandomPhoto([88], true, "naoufal", "cats", 1920, 1080)
unsplash.photos.getRandomPhoto({ username: "naoufal" })
.then(toJson)

@@ -632,3 +634,3 @@ .then(json => {

### collections.updateCollection(title, description, private)
### collections.updateCollection(id, title, description, private)
Update an existing collection belonging to the logged-in user. This requires the `write_collections` scope.

@@ -640,2 +642,3 @@

|---|---|---|
|__`id`__|_number_|Required|
|__`title`__|_string_|Optional|

@@ -647,3 +650,3 @@ |__`description`__|_string_|Optional|

```js
unsplash.collections.updateCollection("Wild Birds", "Wild birds from around the world", false)
unsplash.collections.updateCollection(12345, "Wild Birds", "Wild birds from around the world", false)
.then(toJson)

@@ -676,2 +679,42 @@ .then(json => {

### collections.addPhotoToCollection(collectionId, photoId)
Add a photo to one of the logged-in user’s collections. Requires the `write_collections` scope.
__Arguments__
| Argument | Type | Opt/Required |
|---|---|---|
|__`collectionId`__|_number_|Required|
|__`photoId`__|_string_|Required|
__Example__
```js
unsplash.collections.addPhotoToCollection(88, 'abc1234')
.then(toJson)
.then(json => {
// Your code
});
```
---
### collections.removePhotoFromCollection(collectionId, photoId)
Remove a photo from one of the logged-in user’s collections. Requires the `write_collections` scope.
__Arguments__
| Argument | Type | Opt/Required |
|---|---|---|
|__`collectionId`__|_number_|Required|
|__`photoId`__|_string_|Required|
__Example__
```js
unsplash.collections.removePhotoFromCollection(88, 'abc1234')
.then(toJson)
.then(json => {
// Your code
});
```
---
<div id="stats" />

@@ -678,0 +721,0 @@

@@ -10,43 +10,208 @@ 'use strict';

callbackUrl: "http://unsplash-js.herokuapp.com",
bearerToken: "fde61c40f4696fce8415f16fb62579ffce708fb566508c5879ea1830b455ac2f"
bearerToken: "ff2109c3419d9b75d0b14c082e504beab2769fd2a5c2d4c3a73f6d34c3354c66"
});
// let authenticationUrl = unsplash.auth.getAuthenticationUrl([
// "public",
// "read_user",
// "write_user",
// "read_photos",
// "write_photos",
// "write_likes",
// "read_collections",
// "write_collections"
// ]);
let authenticationUrl = unsplash.auth.getAuthenticationUrl([
"public",
"read_user",
"write_user",
"read_photos",
"write_photos",
"write_likes",
"read_collections",
"write_collections"
]);
// console.log(authenticationUrl);
console.log(userAuthentication(code));
currentUser();
users();
photos();
collections();
stats();
const code = 'c3ee778fef5f93358add5e657349fba03c7f26403409ffea64af115510e20872';
function userAuthentication(code) {
return unsplash.auth.userAuthentication(code)
.then(toJson)
.then(json => json.access_token);
}
// console.log(code);
function currentUser() {
console.log("\nCurrent User");
// unsplash.auth.userAuthentication(code)
// .then(toJson)
// .then(json => {
// console.log(json);
// // console.log(json.access_token);
// })
// .catch(e => {
// console.log(e)
// });
unsplash.currentUser.profile()
.then(toJson)
.then(json => {
console.log('profile', json);
});
unsplash.currentUser.updateProfile({ location: "¯\_(ツ)_/¯" })
.then(toJson)
.then(json => {
console.log('updateProfile', json);
});
}
unsplash.collections.removePhotoFromCollection(151165, 'iDZt9nmvOWk')
.then(res => {
console.log(res);
})
// .then(toJson)
// .then(json => {
// console.log(json);
// })
.catch(e => {
console.log(e);
})
function users() {
console.log("\nUsers")
unsplash.users.profile('naoufal')
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.users.photos("naoufal")
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.users.likes("naoufal")
.then(toJson)
.then(json => {
console.log(json);
});
}
function photos() {
console.log("\nPhotos");
unsplash.photos.listPhotos(1, 10)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.photos.searchPhotos("bear", undefined, 1, 1)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.photos.getPhoto("kZ8dyUT0h30")
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.photos.getRandomPhoto({ featured: true })
.then(toJson)
.then(json => {
console.log(json.links.html);
});
unsplash.photos.likePhoto("kZ8dyUT0h30")
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.photos.unlikePhoto("kZ8dyUT0h30")
.then(toJson)
.then(json => {
console.log(json);
});
}
function categories() {
console.log("\nCategories");
unsplash.categories.listCategories()
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.categories.category(4)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.categories.categoryPhotos(4, 1, 1)
.then(toJson)
.then(json => {
console.log(json);
});
}
function collections() {
console.log("\nCollections");
unsplash.collections.listCollections(1, 10)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.listCuratedCollections(1, 10)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.getCollection(151165)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.getCuratedCollection(94)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.getCollectionPhotos(151165)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.getCuratedCollectionPhotos(94)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.createCollection("Birds", "Wild birds from 'round the world", true)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.updateCollection(152645, "Wild", "Wild")
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.deleteCollection(152645)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.addPhotoToCollection(151165, '-yPg8cusGD8')
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.removePhotoFromCollection(151165, '-yPg8cusGD8')
.then(toJson)
.then(json => {
console.log(json);
});
}
function stats() {
console.log("\nStats");
unsplash.stats.total()
.then(toJson)
.then(json => {
console.log(json);
});
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc