TrademarkTrademark
Ctrl k
Search docs...
Sdk

Typescript

Last update: August 25, 2025
Thumbnail of Typescript
npm versionnpm downloads
TypeScript SDK for Go IAM - A lightweight Identity and Access Management server.
Bash
npm install @goiam/typescript
# or
pnpm add @goiam/typescript
# or
yarn add @goiam/typescript
Typescript
import { GoIamSdk } from '@goiam/typescript';

const sdk = new GoIamSdk('https://go-iam.example.com', 'your-client-id', 'your-secret');
Typescript
try {
  const token = await sdk.verify('auth-code');
  console.log('Access Token:', token);
} catch (error) {
  console.error('Failed to verify code:', error);
}
Typescript
try {
  const user = await sdk.me(token);
  console.log('User:', user);
} catch (error) {
  console.error('Failed to fetch user information:', error);
}
Typescript
const resource = {
  id: 'resource-id',
  name: 'Resource Name',
  description: 'Resource Description',
  key: 'resource-key',
  enabled: true,
  projectId: 'project-id',
  createdBy: 'creator',
  updatedBy: 'updater',
};

try {
  await sdk.createResource(resource, token);
  console.log('Resource created successfully');
} catch (error) {
  console.error('Failed to create resource:', error);
}
The SDK exports the following TypeScript interfaces:
Typescript
interface User {
  id: string;
  projectId: string;
  name: string;
  email: string;
  phone: string;
  enabled: boolean;
  profile_pic: string;
  expiry?: string;
  roles: Record<string, UserRole>;
  resources: Record<string, UserResource>;
  policies: Record<string, UserPolicy>;
  created_at?: string;
  created_by: string;
  updated_at?: string;
  updated_by: string;
}

interface UserPolicy {
  name: string;
  mapping: UserPolicyMapping;
}

interface UserPolicyMapping {
  arguments: Record<string, UserPolicyMappingValue>;
}

interface UserPolicyMappingValue {
  static: string;
}

interface UserRole {
  id: string;
  name: string;
}

interface UserResource {
  role_ids: { [key: string]: boolean };
  policy_ids: { [key: string]: boolean };
  key: string;
  name: string;
}
Typescript
interface Resource {
  id: string;
  name: string;
  description: string;
  key: string;
  enabled: boolean;
  projectId: string;
  createdAt?: string;
  createdBy: string;
  updatedAt?: string;
  updatedBy: string;
  deletedAt?: string;
}
The SDK methods throw errors with descriptive messages. It's recommended to wrap API calls in try-catch blocks:
Typescript
try {
  const result = await sdk.verify('code');
  // Handle success
} catch (error) {
  console.error('API Error:', error.message);
  // Handle error
}
On this page
© 2025 Go IAM. Open source under Apache 2.0 License.