Socket
Socket
Sign inDemoInstall

ng.cx.google.drive

Package Overview
Dependencies
3
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

2

dist/ng.cx.google.drive.js

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

System.register("google/auth.js",["google/google"],function(a){var b,c,d;return{setters:[function(a){b=a}],execute:function(){c=["https://www.googleapis.com/auth/drive"],d=function(){function a(a,b){this.clientId=a,this.scopes=b||c}return a.prototype.authorize=function(){var a=this;return new Promise(function(b,c){return a._authorize(b,c,!1)})},a.prototype.checkAuth=function(){var a=this;return new Promise(function(b,c){return a._authorize(b,c,!0)})},a.prototype._authorize=function(a,c,d){function e(){gapi.auth.authorize({client_id:f.clientId,scope:f.scopes,immediate:d},f._handleAuthResult(a,c))}var f=this;b.API.bootstrap().then(e)},a.prototype._handleAuthResult=function(a,b){return function(c){c&&!c.error?a(c):b(c.error)}},a}(),a("Auth",d)}}}),System.register("google/api.js",[],function(a){var b,c;return{setters:[],execute:function(){b={drive:"v3"},c=function(){function a(){}return a.bootstrap=function(a){var b=this;return this._api_load_promise||(this._api_load_promise=new Promise(function(c,d){return b._add_script_tag(c,d,a)})),this._api_load_promise},a.load=function(c,d){return b.hasOwnProperty(c)?b[c]!==d&&console.warn("Unsupported "+c+'-api version "'+d+'"'):console.warn('Unsupported api "'+c+'"'),a._script_loaded?new Promise(function(a,b){return gapi.client.load(c,d,a)}):Promise.reject("Google Apis has not been loaded")},a._add_script_tag=function(b,c,d){var e=this;if(a._script_loaded)this._api_has_loaded(b,c,d);else{var f=document.createElement("script"),g="__gapi__callback",h=window.document,i=h.getElementsByTagName("script")[0];f.setAttribute("src","https://apis.google.com/js/client.js?onload="+g),f.async=!0,window[g]=function(){return e._api_has_loaded(b,c,d)},i?i.parentNode.insertBefore(f,i):(h.head||h.body||h.documentElement).appendChild(f)}},a._api_has_loaded=function(c,d,e){a._script_loaded=!0,e?this.load(e,b[e]).then(c):c()},a._script_loaded=!1,a}(),a("API",c)}}}),System.register("google/drive/file.js",[],function(a){var b,c;return{setters:[],execute:function(){b={FOLDER:"application/vnd.google-apps.folder"},c=function(){function a(a){this.kind=a.kind,this.id=a.id,this.name=a.name,this.mimeType=a.mimeType,this.description=a.description,this.starred=a.starred,this.trashed=a.trashed,this.parents=a.parents,this.version=a.version,this.webContentLink=a.webContentLink,this.webViewLink=a.webViewLink,this.iconLink=a.iconLink,this.thumbnailLink=a.thumbnailLink,this.createdTime=a.createdTime,this.modifiedTime=a.modifiedTime}return a.prototype.isFolder=function(){return this.mimeType&&this.mimeType===b.FOLDER},a}(),a("DriveFileResource",c)}}}),System.register("google/drive/permissions.js",[],function(a){var b,c;return{setters:[],execute:function(){b={COMMENTER:"commenter",OWNER:"owner",READER:"reader",WRITER:"writer"},c=function(){function a(){}return a.create=function(a,b,c){var d=this,e={fileId:a,type:b,role:c},f=gapi.client.drive.permissions.create(e);return new Promise(function(a,b){return d._execute(f,a,b)})},a._execute=function(a,b,c){var d=this;a.execute(function(a){return d._handleResponse(a,b,c)})},a._handleResponse=function(a,b,c){b(a)},a}(),a("DrivePermissions",c)}}}),System.register("google/drive/drive.js",["./query","./file","./permissions"],function(a){var b,c,d,e,f,g;return{setters:[function(a){b=a},function(a){c=a},function(a){d=a}],execute:function(){e={UNKONW_ACTION:new Error("Can't handle result for unkown action")},function(a){a[a.GET=0]="GET",a[a.LIST=1]="LIST"}(f||(f={})),g=function(){function a(){}return a.get=function(a){var b=this,c=a||this._defaultQuery(),d=gapi.client.drive.files.get(c.toQuery());return new Promise(function(a,e){return b._execute(f.GET,d,c,a,e)})},a.list=function(a){var b,c=this,d=a||this._defaultQuery();return b=gapi.client.drive.files.list(d.toQuery()),new Promise(function(a,e){return c._execute(f.LIST,b,d,a,e)})},a._createFileResources=function(a){var b=[];return a.forEach(function(a){b.push(new c.DriveFileResource(a))}),b},a._defaultQuery=function(){return(new b.DriveQuery).limit(100)},a._execute=function(a,b,c,d,e){var f=this;b.execute(function(b){return f._handleResponse(a,c,b,d,e)})},a._handleResponse=function(a,b,d,g,h){var i={query:b};switch(a){case f.GET:i.resource=new c.DriveFileResource(d),g(i);break;case f.LIST:b._pageToken(d.nextPageToken),i.resources=this._createFileResources(d.files||[]),g(i);break;default:throw e.UNKONW_ACTION}},a.permissions=d.DrivePermissions,a}(),a("Drive",g)}}}),System.register("google/drive/query.js",[],function(a){function b(a,b){a._queryFieldsRegistry=a._queryFieldsRegistry||{},a._queryFieldsRegistry[b]=[i,b,d.EQUAL]}function c(a,b){a._queryFieldsRegistry=a._queryFieldsRegistry||{},a._queryFieldsRegistry[b]=[j,b,d.IN]}var d,e,f,g,h,i,j,k,l,m=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},n=this&&this.__decorate||function(a,b,c,d){var e,f=arguments.length,g=3>f?b:null===d?d=Object.getOwnPropertyDescriptor(b,c):d;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)g=Reflect.decorate(a,b,c,d);else for(var h=a.length-1;h>=0;h--)(e=a[h])&&(g=(3>f?e(g):f>3?e(b,c,g):e(b,c))||g);return f>3&&g&&Object.defineProperty(b,c,g),g},o=this&&this.__metadata||function(a,b){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(a,b):void 0};return{setters:[],execute:function(){d={EQUAL:"=",NOT_EQUAL:"!=",IN:"in"},e={ASCENDING:"asc",DESCENDING:"desc"},f=["domain","user"],g=["createdTime","folder","modifiedByMeTime","modifiedTime","name","quotaBytesUsed","recency","sharedWithMeTime","starred","viewedByMeTime"],h=["drive","appDataFolder","photos"],i=function(){function a(a,b){this.key=a,this.defaultOperator=b,this.operatorValuePair={},this.operatorValuePair[d.EQUAL]=[],this.operatorValuePair[d.NOT_EQUAL]=[],this.operatorValuePair[d.IN]=[]}return Object.defineProperty(a.prototype,"valuesCount",{get:function(){var a,b=0;for(a in this.operatorValuePair)b+=this.operatorValuePair[a].length;return b},enumerable:!0,configurable:!0}),a.prototype.set=function(a,b){var c=a||this.defaultOperator;if(!this.operatorValuePair.hasOwnProperty(c))throw new Error('Uknown operator "'+c+'" for QueryField when setting value "'+b+'"');this.operatorValuePair[c].push(b)},a.prototype.toString=function(){var a,b,c,d,e,f=[];for(c in this.operatorValuePair)for(d=0;d<this.operatorValuePair[c].length;d+=1)if(this.operatorValuePair[c][d]instanceof Array){for(a="(",b=[],e=0;e<this.operatorValuePair[c][d].length;e+=1)b.push(this.key+c+'"'+this.operatorValuePair[c][d][e]+'"');a+=b.join(" or "),a+=")",f.push(a)}else f.push(this.key+c+'"'+this.operatorValuePair[c][d]+'"');return f.length>1?f.join(" and "):f.join("")},a}(),j=function(a){function b(){a.apply(this,arguments)}return m(b,a),b.prototype.toString=function(){var a,b,c=[];for(a in this.operatorValuePair)for(b=0;b<this.operatorValuePair[a].length;b+=1)c.push('"'+this.operatorValuePair[a][b]+'" '+a+" "+this.key);return c.join("")},b}(i),k=function(){function a(){var a,b,c;this._queryFields={};for(var d in this._queryFieldsRegistry)a=this._queryFieldsRegistry[d][0],b=this._queryFieldsRegistry[d][1],c=this._queryFieldsRegistry[d][2],this._queryFields[d]=new a(b,c)}return Object.defineProperty(a.prototype,"name",{get:function(){return this._queryFields.name.value},set:function(a){this._queryFields.name.value=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"mimeType",{get:function(){return this._queryFields.mimeType.value},set:function(a){this._queryFields.mimeType.value=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"fullText",{get:function(){return this._queryFields.fullText.value},set:function(a){this._queryFields.fullText.value=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"modifiedTime",{get:function(){return this._queryFields.modifiedTime.value},set:function(a){this._queryFields.modifiedTime.value=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"viewedByMeTime",{get:function(){return this._queryFields.viewedByMeTime.value},set:function(a){this._queryFields.viewedByMeTime.value=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"trashed",{get:function(){return this._queryFields.trashed.value},set:function(a){this._queryFields.trashed.value=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"starred",{get:function(){return this._queryFields.starred.value},set:function(a){this._queryFields.starred.value=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"parents",{get:function(){return this._queryFields.parents.value},set:function(a){this._queryFields.parents.value=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"owners",{get:function(){return this._queryFields.owners.value},set:function(a){this._queryFields.owners.value=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"writers",{get:function(){return this._queryFields.writers.value},set:function(a){this._queryFields.writers.value=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"readers",{get:function(){return this._queryFields.readers.value},set:function(a){this._queryFields.readers.value=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"sharedWithMe",{get:function(){return this._queryFields.sharedWithMe.value},set:function(a){this._queryFields.sharedWithMe.value=a},enumerable:!0,configurable:!0}),a.prototype.toString=function(){var a,b=[];for(var c in this._queryFields)this._queryFields.hasOwnProperty(c)&&this._queryFields[c].valuesCount>0&&(a=this._queryFields[c],b.push(a.toString()));return b.join(" and ")},n([b,o("design:type",String)],a.prototype,"name",null),n([b,o("design:type",String)],a.prototype,"mimeType",null),n([b,o("design:type",String)],a.prototype,"fullText",null),n([b,o("design:type",Date)],a.prototype,"modifiedTime",null),n([b,o("design:type",Date)],a.prototype,"viewedByMeTime",null),n([b,o("design:type",Boolean)],a.prototype,"trashed",null),n([b,o("design:type",Boolean)],a.prototype,"starred",null),n([c,o("design:type",String)],a.prototype,"parents",null),n([c,o("design:type",String)],a.prototype,"owners",null),n([c,o("design:type",String)],a.prototype,"writers",null),n([c,o("design:type",String)],a.prototype,"readers",null),n([b,o("design:type",Boolean)],a.prototype,"sharedWithMe",null),a}(),l=function(){function a(){this._queryQ=new k,this._fields=[],this._orderBy=[],this._spaces=[]}return a.prototype.corpus=function(a){if(-1===f.indexOf(a))throw new Error('"'+a+'" is not a valid corpus field. Valid fields are '+f);return this._corpus=a,this},a.prototype.equal=function(a,b,c){if(!this._queryQ._queryFields.hasOwnProperty(a))throw new Error('DriveQuery: No property named "'+a+'"');if(this._queryQ._queryFields[a]instanceof j&&(c||this._queryQ._queryFields[a].defaultOperator)!==d.IN)throw new Error('DriveQuery: QueryCollectionField only supports operator "'+d.IN+'"');return this._queryQ._queryFields[a].set(c,b),this},a.prototype.fields=function(a){return a instanceof Array?this._fields=this._fields.concat(a):this._fields.push(a),this},a.prototype.fileId=function(a){return this._fileId=a,this},a.prototype.limit=function(a){return this._limit=a,this},Object.defineProperty(a.prototype,"not",{get:function(){var a=this;return{equal:function(b,c){return a.equal(b,c,d.NOT_EQUAL)}}},enumerable:!0,configurable:!0}),a.prototype.orderBy=function(a,b){void 0===b&&(b=e.ASCENDING);var c;if(-1===g.indexOf(a))throw new Error('"'+a+'" is not a valid orderBy field. Valid fields are '+g);return c=a+(b===e.DESCENDING?" desc":""),this._orderBy.push(c),this},a.prototype.spaces=function(a){if(-1===h.indexOf(a))throw new Error('"'+a+'" is not a valid spaces field. Valid fields are '+h);return this._spaces.push(a),this},a.prototype.toQuery=function(){var a=this._queryQ.toString(),b={};return a&&(b.q=a),this._corpus&&(b.corpus=this._corpus),this._fields.length>0&&(b.fields=this._fields.join(",")),this._fileId&&(b.fileId=this._fileId),this._limit&&(b.pageSize=this._limit),this._orderBy.length>0&&(b.orderBy=this._orderBy.join(",")),this._spaces.length>0&&(b.spaces=this._spaces.join(",")),this._nextPageToken&&(b.pageToken=this._nextPageToken),b},a.prototype._pageToken=function(a){this._nextPageToken=a},a}(),a("DriveQuery",l)}}}),System.register("google/google.js",["./auth","./api","./drive/drive","./drive/query"],function(a){return{setters:[function(b){a({Auth:b.Auth})},function(b){a({API:b.API})},function(b){a({Drive:b.Drive})},function(b){a({DriveQuery:b.DriveQuery})}],execute:function(){}}}),System.register("cx/googleDrive.js",["google/google"],function(a){var b,c;return{setters:[function(a){b=a}],execute:function(){c=function(){function a(){}return a.bootstrap=function(){b.API.bootstrap("drive"),angular.module("ng.cx.google.drive",[]).service("google",[function(){"use strict";return{api:b.API,Auth:b.Auth,drive:b.Drive,DriveQuery:b.DriveQuery}}])},a}(),a("GoogleDrive",c)}}});
System.register("google/auth.js",["google/google"],function(a){var b,c,d;return{setters:[function(a){b=a}],execute:function(){c=["profile","https://www.googleapis.com/auth/drive"],d=function(){function a(a,b){var d,e=this;this.clientId=a,this.scopes=b||c,this._hook=new Promise(function(a){return d=a}),this._wait(function(){e._googleAuth=gapi.auth2.init({client_id:e.clientId,scope:e.scopes.join(" "),fetch_basic_profile:!1}),e._googleAuth.then(function(){d()})})}return a.prototype.authorize=function(){var a=this;return new Promise(function(b,c){a._hook.then(function(){a._googleAuth.signIn().then(b,c)})})},a.prototype.checkAuth=function(){var a=this;return new Promise(function(b,c){a._hook.then(function(){a._googleAuth.isSignedIn.get()?b():c()})})},a.prototype.signOut=function(){var a=this;return new Promise(function(b,c){a._hook.then(function(){a._googleAuth.signOut().then(b,c)})})},a.prototype._wait=function(a){b.API.bootstrap().then(a)},a}(),a("Auth",d)}}}),System.register("google/api.js",[],function(a){var b,c;return{setters:[],execute:function(){b={drive:"v3"},c=function(){function a(){}return a.bootstrap=function(a){var b=this;return this._api_load_promise||(this._api_load_promise=new Promise(function(c,d){return b._add_script_tag(c,d,a)})),this._api_load_promise},a.load=function(c,d){return b.hasOwnProperty(c)?b[c]!==d&&console.warn("Unsupported "+c+'-api version "'+d+'"'):console.warn('Unsupported api "'+c+'"'),a._script_loaded?new Promise(function(a,b){return gapi.client.load(c,d,a)}):Promise.reject("Google Apis has not been loaded")},a._add_script_tag=function(b,c,d){var e=this;if(a._script_loaded)this._api_has_loaded(b,c,d);else{var f=document.createElement("script"),g="__gapi__callback",h=window.document,i=h.getElementsByTagName("script")[0];f.setAttribute("src","https://apis.google.com/js/api:client.js?onload="+g),f.async=!0,window[g]=function(){gapi.load("auth2",function(){return e._api_has_loaded(b,c,d)})},i?i.parentNode.insertBefore(f,i):(h.head||h.body||h.documentElement).appendChild(f)}},a._api_has_loaded=function(c,d,e){a._script_loaded=!0,e?this.load(e,b[e]).then(c):c()},a._script_loaded=!1,a}(),a("API",c)}}}),System.register("google/drive/file.js",[],function(a){var b,c;return{setters:[],execute:function(){b={FOLDER:"application/vnd.google-apps.folder"},c=function(){function a(a){this.kind=a.kind,this.id=a.id,this.name=a.name,this.mimeType=a.mimeType,this.description=a.description,this.starred=a.starred,this.trashed=a.trashed,this.parents=a.parents,this.version=a.version,this.webContentLink=a.webContentLink,this.webViewLink=a.webViewLink,this.iconLink=a.iconLink,this.thumbnailLink=a.thumbnailLink,this.createdTime=a.createdTime,this.modifiedTime=a.modifiedTime}return a.prototype.isFolder=function(){return this.mimeType&&this.mimeType===b.FOLDER},a}(),a("DriveFileResource",c)}}}),System.register("google/drive/permissions.js",[],function(a){var b,c;return{setters:[],execute:function(){b={COMMENTER:"commenter",OWNER:"owner",READER:"reader",WRITER:"writer"},c=function(){function a(){}return a.create=function(a,b,c){var d=this,e={fileId:a,type:b,role:c},f=gapi.client.drive.permissions.create(e);return new Promise(function(a,b){return d._execute(f,a,b)})},a._execute=function(a,b,c){var d=this;a.execute(function(a){return d._handleResponse(a,b,c)})},a._handleResponse=function(a,b,c){b(a)},a}(),a("DrivePermissions",c)}}}),System.register("google/drive/drive.js",["./query","./file","./permissions"],function(a){var b,c,d,e,f,g;return{setters:[function(a){b=a},function(a){c=a},function(a){d=a}],execute:function(){e={UNKONW_ACTION:new Error("Can't handle result for unkown action")},function(a){a[a.GET=0]="GET",a[a.LIST=1]="LIST"}(f||(f={})),g=function(){function a(){}return a.get=function(a){var b=this,c=a||this._defaultQuery(),d=gapi.client.drive.files.get(c.toQuery());return new Promise(function(a,e){return b._execute(f.GET,d,c,a,e)})},a.list=function(a){var b,c=this,d=a||this._defaultQuery();return b=gapi.client.drive.files.list(d.toQuery()),new Promise(function(a,e){return c._execute(f.LIST,b,d,a,e)})},a._createFileResources=function(a){var b=[];return a.forEach(function(a){b.push(new c.DriveFileResource(a))}),b},a._defaultQuery=function(){return(new b.DriveQuery).limit(100)},a._execute=function(a,b,c,d,e){var f=this;b.execute(function(b){return f._handleResponse(a,c,b,d,e)})},a._handleResponse=function(a,b,d,g,h){var i={query:b};switch(a){case f.GET:i.resource=new c.DriveFileResource(d),g(i);break;case f.LIST:b._pageToken(d.nextPageToken),i.resources=this._createFileResources(d.files||[]),g(i);break;default:throw e.UNKONW_ACTION}},a.permissions=d.DrivePermissions,a}(),a("Drive",g)}}}),System.register("google/drive/query.js",[],function(a){function b(a,b){a._queryFieldsRegistry=a._queryFieldsRegistry||{},a._queryFieldsRegistry[b]=[i,b,d.EQUAL]}function c(a,b){a._queryFieldsRegistry=a._queryFieldsRegistry||{},a._queryFieldsRegistry[b]=[j,b,d.IN]}var d,e,f,g,h,i,j,k,l,m=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},n=this&&this.__decorate||function(a,b,c,d){var e,f=arguments.length,g=3>f?b:null===d?d=Object.getOwnPropertyDescriptor(b,c):d;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)g=Reflect.decorate(a,b,c,d);else for(var h=a.length-1;h>=0;h--)(e=a[h])&&(g=(3>f?e(g):f>3?e(b,c,g):e(b,c))||g);return f>3&&g&&Object.defineProperty(b,c,g),g},o=this&&this.__metadata||function(a,b){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(a,b):void 0};return{setters:[],execute:function(){d={EQUAL:"=",NOT_EQUAL:"!=",IN:"in"},e={ASCENDING:"asc",DESCENDING:"desc"},f=["domain","user"],g=["createdTime","folder","modifiedByMeTime","modifiedTime","name","quotaBytesUsed","recency","sharedWithMeTime","starred","viewedByMeTime"],h=["drive","appDataFolder","photos"],i=function(){function a(a,b){this.key=a,this.defaultOperator=b,this.operatorValuePair={},this.operatorValuePair[d.EQUAL]=[],this.operatorValuePair[d.NOT_EQUAL]=[],this.operatorValuePair[d.IN]=[]}return Object.defineProperty(a.prototype,"valuesCount",{get:function(){var a,b=0;for(a in this.operatorValuePair)b+=this.operatorValuePair[a].length;return b},enumerable:!0,configurable:!0}),a.prototype.set=function(a,b){var c=a||this.defaultOperator;if(!this.operatorValuePair.hasOwnProperty(c))throw new Error('Uknown operator "'+c+'" for QueryField when setting value "'+b+'"');this.operatorValuePair[c].push(b)},a.prototype.toString=function(){var a,b,c,d,e,f=[];for(c in this.operatorValuePair)for(d=0;d<this.operatorValuePair[c].length;d+=1)if(this.operatorValuePair[c][d]instanceof Array){for(a="(",b=[],e=0;e<this.operatorValuePair[c][d].length;e+=1)b.push(this.key+c+'"'+this.operatorValuePair[c][d][e]+'"');a+=b.join(" or "),a+=")",f.push(a)}else f.push(this.key+c+'"'+this.operatorValuePair[c][d]+'"');return f.length>1?f.join(" and "):f.join("")},a}(),j=function(a){function b(){a.apply(this,arguments)}return m(b,a),b.prototype.toString=function(){var a,b,c=[];for(a in this.operatorValuePair)for(b=0;b<this.operatorValuePair[a].length;b+=1)c.push('"'+this.operatorValuePair[a][b]+'" '+a+" "+this.key);return c.join("")},b}(i),k=function(){function a(){var a,b,c;this._queryFields={};for(var d in this._queryFieldsRegistry)a=this._queryFieldsRegistry[d][0],b=this._queryFieldsRegistry[d][1],c=this._queryFieldsRegistry[d][2],this._queryFields[d]=new a(b,c)}return Object.defineProperty(a.prototype,"name",{get:function(){return this._queryFields.name.value},set:function(a){this._queryFields.name.value=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"mimeType",{get:function(){return this._queryFields.mimeType.value},set:function(a){this._queryFields.mimeType.value=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"fullText",{get:function(){return this._queryFields.fullText.value},set:function(a){this._queryFields.fullText.value=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"modifiedTime",{get:function(){return this._queryFields.modifiedTime.value},set:function(a){this._queryFields.modifiedTime.value=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"viewedByMeTime",{get:function(){return this._queryFields.viewedByMeTime.value},set:function(a){this._queryFields.viewedByMeTime.value=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"trashed",{get:function(){return this._queryFields.trashed.value},set:function(a){this._queryFields.trashed.value=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"starred",{get:function(){return this._queryFields.starred.value},set:function(a){this._queryFields.starred.value=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"parents",{get:function(){return this._queryFields.parents.value},set:function(a){this._queryFields.parents.value=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"owners",{get:function(){return this._queryFields.owners.value},set:function(a){this._queryFields.owners.value=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"writers",{get:function(){return this._queryFields.writers.value},set:function(a){this._queryFields.writers.value=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"readers",{get:function(){return this._queryFields.readers.value},set:function(a){this._queryFields.readers.value=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"sharedWithMe",{get:function(){return this._queryFields.sharedWithMe.value},set:function(a){this._queryFields.sharedWithMe.value=a},enumerable:!0,configurable:!0}),a.prototype.toString=function(){var a,b=[];for(var c in this._queryFields)this._queryFields.hasOwnProperty(c)&&this._queryFields[c].valuesCount>0&&(a=this._queryFields[c],b.push(a.toString()));return b.join(" and ")},n([b,o("design:type",String)],a.prototype,"name",null),n([b,o("design:type",String)],a.prototype,"mimeType",null),n([b,o("design:type",String)],a.prototype,"fullText",null),n([b,o("design:type",Date)],a.prototype,"modifiedTime",null),n([b,o("design:type",Date)],a.prototype,"viewedByMeTime",null),n([b,o("design:type",Boolean)],a.prototype,"trashed",null),n([b,o("design:type",Boolean)],a.prototype,"starred",null),n([c,o("design:type",String)],a.prototype,"parents",null),n([c,o("design:type",String)],a.prototype,"owners",null),n([c,o("design:type",String)],a.prototype,"writers",null),n([c,o("design:type",String)],a.prototype,"readers",null),n([b,o("design:type",Boolean)],a.prototype,"sharedWithMe",null),a}(),l=function(){function a(){this._queryQ=new k,this._fields=[],this._orderBy=[],this._spaces=[]}return a.prototype.corpus=function(a){if(-1===f.indexOf(a))throw new Error('"'+a+'" is not a valid corpus field. Valid fields are '+f);return this._corpus=a,this},a.prototype.equal=function(a,b,c){if(!this._queryQ._queryFields.hasOwnProperty(a))throw new Error('DriveQuery: No property named "'+a+'"');if(this._queryQ._queryFields[a]instanceof j&&(c||this._queryQ._queryFields[a].defaultOperator)!==d.IN)throw new Error('DriveQuery: QueryCollectionField only supports operator "'+d.IN+'"');return this._queryQ._queryFields[a].set(c,b),this},a.prototype.fields=function(a){return a instanceof Array?this._fields=this._fields.concat(a):this._fields.push(a),this},a.prototype.fileId=function(a){return this._fileId=a,this},a.prototype.limit=function(a){return this._limit=a,this},Object.defineProperty(a.prototype,"not",{get:function(){var a=this;return{equal:function(b,c){return a.equal(b,c,d.NOT_EQUAL)}}},enumerable:!0,configurable:!0}),a.prototype.orderBy=function(a,b){void 0===b&&(b=e.ASCENDING);var c;if(-1===g.indexOf(a))throw new Error('"'+a+'" is not a valid orderBy field. Valid fields are '+g);return c=a+(b===e.DESCENDING?" desc":""),this._orderBy.push(c),this},a.prototype.spaces=function(a){if(-1===h.indexOf(a))throw new Error('"'+a+'" is not a valid spaces field. Valid fields are '+h);return this._spaces.push(a),this},a.prototype.toQuery=function(){var a=this._queryQ.toString(),b={};return a&&(b.q=a),this._corpus&&(b.corpus=this._corpus),this._fields.length>0&&(b.fields=this._fields.join(",")),this._fileId&&(b.fileId=this._fileId),this._limit&&(b.pageSize=this._limit),this._orderBy.length>0&&(b.orderBy=this._orderBy.join(",")),this._spaces.length>0&&(b.spaces=this._spaces.join(",")),this._nextPageToken&&(b.pageToken=this._nextPageToken),b},a.prototype._pageToken=function(a){this._nextPageToken=a},a}(),a("DriveQuery",l)}}}),System.register("google/google.js",["./auth","./api","./drive/drive","./drive/query"],function(a){return{setters:[function(b){a({Auth:b.Auth})},function(b){a({API:b.API})},function(b){a({Drive:b.Drive})},function(b){a({DriveQuery:b.DriveQuery})}],execute:function(){}}}),System.register("cx/googleDrive.js",["google/google"],function(a){var b,c;return{setters:[function(a){b=a}],execute:function(){c=function(){function a(){}return a.bootstrap=function(){b.API.bootstrap("drive"),angular.module("ng.cx.google.drive",[]).service("google",[function(){"use strict";return{api:b.API,Auth:b.Auth,drive:b.Drive,DriveQuery:b.DriveQuery}}])},a}(),a("GoogleDrive",c)}}});
//# sourceMappingURL=ng.cx.google.drive.js.map

@@ -31,2 +31,3 @@ angular.module('ng.cx.google.drive.example', [

$scope.openNewWindow = openNewWindow;
$scope.revoke = revoke;
$scope.isAudio = isAudio;

@@ -39,16 +40,4 @@ $scope.isImage = isImage;

_auth.checkAuth().then(function () {
$scope.$evalAsync(function () {
$scope.authorized = true;
$scope.loading = false;
});
_checkAuth();
_loadFiles();
}, function (reason) {
$scope.$evalAsync(function () {
$scope.authorized = false;
$scope.loading = false;
});
});
function authorize() {

@@ -58,2 +47,4 @@ _auth.authorize().then(function () {

_loadFiles();
}, function (reason) {
console.log('reason', reason);
});

@@ -97,2 +88,6 @@ }

function revoke() {
_auth.signOut().then(_checkAuth, _checkAuth);
}
function isAudio(file) {

@@ -124,2 +119,19 @@ return /^audio/.test(file.mimeType);

function _checkAuth() {
_auth.checkAuth().then(function () {
$scope.$evalAsync(function () {
$scope.authorized = true;
$scope.loading = false;
});
_loadFiles();
}, function (reason) {
$scope.$evalAsync(function () {
$scope.authorized = false;
$scope.loading = false;
$scope.items = [];
});
});
}
function _loadFiles() {

@@ -126,0 +138,0 @@ var _query = new google.DriveQuery();

{
"name": "ng.cx.google.drive",
"version": "1.0.1",
"version": "1.0.2",
"description": "angular 1.0 wrapper for google drive api written in typescript",

@@ -5,0 +5,0 @@ "license": {

@@ -44,6 +44,17 @@ /// <reference path="../../typings/tsd.d.ts" />

_elem.setAttribute('src', 'https://apis.google.com/js/client.js?onload=' + _readyCallbackName);
/**
On a side note: It's impossible to decypher what google js-api to load.
`https://apis.google.com/js/api:client.js`
or
`https://apis.google.com/js/api/client.js`
or
`https://apis.google.com/js/api/platform.js`
*/
_elem.setAttribute('src', 'https://apis.google.com/js/api:client.js?onload=' + _readyCallbackName);
_elem.async = true;
window[_readyCallbackName] = () => this._api_has_loaded(resolve, reject, preload_api);
window[_readyCallbackName] = () => {
gapi.load('auth2', () => this._api_has_loaded(resolve, reject, preload_api));
}

@@ -50,0 +61,0 @@ if (_node) {

@@ -8,6 +8,7 @@ /// <reference path="../../typings/tsd.d.ts" />

describe('Auth', function() {
var clientId = '42';
var CLIENT_ID = '42';
beforeEach(function() {
spyOn(gapi.auth, 'authorize').and.callThrough();
spyOn(gapi.auth2, 'init').and.callThrough();
API._add_script_tag = function(resolve, reject) {

@@ -18,29 +19,31 @@ this._api_has_loaded(resolve, reject);

it('should assign clientId and scopes', function() {
it('should assign clientId and scopes', function(done) {
var scopes = ['scope1'];
var client = new Auth('42', scopes);
var client = new Auth(CLIENT_ID, scopes);
expect(client.clientId).toBe('42');
expect(client.scopes).toBe(scopes);
API.bootstrap().then(() => {
expect(client.clientId).toBe(CLIENT_ID);
expect(client.scopes).toBe(scopes);
expect(gapi.auth2.init).toHaveBeenCalled();
done();
});
});
it('should assign default scopes', function() {
var client = new Auth('42');
var client = new Auth(CLIENT_ID);
expect(client.clientId).toBe('42');
expect(client.scopes).toEqual(['https://www.googleapis.com/auth/drive']);
expect(client.clientId).toBe(CLIENT_ID);
expect(client.scopes).toEqual(['profile', 'https://www.googleapis.com/auth/drive']);
});
it('should call gapi.auth.authorize and resolve promise', function(done) {
var client = new Auth('42'),
success = false;
it('should call signIn on _googleAuth and resolve promise', function(done) {
var client = new Auth(CLIENT_ID),
success = false;
client.authorize().then(function () {
success = true;
expect(gapi.auth.authorize).toHaveBeenCalled();
expect(success).toBe(true);
done();
}, function () {
}, function (reason) {
expect(success).toBe(true);

@@ -51,10 +54,24 @@ done();

it('should call gapi.auth.checkAuth and resolve promise', function(done) {
var client = new Auth('42'),
success = false;
it('should signout and resolve promise', function(done) {
var client = new Auth(CLIENT_ID),
success = false;
client.signOut().then(function() {
success = true;
expect(success).toBe(true);
done();
}, function(reason) {
expect(success).toBe(true);
done();
});
});
it('should call isSignedIn.get and resolve promise', function(done) {
var client = new Auth(CLIENT_ID),
success = false;
client.checkAuth().then(function() {
success = true;
expect(gapi.auth.authorize).toHaveBeenCalled();
expect(success).toBe(true);

@@ -61,0 +78,0 @@

/// <reference path="../../typings/tsd.d.ts" />
import {API} from 'google/google';
/**
For some damned reason we need to get the 'profile' scope as well.
If we don't we get "random" error after `signIn`.
Errors include:
- `{"error":"IMMEDIATE_FAILED","detail":"Not all scopes are approved."}` when using promt=none on signIn
- `{type: "tokenFailed", idpId: "google", error: "IMMEDIATE_FAILED"}` when using `signIn` with no arguments
var SCOPES = ['https://www.googleapis.com/auth/drive'];
Adding `profile` as part of the scope seems to solve all these issues.
Note:
Using auth2 or auth since gapi.auth.signOut is broken. And undocumented (https://developers.google.com/api-client-library/javascript/reference/referencedocs#gapiclientrequest)
It's too bad, since `gapi.auth.authorize` seems to work better then `auth2` and `signIn`.
Also it would be amazing to know where this API is headed. Is auth or auth2 the way to go.
**/
var SCOPES = ['profile', 'https://www.googleapis.com/auth/drive'];
export class Auth {

@@ -11,39 +24,53 @@ scopes: Array<string>;

private _googleAuth: any;
private _hook: Promise<any>;
constructor(clientId: string, scopes?:Array<string>) {
var _resolve;
this.clientId = clientId;
this.scopes = scopes || SCOPES;
this._hook = new Promise((resolve) => _resolve = resolve);
this._wait(() => {
this._googleAuth = gapi.auth2.init({
'client_id': this.clientId,
'scope': this.scopes.join(' '),
'fetch_basic_profile': false
});
this._googleAuth.then(() => {
_resolve();
});
});
}
authorize() {
return new Promise((resolve, reject) => this._authorize(resolve, reject, false));
return new Promise((resolve, reject) => {
this._hook.then(() => {
this._googleAuth.signIn().then(resolve, reject);
});
});
}
checkAuth() {
return new Promise((resolve, reject) => this._authorize(resolve, reject, true));
return new Promise((resolve, reject) => {
this._hook.then(() => {
this._googleAuth.isSignedIn.get() ? resolve() : reject();
});
});
}
private _authorize(resolve, reject, immediate) {
var self = this;
signOut() {
return new Promise((resolve, reject) => {
this._hook.then(() => {
this._googleAuth.signOut().then(resolve, reject);
});
});
}
API.bootstrap().then(_gapi_authorize);
function _gapi_authorize() {
gapi.auth.authorize({
'client_id': self.clientId,
'scope': self.scopes,
'immediate': immediate
},
self._handleAuthResult(resolve, reject));
}
}
private _handleAuthResult(resolve, reject) {
return function(authResult) {
if (authResult && !authResult.error) {
resolve(authResult);
} else {
reject(authResult.error);
}
}
private _wait(fn:any) {
API.bootstrap().then(fn);
}
}

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

declare class GoogleAuth {}
declare module gapi {
export function load(name: string, version: any, callback?:any): any;
}
declare module gapi.auth2 {
export function init(params: any): GoogleAuth;
}
declare module gapi.client.drive {

@@ -2,0 +12,0 @@

@@ -12,11 +12,17 @@ /// <reference path='../typings/tsd.d.ts' />

function GoogleAuthMock() {
this.signIn = () => Promise.resolve(true);
this.signOut = () => Promise.resolve(true);
this.isSignedIn = {
'get': () => true
}
this.then = (cb) => cb() && this;
}
gapi = {
'auth': {
'authorize': function(opt, callback) {
callback({
'access_token': 'a',
'expires_in': '1',
'state': '1'
});
'auth2': {
'init': function () {
return new GoogleAuthMock();
}

@@ -23,0 +29,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc