@choiceform/shared-auth 0.1.4 → 0.1.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.
package/README.md CHANGED
@@ -487,11 +487,6 @@ A: 不配置 `VITE_AUTH_API_URL` 环境变量即可。功能会静默跳过。
487
487
 
488
488
  ## 更新日志
489
489
 
490
- ### v0.1.4
491
-
492
- - 🔧 改进:移除所有 token 编码,保持与 URL 传入的 token 格式完全一致
493
- - 📝 改进:所有 API 请求中的 token 不再进行 `encodeURIComponent` 编码
494
-
495
490
  ### v0.1.2
496
491
 
497
492
  - ✨ 新增:登录时自动获取并设置伴生团队功能
@@ -1 +1 @@
1
- {"version":3,"file":"auth-sync.d.ts","sourceRoot":"","sources":["../../src/components/auth-sync.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAoS3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,QA0FxD"}
1
+ {"version":3,"file":"auth-sync.d.ts","sourceRoot":"","sources":["../../src/components/auth-sync.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAuS3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,QA0FxD"}
@@ -114,14 +114,16 @@ async function setupCompanionTeam(auth, token, refetchSession) {
114
114
  }
115
115
  return;
116
116
  }
117
- // 4. 获取组织信息
117
+ // 4. Token 编码(与 fetchSessionWithToken 保持一致)
118
+ const encodedToken = encodeURIComponent(oneAuthToken);
119
+ // 5. 获取组织信息
118
120
  const myOrganizationUrl = `${oneAuthBaseUrl}/v1/organizations/me`;
119
121
  if (isDev) {
120
122
  console.log("[AuthSync] Fetching organization from:", myOrganizationUrl);
121
123
  }
122
124
  const orgResponse = await fetch(myOrganizationUrl, {
123
125
  headers: {
124
- Authorization: `Bearer ${oneAuthToken}`,
126
+ Authorization: `Bearer ${encodedToken}`,
125
127
  "Content-Type": "application/json",
126
128
  },
127
129
  });
@@ -156,7 +158,7 @@ async function setupCompanionTeam(auth, token, refetchSession) {
156
158
  const setActiveOrgResponse = await fetch(setActiveOrgUrl, {
157
159
  method: "POST",
158
160
  headers: {
159
- Authorization: `Bearer ${oneAuthToken}`,
161
+ Authorization: `Bearer ${encodedToken}`,
160
162
  "Content-Type": "application/json",
161
163
  },
162
164
  body: JSON.stringify({ organizationId: organization.id }),
@@ -176,7 +178,7 @@ async function setupCompanionTeam(auth, token, refetchSession) {
176
178
  const setActiveTeamResponse = await fetch(setActiveTeamUrl, {
177
179
  method: "POST",
178
180
  headers: {
179
- Authorization: `Bearer ${oneAuthToken}`,
181
+ Authorization: `Bearer ${encodedToken}`,
180
182
  "Content-Type": "application/json",
181
183
  },
182
184
  body: JSON.stringify({ teamId: firstTeam.id }),
@@ -197,7 +199,7 @@ async function setupCompanionTeam(auth, token, refetchSession) {
197
199
  const getSessionUrl = `${authBaseURL}/v1/auth/get-session`;
198
200
  const sessionResponse = await fetch(getSessionUrl, {
199
201
  headers: {
200
- Authorization: `Bearer ${oneAuthToken}`,
202
+ Authorization: `Bearer ${encodedToken}`,
201
203
  "Content-Type": "application/json",
202
204
  },
203
205
  });
@@ -104,7 +104,7 @@ export function createAuthActions(authStore, tokenStorage, config, authClient) {
104
104
  const response = await fetch(endpoint, {
105
105
  method: "GET",
106
106
  headers: {
107
- Authorization: `Bearer ${token}`,
107
+ Authorization: `Bearer ${encodeURIComponent(token)}`,
108
108
  "Content-Type": "application/json",
109
109
  },
110
110
  });
@@ -1 +1 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/store/state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE;;;oBAuBnD,MAAM,GAAG,IAAI;eAclB,MAAM,GAAG,IAAI;;;EAavB;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,cAAc,CAAC,CAAA"}
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/store/state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE;;;oBAyBnD,MAAM,GAAG,IAAI;eAelB,MAAM,GAAG,IAAI;;;EAavB;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,cAAc,CAAC,CAAA"}
@@ -7,7 +7,10 @@ export function createAuthStore(config) {
7
7
  // 从 localStorage 读取初始 token
8
8
  const getStoredToken = () => {
9
9
  try {
10
- return localStorage.getItem(tokenStorageKey);
10
+ const stored = localStorage.getItem(tokenStorageKey);
11
+ if (!stored)
12
+ return null;
13
+ return decodeURIComponent(stored);
11
14
  }
12
15
  catch {
13
16
  return null;
@@ -26,7 +29,8 @@ export function createAuthStore(config) {
26
29
  save(token) {
27
30
  try {
28
31
  if (token) {
29
- localStorage.setItem(tokenStorageKey, token);
32
+ const encodedToken = encodeURIComponent(token);
33
+ localStorage.setItem(tokenStorageKey, encodedToken);
30
34
  authStore.token.set(token);
31
35
  }
32
36
  else {
@@ -89,7 +89,7 @@ export async function getAuthHeaders(authStore, tokenStorage, authActions, authC
89
89
  return {};
90
90
  }
91
91
  return {
92
- Authorization: `Bearer ${token}`,
92
+ Authorization: `Bearer ${encodeURIComponent(token)}`,
93
93
  };
94
94
  }
95
95
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@choiceform/shared-auth",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Shared authentication package for Choiceform projects",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -16,6 +16,12 @@
16
16
  "dist",
17
17
  "README.md"
18
18
  ],
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "dev": "tsc --watch",
22
+ "clean": "rimraf dist",
23
+ "prepublishOnly": "pnpm run build"
24
+ },
19
25
  "repository": {
20
26
  "type": "git",
21
27
  "url": "git+https://github.com/choiceform/automation.git",
@@ -51,10 +57,6 @@
51
57
  "@types/react-dom": "18.2.22",
52
58
  "typescript": "^5.5.3",
53
59
  "rimraf": "^6.0.1"
54
- },
55
- "scripts": {
56
- "build": "tsc",
57
- "dev": "tsc --watch",
58
- "clean": "rimraf dist"
59
60
  }
60
- }
61
+ }
62
+
package/LICENSE.md DELETED
@@ -1,149 +0,0 @@
1
- # License
2
-
3
- Portions of this software are licensed as follows:
4
-
5
- - Content of branches other than the main branch are not licensed.
6
- - Source code files that contain `.ee.` in their filename or `.ee` in their directory name are NOT licensed under the Sustainable Use License. To use source code files that contain `.ee.` in their filename or `.ee` in their directory name you must hold a valid Rungraf Enterprise License specifically allowing you access to such source code files and as defined in "LICENSE_EE.md".
7
- - All third party components incorporated into the Rungraf software are licensed under the original license provided by the owner of the applicable component.
8
- - Content outside of the above mentioned files or restrictions is available under the "Sustainable Use License" as defined below.
9
-
10
- ---
11
-
12
- ## Sustainable Use License
13
-
14
- **Version 1.0**
15
-
16
- ### Acceptance
17
-
18
- By using the software, you agree to all of the terms and conditions below.
19
-
20
- ### Copyright License
21
-
22
- The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations below.
23
-
24
- ### Limitations
25
-
26
- You may use or modify the software only for your own internal business purposes or for non-commercial or personal use. You may distribute the software or provide it to others only if you do so free of charge for non-commercial purposes. You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor's trademarks is subject to applicable law.
27
-
28
- ### Patents
29
-
30
- The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
31
-
32
- ### Notices
33
-
34
- You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms. If you modify the software, you must include in any modified copies of the software a prominent notice stating that you have modified the software.
35
-
36
- ### No Other Rights
37
-
38
- These terms do not imply any licenses other than those expressly granted in these terms.
39
-
40
- ### Termination
41
-
42
- If you use the software in violation of these terms, such use is not licensed, and your license will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your license will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your license to terminate automatically and permanently.
43
-
44
- ### No Liability
45
-
46
- As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
47
-
48
- ### Definitions
49
-
50
- - The **"licensor"** is the entity offering these terms, which is the Rungraf project and its contributors.
51
-
52
- - The **"software"** is the software the licensor makes available under these terms, including any portion of it.
53
-
54
- - **"You"** refers to the individual or entity agreeing to these terms.
55
-
56
- - **"Your company"** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. Control means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
57
-
58
- - **"Your license"** is the license granted to you for the software under these terms.
59
-
60
- - **"Use"** means anything you do with the software requiring your license.
61
-
62
- - **"Trademark"** means trademarks, service marks, and similar rights.
63
-
64
- ---
65
-
66
- ## Additional Terms for Rungraf
67
-
68
- In addition to the Sustainable Use License terms above, the following specific limitations apply to Rungraf:
69
-
70
- ### Multi-Tenant SaaS Restriction
71
-
72
- You may NOT use Rungraf to operate a multi-tenant Software-as-a-Service (SaaS) offering where you provide Rungraf as a hosted service to multiple external customers or organizations, unless you obtain a separate commercial license from the Rungraf project.
73
-
74
- **Examples of PROHIBITED use without commercial license:**
75
- - Operating "AI Agent Platform as a Service" for multiple paying customers
76
- - Providing Rungraf as a white-labeled workflow automation service
77
- - Running a marketplace where multiple organizations build AI Agents on your hosted Rungraf instance
78
-
79
- **Examples of PERMITTED use:**
80
- - Deploying Rungraf within your organization for your employees and internal use
81
- - Embedding Rungraf in your product where each customer gets their own dedicated Rungraf instance
82
- - Using Rungraf as a backend service for your own application (single-tenant)
83
-
84
- **Workspace Definition:** Within Rungraf, one workspace represents one tenant. A workspace provides an isolated environment for each tenant's AI Agents, workflows, data, and configurations.
85
-
86
- ### Branding and Attribution
87
-
88
- When using Rungraf's frontend interface, you may not remove, alter, or obscure the Rungraf logo, branding, or copyright notices displayed in the user interface. This restriction applies only to the visual frontend components.
89
-
90
- **Frontend Definition:** The "frontend" of Rungraf includes all components located in the `packages/client/` directory when running from source code, or the "client" Docker image when running via containers.
91
-
92
- **Examples of PERMITTED use:**
93
- - Using only Rungraf's backend APIs with your own custom frontend (no branding requirement)
94
- - Forking and customizing the codebase while maintaining attribution
95
- - White-labeling with a separate commercial license
96
-
97
- **Examples of PROHIBITED use:**
98
- - Using the Rungraf frontend with logos and branding removed
99
- - Distributing modified versions without proper attribution
100
-
101
- ### Core Engine Protection
102
-
103
- The Rungraf AI Agent Runtime (located in `packages/runner/`) and Expression Engine may be used and modified for your own purposes, but you may NOT:
104
-
105
- - Extract the Agent Runtime as a standalone product and sell it separately
106
- - Use Rungraf's core orchestration engine to build a competing workflow automation platform for sale
107
- - Offer the Expression Engine as a standalone commercial service
108
-
109
- **Examples of PERMITTED use:**
110
- - Integrating Rungraf into your product's backend
111
- - Modifying the runtime for your specific use case
112
- - Contributing improvements back to the open source project
113
-
114
- **Examples of PROHIBITED use:**
115
- - Packaging the Elixir Agent Runtime as "SuperAgent Engine" and selling it
116
- - Building a competitor workflow platform using Rungraf's core code
117
-
118
- ---
119
-
120
- ## Fair Code Principles
121
-
122
- Rungraf follows the [Fair Code](https://faircode.io) principles. We believe in:
123
-
124
- 1. **Transparency**: Source code is publicly available for review and contribution
125
- 2. **Sustainability**: Protecting the project's ability to fund ongoing development
126
- 3. **Community**: Encouraging contributions while preventing exploitation
127
- 4. **Freedom**: Allowing use for internal business purposes and non-commercial projects
128
-
129
- ---
130
-
131
- ## Getting a Commercial License
132
-
133
- If your use case falls under the restrictions above, you can obtain a commercial Rungraf Enterprise License. Enterprise licenses include:
134
-
135
- - Multi-tenant SaaS deployment rights
136
- - White-labeling permissions
137
- - Priority support and SLA guarantees
138
- - Enterprise features (SSO, advanced RBAC, audit logs)
139
- - Custom development support
140
-
141
- Contact us for enterprise licensing:
142
- - **Email**: [enterprise@rungraf.io](mailto:enterprise@rungraf.io)
143
- - **Website**: [https://rungraf.io/enterprise](https://rungraf.io/enterprise)
144
-
145
- ---
146
-
147
- **© 2024-2025 Rungraf Project**
148
-
149
- This software is provided "as is", without warranty of any kind, express or implied.