Git Product home page Git Product logo

angular-safeguard's Introduction

Greetings from Vancouver! 🌲

🔍 Transitioned from large JavaScript applications to high scale distributed Elixir.
🛠 Architecting applications, ensuring they're scalable, testable and maintainable.
🌐 Founder of Learn Elixir, guiding developers on their Elixir voyage.
🤝 Passionate about AI, data and building tools to enable developers
🌱 Always evolving, always learning.
🚀 Beyond coding: Mentorship, community building, and tech evangelism.


Mika's GitHub stats

Looking to learn how to level up your elixir skills? Checkout https://learn-elixir.dev where I help speed up the journey to mastery

angular-safeguard's People

Contributors

dependabot[bot] avatar keithdmoore avatar mikaak avatar robscotts4rb avatar rpdasilva avatar vuongn avatar wittbulter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-safeguard's Issues

Support of new version angular and angular-cli

@MikaAK I'm using yours plugin version 1.0.0
I have angular-cli application ("angular-cli": "1.0.0-beta.26", "@angular/core": "^2.4.5") and when I try to compile app with ng serve I see an error below:

ERROR in Error encountered resolving symbol values statically. Calling function 'LockerModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in ./src/app/app.module.ts, resolving symbol AppModule ./src/app/app.module.ts

Looks that it happens because plugin doesn't support AoT compilation and doesn't create metadata.json file.

Could you fix it, please?

Rollup pluggin compatible

Hello,

Thanks for component, very helpful, and congratulations on the last update (1.0.0).

I installed the "rollup" component (https://github.com/rollup/rollup)
I do not know if I did everything right, but I do not think it's compatible with your plugin.
It displays this error message.

Rollup failed: 'Locker' is not exported by node_modules / angular-safeguard / dist / locker.js (imported by
             Src / providers / client.service.ts). For help fixing this error see
             Https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module

To configure the component follow these steps:

Https://www.bountysource.com/issues/36339429-feature-request-ionic-2-dev-prod-environment-variables-configuration

Are you able to adapt your component so that it is compatible? Can I wait for this?

Thank you

Allow Angular4

Since Angular 4 didn't break anything in this library can the package.json be tweaked so it can allow Angular4?

systemjs.config mapping

I've ran into an issue here and I'm not really sure how to solve it. I'm new to Angular 2 so that's probably the problem but there is no index.js and if I try to map it to dist/locker.js I just get a 404. Can anyone tell me what should be here?

  var map = {
    'app':                        'js', // 'dist',
    '@angular':                   'node_modules/@angular',
    'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
    'rxjs':                       'node_modules/rxjs',
    'angular2-locker':            'node_modules/angular2-locker'
  };
  // packages tells the System loader how to load when no filename and/or no extension
  var packages = {
    'app':                        { main: 'main.js',  defaultExtension: 'js' },
    'rxjs':                       { defaultExtension: 'js' },
    'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
    'angular2-locker': { main: 'dist/locker.js', defaultExtension: 'js' }    
  };

No exported member 'LockerModule'.

I think something is wrong with your documentation or your exports because i get an error stating:
**/node_modules/angular2-locker/index"' has no exported member 'LockerModule'.

Create `dist` directory in master branch

It's useful to install the latest source with github commit ID like the following:

{
  ...
  "dependencies": {
    ...
    "angular-safeguard": "https://github.com/MikaAK/angular-safeguard.git#4a3d9f0",
    ...
  }
}

I'd like to use the latest source because it supports AoT.

Path is not set for cookie storage

In current implementation the path isn't specified, this causes it to be figured out by browser. It is not compatible with HTML5 mode routing and PathLocationStrategy.

I had a weird bug where 'deleting cookies' recipe really helped at last. As it appeared, were two cookies with same namespaces and names, one for / path, another for /route path.

It is not possible to specify custom config for driver. I guess it may be set to base href by user, but it should be / by default.

Configure angular2-locker with karma, WARN: 404: /base/angular2-locker.js

I am getting a 404 error when running tests
image

I added the module path to the files array in karma.conf.js, but now I am getting different error

files: [
// Polyfills.
'node_modules/core-js/client/shim.min.js',

  // System.js for module loading
  'node_modules/systemjs/dist/system-polyfills.js',
  'node_modules/systemjs/dist/system.src.js',

  // Zone.js dependencies
  'node_modules/zone.js/dist/zone.js',
  'node_modules/zone.js/dist/jasmine-patch.js',
  'node_modules/zone.js/dist/async-test.js',
  'node_modules/zone.js/dist/fake-async-test.js',

  // RxJs.
  { pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
  { pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },

  // paths loaded via module imports
  // Angular itself
  { pattern: 'node_modules/@angular/**/*.js', included: false, watched: true },

  { pattern: 'dist/dev/**/*.js', included: false, watched: true },
  { pattern: 'dist/dev/**/*.html', included: false, watched: true, served: true },
  { pattern: 'dist/dev/**/*.css', included: false, watched: true, served: true },
  { pattern: 'node_modules/systemjs/dist/system-polyfills.js', included: false, watched: false }, // PhantomJS2 (and possibly others) might require it

  'node_modules/angular2-locker/dist/*.js',

  // suppress annoying 404 warnings for resources, images, etc.
  { pattern: 'dist/dev/assets/**/*', watched: false, included: false, served: true },

  'test-main.js'
],

image

Angular 16: Generic type 'ModuleWithProviders<T>' requires 1 type argument(s).

Compilation error:

Error: node_modules/angular-safeguard/dist/Locker.module.d.ts:4:51 - error TS2314: Generic type 'ModuleWithProviders<T>' requires 1 type argument(s).

4     static withConfig(userConfig: ILockerConfig): ModuleWithProviders;
$ ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 16.0.0
Node: 16.17.0
Package Manager: npm 8.15.0
OS: win32 x64

Angular: 16.0.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, google-maps, language-service, material
... material-date-fns-adapter, platform-browser
... platform-browser-dynamic, platform-server, router

Package                                    Version
--------------------------------------------------------------------
@angular-devkit/architect                  0.1600.0
@angular-devkit/build-angular              16.0.0
@angular-devkit/core                       16.0.0
@angular-devkit/schematics                 16.0.0
@nguniversal/builders                      16.0.0
@nguniversal/common                        16.0.0
@nguniversal/express-engine                16.0.0
@nguniversal/module-map-ngfactory-loader   v8.2.6
@schematics/angular                        16.0.0
rxjs                                       7.8.1
typescript                                 5.0.4

Incorrect docs for released version of Angular 2?

To get Locker working with the actual released version of Angular 2 my App Module had to look like this:

@NgModule({
    imports: [
        BrowserModule,
        LockerModule,
    ],
    providers: [
        Locker,
    ],
    declarations: [
        TestComponent,
    ],
})

This is different to what is shown in the docs, so the docs may need updating

ERROR in LockerModule is not an NgModule

First of all, thanks for making this amazing component! I love using it.

There's one problem I'm getting though. I'm using this component in a project created with Angular CLI and when I use ng serve to start up the dev server. I get the following error:

ERROR in LockerModule is not an NgModule
webpack: Failed to compile.

The output of my ng --version command:

  __ _  _ __    __ _  _   _ | |  __ _  _ __         ___ | |(_)
 / _` || '_ \  / _` || | | || | / _` || '__|_____  / __|| || |
| (_| || | | || (_| || |_| || || (_| || |  |_____|| (__ | || |
 \__,_||_| |_| \__, | \__,_||_| \__,_||_|          \___||_||_|
               |___/
@angular/cli: 1.0.0-beta.32.3 [1.0.0-beta.25.5]
node: 6.9.4
os: darwin x64
@angular/common: 2.4.8
@angular/compiler: 2.4.8
@angular/core: 2.4.8
@angular/forms: 2.4.8
@angular/http: 2.4.8
@angular/platform-browser: 2.4.8
@angular/platform-browser-dynamic: 2.4.8
@angular/router: 3.4.8
@angular/cli: 1.0.0-beta.32.3
@angular/compiler-cli: 2.4.8

I'm not sure what I'm doing wrong, I've tried re-installing the package but that didn't help either. As I'm not seeing anybody else with this issue on here I think I must be doing something wrong..

Anybody have an idea? Thanks!

ngc aot build fail

When I'm trying to transpile my ionic 2 app which uses ngc, I encounter this error:
Error: Unexpected value 'LockerModule' imported by the module 'AppModule'

This is the problematic code:

// Some angular and ionic related imports above...
import {LockerModule, Locker, LockerConfig} from 'angular2-locker';
let components = [MyPage];

@NgModule({
	declarations: components,
	imports: [
		IonicModule.forRoot(MyApp, {
			mode: 'ios'
		}),
		LockerModule
	],
	bootstrap: [IonicApp],
	entryComponents: components,
	providers: [Settings, {provide: ErrorHandler, useClass: IonicErrorHandler}]
})

export class AppModule {
	constructor (protected locker: Locker){}
}

How can I fix this issue? I can't find any helpful information by googling.

Cannot use this to build Ionic2 APP

I create an Ionic2 APP, and import this into it.

Then I tried to build the APP for android platform, it will show error when building

[23:22:20] Error: Error encountered resolving symbol values statically. Function calls are not supported. Consider
replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in
/Users/abc/code/ionic2/�test/.tmp/app/app.module.ts, resolving symbol AppModule in
/Users/abc/code/ionic2/test/.tmp/app/app.module.ts
[23:22:20] ngc failed
[23:22:20] ionic-app-script task: "build"
[23:22:20] Error: Error

The new setNamespace does not use configured separator on consequent calls

After configuring the Locker instance one should not have to constantly pass the namespace separator while trying to change the namespace with Locker.setNamespace or else it doesn't really makes sense to configure the separator in first place.

I am sure that one will need to change the namespace much more often than change the separator (if ever).

https://github.com/MikaAK/angular2-locker/blob/master/src/Locker.ts#L43

I think that this

constructor(lockerConfig: LockerConfig) {
    const {driverNamespace, defaultDriverType, namespaceSeparator} = lockerConfig

    this.setNamespace(driverNamespace, namespaceSeparator)
    this.driver = defaultDriverType.isSupported() ? defaultDriverType : DRIVERS.MEMORY
  }
...
public setNamespace(namespace, separator) {
    this.namespace = namespace
    this.separator = separator
  }

Should become something like this

constructor(protected lockerConfig: LockerConfig) {
    this.setNamespace(this.lockerConfig.driverNamespace, this.lockerConfig.namespaceSeparator)
    this.driver = this.lockerConfig.defaultDriverType.isSupported() ? this.lockerConfig.defaultDriverType : DRIVERS.MEMORY
  }
...
public setNamespace(namespace, separator?) {
    this.namespace = namespace
    this.separator = separator ? separator : this.lockerConfig.namespaceSeparator
  }

Support for Angular 5

Issue
Angular 5 dropped deprecated OpaqueToken. OpaqueToken was replaced by InjectionToken.

Can you please update the lib to support Angular 5?

Version 2 ?

In the doc, it says version 2.0. referring to angular version or plugin version ?

Error encountered resolving symbol values statically. Function calls are not supported.

Hi,
I'm getting this error:

Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule

this are my dependencies:

 "dependencies": {
        "@angular/common": "2.2.3",
        "@angular/compiler": "2.2.3",
        "@angular/core": "2.2.3",
        "@angular/forms": "2.2.3",
        "@angular/http": "2.2.3",
        "@angular/platform-browser": "2.2.3",
        "@angular/platform-browser-dynamic": "2.2.3",
        "@angular/router": "3.2.3",
        "angular2-locker": "^0.5.0",
        "bootstrap-sass": "^3.3.7",
        "core-js": "^2.4.1",
        "firebase": "^3.5.3",
        "lodash": "^4.16.6",
        "ng2-bootstrap": "^1.1.16",
        "rxjs": "5.0.0-beta.12",
        "ts-helpers": "^1.1.1",
        "zone.js": "^0.6.23"
    },
    "devDependencies": {
        "@types/jasmine": "2.5.38",
        "@types/lodash": "^4.14.38",
        "@types/node": "^6.0.42",
        "@angular/compiler-cli": "2.2.3",
        "angular-cli": "1.0.0-beta.22-1",
        "codelyzer": "~2.0.0-beta.1",
        "jasmine-core": "2.5.2",
        "jasmine-spec-reporter": "2.5.0",
        "karma": "1.2.0",
        "karma-chrome-launcher": "^2.0.0",
        "karma-cli": "^1.0.1",
        "karma-jasmine": "^1.0.2",
        "karma-remap-istanbul": "^0.2.1",
        "protractor": "4.0.9",
        "ts-node": "1.2.1",
        "tslint": "^4.0.2",
        "typescript": "~2.0.3",
        "webdriver-manager": "10.2.5"
    }

Any idea how to fix it?

ERROR in LockerModule is not an NgModule (with angular-cli)

app.module.ts

import { NgModule } from '@angular/core';
import {LockerModule} from 'angular-safeguard';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,

    LockerModule // import
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

and error happens

ERROR in LockerModule is not an NgModule

How can I use this library with angular-cli project ?
Could you please show me the instruction ?

thanks

Memory Storage ts error

src/js/storage/MemoryStorage.ts(8,19): error TS2495: Type 'Iterator<{}>' is not an array type or a string type.

Looks like this is culprit.

for (let key of _cache.keys())

2.0.0-beta.17

Compatibility with angular-locker when using hybrid app

The previous version that was called angular2-locker worked great with angular-locker as you could configure the settings to store things under the same namespace.

Now with the change to store things as { data: myObj } we can no longer read things stored using angular-locker because they aren't in the expected format.

It would be nice if angular-safeguard can read properties that are stored as simple values (strings, numbers, etc) and the new advanced format.

Happy to provide a pull request if needs be

Bug in getting FALSE value

Problem description:

  • Use PolyfillDriver
  • Save value: this.storage.set(DRIVERS.SESSION, 'foobar', false);
  • Get value: const result = this.storage.get(DRIVERS.SESSION, 'foobar');

Expectation

  • the value result equals false

Actual behaviour

  • the value result equals { data: false }

Analysis

Possible solution

  • maybe it would be better to use if (data && data.hasOwnProperty('data'))

Angular 9 production build errors for type without a generic type argument

  1. Add LockerModule to AppModel using withConfig
  2. Run ng serve - all good
  3. Run ng serve --prod getting error as follows:

ERROR in node_modules/angular-safeguard/dist/Locker.module.d.ts:4:51 - error NG6005: LockerModule.withConfig returns a ModuleWithProviders type without a generic type argument. Please add a generic type argument to the ModuleWithProviders type. If this occurrence is in library code you don't control, please contact the library authors.

4 static withConfig(userConfig: ILockerConfig): ModuleWithProviders;

ERROR in Error encountered resolving symbol values statically.

I get this when I try to use LockerModule.withConfig():

ERROR in Error encountered resolving symbol values statically. Calling function 'LockerModule',
function calls are not supported. Consider replacing the function or lambda with a reference to an
exported function, resolving symbol LocalStorage in ..../ng2-demo/src/app/app.local-storage.ts,
resolving symbol AppModule in ..../ng2-demo/src/app/app.module.ts, resolving symbol AppModule
in ..../ng2-demo/src/app/app.module.ts
webpack: Failed to compile.

The problem doesn't appear if I try to use LockerModule without calling withConfig().

Name change to angular-safeguard

angular2-locker -> angular-safeguard

I just wanted to post an issue regarding the changing the name of this library. It is officially unadvised to use angular2 in the name of packages and when it moves to angular3/4 it will become confusing. As angular-locker is already existing and for angular1 I have decided to rename to angular-safeguard!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.