Skip to content
This repository was archived by the owner on Dec 15, 2023. It is now read-only.

Commit 67298b2

Browse files
committed
use webpack
1 parent b4e0818 commit 67298b2

File tree

8 files changed

+198
-86
lines changed

8 files changed

+198
-86
lines changed

README.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
1-
# Auth0.js for Angular 1.x
1+
# Angular 1.x Wrapper for Auth0.js
22

33
This module provides a thin wrapper for [auth0.js](https://auth0.com/docs/libraries/auth0js).
44

5-
> Note: angular-auth0 v1 is to be used with auth0.js v7.
6-
7-
See the [sample project](https://github.com/auth0-samples/auth0-angularjs-sample/tree/master/02-Custom-Login) for further detail on how to use angular-auth0.
5+
> Note: This is the v2 branch which is for use with auth0.js v8. angular-auth0 v1 is to be used with auth0.js v7.
86
97
## Installation
108

11-
**Bower**
12-
139
```bash
14-
bower install angular-auth0
10+
# installation with npm
11+
npm install --save angular-auth0
12+
13+
# installation with yarn
14+
yarn add angular-auth0
15+
16+
# installation with bower
17+
bower install --save angular-auth0
1518
```
1619

1720
Ensure that both `auth0.js` and `angular-auth0.js` are loaded on the page.
1821

1922
```html
23+
<!-- installed with npm or yarn -->
24+
<script src="node_modules/auth0-js/build/auth0.js"></script>
25+
<script src="node_modules/angular-auth0/dist/angular-auth0.js"></script>
26+
```
27+
28+
```html
29+
<!-- installed with bower -->
2030
<script src="bower_components/auth0.js/build/auth0.js"></script>
21-
<script src="bower_components/angular-auth0/build/angular-auth0.js"></script>
31+
<script src="bower_components/angular-auth0/dist/angular-auth0.js"></script>
2232
```
2333

2434
## Usage
@@ -54,9 +64,9 @@ app.controller('loginController', function(angularAuth0) {
5464
```
5565

5666
```html
57-
<div ng-controller="loginController as login">
67+
<div ng-controller="loginController as vm">
5868

59-
<button ng-click="login.login(options)">Log In</button>
69+
<button ng-click="vm.login(options)">Log In</button>
6070

6171
</div>
6272
```

bower.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "angular-auth0",
3-
"main": "angular-auth0.js",
4-
"version": "2.0.0-beta.2",
3+
"main": "dist/angular-auth0.js",
4+
"version": "2.0.0-beta.3",
55
"dependencies": {
66
"angular": "*",
7-
"auth0.js": "^8.0.0"
7+
"auth0.js": "^8.8.0"
88
},
99
"resolutions": {
10-
"angular": "1.5.8"
10+
"angular": "1.6.0"
1111
}
1212
}

dist/angular-auth0.js

Lines changed: 118 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,119 @@
1-
(function() {
1+
/******/ (function(modules) { // webpackBootstrap
2+
/******/ // The module cache
3+
/******/ var installedModules = {};
4+
/******/
5+
/******/ // The require function
6+
/******/ function __webpack_require__(moduleId) {
7+
/******/
8+
/******/ // Check if module is in cache
9+
/******/ if(installedModules[moduleId]) {
10+
/******/ return installedModules[moduleId].exports;
11+
/******/ }
12+
/******/ // Create a new module (and put it into the cache)
13+
/******/ var module = installedModules[moduleId] = {
14+
/******/ i: moduleId,
15+
/******/ l: false,
16+
/******/ exports: {}
17+
/******/ };
18+
/******/
19+
/******/ // Execute the module function
20+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21+
/******/
22+
/******/ // Flag the module as loaded
23+
/******/ module.l = true;
24+
/******/
25+
/******/ // Return the exports of the module
26+
/******/ return module.exports;
27+
/******/ }
28+
/******/
29+
/******/
30+
/******/ // expose the modules object (__webpack_modules__)
31+
/******/ __webpack_require__.m = modules;
32+
/******/
33+
/******/ // expose the module cache
34+
/******/ __webpack_require__.c = installedModules;
35+
/******/
36+
/******/ // define getter function for harmony exports
37+
/******/ __webpack_require__.d = function(exports, name, getter) {
38+
/******/ if(!__webpack_require__.o(exports, name)) {
39+
/******/ Object.defineProperty(exports, name, {
40+
/******/ configurable: false,
41+
/******/ enumerable: true,
42+
/******/ get: getter
43+
/******/ });
44+
/******/ }
45+
/******/ };
46+
/******/
47+
/******/ // getDefaultExport function for compatibility with non-harmony modules
48+
/******/ __webpack_require__.n = function(module) {
49+
/******/ var getter = module && module.__esModule ?
50+
/******/ function getDefault() { return module['default']; } :
51+
/******/ function getModuleExports() { return module; };
52+
/******/ __webpack_require__.d(getter, 'a', getter);
53+
/******/ return getter;
54+
/******/ };
55+
/******/
56+
/******/ // Object.prototype.hasOwnProperty.call
57+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
58+
/******/
59+
/******/ // __webpack_public_path__
60+
/******/ __webpack_require__.p = "";
61+
/******/
62+
/******/ // Load entry module and return exports
63+
/******/ return __webpack_require__(__webpack_require__.s = 0);
64+
/******/ })
65+
/************************************************************************/
66+
/******/ ([
67+
/* 0 */
68+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
269

3-
'use strict';
70+
"use strict";
71+
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
72+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular__ = __webpack_require__(1);
73+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_angular__);
74+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_auth0_js__ = __webpack_require__(2);
75+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_auth0_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_auth0_js__);
476

5-
angular
6-
.module('auth0.auth0', [])
7-
.provider('angularAuth0', angularAuth0);
877

9-
function angularAuth0() {
10-
if (!angular.isObject(auth0)) {
11-
throw new Error('Auth0 must be loaded.');
12-
}
1378

14-
this.init = function(config) {
15-
if (!config) {
16-
throw new Error('clientID and domain must be provided to auth0');
17-
}
18-
this.config = config;
19-
}
79+
if (typeof __WEBPACK_IMPORTED_MODULE_0_angular___default.a !== 'object') {
80+
throw new Error('Angular must be loaded.');
81+
}
82+
83+
if (!__WEBPACK_IMPORTED_MODULE_0_angular___default.a.isObject(__WEBPACK_IMPORTED_MODULE_1_auth0_js___default.a)) {
84+
throw new Error('Auth0 must be loaded.');
85+
}
2086

21-
this.$get = ["$rootScope", function($rootScope) {
87+
__WEBPACK_IMPORTED_MODULE_0_angular___default.a.module('auth0.auth0', []).provider('angularAuth0', angularAuth0);
2288

23-
var Auth0Js = new auth0.WebAuth(this.config);
89+
function angularAuth0() {
90+
this.init = function(config) {
91+
if (!config) {
92+
throw new Error('Client ID and Domain are required to initialize Auth0.js');
93+
}
94+
this.config = config;
95+
};
96+
97+
this.$get = [
98+
'$rootScope',
99+
function($rootScope) {
100+
var Auth0Js = new __WEBPACK_IMPORTED_MODULE_1_auth0_js___default.a.WebAuth(this.config);
24101
var webAuth = {};
25102
var functions = [];
103+
26104
for (var i in Auth0Js) {
27-
if (angular.isFunction(Auth0Js[i])) {
105+
if (__WEBPACK_IMPORTED_MODULE_0_angular___default.a.isFunction(Auth0Js[i])) {
28106
functions.push(i);
29107
}
30-
if (angular.isObject(Auth0Js[i])) {
108+
if (__WEBPACK_IMPORTED_MODULE_0_angular___default.a.isObject(Auth0Js[i])) {
31109
webAuth[i] = Auth0Js[i];
32110
}
33111
}
34112

35113
function wrapArguments(parameters) {
36114
var lastIndex = parameters.length - 1,
37115
func = parameters[lastIndex];
38-
if (angular.isFunction(func)) {
116+
if (__WEBPACK_IMPORTED_MODULE_0_angular___default.a.isFunction(func)) {
39117
parameters[lastIndex] = function() {
40118
var args = arguments;
41119
$rootScope.$evalAsync(function() {
@@ -54,7 +132,24 @@
54132
return customFunction;
55133
})(functions[i]);
56134
}
135+
57136
return webAuth;
58-
}];
59-
}
60-
})();
137+
}
138+
];
139+
}
140+
141+
142+
/***/ }),
143+
/* 1 */
144+
/***/ (function(module, exports) {
145+
146+
module.exports = angular;
147+
148+
/***/ }),
149+
/* 2 */
150+
/***/ (function(module, exports) {
151+
152+
module.exports = auth0;
153+
154+
/***/ })
155+
/******/ ]);

dist/angular-auth0.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

package.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
{
22
"name": "angular-auth0",
3-
"version": "2.0.0-beta.2",
3+
"version": "2.0.0-beta.3",
44
"description": "Auth0.js wrapper for Angular.js",
55
"main": "index.js",
6+
"scripts": {
7+
"build": "webpack",
8+
"build:watch": "webpack --progress --colors --watch"
9+
},
610
"repository": {
711
"type": "git",
812
"url": "git+https://github.com/auth0/angular-auth0.git"
@@ -14,14 +18,11 @@
1418
},
1519
"homepage": "https://github.com/auth0/angular-auth0#readme",
1620
"devDependencies": {
17-
"gulp": "^3.9.1",
18-
"gulp-concat": "^2.6.0",
19-
"gulp-ng-annotate": "^2.0.0",
20-
"gulp-rename": "^1.2.2",
21-
"gulp-uglify": "^2.0.0"
21+
"babili-webpack-plugin": "^0.1.2",
22+
"webpack": "^3.1.0"
2223
},
23-
"peerDependencies": {
24-
"angular": "^1.5.8",
25-
"auth0-js": "^8.0.0"
24+
"dependencies": {
25+
"angular": "^1.6.0",
26+
"auth0-js": "^8.8.0"
2627
}
2728
}

angular-auth0.js renamed to src/index.js

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
1-
(function() {
1+
import angular from 'angular';
2+
import auth0 from 'auth0-js';
23

3-
'use strict';
4+
if (typeof angular !== 'object') {
5+
throw new Error('Angular must be loaded.');
6+
}
47

5-
angular
6-
.module('auth0.auth0', [])
7-
.provider('angularAuth0', angularAuth0);
8+
if (!angular.isObject(auth0)) {
9+
throw new Error('Auth0 must be loaded.');
10+
}
811

9-
function angularAuth0() {
10-
if (!angular.isObject(auth0)) {
11-
throw new Error('Auth0 must be loaded.');
12-
}
12+
angular.module('auth0.auth0', []).provider('angularAuth0', angularAuth0);
1313

14-
this.init = function(config) {
15-
if (!config) {
16-
throw new Error('clientID and domain must be provided to auth0');
17-
}
18-
this.config = config;
14+
function angularAuth0() {
15+
this.init = function(config) {
16+
if (!config) {
17+
throw new Error('Client ID and Domain are required to initialize Auth0.js');
1918
}
19+
this.config = config;
20+
};
2021

21-
this.$get = ["$rootScope", function($rootScope) {
22-
22+
this.$get = [
23+
'$rootScope',
24+
function($rootScope) {
2325
var Auth0Js = new auth0.WebAuth(this.config);
2426
var webAuth = {};
2527
var functions = [];
28+
2629
for (var i in Auth0Js) {
2730
if (angular.isFunction(Auth0Js[i])) {
2831
functions.push(i);
@@ -54,7 +57,8 @@
5457
return customFunction;
5558
})(functions[i]);
5659
}
60+
5761
return webAuth;
58-
}];
59-
}
60-
})();
62+
}
63+
];
64+
}

webpack.config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const path = require('path');
2+
const BabiliPlugin = require('babili-webpack-plugin');
3+
4+
module.exports = {
5+
entry: {
6+
'angular-auth0.js': './src/index.js',
7+
'angular-auth0.min.js': './src/index.js'
8+
},
9+
output: {
10+
filename: '[name]',
11+
path: path.resolve(__dirname, 'dist')
12+
},
13+
externals: {
14+
angular: 'angular',
15+
'auth0-js': 'auth0'
16+
},
17+
plugins: [
18+
new BabiliPlugin({}, {
19+
test: /\.min\.js$/
20+
})
21+
]
22+
};

0 commit comments

Comments
 (0)