├── .babelrc ├── .gitattributes ├── .github └── ISSUE_TEMPLATE │ └── config.yml ├── .gitignore ├── .npmignore ├── GitReleaseManager.yaml ├── LICENSE ├── README.md ├── bower.json ├── dist ├── oidc-client.d.ts ├── oidc-client.js ├── oidc-client.min.js ├── oidc-client.rsa256.slim.js ├── oidc-client.rsa256.slim.min.js ├── oidc-client.slim.js └── oidc-client.slim.min.js ├── gulpfile.js ├── index.d.ts ├── index.js ├── jsconfig.json ├── jsrsasign ├── dist │ └── jsrsasign.js ├── ext │ ├── THIRDPARTY_LICENSE.bitcoin.txt │ ├── THIRDPARTY_LICENSE.cryptojs.txt │ ├── THIRDPARTY_LICENSE.jsonsans.txt │ ├── THIRDPARTY_LICENSE.tomwu.txt │ ├── base64-min.js │ ├── base64.js │ ├── cj │ │ ├── THIRDPARTY_LICENSE.cryptojs.txt │ │ ├── aes.js │ │ ├── aes_min.js │ │ ├── cipher-core.js │ │ ├── cipher-core_min.js │ │ ├── core-min.js.ORG │ │ ├── core.js.ORG │ │ ├── cryptojs-312-core-fix-min.js │ │ ├── cryptojs-312-core-fix.js │ │ ├── enc-base64.js │ │ ├── enc-base64_min.js │ │ ├── hmac.js │ │ ├── hmac_min.js │ │ ├── md5.js │ │ ├── md5_min.js │ │ ├── pbkdf2.js │ │ ├── pbkdf2_min.js │ │ ├── ripemd160.js │ │ ├── ripemd160_min.js │ │ ├── sha1.js │ │ ├── sha1_min.js │ │ ├── sha224.js │ │ ├── sha224_min.js │ │ ├── sha256.js │ │ ├── sha256_min.js │ │ ├── sha384.js │ │ ├── sha384_min.js │ │ ├── sha512.js │ │ ├── sha512_min.js │ │ ├── tripledes.js │ │ ├── tripledes_min.js │ │ ├── x64-core.js │ │ └── x64-core_min.js │ ├── ec-min.js │ ├── ec-patch-min.js │ ├── ec-patch.js │ ├── ec.js │ ├── jsbn-min.js │ ├── jsbn.js │ ├── jsbn2-min.js │ ├── jsbn2.js │ ├── json-sans-eval-min.js │ ├── json-sans-eval.js │ ├── prng4-min.js │ ├── prng4.js │ ├── rng-min.js │ ├── rng.js │ ├── rsa-min.js │ ├── rsa.js │ ├── rsa2-min.js │ └── rsa2.js ├── footer.js ├── header.js └── min │ ├── asn1-1.0.min.js │ ├── asn1cades-1.0.min.js │ ├── asn1cms-1.0.min.js │ ├── asn1csr-1.0.min.js │ ├── asn1hex-1.1.min.js │ ├── asn1ocsp-1.0.min.js │ ├── asn1tsp-1.0.min.js │ ├── asn1x509-1.0.min.js │ ├── base64x-1.1.min.js │ ├── crypto-1.1.min.js │ ├── dsa-2.0.min.js │ ├── ecdsa-modified-1.0.min.js │ ├── ecparam-1.0.min.js │ ├── jws-3.3.min.js │ ├── jwsjs-2.0.min.js │ ├── keyutil-1.0.min.js │ ├── nodeutil-1.0.min.js │ ├── pkcs5pkey-1.0.min.js │ ├── rsapem-1.1.min.js │ ├── rsasign-1.2.min.js │ ├── x509-1.1.min.js │ └── x509crl.min.js ├── lib ├── oidc-client.js ├── oidc-client.min.js ├── oidc-client.rsa256.js └── oidc-client.rsa256.min.js ├── package-lock.json ├── package.json ├── polyfills.js ├── samples ├── Angular │ ├── App │ │ ├── .editorconfig │ │ ├── .gitignore │ │ ├── README.md │ │ ├── angular.json │ │ ├── e2e │ │ │ ├── protractor.conf.js │ │ │ ├── src │ │ │ │ ├── app.e2e-spec.ts │ │ │ │ └── app.po.ts │ │ │ └── tsconfig.e2e.json │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── src │ │ │ ├── app │ │ │ │ ├── app.component.css │ │ │ │ ├── app.component.html │ │ │ │ ├── app.component.spec.ts │ │ │ │ ├── app.component.ts │ │ │ │ ├── app.module.ts │ │ │ │ └── core │ │ │ │ │ └── services │ │ │ │ │ ├── auth.service.spec.ts │ │ │ │ │ ├── auth.service.ts │ │ │ │ │ ├── test-api.service.spec.ts │ │ │ │ │ └── test-api.service.ts │ │ │ ├── assets │ │ │ │ ├── .gitkeep │ │ │ │ ├── signin-callback.html │ │ │ │ └── silent-callback.html │ │ │ ├── browserslist │ │ │ ├── environments │ │ │ │ ├── environment.prod.ts │ │ │ │ └── environment.ts │ │ │ ├── favicon.ico │ │ │ ├── index.html │ │ │ ├── karma.conf.js │ │ │ ├── main.ts │ │ │ ├── polyfills.ts │ │ │ ├── styles.css │ │ │ ├── test.ts │ │ │ ├── tsconfig.app.json │ │ │ ├── tsconfig.spec.json │ │ │ └── tslint.json │ │ ├── tsconfig.json │ │ └── tslint.json │ ├── package-lock.json │ └── package.json └── VanillaJS │ ├── oidc.js │ ├── public │ ├── app.css │ ├── code-identityserver-sample-callback.html │ ├── code-identityserver-sample-callback.js │ ├── code-identityserver-sample-popup-signin.html │ ├── code-identityserver-sample-popup-signin.js │ ├── code-identityserver-sample-popup-signout.html │ ├── code-identityserver-sample-popup-signout.js │ ├── code-identityserver-sample-silent.html │ ├── code-identityserver-sample-silent.js │ ├── code-identityserver-sample.html │ ├── code-identityserver-sample.js │ ├── identityserver-sample-callback.html │ ├── identityserver-sample-callback.js │ ├── identityserver-sample-popup-signin.html │ ├── identityserver-sample-popup-signin.js │ ├── identityserver-sample-popup-signout.html │ ├── identityserver-sample-popup-signout.js │ ├── identityserver-sample-silent.html │ ├── identityserver-sample-silent.js │ ├── identityserver-sample.html │ ├── identityserver-sample.js │ ├── index.html │ ├── log.js │ ├── oidc-client-sample-callback.html │ ├── oidc-client-sample-callback.js │ ├── oidc-client-sample.html │ ├── oidc-client-sample.js │ ├── user-manager-sample-callback.html │ ├── user-manager-sample-callback.js │ ├── user-manager-sample-popup-signin.html │ ├── user-manager-sample-popup-signin.js │ ├── user-manager-sample-popup-signout.html │ ├── user-manager-sample-popup-signout.js │ ├── user-manager-sample-silent.html │ ├── user-manager-sample-silent.js │ ├── user-manager-sample.html │ └── user-manager-sample.js │ └── server.js ├── src ├── AccessTokenEvents.js ├── CheckSessionIFrame.js ├── ClockService.js ├── CordovaIFrameNavigator.js ├── CordovaPopupNavigator.js ├── CordovaPopupWindow.js ├── ErrorResponse.js ├── Event.js ├── Global.js ├── IFrameNavigator.js ├── IFrameWindow.js ├── InMemoryWebStorage.js ├── JoseUtil.js ├── JoseUtilImpl.js ├── JoseUtilRsa.js ├── JsonService.js ├── Log.js ├── MetadataService.js ├── OidcClient.js ├── OidcClientSettings.js ├── PopupNavigator.js ├── PopupWindow.js ├── RedirectNavigator.js ├── ResponseValidator.js ├── SessionMonitor.js ├── SigninRequest.js ├── SigninResponse.js ├── SigninState.js ├── SignoutRequest.js ├── SignoutResponse.js ├── SilentRenewService.js ├── State.js ├── Timer.js ├── TokenClient.js ├── TokenRevocationClient.js ├── UrlUtility.js ├── User.js ├── UserInfoService.js ├── UserManager.js ├── UserManagerEvents.js ├── UserManagerSettings.js ├── WebStorageStateStore.js ├── crypto │ ├── jsrsasign.js │ └── rsa.js └── random.js ├── test ├── conformance │ └── Oidc-Client-Conformance │ │ ├── .vs │ │ └── config │ │ │ └── applicationhost.config │ │ ├── Oidc-Client-Conformance.sln │ │ └── Oidc-Client-Conformance │ │ ├── Oidc-Client-Conformance.csproj │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ ├── Web.Debug.config │ │ ├── Web.Release.config │ │ ├── Web.config │ │ ├── app.css │ │ ├── callback.html │ │ ├── configuration_tests.js │ │ ├── id_token_tests.js │ │ ├── id_token_token_tests.js │ │ ├── index.html │ │ ├── log.js │ │ ├── oidc-client.js │ │ └── packages.config ├── integration │ └── OidcClient.spec.js └── unit │ ├── AccessTokenEvents.spec.js │ ├── ErrorResponse.spec.js │ ├── Event.spec.js │ ├── JoseUtil.spec.js │ ├── JsonService.spec.js │ ├── Log.spec.js │ ├── MetadataService.spec.js │ ├── OidcClient.spec.js │ ├── OidcClientSettings.spec.js │ ├── ResponseValidator.spec.js │ ├── SigninRequest.spec.js │ ├── SigninResponse.spec.js │ ├── SigninState.spec.js │ ├── SignoutRequest.spec.js │ ├── SignoutResponse.spec.js │ ├── State.spec.js │ ├── StubJsonService.js │ ├── StubMetadataService.js │ ├── StubResponseValidator.js │ ├── StubSilentRenewService.js │ ├── StubStateStore.js │ ├── StubTokenRevocationClient.js │ ├── Timer.spec.js │ ├── UrlUtility.spec.js │ ├── UserInfoService.spec.js │ ├── UserManager.spec.js │ ├── UserManagerEvents.spec.js │ ├── UserManagerSettings.spec.js │ ├── WebStorageStateStore.spec.js │ └── random.spec.js ├── version.js └── webpack.base.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015"], 3 | "plugins": [ 4 | "babel-plugin-add-module-exports", 5 | ["transform-es2015-classes", { 6 | "loose": true 7 | }] 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | .idea/ 9 | 10 | # Build results 11 | 12 | [Dd]ebug/ 13 | [Rr]elease/ 14 | x64/ 15 | build/ 16 | [Bb]in/ 17 | [Oo]bj/ 18 | bower_components/ 19 | node_modules/ 20 | 21 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets 22 | !packages/*/build/ 23 | 24 | # MSTest test Results 25 | [Tt]est[Rr]esult*/ 26 | [Bb]uild[Ll]og.* 27 | 28 | *_i.c 29 | *_p.c 30 | *.ilk 31 | *.meta 32 | *.obj 33 | *.pch 34 | *.pdb 35 | *.pgc 36 | *.pgd 37 | *.rsp 38 | *.sbr 39 | *.tlb 40 | *.tli 41 | *.tlh 42 | *.tmp 43 | *.tmp_proj 44 | *.log 45 | *.vspscc 46 | *.vssscc 47 | .builds 48 | *.pidb 49 | *.log 50 | *.svclog 51 | *.scc 52 | 53 | # Visual C++ cache files 54 | ipch/ 55 | *.aps 56 | *.ncb 57 | *.opensdf 58 | *.sdf 59 | *.cachefile 60 | 61 | # Visual Studio profiler 62 | *.psess 63 | *.vsp 64 | *.vspx 65 | 66 | # Guidance Automation Toolkit 67 | *.gpState 68 | 69 | # ReSharper is a .NET coding add-in 70 | _ReSharper*/ 71 | *.[Rr]e[Ss]harper 72 | 73 | # TeamCity is a build add-in 74 | _TeamCity* 75 | 76 | # DotCover is a Code Coverage Tool 77 | *.dotCover 78 | 79 | # NCrunch 80 | *.ncrunch* 81 | .*crunch*.local.xml 82 | 83 | # Installshield output folder 84 | [Ee]xpress/ 85 | 86 | # DocProject is a documentation generator add-in 87 | DocProject/buildhelp/ 88 | DocProject/Help/*.HxT 89 | DocProject/Help/*.HxC 90 | DocProject/Help/*.hhc 91 | DocProject/Help/*.hhk 92 | DocProject/Help/*.hhp 93 | DocProject/Help/Html2 94 | DocProject/Help/html 95 | 96 | # Click-Once directory 97 | publish/ 98 | 99 | # Publish Web Output 100 | *.Publish.xml 101 | *.pubxml 102 | !Local.pubxml 103 | 104 | # NuGet Packages Directory 105 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 106 | packages/ 107 | 108 | # Windows Azure Build Output 109 | csx 110 | *.build.csdef 111 | 112 | # Windows Store app package directory 113 | AppPackages/ 114 | 115 | # Others 116 | sql/ 117 | *.Cache 118 | ClientBin/ 119 | [Ss]tyle[Cc]op.* 120 | ~$* 121 | *~ 122 | *.dbmdl 123 | *.[Pp]ublish.xml 124 | *.publishsettings 125 | 126 | # RIA/Silverlight projects 127 | Generated_Code/ 128 | 129 | # Backup & report files from converting an old project file to a newer 130 | # Visual Studio version. Backup files are not needed, because we have git ;-) 131 | _UpgradeReport_Files/ 132 | Backup*/ 133 | UpgradeLog*.XML 134 | UpgradeLog*.htm 135 | 136 | # SQL Server files 137 | App_Data/*.mdf 138 | App_Data/*.ldf 139 | 140 | # ========================= 141 | # Windows detritus 142 | # ========================= 143 | 144 | # Windows image file caches 145 | Thumbs.db 146 | ehthumbs.db 147 | 148 | # Folder config file 149 | Desktop.ini 150 | 151 | # Recycle Bin used on file shares 152 | $RECYCLE.BIN/ 153 | 154 | # Mac crap 155 | .DS_Store 156 | distribution/ 157 | *_NCrunch_* 158 | source/IdentityServer3.sln.GhostDoc.xml 159 | /.vs 160 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | samples/ 2 | test/ 3 | .babelrc 4 | -------------------------------------------------------------------------------- /GitReleaseManager.yaml: -------------------------------------------------------------------------------- 1 | create: 2 | include-footer: false 3 | footer-heading: 4 | footer-content: 5 | footer-includes-milestone: false 6 | milestone-replace-text: 7 | export: 8 | include-created-date-in-title: false 9 | created-date-string-format: 10 | perform-regex-removal: false 11 | regex-text: 12 | multiline-regex: false 13 | issue-labels-include: 14 | - bug 15 | - enhancement 16 | issue-labels-exclude: 17 | - Internal Refactoring 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # No Longer Maintained 2 | 3 | This library, while functional, is no longer being maintained. 4 | 5 | A successor project that is showing great progress in updating and modernizing is "oidc-client-ts" and can be found [here](https://github.com/authts/oidc-client-ts). 6 | 7 | -------------------------------------------------- 8 | 9 | 10 | [![npm package](https://badge.fury.io/js/oidc-client.svg)](https://www.npmjs.com/package/oidc-client) 11 | 12 | # oidc-client 13 | 14 | Library to provide OpenID Connect (OIDC) and OAuth2 protocol support for client-side, browser-based JavaScript client applications. 15 | Also included is support for user session and access token management. 16 | 17 | ## Install 18 | 19 | ##### Node.js 20 | 21 | Node.js v4.4 or later required. 22 | 23 | ##### NPM 24 | 25 | `npm install oidc-client --save` 26 | 27 | **NOTE**: if you're not already using [babel-polyfill](https://www.npmjs.com/package/babel-polyfill) make sure you run 28 | `npm install --save babel-polyfill` as well. Then include it in your build. 29 | 30 | ##### CommonJS 31 | If you don't use a package manager or a module loader, then you can get the library from the `dist` folder on github [here](dist). 32 | 33 | ## Including in the browser 34 | 35 | If you intend to use this library directly in a browser and are not using UMD/AMD then there is a compiled version in the [~/dist](dist) folder. 36 | It is already bundled/minified and contains the necessary dependencies and polyfills (mainly for ES6 features such as Promises). 37 | 38 | If you are using UMD/AMD and/or you already have included an ES6 polyfill (such as babel-polyfill.js) then you can include the UMD packaged version of the file from the [~/lib](lib) folder. 39 | 40 | ## Building the Source 41 | 42 | ``` 43 | git clone https://github.com/IdentityModel/oidc-client-js.git 44 | cd oidc-client-js 45 | npm install 46 | npm run build 47 | ``` 48 | 49 | ## Running the Sample 50 | 51 | `npm start` 52 | 53 | and then browse to [http://localhost:15000](http://localhost:15000). 54 | 55 | ## Running the Tests 56 | 57 | `npm test` 58 | 59 | ## Docs 60 | 61 | Some initial docs are [here](https://github.com/IdentityModel/oidc-client-js/wiki). 62 | 63 | ## Feedback, Feature requests, and Bugs 64 | 65 | All are welcome on the [issue tracker](https://github.com/IdentityModel/oidc-client-js/issues). 66 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "oidc-client", 3 | "description": "OpenID Connect (OIDC) & OAuth2 client library", 4 | "main": "dist/oidc-client.js", 5 | "authors": [ 6 | "Brock Allen & Dominick Baier" 7 | ], 8 | "license": "Apache-2.0", 9 | "keywords": [ 10 | "oidc", 11 | "oauth", 12 | "openid", 13 | "identitymodel" 14 | ], 15 | "homepage": "https://github.com/IdentityModel/oidc-client-js", 16 | "private": false, 17 | "ignore": [ 18 | "**/.*", 19 | "node_modules", 20 | "bower_components", 21 | "lib", 22 | "sample", 23 | "src", 24 | "test" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. 3 | 4 | import { Log } from './src/Log.js'; 5 | import { OidcClient } from './src/OidcClient.js'; 6 | import { OidcClientSettings } from './src/OidcClientSettings.js'; 7 | import { WebStorageStateStore } from './src/WebStorageStateStore.js'; 8 | import { InMemoryWebStorage } from './src/InMemoryWebStorage.js'; 9 | import { UserManager } from './src/UserManager.js'; 10 | import { AccessTokenEvents } from './src/AccessTokenEvents.js'; 11 | import { MetadataService } from './src/MetadataService.js'; 12 | import { CordovaPopupNavigator } from './src/CordovaPopupNavigator.js'; 13 | import { CordovaIFrameNavigator } from './src/CordovaIFrameNavigator.js'; 14 | import { CheckSessionIFrame } from './src/CheckSessionIFrame.js'; 15 | import { TokenRevocationClient } from './src/TokenRevocationClient.js'; 16 | import { SessionMonitor } from './src/SessionMonitor.js'; 17 | import { Global } from './src/Global.js'; 18 | import { User } from './src/User.js'; 19 | 20 | import { Version } from './version.js'; 21 | 22 | export default { 23 | Version, 24 | Log, 25 | OidcClient, 26 | OidcClientSettings, 27 | WebStorageStateStore, 28 | InMemoryWebStorage, 29 | UserManager, 30 | AccessTokenEvents, 31 | MetadataService, 32 | CordovaPopupNavigator, 33 | CordovaIFrameNavigator, 34 | CheckSessionIFrame, 35 | TokenRevocationClient, 36 | SessionMonitor, 37 | Global, 38 | User 39 | }; 40 | -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES6", 4 | "module": "commonjs" 5 | } 6 | } -------------------------------------------------------------------------------- /jsrsasign/ext/THIRDPARTY_LICENSE.bitcoin.txt: -------------------------------------------------------------------------------- 1 | https://github.com/bitcoinjs/bitcoinjs-lib 2 | 3 | LICENCE: 4 | MIT License 5 | 6 | FILES: 7 | - ../ecdsa-modified.js (modified version of bitcoin-lib/ecdsa.js) 8 | - ec-patch.js (part of bitcoin-lib/ecdsa.js) 9 | 10 | Copyright (c) 2011 Stefan Thomas 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 17 | -------------------------------------------------------------------------------- /jsrsasign/ext/THIRDPARTY_LICENSE.cryptojs.txt: -------------------------------------------------------------------------------- 1 | https://code.google.com/p/crypto-js/wiki/License 2 | 3 | LICENSE: 4 | NEW BSD License 5 | 6 | FILES: 7 | ext/cryptojs-312-core-fix.js 8 | ext/cryptojs-312-core-fix-min.js 9 | ext/jsrsasign-*-all-min.js 10 | 11 | Copyright (c) 2009-2013 Jeff Mott 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining 14 | a copy of this software and associated documentation files (the 15 | "Software"), to deal in the Software without restriction, including 16 | without limitation the rights to use, copy, modify, merge, publish, 17 | distribute, sublicense, and/or sell copies of the Software, and to 18 | permit persons to whom the Software is furnished to do so, subject to 19 | the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be 22 | included in all copies or substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 27 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 28 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 29 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 30 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 | -------------------------------------------------------------------------------- /jsrsasign/ext/THIRDPARTY_LICENSE.tomwu.txt: -------------------------------------------------------------------------------- 1 | 2 | The 'RSA-Sign JavaScript Library' (jsrsasig) THRID PARTY LICENSE: 3 | 4 | Apr 30, 2012 5 | 6 | This document contains third party licensing information for 7 | the 'RSA-Sign JavaScript Library'. Where applicable, 8 | the text has not been edited from its original content or spelling. 9 | 10 | ********************************************************* 11 | For Tom Wu's jsbn library - BigInteger and RSA 12 | 13 | base64.js - String encoder for Base64 and Hex 14 | jsbn.js - basic BigInteger class 15 | jsbn2.js - BigInteger class extension 16 | prng4.js - Random number generator 17 | rng.js - Random number generator 18 | rsa.js - RSAKey class for RSA public key encryption. 19 | rsa2.js - RSA class extension for RSA private key decryption. 20 | 21 | http://www-cs-students.stanford.edu/~tjw/jsbn/LICENSE 22 | 23 | ********************************************************* 24 | 25 | Licensing 26 | --------- 27 | 28 | This software is covered under the following copyright: 29 | 30 | /* 31 | * Copyright (c) 2003-2005 Tom Wu 32 | * All Rights Reserved. 33 | * 34 | * Permission is hereby granted, free of charge, to any person obtaining 35 | * a copy of this software and associated documentation files (the 36 | * "Software"), to deal in the Software without restriction, including 37 | * without limitation the rights to use, copy, modify, merge, publish, 38 | * distribute, sublicense, and/or sell copies of the Software, and to 39 | * permit persons to whom the Software is furnished to do so, subject to 40 | * the following conditions: 41 | * 42 | * The above copyright notice and this permission notice shall be 43 | * included in all copies or substantial portions of the Software. 44 | * 45 | * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 46 | * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 47 | * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 48 | * 49 | * IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL, 50 | * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER 51 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF 52 | * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT 53 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 54 | * 55 | * In addition, the following condition applies: 56 | * 57 | * All redistributions must retain an intact copy of this copyright notice 58 | * and disclaimer. 59 | */ 60 | 61 | Address all questions regarding this license to: 62 | 63 | Tom Wu 64 | tjw@cs.Stanford.EDU 65 | 66 | -------------------------------------------------------------------------------- /jsrsasign/ext/base64-min.js: -------------------------------------------------------------------------------- 1 | /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ 2 | */ 3 | var b64map="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var b64pad="=";function hex2b64(d){var b;var e;var a="";for(b=0;b+3<=d.length;b+=3){e=parseInt(d.substring(b,b+3),16);a+=b64map.charAt(e>>6)+b64map.charAt(e&63)}if(b+1==d.length){e=parseInt(d.substring(b,b+1),16);a+=b64map.charAt(e<<2)}else{if(b+2==d.length){e=parseInt(d.substring(b,b+2),16);a+=b64map.charAt(e>>2)+b64map.charAt((e&3)<<4)}}if(b64pad){while((a.length&3)>0){a+=b64pad}}return a}function b64tohex(f){var d="";var e;var b=0;var c;var a;for(e=0;e>2);c=a&3;b=1}else{if(b==1){d+=int2char((c<<2)|(a>>4));c=a&15;b=2}else{if(b==2){d+=int2char(c);d+=int2char(a>>2);c=a&3;b=3}else{d+=int2char((c<<2)|(a>>4));d+=int2char(a&15);b=0}}}}if(b==1){d+=int2char(c<<2)}return d}function b64toBA(e){var d=b64tohex(e);var c;var b=new Array();for(c=0;2*c> 6) + b64map.charAt(c & 63); 13 | } 14 | if(i+1 == h.length) { 15 | c = parseInt(h.substring(i,i+1),16); 16 | ret += b64map.charAt(c << 2); 17 | } 18 | else if(i+2 == h.length) { 19 | c = parseInt(h.substring(i,i+2),16); 20 | ret += b64map.charAt(c >> 2) + b64map.charAt((c & 3) << 4); 21 | } 22 | if (b64pad) while((ret.length & 3) > 0) ret += b64pad; 23 | return ret; 24 | } 25 | 26 | // convert a base64 string to hex 27 | function b64tohex(s) { 28 | var ret = "" 29 | var i; 30 | var k = 0; // b64 state, 0-3 31 | var slop; 32 | var v; 33 | for(i = 0; i < s.length; ++i) { 34 | if(s.charAt(i) == b64pad) break; 35 | v = b64map.indexOf(s.charAt(i)); 36 | if(v < 0) continue; 37 | if(k == 0) { 38 | ret += int2char(v >> 2); 39 | slop = v & 3; 40 | k = 1; 41 | } 42 | else if(k == 1) { 43 | ret += int2char((slop << 2) | (v >> 4)); 44 | slop = v & 0xf; 45 | k = 2; 46 | } 47 | else if(k == 2) { 48 | ret += int2char(slop); 49 | ret += int2char(v >> 2); 50 | slop = v & 3; 51 | k = 3; 52 | } 53 | else { 54 | ret += int2char((slop << 2) | (v >> 4)); 55 | ret += int2char(v & 0xf); 56 | k = 0; 57 | } 58 | } 59 | if(k == 1) 60 | ret += int2char(slop << 2); 61 | return ret; 62 | } 63 | 64 | // convert a base64 string to a byte/number array 65 | function b64toBA(s) { 66 | //piggyback on b64tohex for now, optimize later 67 | var h = b64tohex(s); 68 | var i; 69 | var a = new Array(); 70 | for(i = 0; 2*i < h.length; ++i) { 71 | a[i] = parseInt(h.substring(2*i,2*i+2),16); 72 | } 73 | return a; 74 | } 75 | -------------------------------------------------------------------------------- /jsrsasign/ext/cj/THIRDPARTY_LICENSE.cryptojs.txt: -------------------------------------------------------------------------------- 1 | https://code.google.com/p/crypto-js/wiki/License 2 | 3 | LICENSE: 4 | NEW BSD License 5 | 6 | FILES: 7 | ext/cryptojs-312-core-fix.js 8 | ext/cryptojs-312-core-fix-min.js 9 | ext/jsrsasign-*-all-min.js 10 | 11 | Copyright (c) 2009-2013 Jeff Mott 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining 14 | a copy of this software and associated documentation files (the 15 | "Software"), to deal in the Software without restriction, including 16 | without limitation the rights to use, copy, modify, merge, publish, 17 | distribute, sublicense, and/or sell copies of the Software, and to 18 | permit persons to whom the Software is furnished to do so, subject to 19 | the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be 22 | included in all copies or substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 27 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 28 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 29 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 30 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 | -------------------------------------------------------------------------------- /jsrsasign/ext/cj/aes_min.js: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.1.2 aes.js 3 | code.google.com/p/crypto-js 4 | (c) 2009-2013 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (function(){for(var q=CryptoJS,x=q.lib.BlockCipher,r=q.algo,j=[],y=[],z=[],A=[],B=[],C=[],s=[],u=[],v=[],w=[],g=[],k=0;256>k;k++)g[k]=128>k?k<<1:k<<1^283;for(var n=0,l=0,k=0;256>k;k++){var f=l^l<<1^l<<2^l<<3^l<<4,f=f>>>8^f&255^99;j[n]=f;y[f]=n;var t=g[n],D=g[t],E=g[D],b=257*g[f]^16843008*f;z[n]=b<<24|b>>>8;A[n]=b<<16|b>>>16;B[n]=b<<8|b>>>24;C[n]=b;b=16843009*E^65537*D^257*t^16843008*n;s[f]=b<<24|b>>>8;u[f]=b<<16|b>>>16;v[f]=b<<8|b>>>24;w[f]=b;n?(n=t^g[g[g[E^t]]],l^=g[g[l]]):n=l=1}var F=[0,1,2,4,8, 8 | 16,32,64,128,27,54],r=r.AES=x.extend({_doReset:function(){for(var c=this._key,e=c.words,a=c.sigBytes/4,c=4*((this._nRounds=a+6)+1),b=this._keySchedule=[],h=0;h>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255]):(d=d<<8|d>>>24,d=j[d>>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255],d^=F[h/a|0]<<24);b[h]=b[h-a]^d}e=this._invKeySchedule=[];for(a=0;aa||4>=h?d:s[j[d>>>24]]^u[j[d>>>16&255]]^v[j[d>>> 9 | 8&255]]^w[j[d&255]]},encryptBlock:function(c,e){this._doCryptBlock(c,e,this._keySchedule,z,A,B,C,j)},decryptBlock:function(c,e){var a=c[e+1];c[e+1]=c[e+3];c[e+3]=a;this._doCryptBlock(c,e,this._invKeySchedule,s,u,v,w,y);a=c[e+1];c[e+1]=c[e+3];c[e+3]=a},_doCryptBlock:function(c,e,a,b,h,d,j,m){for(var n=this._nRounds,f=c[e]^a[0],g=c[e+1]^a[1],k=c[e+2]^a[2],p=c[e+3]^a[3],l=4,t=1;t>>24]^h[g>>>16&255]^d[k>>>8&255]^j[p&255]^a[l++],r=b[g>>>24]^h[k>>>16&255]^d[p>>>8&255]^j[f&255]^a[l++],s= 10 | b[k>>>24]^h[p>>>16&255]^d[f>>>8&255]^j[g&255]^a[l++],p=b[p>>>24]^h[f>>>16&255]^d[g>>>8&255]^j[k&255]^a[l++],f=q,g=r,k=s;q=(m[f>>>24]<<24|m[g>>>16&255]<<16|m[k>>>8&255]<<8|m[p&255])^a[l++];r=(m[g>>>24]<<24|m[k>>>16&255]<<16|m[p>>>8&255]<<8|m[f&255])^a[l++];s=(m[k>>>24]<<24|m[p>>>16&255]<<16|m[f>>>8&255]<<8|m[g&255])^a[l++];p=(m[p>>>24]<<24|m[f>>>16&255]<<16|m[g>>>8&255]<<8|m[k&255])^a[l++];c[e]=q;c[e+1]=r;c[e+2]=s;c[e+3]=p},keySize:8});q.AES=x._createHelper(r)})(); 11 | -------------------------------------------------------------------------------- /jsrsasign/ext/cj/core-min.js.ORG: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.1.2 3 | code.google.com/p/crypto-js 4 | (c) 2009-2013 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | var CryptoJS=CryptoJS||function(h,r){var k={},l=k.lib={},n=function(){},f=l.Base={extend:function(a){n.prototype=this;var b=new n;a&&b.mixIn(a);b.hasOwnProperty("init")||(b.init=function(){b.$super.init.apply(this,arguments)});b.init.prototype=b;b.$super=this;return b},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}}, 8 | j=l.WordArray=f.extend({init:function(a,b){a=this.words=a||[];this.sigBytes=b!=r?b:4*a.length},toString:function(a){return(a||s).stringify(this)},concat:function(a){var b=this.words,d=a.words,c=this.sigBytes;a=a.sigBytes;this.clamp();if(c%4)for(var e=0;e>>2]|=(d[e>>>2]>>>24-8*(e%4)&255)<<24-8*((c+e)%4);else if(65535>>2]=d[e>>>2];else b.push.apply(b,d);this.sigBytes+=a;return this},clamp:function(){var a=this.words,b=this.sigBytes;a[b>>>2]&=4294967295<< 9 | 32-8*(b%4);a.length=h.ceil(b/4)},clone:function(){var a=f.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var b=[],d=0;d>>2]>>>24-8*(c%4)&255;d.push((e>>>4).toString(16));d.push((e&15).toString(16))}return d.join("")},parse:function(a){for(var b=a.length,d=[],c=0;c>>3]|=parseInt(a.substr(c, 10 | 2),16)<<24-4*(c%8);return new j.init(d,b/2)}},p=m.Latin1={stringify:function(a){var b=a.words;a=a.sigBytes;for(var d=[],c=0;c>>2]>>>24-8*(c%4)&255));return d.join("")},parse:function(a){for(var b=a.length,d=[],c=0;c>>2]|=(a.charCodeAt(c)&255)<<24-8*(c%4);return new j.init(d,b)}},t=m.Utf8={stringify:function(a){try{return decodeURIComponent(escape(p.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data");}},parse:function(a){return p.parse(unescape(encodeURIComponent(a)))}}, 11 | q=l.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new j.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=t.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var b=this._data,d=b.words,c=b.sigBytes,e=this.blockSize,f=c/(4*e),f=a?h.ceil(f):h.max((f|0)-this._minBufferSize,0);a=f*e;c=h.min(4*a,c);if(a){for(var g=0;g>>2]>>>(24-(r%4)*8))&255;q[(n+r)>>>2]|=o<<(24-((n+r)%4)*8)}}else{for(var r=0;r>>2]=p[r>>>2]}}this.sigBytes+=s;return this},clamp:function(){var o=this.words;var n=this.sigBytes;o[n>>>2]&=4294967295<<(32-(n%4)*8);o.length=e.ceil(n/4)},clone:function(){var n=j.clone.call(this);n.words=this.words.slice(0);return n},random:function(p){var o=[];for(var n=0;n>>2]>>>(24-(n%4)*8))&255;q.push((s>>>4).toString(16));q.push((s&15).toString(16))}return q.join("")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>3]|=parseInt(p.substr(o,2),16)<<(24-(o%8)*4)}return new l.init(q,n/2)}};var d=m.Latin1={stringify:function(q){var r=q.words;var p=q.sigBytes;var n=[];for(var o=0;o>>2]>>>(24-(o%4)*8))&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>2]|=(p.charCodeAt(o)&255)<<(24-(o%4)*8)}return new l.init(q,n)}};var c=m.Utf8={stringify:function(n){try{return decodeURIComponent(escape(d.stringify(n)))}catch(o){throw new Error("Malformed UTF-8 data")}},parse:function(n){return d.parse(unescape(encodeURIComponent(n)))}};var i=b.BufferedBlockAlgorithm=j.extend({reset:function(){this._data=new l.init();this._nDataBytes=0},_append:function(n){if(typeof n=="string"){n=c.parse(n)}this._data.concat(n);this._nDataBytes+=n.sigBytes},_process:function(w){var q=this._data;var x=q.words;var n=q.sigBytes;var t=this.blockSize;var v=t*4;var u=n/v;if(w){u=e.ceil(u)}else{u=e.max((u|0)-this._minBufferSize,0)}var s=u*t;var r=e.min(s*4,n);if(s){for(var p=0;p>>2]>>>24-8*(a%4)&255)<<16|(e[a+1>>>2]>>>24-8*((a+1)%4)&255)<<8|e[a+2>>>2]>>>24-8*((a+2)%4)&255,g=0;4>g&&a+0.75*g>>6*(3-g)&63));if(e=c.charAt(64))for(;b.length%4;)b.push(e);return b.join("")},parse:function(b){var e=b.length,f=this._map,c=f.charAt(64);c&&(c=b.indexOf(c),-1!=c&&(e=c));for(var c=[],a=0,d=0;d< 8 | e;d++)if(d%4){var g=f.indexOf(b.charAt(d-1))<<2*(d%4),h=f.indexOf(b.charAt(d))>>>6-2*(d%4);c[a>>>2]|=(g|h)<<24-8*(a%4);a++}return j.create(c,a)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})(); 9 | -------------------------------------------------------------------------------- /jsrsasign/ext/cj/hmac_min.js: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.1.2 hmac.js 3 | code.google.com/p/crypto-js 4 | (c) 2009-2013 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (function(){var c=CryptoJS,k=c.enc.Utf8;c.algo.HMAC=c.lib.Base.extend({init:function(a,b){a=this._hasher=new a.init;"string"==typeof b&&(b=k.parse(b));var c=a.blockSize,e=4*c;b.sigBytes>e&&(b=a.finalize(b));b.clamp();for(var f=this._oKey=b.clone(),g=this._iKey=b.clone(),h=f.words,j=g.words,d=0;d>>32-h)+f}function k(a,f,g,j,p,h,k){a=a+(f&j|g&~j)+p+k;return(a<>>32-h)+f}function l(a,f,g,j,h,k,l){a=a+(f^g^j)+h+l;return(a<>>32-k)+f}function n(a,f,g,j,h,k,l){a=a+(g^(f|~j))+h+l;return(a<>>32-k)+f}for(var r=CryptoJS,q=r.lib,F=q.WordArray,s=q.Hasher,q=r.algo,a=[],t=0;64>t;t++)a[t]=4294967296*E.abs(E.sin(t+1))|0;q=q.MD5=s.extend({_doReset:function(){this._hash=new F.init([1732584193,4023233417,2562383102,271733878])}, 8 | _doProcessBlock:function(m,f){for(var g=0;16>g;g++){var j=f+g,p=m[j];m[j]=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360}var g=this._hash.words,j=m[f+0],p=m[f+1],q=m[f+2],r=m[f+3],s=m[f+4],t=m[f+5],u=m[f+6],v=m[f+7],w=m[f+8],x=m[f+9],y=m[f+10],z=m[f+11],A=m[f+12],B=m[f+13],C=m[f+14],D=m[f+15],b=g[0],c=g[1],d=g[2],e=g[3],b=h(b,c,d,e,j,7,a[0]),e=h(e,b,c,d,p,12,a[1]),d=h(d,e,b,c,q,17,a[2]),c=h(c,d,e,b,r,22,a[3]),b=h(b,c,d,e,s,7,a[4]),e=h(e,b,c,d,t,12,a[5]),d=h(d,e,b,c,u,17,a[6]),c=h(c,d,e,b,v,22,a[7]), 9 | b=h(b,c,d,e,w,7,a[8]),e=h(e,b,c,d,x,12,a[9]),d=h(d,e,b,c,y,17,a[10]),c=h(c,d,e,b,z,22,a[11]),b=h(b,c,d,e,A,7,a[12]),e=h(e,b,c,d,B,12,a[13]),d=h(d,e,b,c,C,17,a[14]),c=h(c,d,e,b,D,22,a[15]),b=k(b,c,d,e,p,5,a[16]),e=k(e,b,c,d,u,9,a[17]),d=k(d,e,b,c,z,14,a[18]),c=k(c,d,e,b,j,20,a[19]),b=k(b,c,d,e,t,5,a[20]),e=k(e,b,c,d,y,9,a[21]),d=k(d,e,b,c,D,14,a[22]),c=k(c,d,e,b,s,20,a[23]),b=k(b,c,d,e,x,5,a[24]),e=k(e,b,c,d,C,9,a[25]),d=k(d,e,b,c,r,14,a[26]),c=k(c,d,e,b,w,20,a[27]),b=k(b,c,d,e,B,5,a[28]),e=k(e,b, 10 | c,d,q,9,a[29]),d=k(d,e,b,c,v,14,a[30]),c=k(c,d,e,b,A,20,a[31]),b=l(b,c,d,e,t,4,a[32]),e=l(e,b,c,d,w,11,a[33]),d=l(d,e,b,c,z,16,a[34]),c=l(c,d,e,b,C,23,a[35]),b=l(b,c,d,e,p,4,a[36]),e=l(e,b,c,d,s,11,a[37]),d=l(d,e,b,c,v,16,a[38]),c=l(c,d,e,b,y,23,a[39]),b=l(b,c,d,e,B,4,a[40]),e=l(e,b,c,d,j,11,a[41]),d=l(d,e,b,c,r,16,a[42]),c=l(c,d,e,b,u,23,a[43]),b=l(b,c,d,e,x,4,a[44]),e=l(e,b,c,d,A,11,a[45]),d=l(d,e,b,c,D,16,a[46]),c=l(c,d,e,b,q,23,a[47]),b=n(b,c,d,e,j,6,a[48]),e=n(e,b,c,d,v,10,a[49]),d=n(d,e,b,c, 11 | C,15,a[50]),c=n(c,d,e,b,t,21,a[51]),b=n(b,c,d,e,A,6,a[52]),e=n(e,b,c,d,r,10,a[53]),d=n(d,e,b,c,y,15,a[54]),c=n(c,d,e,b,p,21,a[55]),b=n(b,c,d,e,w,6,a[56]),e=n(e,b,c,d,D,10,a[57]),d=n(d,e,b,c,u,15,a[58]),c=n(c,d,e,b,B,21,a[59]),b=n(b,c,d,e,s,6,a[60]),e=n(e,b,c,d,z,10,a[61]),d=n(d,e,b,c,q,15,a[62]),c=n(c,d,e,b,x,21,a[63]);g[0]=g[0]+b|0;g[1]=g[1]+c|0;g[2]=g[2]+d|0;g[3]=g[3]+e|0},_doFinalize:function(){var a=this._data,f=a.words,g=8*this._nDataBytes,j=8*a.sigBytes;f[j>>>5]|=128<<24-j%32;var h=E.floor(g/ 12 | 4294967296);f[(j+64>>>9<<4)+15]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360;f[(j+64>>>9<<4)+14]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360;a.sigBytes=4*(f.length+1);this._process();a=this._hash;f=a.words;for(g=0;4>g;g++)j=f[g],f[g]=(j<<8|j>>>24)&16711935|(j<<24|j>>>8)&4278255360;return a},clone:function(){var a=s.clone.call(this);a._hash=this._hash.clone();return a}});r.MD5=s._createHelper(q);r.HmacMD5=s._createHmacHelper(q)})(Math); 13 | -------------------------------------------------------------------------------- /jsrsasign/ext/cj/pbkdf2_min.js: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.1.2 pbkdf2-min.js 3 | code.google.com/p/crypto-js 4 | (c) 2009-2013 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (function(){var b=CryptoJS,a=b.lib,d=a.Base,m=a.WordArray,a=b.algo,q=a.HMAC,l=a.PBKDF2=d.extend({cfg:d.extend({keySize:4,hasher:a.SHA1,iterations:1}),init:function(a){this.cfg=this.cfg.extend(a)},compute:function(a,b){for(var c=this.cfg,f=q.create(c.hasher,a),g=m.create(),d=m.create([1]),l=g.words,r=d.words,n=c.keySize,c=c.iterations;l.lengthc;c++){if(16>c)d[c]=n[p+c]|0;else{var g=d[c-3]^d[c-8]^d[c-14]^d[c-16];d[c]=g<<1|g>>>31}g=(e<<5|e>>>27)+b+d[c];g=20>c?g+((f&h|~f&j)+1518500249):40>c?g+((f^h^j)+1859775393):60>c?g+((f&h|f&j|h&j)-1894007588):g+((f^h^ 8 | j)-899497514);b=j;j=h;h=f<<30|f>>>2;f=e;e=g}a[0]=a[0]+e|0;a[1]=a[1]+f|0;a[2]=a[2]+h|0;a[3]=a[3]+j|0;a[4]=a[4]+b|0},_doFinalize:function(){var b=this._data,d=b.words,a=8*this._nDataBytes,e=8*b.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=Math.floor(a/4294967296);d[(e+64>>>9<<4)+15]=a;b.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var b=l.clone.call(this);b._hash=this._hash.clone();return b}});k.SHA1=l._createHelper(b);k.HmacSHA1=l._createHmacHelper(b)})(); 9 | -------------------------------------------------------------------------------- /jsrsasign/ext/cj/sha224.js: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.1.2 3 | code.google.com/p/crypto-js 4 | (c) 2009-2013 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (function () { 8 | // Shortcuts 9 | var C = CryptoJS; 10 | var C_lib = C.lib; 11 | var WordArray = C_lib.WordArray; 12 | var C_algo = C.algo; 13 | var SHA256 = C_algo.SHA256; 14 | 15 | /** 16 | * SHA-224 hash algorithm. 17 | */ 18 | var SHA224 = C_algo.SHA224 = SHA256.extend({ 19 | _doReset: function () { 20 | this._hash = new WordArray.init([ 21 | 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 22 | 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 23 | ]); 24 | }, 25 | 26 | _doFinalize: function () { 27 | var hash = SHA256._doFinalize.call(this); 28 | 29 | hash.sigBytes -= 4; 30 | 31 | return hash; 32 | } 33 | }); 34 | 35 | /** 36 | * Shortcut function to the hasher's object interface. 37 | * 38 | * @param {WordArray|string} message The message to hash. 39 | * 40 | * @return {WordArray} The hash. 41 | * 42 | * @static 43 | * 44 | * @example 45 | * 46 | * var hash = CryptoJS.SHA224('message'); 47 | * var hash = CryptoJS.SHA224(wordArray); 48 | */ 49 | C.SHA224 = SHA256._createHelper(SHA224); 50 | 51 | /** 52 | * Shortcut function to the HMAC's object interface. 53 | * 54 | * @param {WordArray|string} message The message to hash. 55 | * @param {WordArray|string} key The secret key. 56 | * 57 | * @return {WordArray} The HMAC. 58 | * 59 | * @static 60 | * 61 | * @example 62 | * 63 | * var hmac = CryptoJS.HmacSHA224(message, key); 64 | */ 65 | C.HmacSHA224 = SHA256._createHmacHelper(SHA224); 66 | }()); 67 | -------------------------------------------------------------------------------- /jsrsasign/ext/cj/sha224_min.js: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.1.2 sha224-min.js 3 | code.google.com/p/crypto-js 4 | (c) 2009-2013 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (function(){var b=CryptoJS,d=b.lib.WordArray,a=b.algo,c=a.SHA256,a=a.SHA224=c.extend({_doReset:function(){this._hash=new d.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var a=c._doFinalize.call(this);a.sigBytes-=4;return a}});b.SHA224=c._createHelper(a);b.HmacSHA224=c._createHmacHelper(a)})(); 8 | -------------------------------------------------------------------------------- /jsrsasign/ext/cj/sha256_min.js: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.1.2 sha256-min.js 3 | code.google.com/p/crypto-js 4 | (c) 2009-2013 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (function(k){for(var g=CryptoJS,h=g.lib,v=h.WordArray,j=h.Hasher,h=g.algo,s=[],t=[],u=function(q){return 4294967296*(q-(q|0))|0},l=2,b=0;64>b;){var d;a:{d=l;for(var w=k.sqrt(d),r=2;r<=w;r++)if(!(d%r)){d=!1;break a}d=!0}d&&(8>b&&(s[b]=u(k.pow(l,0.5))),t[b]=u(k.pow(l,1/3)),b++);l++}var n=[],h=h.SHA256=j.extend({_doReset:function(){this._hash=new v.init(s.slice(0))},_doProcessBlock:function(q,h){for(var a=this._hash.words,c=a[0],d=a[1],b=a[2],k=a[3],f=a[4],g=a[5],j=a[6],l=a[7],e=0;64>e;e++){if(16>e)n[e]= 8 | q[h+e]|0;else{var m=n[e-15],p=n[e-2];n[e]=((m<<25|m>>>7)^(m<<14|m>>>18)^m>>>3)+n[e-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+n[e-16]}m=l+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&g^~f&j)+t[e]+n[e];p=((c<<30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22))+(c&d^c&b^d&b);l=j;j=g;g=f;f=k+m|0;k=b;b=d;d=c;c=m+p|0}a[0]=a[0]+c|0;a[1]=a[1]+d|0;a[2]=a[2]+b|0;a[3]=a[3]+k|0;a[4]=a[4]+f|0;a[5]=a[5]+g|0;a[6]=a[6]+j|0;a[7]=a[7]+l|0},_doFinalize:function(){var d=this._data,b=d.words,a=8*this._nDataBytes,c=8*d.sigBytes; 9 | b[c>>>5]|=128<<24-c%32;b[(c+64>>>9<<4)+14]=k.floor(a/4294967296);b[(c+64>>>9<<4)+15]=a;d.sigBytes=4*b.length;this._process();return this._hash},clone:function(){var b=j.clone.call(this);b._hash=this._hash.clone();return b}});g.SHA256=j._createHelper(h);g.HmacSHA256=j._createHmacHelper(h)})(Math); 10 | -------------------------------------------------------------------------------- /jsrsasign/ext/cj/sha384.js: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.1.2 3 | code.google.com/p/crypto-js 4 | (c) 2009-2013 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (function () { 8 | // Shortcuts 9 | var C = CryptoJS; 10 | var C_x64 = C.x64; 11 | var X64Word = C_x64.Word; 12 | var X64WordArray = C_x64.WordArray; 13 | var C_algo = C.algo; 14 | var SHA512 = C_algo.SHA512; 15 | 16 | /** 17 | * SHA-384 hash algorithm. 18 | */ 19 | var SHA384 = C_algo.SHA384 = SHA512.extend({ 20 | _doReset: function () { 21 | this._hash = new X64WordArray.init([ 22 | new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507), 23 | new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939), 24 | new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511), 25 | new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4) 26 | ]); 27 | }, 28 | 29 | _doFinalize: function () { 30 | var hash = SHA512._doFinalize.call(this); 31 | 32 | hash.sigBytes -= 16; 33 | 34 | return hash; 35 | } 36 | }); 37 | 38 | /** 39 | * Shortcut function to the hasher's object interface. 40 | * 41 | * @param {WordArray|string} message The message to hash. 42 | * 43 | * @return {WordArray} The hash. 44 | * 45 | * @static 46 | * 47 | * @example 48 | * 49 | * var hash = CryptoJS.SHA384('message'); 50 | * var hash = CryptoJS.SHA384(wordArray); 51 | */ 52 | C.SHA384 = SHA512._createHelper(SHA384); 53 | 54 | /** 55 | * Shortcut function to the HMAC's object interface. 56 | * 57 | * @param {WordArray|string} message The message to hash. 58 | * @param {WordArray|string} key The secret key. 59 | * 60 | * @return {WordArray} The HMAC. 61 | * 62 | * @static 63 | * 64 | * @example 65 | * 66 | * var hmac = CryptoJS.HmacSHA384(message, key); 67 | */ 68 | C.HmacSHA384 = SHA512._createHmacHelper(SHA384); 69 | }()); 70 | -------------------------------------------------------------------------------- /jsrsasign/ext/cj/sha384_min.js: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.1.2 sha384-min.js 3 | code.google.com/p/crypto-js 4 | (c) 2009-2013 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (function(){var c=CryptoJS,a=c.x64,b=a.Word,e=a.WordArray,a=c.algo,d=a.SHA512,a=a.SHA384=d.extend({_doReset:function(){this._hash=new e.init([new b.init(3418070365,3238371032),new b.init(1654270250,914150663),new b.init(2438529370,812702999),new b.init(355462360,4144912697),new b.init(1731405415,4290775857),new b.init(2394180231,1750603025),new b.init(3675008525,1694076839),new b.init(1203062813,3204075428)])},_doFinalize:function(){var a=d._doFinalize.call(this);a.sigBytes-=16;return a}});c.SHA384= 8 | d._createHelper(a);c.HmacSHA384=d._createHmacHelper(a)})(); 9 | -------------------------------------------------------------------------------- /jsrsasign/ext/cj/x64-core_min.js: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.1.2 x64-core-min.js 3 | code.google.com/p/crypto-js 4 | (c) 2009-2013 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (function(g){var a=CryptoJS,f=a.lib,e=f.Base,h=f.WordArray,a=a.x64={};a.Word=e.extend({init:function(b,c){this.high=b;this.low=c}});a.WordArray=e.extend({init:function(b,c){b=this.words=b||[];this.sigBytes=c!=g?c:8*b.length},toX32:function(){for(var b=this.words,c=b.length,a=[],d=0;dg.length){g.unshift(0)}}return g};var a=this.getX().toBigInteger();var e=this.getY().toBigInteger();var b=d(a,32);if(c){if(e.isEven()){b.unshift(2)}else{b.unshift(3)}}else{b.unshift(4);b=b.concat(d(e,32))}return b};ECPointFp.decodeFrom=function(g,c){var f=c[0];var e=c.length-1;var d=c.slice(1,1+e/2);var b=c.slice(1+e/2,1+e);d.unshift(0);b.unshift(0);var a=new BigInteger(d);var h=new BigInteger(b);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.decodeFromHex=function(g,c){var f=c.substr(0,2);var e=c.length-2;var d=c.substr(2,e/2);var b=c.substr(2+e/2,e/2);var a=new BigInteger(d,16);var h=new BigInteger(b,16);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.prototype.add2D=function(c){if(this.isInfinity()){return c}if(c.isInfinity()){return this}if(this.x.equals(c.x)){if(this.y.equals(c.y)){return this.twice()}return this.curve.getInfinity()}var g=c.x.subtract(this.x);var e=c.y.subtract(this.y);var a=e.divide(g);var d=a.square().subtract(this.x).subtract(c.x);var f=a.multiply(this.x.subtract(d)).subtract(this.y);return new ECPointFp(this.curve,d,f)};ECPointFp.prototype.twice2D=function(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var b=this.curve.fromBigInteger(BigInteger.valueOf(2));var e=this.curve.fromBigInteger(BigInteger.valueOf(3));var a=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(b));var c=a.square().subtract(this.x.multiply(b));var d=a.multiply(this.x.subtract(c)).subtract(this.y);return new ECPointFp(this.curve,c,d)};ECPointFp.prototype.multiply2D=function(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger("3"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add2D(a?this:l)}}return d};ECPointFp.prototype.isOnCurve=function(){var d=this.getX().toBigInteger();var i=this.getY().toBigInteger();var f=this.curve.getA().toBigInteger();var c=this.curve.getB().toBigInteger();var h=this.curve.getQ();var e=i.multiply(i).mod(h);var g=d.multiply(d).multiply(d).add(f.multiply(d)).add(c).mod(h);return e.equals(g)};ECPointFp.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"};ECPointFp.prototype.validate=function(){var c=this.curve.getQ();if(this.isInfinity()){throw new Error("Point is at infinity.")}var a=this.getX().toBigInteger();var b=this.getY().toBigInteger();if(a.compareTo(BigInteger.ONE)<0||a.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error("x coordinate out of bounds")}if(b.compareTo(BigInteger.ONE)<0||b.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error("y coordinate out of bounds")}if(!this.isOnCurve()){throw new Error("Point is not on the curve.")}if(this.multiply(c).isInfinity()){throw new Error("Point is not a scalar multiple of G.")}return true}; -------------------------------------------------------------------------------- /jsrsasign/ext/json-sans-eval-min.js: -------------------------------------------------------------------------------- 1 | /*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval 2 | */ 3 | var jsonParse=(function(){var e="(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)";var j='(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))';var i='(?:"'+j+'*")';var d=new RegExp("(?:false|true|null|[\\{\\}\\[\\]]|"+e+"|"+i+")","g");var k=new RegExp("\\\\(?:([^u])|u(.{4}))","g");var g={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function h(l,m,n){return m?g[m]:String.fromCharCode(parseInt(n,16))}var c=new String("");var a="\\";var f={"{":Object,"[":Array};var b=Object.hasOwnProperty;return function(u,q){var p=u.match(d);var x;var v=p[0];var l=false;if("{"===v){x={}}else{if("["===v){x=[]}else{x=[];l=true}}var t;var r=[x];for(var o=1-l,m=p.length;o=0;){delete D[n[A]]}}}return q.call(C,B,D)};x=s({"":x},"")}return x}})(); -------------------------------------------------------------------------------- /jsrsasign/ext/prng4-min.js: -------------------------------------------------------------------------------- 1 | /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ 2 | */ 3 | function Arcfour(){this.i=0;this.j=0;this.S=new Array()}function ARC4init(d){var c,a,b;for(c=0;c<256;++c){this.S[c]=c}a=0;for(c=0;c<256;++c){a=(a+this.S[c]+d[c%d.length])&255;b=this.S[c];this.S[c]=this.S[a];this.S[a]=b}this.i=0;this.j=0}function ARC4next(){var a;this.i=(this.i+1)&255;this.j=(this.j+this.S[this.i])&255;a=this.S[this.i];this.S[this.i]=this.S[this.j];this.S[this.j]=a;return this.S[(a+this.S[this.i])&255]}Arcfour.prototype.init=ARC4init;Arcfour.prototype.next=ARC4next;function prng_newstate(){return new Arcfour()}var rng_psize=256; -------------------------------------------------------------------------------- /jsrsasign/ext/prng4.js: -------------------------------------------------------------------------------- 1 | /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ 2 | */ 3 | // prng4.js - uses Arcfour as a PRNG 4 | 5 | function Arcfour() { 6 | this.i = 0; 7 | this.j = 0; 8 | this.S = new Array(); 9 | } 10 | 11 | // Initialize arcfour context from key, an array of ints, each from [0..255] 12 | function ARC4init(key) { 13 | var i, j, t; 14 | for(i = 0; i < 256; ++i) 15 | this.S[i] = i; 16 | j = 0; 17 | for(i = 0; i < 256; ++i) { 18 | j = (j + this.S[i] + key[i % key.length]) & 255; 19 | t = this.S[i]; 20 | this.S[i] = this.S[j]; 21 | this.S[j] = t; 22 | } 23 | this.i = 0; 24 | this.j = 0; 25 | } 26 | 27 | function ARC4next() { 28 | var t; 29 | this.i = (this.i + 1) & 255; 30 | this.j = (this.j + this.S[this.i]) & 255; 31 | t = this.S[this.i]; 32 | this.S[this.i] = this.S[this.j]; 33 | this.S[this.j] = t; 34 | return this.S[(t + this.S[this.i]) & 255]; 35 | } 36 | 37 | Arcfour.prototype.init = ARC4init; 38 | Arcfour.prototype.next = ARC4next; 39 | 40 | // Plug in your RNG constructor here 41 | function prng_newstate() { 42 | return new Arcfour(); 43 | } 44 | 45 | // Pool size must be a multiple of 4 and greater than 32. 46 | // An array of bytes the size of the pool will be passed to init() 47 | var rng_psize = 256; 48 | -------------------------------------------------------------------------------- /jsrsasign/ext/rng-min.js: -------------------------------------------------------------------------------- 1 | /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ 2 | */ 3 | var rng_state;var rng_pool;var rng_pptr;function rng_seed_int(a){rng_pool[rng_pptr++]^=a&255;rng_pool[rng_pptr++]^=(a>>8)&255;rng_pool[rng_pptr++]^=(a>>16)&255;rng_pool[rng_pptr++]^=(a>>24)&255;if(rng_pptr>=rng_psize){rng_pptr-=rng_psize}}function rng_seed_time(){rng_seed_int(new Date().getTime())}if(rng_pool==null){rng_pool=new Array();rng_pptr=0;var t;if(window!==undefined&&(window.crypto!==undefined||window.msCrypto!==undefined)){var crypto=window.crypto||window.msCrypto;if(crypto.getRandomValues){var ua=new Uint8Array(32);crypto.getRandomValues(ua);for(t=0;t<32;++t){rng_pool[rng_pptr++]=ua[t]}}else{if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var z=window.crypto.random(32);for(t=0;t>>8;rng_pool[rng_pptr++]=t&255}rng_pptr=0;rng_seed_time()}function rng_get_byte(){if(rng_state==null){rng_seed_time();rng_state=prng_newstate();rng_state.init(rng_pool);for(rng_pptr=0;rng_pptr 7 | // in your main HTML document. 8 | 9 | var rng_state; 10 | var rng_pool; 11 | var rng_pptr; 12 | 13 | // Mix in a 32-bit integer into the pool 14 | function rng_seed_int(x) { 15 | rng_pool[rng_pptr++] ^= x & 255; 16 | rng_pool[rng_pptr++] ^= (x >> 8) & 255; 17 | rng_pool[rng_pptr++] ^= (x >> 16) & 255; 18 | rng_pool[rng_pptr++] ^= (x >> 24) & 255; 19 | if(rng_pptr >= rng_psize) rng_pptr -= rng_psize; 20 | } 21 | 22 | // Mix in the current time (w/milliseconds) into the pool 23 | function rng_seed_time() { 24 | rng_seed_int(new Date().getTime()); 25 | } 26 | 27 | // Initialize the pool with junk if needed. 28 | if (rng_pool == null) { 29 | rng_pool = new Array(); 30 | rng_pptr = 0; 31 | var t; 32 | if (window !== undefined && 33 | (window.crypto !== undefined || 34 | window.msCrypto !== undefined)) { 35 | var crypto = window.crypto || window.msCrypto; 36 | if (crypto.getRandomValues) { 37 | // Use webcrypto if available 38 | var ua = new Uint8Array(32); 39 | crypto.getRandomValues(ua); 40 | for(t = 0; t < 32; ++t) 41 | rng_pool[rng_pptr++] = ua[t]; 42 | } else if (navigator.appName == "Netscape" && navigator.appVersion < "5") { 43 | // Extract entropy (256 bits) from NS4 RNG if available 44 | var z = window.crypto.random(32); 45 | for(t = 0; t < z.length; ++t) 46 | rng_pool[rng_pptr++] = z.charCodeAt(t) & 255; 47 | } 48 | } 49 | while (rng_pptr < rng_psize) { // extract some randomness from Math.random() 50 | t = Math.floor(65536 * Math.random()); 51 | rng_pool[rng_pptr++] = t >>> 8; 52 | rng_pool[rng_pptr++] = t & 255; 53 | } 54 | rng_pptr = 0; 55 | rng_seed_time(); 56 | //rng_seed_int(window.screenX); 57 | //rng_seed_int(window.screenY); 58 | } 59 | 60 | function rng_get_byte() { 61 | if (rng_state == null) { 62 | rng_seed_time(); 63 | rng_state = prng_newstate(); 64 | rng_state.init(rng_pool); 65 | for(rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr) 66 | rng_pool[rng_pptr] = 0; 67 | rng_pptr = 0; 68 | //rng_pool = null; 69 | } 70 | // TODO: allow reseeding after first request 71 | return rng_state.next(); 72 | } 73 | 74 | function rng_get_bytes(ba) { 75 | var i; 76 | for (i = 0; i < ba.length; ++i) ba[i] = rng_get_byte(); 77 | } 78 | 79 | function SecureRandom() {} 80 | 81 | SecureRandom.prototype.nextBytes = rng_get_bytes; 82 | -------------------------------------------------------------------------------- /jsrsasign/ext/rsa-min.js: -------------------------------------------------------------------------------- 1 | /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ 2 | */ 3 | function parseBigInt(b,a){return new BigInteger(b,a)}function linebrk(c,d){var a="";var b=0;while(b+d=0&&h>0){var f=e.charCodeAt(d--);if(f<128){g[--h]=f}else{if((f>127)&&(f<2048)){g[--h]=(f&63)|128;g[--h]=(f>>6)|192}else{g[--h]=(f&63)|128;g[--h]=((f>>6)&63)|128;g[--h]=(f>>12)|224}}}g[--h]=0;var b=new SecureRandom();var a=new Array();while(h>2){a[0]=0;while(a[0]==0){b.nextBytes(a)}g[--h]=a[0]}g[--h]=2;g[--h]=0;return new BigInteger(g)}function oaep_mgf1_arr(c,a,e){var b="",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255])));d+=1}return b}function oaep_pad(q,a,f,l){var c=KJUR.crypto.MessageDigest;var o=KJUR.crypto.Util;var b=null;if(!f){f="sha1"}if(typeof f==="string"){b=c.getCanonicalAlgName(f);l=c.getHashLength(b);f=function(i){return hextorstr(o.hashHex(rstrtohex(i),b))}}if(q.length+2*l+2>a){throw"Message too long for RSA"}var k="",e;for(e=0;e0&&a.length>0){this.n=parseBigInt(b,16);this.e=parseInt(a,16)}else{throw"Invalid RSA public key"}}}function RSADoPublic(a){return a.modPowInt(this.e,this.n)}function RSAEncrypt(d){var a=pkcs1pad2(d,(this.n.bitLength()+7)>>3);if(a==null){return null}var e=this.doPublic(a);if(e==null){return null}var b=e.toString(16);if((b.length&1)==0){return b}else{return"0"+b}}function RSAEncryptOAEP(f,e,b){var a=oaep_pad(f,(this.n.bitLength()+7)>>3,e,b);if(a==null){return null}var g=this.doPublic(a);if(g==null){return null}var d=g.toString(16);if((d.length&1)==0){return d}else{return"0"+d}}RSAKey.prototype.doPublic=RSADoPublic;RSAKey.prototype.setPublic=RSASetPublic;RSAKey.prototype.encrypt=RSAEncrypt;RSAKey.prototype.encryptOAEP=RSAEncryptOAEP;RSAKey.prototype.type="RSA"; -------------------------------------------------------------------------------- /jsrsasign/footer.js: -------------------------------------------------------------------------------- 1 | export { SecureRandom }; 2 | export { rng_seed_time }; 3 | 4 | export { BigInteger }; 5 | export { RSAKey }; 6 | export const { EDSA } = KJUR.crypto; 7 | export const { DSA } = KJUR.crypto; 8 | export const { Signature } = KJUR.crypto; 9 | export const { MessageDigest } = KJUR.crypto; 10 | export const { Mac } = KJUR.crypto; 11 | export const { Cipher } = KJUR.crypto; 12 | export { KEYUTIL }; 13 | export { ASN1HEX }; 14 | export { X509 }; 15 | export { CryptoJS }; 16 | 17 | // ext/base64.js 18 | export { b64tohex }; 19 | export { b64toBA }; 20 | 21 | // base64x.js 22 | export { stoBA }; 23 | export { BAtos }; 24 | export { BAtohex }; 25 | export { stohex }; 26 | export { stob64 }; 27 | export { stob64u }; 28 | export { b64utos }; 29 | export { b64tob64u }; 30 | export { b64utob64 }; 31 | export { hex2b64 }; 32 | export { hextob64u }; 33 | export { b64utohex }; 34 | export { utf8tob64u }; 35 | export { b64utoutf8 }; 36 | export { utf8tob64 }; 37 | export { b64toutf8 }; 38 | export { utf8tohex }; 39 | export { hextoutf8 }; 40 | export { hextorstr }; 41 | export { rstrtohex }; 42 | export { hextob64 }; 43 | export { hextob64nl }; 44 | export { b64nltohex }; 45 | export { hextopem }; 46 | export { pemtohex }; 47 | export { hextoArrayBuffer }; 48 | export { ArrayBuffertohex }; 49 | export { zulutomsec }; 50 | export { zulutosec }; 51 | export { zulutodate }; 52 | export { datetozulu }; 53 | export { uricmptohex }; 54 | export { hextouricmp }; 55 | export { ipv6tohex }; 56 | export { hextoipv6 }; 57 | export { hextoip }; 58 | export { iptohex }; 59 | export { encodeURIComponentAll }; 60 | export { newline_toUnix }; 61 | export { newline_toDos }; 62 | export { hextoposhex }; 63 | export { intarystrtohex }; 64 | export { strdiffidx }; 65 | 66 | // name spaces 67 | export { KJUR }; 68 | const _crypto = KJUR.crypto; 69 | export { _crypto as crypto }; 70 | export const { asn1 } = KJUR; 71 | export const { jws } = KJUR; 72 | export const { lang } = KJUR; 73 | 74 | 75 | -------------------------------------------------------------------------------- /jsrsasign/header.js: -------------------------------------------------------------------------------- 1 | /* 2 | * jsrsasign(all) 8.0.12 (2018-04-22) (c) 2010-2018 Kenji Urushima | kjur.github.com/jsrsasign/license 3 | */ 4 | 5 | var navigator = {}; 6 | navigator.userAgent = false; 7 | 8 | var window = {}; 9 | -------------------------------------------------------------------------------- /jsrsasign/min/asn1csr-1.0.min.js: -------------------------------------------------------------------------------- 1 | if(typeof KJUR.asn1.csr=="undefined"||!KJUR.asn1.csr){KJUR.asn1.csr={}}KJUR.asn1.csr.CertificationRequest=function(g){var d=KJUR,c=d.asn1,e=c.DERBitString,b=c.DERSequence,a=c.csr,f=c.x509,h=a.CertificationRequestInfo;a.CertificationRequest.superclass.constructor.call(this);this.setByParam=function(i){this.params=i};this.sign=function(){var j=(new h(this.params)).getEncodedHex();var k=new KJUR.crypto.Signature({alg:this.params.sigalg});k.init(this.params.sbjprvkey);k.updateHex(j);var i=k.sign();this.params.sighex=i};this.getPEM=function(){return hextopem(this.getEncodedHex(),"CERTIFICATE REQUEST")};this.getEncodedHex=function(){var l=this.params;var j=new KJUR.asn1.csr.CertificationRequestInfo(this.params);var m=new KJUR.asn1.x509.AlgorithmIdentifier({name:l.sigalg});if(l.sighex==undefined&&l.sbjprvkey!=undefined){this.sign()}if(l.sighex==undefined){throw new Error("sighex or sbjprvkey parameter not defined")}var k=new e({hex:"00"+l.sighex});var i=new b({array:[j,m,k]});return i.getEncodedHex()};if(g!==undefined){this.setByParam(g)}};extendClass(KJUR.asn1.csr.CertificationRequest,KJUR.asn1.ASN1Object);KJUR.asn1.csr.CertificationRequestInfo=function(f){var b=KJUR,j=b.asn1,c=j.DERBitString,g=j.DERSequence,i=j.DERInteger,n=j.DERUTF8String,d=j.DERTaggedObject,h=j.ASN1Util.newObject,l=j.csr,e=j.x509,a=e.X500Name,k=e.Extensions,m=e.SubjectPublicKeyInfo;l.CertificationRequestInfo.superclass.constructor.call(this);this.params=null;this.setByParam=function(o){if(o!=undefined){this.params=o}};this.getEncodedHex=function(){var s=this.params;var p=[];p.push(new i({"int":0}));p.push(new a(s.subject));p.push(new m(KEYUTIL.getKey(s.sbjpubkey)));if(s.extreq!=undefined){var o=new k(s.extreq);var r=h({tag:{tag:"a0",explict:true,obj:{seq:[{oid:"1.2.840.113549.1.9.14"},{set:[o]}]}}});p.push(r)}else{p.push(new d({tag:"a0",explicit:false,obj:new n({str:""})}))}var q=new g({array:p});return q.getEncodedHex()};if(f!=undefined){this.setByParam(f)}};extendClass(KJUR.asn1.csr.CertificationRequestInfo,KJUR.asn1.ASN1Object);KJUR.asn1.csr.CSRUtil=new function(){};KJUR.asn1.csr.CSRUtil.newCSRPEM=function(e){var b=KEYUTIL,a=KJUR.asn1.csr;var c=new a.CertificationRequest(e);var d=c.getPEM();return d};KJUR.asn1.csr.CSRUtil.getParam=function(c){var m=ASN1HEX,j=m.getV;_getIdxbyList=m.getIdxbyList;_getTLVbyList=m.getTLVbyList,_getTLVbyListEx=m.getTLVbyListEx,_getVbyListEx=m.getVbyListEx;var b=function(p){var o=_getIdxbyList(p,0,[0,3,0,0],"06");if(j(p,o)!="2a864886f70d01090e"){return null}return _getTLVbyList(p,0,[0,3,0,1,0],"30")};var n={};if(c.indexOf("-----BEGIN CERTIFICATE REQUEST")==-1){throw new Error("argument is not PEM file")}var e=pemtohex(c,"CERTIFICATE REQUEST");try{var g=_getTLVbyListEx(e,0,[0,1]);if(g=="3000"){n.subject={}}else{var k=new X509();n.subject=k.getX500Name(g)}}catch(h){}var d=_getTLVbyListEx(e,0,[0,2]);var f=KEYUTIL.getKey(d,null,"pkcs8pub");n.sbjpubkey=KEYUTIL.getPEM(f,"PKCS8PUB");var i=b(e);var k=new X509();if(i!=null){n.extreq=k.getExtParamArray(i)}try{var a=_getTLVbyListEx(e,0,[1],"30");var k=new X509();n.sigalg=k.getAlgorithmIdentifierName(a)}catch(h){}try{var l=_getVbyListEx(e,0,[2]);n.sighex=l}catch(h){}return n}; -------------------------------------------------------------------------------- /jsrsasign/min/dsa-2.0.min.js: -------------------------------------------------------------------------------- 1 | if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.crypto=="undefined"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.DSA=function(){var b=ASN1HEX,e=b.getVbyList,d=b.getVbyListEx,a=b.isASN1HEX,c=BigInteger;this.p=null;this.q=null;this.g=null;this.y=null;this.x=null;this.type="DSA";this.isPrivate=false;this.isPublic=false;this.setPrivate=function(j,i,h,k,f){this.isPrivate=true;this.p=j;this.q=i;this.g=h;this.y=k;this.x=f};this.setPrivateHex=function(i,g,k,n,o){var h,f,j,l,m;h=new BigInteger(i,16);f=new BigInteger(g,16);j=new BigInteger(k,16);if(typeof n==="string"&&n.length>1){l=new BigInteger(n,16)}else{l=null}m=new BigInteger(o,16);this.setPrivate(h,f,j,l,m)};this.setPublic=function(i,h,f,j){this.isPublic=true;this.p=i;this.q=h;this.g=f;this.y=j;this.x=null};this.setPublicHex=function(k,j,i,l){var g,f,m,h;g=new BigInteger(k,16);f=new BigInteger(j,16);m=new BigInteger(i,16);h=new BigInteger(l,16);this.setPublic(g,f,m,h)};this.signWithMessageHash=function(j){var i=this.p;var h=this.q;var m=this.g;var o=this.y;var t=this.x;var l=KJUR.crypto.Util.getRandomBigIntegerMinToMax(BigInteger.ONE.add(BigInteger.ONE),h.subtract(BigInteger.ONE));var u=j.substr(0,h.bitLength()/4);var n=new BigInteger(u,16);var f=(m.modPow(l,i)).mod(h);var w=(l.modInverse(h).multiply(n.add(t.multiply(f)))).mod(h);var v=KJUR.asn1.ASN1Util.jsonToASN1HEX({seq:[{"int":{bigint:f}},{"int":{bigint:w}}]});return v};this.verifyWithMessageHash=function(m,l){var j=this.p;var h=this.q;var o=this.g;var u=this.y;var n=this.parseASN1Signature(l);var f=n[0];var C=n[1];var B=m.substr(0,h.bitLength()/4);var t=new BigInteger(B,16);if(BigInteger.ZERO.compareTo(f)>0||f.compareTo(h)>0){throw"invalid DSA signature"}if(BigInteger.ZERO.compareTo(C)>=0||C.compareTo(h)>0){throw"invalid DSA signature"}var x=C.modInverse(h);var k=t.multiply(x).mod(h);var i=f.multiply(x).mod(h);var A=o.modPow(k,j).multiply(u.modPow(i,j)).mod(j).mod(h);return A.compareTo(f)==0};this.parseASN1Signature=function(f){try{var i=new c(d(f,0,[0],"02"),16);var h=new c(d(f,0,[1],"02"),16);return[i,h]}catch(g){throw new Error("malformed ASN.1 DSA signature")}};this.readPKCS5PrvKeyHex=function(j){var k,i,g,l,m;if(a(j)===false){throw new Error("not ASN.1 hex string")}try{k=d(j,0,[1],"02");i=d(j,0,[2],"02");g=d(j,0,[3],"02");l=d(j,0,[4],"02");m=d(j,0,[5],"02")}catch(f){throw new Error("malformed PKCS#1/5 plain DSA private key")}this.setPrivateHex(k,i,g,l,m)};this.readPKCS8PrvKeyHex=function(j){var k,i,g,l;if(a(j)===false){throw new Error("not ASN.1 hex string")}try{k=d(j,0,[1,1,0],"02");i=d(j,0,[1,1,1],"02");g=d(j,0,[1,1,2],"02");l=d(j,0,[2,0],"02")}catch(f){throw new Error("malformed PKCS#8 plain DSA private key")}this.setPrivateHex(k,i,g,null,l)};this.readPKCS8PubKeyHex=function(j){var k,i,g,l;if(a(j)===false){throw new Error("not ASN.1 hex string")}try{k=d(j,0,[0,1,0],"02");i=d(j,0,[0,1,1],"02");g=d(j,0,[0,1,2],"02");l=d(j,0,[1,0],"02")}catch(f){throw new Error("malformed PKCS#8 DSA public key")}this.setPublicHex(k,i,g,l)};this.readCertPubKeyHex=function(j,m){var k,i,g,l;if(a(j)===false){throw new Error("not ASN.1 hex string")}try{k=d(j,0,[0,5,0,1,0],"02");i=d(j,0,[0,5,0,1,1],"02");g=d(j,0,[0,5,0,1,2],"02");l=d(j,0,[0,5,1,0],"02")}catch(f){throw new Error("malformed X.509 certificate DSA public key")}this.setPublicHex(k,i,g,l)}}; -------------------------------------------------------------------------------- /jsrsasign/min/jwsjs-2.0.min.js: -------------------------------------------------------------------------------- 1 | if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.jws=="undefined"||!KJUR.jws){KJUR.jws={}}KJUR.jws.JWSJS=function(){var c=KJUR,b=c.jws,a=b.JWS,d=a.readSafeJSONString;this.aHeader=[];this.sPayload="";this.aSignature=[];this.init=function(){this.aHeader=[];this.sPayload=undefined;this.aSignature=[]};this.initWithJWS=function(f){this.init();var e=f.split(".");if(e.length!=3){throw"malformed input JWS"}this.aHeader.push(e[0]);this.sPayload=e[1];this.aSignature.push(e[2])};this.addSignature=function(e,h,m,k){if(this.sPayload===undefined||this.sPayload===null){throw"there's no JSON-JS signature to add."}var l=this.aHeader.length;if(this.aHeader.length!=this.aSignature.length){throw"aHeader.length != aSignature.length"}try{var f=KJUR.jws.JWS.sign(e,h,this.sPayload,m,k);var j=f.split(".");var n=j[0];var g=j[2];this.aHeader.push(j[0]);this.aSignature.push(j[2])}catch(i){if(this.aHeader.length>l){this.aHeader.pop()}if(this.aSignature.length>l){this.aSignature.pop()}throw"addSignature failed: "+i}};this.verifyAll=function(h){if(this.aHeader.length!==h.length||this.aSignature.length!==h.length){return false}for(var g=0;g0){this.aHeader=g.headers}else{throw"malformed header"}if(typeof g.payload==="string"){this.sPayload=g.payload}else{throw"malformed signatures"}if(g.signatures.length>0){this.aSignature=g.signatures}else{throw"malformed signatures"}}catch(e){throw"malformed JWS-JS JSON object: "+e}}};this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}};this.isEmpty=function(){if(this.aHeader.length==0){return 1}return 0}}; -------------------------------------------------------------------------------- /jsrsasign/min/nodeutil-1.0.min.js: -------------------------------------------------------------------------------- 1 | var fs=require("fs");var JSONC=require("jsonc-parser");var rs=require("jsrsasign");function readFileUTF8(a){return require("fs").readFileSync(a,"utf8")}function readFileHexByBin(a){return rs.rstrtohex(fs.readFileSync(a,"binary"))}function readFile(a){return fs.readFileSync(a,"binary")}function saveFile(c,b){var a=require("fs");a.writeFileSync(c,b,"binary")}function saveFileUTF8(c,b){var a=require("fs");a.writeFileSync(c,b,"utf8")}function saveFileBinByHex(c,a){var b=rs.hextorstr(a);fs.writeFileSync(c,b,"binary")}function readJSON(b){var a=fs.readFileSync(b,"utf8");var c=JSON.parse(a);return c}function readJSONC(b){var a=fs.readFileSync(b,"utf8");var c=JSONC.parse(a);return c}function saveFileJSON(a,b){var c=JSON.stringify(b,null," ");saveFileUTF8(a,c)}function printJSON(a,c){var b="";if(c!=undefined){b=c}console.log(b+JSON.stringify(a,null," "))}; -------------------------------------------------------------------------------- /jsrsasign/min/rsapem-1.1.min.js: -------------------------------------------------------------------------------- 1 | RSAKey.getPosArrayOfChildrenFromHex=function(a){return ASN1HEX.getChildIdx(a,0)};RSAKey.getHexValueArrayOfChildrenFromHex=function(f){var n=ASN1HEX;var i=n.getV;var k=RSAKey.getPosArrayOfChildrenFromHex(f);var e=i(f,k[0]);var j=i(f,k[1]);var b=i(f,k[2]);var c=i(f,k[3]);var h=i(f,k[4]);var g=i(f,k[5]);var m=i(f,k[6]);var l=i(f,k[7]);var d=i(f,k[8]);var k=new Array();k.push(e,j,b,c,h,g,m,l,d);return k};RSAKey.prototype.readPrivateKeyFromPEMString=function(d){var c=pemtohex(d);var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS5PrvKeyHex=function(c){var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS8PrvKeyHex=function(e){var c,i,k,b,a,f,d,j;var m=ASN1HEX;var l=m.getVbyListEx;if(m.isASN1HEX(e)===false){throw new Error("not ASN.1 hex string")}try{c=l(e,0,[2,0,1],"02");i=l(e,0,[2,0,2],"02");k=l(e,0,[2,0,3],"02");b=l(e,0,[2,0,4],"02");a=l(e,0,[2,0,5],"02");f=l(e,0,[2,0,6],"02");d=l(e,0,[2,0,7],"02");j=l(e,0,[2,0,8],"02")}catch(g){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(c,i,k,b,a,f,d,j)};RSAKey.prototype.readPKCS5PubKeyHex=function(c){var e=ASN1HEX;var b=e.getV;if(e.isASN1HEX(c)===false){throw new Error("keyHex is not ASN.1 hex string")}var a=e.getChildIdx(c,0);if(a.length!==2||c.substr(a[0],2)!=="02"||c.substr(a[1],2)!=="02"){throw new Error("wrong hex for PKCS#5 public key")}var f=b(c,a[0]);var d=b(c,a[1]);this.setPublic(f,d)};RSAKey.prototype.readPKCS8PubKeyHex=function(b){var c=ASN1HEX;if(c.isASN1HEX(b)===false){throw new Error("not ASN.1 hex string")}if(c.getTLVbyListEx(b,0,[0,0])!=="06092a864886f70d010101"){throw new Error("not PKCS8 RSA public key")}var a=c.getTLVbyListEx(b,0,[1,0]);this.readPKCS5PubKeyHex(a)};RSAKey.prototype.readCertPubKeyHex=function(b,d){var a,c;a=new X509();a.readCertHex(b);c=a.getPublicKeyHex();this.readPKCS8PubKeyHex(c)}; -------------------------------------------------------------------------------- /jsrsasign/min/x509crl.min.js: -------------------------------------------------------------------------------- 1 | var X509CRL=function(e){var a=KJUR,f=a.lang.String.isHex,m=ASN1HEX,k=m.getV,b=m.getTLV,h=m.getVbyList,c=m.getTLVbyList,d=m.getTLVbyListEx,i=m.getIdxbyList,g=m.getIdxbyListEx,l=m.getChildIdx,j=new X509();this.hex=null;this.posSigAlg=null;this.posRevCert=null;this._setPos=function(){var o=i(this.hex,0,[0,0]);var n=this.hex.substr(o,2);if(n=="02"){this.posSigAlg=1}else{if(n=="30"){this.posSigAlg=0}else{throw new Error("malformed 1st item of TBSCertList: "+n)}}var s=i(this.hex,0,[0,this.posSigAlg+3]);var r=this.hex.substr(s,2);if(r=="17"||r=="18"){var q,p;q=i(this.hex,0,[0,this.posSigAlg+4]);this.posRevCert=null;if(q!=-1){p=this.hex.substr(q,2);if(p=="30"){this.posRevCert=this.posSigAlg+4}}}else{if(r=="30"){this.posRevCert=this.posSigAlg+3}else{if(r=="a0"){this.posRevCert=null}else{throw new Error("malformed nextUpdate or revCert tag: "+r)}}}};this.getVersion=function(){if(this.posSigAlg==0){return null}return parseInt(h(this.hex,0,[0,0],"02"),16)+1};this.getSignatureAlgorithmField=function(){var n=c(this.hex,0,[0,this.posSigAlg],"30");return j.getAlgorithmIdentifierName(n)};this.getIssuer=function(){var n=c(this.hex,0,[0,this.posSigAlg+1],"30");return j.getX500Name(n)};this.getThisUpdate=function(){var n=h(this.hex,0,[0,this.posSigAlg+2]);return result=hextorstr(n)};this.getNextUpdate=function(){var o=i(this.hex,0,[0,this.posSigAlg+3]);var n=this.hex.substr(o,2);if(n!="17"&&n!="18"){return null}return hextorstr(k(this.hex,o))};this.getRevCertArray=function(){if(this.posRevCert==null){return null}var o=[];var n=i(this.hex,0,[0,this.posRevCert]);var p=l(this.hex,n);for(var q=0;q { 4 | let page: AppPage; 5 | 6 | beforeEach(() => { 7 | page = new AppPage(); 8 | }); 9 | 10 | it('should display welcome message', () => { 11 | page.navigateTo(); 12 | expect(page.getParagraphText()).toEqual('Welcome to app!'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /samples/Angular/App/e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getParagraphText() { 9 | return element(by.css('app-root h1')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /samples/Angular/App/e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } -------------------------------------------------------------------------------- /samples/Angular/App/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "app", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "start:prod": "ng serve --prod", 8 | "build": "ng build", 9 | "test": "ng test", 10 | "lint": "ng lint", 11 | "e2e": "ng e2e" 12 | }, 13 | "private": true, 14 | "dependencies": { 15 | "@angular/animations": "~8.2.14", 16 | "@angular/common": "~8.2.14", 17 | "@angular/compiler": "~8.2.14", 18 | "@angular/core": "~8.2.14", 19 | "@angular/forms": "~8.2.14", 20 | "@angular/platform-browser": "~8.2.14", 21 | "@angular/platform-browser-dynamic": "~8.2.14", 22 | "@angular/router": "~8.2.14", 23 | "core-js": "^2.5.4", 24 | "oidc-client": "^1.9.1", 25 | "rxjs": "~6.5.3", 26 | "tslib": "^1.9.0", 27 | "zone.js": "~0.9.1" 28 | }, 29 | "devDependencies": { 30 | "@angular-devkit/build-angular": "~0.803.20", 31 | "@angular/cli": "~8.3.20", 32 | "@angular/compiler-cli": "~8.2.14", 33 | "@angular/language-service": "~8.2.14", 34 | "@types/node": "~8.9.4", 35 | "@types/jasmine": "~2.8.8", 36 | "@types/jasminewd2": "~2.0.3", 37 | "codelyzer": "~4.5.0", 38 | "jasmine-core": "~2.99.1", 39 | "jasmine-spec-reporter": "~4.2.1", 40 | "karma": "~4.0.0", 41 | "karma-chrome-launcher": "~2.2.0", 42 | "karma-coverage-istanbul-reporter": "~2.0.1", 43 | "karma-jasmine": "~1.1.2", 44 | "karma-jasmine-html-reporter": "^0.2.2", 45 | "protractor": "~5.4.0", 46 | "ts-node": "~7.0.0", 47 | "tslint": "~5.11.0", 48 | "typescript": "~3.5.3" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /samples/Angular/App/src/app/app.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuendeArchive/identity-model-oidc-client-js/edec8f59897bdeedcb0b4167586d49626203c2c1/samples/Angular/App/src/app/app.component.css -------------------------------------------------------------------------------- /samples/Angular/App/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |

4 | Sample Angular Client 5 |

6 |
7 |
8 | 9 | 10 | 11 | 12 |
13 |
{{currentUserJson}}
14 |
15 |

Messages

16 |
    17 |
  • {{msg}}
  • 18 |
19 |
-------------------------------------------------------------------------------- /samples/Angular/App/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | import { AppComponent } from './app.component'; 3 | describe('AppComponent', () => { 4 | beforeEach(async(() => { 5 | TestBed.configureTestingModule({ 6 | declarations: [ 7 | AppComponent 8 | ], 9 | }).compileComponents(); 10 | })); 11 | it('should create the app', async(() => { 12 | const fixture = TestBed.createComponent(AppComponent); 13 | const app = fixture.debugElement.componentInstance; 14 | expect(app).toBeTruthy(); 15 | })); 16 | it(`should have as title 'app'`, async(() => { 17 | const fixture = TestBed.createComponent(AppComponent); 18 | const app = fixture.debugElement.componentInstance; 19 | expect(app.title).toEqual('app'); 20 | })); 21 | it('should render title in a h1 tag', async(() => { 22 | const fixture = TestBed.createComponent(AppComponent); 23 | fixture.detectChanges(); 24 | const compiled = fixture.debugElement.nativeElement; 25 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to App!'); 26 | })); 27 | }); 28 | -------------------------------------------------------------------------------- /samples/Angular/App/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | import { AuthService, User } from './core/services/auth.service'; 4 | import { TestApiService } from './core/services/test-api.service'; 5 | 6 | @Component({ 7 | selector: 'app-root', 8 | templateUrl: './app.component.html', 9 | styleUrls: ['./app.component.css'] 10 | }) 11 | export class AppComponent implements OnInit { 12 | constructor(public authService: AuthService, public apiService: TestApiService) { 13 | } 14 | 15 | messages: string[] = []; 16 | get currentUserJson(): string { 17 | return JSON.stringify(this.currentUser, null, 2); 18 | } 19 | currentUser: User; 20 | 21 | ngOnInit(): void { 22 | this.authService.getUser().then(user => { 23 | this.currentUser = user; 24 | 25 | if (user) { 26 | this.addMessage('User Logged In'); 27 | } else { 28 | this.addMessage('User Not Logged In'); 29 | } 30 | }).catch(err => this.addError(err)); 31 | } 32 | 33 | clearMessages() { 34 | while (this.messages.length) { 35 | this.messages.pop(); 36 | } 37 | } 38 | addMessage(msg: string) { 39 | this.messages.push(msg); 40 | } 41 | addError(msg: string | any) { 42 | this.messages.push('Error: ' + msg && msg.message); 43 | } 44 | 45 | public onLogin() { 46 | this.clearMessages(); 47 | this.authService.login().catch(err => { 48 | this.addError(err); 49 | }); 50 | } 51 | 52 | public onCallAPI() { 53 | this.clearMessages(); 54 | this.apiService.callApi().then(result => { 55 | this.addMessage('API Result: ' + JSON.stringify(result)); 56 | }, err => this.addError(err)); 57 | } 58 | 59 | public onRenewToken() { 60 | this.clearMessages(); 61 | this.authService.renewToken() 62 | .then(user => { 63 | this.currentUser = user; 64 | this.addMessage('Silent Renew Success'); 65 | }) 66 | .catch(err => this.addError(err)); 67 | } 68 | 69 | public onLogout() { 70 | this.clearMessages(); 71 | this.authService.logout().catch(err => this.addError(err)); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /samples/Angular/App/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { HttpClientModule } from '@angular/common/http'; 2 | import { NgModule } from '@angular/core'; 3 | import { BrowserModule } from '@angular/platform-browser'; 4 | 5 | import { AppComponent } from './app.component'; 6 | 7 | @NgModule({ 8 | declarations: [ 9 | AppComponent 10 | ], 11 | imports: [ 12 | BrowserModule, 13 | HttpClientModule 14 | ], 15 | providers: [], 16 | bootstrap: [AppComponent] 17 | }) 18 | export class AppModule { } 19 | -------------------------------------------------------------------------------- /samples/Angular/App/src/app/core/services/auth.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { inject, TestBed } from '@angular/core/testing'; 2 | 3 | import { AuthService } from './auth.service'; 4 | 5 | describe('AuthService', () => { 6 | beforeEach(() => { 7 | TestBed.configureTestingModule({ 8 | providers: [AuthService] 9 | }); 10 | }); 11 | 12 | it('should be created', inject([AuthService], (service: AuthService) => { 13 | expect(service).toBeTruthy(); 14 | })); 15 | }); 16 | -------------------------------------------------------------------------------- /samples/Angular/App/src/app/core/services/auth.service.ts: -------------------------------------------------------------------------------- 1 | import { User, UserManager, UserManagerSettings } from 'oidc-client'; 2 | import { environment } from 'src/environments/environment'; 3 | 4 | import { Injectable } from '@angular/core'; 5 | 6 | export { User }; 7 | 8 | @Injectable({ 9 | providedIn: 'root' 10 | }) 11 | export class AuthService { 12 | 13 | userManager: UserManager; 14 | 15 | constructor() { 16 | const settings = { 17 | authority: environment.stsAuthority, 18 | client_id: environment.clientId, 19 | redirect_uri: `${environment.clientRoot}assets/signin-callback.html`, 20 | silent_redirect_uri: `${environment.clientRoot}assets/silent-callback.html`, 21 | post_logout_redirect_uri: `${environment.clientRoot}`, 22 | response_type: 'id_token token', 23 | scope: environment.clientScope 24 | }; 25 | this.userManager = new UserManager(settings); 26 | } 27 | 28 | public getUser(): Promise { 29 | return this.userManager.getUser(); 30 | } 31 | 32 | public login(): Promise { 33 | return this.userManager.signinRedirect(); 34 | } 35 | 36 | public renewToken(): Promise { 37 | return this.userManager.signinSilent(); 38 | } 39 | 40 | public logout(): Promise { 41 | return this.userManager.signoutRedirect(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /samples/Angular/App/src/app/core/services/test-api.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, inject } from '@angular/core/testing'; 2 | 3 | import { TestApiService } from './test-api.service'; 4 | 5 | describe('TestApiService', () => { 6 | beforeEach(() => { 7 | TestBed.configureTestingModule({ 8 | providers: [TestApiService] 9 | }); 10 | }); 11 | 12 | it('should be created', inject([TestApiService], (service: TestApiService) => { 13 | expect(service).toBeTruthy(); 14 | })); 15 | }); 16 | -------------------------------------------------------------------------------- /samples/Angular/App/src/app/core/services/test-api.service.ts: -------------------------------------------------------------------------------- 1 | import { Observable } from 'rxjs'; 2 | import { environment } from 'src/environments/environment'; 3 | 4 | import { HttpClient, HttpErrorResponse, HttpHeaders, HttpResponse } from '@angular/common/http'; 5 | import { Injectable } from '@angular/core'; 6 | 7 | import { AuthService, User } from './auth.service'; 8 | 9 | @Injectable({ 10 | providedIn: 'root' 11 | }) 12 | export class TestApiService { 13 | 14 | constructor(private httpClient: HttpClient, private authService: AuthService) { 15 | } 16 | 17 | public callApi(): Promise { 18 | return this.authService.getUser().then((user: User) => { 19 | if (user && user.access_token) { 20 | return this._callApi(user.access_token); 21 | } else if (user) { 22 | return this.authService.renewToken().then((user: User) => { 23 | return this._callApi(user.access_token); 24 | }); 25 | } else { 26 | throw new Error('user is not logged in'); 27 | } 28 | }); 29 | } 30 | 31 | _callApi(token: string) { 32 | const headers = new HttpHeaders({ 33 | Accept: 'application/json', 34 | Authorization: 'Bearer ' + token 35 | }); 36 | 37 | return this.httpClient.get(environment.apiRoot + 'test', { headers }) 38 | .toPromise() 39 | .catch((result: HttpErrorResponse) => { 40 | if (result.status === 401) { 41 | return this.authService.renewToken().then(user => { 42 | return this._callApi(user.access_token); 43 | }); 44 | } 45 | throw result; 46 | }); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /samples/Angular/App/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuendeArchive/identity-model-oidc-client-js/edec8f59897bdeedcb0b4167586d49626203c2c1/samples/Angular/App/src/assets/.gitkeep -------------------------------------------------------------------------------- /samples/Angular/App/src/assets/signin-callback.html: -------------------------------------------------------------------------------- 1 | 2 | 13 | -------------------------------------------------------------------------------- /samples/Angular/App/src/assets/silent-callback.html: -------------------------------------------------------------------------------- 1 | 2 | 8 | -------------------------------------------------------------------------------- /samples/Angular/App/src/browserslist: -------------------------------------------------------------------------------- 1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | # For IE 9-11 support, please uncomment the last line of the file and adjust as needed 5 | > 0.5% 6 | last 2 versions 7 | Firefox ESR 8 | not dead 9 | # IE 9-11 -------------------------------------------------------------------------------- /samples/Angular/App/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true, 3 | stsAuthority: 'https://demo.identityserver.io/', 4 | clientId: 'implicit', 5 | clientRoot: 'http://localhost:4200/', 6 | clientScope: 'openid profile email api', 7 | apiRoot: 'https://demo.identityserver.io/api/', 8 | }; 9 | -------------------------------------------------------------------------------- /samples/Angular/App/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false, 7 | stsAuthority: 'https://demo.identityserver.io/', 8 | clientId: 'implicit', 9 | clientRoot: 'http://localhost:4200/', 10 | clientScope: 'openid profile email api', 11 | apiRoot: 'https://demo.identityserver.io/api/', 12 | }; 13 | 14 | /* 15 | * In development mode, to ignore zone related error stack frames such as 16 | * `zone.run`, `zoneDelegate.invokeTask` for easier debugging, you can 17 | * import the following file, but please comment it out in production mode 18 | * because it will have performance impact when throw error 19 | */ 20 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 21 | -------------------------------------------------------------------------------- /samples/Angular/App/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuendeArchive/identity-model-oidc-client-js/edec8f59897bdeedcb0b4167586d49626203c2c1/samples/Angular/App/src/favicon.ico -------------------------------------------------------------------------------- /samples/Angular/App/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | App 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /samples/Angular/App/src/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../coverage/angular-seven-three-six'), 20 | reports: ['html', 'lcovonly', 'text-summary'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false, 30 | restartOnFileChange: true 31 | }); 32 | }; 33 | -------------------------------------------------------------------------------- /samples/Angular/App/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /samples/Angular/App/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | /*************************************************************************************************** 17 | * BROWSER POLYFILLS 18 | */ 19 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 20 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 21 | /** 22 | * Web Animations `@angular/platform-browser/animations` 23 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 24 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 25 | */ 26 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 27 | /** 28 | * By default, zone.js will patch all possible macroTask and DomEvents 29 | * user can disable parts of macroTask/DomEvents patch by setting following flags 30 | * because those flags need to be set before `zone.js` being loaded, and webpack 31 | * will put import in the top of bundle, so user need to create a separate file 32 | * in this directory (for example: zone-flags.ts), and put the following flags 33 | * into that file, and then add the following code before importing zone.js. 34 | * import './zone-flags.ts'; 35 | * 36 | * The flags allowed in zone-flags.ts are listed here. 37 | * 38 | * The following flags will work for all browsers. 39 | * 40 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 41 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 42 | * (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 43 | * 44 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 45 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 46 | * 47 | * (window as any).__Zone_enable_cross_context_check = true; 48 | * 49 | */ 50 | /*************************************************************************************************** 51 | * Zone JS is required by default for Angular itself. 52 | */ 53 | import 'zone.js/dist/zone'; // Included with Angular CLI. 54 | 55 | /*************************************************************************************************** 56 | * APPLICATION IMPORTS 57 | */ 58 | -------------------------------------------------------------------------------- /samples/Angular/App/src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /samples/Angular/App/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | import 'zone.js/dist/zone-testing'; 3 | 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, platformBrowserDynamicTesting 7 | } from '@angular/platform-browser-dynamic/testing'; 8 | 9 | declare const require: any; 10 | 11 | // First, initialize the Angular testing environment. 12 | getTestBed().initTestEnvironment( 13 | BrowserDynamicTestingModule, 14 | platformBrowserDynamicTesting() 15 | ); 16 | // Then we find all the tests. 17 | const context = require.context('./', true, /\.spec\.ts$/); 18 | // And load the modules. 19 | context.keys().map(context); 20 | -------------------------------------------------------------------------------- /samples/Angular/App/src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "types": [] 6 | }, 7 | "exclude": [ 8 | "test.ts", 9 | "**/*.spec.ts" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /samples/Angular/App/src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "test.ts", 12 | "polyfills.ts" 13 | ], 14 | "include": [ 15 | "**/*.spec.ts", 16 | "**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /samples/Angular/App/src/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "directive-selector": [ 5 | true, 6 | "attribute", 7 | "app", 8 | "camelCase" 9 | ], 10 | "component-selector": [ 11 | true, 12 | "element", 13 | "app", 14 | "kebab-case" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /samples/Angular/App/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "module": "es2015", 9 | "moduleResolution": "node", 10 | "emitDecoratorMetadata": true, 11 | "experimentalDecorators": true, 12 | "importHelpers": true, 13 | "target": "es5", 14 | "typeRoots": [ 15 | "node_modules/@types" 16 | ], 17 | "lib": [ 18 | "es2018", 19 | "dom" 20 | ] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /samples/Angular/App/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rulesDirectory": [ 4 | "codelyzer" 5 | ], 6 | "rules": { 7 | "array-type": false, 8 | "arrow-parens": false, 9 | "deprecation": { 10 | "severity": "warn" 11 | }, 12 | "import-blacklist": [ 13 | true, 14 | "rxjs/Rx" 15 | ], 16 | "interface-name": false, 17 | "max-classes-per-file": false, 18 | "max-line-length": [ 19 | true, 20 | 140 21 | ], 22 | "no-shadowed-variable": false, 23 | "member-access": false, 24 | "member-ordering": [ 25 | true, 26 | { 27 | "order": [ 28 | "static-field", 29 | "instance-field", 30 | "static-method", 31 | "instance-method" 32 | ] 33 | } 34 | ], 35 | "no-consecutive-blank-lines": false, 36 | "no-console": [ 37 | true, 38 | "debug", 39 | "info", 40 | "time", 41 | "timeEnd", 42 | "trace" 43 | ], 44 | "no-empty": false, 45 | "no-inferrable-types": [ 46 | true, 47 | "ignore-params" 48 | ], 49 | "no-non-null-assertion": true, 50 | "no-redundant-jsdoc": true, 51 | "no-switch-case-fall-through": true, 52 | "no-use-before-declare": true, 53 | "no-var-requires": false, 54 | "object-literal-key-quotes": [ 55 | true, 56 | "as-needed" 57 | ], 58 | "object-literal-sort-keys": false, 59 | "ordered-imports": false, 60 | "quotemark": [ 61 | true, 62 | "single" 63 | ], 64 | "trailing-comma": false, 65 | "no-output-on-prefix": true, 66 | "use-input-property-decorator": true, 67 | "use-output-property-decorator": true, 68 | "use-host-property-decorator": true, 69 | "no-input-rename": true, 70 | "no-output-rename": true, 71 | "use-life-cycle-interface": true, 72 | "use-pipe-transform-interface": true, 73 | "component-class-suffix": true, 74 | "directive-class-suffix": true 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /samples/Angular/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angularclient", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "devDependencies": { 12 | "@angular/cli": "^8.3.20" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples/VanillaJS/public/app.css: -------------------------------------------------------------------------------- 1 | pre { 2 | padding:10px; 3 | width: 100%; 4 | background-color: lightgray; 5 | } -------------------------------------------------------------------------------- /samples/VanillaJS/public/code-identityserver-sample-callback.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | oidc-client test 5 | 6 | 7 | 8 |
9 | back to sample 10 |
11 |

12 |         
13 |         
14 |         
15 |     
16 | 
17 | 


--------------------------------------------------------------------------------
/samples/VanillaJS/public/code-identityserver-sample-callback.js:
--------------------------------------------------------------------------------
1 | Oidc.Log.logger = console;
2 | Oidc.Log.level = Oidc.Log.DEBUG;
3 | new Oidc.UserManager({response_mode:'query'}).signinCallback().then(function(user) {
4 |     log("signin response success", user);
5 | }).catch(function(err) {
6 |     log(err);
7 | });
8 | 


--------------------------------------------------------------------------------
/samples/VanillaJS/public/code-identityserver-sample-popup-signin.html:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 | 
 4 | 
 5 |     identityserver test
 6 |     
 7 | 
 8 | 
 9 | 
10 |     
    11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /samples/VanillaJS/public/code-identityserver-sample-popup-signin.js: -------------------------------------------------------------------------------- 1 | var log = { 2 | debug:logMessage, warn: logMessage, info: logMessage, error:logMessage 3 | }; 4 | 5 | function logMessage(msg){ 6 | document.getElementById('logMessages').innerHTML += "
  • " + msg + "
  • "; 7 | console.log(msg); 8 | } 9 | 10 | Oidc.Log.logger = console; // log; 11 | Oidc.Log.level = Oidc.Log.DEBUG; 12 | 13 | new Oidc.UserManager({response_mode:'query'}).signinCallback().catch(function(err){ 14 | Oidc.Log.logger.error("error: " + err && err.message); 15 | }); 16 | -------------------------------------------------------------------------------- /samples/VanillaJS/public/code-identityserver-sample-popup-signout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | identityserver test 6 | 7 | 8 | 9 | 10 |

    Signed Out

    11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /samples/VanillaJS/public/code-identityserver-sample-popup-signout.js: -------------------------------------------------------------------------------- 1 | Oidc.Log.logger = console; 2 | Oidc.Log.level = Oidc.Log.INFO; 3 | // can pass true param and will keep popup window open 4 | new Oidc.UserManager().signoutCallback(); 5 | -------------------------------------------------------------------------------- /samples/VanillaJS/public/code-identityserver-sample-silent.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | identityserver test 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /samples/VanillaJS/public/code-identityserver-sample-silent.js: -------------------------------------------------------------------------------- 1 | Oidc.Log.logger = console; 2 | Oidc.Log.level = Oidc.Log.INFO; 3 | new Oidc.UserManager({response_mode:'query'}).signinCallback(); 4 | -------------------------------------------------------------------------------- /samples/VanillaJS/public/code-identityserver-sample.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | identityserver test against https://demo.identityserver.io/ 5 | 6 | 7 | 8 |
    9 | home 10 | clear url 11 |
    12 |
    13 | 14 | 15 | 16 | 17 |
    18 |
    19 | 20 | 21 | 22 |
    23 |
    24 | 25 | 26 |
    27 |
    28 | 29 | 30 |
    31 |
    32 | 33 |
    34 | 35 |
    
    36 |         
    37 |         
    38 |         
    39 |         
    40 |     
    41 | 
    42 | 
    
    
    --------------------------------------------------------------------------------
    /samples/VanillaJS/public/identityserver-sample-callback.html:
    --------------------------------------------------------------------------------
     1 | 
     2 | 
     3 |     
     4 |         oidc-client test
     5 |         
     6 |     
     7 |     
     8 |         
    9 | back to sample 10 |
    11 |
    
    12 |         
    13 |         
    14 |         
    15 |     
    16 | 
    17 | 
    
    
    --------------------------------------------------------------------------------
    /samples/VanillaJS/public/identityserver-sample-callback.js:
    --------------------------------------------------------------------------------
    1 | Oidc.Log.logger = console;
    2 | Oidc.Log.level = Oidc.Log.DEBUG;
    3 | new Oidc.UserManager().signinRedirectCallback().then(function(user) {
    4 |     log("signin response success", user);
    5 | }).catch(function(err) {
    6 |     log(err);
    7 | });
    8 | 
    
    
    --------------------------------------------------------------------------------
    /samples/VanillaJS/public/identityserver-sample-popup-signin.html:
    --------------------------------------------------------------------------------
     1 | 
     2 | 
     3 | 
     4 | 
     5 |     identityserver test
     6 |     
     7 | 
     8 | 
     9 | 
    10 |     
      11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /samples/VanillaJS/public/identityserver-sample-popup-signin.js: -------------------------------------------------------------------------------- 1 | var log = { 2 | debug:logMessage, warn: logMessage, info: logMessage, error:logMessage 3 | }; 4 | 5 | function logMessage(msg){ 6 | document.getElementById('logMessages').innerHTML += "
    • " + msg + "
    • "; 7 | console.log(msg); 8 | } 9 | 10 | Oidc.Log.logger = console; // log; 11 | Oidc.Log.level = Oidc.Log.DEBUG; 12 | 13 | new Oidc.UserManager().signinPopupCallback().catch(function(err){ 14 | Oidc.Log.logger.error("error: " + err && err.message); 15 | }); 16 | -------------------------------------------------------------------------------- /samples/VanillaJS/public/identityserver-sample-popup-signout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | identityserver test 6 | 7 | 8 | 9 | 10 |

      Signed Out

      11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /samples/VanillaJS/public/identityserver-sample-popup-signout.js: -------------------------------------------------------------------------------- 1 | Oidc.Log.logger = console; 2 | Oidc.Log.level = Oidc.Log.INFO; 3 | // can pass true param and will keep popup window open 4 | new Oidc.UserManager().signoutPopupCallback(); 5 | -------------------------------------------------------------------------------- /samples/VanillaJS/public/identityserver-sample-silent.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | identityserver test 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /samples/VanillaJS/public/identityserver-sample-silent.js: -------------------------------------------------------------------------------- 1 | Oidc.Log.logger = console; 2 | Oidc.Log.level = Oidc.Log.INFO; 3 | new Oidc.UserManager().signinSilentCallback(); 4 | -------------------------------------------------------------------------------- /samples/VanillaJS/public/identityserver-sample.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | identityserver test against https://demo.identityserver.io/ 5 | 6 | 7 | 8 |
      9 | home 10 | clear url 11 |
      12 |
      13 | 14 | 15 | 16 | 17 |
      18 |
      19 | 20 | 21 | 22 |
      23 |
      24 | 25 | 26 |
      27 |
      28 | 29 | 30 |
      31 |
      32 | 33 |
      34 | 35 |
      
      36 |         
      37 |         
      38 |         
      39 |         
      40 |     
      41 | 
      42 | 
      
      
      --------------------------------------------------------------------------------
      /samples/VanillaJS/public/index.html:
      --------------------------------------------------------------------------------
       1 | 
       2 | 
       3 |     
       4 |         oidc-client test
       5 |         
       6 |     
       7 |     
       8 |         
      14 |     
      15 | 
      16 | 
      
      
      --------------------------------------------------------------------------------
      /samples/VanillaJS/public/log.js:
      --------------------------------------------------------------------------------
       1 | function log() {
       2 |     document.getElementById('out').innerText = '';
       3 | 
       4 |     Array.prototype.forEach.call(arguments, function(msg) {
       5 |         if (msg instanceof Error){
       6 |             msg = "Error: " + msg.message;
       7 |         }
       8 |         else if (typeof msg !== 'string') {
       9 |             msg = JSON.stringify(msg, null, 2);
      10 |         }
      11 |         document.getElementById('out').innerHTML += msg + '\r\n';
      12 |     });
      13 | }
      14 | 
      
      
      --------------------------------------------------------------------------------
      /samples/VanillaJS/public/oidc-client-sample-callback.html:
      --------------------------------------------------------------------------------
       1 | 
       2 | 
       3 |     
       4 |         oidc-client test
       5 |         
       6 |     
       7 |     
       8 |         
      9 | back to sample 10 |
      11 |
      
      12 |         
      13 |         
      14 |         
      15 |     
      16 | 
      17 | 
      
      
      --------------------------------------------------------------------------------
      /samples/VanillaJS/public/oidc-client-sample-callback.js:
      --------------------------------------------------------------------------------
      1 | Oidc.Log.logger = console;
      2 | Oidc.Log.level = Oidc.Log.INFO;
      3 | new Oidc.OidcClient().processSigninResponse().then(function(response) {
      4 |     log("signin response success", response);
      5 | }).catch(function(err) {
      6 |     log(err);
      7 | });
      8 | 
      
      
      --------------------------------------------------------------------------------
      /samples/VanillaJS/public/oidc-client-sample.html:
      --------------------------------------------------------------------------------
       1 | 
       2 | 
       3 |     
       4 |         oidc-client test
       5 |         
       6 |     
       7 |     
       8 |         
      9 | home 10 | clear url 11 | 14 | 15 | 16 | 17 | 18 | 19 |
      20 | 21 |
      
      22 |         
      23 |         
      24 |         
      25 |         
      26 |     
      27 | 
      28 | 
      
      
      --------------------------------------------------------------------------------
      /samples/VanillaJS/public/user-manager-sample-callback.html:
      --------------------------------------------------------------------------------
       1 | 
       2 | 
       3 |     
       4 |         oidc-client test
       5 |         
       6 |     
       7 |     
       8 |         
      9 | back to sample 10 |
      11 |
      
      12 |         
      13 |         
      14 |         
      15 |     
      16 | 
      17 | 
      
      
      --------------------------------------------------------------------------------
      /samples/VanillaJS/public/user-manager-sample-callback.js:
      --------------------------------------------------------------------------------
      1 | Oidc.Log.logger = console;
      2 | Oidc.Log.level = Oidc.Log.INFO;
      3 | new Oidc.UserManager().signinRedirectCallback().then(function(user) {
      4 |     log("signin response success", user);
      5 | }).catch(function(err) {
      6 |     log(err);
      7 | });
      8 | 
      
      
      --------------------------------------------------------------------------------
      /samples/VanillaJS/public/user-manager-sample-popup-signin.html:
      --------------------------------------------------------------------------------
       1 | 
       2 | 
       3 | 
       4 | 
       5 |     user-manager test
       6 |     
       7 | 
       8 | 
       9 | 
      10 |     
      11 |     
      12 | 
      13 | 
      14 | 
      15 | 
      
      
      --------------------------------------------------------------------------------
      /samples/VanillaJS/public/user-manager-sample-popup-signin.js:
      --------------------------------------------------------------------------------
      1 | Oidc.Log.logger = console;
      2 | Oidc.Log.level = Oidc.Log.INFO;
      3 | new Oidc.UserManager().signinPopupCallback();
      4 | 
      
      
      --------------------------------------------------------------------------------
      /samples/VanillaJS/public/user-manager-sample-popup-signout.html:
      --------------------------------------------------------------------------------
       1 | 
       2 | 
       3 | 
       4 | 
       5 |     user-manager test
       6 |     
       7 | 
       8 | 
       9 | 
      10 |     

      Signed Out

      11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /samples/VanillaJS/public/user-manager-sample-popup-signout.js: -------------------------------------------------------------------------------- 1 | Oidc.Log.logger = console; 2 | Oidc.Log.level = Oidc.Log.INFO; 3 | // true param will keep popup window open 4 | new Oidc.UserManager().signoutPopupCallback(true); 5 | -------------------------------------------------------------------------------- /samples/VanillaJS/public/user-manager-sample-silent.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | user-manager test 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /samples/VanillaJS/public/user-manager-sample-silent.js: -------------------------------------------------------------------------------- 1 | Oidc.Log.logger = console; 2 | Oidc.Log.level = Oidc.Log.INFO; 3 | new Oidc.UserManager().signinSilentCallback(); 4 | -------------------------------------------------------------------------------- /samples/VanillaJS/public/user-manager-sample.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | user-manager test 5 | 6 | 7 | 8 |
      9 | home 10 | clear url 11 |
      12 |
      13 | 14 | 15 | 16 |
      17 |
      18 | 19 | 20 | 21 |
      22 |
      23 | 24 | 25 |
      26 |
      27 | 28 | 29 |
      30 |
      31 | 32 |
      33 | 34 |
      
      35 |         
      36 |         
      37 |         
      38 |         
      39 |     
      40 | 
      41 | 
      
      
      --------------------------------------------------------------------------------
      /samples/VanillaJS/server.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | var open = require('open');
       5 | var path = require('path');
       6 | 
       7 | var port = 15000;
       8 | var url = "http://localhost:" + port;
       9 | 
      10 | var express = require('express');
      11 | var app = express();
      12 | 
      13 | var static = express.static(path.join(__dirname, 'public'));
      14 | app.use(function (req, res, next) {
      15 |     //res.set('Content-Security-Policy', "default-src 'self' https://demo.identityserver.io http://localhost:" + port);
      16 |     next();
      17 |   });
      18 | app.use(static);
      19 | 
      20 | app.get("/oidc-client.js", function(req, res){
      21 |     res.sendFile(path.join(__dirname, '../../dist/oidc-client.js'));
      22 | });
      23 | 
      24 | var oidc = require('./oidc.js');
      25 | oidc(url, app);
      26 | 
      27 | console.log("listening on " + url);
      28 | //open(url);
      29 | app.listen(port);
      30 | 
      
      
      --------------------------------------------------------------------------------
      /src/AccessTokenEvents.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from './Log.js';
       5 | import { Timer } from './Timer.js';
       6 | 
       7 | const DefaultAccessTokenExpiringNotificationTime = 60; // seconds
       8 | 
       9 | export class AccessTokenEvents {
      10 | 
      11 |     constructor({
      12 |         accessTokenExpiringNotificationTime = DefaultAccessTokenExpiringNotificationTime,
      13 |         accessTokenExpiringTimer = new Timer("Access token expiring"),
      14 |         accessTokenExpiredTimer = new Timer("Access token expired")
      15 |     } = {}) {
      16 |         this._accessTokenExpiringNotificationTime = accessTokenExpiringNotificationTime;
      17 | 
      18 |         this._accessTokenExpiring = accessTokenExpiringTimer;
      19 |         this._accessTokenExpired = accessTokenExpiredTimer;
      20 |     }
      21 | 
      22 |     load(container) {
      23 |         // only register events if there's an access token and it has an expiration
      24 |         if (container.access_token && container.expires_in !== undefined) {
      25 |             let duration = container.expires_in;
      26 |             Log.debug("AccessTokenEvents.load: access token present, remaining duration:", duration);
      27 | 
      28 |             if (duration > 0) {
      29 |                 // only register expiring if we still have time
      30 |                 let expiring = duration - this._accessTokenExpiringNotificationTime;
      31 |                 if (expiring <= 0){
      32 |                     expiring = 1;
      33 |                 }
      34 |                 
      35 |                 Log.debug("AccessTokenEvents.load: registering expiring timer in:", expiring);
      36 |                 this._accessTokenExpiring.init(expiring);
      37 |             }
      38 |             else {
      39 |                 Log.debug("AccessTokenEvents.load: canceling existing expiring timer becase we're past expiration.");
      40 |                 this._accessTokenExpiring.cancel();
      41 |             }
      42 | 
      43 |             // if it's negative, it will still fire
      44 |             let expired = duration + 1;
      45 |             Log.debug("AccessTokenEvents.load: registering expired timer in:", expired);
      46 |             this._accessTokenExpired.init(expired);
      47 |         }
      48 |         else {
      49 |             this._accessTokenExpiring.cancel();
      50 |             this._accessTokenExpired.cancel();
      51 |         }
      52 |     }
      53 | 
      54 |     unload() {
      55 |         Log.debug("AccessTokenEvents.unload: canceling existing access token timers");
      56 |         this._accessTokenExpiring.cancel();
      57 |         this._accessTokenExpired.cancel();
      58 |     }
      59 | 
      60 |     addAccessTokenExpiring(cb) {
      61 |         this._accessTokenExpiring.addHandler(cb);
      62 |     }
      63 |     removeAccessTokenExpiring(cb) {
      64 |         this._accessTokenExpiring.removeHandler(cb);
      65 |     }
      66 | 
      67 |     addAccessTokenExpired(cb) {
      68 |         this._accessTokenExpired.addHandler(cb);
      69 |     }
      70 |     removeAccessTokenExpired(cb) {
      71 |         this._accessTokenExpired.removeHandler(cb);
      72 |     }
      73 | }
      74 | 
      
      
      --------------------------------------------------------------------------------
      /src/CheckSessionIFrame.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from './Log.js';
       5 | 
       6 | const DefaultInterval = 2000;
       7 | 
       8 | export class CheckSessionIFrame {
       9 |     constructor(callback, client_id, url, interval, stopOnError = true) {
      10 |         this._callback = callback;
      11 |         this._client_id = client_id;
      12 |         this._url = url;
      13 |         this._interval = interval || DefaultInterval;
      14 |         this._stopOnError = stopOnError;
      15 | 
      16 |         var idx = url.indexOf("/", url.indexOf("//") + 2);
      17 |         this._frame_origin = url.substr(0, idx);
      18 | 
      19 |         this._frame = window.document.createElement("iframe");
      20 | 
      21 |         // shotgun approach
      22 |         this._frame.style.visibility = "hidden";
      23 |         this._frame.style.position = "absolute";
      24 |         this._frame.style.display = "none";
      25 |         this._frame.width = 0;
      26 |         this._frame.height = 0;
      27 | 
      28 |         this._frame.src = url;
      29 |     }
      30 |     load() {
      31 |         return new Promise((resolve) => {
      32 |             this._frame.onload = () => {
      33 |                 resolve();
      34 |             }
      35 | 
      36 |             window.document.body.appendChild(this._frame);
      37 |             this._boundMessageEvent = this._message.bind(this);
      38 |             window.addEventListener("message", this._boundMessageEvent, false);
      39 |         });
      40 |     }
      41 |     _message(e) {
      42 |         if (e.origin === this._frame_origin &&
      43 |             e.source === this._frame.contentWindow
      44 |         ) {
      45 |             if (e.data === "error") {
      46 |                 Log.error("CheckSessionIFrame: error message from check session op iframe");
      47 |                 if (this._stopOnError) {
      48 |                     this.stop();
      49 |                 }
      50 |             }
      51 |             else if (e.data === "changed") {
      52 |                 Log.debug("CheckSessionIFrame: changed message from check session op iframe");
      53 |                 this.stop();
      54 |                 this._callback();
      55 |             }
      56 |             else {
      57 |                 Log.debug("CheckSessionIFrame: " + e.data + " message from check session op iframe");
      58 |             }
      59 |         }
      60 |     }
      61 |     start(session_state) {
      62 |         if (this._session_state !== session_state) {
      63 |             Log.debug("CheckSessionIFrame.start");
      64 | 
      65 |             this.stop();
      66 | 
      67 |             this._session_state = session_state;
      68 | 
      69 |             let send = () => {
      70 |                 this._frame.contentWindow.postMessage(this._client_id + " " + this._session_state, this._frame_origin);
      71 |             };
      72 |             
      73 |             // trigger now
      74 |             send();
      75 | 
      76 |             // and setup timer
      77 |             this._timer = window.setInterval(send, this._interval);
      78 |         }
      79 |     }
      80 | 
      81 |     stop() {
      82 |         this._session_state = null;
      83 | 
      84 |         if (this._timer) {
      85 |             Log.debug("CheckSessionIFrame.stop");
      86 | 
      87 |             window.clearInterval(this._timer);
      88 |             this._timer = null;
      89 |         }
      90 |     }
      91 | }
      92 | 
      
      
      --------------------------------------------------------------------------------
      /src/ClockService.js:
      --------------------------------------------------------------------------------
      1 | export class ClockService {
      2 |     getEpochTime() {
      3 |         return Promise.resolve(Date.now() / 1000 | 0);
      4 |     }
      5 | }
      6 | 
      
      
      --------------------------------------------------------------------------------
      /src/CordovaIFrameNavigator.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { CordovaPopupWindow } from './CordovaPopupWindow.js';
       5 | 
       6 | export class CordovaIFrameNavigator {
       7 | 
       8 |     prepare(params) {
       9 |         params.popupWindowFeatures = 'hidden=yes';
      10 |         let popup = new CordovaPopupWindow(params);
      11 |         return Promise.resolve(popup);
      12 |     }
      13 | }
      14 | 
      
      
      --------------------------------------------------------------------------------
      /src/CordovaPopupNavigator.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { CordovaPopupWindow } from './CordovaPopupWindow.js';
       5 | 
       6 | export class CordovaPopupNavigator {
       7 | 
       8 |     prepare(params) {
       9 |         let popup = new CordovaPopupWindow(params);
      10 |         return Promise.resolve(popup);
      11 |     }
      12 | }
      13 | 
      
      
      --------------------------------------------------------------------------------
      /src/CordovaPopupWindow.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from './Log.js';
       5 | 
       6 | const DefaultPopupFeatures = 'location=no,toolbar=no,zoom=no';
       7 | const DefaultPopupTarget = "_blank";
       8 | 
       9 | export class CordovaPopupWindow {
      10 | 
      11 |     constructor(params) {
      12 |         this._promise = new Promise((resolve, reject) => {
      13 |             this._resolve = resolve;
      14 |             this._reject = reject;
      15 |         });
      16 | 
      17 |         this.features = params.popupWindowFeatures || DefaultPopupFeatures;
      18 |         this.target = params.popupWindowTarget || DefaultPopupTarget;
      19 |         
      20 |         this.redirect_uri = params.startUrl;
      21 |         Log.debug("CordovaPopupWindow.ctor: redirect_uri: " + this.redirect_uri);
      22 |     }
      23 | 
      24 |     _isInAppBrowserInstalled(cordovaMetadata) {
      25 |         return ["cordova-plugin-inappbrowser", "cordova-plugin-inappbrowser.inappbrowser", "org.apache.cordova.inappbrowser"].some(function (name) {
      26 |             return cordovaMetadata.hasOwnProperty(name)
      27 |         })
      28 |     }
      29 |     
      30 |     navigate(params) {
      31 |         if (!params || !params.url) {
      32 |             this._error("No url provided");
      33 |         } else {
      34 |             if (!window.cordova) {
      35 |                 return this._error("cordova is undefined")
      36 |             }
      37 |             
      38 |             var cordovaMetadata = window.cordova.require("cordova/plugin_list").metadata;
      39 |             if (this._isInAppBrowserInstalled(cordovaMetadata) === false) {
      40 |                 return this._error("InAppBrowser plugin not found")
      41 |             }
      42 |             this._popup = cordova.InAppBrowser.open(params.url, this.target, this.features);
      43 |             if (this._popup) {
      44 |                 Log.debug("CordovaPopupWindow.navigate: popup successfully created");
      45 |                 
      46 |                 this._exitCallbackEvent = this._exitCallback.bind(this); 
      47 |                 this._loadStartCallbackEvent = this._loadStartCallback.bind(this);
      48 |                 
      49 |                 this._popup.addEventListener("exit", this._exitCallbackEvent, false);
      50 |                 this._popup.addEventListener("loadstart", this._loadStartCallbackEvent, false);
      51 |             } else {
      52 |                 this._error("Error opening popup window");
      53 |             }
      54 |         }
      55 |         return this.promise;
      56 |     }
      57 | 
      58 |     get promise() {
      59 |         return this._promise;
      60 |     }
      61 | 
      62 |     _loadStartCallback(event) {
      63 |         if (event.url.indexOf(this.redirect_uri) === 0) {
      64 |             this._success({ url: event.url });
      65 |         }    
      66 |     }
      67 |     _exitCallback(message) {
      68 |         this._error(message);    
      69 |     }
      70 |     
      71 |     _success(data) {
      72 |         this._cleanup();
      73 | 
      74 |         Log.debug("CordovaPopupWindow: Successful response from cordova popup window");
      75 |         this._resolve(data);
      76 |     }
      77 |     _error(message) {
      78 |         this._cleanup();
      79 | 
      80 |         Log.error(message);
      81 |         this._reject(new Error(message));
      82 |     }
      83 | 
      84 |     close() {
      85 |         this._cleanup();
      86 |     }
      87 | 
      88 |     _cleanup() {
      89 |         if (this._popup){
      90 |             Log.debug("CordovaPopupWindow: cleaning up popup");
      91 |             this._popup.removeEventListener("exit", this._exitCallbackEvent, false);
      92 |             this._popup.removeEventListener("loadstart", this._loadStartCallbackEvent, false);
      93 |             this._popup.close();
      94 |         }
      95 |         this._popup = null;
      96 |     }
      97 | }
      98 | 
      
      
      --------------------------------------------------------------------------------
      /src/ErrorResponse.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from './Log.js';
       5 | 
       6 | export class ErrorResponse extends Error {
       7 |     constructor({error, error_description, error_uri, state, session_state}={}
       8 |     ) {
       9 |          if (!error){
      10 |             Log.error("No error passed to ErrorResponse");
      11 |             throw new Error("error");
      12 |         }
      13 | 
      14 |         super(error_description || error);
      15 | 
      16 |         this.name = "ErrorResponse";
      17 | 
      18 |         this.error = error;
      19 |         this.error_description = error_description;
      20 |         this.error_uri = error_uri;
      21 | 
      22 |         this.state = state;
      23 |         this.session_state = session_state;
      24 |     }
      25 | }
      26 | 
      
      
      --------------------------------------------------------------------------------
      /src/Event.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from './Log.js';
       5 | 
       6 | export class Event {
       7 | 
       8 |     constructor(name) {
       9 |         this._name = name;
      10 |         this._callbacks = [];
      11 |     }
      12 | 
      13 |     addHandler(cb) {
      14 |         this._callbacks.push(cb);
      15 |     }
      16 | 
      17 |     removeHandler(cb) {
      18 |         var idx = this._callbacks.findIndex(item => item === cb);
      19 |         if (idx >= 0) {
      20 |             this._callbacks.splice(idx, 1);
      21 |         }
      22 |     }
      23 | 
      24 |     raise(...params) {
      25 |         Log.debug("Event: Raising event: " + this._name);
      26 |         for (let i = 0; i < this._callbacks.length; i++) {
      27 |             this._callbacks[i](...params);
      28 |         }
      29 |     }
      30 | }
      31 | 
      
      
      --------------------------------------------------------------------------------
      /src/Global.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | const timer = {
       5 |     setInterval: function (cb, duration) {
       6 |         return setInterval(cb, duration);
       7 |     },
       8 |     clearInterval: function (handle) {
       9 |         return clearInterval(handle);
      10 |     }
      11 | };
      12 | 
      13 | let testing = false;
      14 | let request = null;
      15 | 
      16 | export class Global {
      17 | 
      18 |     static _testing() {
      19 |         testing = true;
      20 |     }
      21 | 
      22 |     static get location() {
      23 |         if (!testing) {
      24 |             return location;
      25 |         }
      26 |     }
      27 | 
      28 |     static get localStorage() {
      29 |         if (!testing && typeof window !== 'undefined') {
      30 |             return localStorage;
      31 |         }
      32 |     }
      33 | 
      34 |     static get sessionStorage() {
      35 |         if (!testing && typeof window !== 'undefined') {
      36 |             return sessionStorage;
      37 |         }
      38 |     }
      39 | 
      40 |     static setXMLHttpRequest(newRequest) {
      41 |         request = newRequest;
      42 |     }
      43 | 
      44 |     static get XMLHttpRequest() {
      45 |         if (!testing && typeof window !== 'undefined') {
      46 |             return request || XMLHttpRequest;
      47 |         }
      48 |     }
      49 | 
      50 |     static get timer() {
      51 |         if (!testing) {
      52 |             return timer;
      53 |         }
      54 |     }
      55 | }
      56 | 
      
      
      --------------------------------------------------------------------------------
      /src/IFrameNavigator.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from './Log.js';
       5 | import { IFrameWindow } from './IFrameWindow.js';
       6 | 
       7 | export class IFrameNavigator {
       8 | 
       9 |     prepare(params) {
      10 |         let frame = new IFrameWindow(params);
      11 |         return Promise.resolve(frame);
      12 |     }
      13 | 
      14 |     callback(url) {
      15 |         Log.debug("IFrameNavigator.callback");
      16 | 
      17 |         try {
      18 |             IFrameWindow.notifyParent(url);
      19 |             return Promise.resolve();
      20 |         }
      21 |         catch (e) {
      22 |             return Promise.reject(e);
      23 |         }
      24 |     }
      25 | }
      26 | 
      
      
      --------------------------------------------------------------------------------
      /src/IFrameWindow.js:
      --------------------------------------------------------------------------------
        1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
        2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
        3 | 
        4 | import { Log } from './Log.js';
        5 | 
        6 | const DefaultTimeout = 10000;
        7 | 
        8 | export class IFrameWindow {
        9 | 
       10 |     constructor(params) {
       11 |         this._promise = new Promise((resolve, reject) => {
       12 |             this._resolve = resolve;
       13 |             this._reject = reject;
       14 |         });
       15 | 
       16 |         this._boundMessageEvent = this._message.bind(this);
       17 |         window.addEventListener("message", this._boundMessageEvent, false);
       18 | 
       19 |         this._frame = window.document.createElement("iframe");
       20 | 
       21 |         // shotgun approach
       22 |         this._frame.style.visibility = "hidden";
       23 |         this._frame.style.position = "absolute";
       24 |         this._frame.width = 0;
       25 |         this._frame.height = 0;
       26 | 
       27 |         window.document.body.appendChild(this._frame);
       28 |     }
       29 | 
       30 |     navigate(params) {
       31 |         if (!params || !params.url) {
       32 |             this._error("No url provided");
       33 |         }
       34 |         else {
       35 |             let timeout = params.silentRequestTimeout || DefaultTimeout;
       36 |             Log.debug("IFrameWindow.navigate: Using timeout of:", timeout);
       37 |             this._timer = window.setTimeout(this._timeout.bind(this), timeout);
       38 |             this._frame.src = params.url;
       39 |         }
       40 | 
       41 |         return this.promise;
       42 |     }
       43 | 
       44 |     get promise() {
       45 |         return this._promise;
       46 |     }
       47 | 
       48 |     _success(data) {
       49 |         this._cleanup();
       50 | 
       51 |         Log.debug("IFrameWindow: Successful response from frame window");
       52 |         this._resolve(data);
       53 |     }
       54 |     _error(message) {
       55 |         this._cleanup();
       56 | 
       57 |         Log.error(message);
       58 |         this._reject(new Error(message));
       59 |     }
       60 | 
       61 |     close() {
       62 |         this._cleanup();
       63 |     }
       64 | 
       65 |     _cleanup() {
       66 |         if (this._frame) {
       67 |             Log.debug("IFrameWindow: cleanup");
       68 | 
       69 |             window.removeEventListener("message", this._boundMessageEvent, false);
       70 |             window.clearTimeout(this._timer);
       71 |             window.document.body.removeChild(this._frame);
       72 | 
       73 |             this._timer = null;
       74 |             this._frame = null;
       75 |             this._boundMessageEvent = null;
       76 |         }
       77 |     }
       78 | 
       79 |     _timeout() {
       80 |         Log.debug("IFrameWindow.timeout");
       81 |         this._error("Frame window timed out");
       82 |     }
       83 | 
       84 |     _message(e) {
       85 |         Log.debug("IFrameWindow.message");
       86 | 
       87 |         if (this._timer &&
       88 |             e.origin === this._origin &&
       89 |             e.source === this._frame.contentWindow &&
       90 |             (typeof e.data === 'string' && (e.data.startsWith('http://') || e.data.startsWith('https://')))
       91 |         ) {
       92 |             let url = e.data;
       93 |             if (url) {
       94 |                 this._success({ url: url });
       95 |             }
       96 |             else {
       97 |                 this._error("Invalid response from frame");
       98 |             }
       99 |         }
      100 |     }
      101 | 
      102 |     get _origin() {
      103 |         return location.protocol + "//" + location.host;
      104 |     }
      105 | 
      106 |     static notifyParent(url) {
      107 |         Log.debug("IFrameWindow.notifyParent");
      108 |         url = url || window.location.href;
      109 |         if (url) {
      110 |             Log.debug("IFrameWindow.notifyParent: posting url message to parent");
      111 |             window.parent.postMessage(url, location.protocol + "//" + location.host);
      112 |         }
      113 |     }
      114 | }
      115 | 
      
      
      --------------------------------------------------------------------------------
      /src/InMemoryWebStorage.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from './Log.js';
       5 | 
       6 | export class InMemoryWebStorage{
       7 |     constructor(){
       8 |         this._data = {};
       9 |     }
      10 | 
      11 |     getItem(key) {
      12 |         Log.debug("InMemoryWebStorage.getItem", key);
      13 |         return this._data[key];
      14 |     }
      15 | 
      16 |     setItem(key, value){
      17 |         Log.debug("InMemoryWebStorage.setItem", key);
      18 |         this._data[key] = value;
      19 |     }
      20 | 
      21 |     removeItem(key){
      22 |         Log.debug("InMemoryWebStorage.removeItem", key);
      23 |         delete this._data[key];
      24 |     }
      25 | 
      26 |     get length() {
      27 |         return Object.getOwnPropertyNames(this._data).length;
      28 |     }
      29 | 
      30 |     key(index) {
      31 |         return Object.getOwnPropertyNames(this._data)[index];
      32 |     }
      33 | }
      34 | 
      
      
      --------------------------------------------------------------------------------
      /src/JoseUtil.js:
      --------------------------------------------------------------------------------
      1 | import { jws, KeyUtil, X509, crypto, hextob64u, b64tohex, AllowedSigningAlgs } from './crypto/jsrsasign';
      2 | import getJoseUtil from './JoseUtilImpl';
      3 | 
      4 | export const JoseUtil = getJoseUtil({ jws, KeyUtil, X509, crypto, hextob64u, b64tohex, AllowedSigningAlgs });
      5 | 
      
      
      --------------------------------------------------------------------------------
      /src/JoseUtilRsa.js:
      --------------------------------------------------------------------------------
      1 | import { jws, KeyUtil, X509, crypto, hextob64u, b64tohex, AllowedSigningAlgs } from './crypto/rsa';
      2 | import getJoseUtil from './JoseUtilImpl';
      3 | 
      4 | export const JoseUtil = getJoseUtil({ jws, KeyUtil, X509, crypto, hextob64u, b64tohex, AllowedSigningAlgs });
      5 | 
      
      
      --------------------------------------------------------------------------------
      /src/Log.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | let nopLogger = {
       5 |     debug(){},
       6 |     info(){},
       7 |     warn(){},
       8 |     error(){}
       9 | };
      10 | 
      11 | const NONE = 0;
      12 | const ERROR = 1;
      13 | const WARN = 2;
      14 | const INFO = 3;
      15 | const DEBUG = 4;
      16 | 
      17 | let logger;
      18 | let level;
      19 | 
      20 | export class Log {
      21 |     static get NONE() {return NONE};
      22 |     static get ERROR() {return ERROR};
      23 |     static get WARN() {return WARN};
      24 |     static get INFO() {return INFO};
      25 |     static get DEBUG() {return DEBUG};
      26 |     
      27 |     static reset(){
      28 |         level = INFO;
      29 |         logger = nopLogger;
      30 |     }
      31 |     
      32 |     static get level(){
      33 |         return level;
      34 |     }
      35 |     static set level(value){
      36 |         if (NONE <= value && value <= DEBUG){
      37 |             level = value;
      38 |         }
      39 |         else {
      40 |             throw new Error("Invalid log level");
      41 |         }
      42 |     }
      43 |     
      44 |     static get logger(){
      45 |         return logger;
      46 |     }
      47 |     static set logger(value){
      48 |         if (!value.debug && value.info) {
      49 |             // just to stay backwards compat. can remove in 2.0
      50 |             value.debug = value.info;
      51 |         }
      52 | 
      53 |         if (value.debug && value.info && value.warn && value.error){
      54 |             logger = value;
      55 |         }
      56 |         else {
      57 |             throw new Error("Invalid logger");
      58 |         }
      59 |     }
      60 |     
      61 |     static debug(...args){
      62 |         if (level >= DEBUG){
      63 |             logger.debug.apply(logger, Array.from(args));
      64 |         }
      65 |     }
      66 |     static info(...args){
      67 |         if (level >= INFO){
      68 |             logger.info.apply(logger, Array.from(args));
      69 |         }
      70 |     }
      71 |     static warn(...args){
      72 |         if (level >= WARN){
      73 |             logger.warn.apply(logger, Array.from(args));
      74 |         }
      75 |     }
      76 |     static error(...args){
      77 |         if (level >= ERROR){
      78 |             logger.error.apply(logger, Array.from(args));
      79 |         }
      80 |     }
      81 | }
      82 | 
      83 | Log.reset();
      84 | 
      
      
      --------------------------------------------------------------------------------
      /src/PopupNavigator.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from './Log.js';
       5 | import { PopupWindow } from './PopupWindow.js';
       6 | 
       7 | export class PopupNavigator {
       8 | 
       9 |     prepare(params) {
      10 |         let popup = new PopupWindow(params);
      11 |         return Promise.resolve(popup);
      12 |     }
      13 | 
      14 |     callback(url, keepOpen, delimiter) {
      15 |         Log.debug("PopupNavigator.callback");
      16 | 
      17 |         try {
      18 |             PopupWindow.notifyOpener(url, keepOpen, delimiter);
      19 |             return Promise.resolve();
      20 |         }
      21 |         catch (e) {
      22 |             return Promise.reject(e);
      23 |         }
      24 |     }
      25 | }
      26 | 
      
      
      --------------------------------------------------------------------------------
      /src/RedirectNavigator.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from './Log.js';
       5 | 
       6 | export class RedirectNavigator {
       7 | 
       8 |     prepare() {
       9 |         return Promise.resolve(this);
      10 |     }
      11 | 
      12 |     navigate(params) {
      13 |         if (!params || !params.url) {
      14 |             Log.error("RedirectNavigator.navigate: No url provided");
      15 |             return Promise.reject(new Error("No url provided"));
      16 |         }
      17 | 
      18 |         if (params.useReplaceToNavigate) {
      19 |             window.location.replace(params.url);
      20 |         }
      21 |         else {
      22 |             window.location = params.url;
      23 |         }
      24 | 
      25 |         return Promise.resolve();
      26 |     }
      27 | 
      28 |     get url() {
      29 |         return window.location.href;
      30 |     }
      31 | }
      32 | 
      
      
      --------------------------------------------------------------------------------
      /src/SigninResponse.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { UrlUtility } from './UrlUtility.js';
       5 | 
       6 | const OidcScope = "openid";
       7 | 
       8 | export class SigninResponse {
       9 |     constructor(url, delimiter = "#") {
      10 | 
      11 |         var values = UrlUtility.parseUrlFragment(url, delimiter);
      12 | 
      13 |         this.error = values.error;
      14 |         this.error_description = values.error_description;
      15 |         this.error_uri = values.error_uri;
      16 | 
      17 |         this.code = values.code;
      18 |         this.state = values.state;
      19 |         this.id_token = values.id_token;
      20 |         this.session_state = values.session_state;
      21 |         this.access_token = values.access_token;
      22 |         this.token_type = values.token_type;
      23 |         this.scope = values.scope;
      24 |         this.profile = undefined; // will be set from ResponseValidator
      25 | 
      26 |         this.expires_in = values.expires_in;
      27 |     }
      28 | 
      29 |     get expires_in() {
      30 |         if (this.expires_at) {
      31 |             let now = parseInt(Date.now() / 1000);
      32 |             return this.expires_at - now;
      33 |         }
      34 |         return undefined;
      35 |     }
      36 |     set expires_in(value){
      37 |         let expires_in = parseInt(value);
      38 |         if (typeof expires_in === 'number' && expires_in > 0) {
      39 |             let now = parseInt(Date.now() / 1000);
      40 |             this.expires_at = now + expires_in;
      41 |         }
      42 |     }
      43 | 
      44 |     get expired() {
      45 |         let expires_in = this.expires_in;
      46 |         if (expires_in !== undefined) {
      47 |             return expires_in <= 0;
      48 |         }
      49 |         return undefined;
      50 |     }
      51 | 
      52 |     get scopes() {
      53 |         return (this.scope || "").split(" ");
      54 |     }
      55 | 
      56 |     get isOpenIdConnect() {
      57 |         return this.scopes.indexOf(OidcScope) >= 0 || !!this.id_token;
      58 |     }
      59 | }
      60 | 
      
      
      --------------------------------------------------------------------------------
      /src/SigninState.js:
      --------------------------------------------------------------------------------
        1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
        2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
        3 | 
        4 | import { Log } from './Log.js';
        5 | import { State } from './State.js';
        6 | import { JoseUtil } from './JoseUtil.js';
        7 | import random from './random.js';
        8 | 
        9 | export class SigninState extends State {
       10 |     constructor({nonce, authority, client_id, redirect_uri, code_verifier, response_mode, client_secret, scope, extraTokenParams, skipUserInfo} = {}) {
       11 |         super(arguments[0]);
       12 | 
       13 |         if (nonce === true) {
       14 |             this._nonce = random();
       15 |         }
       16 |         else if (nonce) {
       17 |             this._nonce = nonce;
       18 |         }
       19 | 
       20 |         if (code_verifier === true) {
       21 |             // random() produces 32 length
       22 |             this._code_verifier = random() + random() + random();
       23 |         }
       24 |         else if (code_verifier) {
       25 |             this._code_verifier = code_verifier;
       26 |         }
       27 |         
       28 |         if (this.code_verifier) {
       29 |             let hash = JoseUtil.hashString(this.code_verifier, "SHA256");
       30 |             this._code_challenge = JoseUtil.hexToBase64Url(hash);
       31 |         }
       32 | 
       33 |         this._redirect_uri = redirect_uri;
       34 |         this._authority = authority;
       35 |         this._client_id = client_id;
       36 |         this._response_mode = response_mode;
       37 |         this._client_secret = client_secret;
       38 |         this._scope = scope;
       39 |         this._extraTokenParams = extraTokenParams;
       40 |         this._skipUserInfo = skipUserInfo;
       41 |     }
       42 | 
       43 |     get nonce() {
       44 |         return this._nonce;
       45 |     }
       46 |     get authority() {
       47 |         return this._authority;
       48 |     }
       49 |     get client_id() {
       50 |         return this._client_id;
       51 |     }
       52 |     get redirect_uri() {
       53 |         return this._redirect_uri;
       54 |     }
       55 |     get code_verifier() {
       56 |         return this._code_verifier;
       57 |     }
       58 |     get code_challenge() {
       59 |         return this._code_challenge;
       60 |     }
       61 |     get response_mode() {
       62 |         return this._response_mode;
       63 |     }
       64 |     get client_secret() {
       65 |         return this._client_secret;
       66 |     }
       67 |     get scope() {
       68 |         return this._scope;
       69 |     }
       70 |     get extraTokenParams() {
       71 |         return this._extraTokenParams;
       72 |     }
       73 |     get skipUserInfo() {
       74 |         return this._skipUserInfo;
       75 |     }
       76 |     
       77 |     toStorageString() {
       78 |         Log.debug("SigninState.toStorageString");
       79 |         return JSON.stringify({
       80 |             id: this.id,
       81 |             data: this.data,
       82 |             created: this.created,
       83 |             request_type: this.request_type,
       84 |             nonce: this.nonce,
       85 |             code_verifier: this.code_verifier,
       86 |             redirect_uri: this.redirect_uri,
       87 |             authority: this.authority,
       88 |             client_id: this.client_id,
       89 |             response_mode: this.response_mode,
       90 |             client_secret: this.client_secret,
       91 |             scope: this.scope,
       92 |             extraTokenParams : this.extraTokenParams,
       93 |             skipUserInfo: this.skipUserInfo
       94 |         });
       95 |     }
       96 | 
       97 |     static fromStorageString(storageString) {
       98 |         Log.debug("SigninState.fromStorageString");
       99 |         var data = JSON.parse(storageString);
      100 |         return new SigninState(data);
      101 |     }
      102 | }
      103 | 
      
      
      --------------------------------------------------------------------------------
      /src/SignoutRequest.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from './Log.js';
       5 | import { UrlUtility } from './UrlUtility.js';
       6 | import { State } from './State.js';
       7 | 
       8 | export class SignoutRequest {
       9 |     constructor({url, id_token_hint, post_logout_redirect_uri, data, extraQueryParams, request_type}) {
      10 |         if (!url) {
      11 |             Log.error("SignoutRequest.ctor: No url passed");
      12 |             throw new Error("url");
      13 |         }
      14 | 
      15 |         if (id_token_hint) {
      16 |             url = UrlUtility.addQueryParam(url, "id_token_hint", id_token_hint);
      17 |         }
      18 | 
      19 |         if (post_logout_redirect_uri) {
      20 |             url = UrlUtility.addQueryParam(url, "post_logout_redirect_uri", post_logout_redirect_uri);
      21 | 
      22 |             if (data) {
      23 |                 this.state = new State({ data, request_type });
      24 | 
      25 |                 url = UrlUtility.addQueryParam(url, "state", this.state.id);
      26 |             }
      27 |         }
      28 | 
      29 |         for(let key in extraQueryParams){
      30 |             url = UrlUtility.addQueryParam(url, key, extraQueryParams[key])
      31 |         }
      32 | 
      33 |         this.url = url;
      34 |     }
      35 | }
      36 | 
      
      
      --------------------------------------------------------------------------------
      /src/SignoutResponse.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { UrlUtility } from './UrlUtility.js';
       5 | 
       6 | export class SignoutResponse {
       7 |     constructor(url) {
       8 | 
       9 |         var values = UrlUtility.parseUrlFragment(url, "?");
      10 | 
      11 |         this.error = values.error;
      12 |         this.error_description = values.error_description;
      13 |         this.error_uri = values.error_uri;
      14 | 
      15 |         this.state = values.state;
      16 |     }
      17 | }
      18 | 
      
      
      --------------------------------------------------------------------------------
      /src/SilentRenewService.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from './Log.js';
       5 | 
       6 | export class SilentRenewService {
       7 | 
       8 |     constructor(userManager) {
       9 |         this._userManager = userManager;
      10 |     }
      11 | 
      12 |     start() {
      13 |         if (!this._callback) {
      14 |             this._callback = this._tokenExpiring.bind(this);
      15 |             this._userManager.events.addAccessTokenExpiring(this._callback);
      16 | 
      17 |             // this will trigger loading of the user so the expiring events can be initialized
      18 |             this._userManager.getUser().then(user=>{
      19 |                 // deliberate nop
      20 |             }).catch(err=>{
      21 |                 // catch to suppress errors since we're in a ctor
      22 |                 Log.error("SilentRenewService.start: Error from getUser:", err.message);
      23 |             });
      24 |         }
      25 |     }
      26 | 
      27 |     stop() {
      28 |         if (this._callback) {
      29 |             this._userManager.events.removeAccessTokenExpiring(this._callback);
      30 |             delete this._callback;
      31 |         }
      32 |     }
      33 | 
      34 |     _tokenExpiring() {
      35 |         this._userManager.signinSilent().then(user => {
      36 |             Log.debug("SilentRenewService._tokenExpiring: Silent token renewal successful");
      37 |         }, err => {
      38 |             Log.error("SilentRenewService._tokenExpiring: Error from signinSilent:", err.message);
      39 |             this._userManager.events._raiseSilentRenewError(err);
      40 |         });
      41 |     }
      42 | }
      43 | 
      
      
      --------------------------------------------------------------------------------
      /src/State.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from './Log.js';
       5 | import random from './random.js';
       6 | 
       7 | export class State {
       8 |     constructor({id, data, created, request_type} = {}) {
       9 |         this._id = id || random();
      10 |         this._data = data;
      11 | 
      12 |         if (typeof created === 'number' && created > 0) {
      13 |             this._created = created;
      14 |         }
      15 |         else {
      16 |             this._created = parseInt(Date.now() / 1000);
      17 |         }
      18 |         this._request_type =  request_type;
      19 |     }
      20 | 
      21 |     get id() {
      22 |         return this._id;
      23 |     }
      24 |     get data() {
      25 |         return this._data;
      26 |     }
      27 |     get created() {
      28 |         return this._created;
      29 |     }
      30 |     get request_type() {
      31 |         return this._request_type;
      32 |     }
      33 | 
      34 |     toStorageString() {
      35 |         Log.debug("State.toStorageString");
      36 |         return JSON.stringify({
      37 |             id: this.id,
      38 |             data: this.data,
      39 |             created: this.created,
      40 |             request_type: this.request_type
      41 |         });
      42 |     }
      43 | 
      44 |     static fromStorageString(storageString) {
      45 |         Log.debug("State.fromStorageString");
      46 |         return new State(JSON.parse(storageString));
      47 |     }
      48 | 
      49 |     static clearStaleState(storage, age) {
      50 | 
      51 |         var cutoff = Date.now() / 1000 - age;
      52 | 
      53 |         return storage.getAllKeys().then(keys => {
      54 |             Log.debug("State.clearStaleState: got keys", keys);
      55 | 
      56 |             var promises = [];
      57 |             for (let i = 0; i < keys.length; i++) {
      58 |                 let key = keys[i];
      59 |                 var p = storage.get(key).then(item => {
      60 |                     let remove = false;
      61 | 
      62 |                     if (item) {
      63 |                         try {
      64 |                             var state = State.fromStorageString(item)
      65 | 
      66 |                             Log.debug("State.clearStaleState: got item from key: ", key, state.created);
      67 | 
      68 |                             if (state.created <= cutoff) {
      69 |                                 remove = true;
      70 |                             }
      71 |                         }
      72 |                         catch (e) {
      73 |                             Log.error("State.clearStaleState: Error parsing state for key", key, e.message);
      74 |                             remove = true;
      75 |                         }
      76 |                     }
      77 |                     else {
      78 |                         Log.debug("State.clearStaleState: no item in storage for key: ", key);
      79 |                         remove = true;
      80 |                     }
      81 | 
      82 |                     if (remove) {
      83 |                         Log.debug("State.clearStaleState: removed item for key: ", key);
      84 |                         return storage.remove(key);
      85 |                     }
      86 |                 });
      87 | 
      88 |                 promises.push(p);
      89 |             }
      90 | 
      91 |             Log.debug("State.clearStaleState: waiting on promise count:", promises.length);
      92 |             return Promise.all(promises);
      93 |         });
      94 |     }
      95 | }
      96 | 
      
      
      --------------------------------------------------------------------------------
      /src/Timer.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from './Log.js';
       5 | import { Global } from './Global.js';
       6 | import { Event } from './Event.js';
       7 | 
       8 | const TimerDuration = 5; // seconds
       9 | 
      10 | export class Timer extends Event {
      11 | 
      12 |     constructor(name, timer = Global.timer, nowFunc = undefined) {
      13 |         super(name);
      14 |         this._timer = timer;
      15 | 
      16 |         if (nowFunc) {
      17 |             this._nowFunc = nowFunc;
      18 |         }
      19 |         else {
      20 |             this._nowFunc = () => Date.now() / 1000;
      21 |         }
      22 |     }
      23 | 
      24 |     get now() {
      25 |         return parseInt(this._nowFunc());
      26 |     }
      27 | 
      28 |     init(duration) {
      29 |         if (duration <= 0) {
      30 |             duration = 1;
      31 |         }
      32 |         duration = parseInt(duration);
      33 | 
      34 |         var expiration = this.now + duration;
      35 |         if (this.expiration === expiration && this._timerHandle) {
      36 |             // no need to reinitialize to same expiration, so bail out
      37 |             Log.debug("Timer.init timer " + this._name + " skipping initialization since already initialized for expiration:", this.expiration);
      38 |             return;
      39 |         }
      40 | 
      41 |         this.cancel();
      42 | 
      43 |         Log.debug("Timer.init timer " + this._name + " for duration:", duration);
      44 |         this._expiration = expiration;
      45 | 
      46 |         // we're using a fairly short timer and then checking the expiration in the
      47 |         // callback to handle scenarios where the browser device sleeps, and then
      48 |         // the timers end up getting delayed.
      49 |         var timerDuration = TimerDuration;
      50 |         if (duration < timerDuration) {
      51 |             timerDuration = duration;
      52 |         }
      53 |         this._timerHandle = this._timer.setInterval(this._callback.bind(this), timerDuration * 1000);
      54 |     }
      55 |     
      56 |     get expiration() {
      57 |         return this._expiration;
      58 |     }
      59 | 
      60 |     cancel() {
      61 |         if (this._timerHandle) {
      62 |             Log.debug("Timer.cancel: ", this._name);
      63 |             this._timer.clearInterval(this._timerHandle);
      64 |             this._timerHandle = null;
      65 |         }
      66 |     }
      67 | 
      68 |     _callback() {
      69 |         var diff = this._expiration - this.now;
      70 |         Log.debug("Timer.callback; " + this._name + " timer expires in:", diff);
      71 | 
      72 |         if (this._expiration <= this.now) {
      73 |             this.cancel();
      74 |             super.raise();
      75 |         }
      76 |     }
      77 | }
      78 | 
      
      
      --------------------------------------------------------------------------------
      /src/TokenRevocationClient.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from './Log.js';
       5 | import { MetadataService } from './MetadataService.js';
       6 | import { Global } from './Global.js';
       7 | 
       8 | const AccessTokenTypeHint = "access_token";
       9 | const RefreshTokenTypeHint = "refresh_token";
      10 | 
      11 | export class TokenRevocationClient {
      12 |     constructor(settings, XMLHttpRequestCtor = Global.XMLHttpRequest, MetadataServiceCtor = MetadataService) {
      13 |         if (!settings) {
      14 |             Log.error("TokenRevocationClient.ctor: No settings provided");
      15 |             throw new Error("No settings provided.");
      16 |         }
      17 | 
      18 |         this._settings = settings;
      19 |         this._XMLHttpRequestCtor = XMLHttpRequestCtor;
      20 |         this._metadataService = new MetadataServiceCtor(this._settings);
      21 |     }
      22 | 
      23 |     revoke(token, required, type = "access_token") {
      24 |         if (!token) {
      25 |             Log.error("TokenRevocationClient.revoke: No token provided");
      26 |             throw new Error("No token provided.");
      27 |         }
      28 | 
      29 |         if (type !== AccessTokenTypeHint && type != RefreshTokenTypeHint) {
      30 |             Log.error("TokenRevocationClient.revoke: Invalid token type");
      31 |             throw new Error("Invalid token type.");
      32 |         }
      33 | 
      34 |         return this._metadataService.getRevocationEndpoint().then(url => {
      35 |             if (!url) {
      36 |                 if (required) {
      37 |                     Log.error("TokenRevocationClient.revoke: Revocation not supported");
      38 |                     throw new Error("Revocation not supported");
      39 |                 }
      40 | 
      41 |                 // not required, so don't error and just return
      42 |                 return;
      43 |             }
      44 | 
      45 |             Log.debug("TokenRevocationClient.revoke: Revoking " + type);
      46 |             var client_id = this._settings.client_id;
      47 |             var client_secret = this._settings.client_secret;
      48 |             return this._revoke(url, client_id, client_secret, token, type);
      49 |         });
      50 |     }
      51 | 
      52 |     _revoke(url, client_id, client_secret, token, type) {
      53 | 
      54 |         return new Promise((resolve, reject) => {
      55 | 
      56 |             var xhr = new this._XMLHttpRequestCtor();
      57 |             xhr.open("POST", url);
      58 | 
      59 |             xhr.onload = () => {
      60 |                 Log.debug("TokenRevocationClient.revoke: HTTP response received, status", xhr.status);
      61 | 
      62 |                 if (xhr.status === 200) {
      63 |                     resolve();
      64 |                 }
      65 |                 else {
      66 |                     reject(Error(xhr.statusText + " (" + xhr.status + ")"));
      67 |                 }
      68 |             };
      69 |             xhr.onerror = () => { 
      70 |                 Log.debug("TokenRevocationClient.revoke: Network Error.")
      71 |                 reject("Network Error");
      72 |             };
      73 | 
      74 |             var body = "client_id=" + encodeURIComponent(client_id);
      75 |             if (client_secret) {
      76 |                 body += "&client_secret=" + encodeURIComponent(client_secret);
      77 |             }
      78 |             body += "&token_type_hint=" + encodeURIComponent(type);
      79 |             body += "&token=" + encodeURIComponent(token);
      80 | 
      81 |             xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      82 |             xhr.send(body);
      83 |         });
      84 |     }
      85 | }
      86 | 
      
      
      --------------------------------------------------------------------------------
      /src/UrlUtility.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from './Log.js';
       5 | import { Global } from './Global.js';
       6 | 
       7 | export class UrlUtility {
       8 |     static addQueryParam(url, name, value) {
       9 |         if (url.indexOf('?') < 0) {
      10 |             url += "?";
      11 |         }
      12 | 
      13 |         if (url[url.length - 1] !== "?") {
      14 |             url += "&";
      15 |         }
      16 | 
      17 |         url += encodeURIComponent(name);
      18 |         url += "=";
      19 |         url += encodeURIComponent(value);
      20 | 
      21 |         return url;
      22 |     }
      23 | 
      24 |     static parseUrlFragment(value, delimiter = "#", global = Global) {
      25 |         if (typeof value !== 'string'){
      26 |             value = global.location.href;
      27 |         }
      28 | 
      29 |         var idx = value.lastIndexOf(delimiter);
      30 |         if (idx >= 0) {
      31 |             value = value.substr(idx + 1);
      32 |         }
      33 | 
      34 |         if (delimiter === "?") {
      35 |             // if we're doing query, then strip off hash fragment before we parse
      36 |             idx = value.indexOf('#');
      37 |             if (idx >= 0) {
      38 |                 value = value.substr(0, idx);
      39 |             }
      40 |         }
      41 | 
      42 |         var params = {},
      43 |             regex = /([^&=]+)=([^&]*)/g,
      44 |             m;
      45 | 
      46 |         var counter = 0;
      47 |         while (m = regex.exec(value)) {
      48 |             params[decodeURIComponent(m[1])] = decodeURIComponent(m[2].replace(/\+/g, ' '));
      49 |             if (counter++ > 50) {
      50 |                 Log.error("UrlUtility.parseUrlFragment: response exceeded expected number of parameters", value);
      51 |                 return {
      52 |                     error: "Response exceeded expected number of parameters"
      53 |                 };
      54 |             }
      55 |         }
      56 | 
      57 |         for (var prop in params) {
      58 |             return params;
      59 |         }
      60 | 
      61 |         return {};
      62 |     }
      63 | }
      64 | 
      
      
      --------------------------------------------------------------------------------
      /src/User.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from './Log.js';
       5 | 
       6 | export class User {
       7 |     constructor({id_token, session_state, access_token, refresh_token, token_type, scope, profile, expires_at, state}) {
       8 |         this.id_token = id_token;
       9 |         this.session_state = session_state;
      10 |         this.access_token = access_token;
      11 |         this.refresh_token = refresh_token;
      12 |         this.token_type = token_type;
      13 |         this.scope = scope;
      14 |         this.profile = profile;
      15 |         this.expires_at = expires_at;
      16 |         this.state = state;
      17 |     }
      18 | 
      19 |     get expires_in() {
      20 |         if (this.expires_at) {
      21 |             let now = parseInt(Date.now() / 1000);
      22 |             return this.expires_at - now;
      23 |         }
      24 |         return undefined;
      25 |     }
      26 |     set expires_in(value) {
      27 |         let expires_in = parseInt(value);
      28 |         if (typeof expires_in === 'number' && expires_in > 0) {
      29 |             let now = parseInt(Date.now() / 1000);
      30 |             this.expires_at = now + expires_in;
      31 |         }
      32 |     }
      33 | 
      34 |     get expired() {
      35 |         let expires_in = this.expires_in;
      36 |         if (expires_in !== undefined) {
      37 |             return expires_in <= 0;
      38 |         }
      39 |         return undefined;
      40 |     }
      41 | 
      42 |     get scopes() {
      43 |         return (this.scope || "").split(" ");
      44 |     }
      45 | 
      46 |     toStorageString() {
      47 |         Log.debug("User.toStorageString");
      48 |         return JSON.stringify({
      49 |             id_token: this.id_token,
      50 |             session_state: this.session_state,
      51 |             access_token: this.access_token,
      52 |             refresh_token: this.refresh_token,
      53 |             token_type: this.token_type,
      54 |             scope: this.scope,
      55 |             profile: this.profile,
      56 |             expires_at: this.expires_at
      57 |         });
      58 |     }
      59 | 
      60 |     static fromStorageString(storageString) {
      61 |         Log.debug("User.fromStorageString");
      62 |         return new User(JSON.parse(storageString));
      63 |     }
      64 | }
      65 | 
      
      
      --------------------------------------------------------------------------------
      /src/UserManagerEvents.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from './Log.js';
       5 | import { AccessTokenEvents } from './AccessTokenEvents.js';
       6 | import { Event } from './Event.js';
       7 | 
       8 | export class UserManagerEvents extends AccessTokenEvents {
       9 | 
      10 |     constructor(settings) {
      11 |         super(settings);
      12 |         this._userLoaded = new Event("User loaded");
      13 |         this._userUnloaded = new Event("User unloaded");
      14 |         this._silentRenewError = new Event("Silent renew error");
      15 |         this._userSignedIn = new Event("User signed in");
      16 |         this._userSignedOut = new Event("User signed out");
      17 |         this._userSessionChanged = new Event("User session changed");
      18 |     }
      19 | 
      20 |     load(user, raiseEvent=true) {
      21 |         Log.debug("UserManagerEvents.load");
      22 |         super.load(user);
      23 |         if (raiseEvent) {
      24 |             this._userLoaded.raise(user);
      25 |         }
      26 |     }
      27 |     unload() {
      28 |         Log.debug("UserManagerEvents.unload");
      29 |         super.unload();
      30 |         this._userUnloaded.raise();
      31 |     }
      32 | 
      33 |     addUserLoaded(cb) {
      34 |         this._userLoaded.addHandler(cb);
      35 |     }
      36 |     removeUserLoaded(cb) {
      37 |         this._userLoaded.removeHandler(cb);
      38 |     }
      39 | 
      40 |     addUserUnloaded(cb) {
      41 |         this._userUnloaded.addHandler(cb);
      42 |     }
      43 |     removeUserUnloaded(cb) {
      44 |         this._userUnloaded.removeHandler(cb);
      45 |     }
      46 | 
      47 |     addSilentRenewError(cb) {
      48 |         this._silentRenewError.addHandler(cb);
      49 |     }
      50 |     removeSilentRenewError(cb) {
      51 |         this._silentRenewError.removeHandler(cb);
      52 |     }
      53 |     _raiseSilentRenewError(e) {
      54 |         Log.debug("UserManagerEvents._raiseSilentRenewError", e.message);
      55 |         this._silentRenewError.raise(e);
      56 |     }
      57 | 
      58 |     addUserSignedIn(cb) {
      59 |         this._userSignedIn.addHandler(cb);
      60 |     }
      61 |     removeUserSignedIn(cb) {
      62 |         this._userSignedIn.removeHandler(cb);
      63 |     }
      64 |     _raiseUserSignedIn() {
      65 |         Log.debug("UserManagerEvents._raiseUserSignedIn");
      66 |         this._userSignedIn.raise();
      67 |     }
      68 | 
      69 |     addUserSignedOut(cb) {
      70 |         this._userSignedOut.addHandler(cb);
      71 |     }
      72 |     removeUserSignedOut(cb) {
      73 |         this._userSignedOut.removeHandler(cb);
      74 |     }
      75 |     _raiseUserSignedOut() {
      76 |         Log.debug("UserManagerEvents._raiseUserSignedOut");
      77 |         this._userSignedOut.raise();
      78 |     }
      79 | 
      80 |     addUserSessionChanged(cb) {
      81 |         this._userSessionChanged.addHandler(cb);
      82 |     }
      83 |     removeUserSessionChanged(cb) {
      84 |         this._userSessionChanged.removeHandler(cb);
      85 |     }
      86 |     _raiseUserSessionChanged() {
      87 |         Log.debug("UserManagerEvents._raiseUserSessionChanged");
      88 |         this._userSessionChanged.raise();
      89 |     }
      90 | }
      91 | 
      
      
      --------------------------------------------------------------------------------
      /src/WebStorageStateStore.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from './Log.js';
       5 | import { Global } from './Global.js';
       6 | 
       7 | export class WebStorageStateStore {
       8 |     constructor({prefix = "oidc.", store = Global.localStorage} = {}) {
       9 |         this._store = store;
      10 |         this._prefix = prefix;
      11 |     }
      12 | 
      13 |     set(key, value) {
      14 |         Log.debug("WebStorageStateStore.set", key);
      15 | 
      16 |         key = this._prefix + key;
      17 | 
      18 |         this._store.setItem(key, value);
      19 | 
      20 |         return Promise.resolve();
      21 |     }
      22 | 
      23 |     get(key) {
      24 |         Log.debug("WebStorageStateStore.get", key);
      25 | 
      26 |         key = this._prefix + key;
      27 | 
      28 |         let item = this._store.getItem(key);
      29 | 
      30 |         return Promise.resolve(item);
      31 |     }
      32 | 
      33 |     remove(key) {
      34 |         Log.debug("WebStorageStateStore.remove", key);
      35 | 
      36 |         key = this._prefix + key;
      37 | 
      38 |         let item = this._store.getItem(key);
      39 |         this._store.removeItem(key);
      40 | 
      41 |         return Promise.resolve(item);
      42 |     }
      43 | 
      44 |     getAllKeys() {
      45 |         Log.debug("WebStorageStateStore.getAllKeys");
      46 | 
      47 |         var keys = [];
      48 | 
      49 |         for (let index = 0; index < this._store.length; index++) {
      50 |             let key = this._store.key(index);
      51 | 
      52 |             if (key.indexOf(this._prefix) === 0) {
      53 |                 keys.push(key.substr(this._prefix.length));
      54 |             }
      55 |         }
      56 | 
      57 |         return Promise.resolve(keys);
      58 |     }
      59 | }
      60 | 
      
      
      --------------------------------------------------------------------------------
      /src/crypto/jsrsasign.js:
      --------------------------------------------------------------------------------
       1 | import { jws, KEYUTIL as KeyUtil, X509, crypto, hextob64u, b64tohex } from '../../jsrsasign/dist/jsrsasign.js';
       2 | 
       3 | const AllowedSigningAlgs = ['RS256', 'RS384', 'RS512', 'PS256', 'PS384', 'PS512', 'ES256', 'ES384', 'ES512'];
       4 | 
       5 | export {
       6 |     jws,
       7 |     KeyUtil,
       8 |     X509,
       9 |     crypto,
      10 |     hextob64u,
      11 |     b64tohex,
      12 |     AllowedSigningAlgs
      13 | };
      14 | 
      
      
      --------------------------------------------------------------------------------
      /src/random.js:
      --------------------------------------------------------------------------------
       1 | /**
       2 |  * Generates RFC4122 version 4 guid ()
       3 |  */
       4 | 
       5 | var crypto = (typeof window !== 'undefined') ? (window.crypto || window.msCrypto) : null;
       6 | 
       7 | function _cryptoUuidv4() {
       8 |   return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
       9 |     (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
      10 |   )
      11 | }
      12 | 
      13 | function _uuidv4() {
      14 |     return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
      15 |     (c ^ Math.random() * 16 >> c / 4).toString(16)
      16 |   )
      17 | }
      18 | 
      19 | export default function random() {
      20 |   var hasCrypto = crypto != 'undefined' && crypto !== null;
      21 |   var hasRandomValues = hasCrypto && (typeof(crypto.getRandomValues) != 'undefined');  
      22 |   var uuid = hasRandomValues ? _cryptoUuidv4 : _uuidv4;
      23 |   return uuid().replace(/-/g, '');
      24 | }
      25 | 
      
      
      --------------------------------------------------------------------------------
      /test/conformance/Oidc-Client-Conformance/Oidc-Client-Conformance.sln:
      --------------------------------------------------------------------------------
       1 | 
       2 | Microsoft Visual Studio Solution File, Format Version 12.00
       3 | # Visual Studio 14
       4 | VisualStudioVersion = 14.0.25420.1
       5 | MinimumVisualStudioVersion = 10.0.40219.1
       6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Oidc-Client-Conformance", "Oidc-Client-Conformance\Oidc-Client-Conformance.csproj", "{78D83E70-6DA9-44C6-9F8E-FEEB0897EDE0}"
       7 | EndProject
       8 | Global
       9 | 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
      10 | 		Debug|Any CPU = Debug|Any CPU
      11 | 		Release|Any CPU = Release|Any CPU
      12 | 	EndGlobalSection
      13 | 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
      14 | 		{78D83E70-6DA9-44C6-9F8E-FEEB0897EDE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
      15 | 		{78D83E70-6DA9-44C6-9F8E-FEEB0897EDE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
      16 | 		{78D83E70-6DA9-44C6-9F8E-FEEB0897EDE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
      17 | 		{78D83E70-6DA9-44C6-9F8E-FEEB0897EDE0}.Release|Any CPU.Build.0 = Release|Any CPU
      18 | 	EndGlobalSection
      19 | 	GlobalSection(SolutionProperties) = preSolution
      20 | 		HideSolutionNode = FALSE
      21 | 	EndGlobalSection
      22 | EndGlobal
      23 | 
      
      
      --------------------------------------------------------------------------------
      /test/conformance/Oidc-Client-Conformance/Oidc-Client-Conformance/Properties/AssemblyInfo.cs:
      --------------------------------------------------------------------------------
       1 | using System.Reflection;
       2 | using System.Runtime.CompilerServices;
       3 | using System.Runtime.InteropServices;
       4 | 
       5 | // General Information about an assembly is controlled through the following 
       6 | // set of attributes. Change these attribute values to modify the information
       7 | // associated with an assembly.
       8 | [assembly: AssemblyTitle("Oidc_Client_Conformance")]
       9 | [assembly: AssemblyDescription("")]
      10 | [assembly: AssemblyConfiguration("")]
      11 | [assembly: AssemblyCompany("")]
      12 | [assembly: AssemblyProduct("Oidc_Client_Conformance")]
      13 | [assembly: AssemblyCopyright("Copyright ©  2017")]
      14 | [assembly: AssemblyTrademark("")]
      15 | [assembly: AssemblyCulture("")]
      16 | 
      17 | // Setting ComVisible to false makes the types in this assembly not visible 
      18 | // to COM components.  If you need to access a type in this assembly from 
      19 | // COM, set the ComVisible attribute to true on that type.
      20 | [assembly: ComVisible(false)]
      21 | 
      22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
      23 | [assembly: Guid("78d83e70-6da9-44c6-9f8e-feeb0897ede0")]
      24 | 
      25 | // Version information for an assembly consists of the following four values:
      26 | //
      27 | //      Major Version
      28 | //      Minor Version 
      29 | //      Build Number
      30 | //      Revision
      31 | //
      32 | // You can specify all the values or you can default the Revision and Build Numbers 
      33 | // by using the '*' as shown below:
      34 | [assembly: AssemblyVersion("1.0.0.0")]
      35 | [assembly: AssemblyFileVersion("1.0.0.0")]
      36 | 
      
      
      --------------------------------------------------------------------------------
      /test/conformance/Oidc-Client-Conformance/Oidc-Client-Conformance/Web.Debug.config:
      --------------------------------------------------------------------------------
       1 | 
       2 | 
       3 | 
       4 | 
       5 | 
       6 |   
      17 |   
      18 |     
      29 |   
      30 | 
      
      
      --------------------------------------------------------------------------------
      /test/conformance/Oidc-Client-Conformance/Oidc-Client-Conformance/Web.Release.config:
      --------------------------------------------------------------------------------
       1 | 
       2 | 
       3 | 
       4 | 
       5 | 
       6 |   
      17 |   
      18 |     
      19 |     
      30 |   
      31 | 
      
      
      --------------------------------------------------------------------------------
      /test/conformance/Oidc-Client-Conformance/Oidc-Client-Conformance/Web.config:
      --------------------------------------------------------------------------------
       1 | 
       2 | 
       6 | 
       7 |   
       8 |     
       9 |     
      10 |   
      11 |   
      12 |     
      13 |       
      16 |       
      19 |     
      20 |   
      21 | 
      
      
      --------------------------------------------------------------------------------
      /test/conformance/Oidc-Client-Conformance/Oidc-Client-Conformance/app.css:
      --------------------------------------------------------------------------------
      1 | pre {
      2 |     padding:10px;
      3 |     width: 100%;
      4 |     background-color: lightgray;
      5 | }
      
      
      --------------------------------------------------------------------------------
      /test/conformance/Oidc-Client-Conformance/Oidc-Client-Conformance/callback.html:
      --------------------------------------------------------------------------------
       1 | 
       2 | 
       3 |     
       4 |         oidc-client test
       5 |         
       6 |     
       7 |     
       8 |         
      9 |
      10 | back to index 11 |
      12 |
      
      13 |         
      14 |         
      15 |         
      26 |     
      27 | 
      28 | 
      
      
      --------------------------------------------------------------------------------
      /test/conformance/Oidc-Client-Conformance/Oidc-Client-Conformance/index.html:
      --------------------------------------------------------------------------------
       1 | 
       2 | 
       3 | 
       4 |     oidc-client test
       5 |     
       6 | 
       7 | 
       8 |     
      9 | 10 | log for this test 11 |
      12 | 13 |
      
      14 | 
      15 |     
      16 |     
      17 |     
      18 |     
      19 |     
      20 | 
      21 | 
      22 | 
      
      
      --------------------------------------------------------------------------------
      /test/conformance/Oidc-Client-Conformance/Oidc-Client-Conformance/log.js:
      --------------------------------------------------------------------------------
       1 | function log() {
       2 |     document.getElementById('out').innerText = '';
       3 | 
       4 |     Array.prototype.forEach.call(arguments, function(msg) {
       5 |         if (msg instanceof Error){
       6 |             msg = "Error: " + msg.message;
       7 |         }
       8 |         else if (typeof msg !== 'string') {
       9 |             msg = JSON.stringify(msg, null, 2);
      10 |         }
      11 |         document.getElementById('out').innerHTML += msg + '\r\n';
      12 |     });
      13 | }
      14 | 
      
      
      --------------------------------------------------------------------------------
      /test/conformance/Oidc-Client-Conformance/Oidc-Client-Conformance/packages.config:
      --------------------------------------------------------------------------------
      1 | 
      2 | 
      3 |   
      4 |   
      5 | 
      
      
      --------------------------------------------------------------------------------
      /test/integration/OidcClient.spec.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | IdentityModel.Log.logger = console;
       5 | 
       6 | window.sessionStorage.clear();
       7 | window.localStorage.clear();
       8 | 
       9 | describe("OidcClient", function() {
      10 |     
      11 |     var settings;
      12 |     var oidcClient;
      13 |     
      14 |     beforeEach(function() {
      15 |         IdentityModel.Log.level = IdentityModel.Log.NONE;
      16 | 
      17 |         settings = {
      18 |             authority: 'http://localhost:5000/oidc',
      19 |             metadata: oidc.metadata,
      20 |             signingKeys: oidc.signingKeys,
      21 |             
      22 |             client_id: 'js.tokenmanager',
      23 |             redirect_uri: 'http://localhost:5000/index.html',
      24 |             post_logout_redirect_uri: 'http://localhost:5000/index.html',
      25 |             response_type: 'id_token token',
      26 |             scope: 'openid email roles',
      27 | 
      28 |             filterProtocolClaims: true,
      29 |             loadUserInfo: false
      30 |         };
      31 |         
      32 |         oidcClient = new IdentityModel.OidcClient(settings);
      33 |     });
      34 |     
      35 |     it("should perform signin", function(done) {
      36 |         
      37 |         oidcClient.createSigninRequest({data:{foo:1}}).then(function(req){
      38 |             
      39 |             var url = oidc.processAuthorization(req.url);
      40 | 
      41 |             oidcClient.processSigninResponse(url).then(function(res){
      42 |                 
      43 |                 assert(res, "result");
      44 |                 assert(res.state, "res.result");
      45 |                 assert(res.state.foo === 1, "foo===1");
      46 |                 
      47 |                 done();
      48 |             }, function(e){
      49 |                 fail(e);
      50 |             });
      51 |         }, function(e){
      52 |             fail(e);
      53 |         });
      54 |     });
      55 |     
      56 |     it("should perform signout", function(done) {
      57 |         
      58 |         oidcClient.createSignoutRequest({data:{foo:1}}).then(function(req){
      59 |             
      60 |             var url = oidc.processEndSession(req.url);
      61 | 
      62 |             oidcClient.processSignoutResponse(url).then(function(res){
      63 |                 
      64 |                 assert(res, "result");
      65 |                 assert(res.state, "res.result");
      66 |                 assert(res.state.foo === 1, "foo===1");
      67 |                 
      68 |                 done();
      69 |             }, function(e){
      70 |                 fail(e);
      71 |             });
      72 |         }, function(e){
      73 |             fail(e);
      74 |         });
      75 |     });
      76 | });
      77 | 
      
      
      --------------------------------------------------------------------------------
      /test/unit/ErrorResponse.spec.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from '../../src/Log';
       5 | import { ErrorResponse } from '../../src/ErrorResponse';
       6 | 
       7 | import chai from 'chai';
       8 | chai.should();
       9 | let assert = chai.assert;
      10 | let expect = chai.expect;
      11 | 
      12 | describe("ErrorResponse", function() {
      13 | 
      14 |     describe("constructor", function() {
      15 | 
      16 |         it("should require a error param", function() {
      17 |             try {
      18 |                 new ErrorResponse({});
      19 |             }
      20 |             catch (e) {
      21 |                 e.message.should.contain('error');
      22 |                 return;
      23 |             }
      24 |             assert.fail();
      25 |         });
      26 | 
      27 |         it("should read error", function() {
      28 |             let subject = new ErrorResponse({error:"foo"});
      29 |             subject.error.should.equal("foo");
      30 |         });
      31 | 
      32 |         it("should read error_description", function() {
      33 |             let subject = new ErrorResponse({error:"error", error_description:"foo"});
      34 |             subject.error_description.should.equal("foo");
      35 |         });
      36 | 
      37 |         it("should read error_uri", function() {
      38 |             let subject = new ErrorResponse({error:"error", error_uri:"foo"});
      39 |             subject.error_uri.should.equal("foo");
      40 |         });
      41 | 
      42 |         it("should read state", function() {
      43 |             let subject = new ErrorResponse({error:"error", state:"foo"});
      44 |             subject.state.should.equal("foo");
      45 |         });
      46 |     });
      47 | 
      48 |     describe("message", function() {
      49 |         it("should be description if set", function() {
      50 |             let subject = new ErrorResponse({error:"error", error_description:"foo"});
      51 |             subject.message.should.equal("foo");
      52 |         });
      53 | 
      54 |         it("should be error if description not set", function() {
      55 |             let subject = new ErrorResponse({error:"error"});
      56 |             subject.message.should.equal("error");
      57 |         });
      58 | 
      59 |     });
      60 | 
      61 |     describe("name", function() {
      62 |         it("should be class name", function() {
      63 |             let subject = new ErrorResponse({error:"error"});
      64 |             subject.name.should.equal("ErrorResponse");
      65 |         });
      66 | 
      67 |     });
      68 | 
      69 |     describe("stack", function() {
      70 | 
      71 |         it("should be set", function() {
      72 |             let subject = new ErrorResponse({error:"error"});
      73 |             subject.stack.should.be.ok;
      74 |         });
      75 | 
      76 |     });
      77 | });
      78 | 
      
      
      --------------------------------------------------------------------------------
      /test/unit/Event.spec.js:
      --------------------------------------------------------------------------------
        1 | 
        2 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
        3 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
        4 | 
        5 | import { Event } from '../../src/Event';
        6 | 
        7 | import chai from 'chai';
        8 | chai.should();
        9 | let assert = chai.assert;
       10 | 
       11 | describe("Event", function () {
       12 | 
       13 |     let subject;
       14 | 
       15 |     beforeEach(function () {
       16 |         subject = new Event("test name");
       17 |     });
       18 | 
       19 |     describe("addHandler", function () {
       20 | 
       21 |         it("should allow callback to be invoked", function () {
       22 |             var cb = function () {
       23 |                 cb.wasCalled = true;
       24 |             };
       25 |             subject.addHandler(cb);
       26 | 
       27 |             subject.raise();
       28 | 
       29 |             cb.wasCalled.should.be.true;
       30 |         });
       31 | 
       32 |         it("should allow multiple callbacks", function () {
       33 |             var count = 0;
       34 |             var cb = function () {
       35 |                 count++;
       36 |             };
       37 |             subject.addHandler(cb);
       38 |             subject.addHandler(cb);
       39 |             subject.addHandler(cb);
       40 |             subject.addHandler(cb);
       41 | 
       42 |             subject.raise();
       43 | 
       44 |             count.should.equal(4);
       45 |         });
       46 | 
       47 |     });
       48 | 
       49 |     describe("removeHandler", function () {
       50 | 
       51 |         it("should remove callback from being invoked", function () {
       52 |             var cb = function () {
       53 |                 cb.wasCalled = true;
       54 |             };
       55 |             cb.wasCalled = false;
       56 | 
       57 |             subject.addHandler(cb);
       58 |             subject.removeHandler(cb);
       59 |             subject.raise();
       60 | 
       61 |             cb.wasCalled.should.be.false;
       62 |         });
       63 | 
       64 |         it("should remove individual callback", function () {
       65 |             var count = 0;
       66 |             var cb1 = function () {
       67 |                 count++;
       68 |             };
       69 |             var cb2 = function () {
       70 |                 cb2.wasCalled = true;
       71 |             };
       72 | 
       73 |             subject.addHandler(cb1);
       74 |             subject.addHandler(cb2);
       75 |             subject.addHandler(cb1);
       76 |             subject.removeHandler(cb1);
       77 |             subject.removeHandler(cb1);
       78 | 
       79 |             subject.raise();
       80 | 
       81 |             count.should.equal(0);
       82 |             cb2.wasCalled.should.be.true;
       83 |         });
       84 | 
       85 |     });
       86 | 
       87 |     describe("raise", function () {
       88 | 
       89 |         it("should pass params", function () {
       90 |             var cb = function (a,b,c) {
       91 |                 a.should.equal(1);
       92 |                 b.should.equal(2);
       93 |                 c.should.equal(3);
       94 |             };
       95 |             subject.addHandler(cb);
       96 | 
       97 |             subject.raise(1,2,3);
       98 |         });
       99 | 
      100 |         it("should allow passing no params", function () {
      101 |             var cb = function (a,b,c) {
      102 |                 assert.isUndefined(a);
      103 |                 assert.isUndefined(b);
      104 |                 assert.isUndefined(c);
      105 |             };
      106 |             subject.addHandler(cb);
      107 | 
      108 |             subject.raise();
      109 |         });
      110 | 
      111 |     });
      112 | 
      113 | });
      114 | 
      
      
      --------------------------------------------------------------------------------
      /test/unit/SigninState.spec.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from '../../src/Log';
       5 | import { SigninState } from '../../src/SigninState';
       6 | 
       7 | import chai from 'chai';
       8 | chai.should();
       9 | let assert = chai.assert;
      10 | 
      11 | describe("SigninState", function() {
      12 | 
      13 |     beforeEach(function(){
      14 |         Log.level = Log.NONE;
      15 |         Log.logger = console;
      16 |     });
      17 | 
      18 |     describe("constructor", function() {
      19 | 
      20 |         it("should call base ctor", function() {
      21 |             var subject = new SigninState({ id: 5, created:6, data:7 });
      22 |             subject.id.should.be.equal(5);
      23 |             subject.created.should.be.equal(6);
      24 |             subject.data.should.be.equal(7);
      25 |         });
      26 | 
      27 |         it("should accept nonce", function() {
      28 |             var subject = new SigninState({ nonce: 5 });
      29 |             subject.nonce.should.be.equal(5);
      30 |         });
      31 | 
      32 |         it("should generate nonce", function() {
      33 |             var subject = new SigninState({ nonce: true });
      34 |             subject.nonce.should.be.ok;
      35 |         });
      36 | 
      37 |         it("should accept redirect_uri", function() {
      38 |             var subject = new SigninState({ redirect_uri: "http://cb" });
      39 |             subject.redirect_uri.should.be.equal("http://cb");
      40 |         });
      41 | 
      42 |         it("should accept code_verifier", function() {
      43 |             var subject = new SigninState({ code_verifier: 5 });
      44 |             subject.code_verifier.should.be.equal(5);
      45 |         });
      46 | 
      47 |         it("should generate code_verifier", function() {
      48 |             var subject = new SigninState({ code_verifier: true });
      49 |             subject.code_verifier.should.be.ok;
      50 |         });
      51 | 
      52 |         it("should generate code_challenge", function() {
      53 |             var subject = new SigninState({ code_verifier: true });
      54 |             subject.code_challenge.should.be.ok;
      55 |         });
      56 | 
      57 |         it("should accept client_id", function() {
      58 |             var subject = new SigninState({ client_id: "client" });
      59 |             subject.client_id.should.be.equal("client");
      60 |         });
      61 | 
      62 |         it("should accept authority", function() {
      63 |             var subject = new SigninState({ authority: "test" });
      64 |             subject.authority.should.be.equal("test");
      65 |         });
      66 |         
      67 |         it("should accept request_type", function() {
      68 |             var subject = new SigninState({ request_type: 'xoxo' });
      69 |             subject.request_type.should.be.equal('xoxo');
      70 |         });
      71 | 
      72 |         it("should accept extraTokenParams", function() {
      73 |             var subject = new SigninState({ extraTokenParams: { 'resourceServer' : 'abc' } });
      74 |             assert.deepEqual(subject.extraTokenParams, { 'resourceServer' : 'abc' });
      75 |         });
      76 |     });
      77 | 
      78 |     it("can serialize and then deserialize", function() {
      79 |         var subject1 = new SigninState({ nonce: true, data: { foo: "test" }, created: 1000, client_id:"client", authority:"authority", redirect_uri:"http://cb", code_verifier:true, request_type:'type' });
      80 | 
      81 |         var storage = subject1.toStorageString();
      82 |         var subject2 = SigninState.fromStorageString(storage);
      83 | 
      84 |         subject2.should.be.deep.equal(subject1);
      85 |     });
      86 | 
      87 | });
      88 | 
      
      
      --------------------------------------------------------------------------------
      /test/unit/SignoutRequest.spec.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from '../../src/Log';
       5 | import { SignoutRequest } from '../../src/SignoutRequest';
       6 | 
       7 | import chai from 'chai';
       8 | chai.should();
       9 | let assert = chai.assert;
      10 | 
      11 | describe("SignoutRequest", function() {
      12 | 
      13 |     let subject;
      14 |     let settings;
      15 | 
      16 |     beforeEach(function() {
      17 |         settings = {
      18 |             url: "http://sts/signout",
      19 |             id_token_hint: "hint",
      20 |             post_logout_redirect_uri: "loggedout",
      21 |             data: { data: "test" }
      22 |         };
      23 |         subject = new SignoutRequest(settings);
      24 |     });
      25 | 
      26 |     describe("constructor", function() {
      27 | 
      28 |         it("should require a url param", function() {
      29 |             try {
      30 |                 delete settings.url;
      31 |                 new SignoutRequest(settings);
      32 |             }
      33 |             catch (e) {
      34 |                 e.message.should.contain('url');
      35 |                 return;
      36 |             }
      37 |             assert.fail();
      38 |         });
      39 | 
      40 |     });
      41 | 
      42 |     describe("url", function() {
      43 | 
      44 |         it("should include url", function() {
      45 |             subject.url.indexOf("http://sts/signout").should.equal(0);
      46 |         });
      47 | 
      48 |         it("should include id_token_hint", function() {
      49 |             subject.url.should.contain("id_token_hint=hint");
      50 |         });
      51 | 
      52 |         it("should include post_logout_redirect_uri if id_token_hint also provided", function() {
      53 |             subject.url.should.contain("post_logout_redirect_uri=loggedout");
      54 |         });
      55 | 
      56 |         it("should include post_logout_redirect_uri if no id_token_hint provided", function() {
      57 | 
      58 |             delete settings.id_token_hint;
      59 |             subject = new SignoutRequest(settings);
      60 | 
      61 |             subject.url.should.contain("post_logout_redirect_uri=loggedout");
      62 |         });
      63 | 
      64 |         it("should include state if post_logout_redirect_uri provided", function() {
      65 |             subject.url.should.contain("state=" + subject.state.id);
      66 |         });
      67 | 
      68 |         it("should not include state if no post_logout_redirect_uri provided", function() {
      69 |             delete settings.post_logout_redirect_uri;
      70 |             subject = new SignoutRequest(settings);
      71 |             subject.url.should.not.contain("state=");
      72 |         });
      73 | 
      74 | 
      75 |         it("should include id_token_hint, post_logout_redirect_uri, and state", function() {
      76 |             var url = subject.url;
      77 |             url.indexOf('http://sts/signout?').should.equal(0);
      78 |             url.should.contain("id_token_hint=hint");
      79 |             url.should.contain("post_logout_redirect_uri=loggedout");
      80 |             url.should.contain("state=" + subject.state.id);
      81 |         });
      82 | 
      83 |         it("should include extra query params", function() {
      84 |             settings.extraQueryParams = {
      85 |                 'TargetResource': 'logouturl.com',
      86 |                 'InErrorResource': 'errorurl.com'
      87 |             };
      88 |             subject = new SignoutRequest(settings);
      89 |             subject.url.should.contain('TargetResource=logouturl.com&InErrorResource=errorurl.com');
      90 |         });
      91 | 
      92 |     });
      93 | 
      94 | });
      95 | 
      
      
      --------------------------------------------------------------------------------
      /test/unit/SignoutResponse.spec.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from '../../src/Log';
       5 | import { SignoutResponse } from '../../src/SignoutResponse';
       6 | import { ErrorResponse } from '../../src/ErrorResponse';
       7 | 
       8 | import chai from 'chai';
       9 | chai.should();
      10 | let assert = chai.assert;
      11 | let expect = chai.expect;
      12 | 
      13 | describe("SignoutResponse", function() {
      14 | 
      15 |     describe("constructor", function() {
      16 | 
      17 |         it("should read error", function () {
      18 |             let subject = new SignoutResponse("error=foo");
      19 |             subject.error.should.equal("foo");
      20 |         });
      21 | 
      22 |         it("should read error_description", function () {
      23 |             let subject = new SignoutResponse("error_description=foo");
      24 |             subject.error_description.should.equal("foo");
      25 |         });
      26 | 
      27 |         it("should read error_uri", function () {
      28 |             let subject = new SignoutResponse("error_uri=foo");
      29 |             subject.error_uri.should.equal("foo");
      30 |         });
      31 | 
      32 |         it("should read state", function() {
      33 |             let subject = new SignoutResponse("state=foo");
      34 |             subject.state.should.equal("foo");
      35 |         });
      36 | 
      37 |     });
      38 | 
      39 | });
      40 | 
      
      
      --------------------------------------------------------------------------------
      /test/unit/StubJsonService.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { Log } from '../../src/Log';
       5 | 
       6 | export class StubJsonService {
       7 |     getJson(url, token) {
       8 |         Log.debug("StubJsonService.getJson", this.result);
       9 | 
      10 |         this.url = url;
      11 |         this.token = token;
      12 |         return this.result;
      13 |     }
      14 | }
      15 | 
      
      
      --------------------------------------------------------------------------------
      /test/unit/StubMetadataService.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | export class StubMetadataService{
       5 |     resetSigningKeys(){ }
       6 |     getMetadata(){
       7 |         return this.getMetadataResult;
       8 |     }
       9 |     getIssuer(){
      10 |         return this.getIssuerResult;
      11 |     }
      12 |     getAuthorizationEndpoint(){
      13 |         return this.getAuthorizationEndpointResult;
      14 |     }
      15 |     getEndSessionEndpoint(){
      16 |         return this.getEndSessionEndpointResult;
      17 |     }
      18 |     getUserInfoEndpoint(){
      19 |         return this.userInfoEndpointResult;
      20 |     }
      21 |     getSigningKeys(){
      22 |         return this.getSigningKeysResult;
      23 |     }
      24 | }
      25 | 
      
      
      --------------------------------------------------------------------------------
      /test/unit/StubResponseValidator.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | export class StubResponseValidator {
       5 |     validateSigninResponse(state, response) {
       6 | 
       7 |         this.signinState = state;
       8 |         this.signinResponse = response;
       9 | 
      10 |         return Promise.resolve(response);
      11 |     }
      12 | 
      13 |     validateSignoutResponse(state, response) {
      14 | 
      15 |         this.signoutState = state;
      16 |         this.signoutResponse = response;
      17 | 
      18 |         return Promise.resolve(response);
      19 |     }
      20 | }
      21 | 
      
      
      --------------------------------------------------------------------------------
      /test/unit/StubSilentRenewService.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | export class StubSilentRenewService {
       5 |     start(){
       6 |     }
       7 |     stop(){
       8 |     }
       9 | }
      10 | 
      
      
      --------------------------------------------------------------------------------
      /test/unit/StubStateStore.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | export class StubStateStore {
       5 |     set(key, value) {
       6 |         if (this.error) {
       7 |             return Promise.reject(new Error(this.error));
       8 |         }
       9 |         this.item = value;
      10 |         return Promise.resolve();
      11 |     }
      12 | 
      13 |     get(key) {
      14 |         if (this.error) {
      15 |             return Promise.reject(new Error(this.error));
      16 |         }
      17 |         return Promise.resolve(this.item);
      18 |     }
      19 | 
      20 |     remove(key) {
      21 |         if (this.error) {
      22 |             return Promise.reject(new Error(this.error));
      23 |         }
      24 |         return Promise.resolve(this.item);
      25 |     }
      26 | 
      27 |     getAllKeys(){
      28 |         if (this.item){
      29 |             return Promise.resolve(["key"]);
      30 |         }
      31 |             return Promise.resolve([]);
      32 |     }
      33 |     get length(){
      34 |         return this.item ? 1 : 0;
      35 |     }
      36 | }
      37 | 
      
      
      --------------------------------------------------------------------------------
      /test/unit/StubTokenRevocationClient.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | export class StubTokenRevocationClient {
       5 |     revoke(accessToken, required) {
       6 |         this.accessToken = accessToken;
       7 |         if (this.error) {
       8 |             return Promise.reject(new Error(this.error));
       9 |         }
      10 |         return Promise.resolve();
      11 |     }
      12 | }
      13 | 
      
      
      --------------------------------------------------------------------------------
      /test/unit/UserManagerEvents.spec.js:
      --------------------------------------------------------------------------------
       1 | // Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
       2 | // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
       3 | 
       4 | import { UserManagerEvents } from '../../src/UserManagerEvents';
       5 | 
       6 | import chai from 'chai';
       7 | chai.should();
       8 | let assert = chai.assert;
       9 | 
      10 | describe("UserManagerEvents", function () {
      11 | 
      12 |     let subject;
      13 | 
      14 |     beforeEach(function () {
      15 |         subject = new UserManagerEvents();
      16 |     });
      17 | 
      18 |     describe("silent renew error", function () {
      19 | 
      20 |         it("should allow callback", function () {
      21 |             var cb = function () {
      22 |                 cb.wasCalled = true;
      23 |             };
      24 |             subject.addSilentRenewError(cb);
      25 | 
      26 |             subject._raiseSilentRenewError(new Error("boom"));
      27 | 
      28 |             cb.wasCalled.should.be.true;
      29 |         });
      30 | 
      31 |         it("should allow unregistering callback", function () {
      32 |             var cb = function () {
      33 |                 cb.wasCalled = true;
      34 |             };
      35 |             cb.wasCalled = false;
      36 | 
      37 |             subject.addSilentRenewError(cb);
      38 |             subject.removeSilentRenewError(cb);
      39 | 
      40 |             subject._raiseSilentRenewError(new Error("boom"));
      41 | 
      42 |             cb.wasCalled.should.be.false;
      43 |         });
      44 | 
      45 |         it("should pass error to callback", function () {
      46 |             var cb = function (e) {
      47 |                 e.message.should.equal("boom");
      48 |             };
      49 |             subject.addSilentRenewError(cb);
      50 | 
      51 |             subject._raiseSilentRenewError(new Error("boom"));
      52 |         });
      53 | 
      54 |     });
      55 | 
      56 | });
      57 | 
      
      
      --------------------------------------------------------------------------------
      /test/unit/random.spec.js:
      --------------------------------------------------------------------------------
       1 | import random from '../../src/random'
       2 | 
       3 | const pattern = /^[0-9a-f]{8}[0-9a-f]{4}4[0-9a-f]{3}[89ab][0-9a-f]{3}[0-9a-f]{12}$/
       4 | //const pattern = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/
       5 | 
       6 | 
       7 | describe('random', function() {
       8 |   it('should return a valid RFC4122 v4 guid (sans dashes)', function(){
       9 |     const rnd = random()
      10 |     console.log(rnd);
      11 |     rnd.should.match(pattern)
      12 |   }) 
      13 | })
      14 | 
      15 | 
      
      
      --------------------------------------------------------------------------------
      /version.js:
      --------------------------------------------------------------------------------
      1 | const Version = "1.11.6-beta.1"; export {Version};
      
      
      --------------------------------------------------------------------------------
      /webpack.base.js:
      --------------------------------------------------------------------------------
       1 | // create a webpack configuration with all common parts included here
       2 | function createWebpackConfig(options) {
       3 |   return {
       4 |     mode: options.mode,
       5 |     entry: options.entry,
       6 |     output: options.output,
       7 |     plugins: options.plugins,
       8 |     node: {
       9 |       fs: 'empty', // Because of jsrsasign usage of fs
      10 |       buffer: 'empty'
      11 |     },
      12 |     module: {
      13 |       rules: [
      14 |         {
      15 |           test: /.js$/,
      16 |           loaders: ['babel-loader'],
      17 |           exclude: /node_modules/,
      18 |           include: __dirname
      19 |         }
      20 |       ]
      21 |     },
      22 |     // this is for the sourcemaps
      23 |     devtool: options.devtool,
      24 |     optimization: options.optimization
      25 |   };
      26 | }
      27 | 
      28 | module.exports = createWebpackConfig;
      29 | 
      
      
      --------------------------------------------------------------------------------