@loopstack/auth 0.16.0 → 0.18.0-rc.0
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/auth.module.js +6 -12
- package/dist/auth.module.js.map +1 -1
- package/dist/controllers/auth.controller.d.ts +10 -7
- package/dist/controllers/auth.controller.js +13 -13
- package/dist/controllers/auth.controller.js.map +1 -1
- package/dist/controllers/index.js.map +1 -1
- package/dist/dtos/hub-login-request.dto.js +1 -1
- package/dist/dtos/hub-login-request.dto.js.map +1 -1
- package/dist/dtos/hub-login-response.dto.js +1 -1
- package/dist/dtos/hub-login-response.dto.js.map +1 -1
- package/dist/dtos/worker-info.dto.js +1 -1
- package/dist/dtos/worker-info.dto.js.map +1 -1
- package/dist/guards/index.js.map +1 -1
- package/dist/guards/jwt-auth.guard.d.ts +1 -1
- package/dist/guards/jwt-auth.guard.js +1 -1
- package/dist/guards/jwt-auth.guard.js.map +1 -1
- package/dist/guards/roles.guard.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/interfaces/index.d.ts +0 -1
- package/dist/interfaces/index.js +0 -1
- package/dist/interfaces/index.js.map +1 -1
- package/dist/repositories/index.js.map +1 -1
- package/dist/repositories/user.repository.js +1 -1
- package/dist/seeds/local-dev-user.seed.js.map +1 -1
- package/dist/services/auth.service.d.ts +4 -4
- package/dist/services/auth.service.js +8 -8
- package/dist/services/auth.service.js.map +1 -1
- package/dist/services/config-validation.service.js.map +1 -1
- package/dist/services/hub-audit.service.d.ts +1 -1
- package/dist/services/hub-audit.service.js +1 -1
- package/dist/services/hub-audit.service.js.map +1 -1
- package/dist/services/hub.service.d.ts +2 -2
- package/dist/services/hub.service.js +68 -24
- package/dist/services/hub.service.js.map +1 -1
- package/dist/services/index.js.map +1 -1
- package/dist/services/token.service.d.ts +6 -6
- package/dist/services/token.service.js +16 -11
- package/dist/services/token.service.js.map +1 -1
- package/dist/strategies/hub.strategy.d.ts +4 -4
- package/dist/strategies/hub.strategy.js +4 -4
- package/dist/strategies/hub.strategy.js.map +1 -1
- package/dist/strategies/index.js.map +1 -1
- package/dist/strategies/jwt.strategy.d.ts +8 -10
- package/dist/strategies/jwt.strategy.js +11 -13
- package/dist/strategies/jwt.strategy.js.map +1 -1
- package/package.json +28 -55
- package/LICENSE +0 -43
- package/README.md +0 -7
- package/dist/auth.module-definition.d.ts +0 -2
- package/dist/auth.module-definition.js +0 -7
- package/dist/auth.module-definition.js.map +0 -1
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +0 -5
- package/dist/constants.js.map +0 -1
- package/dist/interfaces/module-options.interface.d.ts +0 -2
- package/dist/interfaces/module-options.interface.js +0 -3
- package/dist/interfaces/module-options.interface.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -1,10 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
2
18
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
19
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
20
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
21
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
22
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
23
|
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
8
41
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
42
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
43
|
};
|
|
@@ -12,10 +45,10 @@ var HubService_1;
|
|
|
12
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
46
|
exports.HubService = void 0;
|
|
14
47
|
const common_1 = require("@nestjs/common");
|
|
15
|
-
const axios_1 = require("axios");
|
|
16
48
|
const config_1 = require("@nestjs/config");
|
|
17
|
-
const
|
|
49
|
+
const axios_1 = __importStar(require("axios"));
|
|
18
50
|
const hub_exceptions_1 = require("../exceptions/hub.exceptions");
|
|
51
|
+
const hub_audit_service_1 = require("./hub-audit.service");
|
|
19
52
|
let HubService = HubService_1 = class HubService {
|
|
20
53
|
configService;
|
|
21
54
|
auditService;
|
|
@@ -26,10 +59,10 @@ let HubService = HubService_1 = class HubService {
|
|
|
26
59
|
this.configService = configService;
|
|
27
60
|
this.auditService = auditService;
|
|
28
61
|
}
|
|
29
|
-
|
|
30
|
-
|
|
62
|
+
onModuleInit() {
|
|
63
|
+
this.initialize();
|
|
31
64
|
}
|
|
32
|
-
|
|
65
|
+
initialize() {
|
|
33
66
|
try {
|
|
34
67
|
this.config = this.loadConfiguration();
|
|
35
68
|
if (!this.configService.get('app.isLocalMode')) {
|
|
@@ -51,18 +84,17 @@ let HubService = HubService_1 = class HubService {
|
|
|
51
84
|
}
|
|
52
85
|
}
|
|
53
86
|
loadConfiguration() {
|
|
54
|
-
const authConfig = this.configService.get('auth');
|
|
55
87
|
return {
|
|
56
|
-
authCallback:
|
|
57
|
-
clientId:
|
|
58
|
-
clientSecret:
|
|
88
|
+
authCallback: this.configService.get('auth.authCallback') ?? '',
|
|
89
|
+
clientId: this.configService.get('auth.clientId') ?? '',
|
|
90
|
+
clientSecret: this.configService.get('auth.clientSecret') ?? '',
|
|
59
91
|
timeout: 10000,
|
|
60
92
|
retries: 3,
|
|
61
93
|
};
|
|
62
94
|
}
|
|
63
95
|
validateConfiguration() {
|
|
64
96
|
const required = ['authCallback'];
|
|
65
|
-
const missing = required.filter(field => !this.config[field]);
|
|
97
|
+
const missing = required.filter((field) => !this.config[field]);
|
|
66
98
|
if (missing.length > 0) {
|
|
67
99
|
throw new hub_exceptions_1.HubConfigurationException(`Missing required fields: ${missing.join(', ')}`);
|
|
68
100
|
}
|
|
@@ -80,30 +112,38 @@ let HubService = HubService_1 = class HubService {
|
|
|
80
112
|
return config;
|
|
81
113
|
}, (error) => {
|
|
82
114
|
this.logger.error('Request interceptor error:', error);
|
|
83
|
-
return Promise.reject(error);
|
|
115
|
+
return Promise.reject(error instanceof Error ? error : new Error(String(error)));
|
|
84
116
|
});
|
|
85
117
|
this.axiosInstance.interceptors.response.use((response) => {
|
|
86
118
|
this.logger.debug(`Response received: ${response.status}`);
|
|
87
119
|
return response;
|
|
88
120
|
}, (error) => {
|
|
89
|
-
|
|
90
|
-
|
|
121
|
+
if (error instanceof axios_1.AxiosError) {
|
|
122
|
+
this.logger.error(`Response error: ${error.response?.status} - ${error.message}`);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
this.logger.error('Response error:', error);
|
|
126
|
+
}
|
|
127
|
+
return Promise.reject(error instanceof Error ? error : new Error(String(error)));
|
|
91
128
|
});
|
|
92
129
|
}
|
|
93
130
|
async retryOperation(operation, maxRetries = 3, delay = 1000) {
|
|
94
|
-
let lastError =
|
|
131
|
+
let lastError = new Error('Unknown error');
|
|
95
132
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
96
133
|
try {
|
|
97
134
|
return await operation();
|
|
98
135
|
}
|
|
99
136
|
catch (error) {
|
|
100
|
-
lastError = error;
|
|
101
|
-
if (error instanceof axios_1.AxiosError &&
|
|
137
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
138
|
+
if (error instanceof axios_1.AxiosError &&
|
|
139
|
+
error.response?.status &&
|
|
140
|
+
error.response?.status >= 400 &&
|
|
141
|
+
error.response?.status < 500) {
|
|
102
142
|
throw error;
|
|
103
143
|
}
|
|
104
144
|
if (attempt < maxRetries) {
|
|
105
|
-
this.logger.warn(`Attempt ${attempt} failed, retrying in ${delay}ms: ${
|
|
106
|
-
await new Promise(resolve => setTimeout(resolve, delay * attempt));
|
|
145
|
+
this.logger.warn(`Attempt ${attempt} failed, retrying in ${delay}ms: ${lastError.message}`);
|
|
146
|
+
await new Promise((resolve) => setTimeout(resolve, delay * attempt));
|
|
107
147
|
}
|
|
108
148
|
}
|
|
109
149
|
}
|
|
@@ -126,7 +166,7 @@ let HubService = HubService_1 = class HubService {
|
|
|
126
166
|
clientId: this.config.clientId,
|
|
127
167
|
}, {
|
|
128
168
|
headers: {
|
|
129
|
-
|
|
169
|
+
Authorization: `Bearer ${this.config.clientSecret}`,
|
|
130
170
|
'X-Correlation-ID': requestContext.correlationId,
|
|
131
171
|
'X-Request-ID': requestContext.requestId || requestContext.correlationId,
|
|
132
172
|
},
|
|
@@ -134,7 +174,7 @@ let HubService = HubService_1 = class HubService {
|
|
|
134
174
|
return response.data;
|
|
135
175
|
}, this.config.retries);
|
|
136
176
|
const responseTime = Date.now() - startTime;
|
|
137
|
-
|
|
177
|
+
this.auditService.logCodeExchange(requestContext, true, responseTime);
|
|
138
178
|
this.logger.log(`[${requestContext.correlationId}] Code exchange successful in ${responseTime}ms`);
|
|
139
179
|
return result;
|
|
140
180
|
}
|
|
@@ -158,15 +198,19 @@ let HubService = HubService_1 = class HubService {
|
|
|
158
198
|
else {
|
|
159
199
|
thrownError = new common_1.BadRequestException('Failed to validate authorization code');
|
|
160
200
|
}
|
|
201
|
+
this.auditService.logCodeExchange(requestContext, false, responseTime, thrownError.message, {
|
|
202
|
+
errorType: error.constructor.name,
|
|
203
|
+
statusCode: error.response?.status,
|
|
204
|
+
});
|
|
161
205
|
}
|
|
162
206
|
else {
|
|
163
207
|
this.logger.error(`[${requestContext.correlationId}] Unexpected error during code exchange:`, error);
|
|
164
208
|
thrownError = new common_1.BadGatewayException('Hub service communication error');
|
|
209
|
+
this.auditService.logCodeExchange(requestContext, false, responseTime, thrownError.message, {
|
|
210
|
+
errorType: error instanceof Error ? error.constructor.name : 'Unknown',
|
|
211
|
+
statusCode: undefined,
|
|
212
|
+
});
|
|
165
213
|
}
|
|
166
|
-
await this.auditService.logCodeExchange(requestContext, false, responseTime, thrownError.message, {
|
|
167
|
-
errorType: error.constructor.name,
|
|
168
|
-
statusCode: error instanceof axios_1.AxiosError ? error.response?.status : undefined
|
|
169
|
-
});
|
|
170
214
|
this.logger.error(`[${requestContext.correlationId}] Code exchange failed in ${responseTime}ms: ${thrownError.message}`);
|
|
171
215
|
throw thrownError;
|
|
172
216
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hub.service.js","sourceRoot":"","sources":["../../src/services/hub.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hub.service.js","sourceRoot":"","sources":["../../src/services/hub.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4G;AAC5G,2CAA+C;AAC/C,+CAAwE;AAGxE,iEAMsC;AAEtC,2DAAsD;AAG/C,IAAM,UAAU,kBAAhB,MAAM,UAAU;IAMF;IACA;IANF,MAAM,GAAG,IAAI,eAAM,CAAC,YAAU,CAAC,IAAI,CAAC,CAAC;IAC9C,aAAa,CAAgB;IAC7B,MAAM,CAAY;IAE1B,YACmB,aAA4B,EAC5B,YAA6B;QAD7B,kBAAa,GAAb,aAAa,CAAe;QAC5B,iBAAY,GAAZ,YAAY,CAAiB;IAC7C,CAAC;IAEJ,YAAY;QACV,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAEO,UAAU;QAChB,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAEvC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAU,iBAAiB,CAAC,EAAE,CAAC;gBACxD,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC/B,CAAC;YAED,IAAI,CAAC,aAAa,GAAG,eAAK,CAAC,MAAM,CAAC;gBAChC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,KAAK;gBACrC,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;oBAClC,YAAY,EAAE,gBAAgB;iBAC/B;aACF,CAAC,CAAC;YAEH,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAE9B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;QAC1D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KA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ACtG,CAAC;YAEF,MAAM,WAAW,CAAC;QACpB,CAAC;IACH,CAAC;CACF,CAAA;AApNY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;qCAOuB,sBAAa;QACd,mCAAe;GAPrC,UAAU,CAoNtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,kDAAgC;AAChC,gDAA8B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ConfigService } from '@nestjs/config';
|
|
1
2
|
import { JwtService } from '@nestjs/jwt';
|
|
2
3
|
import { JwtPayloadInterface } from '@loopstack/common';
|
|
3
|
-
import { ConfigService } from '@nestjs/config';
|
|
4
4
|
export declare class TokenService {
|
|
5
5
|
private readonly configService;
|
|
6
6
|
private jwtService;
|
|
@@ -9,17 +9,17 @@ export declare class TokenService {
|
|
|
9
9
|
private getRefreshExpiresIn;
|
|
10
10
|
getCookieName(suffix: string): string;
|
|
11
11
|
createAccessTokenCookieOptions(): {
|
|
12
|
-
domain:
|
|
12
|
+
domain: string | undefined;
|
|
13
13
|
httpOnly: boolean;
|
|
14
14
|
secure: boolean;
|
|
15
|
-
sameSite:
|
|
15
|
+
sameSite: "none";
|
|
16
16
|
maxAge: number;
|
|
17
17
|
};
|
|
18
18
|
createRefreshTokenCookieOptions(): {
|
|
19
|
-
domain:
|
|
19
|
+
domain: string | undefined;
|
|
20
20
|
httpOnly: boolean;
|
|
21
21
|
secure: boolean;
|
|
22
|
-
sameSite:
|
|
22
|
+
sameSite: "none";
|
|
23
23
|
maxAge: number;
|
|
24
24
|
};
|
|
25
25
|
private getRefreshSecret;
|
|
@@ -29,5 +29,5 @@ export declare class TokenService {
|
|
|
29
29
|
expiresIn: number;
|
|
30
30
|
}>;
|
|
31
31
|
private getExpiresInSeconds;
|
|
32
|
-
verifyRefreshToken(refreshToken: string):
|
|
32
|
+
verifyRefreshToken(refreshToken: string): JwtPayloadInterface;
|
|
33
33
|
}
|
|
@@ -11,8 +11,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.TokenService = void 0;
|
|
13
13
|
const common_1 = require("@nestjs/common");
|
|
14
|
-
const jwt_1 = require("@nestjs/jwt");
|
|
15
14
|
const config_1 = require("@nestjs/config");
|
|
15
|
+
const jwt_1 = require("@nestjs/jwt");
|
|
16
16
|
let TokenService = class TokenService {
|
|
17
17
|
configService;
|
|
18
18
|
jwtService;
|
|
@@ -31,24 +31,24 @@ let TokenService = class TokenService {
|
|
|
31
31
|
}
|
|
32
32
|
createAccessTokenCookieOptions() {
|
|
33
33
|
return {
|
|
34
|
-
domain: this.configService.get('auth.jwt.cookieDomain')
|
|
34
|
+
domain: this.configService.get('auth.jwt.cookieDomain'),
|
|
35
35
|
httpOnly: true,
|
|
36
36
|
secure: true,
|
|
37
|
-
sameSite: '
|
|
37
|
+
sameSite: 'none',
|
|
38
38
|
maxAge: this.getExpiresIn() * 1000,
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
createRefreshTokenCookieOptions() {
|
|
42
42
|
return {
|
|
43
|
-
domain: this.configService.get('auth.jwt.cookieDomain')
|
|
43
|
+
domain: this.configService.get('auth.jwt.cookieDomain'),
|
|
44
44
|
httpOnly: true,
|
|
45
45
|
secure: true,
|
|
46
|
-
sameSite: '
|
|
46
|
+
sameSite: 'none',
|
|
47
47
|
maxAge: this.getRefreshExpiresIn() * 1000,
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
getRefreshSecret() {
|
|
51
|
-
return this.configService.get('auth.jwt.refreshSecret') ?? this.configService.get('auth.jwt.secret');
|
|
51
|
+
return (this.configService.get('auth.jwt.refreshSecret') ?? this.configService.get('auth.jwt.secret'));
|
|
52
52
|
}
|
|
53
53
|
async generateTokens(payload) {
|
|
54
54
|
const [accessToken, refreshToken] = await Promise.all([
|
|
@@ -68,11 +68,16 @@ let TokenService = class TokenService {
|
|
|
68
68
|
const unit = expiresIn.slice(-1);
|
|
69
69
|
const value = parseInt(expiresIn.slice(0, -1));
|
|
70
70
|
switch (unit) {
|
|
71
|
-
case 'h':
|
|
72
|
-
|
|
73
|
-
case '
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
case 'h':
|
|
72
|
+
return value * 3600;
|
|
73
|
+
case 'd':
|
|
74
|
+
return value * 86400;
|
|
75
|
+
case 'm':
|
|
76
|
+
return value * 60;
|
|
77
|
+
case 's':
|
|
78
|
+
return value;
|
|
79
|
+
default:
|
|
80
|
+
return 3600;
|
|
76
81
|
}
|
|
77
82
|
}
|
|
78
83
|
verifyRefreshToken(refreshToken) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.service.js","sourceRoot":"","sources":["../../src/services/token.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"token.service.js","sourceRoot":"","sources":["../../src/services/token.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAA+C;AAC/C,qCAAyC;AAIlC,IAAM,YAAY,GAAlB,MAAM,YAAY;IAEJ;IACT;IAFV,YACmB,aAA4B,EACrC,UAAsB;QADb,kBAAa,GAAb,aAAa,CAAe;QACrC,eAAU,GAAV,UAAU,CAAY;IAC7B,CAAC;IAEI,YAAY;QAClB,OAAO,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,IAAI,CAAC,CAAC;IACxF,CAAC;IAEO,mBAAmB;QACzB,OAAO,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,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AS,EAAE,IAAI,CAAC,YAAY,EAAE;SAC/B,CAAC;IACJ,CAAC;IAEO,mBAAmB,CAAC,SAAiB;QAC3C,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACjC,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAE/C,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,GAAG;gBACN,OAAO,KAAK,GAAG,IAAI,CAAC;YACtB,KAAK,GAAG;gBACN,OAAO,KAAK,GAAG,KAAK,CAAC;YACvB,KAAK,GAAG;gBACN,OAAO,KAAK,GAAG,EAAE,CAAC;YACpB,KAAK,GAAG;gBACN,OAAO,KAAK,CAAC;YACf;gBACE,OAAO,IAAI,CAAC;QAChB,CAAC;IACH,CAAC;IAED,kBAAkB,CAAC,YAAoB;QACrC,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAsB,YAAY,EAAE;YAC/D,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE;SAChC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAnFY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;qCAGuB,sBAAa;QACzB,gBAAU;GAHrB,YAAY,CAmFxB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Strategy } from 'passport-custom';
|
|
2
|
-
import { HubService } from '../services';
|
|
3
|
-
import { Request } from 'express';
|
|
4
|
-
import { UserRepository } from '../repositories';
|
|
5
1
|
import { ConfigService } from '@nestjs/config';
|
|
2
|
+
import { Request } from 'express';
|
|
3
|
+
import { Strategy } from 'passport-custom';
|
|
6
4
|
import { User } from '@loopstack/common';
|
|
5
|
+
import { UserRepository } from '../repositories';
|
|
6
|
+
import { HubService } from '../services';
|
|
7
7
|
declare const HubStrategy_base: new () => Strategy & {
|
|
8
8
|
validate(...args: any[]): unknown;
|
|
9
9
|
};
|
|
@@ -12,12 +12,12 @@ var HubStrategy_1;
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.HubStrategy = void 0;
|
|
14
14
|
const common_1 = require("@nestjs/common");
|
|
15
|
+
const config_1 = require("@nestjs/config");
|
|
15
16
|
const passport_1 = require("@nestjs/passport");
|
|
16
17
|
const passport_custom_1 = require("passport-custom");
|
|
17
|
-
const services_1 = require("../services");
|
|
18
|
-
const repositories_1 = require("../repositories");
|
|
19
|
-
const config_1 = require("@nestjs/config");
|
|
20
18
|
const common_2 = require("@loopstack/common");
|
|
19
|
+
const repositories_1 = require("../repositories");
|
|
20
|
+
const services_1 = require("../services");
|
|
21
21
|
let HubStrategy = HubStrategy_1 = class HubStrategy extends (0, passport_1.PassportStrategy)(passport_custom_1.Strategy, 'hub') {
|
|
22
22
|
configService;
|
|
23
23
|
hubService;
|
|
@@ -73,7 +73,7 @@ let HubStrategy = HubStrategy_1 = class HubStrategy extends (0, passport_1.Passp
|
|
|
73
73
|
}
|
|
74
74
|
return this.validateCloudUser(req);
|
|
75
75
|
}
|
|
76
|
-
catch
|
|
76
|
+
catch {
|
|
77
77
|
throw new common_1.UnauthorizedException('Authentication failed.');
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hub.strategy.js","sourceRoot":"","sources":["../../src/strategies/hub.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAA2E;AAC3E,+CAAoD;
|
|
1
|
+
{"version":3,"file":"hub.strategy.js","sourceRoot":"","sources":["../../src/strategies/hub.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAA2E;AAC3E,2CAA+C;AAC/C,+CAAoD;AAEpD,qDAA2C;AAC3C,8CAAiD;AAEjD,kDAAiD;AACjD,0CAAyC;AAGlC,IAAM,WAAW,mBAAjB,MAAM,WAAY,SAAQ,IAAA,2BAAgB,EAAC,0BAAQ,EAAE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;YACnC,MAAM,IAAI,8BAAqB,CAAC,sBAAsB,CAAC,CAAC;QAC1D,CAAC;QAED,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,oBAAoB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACvF,IAAI,YAAY,EAAE,CAAC;YACjB,OAAO,YAAY,CAAC;QACtB,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC;YAC5C,EAAE,EAAE,oBAAoB,CAAC,IAAI,EAAE,EAAE;YACjC,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,EAAE;SACV,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,0CAA0C,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QAErE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,GAAY;QACzB,IAAI,CAAC;YACH,MAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAU,iBAAiB,CAAC,CAAC;YAC1E,IAAI,cAAc,EAAE,CAAC;gBACnB,OAAO,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAClC,CAAC;YAED,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;QACrC,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,8BAAqB,CAAC,wBAAwB,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;CACF,CAAA;AAvEY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;qCAKuB,sBAAa;QAChB,qBAAU;QACN,6BAAc;GANtC,WAAW,CAuEvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/strategies/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/strategies/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,iDAA+B"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { ConfigService } from '@nestjs/config';
|
|
2
|
+
import { Strategy } from 'passport-jwt';
|
|
3
|
+
import { CurrentUserInterface, JwtPayloadInterface } from '@loopstack/common';
|
|
4
|
+
declare const JwtStrategy_base: new (...args: [opt: import("passport-jwt").StrategyOptionsWithRequest] | [opt: import("passport-jwt").StrategyOptionsWithoutRequest]) => Strategy & {
|
|
5
|
+
validate(...args: any[]): unknown;
|
|
6
|
+
};
|
|
4
7
|
export declare class JwtStrategy extends JwtStrategy_base {
|
|
5
|
-
constructor(
|
|
8
|
+
constructor(configService: ConfigService);
|
|
6
9
|
private static extractJWTFromCookie;
|
|
7
|
-
validate(payload: JwtPayloadInterface):
|
|
8
|
-
userId: string;
|
|
9
|
-
type: import("@loopstack/common").UserTypeEnum;
|
|
10
|
-
workerId: string;
|
|
11
|
-
roles: string[];
|
|
12
|
-
}>;
|
|
10
|
+
validate(payload: JwtPayloadInterface): CurrentUserInterface;
|
|
13
11
|
}
|
|
14
12
|
export {};
|
|
@@ -8,18 +8,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
11
|
var JwtStrategy_1;
|
|
15
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
13
|
exports.JwtStrategy = void 0;
|
|
17
|
-
const passport_jwt_1 = require("passport-jwt");
|
|
18
|
-
const passport_1 = require("@nestjs/passport");
|
|
19
14
|
const common_1 = require("@nestjs/common");
|
|
20
|
-
const
|
|
15
|
+
const config_1 = require("@nestjs/config");
|
|
16
|
+
const passport_1 = require("@nestjs/passport");
|
|
17
|
+
const passport_jwt_1 = require("passport-jwt");
|
|
21
18
|
let JwtStrategy = JwtStrategy_1 = class JwtStrategy extends (0, passport_1.PassportStrategy)(passport_jwt_1.Strategy) {
|
|
22
|
-
constructor(
|
|
19
|
+
constructor(configService) {
|
|
20
|
+
const config = configService.getOrThrow('auth');
|
|
23
21
|
const cookieName = `${config.clientId}-access`;
|
|
24
22
|
super({
|
|
25
23
|
jwtFromRequest: passport_jwt_1.ExtractJwt.fromExtractors([
|
|
@@ -27,18 +25,19 @@ let JwtStrategy = JwtStrategy_1 = class JwtStrategy extends (0, passport_1.Passp
|
|
|
27
25
|
passport_jwt_1.ExtractJwt.fromAuthHeaderAsBearerToken(),
|
|
28
26
|
]),
|
|
29
27
|
ignoreExpiration: false,
|
|
30
|
-
secretOrKey: config.jwt?.secret,
|
|
28
|
+
secretOrKey: config.jwt?.secret ?? '',
|
|
31
29
|
});
|
|
32
30
|
}
|
|
33
31
|
static extractJWTFromCookie(cookieName) {
|
|
34
32
|
return (req) => {
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
const cookies = req.cookies;
|
|
34
|
+
if (cookies && cookies[cookieName]) {
|
|
35
|
+
return cookies[cookieName];
|
|
37
36
|
}
|
|
38
37
|
return null;
|
|
39
38
|
};
|
|
40
39
|
}
|
|
41
|
-
|
|
40
|
+
validate(payload) {
|
|
42
41
|
return {
|
|
43
42
|
userId: payload.sub,
|
|
44
43
|
type: payload.type,
|
|
@@ -50,7 +49,6 @@ let JwtStrategy = JwtStrategy_1 = class JwtStrategy extends (0, passport_1.Passp
|
|
|
50
49
|
exports.JwtStrategy = JwtStrategy;
|
|
51
50
|
exports.JwtStrategy = JwtStrategy = JwtStrategy_1 = __decorate([
|
|
52
51
|
(0, common_1.Injectable)(),
|
|
53
|
-
|
|
54
|
-
__metadata("design:paramtypes", [Object])
|
|
52
|
+
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
55
53
|
], JwtStrategy);
|
|
56
54
|
//# sourceMappingURL=jwt.strategy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.strategy.js","sourceRoot":"","sources":["../../src/strategies/jwt.strategy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jwt.strategy.js","sourceRoot":"","sources":["../../src/strategies/jwt.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAA+C;AAC/C,+CAAoD;AAEpD,+CAAoD;AAK7C,IAAM,WAAW,mBAAjB,MAAM,WAAY,SAAQ,IAAA,2BAAgB,EAAC,uBAAQ,CAAC;IACzD,YAAY,aAA4B;QACtC,MAAM,MAAM,GAAG,aAAa,CAAC,UAAU,CAAa,MAAM,CAAC,CAAC;QAC5D,MAAM,UAAU,GAAG,GAAG,MAAM,CAAC,QAAQ,SAAS,CAAC;QAC/C,KAAK,CAAC;YACJ,cAAc,EAAE,yBAAU,CAAC,cAAc,CAAC;gBACxC,aAAW,CAAC,oBAAoB,CAAC,UAAU,CAAC;gBAC5C,yBAAU,CAAC,2BAA2B,EAAE;aACzC,CAAC;YACF,gBAAgB,EAAE,KAAK;YACvB,WAAW,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,IAAI,EAAE;SACtC,CAAC,CAAC;IACL,CAAC;IAEO,MAAM,CAAC,oBAAoB,CAAC,UAAkB;QACpD,OAAO,CAAC,GAAY,EAAiB,EAAE;YACrC,MAAM,OAAO,GAAG,GAAG,CAAC,OAA6C,CAAC;YAClE,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;gBACnC,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC;YAC7B,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;IACJ,CAAC;IAED,QAAQ,CAAC,OAA4B;QACnC,OAAO;YACL,MAAM,EAAE,OAAO,CAAC,GAAG;YACnB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,KAAK,EAAE,OAAO,CAAC,KAAK;SACrB,CAAC;IACJ,CAAC;CACF,CAAA;AAhCY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;qCAEgB,sBAAa;GAD7B,WAAW,CAgCvB"}
|
package/package.json
CHANGED
|
@@ -2,82 +2,55 @@
|
|
|
2
2
|
"name": "@loopstack/auth",
|
|
3
3
|
"displayName": "Loopstack Auth Module",
|
|
4
4
|
"description": "The auth module of the loopstack automation framework",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.18.0-rc.0",
|
|
6
|
+
"license": "BSL",
|
|
6
7
|
"author": {
|
|
7
8
|
"name": "Jakob Klippel",
|
|
8
9
|
"url": "https://www.linkedin.com/in/jakob-klippel/"
|
|
9
10
|
},
|
|
10
|
-
"license": "BSL",
|
|
11
11
|
"main": "dist/index.js",
|
|
12
12
|
"types": "dist/index.d.ts",
|
|
13
13
|
"scripts": {
|
|
14
|
-
"build": "
|
|
15
|
-
"
|
|
16
|
-
"format": "prettier --write
|
|
17
|
-
"lint": "eslint
|
|
18
|
-
"test": "jest",
|
|
19
|
-
"test:watch": "jest --watch",
|
|
14
|
+
"build": "nest build",
|
|
15
|
+
"compile": "tsc --noEmit",
|
|
16
|
+
"format": "prettier --write .",
|
|
17
|
+
"lint": "eslint .",
|
|
18
|
+
"test": "jest --passWithNoTests",
|
|
20
19
|
"test:cov": "jest --coverage",
|
|
21
20
|
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
|
22
|
-
"test:e2e": "jest --config ./test/jest-e2e.json"
|
|
21
|
+
"test:e2e": "jest --config ./test/jest-e2e.json",
|
|
22
|
+
"test:watch": "jest --watch",
|
|
23
|
+
"watch": "nest build --watch"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@loopstack/common": "^0.
|
|
26
|
-
"@loopstack/contracts": "^0.
|
|
27
|
-
"@loopstack/core": "^0.
|
|
28
|
-
"@nestjs/common": "^11.
|
|
29
|
-
"@nestjs/config": "^4.0.
|
|
30
|
-
"@nestjs/core": "^11.
|
|
26
|
+
"@loopstack/common": "^0.18.0-rc.0",
|
|
27
|
+
"@loopstack/contracts": "^0.18.0-rc.0",
|
|
28
|
+
"@loopstack/core": "^0.18.0-rc.0",
|
|
29
|
+
"@nestjs/common": "^11.1.12",
|
|
30
|
+
"@nestjs/config": "^4.0.2",
|
|
31
|
+
"@nestjs/core": "^11.1.12",
|
|
31
32
|
"@nestjs/event-emitter": "^3.0.1",
|
|
32
|
-
"@nestjs/jwt": "^11.0.
|
|
33
|
-
"@nestjs/microservices": "^11.
|
|
33
|
+
"@nestjs/jwt": "^11.0.2",
|
|
34
|
+
"@nestjs/microservices": "^11.1.12",
|
|
34
35
|
"@nestjs/passport": "^11.0.5",
|
|
35
|
-
"@nestjs/platform-express": "^11.
|
|
36
|
-
"@nestjs/swagger": "^11.
|
|
37
|
-
"axios": "^1.
|
|
36
|
+
"@nestjs/platform-express": "^11.1.12",
|
|
37
|
+
"@nestjs/swagger": "^11.2.5",
|
|
38
|
+
"axios": "^1.13.2",
|
|
38
39
|
"class-transformer": "^0.5.1",
|
|
39
|
-
"class-validator": "^0.14.
|
|
40
|
+
"class-validator": "^0.14.3",
|
|
40
41
|
"cookie-parser": "^1.4.7",
|
|
41
|
-
"lodash": "^4.17.
|
|
42
|
+
"lodash": "^4.17.23",
|
|
42
43
|
"passport-custom": "^1.1.1",
|
|
43
44
|
"passport-jwt": "^4.0.1",
|
|
44
45
|
"reflect-metadata": "^0.2.2",
|
|
45
|
-
"rxjs": "^7.8.
|
|
46
|
-
},
|
|
47
|
-
"peerDependencies": {
|
|
48
|
-
"@nestjs/typeorm": "^11.0.0",
|
|
49
|
-
"typeorm": "^0.3.25"
|
|
46
|
+
"rxjs": "^7.8.2"
|
|
50
47
|
},
|
|
51
48
|
"devDependencies": {
|
|
52
|
-
"@
|
|
53
|
-
"@eslint/js": "^9.18.0",
|
|
54
|
-
"@nestjs/cli": "^11.0.0",
|
|
55
|
-
"@nestjs/schematics": "^11.0.0",
|
|
56
|
-
"@nestjs/testing": "^11.0.1",
|
|
57
|
-
"@nestjs/typeorm": "^11.0.0",
|
|
58
|
-
"@swc/cli": "^0.6.0",
|
|
59
|
-
"@swc/core": "^1.10.7",
|
|
60
|
-
"@types/express": "^5.0.0",
|
|
61
|
-
"@types/jest": "^29.5.14",
|
|
62
|
-
"@types/lodash": "^4.17.15",
|
|
63
|
-
"@types/node": "^22.10.7",
|
|
64
|
-
"@types/supertest": "^6.0.2",
|
|
65
|
-
"eslint": "^9.18.0",
|
|
66
|
-
"eslint-config-prettier": "^10.0.1",
|
|
67
|
-
"eslint-plugin-prettier": "^5.2.2",
|
|
68
|
-
"globals": "^15.14.0",
|
|
69
|
-
"jest": "^29.7.0",
|
|
70
|
-
"prettier": "^3.4.2",
|
|
71
|
-
"source-map-support": "^0.5.21",
|
|
72
|
-
"supertest": "^7.0.0",
|
|
73
|
-
"ts-jest": "^29.2.5",
|
|
74
|
-
"ts-loader": "^9.5.2",
|
|
75
|
-
"ts-node": "^10.9.2",
|
|
76
|
-
"tsconfig-paths": "^4.2.0",
|
|
77
|
-
"typeorm": "^0.3.25",
|
|
78
|
-
"typescript": "^5.7.3",
|
|
79
|
-
"typescript-eslint": "^8.20.0"
|
|
49
|
+
"@types/passport-jwt": "^4.0.1"
|
|
80
50
|
},
|
|
51
|
+
"files": [
|
|
52
|
+
"dist"
|
|
53
|
+
],
|
|
81
54
|
"jest": {
|
|
82
55
|
"moduleFileExtensions": [
|
|
83
56
|
"js",
|
package/LICENSE
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
Business Source License 1.1
|
|
2
|
-
|
|
3
|
-
Parameters
|
|
4
|
-
----------
|
|
5
|
-
Licensor: Loopstack GmbH
|
|
6
|
-
Licensed Work: Loopstack Auth Module (the "Licensed Work")
|
|
7
|
-
Additional Use Grant: You may freely use, copy, modify, and distribute the Licensed Work
|
|
8
|
-
for both personal and commercial purposes, subject to the conditions below.
|
|
9
|
-
Change Date: Four years after the release date of each version.
|
|
10
|
-
Change License: Apache License, Version 2.0
|
|
11
|
-
|
|
12
|
-
Terms
|
|
13
|
-
-----
|
|
14
|
-
1. License Grant
|
|
15
|
-
The Licensed Work is made available under the terms of this Business Source License (the "License").
|
|
16
|
-
You are granted the right to use, copy, modify, and distribute the Licensed Work for any
|
|
17
|
-
personal or commercial purpose, provided that:
|
|
18
|
-
|
|
19
|
-
- You do not provide the Licensed Work to third parties as a managed or hosted service
|
|
20
|
-
where the primary value of the service is the Licensed Work itself, or a substantial
|
|
21
|
-
substitute for it.
|
|
22
|
-
- You comply with attribution requirements by including this License file with any distribution.
|
|
23
|
-
|
|
24
|
-
2. Change License
|
|
25
|
-
On the Change Date, each version of the Licensed Work will automatically be
|
|
26
|
-
made available under the Change License (Apache License 2.0).
|
|
27
|
-
|
|
28
|
-
3. Contributions
|
|
29
|
-
Any contributions to the Licensed Work will be licensed under the terms of this License
|
|
30
|
-
until the Change Date, and under the Change License thereafter.
|
|
31
|
-
|
|
32
|
-
4. Disclaimer
|
|
33
|
-
The Licensed Work is provided "as is," without warranty of any kind, express or implied.
|
|
34
|
-
|
|
35
|
-
Additional Terms
|
|
36
|
-
----------------
|
|
37
|
-
- This License does not grant you any rights to use the Licensor's trademarks or brand.
|
|
38
|
-
- This License explicitly permits both personal and commercial use of the Licensed Work,
|
|
39
|
-
including incorporation into commercial products and services, subject to the restrictions
|
|
40
|
-
outlined in Section 1.
|
|
41
|
-
|
|
42
|
-
For details on the Apache License 2.0 (effective after the Change Date), see:
|
|
43
|
-
https://www.apache.org/licenses/LICENSE-2.0
|