@gpt-platform/client 0.2.0 → 0.2.1
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/dist/index.d.mts +122 -68
- package/dist/index.d.ts +122 -68
- package/dist/index.js +55 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1224,7 +1224,7 @@ function buildUserAgent(sdkVersion, appInfo) {
|
|
|
1224
1224
|
}
|
|
1225
1225
|
|
|
1226
1226
|
// src/version.ts
|
|
1227
|
-
var SDK_VERSION = "0.2.
|
|
1227
|
+
var SDK_VERSION = "0.2.1";
|
|
1228
1228
|
var DEFAULT_API_VERSION = "2026-02-25";
|
|
1229
1229
|
|
|
1230
1230
|
// src/base-client.ts
|
|
@@ -4286,7 +4286,7 @@ var ChangePasswordSchema = z2.object({
|
|
|
4286
4286
|
message: "Passwords do not match",
|
|
4287
4287
|
path: ["password_confirmation"]
|
|
4288
4288
|
});
|
|
4289
|
-
function createIdentityNamespace(rb) {
|
|
4289
|
+
function createIdentityNamespace(rb, baseUrl) {
|
|
4290
4290
|
return {
|
|
4291
4291
|
/** Login with email and password — returns a token object */
|
|
4292
4292
|
login: async (email, password, options) => {
|
|
@@ -4539,6 +4539,58 @@ function createIdentityNamespace(rb) {
|
|
|
4539
4539
|
);
|
|
4540
4540
|
}
|
|
4541
4541
|
},
|
|
4542
|
+
/**
|
|
4543
|
+
* Social OAuth sign-in (Google, GitHub, Microsoft).
|
|
4544
|
+
*
|
|
4545
|
+
* This is a browser-redirect flow — the backend redirects the user's browser
|
|
4546
|
+
* to the provider, then back to your `redirectUrl` with `?token=JWT` appended.
|
|
4547
|
+
*
|
|
4548
|
+
* @example
|
|
4549
|
+
* ```typescript
|
|
4550
|
+
* // Get the URL and redirect manually
|
|
4551
|
+
* const url = client.identity.oauth.getAuthorizationUrl('google', {
|
|
4552
|
+
* appId: 'your-app-id',
|
|
4553
|
+
* redirectUrl: 'https://yourapp.com/auth/callback',
|
|
4554
|
+
* });
|
|
4555
|
+
* window.location.href = url;
|
|
4556
|
+
*
|
|
4557
|
+
* // Or use the convenience helper (browser only)
|
|
4558
|
+
* client.identity.oauth.signIn('google', {
|
|
4559
|
+
* appId: 'your-app-id',
|
|
4560
|
+
* redirectUrl: 'https://yourapp.com/auth/callback',
|
|
4561
|
+
* });
|
|
4562
|
+
*
|
|
4563
|
+
* // On your callback page, extract the token:
|
|
4564
|
+
* const token = new URLSearchParams(window.location.search).get('token');
|
|
4565
|
+
* ```
|
|
4566
|
+
*/
|
|
4567
|
+
oauth: {
|
|
4568
|
+
/**
|
|
4569
|
+
* Build the authorization URL for the given OAuth provider.
|
|
4570
|
+
* Navigate the user's browser to this URL to begin the sign-in flow.
|
|
4571
|
+
*/
|
|
4572
|
+
getAuthorizationUrl(provider, options) {
|
|
4573
|
+
const base = (baseUrl ?? "").replace(/\/$/, "");
|
|
4574
|
+
const params = { app_id: options.appId };
|
|
4575
|
+
if (options.redirectUrl) params["redirect_url"] = options.redirectUrl;
|
|
4576
|
+
return `${base}/oauth/${provider}?${new URLSearchParams(params).toString()}`;
|
|
4577
|
+
},
|
|
4578
|
+
/**
|
|
4579
|
+
* Redirect the browser to the OAuth sign-in page for the given provider.
|
|
4580
|
+
* Only works in browser environments (sets `window.location.href`).
|
|
4581
|
+
*
|
|
4582
|
+
* After the user authenticates, they are redirected back to `redirectUrl`
|
|
4583
|
+
* with a `?token=JWT` query parameter containing their session token.
|
|
4584
|
+
*/
|
|
4585
|
+
signIn(provider, options) {
|
|
4586
|
+
if (typeof window === "undefined") {
|
|
4587
|
+
throw new Error(
|
|
4588
|
+
"identity.oauth.signIn() requires a browser environment. Use identity.oauth.getAuthorizationUrl() to get the URL and redirect manually."
|
|
4589
|
+
);
|
|
4590
|
+
}
|
|
4591
|
+
window.location.href = this.getAuthorizationUrl(provider, options);
|
|
4592
|
+
}
|
|
4593
|
+
},
|
|
4542
4594
|
apiKeys: {
|
|
4543
4595
|
list: async (options) => {
|
|
4544
4596
|
return rb.execute(
|
|
@@ -6435,7 +6487,7 @@ var GptClient = class extends BaseClient {
|
|
|
6435
6487
|
this.billing = createBillingNamespace(rb);
|
|
6436
6488
|
this.communication = createCommunicationNamespace(rb);
|
|
6437
6489
|
this.extraction = createExtractionNamespace(rb);
|
|
6438
|
-
this.identity = createIdentityNamespace(rb);
|
|
6490
|
+
this.identity = createIdentityNamespace(rb, this.config?.baseUrl);
|
|
6439
6491
|
this.platform = createPlatformNamespace(rb);
|
|
6440
6492
|
this.scheduling = createSchedulingNamespace(rb);
|
|
6441
6493
|
this.search = createSearchNamespace(rb);
|