1.1.0 • Published 2 years ago

@solarmosaic/sf-idp-client v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

sf-idp-client

Query the Salesforce IDP endpoints in pure Node.JS (no direct dependencies).

Usage

import { SFIDPClient } from "@solarmosaic/sf-idp-client";

const client = new SFIDPClient({
  sfidpClientId: "<your client id>",
  sfidpClientSecret: "<your client secret>",
  sfidpClientBaseUrl:
    "https://{your-salesforce-domain}.sandbox.my.site.com/services/oauth2",
});

const introspectionResult = await client.introspect(
  "<your salesforce opaque access token>"
);
/* Returns an object like:
{
  "active": true,
  "scope": "id refresh_token openid",
  "client_id": "<your client id>",
  "username": "test.contact@example.com",
  "sub": "https://test.salesforce.com/id/0000000000123456/005R00000000006789",
  "token_type": "access_token",
  "exp": 1676058616,
  "iat": 1676051416,
  "nbf": 1676051416
}
*/

const userinfoResult = await client.userinfo(
  "<your salesforce opaque access token>"
);
/* Returns an object like:
{
  "sub": "https://test.salesforce.com/id/0000000000123456/005R00000000006789",
  "user_id": "005R00000000006789",
  "organization_id": "0000000000123456",
  "preferred_username": "test@example.com",
  "nickname": "User16742547643471388208",
  "name": "Test Example",
  "email": "test@example.com",
  "email_verified": true,
  "given_name": "Test",
  "family_name": "Example",
  "zoneinfo": "GMT",
  "photos": {
    "picture": "https://{your-salesforce-domain}.sandbox.my.site.com/img/userprofile/default_profile_200_v2.png",
    "thumbnail": "https://{your-salesforce-domain}.sandbox.my.site.com/img/userprofile/default_profile_45_v2.png"
  },
  "profile": "https://{your-salesforce-domain}.sandbox.my.salesforce.com/005R000000C6iE6789",
  "picture": "https://{your-salesforce-domain}.sandbox.my.site.com/img/userprofile/default_profile_200_v2.png",
  "address": {
    "country": "United States"
  },
  "urls": {
    "enterprise": "https://{your-salesforce-domain}.sandbox.my.salesforce.com/identitypoc/services/Soap/c/{version}/0000000000123456",
    "metadata": "https://{your-salesforce-domain}.sandbox.my.salesforce.com/identitypoc/services/Soap/m/{version}/0000000000123456",
    "partner": "https://{your-salesforce-domain}.sandbox.my.salesforce.com/identitypoc/services/Soap/u/{version}/0000000000123456",
    "rest": "https://{your-salesforce-domain}.sandbox.my.salesforce.com/services/data/v{version}/",
    "sobjects": "https://{your-salesforce-domain}.sandbox.my.salesforce.com/services/data/v{version}/sobjects/",
    "search": "https://{your-salesforce-domain}.sandbox.my.salesforce.com/services/data/v{version}/search/",
    "query": "https://{your-salesforce-domain}.sandbox.my.salesforce.com/services/data/v{version}/query/",
    "recent": "https://{your-salesforce-domain}.sandbox.my.salesforce.com/services/data/v{version}/recent/",
    "tooling_soap": "https://{your-salesforce-domain}.sandbox.my.salesforce.com/identitypoc/services/Soap/T/{version}/0000000000123456",
    "tooling_rest": "https://{your-salesforce-domain}.sandbox.my.salesforce.com/services/data/v{version}/tooling/",
    "profile": "https://{your-salesforce-domain}.sandbox.my.salesforce.com/005R000000C6iE6789",
    "feeds": "https://{your-salesforce-domain}.sandbox.my.salesforce.com/services/data/v{version}/chatter/feeds",
    "groups": "https://{your-salesforce-domain}.sandbox.my.salesforce.com/services/data/v{version}/chatter/groups",
    "users": "https://{your-salesforce-domain}.sandbox.my.salesforce.com/services/data/v{version}/chatter/users",
    "feed_items": "https://{your-salesforce-domain}.sandbox.my.salesforce.com/services/data/v{version}/chatter/feed-items",
    "feed_elements": "https://{your-salesforce-domain}.sandbox.my.salesforce.com/services/data/v{version}/chatter/feed-elements",
    "custom_domain": "https://{your-salesforce-domain}.sandbox.my.salesforce.com"
  },
  "active": true,
  "language": "en_US",
  "locale": "en_US",
  "utcOffset": 0,
  "updated_at": "2023-02-10T16:04:50Z",
  "is_app_installed": true,
  "custom_attributes": {
    /// ...
  },
  "custom_permissions": {
    /// ...
  }
}
*/
1.1.0

2 years ago

1.0.0

2 years ago

0.1.0

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago