@mediaviz/sdk 0.1.0 → 1.0.60

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 (53) hide show
  1. package/LICENSE +21 -0
  2. package/dist/sdk.cjs +21 -260
  3. package/dist/sdk.esm.js +22 -259
  4. package/dist/sdk.umd.js +21 -260
  5. package/package.json +15 -1
  6. package/MediaViz.js +0 -126
  7. package/_oauth.js +0 -3
  8. package/admin.js +0 -93
  9. package/ai_model_credits.js +0 -22
  10. package/company.js +0 -54
  11. package/curated_albums.js +0 -85
  12. package/custom_albums.js +0 -78
  13. package/email_tokens.js +0 -64
  14. package/errors.js +0 -81
  15. package/health.js +0 -20
  16. package/index.js +0 -21
  17. package/keywords.js +0 -123
  18. package/oauth/.prettierrc +0 -6
  19. package/oauth/README.md +0 -76
  20. package/oauth/browser-smoke-test.html +0 -45
  21. package/oauth/implementation_plan.json +0 -106
  22. package/oauth/package-lock.json +0 -5236
  23. package/oauth/package.json +0 -28
  24. package/oauth/rollup.config.js +0 -21
  25. package/oauth/smoke-test.js +0 -27
  26. package/oauth/spec.md +0 -187
  27. package/oauth/src/__tests__/browser-smoke-test.test.js +0 -38
  28. package/oauth/src/__tests__/client.test.js +0 -556
  29. package/oauth/src/__tests__/errors.test.js +0 -73
  30. package/oauth/src/__tests__/http.test.js +0 -102
  31. package/oauth/src/__tests__/index.test.js +0 -53
  32. package/oauth/src/__tests__/package-fields.test.js +0 -29
  33. package/oauth/src/__tests__/pkce.test.js +0 -55
  34. package/oauth/src/__tests__/rollup-build.test.js +0 -58
  35. package/oauth/src/__tests__/smoke-test.test.js +0 -26
  36. package/oauth/src/__tests__/types.test.js +0 -29
  37. package/oauth/src/client.js +0 -180
  38. package/oauth/src/errors.js +0 -32
  39. package/oauth/src/http.js +0 -52
  40. package/oauth/src/index.js +0 -7
  41. package/oauth/src/pkce.js +0 -50
  42. package/oauth/src/types.js +0 -67
  43. package/oauth_authorization.js +0 -53
  44. package/oauth_clients.js +0 -18
  45. package/oauth_login.js +0 -24
  46. package/oauth_token.js +0 -30
  47. package/person.js +0 -54
  48. package/photos.js +0 -106
  49. package/photoupload.js +0 -55
  50. package/projects.js +0 -191
  51. package/rollup.config.js +0 -12
  52. package/search.js +0 -99
  53. package/users.js +0 -137
package/oauth/README.md DELETED
@@ -1,76 +0,0 @@
1
- # @yourorg/oauth-sdk
2
-
3
- JavaScript SDK for the OAuth 2.0 Authorization Server. Implements Authorization Code + PKCE flow, token refresh, token revocation, and JWT payload decoding for confidential (server-side) clients.
4
-
5
- ## Installation
6
-
7
- ```sh
8
- npm install @yourorg/oauth-sdk
9
- ```
10
-
11
- ## Quick start
12
-
13
- ```js
14
- const { OAuthClient } = require('@yourorg/oauth-sdk');
15
-
16
- const oauthClient = new OAuthClient({
17
- baseUrl: 'https://api.example.com',
18
- clientId: process.env.OAUTH_CLIENT_ID,
19
- clientSecret: process.env.OAUTH_CLIENT_SECRET,
20
- redirectUri: 'https://myapp.com/callback',
21
- });
22
-
23
- // Step 1: initiate login
24
- app.get('/login', (req, res) => {
25
- const { url, state, code_verifier } = oauthClient.generateAuthorizationUrl();
26
- req.session.oauthState = state;
27
- req.session.codeVerifier = code_verifier;
28
- res.redirect(url);
29
- });
30
-
31
- // Step 2: handle callback
32
- app.get('/callback', async (req, res) => {
33
- const { code, state } = req.query;
34
- if (state !== req.session.oauthState) throw new Error('State mismatch');
35
-
36
- const tokens = await oauthClient.exchangeCode(code, req.session.codeVerifier);
37
- const payload = oauthClient.decodeAccessToken(tokens.access_token);
38
-
39
- req.session.userId = payload.user_id;
40
- req.session.accessToken = tokens.access_token;
41
- req.session.refreshToken = tokens.refresh_token;
42
- res.redirect('/dashboard');
43
- });
44
-
45
- // Step 3: make authenticated requests
46
- app.get('/dashboard', async (req, res) => {
47
- const { data, updated_tokens } = await oauthClient.request(
48
- 'https://api.example.com/me',
49
- 'GET',
50
- req.session.accessToken,
51
- req.session.refreshToken,
52
- );
53
-
54
- if (updated_tokens) {
55
- req.session.accessToken = updated_tokens.access_token;
56
- req.session.refreshToken = updated_tokens.refresh_token;
57
- }
58
-
59
- res.json(data);
60
- });
61
- ```
62
-
63
- > **Important:** `generateAuthorizationUrl()` returns `{ url, state, code_verifier }`. You **must** persist `state` and `code_verifier` (e.g. in an encrypted server-side session or short-lived encrypted cookie) and pass `code_verifier` back to `exchangeCode()` in the callback handler. The SDK does not store any state between calls.
64
-
65
- ## Method reference
66
-
67
- | Method | Description | Returns |
68
- |--------|-------------|---------|
69
- | `generateAuthorizationUrl(state?)` | Generates PKCE verifier + challenge, builds `/oauth/authorize` URL | `AuthorizationUrlResult` |
70
- | `exchangeCode(code, codeVerifier, redirectUri?)` | Exchanges authorization code for tokens | `Promise<TokenResponse>` |
71
- | `refreshAccessToken(refreshToken)` | Issues new tokens using a refresh token | `Promise<TokenResponse>` |
72
- | `revokeToken(token, tokenTypeHint?)` | Revokes an access or refresh token (RFC 7009) | `Promise<void>` |
73
- | `decodeAccessToken(accessToken)` | Decodes JWT payload without signature verification | `TokenPayload` |
74
- | `request(url, method, accessToken, refreshToken, body?)` | Authenticated request with automatic 401 retry | `Promise<AuthenticatedResponse>` |
75
-
76
- See [spec.md](../../spec.md) for full API documentation.
@@ -1,45 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <title>OAuth SDK Browser Smoke Test</title>
6
- </head>
7
- <body>
8
- <pre id="output"></pre>
9
- <script src="dist/oauth-sdk.umd.js"></script>
10
- <script>
11
- (async () => {
12
- const log = (msg) => {
13
- document.getElementById('output').textContent += msg + '\n';
14
- console.log(msg);
15
- };
16
-
17
- try {
18
- const { OAuthClient } = OAuthSDK;
19
- const client = new OAuthClient({
20
- baseUrl: 'https://example.com',
21
- clientId: 'test-client-id',
22
- clientSecret: 'test-client-secret',
23
- redirectUri: 'https://example.com/callback',
24
- });
25
-
26
- const result = await client.generateAuthorizationUrl();
27
-
28
- if (!result.url.includes('response_type=code')) {
29
- throw new Error(`url missing response_type=code: ${result.url}`);
30
- }
31
- if (result.code_verifier.length !== 64) {
32
- throw new Error(`code_verifier length ${result.code_verifier.length} !== 64`);
33
- }
34
- if (result.state.length !== 32) {
35
- throw new Error(`state length ${result.state.length} !== 32`);
36
- }
37
-
38
- log('PASS');
39
- } catch (err) {
40
- log('FAIL: ' + err.message);
41
- }
42
- })();
43
- </script>
44
- </body>
45
- </html>
@@ -1,106 +0,0 @@
1
- [
2
- {
3
- "id": 1,
4
- "description": "Replace Node.js crypto with Web Crypto API in pkce.js. generateCodeVerifier: use globalThis.crypto.getRandomValues(new Uint8Array(48)) + manual base64url encode + slice to 64 chars. generateCodeChallenge: use globalThis.crypto.subtle.digest('SHA-256', TextEncoder) — must become async, returns Promise<string>. generateState: use getRandomValues(new Uint8Array(16)) + hex join. Remove require('crypto'). Keep module.exports unchanged.",
5
- "touch_points": [
6
- {
7
- "file": "sdk/javascript/src/pkce.js",
8
- "location": "generateCodeVerifier",
9
- "status": "replace crypto.randomBytes with getRandomValues + base64url encode"
10
- },
11
- {
12
- "file": "sdk/javascript/src/pkce.js",
13
- "location": "generateCodeChallenge",
14
- "status": "make async, replace createHash with crypto.subtle.digest"
15
- },
16
- {
17
- "file": "sdk/javascript/src/pkce.js",
18
- "location": "generateState",
19
- "status": "replace crypto.randomBytes with getRandomValues + hex join"
20
- }
21
- ],
22
- "completion_status": true
23
- },
24
- {
25
- "id": 2,
26
- "description": "Update client.js to await the now-async generateCodeChallenge. In generateAuthorizationUrl, change the call to: const challenge = await generateCodeChallenge(verifier). The method is already async so the public signature is unchanged.",
27
- "touch_points": [
28
- {
29
- "file": "sdk/javascript/src/client.js",
30
- "location": "generateAuthorizationUrl",
31
- "status": "add await before generateCodeChallenge call"
32
- }
33
- ],
34
- "completion_status": true
35
- },
36
- {
37
- "id": 3,
38
- "description": "Update pkce.test.js for async generateCodeChallenge. Change the PKCE test vector assertion to use await: expect(await generateCodeChallenge(verifier)).toBe('E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM'). Mark the test function async. All other tests are sync and unchanged.",
39
- "touch_points": [
40
- {
41
- "file": "sdk/javascript/src/__tests__/pkce.test.js",
42
- "location": "test('generateCodeChallenge')",
43
- "status": "add async/await to test vector assertion"
44
- }
45
- ],
46
- "completion_status": true
47
- },
48
- {
49
- "id": 4,
50
- "description": "Add Rollup build tooling. Install dev dependencies: rollup, @rollup/plugin-node-resolve, @rollup/plugin-terser. Create rollup.config.js at sdk/javascript/ with two outputs: (1) dist/oauth-sdk.umd.js — format: 'umd', name: 'OAuthSDK', exports: 'named', plugins: [terser()]; (2) dist/oauth-sdk.esm.js — format: 'esm'. Input: src/index.js. Use nodeResolve plugin to handle any internal references.",
51
- "touch_points": [
52
- {
53
- "file": "sdk/javascript/package.json",
54
- "location": "devDependencies",
55
- "status": "add rollup, @rollup/plugin-node-resolve, @rollup/plugin-terser"
56
- },
57
- {
58
- "file": "sdk/javascript/rollup.config.js",
59
- "location": "module",
60
- "status": "create with umd + esm output config"
61
- }
62
- ],
63
- "completion_status": true
64
- },
65
- {
66
- "id": 5,
67
- "description": "Update package.json fields. Add: 'module': 'dist/oauth-sdk.esm.js'; 'browser': 'dist/oauth-sdk.umd.js'; 'files': ['src/', 'dist/']; scripts 'build': 'rollup -c' and 'prepublishOnly': 'npm run build'. Keep 'main': 'src/index.js' for Node.js CJS path.",
68
- "touch_points": [
69
- {
70
- "file": "sdk/javascript/package.json",
71
- "location": "root",
72
- "status": "add module, browser, files fields and build scripts"
73
- }
74
- ],
75
- "completion_status": true
76
- },
77
- {
78
- "id": 6,
79
- "description": "Add dist/ to .gitignore in sdk/javascript/. Update smoke-test.js: add await to generateAuthorizationUrl call (wrap in async IIFE or top-level await if package is ESM). Verify node smoke-test.js still exits 0.",
80
- "touch_points": [
81
- {
82
- "file": "sdk/javascript/.gitignore",
83
- "location": "root",
84
- "status": "add dist/"
85
- },
86
- {
87
- "file": "sdk/javascript/smoke-test.js",
88
- "location": "main assertion block",
89
- "status": "confirm generateAuthorizationUrl is awaited (should already be)"
90
- }
91
- ],
92
- "completion_status": true
93
- },
94
- {
95
- "id": 7,
96
- "description": "Build verification. Run npm install then npm run build in sdk/javascript/. Confirm dist/oauth-sdk.umd.js and dist/oauth-sdk.esm.js are produced. Run npm test — all tests must pass. Run node smoke-test.js — must exit 0. Create sdk/javascript/browser-smoke-test.html: minimal HTML page that loads dist/oauth-sdk.umd.js via <script>, calls OAuthSDK.OAuthClient with dummy config, calls generateAuthorizationUrl(), asserts url contains 'response_type=code', logs PASS/FAIL to console.",
97
- "touch_points": [
98
- {
99
- "file": "sdk/javascript/browser-smoke-test.html",
100
- "location": "script block",
101
- "status": "create browser smoke test for UMD bundle"
102
- }
103
- ],
104
- "completion_status": true
105
- }
106
- ]