@progalaxyelabs/ngx-stonescriptphp-client 1.0.0 → 1.1.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/HLD.md +31 -0
- package/LICENSE +21 -0
- package/README.md +89 -2
- package/{lib → dist}/api-connection.service.d.ts +1 -3
- package/dist/api-connection.service.d.ts.map +1 -0
- package/dist/api-connection.service.js +314 -0
- package/dist/api-connection.service.js.map +1 -0
- package/{lib → dist}/api-response.model.d.ts +1 -0
- package/dist/api-response.model.d.ts.map +1 -0
- package/dist/api-response.model.js +51 -0
- package/dist/api-response.model.js.map +1 -0
- package/dist/auth.service.d.ts +4 -0
- package/dist/auth.service.d.ts.map +1 -0
- package/dist/auth.service.js +16 -0
- package/dist/auth.service.js.map +1 -0
- package/{lib → dist}/csrf.service.d.ts +1 -3
- package/dist/csrf.service.d.ts.map +1 -0
- package/dist/csrf.service.js +47 -0
- package/dist/csrf.service.js.map +1 -0
- package/dist/db.service.d.ts +4 -0
- package/dist/db.service.d.ts.map +1 -0
- package/dist/db.service.js +16 -0
- package/dist/db.service.js.map +1 -0
- package/{fesm2022/progalaxyelabs-ngx-stonescriptphp-client.mjs → dist/esm/api-connection.service.js} +28 -276
- package/dist/esm/api-connection.service.js.map +1 -0
- package/dist/esm/api-response.model.js +47 -0
- package/dist/esm/api-response.model.js.map +1 -0
- package/dist/esm/auth.service.js +13 -0
- package/dist/esm/auth.service.js.map +1 -0
- package/dist/esm/csrf.service.js +44 -0
- package/dist/esm/csrf.service.js.map +1 -0
- package/dist/esm/db.service.js +13 -0
- package/dist/esm/db.service.js.map +1 -0
- package/dist/esm/index.js +13 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/my-environment.model.js +29 -0
- package/dist/esm/my-environment.model.js.map +1 -0
- package/dist/esm/ngx-stonescriptphp-client.module.js +25 -0
- package/dist/esm/ngx-stonescriptphp-client.module.js.map +1 -0
- package/dist/esm/signin-status.service.js +23 -0
- package/dist/esm/signin-status.service.js.map +1 -0
- package/dist/esm/token.service.js +61 -0
- package/dist/esm/token.service.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/{lib → dist}/my-environment.model.d.ts +1 -0
- package/dist/my-environment.model.d.ts.map +1 -0
- package/dist/my-environment.model.js +33 -0
- package/dist/my-environment.model.js.map +1 -0
- package/dist/ngx-stonescriptphp-client.module.d.ts +6 -0
- package/dist/ngx-stonescriptphp-client.module.d.ts.map +1 -0
- package/dist/ngx-stonescriptphp-client.module.js +28 -0
- package/dist/ngx-stonescriptphp-client.module.js.map +1 -0
- package/{lib → dist}/signin-status.service.d.ts +1 -3
- package/dist/signin-status.service.d.ts.map +1 -0
- package/dist/signin-status.service.js +26 -0
- package/dist/signin-status.service.js.map +1 -0
- package/{lib → dist}/token.service.d.ts +1 -3
- package/dist/token.service.d.ts.map +1 -0
- package/dist/token.service.js +64 -0
- package/dist/token.service.js.map +1 -0
- package/docs/AUTH_COMPATIBILITY.md +310 -0
- package/docs/CHANGELOG.md +261 -0
- package/package.json +59 -18
- package/esm2022/lib/api-connection.service.mjs +0 -304
- package/esm2022/lib/api-response.model.mjs +0 -44
- package/esm2022/lib/auth.service.mjs +0 -14
- package/esm2022/lib/csrf.service.mjs +0 -46
- package/esm2022/lib/db.service.mjs +0 -14
- package/esm2022/lib/my-environment.model.mjs +0 -31
- package/esm2022/lib/ngx-stonescriptphp-client/ngx-stonescriptphp-client.module.mjs +0 -27
- package/esm2022/lib/signin-status.service.mjs +0 -23
- package/esm2022/lib/token.service.mjs +0 -63
- package/esm2022/progalaxyelabs-ngx-stonescriptphp-client.mjs +0 -5
- package/esm2022/public-api.mjs +0 -13
- package/fesm2022/progalaxyelabs-ngx-stonescriptphp-client.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/auth.service.d.ts +0 -6
- package/lib/db.service.d.ts +0 -6
- package/lib/ngx-stonescriptphp-client/ngx-stonescriptphp-client.module.d.ts +0 -10
- package/public-api.d.ts +0 -9
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { Injectable } from '@angular/core';
|
|
3
|
+
import { BehaviorSubject } from 'rxjs';
|
|
4
|
+
let SigninStatusService = class SigninStatusService {
|
|
5
|
+
status;
|
|
6
|
+
constructor() {
|
|
7
|
+
this.status = new BehaviorSubject(false);
|
|
8
|
+
}
|
|
9
|
+
signedOut() {
|
|
10
|
+
this.status.next(false);
|
|
11
|
+
}
|
|
12
|
+
signedIn() {
|
|
13
|
+
this.status.next(true);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
SigninStatusService = __decorate([
|
|
17
|
+
Injectable({
|
|
18
|
+
providedIn: 'root'
|
|
19
|
+
}),
|
|
20
|
+
__metadata("design:paramtypes", [])
|
|
21
|
+
], SigninStatusService);
|
|
22
|
+
export { SigninStatusService };
|
|
23
|
+
//# sourceMappingURL=signin-status.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signin-status.service.js","sourceRoot":"","sources":["../../src/signin-status.service.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAKhC,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IACrB,MAAM,CAA0B;IAEvC;QACI,IAAI,CAAC,MAAM,GAAG,IAAI,eAAe,CAAU,KAAK,CAAC,CAAA;IACrD,CAAC;IAED,SAAS;QACL,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC3B,CAAC;IAED,QAAQ;QACJ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC1B,CAAC;CACJ,CAAA;AAdY,mBAAmB;IAH/B,UAAU,CAAC;QACR,UAAU,EAAE,MAAM;KACrB,CAAC;;GACW,mBAAmB,CAc/B"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { Injectable } from '@angular/core';
|
|
3
|
+
let TokenService = class TokenService {
|
|
4
|
+
accessToken = '';
|
|
5
|
+
refreshToken = '';
|
|
6
|
+
lsAccessTokenKey = 'progalaxyapi_access_token';
|
|
7
|
+
lsRefreshTokenKey = 'progalaxyapi_refresh_token';
|
|
8
|
+
constructor() { }
|
|
9
|
+
setTokens(accessToken, refreshToken) {
|
|
10
|
+
this.accessToken = accessToken;
|
|
11
|
+
this.refreshToken = refreshToken;
|
|
12
|
+
localStorage.setItem(this.lsAccessTokenKey, accessToken);
|
|
13
|
+
localStorage.setItem(this.lsRefreshTokenKey, refreshToken);
|
|
14
|
+
}
|
|
15
|
+
setAccessToken(accessToken) {
|
|
16
|
+
this.accessToken = accessToken;
|
|
17
|
+
localStorage.setItem(this.lsAccessTokenKey, accessToken);
|
|
18
|
+
}
|
|
19
|
+
setRefreshToken(refreshToken) {
|
|
20
|
+
this.refreshToken = refreshToken;
|
|
21
|
+
localStorage.setItem(this.lsRefreshTokenKey, refreshToken);
|
|
22
|
+
}
|
|
23
|
+
getAccessToken() {
|
|
24
|
+
if (this.accessToken) {
|
|
25
|
+
return this.accessToken;
|
|
26
|
+
}
|
|
27
|
+
const storedAccessToken = localStorage.getItem(this.lsAccessTokenKey);
|
|
28
|
+
if (storedAccessToken) {
|
|
29
|
+
return storedAccessToken;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return '';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
getRefreshToken() {
|
|
36
|
+
if (this.refreshToken) {
|
|
37
|
+
return this.refreshToken;
|
|
38
|
+
}
|
|
39
|
+
const storedRefreshToken = localStorage.getItem(this.lsRefreshTokenKey);
|
|
40
|
+
if (storedRefreshToken) {
|
|
41
|
+
return storedRefreshToken;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return '';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
clear() {
|
|
48
|
+
this.accessToken = '';
|
|
49
|
+
this.refreshToken = '';
|
|
50
|
+
localStorage.removeItem(this.lsAccessTokenKey);
|
|
51
|
+
localStorage.removeItem(this.lsRefreshTokenKey);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
TokenService = __decorate([
|
|
55
|
+
Injectable({
|
|
56
|
+
providedIn: 'root'
|
|
57
|
+
}),
|
|
58
|
+
__metadata("design:paramtypes", [])
|
|
59
|
+
], TokenService);
|
|
60
|
+
export { TokenService };
|
|
61
|
+
//# sourceMappingURL=token.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.service.js","sourceRoot":"","sources":["../../src/token.service.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAKpC,IAAM,YAAY,GAAlB,MAAM,YAAY;IACb,WAAW,GAAG,EAAE,CAAA;IAChB,YAAY,GAAG,EAAE,CAAA;IAEjB,gBAAgB,GAAG,2BAA2B,CAAA;IAC9C,iBAAiB,GAAG,4BAA4B,CAAA;IAExD,gBAAgB,CAAC;IAEjB,SAAS,CAAC,WAAmB,EAAE,YAAoB;QAC/C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAA;QACxD,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAA;IAC9D,CAAC;IAED,cAAc,CAAC,WAAmB;QAC9B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAA;IAC5D,CAAC;IAED,eAAe,CAAC,YAAoB;QAChC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAA;IAC9D,CAAC;IAED,cAAc;QACV,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC,WAAW,CAAA;QAC3B,CAAC;QAED,MAAM,iBAAiB,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;QACrE,IAAI,iBAAiB,EAAE,CAAC;YACpB,OAAO,iBAAiB,CAAA;QAC5B,CAAC;aAAM,CAAC;YACJ,OAAO,EAAE,CAAA;QACb,CAAC;IACL,CAAC;IAED,eAAe;QACX,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC,YAAY,CAAA;QAC5B,CAAC;QAED,MAAM,kBAAkB,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;QACvE,IAAI,kBAAkB,EAAE,CAAC;YACrB,OAAO,kBAAkB,CAAA;QAC7B,CAAC;aAAM,CAAC;YACJ,OAAO,EAAE,CAAA;QACb,CAAC;IACL,CAAC;IAED,KAAK;QACD,IAAI,CAAC,WAAW,GAAG,EAAE,CAAA;QACrB,IAAI,CAAC,YAAY,GAAG,EAAE,CAAA;QACtB,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;QAC9C,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;IACnD,CAAC;CACJ,CAAA;AA1DY,YAAY;IAHxB,UAAU,CAAC;QACR,UAAU,EAAE,MAAM;KACrB,CAAC;;GACW,YAAY,CA0DxB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './api-connection.service';
|
|
2
|
+
export * from './auth.service';
|
|
3
|
+
export * from './db.service';
|
|
4
|
+
export * from './signin-status.service';
|
|
5
|
+
export * from './token.service';
|
|
6
|
+
export * from './csrf.service';
|
|
7
|
+
export * from './api-response.model';
|
|
8
|
+
export * from './my-environment.model';
|
|
9
|
+
export * from './ngx-stonescriptphp-client.module';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oCAAoC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Public API Surface of ngx-stonescriptphp-client
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
tslib_1.__exportStar(require("./api-connection.service"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./auth.service"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./db.service"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./signin-status.service"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./token.service"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./csrf.service"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./api-response.model"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./my-environment.model"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./ngx-stonescriptphp-client.module"), exports);
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,mEAAyC;AACzC,yDAA+B;AAC/B,uDAA6B;AAC7B,kEAAwC;AACxC,0DAAgC;AAChC,yDAA+B;AAC/B,+DAAqC;AACrC,iEAAuC;AACvC,6EAAmD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"my-environment.model.d.ts","sourceRoot":"","sources":["../src/my-environment.model.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAElD,MAAM,WAAW,UAAU;IACvB;;;;;OAKG;IACH,IAAI,EAAE,QAAQ,CAAC;IAEf;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,qBAAa,kBAAkB;IAC3B,UAAU,EAAE,OAAO,CAAO;IAC1B,QAAQ,EAAE;QACN,SAAS,EAAE,MAAM,CAAA;QACjB,KAAK,EAAE,MAAM,CAAA;QACb,WAAW,EAAE,MAAM,CAAA;QACnB,aAAa,EAAE,MAAM,CAAA;QACrB,UAAU,EAAE,MAAM,CAAA;QAClB,MAAM,EAAE,MAAM,CAAA;QACd,UAAU,EAAE,MAAM,CAAA;QAClB,iBAAiB,EAAE,MAAM,CAAA;QACzB,aAAa,EAAE,MAAM,CAAA;KACxB,CAUI;IACL,SAAS,EAAE;QACP,IAAI,EAAE,MAAM,CAAA;KACf,CAAe;IAChB,UAAU,EAAE;QACR,IAAI,EAAE,MAAM,CAAA;KACf,CAAe;IAEhB;;;OAGG;IACH,IAAI,CAAC,EAAE,UAAU,CAOf;CACL"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MyEnvironmentModel = void 0;
|
|
4
|
+
class MyEnvironmentModel {
|
|
5
|
+
production = true;
|
|
6
|
+
firebase = {
|
|
7
|
+
projectId: '',
|
|
8
|
+
appId: '',
|
|
9
|
+
databaseURL: '',
|
|
10
|
+
storageBucket: '',
|
|
11
|
+
locationId: '',
|
|
12
|
+
apiKey: '',
|
|
13
|
+
authDomain: '',
|
|
14
|
+
messagingSenderId: '',
|
|
15
|
+
measurementId: ''
|
|
16
|
+
};
|
|
17
|
+
apiServer = { host: '' };
|
|
18
|
+
chatServer = { host: '' };
|
|
19
|
+
/**
|
|
20
|
+
* Authentication configuration
|
|
21
|
+
* @default { mode: 'cookie', refreshEndpoint: '/auth/refresh', useCsrf: true }
|
|
22
|
+
*/
|
|
23
|
+
auth = {
|
|
24
|
+
mode: 'cookie',
|
|
25
|
+
refreshEndpoint: '/auth/refresh',
|
|
26
|
+
useCsrf: true,
|
|
27
|
+
refreshTokenCookieName: 'refresh_token',
|
|
28
|
+
csrfTokenCookieName: 'csrf_token',
|
|
29
|
+
csrfHeaderName: 'X-CSRF-Token'
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.MyEnvironmentModel = MyEnvironmentModel;
|
|
33
|
+
//# sourceMappingURL=my-environment.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"my-environment.model.js","sourceRoot":"","sources":["../src/my-environment.model.ts"],"names":[],"mappings":";;;AA0CA,MAAa,kBAAkB;IAC3B,UAAU,GAAY,IAAI,CAAA;IAC1B,QAAQ,GAUJ;QACI,SAAS,EAAE,EAAE;QACb,KAAK,EAAE,EAAE;QACT,WAAW,EAAE,EAAE;QACf,aAAa,EAAE,EAAE;QACjB,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,EAAE;QACV,UAAU,EAAE,EAAE;QACd,iBAAiB,EAAE,EAAE;QACrB,aAAa,EAAE,EAAE;KACpB,CAAA;IACL,SAAS,GAEL,EAAE,IAAI,EAAE,EAAE,EAAE,CAAA;IAChB,UAAU,GAEN,EAAE,IAAI,EAAE,EAAE,EAAE,CAAA;IAEhB;;;OAGG;IACH,IAAI,GAAgB;QAChB,IAAI,EAAE,QAAQ;QACd,eAAe,EAAE,eAAe;QAChC,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,eAAe;QACvC,mBAAmB,EAAE,YAAY;QACjC,cAAc,EAAE,cAAc;KACjC,CAAC;CACL;AA1CD,gDA0CC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ModuleWithProviders } from '@angular/core';
|
|
2
|
+
import { MyEnvironmentModel } from './my-environment.model';
|
|
3
|
+
export declare class NgxStoneScriptPhpClientModule {
|
|
4
|
+
static forRoot(environment: MyEnvironmentModel): ModuleWithProviders<NgxStoneScriptPhpClientModule>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=ngx-stonescriptphp-client.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngx-stonescriptphp-client.module.d.ts","sourceRoot":"","sources":["../src/ngx-stonescriptphp-client.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAY,MAAM,eAAe,CAAC;AAE9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAI5D,qBAMa,6BAA6B;WACxB,OAAO,CAAC,WAAW,EAAE,kBAAkB,GAAG,mBAAmB,CAAC,6BAA6B,CAAC;CAQ7G"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var NgxStoneScriptPhpClientModule_1;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.NgxStoneScriptPhpClientModule = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const core_1 = require("@angular/core");
|
|
7
|
+
const common_1 = require("@angular/common");
|
|
8
|
+
const my_environment_model_1 = require("./my-environment.model");
|
|
9
|
+
let NgxStoneScriptPhpClientModule = NgxStoneScriptPhpClientModule_1 = class NgxStoneScriptPhpClientModule {
|
|
10
|
+
static forRoot(environment) {
|
|
11
|
+
return {
|
|
12
|
+
ngModule: NgxStoneScriptPhpClientModule_1,
|
|
13
|
+
providers: [
|
|
14
|
+
{ provide: my_environment_model_1.MyEnvironmentModel, useValue: environment }
|
|
15
|
+
]
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
exports.NgxStoneScriptPhpClientModule = NgxStoneScriptPhpClientModule;
|
|
20
|
+
exports.NgxStoneScriptPhpClientModule = NgxStoneScriptPhpClientModule = NgxStoneScriptPhpClientModule_1 = tslib_1.__decorate([
|
|
21
|
+
(0, core_1.NgModule)({
|
|
22
|
+
declarations: [],
|
|
23
|
+
imports: [
|
|
24
|
+
common_1.CommonModule
|
|
25
|
+
]
|
|
26
|
+
})
|
|
27
|
+
], NgxStoneScriptPhpClientModule);
|
|
28
|
+
//# sourceMappingURL=ngx-stonescriptphp-client.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngx-stonescriptphp-client.module.js","sourceRoot":"","sources":["../src/ngx-stonescriptphp-client.module.ts"],"names":[],"mappings":";;;;;AAAA,wCAA8D;AAC9D,4CAA+C;AAC/C,iEAA4D;AAUrD,IAAM,6BAA6B,qCAAnC,MAAM,6BAA6B;IAC/B,MAAM,CAAC,OAAO,CAAC,WAA+B;QACjD,OAAO;YACH,QAAQ,EAAE,+BAA6B;YACvC,SAAS,EAAE;gBACP,EAAE,OAAO,EAAE,yCAAkB,EAAE,QAAQ,EAAE,WAAW,EAAE;aACzD;SACJ,CAAA;IACL,CAAC;CACJ,CAAA;AATY,sEAA6B;wCAA7B,6BAA6B;IANzC,IAAA,eAAQ,EAAC;QACN,YAAY,EAAE,EAAE;QAChB,OAAO,EAAE;YACL,qBAAY;SACf;KACJ,CAAC;GACW,6BAA6B,CASzC"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { BehaviorSubject } from 'rxjs';
|
|
2
|
-
import * as i0 from "@angular/core";
|
|
3
2
|
export declare class SigninStatusService {
|
|
4
3
|
status: BehaviorSubject<boolean>;
|
|
5
4
|
constructor();
|
|
6
5
|
signedOut(): void;
|
|
7
6
|
signedIn(): void;
|
|
8
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<SigninStatusService, never>;
|
|
9
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<SigninStatusService>;
|
|
10
7
|
}
|
|
8
|
+
//# sourceMappingURL=signin-status.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signin-status.service.d.ts","sourceRoot":"","sources":["../src/signin-status.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAEvC,qBAGa,mBAAmB;IACrB,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,CAAA;;IAMvC,SAAS,IAAI,IAAI;IAIjB,QAAQ,IAAI,IAAI;CAGnB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SigninStatusService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const core_1 = require("@angular/core");
|
|
6
|
+
const rxjs_1 = require("rxjs");
|
|
7
|
+
let SigninStatusService = class SigninStatusService {
|
|
8
|
+
status;
|
|
9
|
+
constructor() {
|
|
10
|
+
this.status = new rxjs_1.BehaviorSubject(false);
|
|
11
|
+
}
|
|
12
|
+
signedOut() {
|
|
13
|
+
this.status.next(false);
|
|
14
|
+
}
|
|
15
|
+
signedIn() {
|
|
16
|
+
this.status.next(true);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
exports.SigninStatusService = SigninStatusService;
|
|
20
|
+
exports.SigninStatusService = SigninStatusService = tslib_1.__decorate([
|
|
21
|
+
(0, core_1.Injectable)({
|
|
22
|
+
providedIn: 'root'
|
|
23
|
+
}),
|
|
24
|
+
tslib_1.__metadata("design:paramtypes", [])
|
|
25
|
+
], SigninStatusService);
|
|
26
|
+
//# sourceMappingURL=signin-status.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signin-status.service.js","sourceRoot":"","sources":["../src/signin-status.service.ts"],"names":[],"mappings":";;;;AAAA,wCAA2C;AAC3C,+BAAuC;AAKhC,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IACrB,MAAM,CAA0B;IAEvC;QACI,IAAI,CAAC,MAAM,GAAG,IAAI,sBAAe,CAAU,KAAK,CAAC,CAAA;IACrD,CAAC;IAED,SAAS;QACL,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC3B,CAAC;IAED,QAAQ;QACJ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC1B,CAAC;CACJ,CAAA;AAdY,kDAAmB;8BAAnB,mBAAmB;IAH/B,IAAA,iBAAU,EAAC;QACR,UAAU,EAAE,MAAM;KACrB,CAAC;;GACW,mBAAmB,CAc/B"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as i0 from "@angular/core";
|
|
2
1
|
export declare class TokenService {
|
|
3
2
|
private accessToken;
|
|
4
3
|
private refreshToken;
|
|
@@ -11,6 +10,5 @@ export declare class TokenService {
|
|
|
11
10
|
getAccessToken(): string;
|
|
12
11
|
getRefreshToken(): string;
|
|
13
12
|
clear(): void;
|
|
14
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<TokenService, never>;
|
|
15
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<TokenService>;
|
|
16
13
|
}
|
|
14
|
+
//# sourceMappingURL=token.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.service.d.ts","sourceRoot":"","sources":["../src/token.service.ts"],"names":[],"mappings":"AAEA,qBAGa,YAAY;IACrB,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,YAAY,CAAK;IAEzB,OAAO,CAAC,gBAAgB,CAA8B;IACtD,OAAO,CAAC,iBAAiB,CAA+B;;IAIxD,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAOnD,cAAc,CAAC,WAAW,EAAE,MAAM;IAKlC,eAAe,CAAC,YAAY,EAAE,MAAM;IAKpC,cAAc;IAad,eAAe;IAaf,KAAK;CAMR"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TokenService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const core_1 = require("@angular/core");
|
|
6
|
+
let TokenService = class TokenService {
|
|
7
|
+
accessToken = '';
|
|
8
|
+
refreshToken = '';
|
|
9
|
+
lsAccessTokenKey = 'progalaxyapi_access_token';
|
|
10
|
+
lsRefreshTokenKey = 'progalaxyapi_refresh_token';
|
|
11
|
+
constructor() { }
|
|
12
|
+
setTokens(accessToken, refreshToken) {
|
|
13
|
+
this.accessToken = accessToken;
|
|
14
|
+
this.refreshToken = refreshToken;
|
|
15
|
+
localStorage.setItem(this.lsAccessTokenKey, accessToken);
|
|
16
|
+
localStorage.setItem(this.lsRefreshTokenKey, refreshToken);
|
|
17
|
+
}
|
|
18
|
+
setAccessToken(accessToken) {
|
|
19
|
+
this.accessToken = accessToken;
|
|
20
|
+
localStorage.setItem(this.lsAccessTokenKey, accessToken);
|
|
21
|
+
}
|
|
22
|
+
setRefreshToken(refreshToken) {
|
|
23
|
+
this.refreshToken = refreshToken;
|
|
24
|
+
localStorage.setItem(this.lsRefreshTokenKey, refreshToken);
|
|
25
|
+
}
|
|
26
|
+
getAccessToken() {
|
|
27
|
+
if (this.accessToken) {
|
|
28
|
+
return this.accessToken;
|
|
29
|
+
}
|
|
30
|
+
const storedAccessToken = localStorage.getItem(this.lsAccessTokenKey);
|
|
31
|
+
if (storedAccessToken) {
|
|
32
|
+
return storedAccessToken;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return '';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
getRefreshToken() {
|
|
39
|
+
if (this.refreshToken) {
|
|
40
|
+
return this.refreshToken;
|
|
41
|
+
}
|
|
42
|
+
const storedRefreshToken = localStorage.getItem(this.lsRefreshTokenKey);
|
|
43
|
+
if (storedRefreshToken) {
|
|
44
|
+
return storedRefreshToken;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return '';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
clear() {
|
|
51
|
+
this.accessToken = '';
|
|
52
|
+
this.refreshToken = '';
|
|
53
|
+
localStorage.removeItem(this.lsAccessTokenKey);
|
|
54
|
+
localStorage.removeItem(this.lsRefreshTokenKey);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
exports.TokenService = TokenService;
|
|
58
|
+
exports.TokenService = TokenService = tslib_1.__decorate([
|
|
59
|
+
(0, core_1.Injectable)({
|
|
60
|
+
providedIn: 'root'
|
|
61
|
+
}),
|
|
62
|
+
tslib_1.__metadata("design:paramtypes", [])
|
|
63
|
+
], TokenService);
|
|
64
|
+
//# sourceMappingURL=token.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.service.js","sourceRoot":"","sources":["../src/token.service.ts"],"names":[],"mappings":";;;;AAAA,wCAA2C;AAKpC,IAAM,YAAY,GAAlB,MAAM,YAAY;IACb,WAAW,GAAG,EAAE,CAAA;IAChB,YAAY,GAAG,EAAE,CAAA;IAEjB,gBAAgB,GAAG,2BAA2B,CAAA;IAC9C,iBAAiB,GAAG,4BAA4B,CAAA;IAExD,gBAAgB,CAAC;IAEjB,SAAS,CAAC,WAAmB,EAAE,YAAoB;QAC/C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAA;QACxD,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAA;IAC9D,CAAC;IAED,cAAc,CAAC,WAAmB;QAC9B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAA;IAC5D,CAAC;IAED,eAAe,CAAC,YAAoB;QAChC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAA;IAC9D,CAAC;IAED,cAAc;QACV,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC,WAAW,CAAA;QAC3B,CAAC;QAED,MAAM,iBAAiB,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;QACrE,IAAI,iBAAiB,EAAE,CAAC;YACpB,OAAO,iBAAiB,CAAA;QAC5B,CAAC;aAAM,CAAC;YACJ,OAAO,EAAE,CAAA;QACb,CAAC;IACL,CAAC;IAED,eAAe;QACX,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC,YAAY,CAAA;QAC5B,CAAC;QAED,MAAM,kBAAkB,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;QACvE,IAAI,kBAAkB,EAAE,CAAC;YACrB,OAAO,kBAAkB,CAAA;QAC7B,CAAC;aAAM,CAAC;YACJ,OAAO,EAAE,CAAA;QACb,CAAC;IACL,CAAC;IAED,KAAK;QACD,IAAI,CAAC,WAAW,GAAG,EAAE,CAAA;QACrB,IAAI,CAAC,YAAY,GAAG,EAAE,CAAA;QACtB,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;QAC9C,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;IACnD,CAAC;CACJ,CAAA;AA1DY,oCAAY;uBAAZ,YAAY;IAHxB,IAAA,iBAAU,EAAC;QACR,UAAU,EAAE,MAAM;KACrB,CAAC;;GACW,YAAY,CA0DxB"}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
# Authentication Compatibility Guide
|
|
2
|
+
|
|
3
|
+
## StoneScriptPHP Framework vs ngx-stonescriptphp-client
|
|
4
|
+
|
|
5
|
+
This document outlines the authentication flow compatibility between the Angular client library and StoneScriptPHP backend framework (v2.1.x).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## ⚠️ CRITICAL INCOMPATIBILITY FOUND
|
|
10
|
+
|
|
11
|
+
### Token Refresh Endpoint Mismatch
|
|
12
|
+
|
|
13
|
+
**CLIENT IMPLEMENTATION** (`api-connection.service.ts:187`):
|
|
14
|
+
```typescript
|
|
15
|
+
const refreshTokenUrl = this.host + 'user/refresh_access'
|
|
16
|
+
await fetch(refreshTokenUrl, {
|
|
17
|
+
method: 'POST',
|
|
18
|
+
body: JSON.stringify({
|
|
19
|
+
access_token: this.accessToken,
|
|
20
|
+
refresh_token: refreshToken
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**SERVER IMPLEMENTATION** (StoneScriptPHP `RefreshRoute.php`):
|
|
26
|
+
```php
|
|
27
|
+
// Default route: POST /auth/refresh
|
|
28
|
+
// OR custom: AuthRoutes::register($router, ['prefix' => '/api/auth']);
|
|
29
|
+
|
|
30
|
+
// Expected request:
|
|
31
|
+
// - Refresh token comes from httpOnly cookie (NOT request body)
|
|
32
|
+
// - CSRF token required in X-CSRF-Token header
|
|
33
|
+
// - Does NOT accept tokens in request body for security
|
|
34
|
+
|
|
35
|
+
// Response:
|
|
36
|
+
{
|
|
37
|
+
"status": "ok",
|
|
38
|
+
"data": {
|
|
39
|
+
"access_token": "eyJ...",
|
|
40
|
+
"expires_in": 900,
|
|
41
|
+
"token_type": "Bearer"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Issues Identified
|
|
47
|
+
|
|
48
|
+
#### 1. **Endpoint Path Mismatch**
|
|
49
|
+
- **Client expects**: `/user/refresh_access`
|
|
50
|
+
- **Server provides**: `/auth/refresh` (default) or custom prefix
|
|
51
|
+
|
|
52
|
+
#### 2. **Token Transmission Mismatch**
|
|
53
|
+
- **Client sends**: Tokens in JSON request body
|
|
54
|
+
- **Server expects**:
|
|
55
|
+
- Refresh token in httpOnly cookie (named `refresh_token`)
|
|
56
|
+
- CSRF token in `X-CSRF-Token` header
|
|
57
|
+
- **Does NOT read tokens from request body**
|
|
58
|
+
|
|
59
|
+
#### 3. **Security Model Mismatch**
|
|
60
|
+
- **Client**: Stores tokens in localStorage/sessionStorage (via TokenService)
|
|
61
|
+
- **Server**: Uses httpOnly cookies + CSRF protection (XSS-safe)
|
|
62
|
+
|
|
63
|
+
#### 4. **Response Format Mismatch**
|
|
64
|
+
- **Client expects**: `response.data.access_token`
|
|
65
|
+
- **Server returns**: `ApiResponse` where data is the second parameter:
|
|
66
|
+
```php
|
|
67
|
+
return new ApiResponse('ok', [
|
|
68
|
+
'access_token' => $token,
|
|
69
|
+
'expires_in' => 900,
|
|
70
|
+
'token_type' => 'Bearer'
|
|
71
|
+
]);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Authentication Flow Analysis
|
|
77
|
+
|
|
78
|
+
### StoneScriptPHP Framework Auth System
|
|
79
|
+
|
|
80
|
+
The framework provides **two authentication modes**:
|
|
81
|
+
|
|
82
|
+
#### Mode 1: Built-in Cookie-Based Auth (Secure, Recommended)
|
|
83
|
+
Located in `/src/Auth/Routes/`:
|
|
84
|
+
- `POST /auth/refresh` - Refresh access token using httpOnly cookies
|
|
85
|
+
- `POST /auth/logout` - Logout and invalidate refresh token
|
|
86
|
+
|
|
87
|
+
**Security Features**:
|
|
88
|
+
- httpOnly cookies prevent XSS attacks
|
|
89
|
+
- CSRF token protection
|
|
90
|
+
- Refresh token rotation
|
|
91
|
+
- Optional token blacklisting via `TokenStorageInterface`
|
|
92
|
+
|
|
93
|
+
**Registration**:
|
|
94
|
+
```php
|
|
95
|
+
// In your index.php or bootstrap
|
|
96
|
+
use StoneScriptPHP\Auth\AuthRoutes;
|
|
97
|
+
|
|
98
|
+
AuthRoutes::register($router, [
|
|
99
|
+
'prefix' => '/auth', // or '/api/auth'
|
|
100
|
+
'token_storage' => $tokenStorage // optional
|
|
101
|
+
]);
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### Mode 2: Custom Implementation (Templates)
|
|
105
|
+
Located in `/src/Templates/Auth/`:
|
|
106
|
+
- `email-password/LoginRoute.php.template`
|
|
107
|
+
- `email-password/RegisterRoute.php.template`
|
|
108
|
+
- `email-password/PasswordResetRoute.php.template`
|
|
109
|
+
- `mobile-otp/SendOtpRoute.php.template`
|
|
110
|
+
- And more...
|
|
111
|
+
|
|
112
|
+
**Note**: Templates are **scaffolding code** that developers customize. They show:
|
|
113
|
+
- Example status values: `'success'` vs `'ok'` (inconsistent!)
|
|
114
|
+
- Example token format
|
|
115
|
+
- Database queries
|
|
116
|
+
- But are NOT the actual built-in implementation
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Current Client Implementation Analysis
|
|
121
|
+
|
|
122
|
+
### What Works ✅
|
|
123
|
+
|
|
124
|
+
1. **HTTP Methods**: All match (GET, POST, PUT, PATCH, DELETE)
|
|
125
|
+
2. **ApiResponse Structure**: Compatible
|
|
126
|
+
- Client expects: `{ status: string, message: string, data: any }`
|
|
127
|
+
- Server returns: Same structure
|
|
128
|
+
3. **Bearer Token Authentication**: Client correctly adds `Authorization: Bearer {token}`
|
|
129
|
+
4. **Automatic 401 Retry**: Client attempts token refresh on 401 errors
|
|
130
|
+
|
|
131
|
+
### What's Broken ❌
|
|
132
|
+
|
|
133
|
+
1. **Token Refresh Flow**: Completely incompatible
|
|
134
|
+
- Different endpoint paths
|
|
135
|
+
- Different token transmission method
|
|
136
|
+
- Different security model
|
|
137
|
+
|
|
138
|
+
2. **AuthService**: Empty placeholder (no implementation)
|
|
139
|
+
|
|
140
|
+
3. **Login/Register Endpoints**: Not standardized
|
|
141
|
+
- Templates show `/api/auth/login` but customizable
|
|
142
|
+
- Response format varies (some templates use `'success'` vs `'ok'`)
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Compatibility Matrix
|
|
147
|
+
|
|
148
|
+
| Feature | Client (v0.0.13) | Framework (v2.1.x) | Compatible? |
|
|
149
|
+
|---------|------------------|-------------------|-------------|
|
|
150
|
+
| **HTTP Methods** | GET, POST, PUT, PATCH, DELETE | All supported | ✅ Yes |
|
|
151
|
+
| **ApiResponse Format** | `{status, message, data}` | Same | ✅ Yes |
|
|
152
|
+
| **Bearer Auth** | `Authorization: Bearer {token}` | Same | ✅ Yes |
|
|
153
|
+
| **Token Refresh Endpoint** | `/user/refresh_access` | `/auth/refresh` | ❌ No |
|
|
154
|
+
| **Token Storage** | localStorage | httpOnly cookies | ❌ No |
|
|
155
|
+
| **CSRF Protection** | Not implemented | Required | ❌ No |
|
|
156
|
+
| **Login Endpoint** | Not defined | Custom (templates) | ⚠️ Varies |
|
|
157
|
+
| **Token Format** | JWT in response body | JWT in cookie + body | ⚠️ Partial |
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Recommended Solutions
|
|
162
|
+
|
|
163
|
+
### Option 1: Update Client to Match Framework (Recommended)
|
|
164
|
+
|
|
165
|
+
**Pros**:
|
|
166
|
+
- Better security (httpOnly cookies)
|
|
167
|
+
- CSRF protection
|
|
168
|
+
- Aligns with framework best practices
|
|
169
|
+
|
|
170
|
+
**Cons**:
|
|
171
|
+
- Breaking change for existing users
|
|
172
|
+
- Requires cookie handling
|
|
173
|
+
|
|
174
|
+
**Implementation**:
|
|
175
|
+
1. Update `refreshAccessToken()` to:
|
|
176
|
+
- Call `POST /auth/refresh` with credentials: 'include'
|
|
177
|
+
- Send CSRF token from cookie
|
|
178
|
+
- Don't send tokens in body
|
|
179
|
+
2. Add `CsrfService` to manage CSRF tokens
|
|
180
|
+
3. Update `TokenService` to work with cookies
|
|
181
|
+
4. Add cookie configuration to `MyEnvironmentModel`
|
|
182
|
+
|
|
183
|
+
### Option 2: Add Server-Side Compatibility Endpoint
|
|
184
|
+
|
|
185
|
+
**Pros**:
|
|
186
|
+
- No client breaking changes
|
|
187
|
+
- Backward compatible
|
|
188
|
+
|
|
189
|
+
**Cons**:
|
|
190
|
+
- Less secure (tokens in body)
|
|
191
|
+
- Developers must implement it
|
|
192
|
+
|
|
193
|
+
**Implementation**:
|
|
194
|
+
Create custom route in StoneScriptPHP project:
|
|
195
|
+
```php
|
|
196
|
+
// src/App/Routes/LegacyRefreshRoute.php
|
|
197
|
+
class LegacyRefreshRoute implements IRouteHandler {
|
|
198
|
+
public function process(): ApiResponse {
|
|
199
|
+
// Read tokens from request body
|
|
200
|
+
$accessToken = request()->input['access_token'] ?? null;
|
|
201
|
+
$refreshToken = request()->input['refresh_token'] ?? null;
|
|
202
|
+
|
|
203
|
+
// Verify and refresh...
|
|
204
|
+
// Return new access token
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Register in routes.php
|
|
209
|
+
'POST' => [
|
|
210
|
+
'/user/refresh_access' => LegacyRefreshRoute::class
|
|
211
|
+
]
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Option 3: Make Client Configurable
|
|
215
|
+
|
|
216
|
+
**Pros**:
|
|
217
|
+
- Supports both modes
|
|
218
|
+
- Migration path
|
|
219
|
+
|
|
220
|
+
**Cons**:
|
|
221
|
+
- More complex
|
|
222
|
+
- Maintenance burden
|
|
223
|
+
|
|
224
|
+
**Implementation**:
|
|
225
|
+
```typescript
|
|
226
|
+
export interface AuthConfig {
|
|
227
|
+
mode: 'cookie' | 'body';
|
|
228
|
+
refreshEndpoint: string;
|
|
229
|
+
useCsrf: boolean;
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Migration Path for Existing Apps
|
|
236
|
+
|
|
237
|
+
For apps currently using the client with custom backends:
|
|
238
|
+
|
|
239
|
+
### Step 1: Check Your Backend Auth Implementation
|
|
240
|
+
```bash
|
|
241
|
+
# Does your backend match the client's expectations?
|
|
242
|
+
curl -X POST http://localhost:8000/user/refresh_access \
|
|
243
|
+
-H "Content-Type: application/json" \
|
|
244
|
+
-d '{"access_token": "...", "refresh_token": "..."}'
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Step 2: Update to StoneScriptPHP v2.1.x Auth
|
|
248
|
+
```php
|
|
249
|
+
// Option A: Use built-in secure auth
|
|
250
|
+
AuthRoutes::register($router, ['prefix' => '/api/auth']);
|
|
251
|
+
|
|
252
|
+
// Option B: Create legacy compatibility route
|
|
253
|
+
// See Option 2 above
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Step 3: Update Client Configuration
|
|
257
|
+
```typescript
|
|
258
|
+
// Wait for v0.0.14+ with auth config support
|
|
259
|
+
// OR implement custom auth service extending ApiConnectionService
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## Action Items for Next Release (v0.0.14)
|
|
265
|
+
|
|
266
|
+
### Must Fix (Breaking Changes Acceptable):
|
|
267
|
+
1. ✅ Add configurable auth endpoints
|
|
268
|
+
2. ✅ Implement cookie-based auth mode
|
|
269
|
+
3. ✅ Add CSRF token support
|
|
270
|
+
4. ✅ Update AuthService with actual implementation
|
|
271
|
+
5. ✅ Document both auth modes
|
|
272
|
+
|
|
273
|
+
### Should Have:
|
|
274
|
+
1. Add login/register/logout helper methods
|
|
275
|
+
2. Add auth state management (RxJS)
|
|
276
|
+
3. Add auth guards/interceptors examples
|
|
277
|
+
4. Create migration guide with code examples
|
|
278
|
+
|
|
279
|
+
### Nice to Have:
|
|
280
|
+
1. Social auth helpers (Google, etc.)
|
|
281
|
+
2. Password reset flow helpers
|
|
282
|
+
3. Email verification helpers
|
|
283
|
+
4. Multi-factor auth support
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## Conclusion
|
|
288
|
+
|
|
289
|
+
**Current Status**: ❌ **NOT FULLY COMPATIBLE**
|
|
290
|
+
|
|
291
|
+
The v0.0.13 client library is **compatible for general API calls** (CRUD operations) but **incompatible for authentication flows**.
|
|
292
|
+
|
|
293
|
+
### For Developers:
|
|
294
|
+
- ✅ Use for: CRUD API calls with manually managed auth
|
|
295
|
+
- ❌ Don't use: Built-in token refresh (broken)
|
|
296
|
+
- ⚠️ Workaround: Implement custom refresh logic or wait for v0.0.14
|
|
297
|
+
|
|
298
|
+
### For Package Maintainers:
|
|
299
|
+
- 🔴 **Priority**: Fix auth compatibility before promoting package
|
|
300
|
+
- 📝 Add clear warnings in README about auth limitations
|
|
301
|
+
- 🚀 Plan v0.0.14 with breaking changes to align with framework
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## References
|
|
306
|
+
|
|
307
|
+
- **StoneScriptPHP Auth**: `/src/Auth/Routes/RefreshRoute.php`
|
|
308
|
+
- **Client Auth**: `/projects/ngx-stonescriptphp-client/src/lib/api-connection.service.ts`
|
|
309
|
+
- **Framework Version**: v2.1.x (on Packagist)
|
|
310
|
+
- **Client Version**: v0.0.13
|