@nsshunt/stsoauth2plugin 0.1.66 → 0.1.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/stores/testStore.js +25 -0
- package/dist/stores/testStore.js.map +1 -0
- package/package.json +7 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/stores/testStore.d.ts +8 -0
- package/types/stores/testStore.d.ts.map +1 -0
- package/.eslintrc.json +0 -27
- package/.github/dependabot.yml +0 -13
- package/.github/workflows/npm-publish.yml +0 -54
- package/babel.config.json +0 -6
- package/build.sh +0 -29
- package/package-bak.json +0 -49
- package/package-vite.json +0 -58
- package/src/Utils/CryptoUtils.ts +0 -32
- package/src/Utils/QueryParams.ts +0 -48
- package/src/index.test.ts +0 -10
- package/src/index.ts +0 -13
- package/src/stsStorage.ts +0 -158
- package/src/stsoauth2launcher.ts +0 -13
- package/src/stsoauth2manager.ts +0 -438
- package/src/stsoauth2types.ts +0 -134
- package/src/stsoauth2worker.ts +0 -595
- package/tsconfig.json +0 -34
- package/vite.config.ts +0 -63
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { STSOAuth2Manager } from './stsoauth2manager';
|
|
|
2
2
|
export * from './stsoauth2types';
|
|
3
3
|
export * from './stsoauth2manager';
|
|
4
4
|
export * from './stsoauth2worker';
|
|
5
|
+
export * from './stores/testStore';
|
|
5
6
|
export const STSOAuth2ManagerPlugin = {
|
|
6
7
|
install: (app, options) => {
|
|
7
8
|
const om = new STSOAuth2Manager(app, options);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAGrD,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AAEjC,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACrC,OAAO,EAAE,CAAC,GAAG,EAAE,OAAiC,EAAE,EAAE;QACnD,MAAM,EAAE,GAAG,IAAI,gBAAgB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC9C,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IAC1C,CAAC;CACD,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAGrD,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AAEjC,cAAc,oBAAoB,CAAA;AAElC,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACrC,OAAO,EAAE,CAAC,GAAG,EAAE,OAAiC,EAAE,EAAE;QACnD,MAAM,EAAE,GAAG,IAAI,gBAAgB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC9C,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IAC1C,CAAC;CACD,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { defineStore } from 'pinia';
|
|
2
|
+
// Replace with pinia
|
|
3
|
+
// https://pinia.vuejs.org/
|
|
4
|
+
// https://seb-l.github.io/pinia-plugin-persist/
|
|
5
|
+
export const TestStore = defineStore('__xxx_test', {
|
|
6
|
+
state: () => {
|
|
7
|
+
return {
|
|
8
|
+
count: 0
|
|
9
|
+
};
|
|
10
|
+
},
|
|
11
|
+
actions: {
|
|
12
|
+
UpdateCount() {
|
|
13
|
+
this.count++;
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
getters: {
|
|
17
|
+
CountXX: (state) => {
|
|
18
|
+
return state.count * 2;
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
persist: {
|
|
22
|
+
storage: window.sessionStorage
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=testStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testStore.js","sourceRoot":"","sources":["../../src/stores/testStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,OAAO,CAAA;AAGhD,qBAAqB;AACrB,2BAA2B;AAC3B,gDAAgD;AAChD,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAC,YAAY,EAAE;IAClD,KAAK,EAAE,GAAG,EAAE;QACX,OAAO;YACN,KAAK,EAAE,CAAC;SACR,CAAA;IACF,CAAC;IACD,OAAO,EAAE;QACR,WAAW;YACV,IAAI,CAAC,KAAK,EAAE,CAAC;QACd,CAAC;KACD;IACD,OAAO,EAAE;QACR,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YAClB,OAAO,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC;QACxB,CAAC;KACD;IACD,OAAO,EAAE;QACR,OAAO,EAAE,MAAM,CAAC,cAAc;KAC9B;CACD,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nsshunt/stsoauth2plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.69",
|
|
4
4
|
"description": "STS OAuth2 VUE Plugin",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -15,6 +15,12 @@
|
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "git+https://github.com/nsshunt/stsoauth2plugin.git"
|
|
17
17
|
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/*",
|
|
20
|
+
"types/*",
|
|
21
|
+
"LICENSE",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
18
24
|
"author": "STS",
|
|
19
25
|
"license": "MIT",
|
|
20
26
|
"bugs": {
|
package/types/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ISTSOAuth2ManagerOptions } from './stsoauth2types';
|
|
|
2
2
|
export * from './stsoauth2types';
|
|
3
3
|
export * from './stsoauth2manager';
|
|
4
4
|
export * from './stsoauth2worker';
|
|
5
|
+
export * from './stores/testStore';
|
|
5
6
|
export declare const STSOAuth2ManagerPlugin: {
|
|
6
7
|
install: (app: any, options: ISTSOAuth2ManagerOptions) => void;
|
|
7
8
|
};
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAE3D,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AAEjC,eAAO,MAAM,sBAAsB;iCACV,wBAAwB;CAIhD,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAE3D,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AAEjC,cAAc,oBAAoB,CAAA;AAElC,eAAO,MAAM,sBAAsB;iCACV,wBAAwB;CAIhD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testStore.d.ts","sourceRoot":"","sources":["../../src/stores/testStore.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS;;;;;;EAmBpB,CAAC"}
|
package/.eslintrc.json
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": {
|
|
3
|
-
"browser": true,
|
|
4
|
-
"es2021": true,
|
|
5
|
-
"node": true,
|
|
6
|
-
"jest": true
|
|
7
|
-
},
|
|
8
|
-
"extends": [
|
|
9
|
-
"eslint:recommended",
|
|
10
|
-
"plugin:@typescript-eslint/recommended"
|
|
11
|
-
],
|
|
12
|
-
"parser": "@typescript-eslint/parser",
|
|
13
|
-
"parserOptions": {
|
|
14
|
-
"ecmaVersion": "latest",
|
|
15
|
-
"sourceType": "module"
|
|
16
|
-
},
|
|
17
|
-
"plugins": [
|
|
18
|
-
"@typescript-eslint"
|
|
19
|
-
],
|
|
20
|
-
"ignorePatterns": ["temp.js", "**/k6scripts/*.js", "**/public/*", "**/dist/*", "**/types/*"],
|
|
21
|
-
"rules": {
|
|
22
|
-
"indent": ["error", "tab"],
|
|
23
|
-
//"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
|
|
24
|
-
"no-mixed-spaces-and-tabs": 0, // disable rule
|
|
25
|
-
"@typescript-eslint/no-var-requires": "warn"
|
|
26
|
-
}
|
|
27
|
-
}
|
package/.github/dependabot.yml
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
-
# package ecosystems to update and where the package manifests are located.
|
|
3
|
-
# Please see the documentation for all configuration options:
|
|
4
|
-
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
5
|
-
#
|
|
6
|
-
# https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates
|
|
7
|
-
|
|
8
|
-
version: 2
|
|
9
|
-
updates:
|
|
10
|
-
- package-ecosystem: "npm" # See documentation for possible values
|
|
11
|
-
directory: "/" # Location of package manifests
|
|
12
|
-
schedule:
|
|
13
|
-
interval: "monthly"
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
|
-
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
|
|
3
|
-
|
|
4
|
-
name: Node.js Package
|
|
5
|
-
|
|
6
|
-
on:
|
|
7
|
-
release:
|
|
8
|
-
types: [created]
|
|
9
|
-
push:
|
|
10
|
-
branches: [ main ]
|
|
11
|
-
|
|
12
|
-
jobs:
|
|
13
|
-
build:
|
|
14
|
-
runs-on: ubuntu-latest
|
|
15
|
-
steps:
|
|
16
|
-
- uses: actions/checkout@v2
|
|
17
|
-
- uses: actions/setup-node@v2
|
|
18
|
-
with:
|
|
19
|
-
node-version: 18
|
|
20
|
-
- run: npm ci
|
|
21
|
-
- run: npm run lint
|
|
22
|
-
- run: npm test
|
|
23
|
-
|
|
24
|
-
publish-npm:
|
|
25
|
-
needs: build
|
|
26
|
-
runs-on: ubuntu-latest
|
|
27
|
-
steps:
|
|
28
|
-
- uses: actions/checkout@v2
|
|
29
|
-
- uses: actions/setup-node@v2
|
|
30
|
-
with:
|
|
31
|
-
node-version: 18
|
|
32
|
-
registry-url: https://registry.npmjs.org/
|
|
33
|
-
- run: npm ci
|
|
34
|
-
- run: npm run build
|
|
35
|
-
- run: npm publish --access public
|
|
36
|
-
env:
|
|
37
|
-
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
|
38
|
-
|
|
39
|
-
# publish-gpr:
|
|
40
|
-
# needs: build
|
|
41
|
-
# runs-on: ubuntu-latest
|
|
42
|
-
# permissions:
|
|
43
|
-
# contents: read
|
|
44
|
-
# packages: write
|
|
45
|
-
# steps:
|
|
46
|
-
# - uses: actions/checkout@v2
|
|
47
|
-
# - uses: actions/setup-node@v2
|
|
48
|
-
# with:
|
|
49
|
-
# node-version: 17
|
|
50
|
-
# registry-url: https://npm.pkg.github.com/
|
|
51
|
-
# - run: npm ci
|
|
52
|
-
# - run: npm publish
|
|
53
|
-
# env:
|
|
54
|
-
# NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
package/babel.config.json
DELETED
package/build.sh
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
rm -rf dist
|
|
3
|
-
rm -rf types
|
|
4
|
-
npm run build
|
|
5
|
-
RESULT=$?
|
|
6
|
-
if [ $RESULT -eq 0 ]; then
|
|
7
|
-
echo success build
|
|
8
|
-
npm run lint
|
|
9
|
-
RESULT=$?
|
|
10
|
-
if [ $RESULT -eq 0 ]; then
|
|
11
|
-
echo success lint
|
|
12
|
-
npm run test
|
|
13
|
-
RESULT=$?
|
|
14
|
-
if [ $RESULT -eq 0 ]; then
|
|
15
|
-
echo success test
|
|
16
|
-
git commit -a -m "changed"
|
|
17
|
-
npm version patch
|
|
18
|
-
npm i
|
|
19
|
-
git commit -a -m "changed"
|
|
20
|
-
git push
|
|
21
|
-
else
|
|
22
|
-
echo failed test
|
|
23
|
-
fi
|
|
24
|
-
else
|
|
25
|
-
echo failed lint
|
|
26
|
-
fi
|
|
27
|
-
else
|
|
28
|
-
echo failed build
|
|
29
|
-
fi
|
package/package-bak.json
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@nsshunt/stsoauth2plugin",
|
|
3
|
-
"version": "0.1.44",
|
|
4
|
-
"description": "STS OAuth2 VUE Plugin",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "./types/index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"lint": "eslint . --ext js,jsx,ts,tsx --fix",
|
|
9
|
-
"test": "jest --detectOpenHandles --no-cache",
|
|
10
|
-
"testwatch": "jest --watchAll --detectOpenHandles --no-cache",
|
|
11
|
-
"build": "tsc",
|
|
12
|
-
"build2": "tsc && vite build"
|
|
13
|
-
},
|
|
14
|
-
"repository": {
|
|
15
|
-
"type": "git",
|
|
16
|
-
"url": "git+https://github.com/nsshunt/stsoauth2plugin.git"
|
|
17
|
-
},
|
|
18
|
-
"author": "STS",
|
|
19
|
-
"license": "MIT",
|
|
20
|
-
"bugs": {
|
|
21
|
-
"url": "https://github.com/nsshunt/stsoauth2plugin/issues"
|
|
22
|
-
},
|
|
23
|
-
"devDependencies": {
|
|
24
|
-
"@babel/preset-env": "^7.18.2",
|
|
25
|
-
"@babel/preset-typescript": "^7.17.12",
|
|
26
|
-
"@tsconfig/node18": "^1.0.0",
|
|
27
|
-
"@types/debug": "^4.1.7",
|
|
28
|
-
"@types/jest": "^28.1.1",
|
|
29
|
-
"@typescript-eslint/eslint-plugin": "^5.28.0",
|
|
30
|
-
"@typescript-eslint/parser": "^5.28.0",
|
|
31
|
-
"eslint": "^8.16.0",
|
|
32
|
-
"jest": "^28.0.2",
|
|
33
|
-
"prettier": "^2.7.1",
|
|
34
|
-
"supertest": "^6.2.2",
|
|
35
|
-
"ts-loader": "^9.3.0",
|
|
36
|
-
"typescript": "^4.7.3"
|
|
37
|
-
},
|
|
38
|
-
"homepage": "https://github.com/nsshunt/stsoauth2plugin#readme",
|
|
39
|
-
"dependencies": {
|
|
40
|
-
"@nsshunt/stsinstrumentation": "^6.11.1",
|
|
41
|
-
"@nsshunt/stsutils": "^1.15.1",
|
|
42
|
-
"axios": "^0.27.2",
|
|
43
|
-
"debug": "^4.3.4",
|
|
44
|
-
"es-cookie": "^1.3.2",
|
|
45
|
-
"http-status-codes": "^2.2.0",
|
|
46
|
-
"jwt-decode": "^3.1.2",
|
|
47
|
-
"vite": "^2.9.12"
|
|
48
|
-
}
|
|
49
|
-
}
|
package/package-vite.json
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@nsshunt/stsoauth2plugin",
|
|
3
|
-
"version": "0.1.52",
|
|
4
|
-
"description": "STS OAuth2 VUE Plugin",
|
|
5
|
-
"files": [
|
|
6
|
-
"dist",
|
|
7
|
-
"types"
|
|
8
|
-
],
|
|
9
|
-
"module": "./dist/stsoauth2plugin.es.js",
|
|
10
|
-
"types": "./types/index.d.ts",
|
|
11
|
-
"exports": {
|
|
12
|
-
".": {
|
|
13
|
-
"import": "./dist/stsoauth2plugin.es.js"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"lint": "eslint . --ext js,jsx,ts,tsx --fix",
|
|
18
|
-
"test": "jest --detectOpenHandles --no-cache",
|
|
19
|
-
"testwatch": "jest --watchAll --detectOpenHandles --no-cache",
|
|
20
|
-
"build2": "tsc",
|
|
21
|
-
"build": "tsc && vite build"
|
|
22
|
-
},
|
|
23
|
-
"repository": {
|
|
24
|
-
"type": "git",
|
|
25
|
-
"url": "git+https://github.com/nsshunt/stsoauth2plugin.git"
|
|
26
|
-
},
|
|
27
|
-
"author": "STS",
|
|
28
|
-
"license": "MIT",
|
|
29
|
-
"bugs": {
|
|
30
|
-
"url": "https://github.com/nsshunt/stsoauth2plugin/issues"
|
|
31
|
-
},
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"@babel/preset-env": "^7.18.2",
|
|
34
|
-
"@babel/preset-typescript": "^7.17.12",
|
|
35
|
-
"@tsconfig/node18": "^1.0.0",
|
|
36
|
-
"@types/debug": "^4.1.7",
|
|
37
|
-
"@types/jest": "^28.1.1",
|
|
38
|
-
"@typescript-eslint/eslint-plugin": "^5.28.0",
|
|
39
|
-
"@typescript-eslint/parser": "^5.28.0",
|
|
40
|
-
"eslint": "^8.16.0",
|
|
41
|
-
"jest": "^28.0.2",
|
|
42
|
-
"prettier": "^2.7.1",
|
|
43
|
-
"supertest": "^6.2.2",
|
|
44
|
-
"ts-loader": "^9.3.0",
|
|
45
|
-
"typescript": "^4.7.3"
|
|
46
|
-
},
|
|
47
|
-
"homepage": "https://github.com/nsshunt/stsoauth2plugin#readme",
|
|
48
|
-
"dependencies": {
|
|
49
|
-
"@nsshunt/stsinstrumentation": "^6.11.1",
|
|
50
|
-
"@nsshunt/stsutils": "^1.15.1",
|
|
51
|
-
"axios": "^0.27.2",
|
|
52
|
-
"debug": "^4.3.4",
|
|
53
|
-
"es-cookie": "^1.3.2",
|
|
54
|
-
"http-status-codes": "^2.2.0",
|
|
55
|
-
"jwt-decode": "^3.1.2",
|
|
56
|
-
"vite": "^2.9.12"
|
|
57
|
-
}
|
|
58
|
-
}
|
package/src/Utils/CryptoUtils.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export class CryptoUtils {
|
|
2
|
-
DigestMessage = async function (message) {
|
|
3
|
-
const encoder = new TextEncoder();
|
|
4
|
-
const data = encoder.encode(message);
|
|
5
|
-
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
|
|
6
|
-
const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
|
|
7
|
-
//let b64 = window.btoa(String.fromCharCode(...hashArray));
|
|
8
|
-
const b64 = btoa(String.fromCharCode(...hashArray));// Use below if a HEX string is required
|
|
9
|
-
// const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); // convert bytes to hex string
|
|
10
|
-
return b64;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
CreateRandomString = (size = 43) => {
|
|
14
|
-
//const randomValues = Array.from(window.crypto.getRandomValues(new Uint8Array(size)))
|
|
15
|
-
const randomValues = Array.from(crypto.getRandomValues(new Uint8Array(size)))
|
|
16
|
-
//let b64 = window.btoa(String.fromCharCode(...randomValues));
|
|
17
|
-
const b64 = btoa(String.fromCharCode(...randomValues));
|
|
18
|
-
return b64;
|
|
19
|
-
//return randomValues.toString('base64');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
CreateRandomStringEx = () => {
|
|
23
|
-
const charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.';
|
|
24
|
-
let random = '';
|
|
25
|
-
//const randomValues = Array.from(window.crypto.getRandomValues(new Uint8Array(43)));
|
|
26
|
-
const randomValues = Array.from(crypto.getRandomValues(new Uint8Array(43)));
|
|
27
|
-
randomValues.forEach(v => (random += charset[v % charset.length]));
|
|
28
|
-
return random;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export default CryptoUtils
|
package/src/Utils/QueryParams.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
// https://github.com/auth0/auth0-spa-js/blob/1de6427f81a8c5b005e9b6d10b9efb1e73542528/static/index.html
|
|
2
|
-
// https://stackoverflow.com/questions/12446317/change-url-without-redirecting-using-javascript
|
|
3
|
-
class QueryParams {
|
|
4
|
-
DecodeQueryParams = (params) => {
|
|
5
|
-
const retObj = { };
|
|
6
|
-
const arr = Object.keys(params)
|
|
7
|
-
.filter(k => typeof params[k] !== 'undefined')
|
|
8
|
-
.map(k => {
|
|
9
|
-
retObj[decodeURIComponent(k)] = decodeURIComponent(params[k]);
|
|
10
|
-
});
|
|
11
|
-
return retObj;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
CreateQueryParams = (params) => {
|
|
15
|
-
return Object.keys(params)
|
|
16
|
-
.filter(k => typeof params[k] !== 'undefined')
|
|
17
|
-
.map(k => {
|
|
18
|
-
if (Array.isArray(params[k])) {
|
|
19
|
-
return encodeURIComponent(k) + '=' + encodeURIComponent(params[k].join(' '))
|
|
20
|
-
} else {
|
|
21
|
-
return encodeURIComponent(k) + '=' + encodeURIComponent(params[k])
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
.join('&');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
_GetQueryParams = (param) => {
|
|
28
|
-
let retVal = { };
|
|
29
|
-
const uri = param.split("?");
|
|
30
|
-
if (uri.length == 2) {
|
|
31
|
-
const vars = uri[1].split("&");
|
|
32
|
-
const getVars = {};
|
|
33
|
-
let tmp = "";
|
|
34
|
-
vars.forEach(function (v) {
|
|
35
|
-
tmp = v.split("=");
|
|
36
|
-
if (tmp.length == 2) getVars[tmp[0]] = tmp[1];
|
|
37
|
-
});
|
|
38
|
-
retVal = this.DecodeQueryParams(getVars);
|
|
39
|
-
}
|
|
40
|
-
return retVal;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
GetQueryParams = () => {
|
|
44
|
-
return this._GetQueryParams(window.location.href);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export default QueryParams;
|
package/src/index.test.ts
DELETED
package/src/index.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { STSOAuth2Manager } from './stsoauth2manager'
|
|
2
|
-
import { ISTSOAuth2ManagerOptions } from './stsoauth2types'
|
|
3
|
-
|
|
4
|
-
export * from './stsoauth2types'
|
|
5
|
-
export * from './stsoauth2manager'
|
|
6
|
-
export * from './stsoauth2worker'
|
|
7
|
-
|
|
8
|
-
export const STSOAuth2ManagerPlugin = {
|
|
9
|
-
install: (app, options: ISTSOAuth2ManagerOptions) => {
|
|
10
|
-
const om = new STSOAuth2Manager(app, options);
|
|
11
|
-
app.config.globalProperties.$sts.om = om;
|
|
12
|
-
}
|
|
13
|
-
}
|
package/src/stsStorage.ts
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import Debug from "debug";
|
|
2
|
-
const debug = Debug(`proc:${process.pid}:storage.ts`);
|
|
3
|
-
|
|
4
|
-
import * as Cookies from 'es-cookie';
|
|
5
|
-
import { JSONObject } from "@nsshunt/stsutils";
|
|
6
|
-
|
|
7
|
-
export interface IStsStorage<T> {
|
|
8
|
-
get(key: string): T
|
|
9
|
-
set(key: string, value: T, options?: JSONObject): void
|
|
10
|
-
remove(key: string): void
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export enum ClientStorageType {
|
|
14
|
-
LOCAL_STORAGE = 'LocalStorage', //@@ todo
|
|
15
|
-
SESSION_STORAGE = 'SessionStorage',
|
|
16
|
-
COOKIE_STORAGE = 'CookieStorage',
|
|
17
|
-
MEMORY_STORAGE = 'MemoryStorage' //@@ todo
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
class CookieStorage<T> implements IStsStorage<T>
|
|
21
|
-
{
|
|
22
|
-
get = (key: string): T => {
|
|
23
|
-
const raw = Cookies.get(key);
|
|
24
|
-
if (raw) {
|
|
25
|
-
return JSON.parse(raw);
|
|
26
|
-
} else {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
set = (key: string, value: T, options: JSONObject = { }) => {
|
|
32
|
-
let cookieAttributes: Cookies.CookieAttributes = { };
|
|
33
|
-
if ('https:' === window.location.protocol) {
|
|
34
|
-
cookieAttributes = {
|
|
35
|
-
secure: true,
|
|
36
|
-
sameSite: 'none'
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (options && options.daysUntilExpire) {
|
|
41
|
-
cookieAttributes.expires = options.daysUntilExpire;
|
|
42
|
-
} else {
|
|
43
|
-
cookieAttributes.expires = 1;
|
|
44
|
-
}
|
|
45
|
-
debug(`CookieStorage.set: key: ${key}, value: [${value}]`);
|
|
46
|
-
Cookies.set(key, JSON.stringify(value), cookieAttributes);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
remove = (key: string): void => {
|
|
50
|
-
Cookies.remove(key);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
class SessionStorage<T> implements IStsStorage<T>
|
|
55
|
-
{
|
|
56
|
-
get = (key: string): T => {
|
|
57
|
-
const value: string = sessionStorage.getItem(key);
|
|
58
|
-
if (typeof value === 'undefined') {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
if (value === null) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
return JSON.parse(value);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
set = (key: string, value: T): void => {
|
|
68
|
-
debug(`SessionStorage.set: key: ${key}, value: [${value}]`);
|
|
69
|
-
sessionStorage.setItem(key, JSON.stringify(value));
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
remove = (key: string): void => {
|
|
73
|
-
sessionStorage.removeItem(key);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
class LocalStorage<T> implements IStsStorage<T>
|
|
78
|
-
{
|
|
79
|
-
get = (key: string): T => {
|
|
80
|
-
const value: string = localStorage.getItem(key);
|
|
81
|
-
if (typeof value === 'undefined') {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
if (value === null) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
return JSON.parse(value);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
set = (key: string, value: T): void => {
|
|
91
|
-
debug(`LocalStorage.set: key: ${key}, value: [${value}]`);
|
|
92
|
-
localStorage.setItem(key, JSON.stringify(value));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
remove = (key: string): void => {
|
|
96
|
-
localStorage.removeItem(key);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
class MemoryStorage<T> implements IStsStorage<T>
|
|
101
|
-
{
|
|
102
|
-
#store: Record<string, T> = { };
|
|
103
|
-
|
|
104
|
-
get = (key: string): T => {
|
|
105
|
-
const value: T = this.#store[key];
|
|
106
|
-
if (typeof value === 'undefined') {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
if (value === null) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
return value;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
set = (key: string, value: T): void => {
|
|
116
|
-
debug(`MemoryStorage.set: key: ${key}, value: [${value}]`);
|
|
117
|
-
this.#store[key] = value;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
remove = (key: string): void => {
|
|
121
|
-
delete this.#store[key];
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export class ClientStorageOptions {
|
|
126
|
-
clientStorageType: ClientStorageType = ClientStorageType.MEMORY_STORAGE;
|
|
127
|
-
storageOptions?: JSONObject
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export class ClientStorageFactory<T>
|
|
131
|
-
{
|
|
132
|
-
#storage = null;
|
|
133
|
-
|
|
134
|
-
constructor(options: ClientStorageOptions) {
|
|
135
|
-
switch (options.clientStorageType) {
|
|
136
|
-
case ClientStorageType.SESSION_STORAGE :
|
|
137
|
-
this.#storage = new SessionStorage<T>();
|
|
138
|
-
break;
|
|
139
|
-
case ClientStorageType.LOCAL_STORAGE :
|
|
140
|
-
this.#storage = new LocalStorage<T>();
|
|
141
|
-
break;
|
|
142
|
-
case ClientStorageType.COOKIE_STORAGE :
|
|
143
|
-
this.#storage = new CookieStorage<T>();
|
|
144
|
-
break;
|
|
145
|
-
case ClientStorageType.MEMORY_STORAGE :
|
|
146
|
-
this.#storage = new MemoryStorage<T>();
|
|
147
|
-
break;
|
|
148
|
-
default:
|
|
149
|
-
throw new Error(`Unknown [${options.clientStorageType}] storage type.`);
|
|
150
|
-
}
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
GetStorage(): IStsStorage<T>
|
|
155
|
-
{
|
|
156
|
-
return this.#storage;
|
|
157
|
-
}
|
|
158
|
-
}
|
package/src/stsoauth2launcher.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ISTSOAuth2WorkerOptions, ISTSOAuth2WorkerMessage } from './stsoauth2types'
|
|
2
|
-
import { STSOAuth2Worker } from './stsoauth2worker'
|
|
3
|
-
|
|
4
|
-
let oAuth2Worker: STSOAuth2Worker = null;
|
|
5
|
-
|
|
6
|
-
onmessage = async function(data: MessageEvent)
|
|
7
|
-
{
|
|
8
|
-
const workerMessage: ISTSOAuth2WorkerMessage = data.data as ISTSOAuth2WorkerMessage;
|
|
9
|
-
|
|
10
|
-
const workerPort = workerMessage.workerPort as MessagePort;
|
|
11
|
-
const options: ISTSOAuth2WorkerOptions = workerMessage.options as ISTSOAuth2WorkerOptions;
|
|
12
|
-
oAuth2Worker = new STSOAuth2Worker(workerPort, options);
|
|
13
|
-
}
|