
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
angular-stored-object
Advanced tools
Local resource support for Angular using HTML5 storage
Combines the best of ngResource, ngStorage and angular-local-storage to give you access to local and session storage within Angular, but also provides a storage strategy that supports sharing sessionStorage data between multiple tabs via transient localStorage use.
Using NPM:
npm install --save angular-stored-object
Using Bower:
bower install --save angular-stored-object
The small API is fully documented.
A session service consists of an object that when stored will be identified via the prefixed key 'session':
angular
.module('auth', ['yaacovCR.storedObject']);
angular
.module('auth')
.factory('session', session);
function session(ycr$StoredObject) {
return new ycr$StoredObject('session');
}
An auth service manipulates the properties of the session object and calls $create and $delete as needed to persist to/delete from storage. $update, not shown, can be used when the token needs to be refreshed.
angular
.module('glass.auth')
.factory('auth', auth);
function auth($http, $state, backendURI, session) {
var _redirectToState = null;
var _redirectToParams = null;
return {
login: login,
isLoggedIn: isLoggedIn,
logout: logout,
registerRedirect: registerRedirect,
followRedirect: followRedirect
};
function login(credentials) {
return $http.post(backendURI + '/login', { credentials: credentials }).then(function(result) {
session.token = result.data.token;
session.loggedInUser = result.data.user;
session.$create('sessionStorageWithMultiTabSupport');
});
}
function isLoggedIn() {
return !!session.token;
}
function logout() {
session.$delete();
$state.transitionTo('login');
}
function registerRedirect(toState, toParams) {
_redirectToState = toState;
_redirectToParams = toParams;
}
function followRedirect() {
if (_redirectToState) {
$state.transitionTo(_redirectToState, _redirectToParams);
_redirectToState = _redirectToParams = null;
} else {
$state.transitionTo('home');
}
}
For completion, the run block:
angular
.module('glass')
.run(runBlock);
function runBlock($rootScope, $state, $timeout, auth) {
$rootScope.$on('$stateChangeStart', onStateChangeStart);
$rootScope.$on('storedObject:session:externalChange', onSessionChange);
function onStateChangeStart(event, toState, toParams) {
if (toState.name === 'login' && auth.isLoggedIn()) {
event.preventDefault();
auth.followRedirect();
}
if (toState.data && toState.data.authenticate && !auth.isLoggedIn()) {
event.preventDefault();
auth.registerRedirect(toState, toParams);
$state.transitionTo('login');
}
}
function onSessionChange() {
$timeout(function() {
$state.reload();
});
}
}
And the routes:
angular
.module('glass')
.config(routerConfig);
function routerConfig($stateProvider, $urlRouterProvider) {
$stateProvider
.state('home', {
url: '/',
templateUrl: 'app/main/main.html',
controller: 'MainController',
controllerAs: 'main',
data: {
authenticate: true
}
})
.state("login", {
templateUrl: "app/components/login/login.route.html"
});
$urlRouterProvider.otherwise('/');
}
FAQs
Local resource support for Angular using HTML5 storage
The npm package angular-stored-object receives a total of 8 weekly downloads. As such, angular-stored-object popularity was classified as not popular.
We found that angular-stored-object demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.