|
6 | 6 | import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' |
7 | 7 | import type { SetNonNullable } from 'type-fest' |
8 | 8 |
|
9 | | -import { type Client, createClient } from 'lib/seam/connect/client.js' |
| 9 | +import { |
| 10 | + type Client, |
| 11 | + type ClientOptions, |
| 12 | + createClient, |
| 13 | +} from 'lib/seam/connect/client.js' |
10 | 14 | import { |
11 | 15 | isSeamHttpOptionsWithApiKey, |
12 | 16 | isSeamHttpOptionsWithClient, |
@@ -63,6 +67,21 @@ export class SeamHttpAcsUsers { |
63 | 67 | return new SeamHttpAcsUsers(opts) |
64 | 68 | } |
65 | 69 |
|
| 70 | + static async fromPublishableKey( |
| 71 | + publishableKey: string, |
| 72 | + userIdentifierKey: string, |
| 73 | + options: ClientOptions = {}, |
| 74 | + ): Promise<SeamHttp> { |
| 75 | + const opts = parseOptions(options) |
| 76 | + const client = createClient({ ...opts, publishableKey }) |
| 77 | + const clientSessions = SeamHttpClientSessions.fromClient(client) |
| 78 | + // TODO: clientSessions.getOrCreate({ user_identifier_key: userIdentifierKey }) |
| 79 | + const { token } = await clientSessions.create({ |
| 80 | + user_identifier_key: userIdentifierKey, |
| 81 | + }) |
| 82 | + return SeamHttp.fromClientSessionToken(token, options) |
| 83 | + } |
| 84 | + |
66 | 85 | async addToAccessGroup(body: AcsUsersAddToAccessGroupBody): Promise<void> { |
67 | 86 | await this.client.request<AcsUsersAddToAccessGroupResponse>({ |
68 | 87 | url: '/acs/users/add_to_access_group', |
|
0 commit comments