@genesislcap/foundation-auth 14.340.1 → 14.340.2

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.
@@ -14,9 +14,13 @@ export declare class TermsConditions extends BaseRoute {
14
14
  pdfDataUrl: string;
15
15
  isContentValid: boolean;
16
16
  private http;
17
+ private objectUrl;
17
18
  connectedCallback(): Promise<void>;
18
- private isBase64Pdf;
19
+ disconnectedCallback(): Promise<void>;
20
+ private decodeBase64Pdf;
19
21
  private createPdfDataUrl;
22
+ private createObjectUrlFromPdfBytes;
23
+ private tryLoadPdfBlob;
20
24
  loadTermsAndConditions(): Promise<void>;
21
25
  onSubmit(): Promise<void>;
22
26
  get headingText(): string;
@@ -1 +1 @@
1
- {"version":3,"file":"terms-conditions.d.ts","sourceRoot":"","sources":["../../../../src/routes/terms-conditions/terms-conditions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC;;;;;;GAMG;AACH,qBAmCa,eAAgB,SAAQ,SAAS;IAChC,WAAW,EAAE,OAAO,CAAS;IAC7B,SAAS,EAAE,MAAM,CAAqC;IACtD,YAAY,EAAE,MAAM,CAAM;IAC1B,SAAS,EAAE,OAAO,CAAS;IAC3B,UAAU,EAAE,MAAM,CAAM;IACxB,cAAc,EAAE,OAAO,CAAQ;IACrC,OAAO,CAAC,IAAI,CAAO;IAEnB,iBAAiB;IAKvB,OAAO,CAAC,WAAW;IAmBnB,OAAO,CAAC,gBAAgB;IAWlB,sBAAsB;IA+CtB,QAAQ;IASd,IACI,WAAW,WAEd;CACF"}
1
+ {"version":3,"file":"terms-conditions.d.ts","sourceRoot":"","sources":["../../../../src/routes/terms-conditions/terms-conditions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC;;;;;;GAMG;AACH,qBAmCa,eAAgB,SAAQ,SAAS;IAChC,WAAW,EAAE,OAAO,CAAS;IAC7B,SAAS,EAAE,MAAM,CAAqC;IACtD,YAAY,EAAE,MAAM,CAAM;IAC1B,SAAS,EAAE,OAAO,CAAS;IAC3B,UAAU,EAAE,MAAM,CAAM;IACxB,cAAc,EAAE,OAAO,CAAQ;IACrC,OAAO,CAAC,IAAI,CAAO;IACzB,OAAO,CAAC,SAAS,CAAuB;IAElC,iBAAiB;IAKjB,oBAAoB;IAQ1B,OAAO,CAAC,eAAe;IAkBvB,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,2BAA2B;YAiBrB,cAAc;IA8BtB,sBAAsB;IAyDtB,QAAQ;IASd,IACI,WAAW,WAEd;CACF"}
@@ -21,6 +21,7 @@ let TermsConditions = class TermsConditions extends BaseRoute {
21
21
  this.isPdfData = false;
22
22
  this.pdfDataUrl = '';
23
23
  this.isContentValid = true;
24
+ this.objectUrl = null;
24
25
  }
25
26
  connectedCallback() {
26
27
  const _super = Object.create(null, {
@@ -31,23 +32,38 @@ let TermsConditions = class TermsConditions extends BaseRoute {
31
32
  yield this.loadTermsAndConditions();
32
33
  });
33
34
  }
34
- isBase64Pdf(content) {
35
- // Check if content looks like base64 encoded PDF data
36
- // PDF files start with specific base64 patterns
35
+ disconnectedCallback() {
36
+ const _super = Object.create(null, {
37
+ disconnectedCallback: { get: () => super.disconnectedCallback }
38
+ });
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ var _a;
41
+ if (this.objectUrl) {
42
+ URL.revokeObjectURL(this.objectUrl);
43
+ this.objectUrl = null;
44
+ }
45
+ (_a = _super.disconnectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
46
+ });
47
+ }
48
+ decodeBase64Pdf(content) {
49
+ // Decode once and validate PDF header ("%PDF")
37
50
  if (!content || typeof content !== 'string')
38
- return false;
39
- // Remove any whitespace and check if it's base64
51
+ return null;
40
52
  const cleanContent = content.trim();
41
53
  if (cleanContent.length < 100)
42
- return false; // Too short to be a meaningful PDF
43
- // Check if it's valid base64
54
+ return null;
44
55
  try {
45
- const decoded = atob(cleanContent);
46
- // Check if decoded content starts with PDF signature (%PDF)
47
- return decoded.startsWith('%PDF');
56
+ const binary = atob(cleanContent);
57
+ if (binary.length < 4)
58
+ return null;
59
+ if (!binary.startsWith('%PDF')) {
60
+ return null;
61
+ }
62
+ const bytes = Uint8Array.from(binary, (c) => c.charCodeAt(0));
63
+ return bytes;
48
64
  }
49
65
  catch (_a) {
50
- return false;
66
+ return null;
51
67
  }
52
68
  }
53
69
  createPdfDataUrl(base64Content) {
@@ -61,40 +77,98 @@ let TermsConditions = class TermsConditions extends BaseRoute {
61
77
  return '';
62
78
  }
63
79
  }
64
- loadTermsAndConditions() {
80
+ createObjectUrlFromPdfBytes(pdfBytes) {
81
+ try {
82
+ const arrayBuffer = new ArrayBuffer(pdfBytes.byteLength);
83
+ new Uint8Array(arrayBuffer).set(pdfBytes);
84
+ const blob = new Blob([arrayBuffer], { type: 'application/pdf' });
85
+ if (this.objectUrl) {
86
+ URL.revokeObjectURL(this.objectUrl);
87
+ this.objectUrl = null;
88
+ }
89
+ this.objectUrl = URL.createObjectURL(blob);
90
+ return `${this.objectUrl}#toolbar=0`;
91
+ }
92
+ catch (error) {
93
+ logger.error('Failed to create object URL from PDF bytes:', error);
94
+ return '';
95
+ }
96
+ }
97
+ tryLoadPdfBlob(userName) {
65
98
  return __awaiter(this, void 0, void 0, function* () {
66
99
  try {
67
- const url = `gwf/auth/terms-and-conditions`;
68
- const userName = this.store.formEntry.orgUsername || this.store.formEntry.username;
69
- logger.debug('Loading terms and conditions for user:', userName);
70
- const data = yield this.http.get(url, {
100
+ const res = yield fetch('gwf/auth/terms-and-conditions', {
101
+ method: 'GET',
71
102
  headers: {
72
- Accept: 'application/json',
103
+ Accept: 'application/pdf',
73
104
  ['USER_NAME']: userName,
74
105
  },
106
+ credentials: 'include',
75
107
  });
76
- logger.debug('Terms and conditions response:', data);
77
- const record = Array.isArray(data) ? data[0] : data;
78
- const content = (record === null || record === void 0 ? void 0 : record.CONTENT) || '';
79
- // Check if content is base64 encoded PDF data
80
- if (this.isBase64Pdf(content)) {
108
+ if (!res.ok)
109
+ return false;
110
+ const contentType = res.headers.get('content-type') || '';
111
+ if (!contentType.includes('application/pdf'))
112
+ return false;
113
+ const blob = yield res.blob();
114
+ if (this.objectUrl) {
115
+ URL.revokeObjectURL(this.objectUrl);
116
+ this.objectUrl = null;
117
+ }
118
+ this.objectUrl = URL.createObjectURL(blob);
119
+ this.pdfDataUrl = `${this.objectUrl}#toolbar=0`;
120
+ return true;
121
+ }
122
+ catch (err) {
123
+ logger.debug('PDF blob fetch path failed:', err);
124
+ return false;
125
+ }
126
+ });
127
+ }
128
+ loadTermsAndConditions() {
129
+ return __awaiter(this, void 0, void 0, function* () {
130
+ try {
131
+ const url = `gwf/auth/terms-and-conditions`;
132
+ const userName = this.store.formEntry.orgUsername || this.store.formEntry.username;
133
+ logger.debug('Loading terms and conditions for user:', userName);
134
+ const loadedViaBlob = yield this.tryLoadPdfBlob(userName);
135
+ if (loadedViaBlob) {
81
136
  this.isPdfData = true;
82
- this.pdfDataUrl = this.createPdfDataUrl(content);
83
137
  this.termsText = 'PDF Terms and Conditions loaded';
84
138
  this.isContentValid = true;
85
- logger.debug('PDF content loaded successfully');
139
+ logger.debug('PDF content loaded successfully (blob)');
86
140
  }
87
141
  else {
88
- this.isPdfData = false;
89
- this.pdfDataUrl = '';
90
- this.termsText = content || 'No terms and conditions available';
91
- this.isContentValid = !!(content && content.trim().length > 0);
92
- logger.debug('Text content loaded:', {
93
- hasContent: !!content,
94
- contentLength: content === null || content === void 0 ? void 0 : content.length,
142
+ const data = yield this.http.get(url, {
143
+ headers: {
144
+ Accept: 'application/json',
145
+ ['USER_NAME']: userName,
146
+ },
95
147
  });
148
+ logger.debug('Terms and conditions response:', data);
149
+ const record = Array.isArray(data) ? data[0] : data;
150
+ const content = (record === null || record === void 0 ? void 0 : record.CONTENT) || '';
151
+ const pdfBytes = this.decodeBase64Pdf(content);
152
+ if (pdfBytes) {
153
+ this.isPdfData = true;
154
+ this.pdfDataUrl =
155
+ this.createObjectUrlFromPdfBytes(pdfBytes) || this.createPdfDataUrl(content);
156
+ this.termsText = 'PDF Terms and Conditions loaded';
157
+ this.isContentValid = true;
158
+ logger.debug('PDF content loaded successfully (base64)');
159
+ }
160
+ else {
161
+ this.isPdfData = false;
162
+ this.pdfDataUrl = '';
163
+ this.termsText = content || 'No terms and conditions available';
164
+ this.isContentValid = !!(content && content.trim().length > 0);
165
+ logger.debug('Text content loaded:', {
166
+ hasContent: !!content,
167
+ contentLength: content === null || content === void 0 ? void 0 : content.length,
168
+ });
169
+ }
170
+ this.termsVersion = (record === null || record === void 0 ? void 0 : record.VERSION) || '';
96
171
  }
97
- this.termsVersion = (record === null || record === void 0 ? void 0 : record.VERSION) || '';
98
172
  }
99
173
  catch (error) {
100
174
  logger.debug('Failed to load terms and conditions:', error);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/foundation-auth",
3
3
  "description": "Genesis Foundation Auth",
4
- "version": "14.340.1",
4
+ "version": "14.340.2",
5
5
  "license": "SEE LICENSE IN license.txt",
6
6
  "main": "dist/esm/index.js",
7
7
  "types": "dist/foundation-auth.d.ts",
@@ -127,25 +127,25 @@
127
127
  }
128
128
  },
129
129
  "devDependencies": {
130
- "@genesislcap/foundation-testing": "14.340.1",
131
- "@genesislcap/genx": "14.340.1",
132
- "@genesislcap/rollup-builder": "14.340.1",
133
- "@genesislcap/ts-builder": "14.340.1",
134
- "@genesislcap/uvu-playwright-builder": "14.340.1",
135
- "@genesislcap/vite-builder": "14.340.1",
136
- "@genesislcap/webpack-builder": "14.340.1"
130
+ "@genesislcap/foundation-testing": "14.340.2",
131
+ "@genesislcap/genx": "14.340.2",
132
+ "@genesislcap/rollup-builder": "14.340.2",
133
+ "@genesislcap/ts-builder": "14.340.2",
134
+ "@genesislcap/uvu-playwright-builder": "14.340.2",
135
+ "@genesislcap/vite-builder": "14.340.2",
136
+ "@genesislcap/webpack-builder": "14.340.2"
137
137
  },
138
138
  "dependencies": {
139
- "@genesislcap/foundation-comms": "14.340.1",
140
- "@genesislcap/foundation-events": "14.340.1",
141
- "@genesislcap/foundation-i18n": "14.340.1",
142
- "@genesislcap/foundation-logger": "14.340.1",
143
- "@genesislcap/foundation-state-machine": "14.340.1",
144
- "@genesislcap/foundation-store": "14.340.1",
145
- "@genesislcap/foundation-ui": "14.340.1",
146
- "@genesislcap/foundation-user": "14.340.1",
147
- "@genesislcap/foundation-utils": "14.340.1",
148
- "@genesislcap/foundation-zero": "14.340.1",
139
+ "@genesislcap/foundation-comms": "14.340.2",
140
+ "@genesislcap/foundation-events": "14.340.2",
141
+ "@genesislcap/foundation-i18n": "14.340.2",
142
+ "@genesislcap/foundation-logger": "14.340.2",
143
+ "@genesislcap/foundation-state-machine": "14.340.2",
144
+ "@genesislcap/foundation-store": "14.340.2",
145
+ "@genesislcap/foundation-ui": "14.340.2",
146
+ "@genesislcap/foundation-user": "14.340.2",
147
+ "@genesislcap/foundation-utils": "14.340.2",
148
+ "@genesislcap/foundation-zero": "14.340.2",
149
149
  "@microsoft/fast-components": "2.30.6",
150
150
  "@microsoft/fast-element": "1.14.0",
151
151
  "@microsoft/fast-foundation": "2.49.6",
@@ -165,5 +165,5 @@
165
165
  "publishConfig": {
166
166
  "access": "public"
167
167
  },
168
- "gitHead": "015b5150fa0edaeedd7712fc35c38328396c0119"
168
+ "gitHead": "7ecf7deac0a7c374998a9e1823ea2b637aacc452"
169
169
  }