{"id":13481795,"url":"https://github.com/selfbits/selfbits-angular2-sdk","last_synced_at":"2025-03-27T12:31:29.861Z","repository":{"id":143907985,"uuid":"68313890","full_name":"selfbits/selfbits-angular2-sdk","owner":"selfbits","description":"Angular 2 SDK for Selfbits Backend-as-a-Service","archived":true,"fork":false,"pushed_at":"2016-12-09T10:45:16.000Z","size":73,"stargazers_count":7,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-22T10:16:15.045Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.selfbits.io","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/selfbits.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-09-15T17:03:45.000Z","updated_at":"2023-01-28T07:56:36.000Z","dependencies_parsed_at":"2023-04-14T12:54:25.272Z","dependency_job_id":null,"html_url":"https://github.com/selfbits/selfbits-angular2-sdk","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selfbits%2Fselfbits-angular2-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selfbits%2Fselfbits-angular2-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selfbits%2Fselfbits-angular2-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selfbits%2Fselfbits-angular2-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/selfbits","download_url":"https://codeload.github.com/selfbits/selfbits-angular2-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245585813,"owners_count":20639671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T17:00:55.823Z","updated_at":"2025-03-27T12:31:29.550Z","avatar_url":"https://github.com/selfbits.png","language":"TypeScript","readme":"![Project Logo](http://i.imgur.com/mAYkfSt.jpg)\n\n\n# [Selfbits Angular2 SDK](https://github.com/selfbits/selfbits-angular2-sdk)\n\nThis package enables you to easily integrate [Selfbits' Backend-as-Service](https://www.selfbits.io) into your **Angular 2 projects**.\nSelfbits allows you to skip backend development and focus on what's most important for you: your user-experience.\n\n\nPlease note that you MUST have a Selfbits account and an active Project to use the service. Check out \u003chttps://www.selfbits.io\u003e for more info.\n\n**Note**: Check out our sdk for [AnguarJS](https://github.com/selfbits/selfbits-angular-sdk) and various [starter templates](https://github.com/selfbits)!\n\n\n## Features\n\n- **auth** - Provides Social \u0026 Basic Auth\n- **database** - Puts a ready to use database integration at your fingertips\n- **file** - Provides easy to use file storage for your App\n- **user** - Handles interaction with user data\n- **device** - Handles data from the device (Cordova only)\n- **push** - Provides Push Notification (Cordova only)\n\n\n\n![Background Auth](http://i.imgur.com/94cDviv.jpg?1)\n\n\n\n\n\n## Contents\n\n- [Installation](#installation)\n\n- [Setup in ngModule](#setup)\n\n- [Usage](#usage)\n  - [Usage in Components](#usage-in-components)\n  - [Usage in Services](#usage-in-services)\n\n- [Implementation with popular templates](#implementation-with-popular-templates)\n  - [SystemJS Based](#systemjs-based)\n      - [Angular 2 Quickstart](#angular-2-quickstart)\n      - [Angular 2 Seed](#angular-2-seed)\n  - [Webpack Based](#systemjs-based)\n      - [Angular 2 Starter Webpack](#angular-2-starter-webpack)\n      - [Angular Cli](#angular-cli)\n\n- [API Reference](#api-reference)\n  - [SelfbitsAngular: auth](#selfbitsangular-auth)\n    - [auth.login(authData)](#auth-login-authdata-)\n    - [auth.signup(authData)](#auth-signup-authdata-)\n    - [auth.social(providerName)](#auth-social-providername-)\n    - [auth.unlink(providerName)](#auth-unlink-providername-)\n    - [auth.password(newPassword, oldPassword)](#auth-password-newpassword-oldpassword-)\n    - [auth.logout()](#auth-logout-)\n    - [auth.getUserId()](#auth-getuserid-)\n    - [auth.isAuthenticated()](#auth-isauthenticated-)\n    - [auth.signupAnonymous()](#auth-signupanonymous-)\n\n  - [SelfbitsAngular: database](#selfbitsangular-database)\n    - [database.databaseSchema()](#database-databaseschema-tablename-)\n\n  - [SelfbitsAngular: file](#selfbitsangular-file)\n    - [file.get()](#file-getparams-)\n    - [file.upload()](#file-uploadparams-)\n\n  - [SelfbitsAngular: user](#selfbitsangular-user)\n    - [user.current()](#user-current-)\n\n  - [device](#selfbitsangular-device)\n    - [device.sync()](#device-sync-)\n\n- [License](#license)\n\n## Installation\n\n\u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/d/db/Npm-logo.svg\" height=\"22\" align=\"top\"\u003e NPM\n```\nnpm install selfbits-angular2-sdk --save\n```\n\n## Setup\n\nGo to your root ngModule (usually app.module.ts).\nAdd your Selfbits app credentials to SELFBITSCONFIG and initialize by importing SelfbitsAngularModule.initializeApp (SELFBITSCONFIG).  *You find your Selfbits app credential, when you access the dashboard of your project and click on the gear-icon in the left column, next to your project name.*\n\n```javascript\n\nimport {SelfbitsAngularModule} from 'selfbits-angular2-sdk';\n\nconst SELFBITSCONFIG = {\n  /* Your App Domain */\n    BASE_URL:'YourSbAppDomain',\n  /* Your Selfbits App ID */\n    APP_ID:'yourSbAppId',\n  /* OPTIONAL: your Selfbits App Secret\n     NOTE: on public clients we highly recommend to set Allowed Origins\n     in your Selfbits BaaS Project Dashboard instead of using the Secret\n  */  \n    APP_SECRET:'yourSbAppSecret',\n};\n\n@NgModule({\n    imports: [\n        /* other imports */\n        SelfbitsAngularModule.initializeApp(SELFBITSCONFIG)\n    ],\n    /*...your other providers, declarations,..*/\n})\nexport class AppModule { }\n```\n\n\n## Usage\n\nOur sdk can be consumed directly inside your components.\n\n### Usage in Components\n\n```javascript\n\nimport { SelfbitsAngular } from 'selfbits-angular2-sdk';\n\nexport class LoginComponent {\n\n  constructor(private sb:SelfbitsAngular) {}\n\n  login(authData) {\n          this.sb.auth.login(authData).subscribe( res =\u003e {\n              // DO SOMETHING AFTER LOGIN\n          })\n      }\n  }\n}\n```\n\n### Usage in Services\n\nOf course feel free to wrap our methods in your own services!\n\n```javascript\nimport { Injectable } from '@angular/core'\nimport { SelfbitsAngular } from 'selfbits-angular2-sdk';\n\n@Injectable()\nexport class TodoDatabaseService {\n\n    public todo;\n\n    constructor(private sb:SelfbitsAngular) {\n        this.todo = this.sb.database.dataSchema('todo');\n    }   \n\n    createTodo(todo) {\n        this.todo.post(todo)\n            .map( res =\u003e { /*do something*/ return res})\n            .subscribe( res =\u003e {\n                console.log(res.json())\n            })\n    }\n}\n```\n\n## Implementation with popular templates\n\n### SystemJS Based\n\nWith SystemJS you need to configure the **system.config.js** file in order to have the sdk loaded. The config file usually sits directly in the root folder.\n\n#### Angular 2 Quickstart\n\nThis is the offical [quickstart template](https://github.com/angular/quickstart) found on angular.io.\n\n```javascript\nmap:{\n    (...)\n    // other libraries\n    'rxjs':                       'npm:rxjs',\n    'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',\n    'selfbits-angular2-sdk':      'npm:selfbits-angular2-sdk/dist' // This tells SystemJs WHERE to look for the sdk, don't forget /dist!\n    },\npackages: {\n    (...)\n    'angular2-in-memory-web-api': {\n        main: './index.js',\n        defaultExtension: 'js'\n    },\n    'selfbits-angular2-sdk':{ // this tells SystemJs WHAT to load, in our case the sdk's entry point\n        main:'./index.js',\n        defaultExtension: 'js'\n    }\n    rxjs: {\n        main: './Rx.js', // if console shows rxjs not found, then add this line\n        defaultExtension: 'js'\n    }\n}\n(...)\n```\n\n#### Angular 2 Seed\n\n[Angular 2 Seed by mgechev](https://github.com/mgechev/angular2-seed) is one of the most popular angular 2 starter templates based on SystemJS. The system.config.js is devided to **project.config.ts** and **seed.config.ts** and can be found under root \u003e tools \u003e config.\n\n```javascript\nSYSTEM_CONFIG_DEV: any = {\n    defaultJSExtensions: true,\n    packageConfigPaths: [\n      `/node_modules/*/package.json`,\n      `/node_modules/**/package.json`,\n      `/node_modules/@angular/*/package.json`\n    ],\n    paths: {\n        (...)\n        'rxjs/*': 'node_modules/rxjs/*',\n        'selfbits-angular2-sdk':'node_modules/selfbits-angular2-sdk/dist/index.js', // here you need to specify the whole file path\n        'app/*': '/app/*',\n    },\n};\n\nSYSTEM_BUILDER_CONFIG: any = {\n    (...)\n    packages: {\n        (...)\n        'rxjs': {\n            defaultExtension: 'js'\n        },\n        'selfbits-angular2-sdk':{ // and again the package infos\n            main: 'index.js',\n            defaultExtension: 'js'\n        }\n    }\n};\n```\n\n### Webpack Based\n\nAll you need to do is to install and setup the sdk as described above (in app.module.ts). Webpack will take care of the rest for us. Here are some templates you can start with.\n\n#### Angular 2 Starter Webpack\nThis popular [template](https://github.com/AngularClass/angular2-webpack-starter) is created from the people of [Angular Class](https://angularclass.com/) and uses Webpack to bundle the files.\n\n#### Angular CLI\nA powerful and convenient [CLI tool](https://github.com/angular/angular-cli) for creating, serving and testing angular 2\n\n## API Reference\n\n### Always import SelfbitsAngular\n\n```javascript\nimport {SelfbitsAngular} from 'selfbits-angular2-sdk';\n```\n\n### SelfbitsAngular: auth\n\n- [auth.login(authData)](#auth-login-authdata-)\n- [auth.signup(authData)](#auth-signup-authdata-)\n- [auth.social(providerName)](#auth-social-providername-)\n- [auth.unlink(providerName)](#auth-unlink-providername-)\n- [auth.password(newPassword, oldPassword)](#auth-password-newpassword-oldpassword-)\n- [auth.logout()](#auth-logout-)\n- [auth.getUserId()](#auth-getuserid-)\n- [auth.isAuthenticated()](#auth-isauthenticated-)\n- [auth.signupAnonymous()](#auth-signupanonymous-)\n\n#### auth.login(authData)\n\nSign in using email and password.\n\n###### Parameters\n\nParam    | Type     | Details\n-------- | -------- | ---------------------------------\nauthData | `Object` | `{email:string, password:string}`\n\n###### Returns\n\n- **Observable** - default angular 2 HTTP observable of type Response.\n\n###### Usage\n\n```javascript\n/* Place code below inside Component or Service */\n\nconstructor(private sb: SelfbitsAngular) {\n\n    let authData = {\n        email: 'abc@def.de',\n        password: 'mypassword'\n    }\n\n    /* This code could go in any method */\n    this.sb.auth.login(authData).subscribe(res =\u003e {\n        if (res.status === 200){\n          // Redirect user here after a successful login.';\n        }\n        else{\n            // Handle errors depndening the response, such as 401 unauthorized\n        }\n        }, err =\u003e console.log(err)\n    );\n}\n```\n\n#### auth.signup(authData)\n\nSign up using email and password.\n\n- **Note** Our Backend accepts only email and password properties for basic signup, everything else will be ignored Don't forget to use angulars formbuilder to perform basic validations!\n\n##### Parameters\n\nParam    | Type     | Details\n-------- | -------- | ---------------------------------\nauthData | `Object` | `{email:string, password:string}`\n\n##### Returns\n\n- **Observable** - default angular 2 HTTP observable of type Response.\n\n##### Usage\n\n```javascript\n\nconstructor(private sb: SelfbitsAngular) {\n\n    let user = {\n        email: 'abc@def.de',\n        password: 'mypassword'\n    }\n\n    this.sb.auth.signup(authData).subscribe( res =\u003e {\n         if (res.status === 200){\n           // Redirect user here after a successful login.';\n         }\n         else{\n           // Handle errors depndening the response, such as 401 unauthorized\n         }\n       }, err =\u003e console.log(err)\n    );\n}\n```\n\n#### auth.signupAnonymous()\n\nSignup as anonymous user\n\n##### Returns\n\n- **Observable** - default angular 2 HTTP observable of type Response.\n\n##### Usage\n\n```javascript\n\nconstructor(private sb: SelfbitsAngular) {\n\n    this.sb.auth.signupAnonymous().subscribe( res =\u003e {\n        if (res.status === 200){\n            // Redirect user here after a successful login.';\n        }\n        else{\n            // Handle errors depndening the response, such as 401 unauthorized\n        }\n        }, err =\u003e console.log(err)\n    );\n}\n```\n\n#### auth.social(providerName)\n\nSign in **OR** up using social providers. Opens a popup window, that leads the user through the social auth flow.\n\n__Selfbits handles the complete OAuth flow in our backend. Please follow the Setup Guide in your Selfbits Admin Panel under: Project \u003e Authentication \u003e Auth Provider__\n\n##### Parameters\n\nParam        | Type     | Details\n------------ | -------- | ----------------------------------------------------------------------\nproviderName | `string` | String with the Providername in lowercase, e.g. 'facebook' or 'github'\n\n##### Returns\n\n- **Observable** - default angular 2 HTTP observable of type Response.\n\n##### Usage\n\n```javascript\n\nconstructor(private sb: SelfbitsAngular) {\n\n    this.sb.auth.social('facebook').subscribe( res =\u003e {\n        if (res.status === 200){\n          // Redirect user here after a successful login.';\n        }\n        else{\n          // Handle errors depndening the response, such as 401 unauthorized\n        }\n        }, err =\u003e console.log(err)\n    );\n}\n```\n\n#### auth.unlink(providerName)\n\nUnlink social providers from a user profile, so it become linkable from other accounts. Does **NOT** remove authentication rights from social provider itself.\n\n##### Parameters\n\nParam        | Type     | Details\n------------ | -------- | ----------------------------------------------------------------------\nproviderName | `string` | String with the Providername in lowercase, e.g. 'facebook' or 'github'\n\n##### Returns\n\n- **Observable** - default angular 2 HTTP observable of type Response.\n\n##### Usage\n\n```javascript\n\nconstructor(private sb: SelfbitsAngular) {\n    this.sb.auth.social('facebook').subscribe( res =\u003e {\n             if (res.status === 200){\n               // Redirect user here after a successful login.';\n             }\n             else{\n               // Handle errors depndening the response, such as 401 unauthorized\n             }\n        }, err =\u003e console.log(err)\n    );\n}\n```\n\n#### auth.password(newPassword, oldPassword?)\n\nAllows users to update password or create one, if the user used social auth. You have to make sure to make necessary sanity checks for the new password (e.g. password repeat, password strength).\n\n##### Parameters\n\nParam                  | Type     | Details\n---------------------- | -------- | ------------------------------------------------------------------\nnewPassword            | `string` | The new password\noldPassword (optional) | `string` | The existing password (only required if a password already exists)\n\n##### Returns\n\n- **Observable** - default angular 2 HTTP observable of type Response.\n\n##### Usage\n\n```javascript\nconstructor(private sb: SelfbitsAngular) {\n\n    this.sb.auth.password('oldPassword', 'newPassword').subscribe( res =\u003e {\n         if (res.status === 200){\n           // Redirect user here after a successful login.';\n         }\n         else{\n           // Handle errors depndening the response, such as 401 unauthorized\n         }\n         }, err =\u003e console.log(err)\n    );\n}\n```\n\n#### auth.logout()\n\nHelper Method which removes Token, UserId and Expires from localStorage.\n\n##### Returns\n\n- **Void**\n\n##### Usage\n\n```javascript\nconstructor(private sb: SelfbitsAngular) {\n    this.sb.auth.logout();\n}\n```\n\n#### auth.getUserId()\n\n##### Returns\n\n- **String** - Returns the UserID as String by retrieving it from the localStorage\n\n##### Usage\n\n```javascript\n\nconstructor(private sb: SelfbitsAngular) {\n\n    this.sb.auth.getUserId();\n\n}\n```\n\n#### auth.isAuthenticated()\n\nPerforms a user.current() http request with the current token, in order to check validity. Returns Observable\n\n\u003cboolean\u003e, can be use for angular 2 routing guards\u003c/boolean\u003e\n\n##### Returns\n\n- **Observable** - Returns Observable of type boolean\n\n##### Usage\n\n```javascript\nimport {Injectable} from \"@angular/core\";\nimport {CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from \"@angular/router\";\n\n@Injectabe()\n\nexport class RoutingGuard implements CanActivate {\n    constructor(private sb: SelfbitsAngular) {\n    }\n\n    canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot):Observable\u003cboolean\u003e || boolean {\n        return this.sb.auth.isAuthenticated()\n    }\n}\n```\n\n### SelfbitsAngular: database\n\nCreate a database object with CRUD Methods on the fly\n\n#### database.databaseSchema(tableName)\n\nReturns an instance of a SbHttp with CRUD Methods. Create by passing the SchemaId of your Collection on Selfbits.\n\n##### Parameters\n\nParam     | Type     | Details\n--------- | -------- | ----------------------------------------------\ntableName | `string` | Name of the table/collection you want to query\n\n##### Returns\n\n- **Object** - returns a SelfbitsHttp object\n\n##### Usage\n\n```javascript\npublic todoDb:SelfbitsHttp; // typing it provides intelliSense for IDE\n\nconstructor(private sb:SelfbitsAngular){\n    this.todoDb = this.sb.database.databaseSchema('todo');\n\n    this.todoDb.get(getParams).subscribe();\n    this.todoDb.query(params).subscribe(); // params optional\n    this.todoDb.post(todo).subscribe();\n    this.todoDb.put(todo, id).subscribe();\n    this.todoDb.delete(id).subscribe();\n}\n```\n\n#### get(getParams)\n\nget single item by ID, with optional params **deep** and **meta** booleans.\n\n**deep** When set to true, referenced children objects are fetched **meta** When set to true, shows timestamp and version metadata\n\n###### Parameters\n\nParam     | Type     | Details\n--------- | -------- | -----------------------------------------------------\ngetParams | `Object` | `SbGetParams {id: any,deep?: boolean,meta?: boolean}`\n\n###### Returns\n\n- **Observable** - default angular 2 HTTP observable of type Response.\n\n#### query(queryParams?)\n\nGet all items with optional mongoose filter as well as **deep** and **meta** booleans. If no params are sent, then all items are fetched according to user roles settings.\n\n###### Parameters\n\nParam                  | Type     | Details\n---------------------- | -------- | ---------------------------------------------------------------------------------------------------------------\n(Optional) queryParams | `Object` | `SbGetParams pageSize?: number,pageNumber?: number,filter?: string,sort?: string,deep?: boolean,meta?: boolean`\n\n###### Returns\n\n- **Observable** - default angular 2 HTTP observable of type Response.\n\n#### post(data)\n\nPost data to the collection specified according to the created database.Schema('collectionName') instance.\n\n###### Parameters\n\nParam | Type     | Details\n----- | -------- | -------------------------------\ndata  | `Object` | according to collection created\n\n###### Returns\n\n- **Observable** - default angular 2 HTTP observable of type Response.\n\n#### put(data,id)\n\nUpdate specific item according to id and replaces it with the data sent.\n\nParam | Type     | Details\n----- | -------- | -------------------------------\ndata  | `Object` | according to collection created\nid    | `string` | id of item to be updated\n\n###### Returns\n\n- **Observable** - default angular 2 HTTP observable of type Response.\n\n#### delete(id)\n\nRemoves item with specific id from collection.\n\n###### Parameters\n\nParam | Type     | Details\n----- | -------- | ------------------------\nid    | `string` | id of item to be deleted\n\n###### Returns\n\n- **Observable** - default angular 2 HTTP observable of type Response.\n\n##### Example Todo\n\n```javascript\n\n//create a variable for a SelfbitsDatabaseObject\nprivate todoDb:SelfbitsHttp;\nprivate todos =[];\nprivate myTodo;\n\n// Select the active database and bind the SelfbitsDatabaseObject to a variable\nconstructor(private sb: SelfbitsAngular) {\n  this.todoDb = this.sb.database.databaseSchema('todo');\n\n  // retrieve all todo and request meta data and deep-linked objects\n  this.todoDb.query({ meta: true, deep: true}).subscribe(res =\u003e {\n    this.todos = res.json() // just passing a reference WITHOUT typing, if typing is needed add a map operator before subscribe\n  })\n\n  // retrieve single todo by id and bind it to variable\n  this.todo.get({ID:\"57879806aeb310dc651899ef\"}).subscribe(res =\u003e this.myTodo = res.json());\n\n  // save a todo object to the database\n  let newTodo = {\n      title: 'Buy Milk',\n      description: 'Please get fresh milk from Wholefoods'\n  }\n  this.todo.post(newTodo).subscribe(res =\u003e console.log(res));\n\n  // update a todo object in the database\n  let updateTodo = {\n      description: 'Please get FRESH milk from Wholefoods'\n  }\n  this.todo.put(updateTodo,\"57879806aeb310dc651899ef\");\n\n  // delete a todo object in the database\n  this.todo.delete(\"57879806aeb310dc651899ef\");\n}\n\n```\n\n\n### SelfbitsAngular: file\n\n```javascript\nconstructor(private sb:SelfbitsAngular){\n    this.sb.file.get(params).subscribe()\n    this.sb.file.upload(params).subscribe()\n}\n```\n\n#### file.get(params)\n\nGet metadata of an uploaded file that contains a temporary download link.\n\n##### Parameters\n\nParam                   | Type     | required | default | Details\n----------------------- | -------- | -------- | ------- | -----------------\nparams                  | `Object` | true     |         | JavaScript object\nparams.fieldId          | `string` | true     |         | JavaScript object\nparams.expiresInSeconds | `number` | false    | 900     | JavaScript object\n\n##### Returns\n\n- **Observable** - default angular 2 HTTP observable of type Response.\n\n##### Usage\n\n```javascript\n\nconstructor(private sb: SelfbitsAngular) {\n\n    let params = {\n      fileId: 'YOUR-FILE-ID',\n      expiresInSeconds: 60\n    }\n\n    this.file.get(params).subscribe(\n      res =\u003e {\n        if (res.status === 200){\n          // do something with file metadata response\n          let downloadLink = res.url;\n          // use download link as long as it is valid\n        }\n        else{\n          // Handle errors here, such as displaying a notification\n        }\n      }\n    );\n}\n```\n\n#### file.upload(params)\n\nUpload a file to the authenticated user's file store. Unified function that initiates, executes and verifies the upload.\n\n##### Parameters\n\nParam                  | Type     | required | default          | Details\n---------------------- | -------- | -------- | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------\nparams                 | `Object` | true     |                  | JavaScript object containing upload information\nparams.file            | `file`   | true     |                  | The file you want to upload\nparams.filePath        | `string` | false    | params.file.name | The destination path where you want to put the file. This path is prefixed by\n\n\u003cproject-id\u003e/\u003cuser-id\u003e/\u003c/user-id\u003e\u003c/project-id\u003e\nparams.permissionScope | `string` | false    | user             | The permission scope: 'user' = only the uploading user can access the file. ' * ' : Every authenticated user can access the file with its fileId.\n\n##### Returns\n\n- **Observable** - default angular 2 HTTP observable of type Response.\n\n##### Usage\n\n```javascript\n\nconstructor(private sb: SelfbitsAngular) {\n\n    let f = new File([\"plain text file content\"], \"filename.txt\")\n    let params = {\n      file: f,\n      filePath: 'myFile.txt'\n    }\n\n    this.sb.file.upload(params).subscribe(\n      res =\u003e {\n        if (res.status === 200){\n          // do something with file metadata response\n        }\n        else{\n          // Handle errors here, such as displaying a notification\n        }\n      }\n    );\n}\n```\n\n### SelfbitsAngular: user\n\n#### user.current()\n\n##### Returns\n\n- **Observable** - default angular 2 HTTP observable of type Response.\n\n##### Usage\n\n```javascript\n\nconstructor(private sb: SelfbitsAngular) {\n\n    this.sb.user.current().subscribe(\n      res =\u003e {\n        if (res.status === 200){\n          // do something with the data\n        }\n        else{\n          // Handle errors here, such as displaying a notification\n        }\n      }\n    );\n}\n```\n\n### SelfbitsAngular: device\n\n#### device.sync()\n\nIf an user is authenticeted this function will post user's mobile device informations to selfbits.\n\n##### Returns\n\n- **Observable** - default angular 2 HTTP observable of type Response.\n\n##### Usage\n\n```javascript\nconstructor(private sb: SelfbitsAngular) {\n\n    this.sb.device.sync().subscribe(\n      res =\u003e {\n        if (res.status === 200){\n          // do something with the data\n        }\n        else{\n          // Handle errors here, such as displaying a notification\n        }\n      }\n    );\n}\n```\n\n## License\n\nCopyright (c) 2016 Selfbits GmbH\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":["Uncategorized","Awesome Angular [![Awesome TipeIO](https://img.shields.io/badge/Awesome%20Angular-@TipeIO-6C6AE7.svg)](https://github.com/gdi2290/awesome-angular) [![Awesome devarchy.com](https://img.shields.io/badge/Awesome%20Angular-@devarchy.com-86BDC1.svg)](https://github.com/brillout/awesome-angular-components)"],"sub_categories":["Uncategorized","Angular \u003ca id=\"angular\"\u003e\u003c/a\u003e"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselfbits%2Fselfbits-angular2-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fselfbits%2Fselfbits-angular2-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselfbits%2Fselfbits-angular2-sdk/lists"}