Skip to content
This repository was archived by the owner on Aug 20, 2026. It is now read-only.

Commit 4efabb0

Browse files
committed
Bump versions
1 parent 59f9014 commit 4efabb0

21 files changed

Lines changed: 181 additions & 51 deletions

File tree

packages/aws-sdk-http-handler/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"@smithy/querystring-builder": "^4.2.14",
3737
"@smithy/types": "^4.14.1",
3838
"axios": "^1.13.2",
39-
"slates": "1.0.0-rc.9"
39+
"slates": "1.0.0-rc.10"
4040
},
4141
"devDependencies": {
4242
"@slates/tsconfig": "1.0.0-rc.1",

packages/cli/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@slates/cli",
3-
"version": "1.0.0-rc.4",
3+
"version": "1.0.0-rc.5",
44
"publishConfig": {
55
"access": "public"
66
},
@@ -25,9 +25,9 @@
2525
},
2626
"dependencies": {
2727
"@inquirer/prompts": "^7.4.0",
28-
"@slates/client": "1.0.0-rc.6",
29-
"@slates/oauth-microsoft": "1.0.0-rc.1",
30-
"@slates/profiles": "1.0.0-rc.4",
28+
"@slates/client": "1.0.0-rc.7",
29+
"@slates/oauth-microsoft": "1.0.0-rc.2",
30+
"@slates/profiles": "1.0.0-rc.5",
3131
"sade": "^1.8.1"
3232
},
3333
"devDependencies": {

packages/client/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@slates/client",
3-
"version": "1.0.0-rc.6",
3+
"version": "1.0.0-rc.7",
44
"publishConfig": {
55
"access": "public"
66
},
@@ -31,9 +31,9 @@
3131
"typecheck": "tsc --noEmit"
3232
},
3333
"dependencies": {
34-
"@slates/proto": "1.0.0-rc.8",
35-
"@slates/provider": "1.0.0-rc.10",
36-
"@slates/provider-handler": "1.0.0-rc.9"
34+
"@slates/proto": "1.0.0-rc.9",
35+
"@slates/provider": "1.0.0-rc.11",
36+
"@slates/provider-handler": "1.0.0-rc.10"
3737
},
3838
"devDependencies": {
3939
"@slates/tsconfig": "1.0.0-rc.1",

packages/oauth-microsoft/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@slates/oauth-microsoft",
3-
"version": "1.0.0-rc.1",
3+
"version": "1.0.0-rc.2",
44
"publishConfig": {
55
"access": "public"
66
},
@@ -31,7 +31,7 @@
3131
"typecheck": "tsc --noEmit"
3232
},
3333
"dependencies": {
34-
"slates": "1.0.0-rc.9"
34+
"slates": "1.0.0-rc.10"
3535
},
3636
"devDependencies": {
3737
"@types/node": "^20",

packages/profiles/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@slates/profiles",
3-
"version": "1.0.0-rc.4",
3+
"version": "1.0.0-rc.5",
44
"publishConfig": {
55
"access": "public"
66
},
@@ -31,11 +31,11 @@
3131
"typecheck": "tsc --noEmit"
3232
},
3333
"dependencies": {
34-
"@slates/client": "1.0.0-rc.6",
35-
"@slates/proto": "1.0.0-rc.8"
34+
"@slates/client": "1.0.0-rc.7",
35+
"@slates/proto": "1.0.0-rc.9"
3636
},
3737
"devDependencies": {
38-
"@slates/provider": "1.0.0-rc.10",
38+
"@slates/provider": "1.0.0-rc.11",
3939
"@slates/tsconfig": "1.0.0-rc.1",
4040
"typescript": "5.8.2",
4141
"vitest": "^3.1.2",

packages/profiles/src/client.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,24 @@ export let createSlatesClientFromProfile = async (
7070

7171
let EXPIRY_BUFFER_MS = 60 * 1000;
7272

73-
let shouldRefreshOAuthAuth = (auth: SlatesStoredAuth) => {
74-
if (auth.authType !== 'auth.oauth') return false;
75-
if (!auth.clientId || !auth.clientSecret) return false;
76-
if (typeof auth.output?.refreshToken !== 'string' || !auth.output.refreshToken) return false;
73+
let hasExpiredOrExpiringOutput = (auth: SlatesStoredAuth) => {
7774
if (typeof auth.output?.expiresAt !== 'string' || !auth.output.expiresAt) return false;
7875

7976
let expiresAt = Date.parse(auth.output.expiresAt);
8077
return Number.isFinite(expiresAt) && expiresAt <= Date.now() + EXPIRY_BUFFER_MS;
8178
};
8279

80+
let shouldRefreshAuth = (auth: SlatesStoredAuth) => {
81+
if (!hasExpiredOrExpiringOutput(auth)) return false;
82+
83+
if (auth.authType === 'auth.oauth') {
84+
if (!auth.clientId || !auth.clientSecret) return false;
85+
if (typeof auth.output?.refreshToken !== 'string' || !auth.output.refreshToken) return false;
86+
}
87+
88+
return true;
89+
};
90+
8391
let attachAutoRefresh = (
8492
client: ReturnType<typeof createSlatesClient>,
8593
profile: SlatesProfileRecord,
@@ -95,7 +103,7 @@ let attachAutoRefresh = (
95103
return;
96104
}
97105

98-
if (!shouldRefreshOAuthAuth(storedAuth)) {
106+
if (!shouldRefreshAuth(storedAuth)) {
99107
return;
100108
}
101109

packages/profiles/src/store.test.ts

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,4 +413,115 @@ export let provider = Slate.create({
413413
token: 'expired-token-refreshed'
414414
});
415415
});
416+
417+
it('refreshes expired custom auth automatically in the profile-backed client', async () => {
418+
let cwd = await createTempDir();
419+
let entry = path.join(cwd, 'custom-slate.mjs');
420+
await writeFile(
421+
entry,
422+
`
423+
import { Slate, SlateAuth, SlateConfig, SlateSpecification, SlateTool } from '@slates/provider';
424+
import { z } from 'zod';
425+
426+
let config = SlateConfig.create(z.object({})).getDefaultConfig(() => ({}));
427+
let auth = SlateAuth.create()
428+
.output(
429+
z.object({
430+
token: z.string(),
431+
expiresAt: z.string().optional()
432+
})
433+
)
434+
.addCustomAuth({
435+
type: 'auth.custom',
436+
key: 'custom',
437+
name: 'Custom',
438+
inputSchema: z.object({
439+
tokenPrefix: z.string()
440+
}),
441+
getOutput: async ctx => ({
442+
output: {
443+
token: \`\${ctx.input.tokenPrefix}-initial\`,
444+
expiresAt: new Date(Date.now() + 60 * 60 * 1000).toISOString()
445+
}
446+
}),
447+
handleTokenRefresh: async ctx => ({
448+
output: {
449+
token: \`\${ctx.input.tokenPrefix}-refreshed\`,
450+
expiresAt: new Date(Date.now() + 60 * 60 * 1000).toISOString()
451+
}
452+
})
453+
});
454+
455+
let spec = SlateSpecification.create({
456+
key: 'custom-demo',
457+
name: 'Custom Demo',
458+
description: 'Custom auth test slate',
459+
config,
460+
auth
461+
});
462+
463+
let tool = SlateTool.create(spec, {
464+
key: 'whoami',
465+
name: 'Who Am I'
466+
})
467+
.input(z.object({}))
468+
.output(
469+
z.object({
470+
token: z.string()
471+
})
472+
)
473+
.handleInvocation(async ctx => ({
474+
output: {
475+
token: ctx.auth.token
476+
}
477+
}))
478+
.build();
479+
480+
export let provider = Slate.create({
481+
spec,
482+
tools: [tool],
483+
triggers: []
484+
});
485+
`,
486+
'utf-8'
487+
);
488+
489+
let store = await SlatesCliStore.open({
490+
cwd,
491+
scope: {
492+
key: 'integrations/demo',
493+
name: 'demo'
494+
}
495+
});
496+
let profile = store.upsertProfile({
497+
name: 'Demo',
498+
target: {
499+
type: 'local',
500+
entry: './custom-slate.mjs',
501+
exportName: 'provider'
502+
}
503+
});
504+
store.setProfileConfig(profile.id, {});
505+
store.upsertAuth(profile.id, {
506+
authMethodId: 'custom',
507+
authType: 'auth.custom',
508+
input: {
509+
tokenPrefix: 'custom-token'
510+
},
511+
output: {
512+
token: 'expired-token',
513+
expiresAt: new Date(Date.now() - 60 * 1000).toISOString()
514+
},
515+
scopes: []
516+
});
517+
await store.save();
518+
519+
let client = await createSlatesClientFromProfile(profile, { cwd, store });
520+
let result = await client.invokeTool('whoami', {});
521+
522+
expect(result.output).toEqual({ token: 'custom-token-refreshed' });
523+
expect(store.getAuth(profile.id, 'custom')?.output).toMatchObject({
524+
token: 'custom-token-refreshed'
525+
});
526+
});
416527
});

packages/proto/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@slates/proto",
3-
"version": "1.0.0-rc.8",
3+
"version": "1.0.0-rc.9",
44
"publishConfig": {
55
"access": "public"
66
},
@@ -43,4 +43,4 @@
4343
"typescript": "5.8.2",
4444
"vitest": "^3.1.2"
4545
}
46-
}
46+
}

packages/provider-handler/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@slates/provider-handler",
3-
"version": "1.0.0-rc.9",
3+
"version": "1.0.0-rc.10",
44
"publishConfig": {
55
"access": "public"
66
},
@@ -32,8 +32,8 @@
3232
},
3333
"dependencies": {
3434
"@lowerdeck/error": "^1.1.0",
35-
"@slates/proto": "1.0.0-rc.8",
36-
"@slates/provider": "1.0.0-rc.10",
35+
"@slates/proto": "1.0.0-rc.9",
36+
"@slates/provider": "1.0.0-rc.11",
3737
"zod": "^4.2.1"
3838
},
3939
"devDependencies": {

packages/provider/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@slates/provider",
3-
"version": "1.0.0-rc.10",
3+
"version": "1.0.0-rc.11",
44
"publishConfig": {
55
"access": "public"
66
},
@@ -42,4 +42,4 @@
4242
"typescript": "5.8.2",
4343
"vitest": "^3.1.2"
4444
}
45-
}
45+
}

0 commit comments

Comments
 (0)