Angular 4 Adal wrapper package. Can be used to authenticate Angular 4 applications to Azure Active Directory.
This project is also designed to be a functional demomonstration of how to create, build, and publish NPM modules for Angular4.
Working example at https://github.com/benbaran/adal-angular4-example.
- Hash is now removed from url after login
- Added HTTP Interceptor for Angular 4.3.0+
- Updated all packages to newest versions
npm install -g npm@latest
npm install -g gulp
npm install -g tslint
npm install -g typescript
npm install -g tslint
mkdir adal-angular4
cd adal-angular4
git init
npm init
git add -A
git commit -m 'Initial commit'
npm install --save rxjs@latest
npm install --save zone.js@latest
npm install --save @angular/core@latest
npm install --save @angular/common@latest
npm install --save @angular/platform-browser@latest
npm install --save @angular/http@latest
npm install --save adal-angular@latest
npm install --save-dev gulp
npm install --save-dev gulp-bump
npm install --save-dev del
npm install --save-dev merge2
npm install --save-dev typescript
npm install --save-dev gulp-typescript
npm install --save-dev @types/jasmine
eslint --init
tslint --init
mkdir src
npm adduser
npm publish
adal4-http.service.ts
adal4.user.ts
adal4.service.ts
export {Adal4User} from './adal4-user';
export {Adal4Service} from './adal4.service';
export {Adal4HTTPService} from './adal4-http.service';
// Declare all dependencies for publish process
var bump = require('gulp-bump'),
del = require('del'),
exec = require('child_process').exec,
gulp = require('gulp'),
merge = require('merge2'),
typescript = require('gulp-typescript'),
fs = require('fs');
gulp.task('clean', function () {
del(['dist/*']);
});
gulp.task('bump', ['clean'], function () {
gulp.src('./package.json')
.pipe(bump({
type: 'patch'
}))
.pipe(gulp.dest('./'));
});
gulp.task('bundle', ['bump'], function () {
var tsResult = gulp.src('src/*.ts')
.pipe(typescript({
module: "commonjs",
target: "es5",
noImplicitAny: true,
experimentalDecorators: true,
outDir: "dist/",
rootDir: "src/",
sourceMap: true,
declaration: true,
moduleResolution: "node",
removeComments: false,
lib: [
"es2015",
"dom"
],
types: ["jasmine"]
}));
return merge([
tsResult.dts.pipe(gulp.dest('dist/')),
tsResult.js.pipe(gulp.dest('dist/'))
]);
});
gulp.task('package', ['bundle'], () => {
const pkgjson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
// remove the scripts section
delete pkgjson.scripts;
// remove the devDependencies section
delete pkgjson.devDependencies;
const filepath = './dist/package.json';
fs.writeFileSync(filepath, JSON.stringify(pkgjson, null, 2), 'utf-8');
});
gulp.task('git-add', ['package'], function (cb) {
exec('git add -A', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});
// Commit
gulp.task('git-commit', ['git-add'], function (cb) {
var package = require('./package.json');
exec('git commit -m "Version ' + package.version + ' release."', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});
gulp.task('git-push', ['git-commit'], function (cb) {
exec('git push', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});
gulp.task('publish', ['git-push'], function (cb) {
exec('npm publish ./dist', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});
gulp publish