Skip to content

Commit

Permalink
🔄 synced file(s) with circlefin/w3s-pw-web-sdk-internal (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
superandydong authored May 9, 2024
2 parents 77af4e8 + 57c8a7f commit de07e65
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@circle-fin/w3s-pw-web-sdk",
"version": "1.0.9",
"version": "1.0.13",
"description": "Javascript/Typescript SDK for Circle Programmable Wallets",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
15 changes: 15 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type {
Challenge,
ChallengeCompleteCallback,
CustomLinks,
DeviceInfo,
Localizations,
PostMessageEvent,
Resources,
Expand All @@ -26,6 +27,8 @@ import type {
ThemeColor,
} from './types'

const packageInfo = require('../package.json') as { version: string }

export class W3SSdk {
private readonly serviceUrl = 'https://pw-auth.circle.com'
private static instance: W3SSdk | null = null
Expand All @@ -42,6 +45,7 @@ export class W3SSdk {
private resources?: Resources
private customLinks?: CustomLinks
private ssoSettings?: SsoSettings
private deviceInfo?: DeviceInfo
/**
* Callback function that is called when the challenge is completed.
*/
Expand All @@ -62,13 +66,23 @@ export class W3SSdk {
private rejectDeviceIdPromise?: (reason: string) => void

constructor() {
const version = packageInfo.version

if (W3SSdk.instance != null) {
this.iframe = W3SSdk.instance.iframe
this.deviceInfo = {
model: 'Web',
version,
}

return W3SSdk.instance
}

this.iframe = document.createElement('iframe')
this.deviceInfo = {
model: 'Web',
version,
}

W3SSdk.instance = this
}
Expand Down Expand Up @@ -309,6 +323,7 @@ export class W3SSdk {
customLinks: this.customLinks,
ssoSettings: this.ssoSettings,
},
deviceInfo: this.deviceInfo,
},
},
this.serviceUrl
Expand Down
37 changes: 36 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,15 @@ export enum ErrorCode {
biometricsUserLockoutPermanent = 155714,
biometricsUserNotAllowPermission = 155715,
biometricsInternalError = 155716,
invalidUserSecret= 155718,
walletIdNotFound = 156001,
tokenIdNotFound = 156002,
transactionIdNotFound = 156003,
entityCredentialNotFound = 156004,
walletSetIdNotFound = 156005,

userSecretMissing = 155717,
invalidUserSecret = 155718,
userTokenMismatch = 155719,
}

// Settings and Authentication
Expand Down Expand Up @@ -165,6 +168,18 @@ export interface Challenge {
userSecret?: string
}

// Device Information
export interface DeviceInfo {
/**
* SDK type.
*/
model: string
/**
* SDK version.
*/
version: string
}

/**
* Base challenge result interface. Holds the challenge type and status.
*/
Expand Down Expand Up @@ -216,6 +231,18 @@ export interface SignTransactionResult extends ChallengeResult {
* Signed transaction.
*/
signedTransaction: string
/**
* The `v` field of the elliptic curve signature. It is used to calculate the public key.
*/
v?: string
/**
* The `r` field of the elliptic curve signature. It is part of the actual signature along with the `s` field.
*/
r?: string
/**
* The `s` field of the elliptic curve signature. It is part of the actual signature along with the `r` field.
*/
s?: string
}
}

Expand Down Expand Up @@ -408,6 +435,14 @@ export interface ThemeColor {
* Fill color for inputted pincode input dot, e.g. '#0000ff' or 'blue'.
*/
pinDotActivated?: string
/**
* Text color for entered pincode input, e.g. `'#000000'` or `'black'`.
*/
enteredPinText?: string
/**
* Text color for text input, e.g. '#000000' or 'black'.
*/
inputText?: string
/**
* Outline color for text input on focused, e.g. '#0000ff' or 'blue'.
*/
Expand Down

0 comments on commit de07e65

Please sign in to comment.