{"_id":"interstellar-core","_rev":"32-e713301047efddbfccc13b1d1e034bc9","name":"interstellar-core","dist-tags":{"latest":"0.0.4"},"versions":{"0.0.1":{"name":"interstellar-core","version":"0.0.1","keywords":["stellar","interstellar"],"author":{"name":"Stellar Development Foundation","email":"stellar@stellar.org"},"license":"Apache-2.0","_id":"interstellar-core@0.0.1","maintainers":[{"name":"stellar","email":"npm@stellar.org"}],"homepage":"https://github.com/stellar/interstellar-core","bugs":{"url":"https://github.com/stellar/interstellar-core/issues"},"dist":{"shasum":"5c95ef2920c44cdaa7468d9bb757f5af528c5748","tarball":"https://registry.npmjs.org/interstellar-core/-/interstellar-core-0.0.1.tgz","integrity":"sha512-WRW/4x7ynnyTUn7sht90b42yD33GBO8GEXXIbgWk+Kdu0RfUj+7CXeQkU/7W4TGG6B6tACiBx+vdV8HHHL9wEg==","signatures":[{"sig":"MEQCIGsaoqjQu8dzi3J+GZ6Ys7/8nBTbhDLdriKvkkhKLE+CAiB7BQgi+2DAf5Q9PYDusm0wDr8ORGwn/yqboJVHhihMQQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"_from":".","_shasum":"5c95ef2920c44cdaa7468d9bb757f5af528c5748","gitHead":"7fcf81a0a37c5a1bd18b97a0492f881ab30580a5","scripts":{"test":"gulp test"},"_npmUser":{"name":"stellar","email":"npm@stellar.org"},"repository":{"url":"http://github.com/stellar/interstellar-core.git","type":"git"},"_npmVersion":"2.1.9","description":"The core modules provides the lowest level functionality within the Interstellar Module System.","directories":{},"_nodeVersion":"0.10.33","dependencies":{"solar":"git+https://github.com/stellar/solar#master","lodash":"^2.4.1","angular":"^1.3.5","dot-object":"^0.11.0","angular-mocks":"^1.3.8","solar-stellarorg":"git+https://github.com/stellar/solar-stellarorg#master","angular-ui-router":"^0.2.13"}},"0.0.2":{"name":"interstellar-core","version":"0.0.2","keywords":["stellar","interstellar"],"author":{"name":"Stellar Development Foundation","email":"stellar@stellar.org"},"license":"Apache-2.0","_id":"interstellar-core@0.0.2","maintainers":[{"name":"stellar","email":"npm@stellar.org"}],"homepage":"https://github.com/stellar/interstellar-core","bugs":{"url":"https://github.com/stellar/interstellar-core/issues"},"dist":{"shasum":"f1f3a6f6cdeea4500654bf023d0bc5499c12ee89","tarball":"https://registry.npmjs.org/interstellar-core/-/interstellar-core-0.0.2.tgz","integrity":"sha512-l03wpmTYpND3b/7+NPo7TnHJHAmdrpRy5uO4NyvxbBQureGnsxKtFCoFMW1RVahmAf1ShSYm8jR/QSRXS5VBeQ==","signatures":[{"sig":"MEYCIQC4duArI1/+ifGLvGiqzEIJmgpOLJy3Kp6Wu2PxpTgXIwIhANgd2LKFHAW7cYyXMe6uyg4vuMRNe+u9695X+UBBjlW0","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"_from":".","_shasum":"f1f3a6f6cdeea4500654bf023d0bc5499c12ee89","gitHead":"0419774cd4fa443a3dbcdb7fa4983e2163c91304","scripts":{"test":"gulp test"},"_npmUser":{"name":"stellar","email":"npm@stellar.org"},"repository":{"url":"http://github.com/stellar/interstellar-core.git","type":"git"},"_npmVersion":"2.1.9","description":"The core modules provides the lowest level functionality within the Interstellar Module System.","directories":{},"_nodeVersion":"0.10.33","dependencies":{"lodash":"^2.4.1","angular":"^1.3.5","solar-css":"git+https://github.com/stellar/solar#master","dot-object":"^0.11.0","angular-mocks":"^1.3.8","solar-stellarorg":"git+https://github.com/stellar/solar-stellarorg#master","angular-ui-router":"^0.2.13"}},"0.0.3":{"name":"interstellar-core","version":"0.0.3","keywords":["stellar","interstellar"],"author":{"name":"Stellar Development Foundation","email":"stellar@stellar.org"},"license":"Apache-2.0","_id":"interstellar-core@0.0.3","maintainers":[{"name":"stellar","email":"npm@stellar.org"}],"homepage":"https://github.com/stellar/interstellar-core","bugs":{"url":"https://github.com/stellar/interstellar-core/issues"},"dist":{"shasum":"fad684aa139ce40a1dd610f4b8036388e8501682","tarball":"https://registry.npmjs.org/interstellar-core/-/interstellar-core-0.0.3.tgz","integrity":"sha512-aAA7aiKF+T5vugYayTa9wEhubpdsOCc0ziCcIE/ZEWY+615BPjE/bBzMzq4srnRzAIlrlZImrnWlcT79EtUSbw==","signatures":[{"sig":"MEUCIGselVg0gsxcaygQsHKga34xvzScFSOThv7QnK33YyXaAiEAqbxIbnzfXblTO+l7TLCNG0AYjNJ5h+MdKHwtgI7iyyI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"_from":".","_shasum":"fad684aa139ce40a1dd610f4b8036388e8501682","gitHead":"8aaea06cf255ab1a1c3c1363a67036d3ab69e8ab","scripts":{"test":"gulp test"},"_npmUser":{"name":"stellar","email":"npm@stellar.org"},"repository":{"url":"http://github.com/stellar/interstellar-core.git","type":"git"},"_npmVersion":"2.1.9","description":"The core modules provides the lowest level functionality within the Interstellar Module System.","directories":{},"_nodeVersion":"0.10.33","dependencies":{"lodash":"^2.4.1","angular":"^1.3.5","solar-css":"git+https://github.com/stellar/solar#master","dot-object":"^0.11.0","angular-mocks":"^1.3.8","solar-stellarorg":"git+https://github.com/stellar/solar-stellarorg#master","angular-ui-router":"^0.2.13"}},"0.0.4":{"name":"interstellar-core","version":"0.0.4","keywords":["stellar","interstellar"],"author":{"name":"Stellar Development Foundation","email":"stellar@stellar.org"},"license":"Apache-2.0","_id":"interstellar-core@0.0.4","maintainers":[{"name":"stellar","email":"npm@stellar.org"}],"homepage":"https://github.com/stellar/interstellar-core#readme","bugs":{"url":"https://github.com/stellar/interstellar-core/issues"},"dist":{"shasum":"cf619d0b69a6ade18a6fdee52a85582d558698a6","tarball":"https://registry.npmjs.org/interstellar-core/-/interstellar-core-0.0.4.tgz","integrity":"sha512-I9FHTl5yUIynxrLTZK4+wA3rVKgR2RuTnyafpyigngiw/c3NfCRpJ3x88+gz9Vh/5C0DNZlrK9YCKQlTUN61rg==","signatures":[{"sig":"MEYCIQDTUVxwoDsHxCkyxRBB5xQ/Qn1/GzmAaoyK9jRflzWtWAIhAPauB4/2pF/eY3Fm4I7HCRoDcX0b6zdB4QFnRb+oaneu","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"_from":".","_shasum":"cf619d0b69a6ade18a6fdee52a85582d558698a6","gitHead":"d9311384f8e0204722d06d7cc3207c6de341e22d","scripts":{"test":"gulp test"},"_npmUser":{"name":"stellar","email":"npm@stellar.org"},"repository":{"url":"git+ssh://git@github.com/stellar/interstellar-core.git","type":"git"},"_npmVersion":"2.13.0","description":"The core modules provides the lowest level functionality within the Interstellar Module System.","directories":{},"_nodeVersion":"0.10.33","dependencies":{"lodash":"^2.4.1","angular":"^1.3.5","solar-css":"git+https://github.com/stellar/solar.git#master","dot-object":"^0.11.0","angular-mocks":"^1.3.8","solar-stellarorg":"git+https://github.com/stellar/solar-stellarorg.git#master","angular-ui-router":"^0.2.13"}}},"time":{"created":"2015-06-08T17:18:17.973Z","modified":"2025-10-16T12:49:15.991Z","0.0.1":"2015-06-08T17:18:17.973Z","0.0.2":"2015-06-08T18:08:30.231Z","0.0.3":"2015-07-23T12:47:56.807Z","0.0.4":"2015-10-12T18:53:04.794Z"},"bugs":{"url":"https://github.com/stellar/interstellar-core/issues"},"author":{"name":"Stellar Development Foundation","email":"stellar@stellar.org"},"license":"Apache-2.0","homepage":"https://github.com/stellar/interstellar-core#readme","keywords":["stellar","interstellar"],"repository":{"url":"git+ssh://git@github.com/stellar/interstellar-core.git","type":"git"},"description":"The core modules provides the lowest level functionality within the Interstellar Module System.","maintainers":[{"email":"ops+stellar-npm-ci@stellar.org","name":"stellar-npm-ci"},{"email":"npm@stellar.org","name":"stellar-npm"},{"email":"iveta@stellar.org","name":"quietbits"},{"email":"account@nykis.net","name":"jacekn"},{"email":"nando@stellar.org","name":"fnando_sdf"},{"email":"cassio@stellar.org","name":"cassiomg"},{"email":"pbasu235@gmail.com","name":"piyalbasu"}],"readme":"`interstellar-core`\n=============\n\nThe `interstellar-core` module is part of the [Interstellar Module System](https://github.com/stellar/interstellar).\n\nIt provides the lowest level functionality: a core JS wrapper. \n\n> Quick start to developing in the Interstellar eco-system:\n>\n> * Read [`Getting started`](https://github.com/stellar/interstellar/tree/master/docs) doc.\n> * Install [`interstellar-workspace`](https://github.com/stellar/interstellar-workspace).\n> * Contribute to our [open-source modules](https://github.com/stellar/interstellar/blob/master/docs/module-list.md) or develop your own.\n\n## Module contents\n\n#### Classes\n* [`Module`](#module-class)\n* [`App`](#app-class)\n* [`Inject` annotation](#inject-annotation)\n* [`Controller` annotation](#controller-annotation)\n* [`Provider` annotation](#provider-annotation)\n* [`Service` annotation](#service-annotation)\n* [`Widget` annotation](#widget-annotation)\n* [`Intent`](#intent-class)\n\n#### Services\n* [`interstellar-core.IntentBroadcast`](#interstellar-coreintentbroadcast-service)\n* [`interstellar-core.Config`](#interstellar-coreconfig-service)\n\n#### Widgets\nNone.\n\n#### Others\n* [`solar`](https://github.com/stellar/solar)\n* [`solar-stellarorg`](https://github.com/stellar/solar-stellarorg)\n\n## `Module` class\n\nModule is a wrapper around [Angular.js module](https://docs.angularjs.org/guide/module). Every Interstellar module is a `Module` object and Angular.js module. `Module` provides several methods to help configure a module. It also provides autoloading support for controllers, templates, services, directives and other components.\n\n```js\nimport {Module} from \"interstellar-core\";\n\nexport const mod = new Module('interstellar-example');\nmod.use(interstellarSomeModule.name);\n\nmod.controllers = require.context(\"./controllers\", true);\nmod.directives  = require.context(\"./directives\", true);\nmod.services    = require.context(\"./services\", true);\nmod.templates   = require.context(\"raw!./templates\", true)\n\nmod.define();\n```\n\n## `App` class\n\n`App` class extends `Module` class and provides helper methods for the final Interstellar application that use other modules. It provides additional functionality like `ui-router`. The second parameter in a constructor is [a configuration JSON](#interstellar-coreconfig-service).\n\n```js\nimport {App, mod as interstellarCore} from \"interstellar-core\";\nimport {mod as interstellarStellarWallet} from \"interstellar-stellar-wallet\";\nimport {mod as interstellarNetwork} from \"interstellar-network\";\nimport {mod as interstellarSettings} from \"interstellar-settings\";\nimport {mod as interstellarStellarApi} from \"interstellar-stellar-api\";\n\nlet config = require('./config.json');\nexport const app = new App(\"interstellar-stellar-client\", config);\n\napp.use(interstellarCore.name);\napp.use(interstellarStellarWallet.name);\napp.use(interstellarNetwork.name);\napp.use(interstellarSettings.name);\napp.use(interstellarStellarApi.name);\n\napp.templates   = require.context(\"raw!./templates\", true);\napp.controllers = require.context(\"./controllers\",   true);\n\napp.routes = ($stateProvider) => {\n  $stateProvider.state('login', {\n    url: \"/login\",\n    templateUrl: \"interstellar-stellar-client/login\"\n  });\n  $stateProvider.state('dashboard', {\n    url: \"/dashboard\",\n    templateUrl: \"interstellar-stellar-client/dashboard\",\n    requireSession: true\n  });\n  // ...\n};\n\n// Callbacks to execute in `config` block.\napp.config(configureServices);\n\n// Callbacks to execute in `run` block.\napp.run(registerBroadcastReceivers);\n\napp.bootstrap();\n```\n\n## `Inject` annotation\n\n[Decorator](https://github.com/wycats/javascript-decorators) class to inject dependencies to your controllers or services using AngularJS injector subsystem:\n\n```js\nimport {Inject} from 'interstellar-core';\n\n@Inject(\"interstellar-sessions.Sessions\", \"interstellar-network.Server\")\nclass ReceiveWidgetController {\n  constructor(Sessions, Server) {\n    this.Server = Server;\n    this.Sessions = Sessions;\n  }\n}\n```\n\n## `Controller` annotation\n\n[Decorator](https://github.com/wycats/javascript-decorators) class to annotate your controllers.\n\n```js\nimport {Controller, Inject} from 'interstellar-core';\n\n@Controller(\"HeaderController\")\n@Inject(\"interstellar-sessions.Sessions\", \"interstellar-network.Server\")\nexport default class HeaderController {\n  constructor(Sessions, Server) {\n    this.Server = Server;\n    this.Sessions = Sessions;\n  }\n  // ...\n}\n```\n\n> **Heads up!** Annotated class _must_ be exported as `default`.\n\n## `Provider` annotation\n\n[Decorator](https://github.com/wycats/javascript-decorators) class to annotate your providers.\n\n```js\nimport {Provider} from 'interstellar-core';\n\n@Provider(\"Config\")\nexport default class ConfigProvider {\n  constructor() {\n    this.appConfig = {};\n    this.modulesConfig = {};\n  }\n  // ...\n}\n```\n\n> **Heads up!** Annotated class _must_ be exported as `default`.\n\n## `Service` annotation\n\n[Decorator](https://github.com/wycats/javascript-decorators) class to annotate your services.\n\n```js\nimport {Service} from 'interstellar-core';\n\n@Service('IntentBroadcast')\nexport default class IntentBroadcastService {\n  constructor() {\n    this.receivers = {};\n  }\n  // ...\n}\n```\n\n> **Heads up!** Annotated class _must_ be exported as `default`.\n\n## `Widget` annotation\n\n[Decorator](https://github.com/wycats/javascript-decorators) class to annotate your widgets' controllers.\n\nThis annotation requires 3 arguments:\n* directive name,\n* controller name,\n* template name.\n\n```js\nimport {Widget, Inject} from 'interstellar-core';\n\n@Widget(\"balance\", \"BalanceWidgetController\", \"interstellar-network-widgets/balance-widget\")\n@Inject(\"$scope\", \"interstellar-sessions.Sessions\", \"interstellar-network.AccountObservable\", \"interstellar-network.Server\")\nexport default class BalanceWidgetController {\n  constructor($scope, Sessions, AccountObservable, Server) {\n    if (!Sessions.hasDefault()) {\n      console.error('No session. This widget should be used with active session.');\n      return;\n    }\n    // ...\n  }\n  // ...\n}\n```\n\n> **Heads up!** Annotated class _must_ be exported as `default`.\n\n## `Intent` class\n\nModules in Interstellar communicate by broadcasting `Intent` objects using [Android-inspired](http://developer.android.com/guide/components/intents-filters.html) intent system. Modules can:\n* **Broadcast Intents** to trigger some events in other modules,\n* **Register Broadcast Receivers** to listen to Intents sent by other modules.\n\nEvery Intent has a type which must be one of standard intent types:\n* `SEND_TRANSACTION` - User wants to send a transaction.\n* `SHOW_DASHBOARD` - User wants to see a dashboard.\n* `LOGOUT` - User wants to logout.\n\n`Intent` can also contain additional data helpful for a Broadcast Receiver. For example, `SEND_TRANSACTION` Intent can contain destination address.\n\n```js\n// Sending Broadcast\nIntentBroadcast.sendBroadcast(\n  new Intent(\n    Intent.TYPES.SEND_TRANSACTION,\n    {destination: this.destination}\n  )\n);\n// Receiving Broadcast\nIntentBroadcast.registerReceiver(Intent.TYPES.SEND_TRANSACTION, intent => {\n  widget.set('destinationAddress', intent.data.destination);\n});\n```\n\n## `interstellar-core.IntentBroadcast` service\n\n`interstellar-core.IntentBroadcast` service is responsible for delivering `Intent`s to correct Broadcast Receivers. It has two methods:\n* `sendBroadcast(intent)` - to broadcast an `Intent`,\n* `registerReceiver(type, broadcastReceiver)` - to register Broadcast Receiver of specific type.\n\n## `interstellar-core.Config` service\n\nThe Config service provides the system through which the client can retrieve configuration flags. It provides a `get(configName)` to which clients can retrieve values.\n\nConceptually, an application's configuration presents itself as a simple nested json object.\n\n### Defining configuration values\n\n`interstellar-core.Config` provider has 2 methods that `App` and `Module`s can use to define configuration values:\n* `addAppConfig(config)` - used by [`App`](#app-class)\n* `addModuleConfig(moduleName, config)` - used by [`Module`](#module-class)s\n\nAll config values added by modules are treated as default values that can be overwritten by the `App` config. For example, let's say [`interstellar-network`](https://github.com/stellar/interstellar-network) module adds following config JSON using `addModuleConfig`:\n```json\n{\n  \"horizon\": {\n    \"secure\": true,\n    \"hostname\": \"horizon-testnet.stellar.org\",\n    \"port\": 443\n  }\n}\n```\nTo overwrite this module's configuration, an app needs to add following config JSON using `addAppConfig`:\n```json\n{\n  \"modules\": {\n    \"interstellar-network\": {\n      \"horizon\": {\n        \"secure\": false,\n        \"hostname\": \"horizon.example.com\",\n        \"port\": 80\n      }\n    }\n  }\n}\n```\n\n### Retrieving values (using `get`)\n\nOnce you have an instance of the config service (using normal angular DI mechanisms), you may access any previously loaded configuration using a \"dot separated\" accessor string. For example, say the [`App`](#app-class) configuration data is the json object below:\n\n```json\n{\n  \"horizon\": {\n    \"secure\": true,\n    \"hostname\": \"horizon-testnet.stellar.org\",\n    \"port\": 443\n  }\n}\n```\n\nYou can retrieve the address for the horizon with:\n```js\nlet hostname = Config.get(\"horizon.hostname\");\n```\n\nGetting configuration values in [`Module`](#module-class) is a little different. During configuration phase all modules' configurations are appended to `modules` object in the main config JSON. For example, let's say [`interstellar-network`](https://github.com/stellar/interstellar-network) module adds following configuration:\n```json\n{\n  \"horizon\": {\n    \"secure\": true,\n    \"hostname\": \"horizon-testnet.stellar.org\",\n    \"port\": 443\n  }\n}\n```\n\nNow, you can retrieve the address for the horizon with:\n```js\nlet hostname = Config.get(\"modules.interstellar-network.horizon.hostname\");\n```\n\n### Typed accessors (`getString`, `getArray`, `getObject`, `getNumber`, `getBoolean`)\n\nIn the spirit of failing fast, consumers of the config service can apply type restrictions to config variables, such that an exception will be thrown at the point of retrieval if the result is of the wrong type.  For example, given a config object of `{\"foo\": \"bar\"}`, executing the statement `Config.getNumber(\"foo\")` will throw an exception because the result (\"bar\") is a string.\n\n","readmeFilename":"README.md"}