@tidecloak/js 0.13.1 → 0.13.5

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.
Files changed (48) hide show
  1. package/README.md +170 -5
  2. package/dist/cjs/lib/tidecloak.js +1759 -1629
  3. package/dist/cjs/lib/tidecloak.js.map +1 -1
  4. package/dist/cjs/src/IAMService.js +526 -32
  5. package/dist/cjs/src/IAMService.js.map +1 -1
  6. package/dist/cjs/src/index.js +4 -21
  7. package/dist/cjs/src/index.js.map +1 -1
  8. package/dist/cjs/src/policy-react.js +3 -0
  9. package/dist/cjs/src/policy-react.js.map +1 -0
  10. package/dist/cjs/src/policy.css +1 -0
  11. package/dist/cjs/src/utils/fetch.js +36 -0
  12. package/dist/cjs/src/utils/fetch.js.map +1 -0
  13. package/dist/cjs/src/utils/index.js +3 -0
  14. package/dist/cjs/src/utils/index.js.map +1 -0
  15. package/dist/cjs/src/utils/pkce.js +43 -0
  16. package/dist/cjs/src/utils/pkce.js.map +1 -0
  17. package/dist/esm/lib/tidecloak.js +1760 -1619
  18. package/dist/esm/lib/tidecloak.js.map +1 -1
  19. package/dist/esm/src/IAMService.js +523 -23
  20. package/dist/esm/src/IAMService.js.map +1 -1
  21. package/dist/esm/src/index.js +2 -6
  22. package/dist/esm/src/index.js.map +1 -1
  23. package/dist/esm/src/policy-react.js +3 -0
  24. package/dist/esm/src/policy-react.js.map +1 -0
  25. package/dist/esm/src/policy.css +1 -0
  26. package/dist/esm/src/utils/fetch.js +36 -0
  27. package/dist/esm/src/utils/fetch.js.map +1 -0
  28. package/dist/esm/src/utils/index.js +3 -0
  29. package/dist/esm/src/utils/index.js.map +1 -0
  30. package/dist/esm/src/utils/pkce.js +43 -0
  31. package/dist/esm/src/utils/pkce.js.map +1 -0
  32. package/dist/types/IAMService.d.ts +328 -0
  33. package/dist/types/index.d.ts +3 -0
  34. package/dist/types/lib/tidecloak.d.ts +325 -31
  35. package/dist/types/policy-react.d.ts +1 -0
  36. package/dist/types/src/IAMService.d.ts +245 -23
  37. package/dist/types/src/index.d.ts +2 -2
  38. package/dist/types/src/policy-react.d.ts +1 -0
  39. package/dist/types/src/utils/fetch.d.ts +11 -0
  40. package/dist/types/src/utils/index.d.ts +2 -0
  41. package/dist/types/src/utils/pkce.d.ts +24 -0
  42. package/dist/types/utils/fetch.d.ts +11 -0
  43. package/dist/types/utils/index.d.ts +2 -0
  44. package/dist/types/utils/pkce.d.ts +24 -0
  45. package/package.json +18 -29
  46. package/scripts/postinstall.cjs +36 -0
  47. package/silent-check-sso.html +1 -0
  48. package/scripts/postinstall.js +0 -43
@@ -1,3 +1,3 @@
1
- export function getHumanReadableObject(modelId: any, data: any, expiry: any): any;
2
1
  export { default as IAMService } from "./IAMService.js";
3
- export { default as TideCloak, RequestEnclave, ApprovalEnclave } from "../lib/tidecloak.js";
2
+ export { default as TideCloak, RequestEnclave, ApprovalEnclaveNew } from "../lib/tidecloak.js";
3
+ export { TideMemory, BaseTideRequest } from "heimdall-tide";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Fetch utilities for HTTP requests.
3
+ */
4
+ /**
5
+ * Fetch JSON with credentials included.
6
+ * @param {string} url - URL to fetch
7
+ * @param {RequestInit} [options={}] - Fetch options
8
+ * @returns {Promise<any>} Parsed JSON response
9
+ * @throws {Error} If request fails (with status and body properties)
10
+ */
11
+ export function fetchJson(url: string, options?: RequestInit): Promise<any>;
@@ -0,0 +1,2 @@
1
+ export { fetchJson } from "./fetch.js";
2
+ export { makePkce, randomPkceVerifier, base64UrlEncode } from "./pkce.js";
@@ -0,0 +1,24 @@
1
+ /**
2
+ * PKCE (Proof Key for Code Exchange) utilities for OAuth 2.0 authorization code flow.
3
+ */
4
+ /**
5
+ * Generate random PKCE verifier string.
6
+ * @param {number} len - Length of the verifier (default 96)
7
+ * @returns {string} Random verifier string
8
+ */
9
+ export function randomPkceVerifier(len?: number): string;
10
+ /**
11
+ * Base64 URL encode an ArrayBuffer.
12
+ * @param {ArrayBuffer} arrayBuffer - Buffer to encode
13
+ * @returns {string} Base64 URL encoded string
14
+ */
15
+ export function base64UrlEncode(arrayBuffer: ArrayBuffer): string;
16
+ /**
17
+ * Generate PKCE verifier and challenge.
18
+ * @returns {Promise<{verifier: string, challenge: string, method: string}>}
19
+ */
20
+ export function makePkce(): Promise<{
21
+ verifier: string;
22
+ challenge: string;
23
+ method: string;
24
+ }>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Fetch utilities for HTTP requests.
3
+ */
4
+ /**
5
+ * Fetch JSON with credentials included.
6
+ * @param {string} url - URL to fetch
7
+ * @param {RequestInit} [options={}] - Fetch options
8
+ * @returns {Promise<any>} Parsed JSON response
9
+ * @throws {Error} If request fails (with status and body properties)
10
+ */
11
+ export function fetchJson(url: string, options?: RequestInit): Promise<any>;
@@ -0,0 +1,2 @@
1
+ export { fetchJson } from "./fetch.js";
2
+ export { makePkce, randomPkceVerifier, base64UrlEncode } from "./pkce.js";
@@ -0,0 +1,24 @@
1
+ /**
2
+ * PKCE (Proof Key for Code Exchange) utilities for OAuth 2.0 authorization code flow.
3
+ */
4
+ /**
5
+ * Generate random PKCE verifier string.
6
+ * @param {number} len - Length of the verifier (default 96)
7
+ * @returns {string} Random verifier string
8
+ */
9
+ export function randomPkceVerifier(len?: number): string;
10
+ /**
11
+ * Base64 URL encode an ArrayBuffer.
12
+ * @param {ArrayBuffer} arrayBuffer - Buffer to encode
13
+ * @returns {string} Base64 URL encoded string
14
+ */
15
+ export function base64UrlEncode(arrayBuffer: ArrayBuffer): string;
16
+ /**
17
+ * Generate PKCE verifier and challenge.
18
+ * @returns {Promise<{verifier: string, challenge: string, method: string}>}
19
+ */
20
+ export function makePkce(): Promise<{
21
+ verifier: string;
22
+ challenge: string;
23
+ method: string;
24
+ }>;
package/package.json CHANGED
@@ -1,48 +1,37 @@
1
1
  {
2
2
  "name": "@tidecloak/js",
3
- "version": "0.13.1",
4
- "description": "TideCloak client side JS SDK",
3
+ "version": "0.13.5",
4
+ "type": "module",
5
5
  "main": "dist/cjs/src/index.js",
6
6
  "module": "dist/esm/src/index.js",
7
7
  "types": "dist/types/src/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
- "import": "./dist/esm/src/index.js",
11
10
  "types": "./dist/types/src/index.d.ts",
11
+ "import": "./dist/esm/src/index.js",
12
12
  "require": "./dist/cjs/src/index.js"
13
- }
13
+ },
14
+ "./policy-react": {
15
+ "import": "./dist/esm/src/policy-react.js",
16
+ "require": "./dist/cjs/src/policy-react.js"
17
+ },
18
+ "./policy.css": "./dist/esm/src/policy.css"
14
19
  },
15
- "files": [
16
- "dist",
17
- "scripts/postinstall.js"
18
- ],
19
20
  "scripts": {
20
- "postinstall": "node ./scripts/postinstall.js",
21
+ "postinstall": "node ./scripts/postinstall.cjs",
21
22
  "build:cjs": "tsc -p tsconfig.cjs.json",
22
23
  "build:esm": "tsc -p tsconfig.esm.json",
23
- "build": "npm run build:cjs && npm run build:esm && cp ./silent-check-sso.html dist/",
24
+ "build:types": "tsc -p tsconfig.types.json",
25
+ "build:copy-css": "node scripts/copy-css.cjs",
26
+ "build": "npm run build:cjs && npm run build:esm && npm run build:types && npm run build:copy-css && cp ./silent-check-sso.html dist/",
24
27
  "prepare": "npm run build"
25
28
  },
26
- "publishConfig": {
27
- "access": "public"
28
- },
29
- "repository": {
30
- "type": "git",
31
- "url": "git+https://github.com/tide-foundation/tidecloak-js.git"
32
- },
33
- "author": "Tide",
34
- "homepage": "https://tide.org",
35
- "license": "https://tide.org/licenses_tcoc2-0-0-en",
36
- "keywords": [
37
- "security",
38
- "tidecloak",
39
- "tide",
40
- "authentication",
41
- "oidc",
42
- "oauth2",
43
- "authorization"
29
+ "files": [
30
+ "dist",
31
+ "scripts/postinstall.cjs",
32
+ "silent-check-sso.html"
44
33
  ],
45
34
  "dependencies": {
46
- "heimdall-tide": "^0.13.1"
35
+ "heimdall-tide": "^0.13.5"
47
36
  }
48
37
  }
@@ -0,0 +1,36 @@
1
+ // scripts/postinstall.cjs (CommonJS)
2
+ const { copyFileSync, existsSync, mkdirSync } = require('node:fs');
3
+ const path = require('node:path');
4
+
5
+ // npm sets INIT_CWD to the *consumer* project root that ran `npm i`
6
+ const initCwd = process.env.INIT_CWD || process.cwd();
7
+ const pkgRoot = __dirname ? path.resolve(__dirname, '..') : process.cwd();
8
+
9
+ // where the file should end up in the *consumer* app
10
+ const targetDir = path.join(initCwd, 'public');
11
+ const targetFile = path.join(targetDir, 'silent-check-sso.html');
12
+
13
+ // possible sources inside this package
14
+ const distSrc = path.join(pkgRoot, 'dist', 'silent-check-sso.html');
15
+ const srcSrc = path.join(pkgRoot, 'silent-check-sso.html');
16
+
17
+ // no-op if the consumer doesn't have a public/ folder
18
+ if (!existsSync(targetDir)) {
19
+ console.log('[tidecloak-js] No public/ directory in consumer, skipping copy.');
20
+ process.exit(0);
21
+ }
22
+
23
+ // find a source file to copy
24
+ let source = null;
25
+ if (existsSync(distSrc)) source = distSrc;
26
+ else if (existsSync(srcSrc)) source = srcSrc;
27
+
28
+ if (!source) {
29
+ console.log('[tidecloak-js] silent-check-sso.html not found in package, skipping copy.');
30
+ process.exit(0);
31
+ }
32
+
33
+ // ensure target dir exists and copy
34
+ mkdirSync(targetDir, { recursive: true });
35
+ copyFileSync(source, targetFile);
36
+ console.log(`[tidecloak-js] Copied ${path.basename(source)} → ${targetFile}`);
@@ -0,0 +1 @@
1
+ <html><body><script>parent.postMessage(location.href, location.origin)</script></body></html>
@@ -1,43 +0,0 @@
1
- #!/usr/bin/env node
2
- const { copyFileSync, existsSync, mkdirSync } = require('fs');
3
- const { join, dirname, sep } = require('path');
4
-
5
- // find the nearest package.json upwards, but skip anything inside node_modules
6
- function findProjectRoot(startDir) {
7
- let dir = startDir;
8
- while (dir !== dirname(dir)) {
9
- // if we're inside node_modules, ignore this level
10
- if (!dir.split(sep).includes('node_modules') &&
11
- existsSync(join(dir, 'package.json'))) {
12
- return dir;
13
- }
14
- dir = dirname(dir);
15
- }
16
- return null;
17
- }
18
-
19
- // where npm/yarn was invoked (if available)
20
- const initialCwd = process.env.INIT_CWD || process.cwd();
21
-
22
- // find the first non-node_modules package.json above that
23
- const projectRoot = findProjectRoot(initialCwd) || process.cwd();
24
-
25
- // now build paths
26
- const pkgRoot = join(__dirname, '..');
27
- const source = join(pkgRoot, 'dist', 'silent-check-sso.html');
28
- const destDir = join(projectRoot, 'public');
29
- const destFile = join(destDir, 'silent-check-sso.html');
30
-
31
- // debug logging—remove in production
32
- console.log(`[tidecloak-js] initialCwd: ${initialCwd}`);
33
- console.log(`[tidecloak-js] projectRoot: ${projectRoot}`);
34
-
35
- // ensure public/ exists
36
- if (!existsSync(destDir)) {
37
- mkdirSync(destDir, { recursive: true });
38
- console.log(`[tidecloak-js] created directory ${destDir}`);
39
- }
40
-
41
- // copy the HTML file
42
- copyFileSync(source, destFile);
43
- console.log(`[tidecloak-js] copied silent-check-sso.html → ${destDir}/`);